| xqd
@@ -384,6 +384,13 @@ class AlbumController extends Controller
|
|
|
$goods->where('style',$style);
|
|
|
}
|
|
|
|
|
|
+ if ($userAuth->up_agent_id != 0) {
|
|
|
+ $agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
+ $set_show_price = $agent->is_show_ma_price;
|
|
|
+ } else {
|
|
|
+ $set_show_price = 0;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
$goods = $goods->select('id','cover_pic','thumb','name','style','hot_cake','news','price_default')->orderByDesc('sort')->paginate(9);
|
|
|
|
| xqd
@@ -412,7 +419,7 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$data =AlbumManufacturerModel::where('store_id',$store_id)->first();
|
|
|
$name = $data['name'];
|
|
|
- return $this->api(compact('goods','name'));
|
|
|
+ return $this->api(compact('goods','name','set_show_price'));
|
|
|
}
|
|
|
|
|
|
|
| xqd
@@ -2072,7 +2079,7 @@ class AlbumController extends Controller
|
|
|
$open_id = $request->input('open_id');
|
|
|
|
|
|
if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
- $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
$customer = CustomerDetailsModel::where([['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->first(['purpose_level','comment','tips','address']);
|
|
|
if(!empty($customer)){
|
|
|
$user = AlbumUserModel::where([['store_id',$store_id],['open_id',$open_id]])->first();
|
| xqd
@@ -2584,4 +2591,72 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
return $this->api(compact('res'));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {post} /api/album/agent_price_set 厂家价格设置(agent_price_set)
|
|
|
+ * @apiDescription 厂家价格设置(agent_price_set)
|
|
|
+ * @apiGroup Album
|
|
|
+ * @apiPermission AUTH
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} [store_id] 商户id
|
|
|
+ * @apiParam {int} [point] 价格设置比例 为0不设置
|
|
|
+ * @apiParam {int} [is_show_ma_price] 厂家价格是否可见 0 不可见 1 可见
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "success",
|
|
|
+ * "data":[]
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function albumAgentPriceSet(Request $request)
|
|
|
+ {
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'is_show_ma_price' => 'required',
|
|
|
+ 'store_id' => 'required',
|
|
|
+ 'point' => 'required',
|
|
|
+ ],[
|
|
|
+ 'is_show_ma_price.required'=>'缺少设置参数',
|
|
|
+ 'store_id.required' => '缺少store参数',
|
|
|
+ 'point.required'=>'缺少比例参数',
|
|
|
+ ]);
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
+ }
|
|
|
+ $data = $request->input();
|
|
|
+ if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ $user_agent->is_show_ma_price = $data['is_show_ma_price'];
|
|
|
+ $user_agent->save();
|
|
|
+ if ($data['point'] != 0) {
|
|
|
+ $product = AlbumProductModel::where('store_id',$data['store_id'])->all('id','price_default');
|
|
|
+ foreach ($product as $key=>$val) {
|
|
|
+ $save['price'] = $val['price_default'] * $data['point']/100;
|
|
|
+ $check = AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
+ if(empty($check)){
|
|
|
+ $save['agent_id'] = $user_agent->id;
|
|
|
+ $save['store_id'] = $data['store_id'];
|
|
|
+ $save['product_id'] = $val['id'];
|
|
|
+ AlbumProductPriceModel::create($save);
|
|
|
+ }else{
|
|
|
+ AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this->api([],0,'success');
|
|
|
+ }
|
|
|
}
|