| xqd
@@ -16,6 +16,7 @@ use App\Models\AlbumProductModel;
|
|
|
use App\Models\AlbumProductPriceModel;
|
|
|
use App\Models\AlbumProductStyleModel;
|
|
|
use App\Models\AlbumUserModel;
|
|
|
+use App\Models\AlbumWatchRecord;
|
|
|
use App\Models\AlbumXyxUserModel;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
| xqd
@@ -240,7 +241,7 @@ class AlbumController extends Controller
|
|
|
$add['store_id'] = $datas['store_id'];
|
|
|
$res = AlbumUserModel::create($add);
|
|
|
if($res){
|
|
|
- $check = AlbumUserModel::where('wechat_open_id',$res['openid'])->first();
|
|
|
+ $check = AlbumUserModel::where([['wechat_open_id',$res['openid']],['store_id',$datas['store_id']]])->first();
|
|
|
$user = [
|
|
|
'user_id'=>$check['id'],
|
|
|
//'avatar'=>$check['avatar'],
|
| xqd
@@ -279,8 +280,14 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
if (Auth::loginUsingId($check->id)) {
|
|
|
$userAuth = Auth::user();
|
|
|
- if($check->is_agent ==1){
|
|
|
+ if($check->is_dealer ==0){
|
|
|
$save['up_agent_id'] = $request->input('agent_id');
|
|
|
+ $add_record['agent_id'] = $request->input('agent_id');
|
|
|
+ $add_record['open_id'] = $check->wechat_open_id;
|
|
|
+ $add_record['action'] = 4;
|
|
|
+ $add_record['store_id'] = $datas['store_id'];
|
|
|
+ $add_record['detail'] = null;
|
|
|
+ AlbumWatchRecord::create($add_record);
|
|
|
}else{
|
|
|
$save['up_agent_id'] = 0;
|
|
|
}
|
| xqd
@@ -389,6 +396,15 @@ class AlbumController extends Controller
|
|
|
$store_id = request('store_id');
|
|
|
$status = request('status');
|
|
|
$style = request('style');
|
|
|
+ $select_info = ['cat_id'=>$cat_id,'style'=>$style];
|
|
|
+ if($userAuth->up_agent_id!=0){
|
|
|
+ $add_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
+ $add_record['open_id'] = $userAuth->wechat_open_id;
|
|
|
+ $add_record['action'] = 2;
|
|
|
+ $add_record['store_id'] = $store_id;
|
|
|
+ $add_record['detail'] = json_encode($select_info);
|
|
|
+ AlbumWatchRecord::create($add_record);
|
|
|
+ }
|
|
|
if(isset($data['keywords'])&&!empty($data['keywords'])) {
|
|
|
$keywords = '%'.$data['keywords'].'%';
|
|
|
$goods = AlbumProductModel::where([['name','like',$keywords],['store_id',$data['store_id']]]);
|
| xqd
@@ -492,6 +508,15 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$goods_id = request('goods_id');
|
|
|
$store_id = request('store_id');
|
|
|
+ $select_info = ['goods_id'=>$goods_id];
|
|
|
+ if($userAuth->up_agent_id!=0){
|
|
|
+ $add_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
+ $add_record['open_id'] = $userAuth->wechat_open_id;
|
|
|
+ $add_record['action'] = 2;
|
|
|
+ $add_record['store_id'] = $store_id;
|
|
|
+ $add_record['detail'] = json_encode($select_info);
|
|
|
+ AlbumWatchRecord::create($add_record);
|
|
|
+ }
|
|
|
$goods = AlbumProductModel::where([['id',$goods_id],['store_id',$store_id]])->first();
|
|
|
if(!empty($goods) && $userAuth->up_agent_id != 0){
|
|
|
$price = DB::table('album_product_price')->where([['agent_id',$userAuth->up_agent_id],['store_id',$store_id],['product_id',$goods['id']]])->first();
|
| xqd
@@ -594,6 +619,86 @@ class AlbumController extends Controller
|
|
|
return $this->api($favorite);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @api {post} /api/album/get-watch-recored 查看客户浏览情况(get-watch-recored)
|
|
|
+ * @apiDescription 查看客户浏览情况(get-watch-recored)
|
|
|
+ * @apiGroup Album
|
|
|
+ * @apiPermission none
|
|
|
+ * @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": [
|
|
|
+ * {
|
|
|
+ * "time": 2018-1-1 10:10:12,
|
|
|
+ * "action": '做了什么什么都做',
|
|
|
+ * "user": [
|
|
|
+ * "username":"王小贱",
|
|
|
+ * "avatar":"awdawdawdawdawdawd",头像
|
|
|
+ * "phone":"1123123123123"
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+
|
|
|
+ public function albumGetWatchRecord(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();
|
|
|
+ $res = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id]])->get();
|
|
|
+ foreach($res as $key=>$val){
|
|
|
+ if($val->action==4){
|
|
|
+ $action = '进入我的画册';
|
|
|
+ }elseif($val->action == 1||$val->action ==3){
|
|
|
+ $goods_data = json_decode($val->detail,true);
|
|
|
+ $goods_id = $goods_data['goods_id'];
|
|
|
+ $goods = AlbumProductModel::find($goods_id);
|
|
|
+ $cat = AlbumCatModel::find($goods->cat_id);
|
|
|
+ $style = AlbumProductStyleModel::find($goods->style);
|
|
|
+ $val->action == 1? $act = '收藏':$act = '查看';
|
|
|
+ $action = $act.'了您的'.$cat->name.'分类下的'.$style->name.'风格的商品 '.$goods->name;
|
|
|
+ }elseif($val->action == 2){
|
|
|
+ $cat_data = json_decode($val->detail,true);
|
|
|
+ $cat = AlbumCatModel::find($cat_data['cat_id']);
|
|
|
+ $style = AlbumProductStyleModel::find($cat_data['style']);
|
|
|
+ $action = '浏览了您的 '.$cat->name.'分类下的 '.$style->name.'风格的商品列表';
|
|
|
+ }
|
|
|
+ $user = AlbumUserModel::where([['wechat_open_id',$val->open_id],['store_id',$val->store_id]])->select(['username','avatar','phone'])->first();
|
|
|
+ $data_res[] = [
|
|
|
+ 'time'=>$val->created_at,
|
|
|
+ 'action'=>$action,
|
|
|
+ 'user'=>$user
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return $this->api(compact('data_res'));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @api {get} /api/album/checklogin 登陆应用(checklogin)
|
|
|
* @apiDescription 登陆应用(checklogin)
|
| xqd
@@ -746,10 +851,20 @@ class AlbumController extends Controller
|
|
|
'store_id.required'=>'缺少商户参数',
|
|
|
'product_id.required'=>'缺少商品参数',
|
|
|
]);
|
|
|
+
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$data = $request->input();
|
|
|
+ $select_info = ['goods_id'=>$data['product_id']];
|
|
|
+ if($userAuth->up_agent_id!=0){
|
|
|
+ $add_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
+ $add_record['open_id'] = $userAuth->wechat_open_id;
|
|
|
+ $add_record['action'] = 1;
|
|
|
+ $add_record['store_id'] = $data['store_id'];
|
|
|
+ $add_record['detail'] = json_encode($select_info);
|
|
|
+ AlbumWatchRecord::create($add_record);
|
|
|
+ }
|
|
|
$check_user = AlbumXyxUserModel::find($userAuth->id);
|
|
|
$check_f = AlbumFavoriteModel::where([['user_id',$userAuth->id],['product_id',$data['product_id']]])->first();
|
|
|
if(!$check_user||$check_f){
|
| xqd
@@ -973,8 +1088,57 @@ class AlbumController extends Controller
|
|
|
return $this->api($return);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @api {post} /api/album/set-phone 获取用户号码(set-phone)
|
|
|
+ * @apiDescription 获取用户号码(set-phone)
|
|
|
+ * @apiGroup Album
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} [store_id] 商户id 模拟值为0
|
|
|
+ * @apiParam {string} [phone] 电话号码
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data":[
|
|
|
+ * "msg":返回信息,
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function albumSavePhone(Request $request)
|
|
|
+ {
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ 'phone' => 'required',
|
|
|
+ ],[
|
|
|
+ 'store_id.required'=>'缺少商户参数',
|
|
|
+ 'phone.required'=>'缺少号码参数',
|
|
|
+ ]);
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
+ }
|
|
|
+ $update['phone'] = $request->input('phone');
|
|
|
+ $res = $userAuth->save($update);
|
|
|
+ if($res){
|
|
|
+ return $this->api(['msg'=>'success']);
|
|
|
+ }else{
|
|
|
+ return $this->api(['msg'=>'error']);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|