| xqd
@@ -20,6 +20,7 @@ use App\Models\AlbumProductStyleModel;
|
|
|
use App\Models\AlbumUserModel;
|
|
|
use App\Models\AlbumWatchRecord;
|
|
|
use App\Models\AlbumXyxUserModel;
|
|
|
+use App\Models\CustomerCatRecordModel;
|
|
|
use App\User;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
| xqd
@@ -431,6 +432,12 @@ class AlbumController extends Controller
|
|
|
$add_record['store_id'] = $store_id;
|
|
|
$add_record['detail'] = json_encode($select_info);
|
|
|
AlbumWatchRecord::create($add_record);
|
|
|
+ $cat_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
+ $cat_record['open_id'] = $userAuth->wechat_open_id;
|
|
|
+ $cat_record['store_id'] = $store_id;
|
|
|
+ $cat_record['style_id'] = $style;
|
|
|
+ $cat_record['cat_id'] = $cat_id;
|
|
|
+ CustomerCatRecordModel::create($cat_record);
|
|
|
$user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
|
try{
|
| xqd
@@ -846,6 +853,7 @@ class AlbumController extends Controller
|
|
|
* {
|
|
|
* "1": [
|
|
|
* 'name':'asdawd',
|
|
|
+ * 'point':'asdawd',
|
|
|
* 'num':'1',
|
|
|
* ],
|
|
|
* }
|
| xqd
@@ -880,6 +888,7 @@ class AlbumController extends Controller
|
|
|
$user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
$res = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['action',3]])->get();
|
|
|
$arr = array();
|
|
|
+ $total = 0;
|
|
|
foreach($res as $key=>$val){
|
|
|
$goods_data = json_decode($val->detail,true);
|
|
|
$goods_id = $goods_data['goods_id'];
|
| xqd
@@ -890,11 +899,82 @@ class AlbumController extends Controller
|
|
|
$arr[$goods->id]['num']=1;
|
|
|
$arr[$goods->id]['name']=$goods->name;
|
|
|
}
|
|
|
-
|
|
|
+ $total++;
|
|
|
+ }
|
|
|
+ foreach($arr as $key=>$val){
|
|
|
+ $arr[$key]['point'] = ($val['num']/$total*100).'%';
|
|
|
}
|
|
|
return $this->api(compact('arr'));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {post} /api/album/get_data_cat 获取分类访问数据(get_data_cat)
|
|
|
+ * @apiDescription 获取分类访问数据(get_data_cat)
|
|
|
+ * @apiGroup Album
|
|
|
+ * @apiPermission 需要登录
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} [store_id] 商户id 模拟值为0
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": [
|
|
|
+ * {
|
|
|
+ * "1": [
|
|
|
+ * 'name':'asdawd',
|
|
|
+ * 'point':'asdawd',
|
|
|
+ * 'num':'1',
|
|
|
+ * ],
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function albumGetDataCat(Request $request)
|
|
|
+ {
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ 'style_id' => 'required'
|
|
|
+ ],[
|
|
|
+ 'store_id.required'=>'缺少商户参数',
|
|
|
+ 'style_id.required'=>'缺少风格参数',
|
|
|
+ ]);
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
+ }
|
|
|
+ $store_id = $request->input('store_id');
|
|
|
+ $style_id = $request->input('style_id');
|
|
|
+ if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ $cat = AlbumCatModel::where('store_id',$store_id)->get(['name','id'])->toArray();
|
|
|
+ $total = 0;
|
|
|
+ foreach ($cat as $key=>$val){
|
|
|
+ $count = CustomerCatRecordModel::where([['agent_id',$user_agent->id],['store_id',$store_id],['style_id',$style_id],['cat_id',$val['id']]])->count();
|
|
|
+ $total += $count;
|
|
|
+ $cat[$key]['num'] = $count;
|
|
|
+ }
|
|
|
+ foreach($cat as $key=>$val){
|
|
|
+ $cat[$key]['point'] = ($val['num']/$total*100).'%';
|
|
|
+ }
|
|
|
+ return $this->api(compact('cat'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @api {post} /api/album/get-cart-of-watch 客户浏览情况概览(get-cart-of-watch)
|
|
|
* @apiDescription 客户浏览情况概览(get-cart-of-watch)
|