| xqd
@@ -219,6 +219,8 @@ class AlbumController extends Controller
|
|
|
$user_agent = AlbumAgentModel::where('id',$add_record['agent_id'])->first();
|
|
|
//dd($user_agent);
|
|
|
if($user_agent){
|
|
|
+ $user_agent->get_count++;
|
|
|
+ $user_agent->save();
|
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
|
try{
|
|
|
$this->sendLogsMessage($datas['store_id'],$agent->open_id,4,$userAuth->username);
|
| xqd
@@ -2005,6 +2007,68 @@ class AlbumController extends Controller
|
|
|
* 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
*/
|
|
|
public function albumCustomerGoods(Request $request)
|
|
|
+ {
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ ],[
|
|
|
+ 'store_id.required'=>'缺少商户参数',
|
|
|
+ ]);
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
+ }
|
|
|
+ $store_id = $request->input('store_id');
|
|
|
+ if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ if($user_agent) $res= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['agent_id',$user_agent->id]])->groupBy('detail')->get('detail');
|
|
|
+ $arr = array();
|
|
|
+ foreach ($res as $key=>$val){
|
|
|
+ $detail = json_decode($val['detail'],true);
|
|
|
+ //dd($detail);die;
|
|
|
+ $goods_id = $detail['goods_id'];
|
|
|
+ $goods = AlbumProductModel::where([['id',$goods_id]])->first();
|
|
|
+ if($goods){
|
|
|
+ $count= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['detail',$detail]])->count();
|
|
|
+ $arr[] = ['name'=>$goods->name,'count'=>$count];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this->api($arr,0,'success');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {get} /api/album/customer-goods-detail 获取客户浏览商品详细(customer-goods-detail)
|
|
|
+ * @apiDescription 获取客户浏览商品详细(customer-goods-detail)
|
|
|
+ * @apiGroup Album
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data":[
|
|
|
+ * {
|
|
|
+ * "name":
|
|
|
+ * "time":
|
|
|
+ * "style":
|
|
|
+ * "cat":
|
|
|
+ * },
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function albumCustomerGoodsDetail(Request $request)
|
|
|
{
|
|
|
$userAuth = Auth('api')->user();
|
|
|
if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
| xqd
@@ -2022,7 +2086,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();
|
|
|
- if($user_agent) $res= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id]])->get();
|
|
|
+ if($user_agent) $res= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->get('detail','created_at')->toArray();
|
|
|
$arr = array();
|
|
|
foreach ($res as $key=>$val){
|
|
|
$detail = json_decode($val['detail'],true);
|
| xqd
@@ -2030,8 +2094,9 @@ class AlbumController extends Controller
|
|
|
$goods_id = $detail['goods_id'];
|
|
|
$goods = AlbumProductModel::where([['id',$goods_id]])->first();
|
|
|
if($goods){
|
|
|
- $count= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['detail',$detail]])->count();
|
|
|
- $arr[] = ['name'=>$goods->name,'count'=>$count];
|
|
|
+ $style = AlbumProductStyleModel::where([['store_id',$store_id],['id',$goods->style]])->first();
|
|
|
+ $cat = AlbumCatModel::where([['store_id',$store_id],['id',$goods->cat_id]])->first();
|
|
|
+ $arr[] = ['name'=>$goods->name,'time'=>date('Y-m-d-h',strtotime($val['created_at'])),'style'=>$style->name,'cat'=>$cat->name];
|
|
|
}
|
|
|
}
|
|
|
return $this->api($arr,0,'success');
|