|
@@ -57,20 +57,20 @@ class ShopController extends Controller {
|
|
|
'shop_id'=>'integer',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
- return $this->jsonError($validator->errors()->first());
|
|
|
+ return $this->response->error($validator->errors()->first(), 500);
|
|
|
+ }
|
|
|
+ if($data['account'] && empty($data['shop_id'])){
|
|
|
+ $shop_account = ShopAccount::where(['account'=>$data['account']])->first();
|
|
|
+ if($shop_account){
|
|
|
+ return $this->jsonError('该账号已存在,请重新输入');
|
|
|
+ }
|
|
|
}
|
|
|
-// if($data['account']){
|
|
|
-// $shop_account = ShopAccount::where(['account'=>$data['account']])->first();
|
|
|
-// if($shop_account){
|
|
|
-// return $this->jsonError('该账号已存在,请重新输入');
|
|
|
-// }
|
|
|
-// }
|
|
|
$shopRepository = new ShopRepository();
|
|
|
$res = $shopRepository->saveShopAccount($data);
|
|
|
if($res){
|
|
|
- return $this->jsonSuccess();
|
|
|
+ return ['message' => '成功','status_code' => 200];
|
|
|
}else{
|
|
|
- return $this->jsonError('添加失败');
|
|
|
+ return $this->response->error("失败", 500);
|
|
|
}
|
|
|
}
|
|
|
//详情
|
|
@@ -81,17 +81,12 @@ class ShopController extends Controller {
|
|
|
'shop_id' => 'required|integer',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
- return $this->jsonError($validator->errors()->first());
|
|
|
+ return $this->response->error($validator->errors()->first(), 500);
|
|
|
}
|
|
|
$shop = Shop::where(['shop_id'=>$data['shop_id']])->first();
|
|
|
$fractal = new Manager();
|
|
|
$res = new Item($shop,new ShopsTransformer());
|
|
|
- $data = $fractal->createData($res)->toArray();
|
|
|
- if($data){
|
|
|
- return $this->jsonSuccess($data);
|
|
|
- }else{
|
|
|
- return $this->jsonError("操作失败");
|
|
|
- }
|
|
|
+ return $fractal->createData($res)->toArray();
|
|
|
}
|
|
|
//列表
|
|
|
public function list(Request $request){
|