| xqd
@@ -64,98 +64,7 @@ class AlbumController extends Controller
|
|
|
return $this->api(compact('setting','banner','news','navbar','menus'));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @api {post} /api/album/login 登陆(login)
|
|
|
- * @apiDescription 登陆(login)
|
|
|
- * @apiGroup Album
|
|
|
- * @apiPermission none
|
|
|
- * @apiVersion 0.1.0
|
|
|
- * @apiParam {string} code 小程序登录生成的code
|
|
|
- * @apiParam {string} nickName 微信昵称
|
|
|
- * @apiParam {string} avatar 微信头像
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
- * HTTP/1.1 200 OK
|
|
|
- * {
|
|
|
- * "status": true,
|
|
|
- * "status_code": 0,
|
|
|
- * "message": "",
|
|
|
- * "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 albumXcxLogin(Request $request)
|
|
|
- {
|
|
|
- $validator = Validator::make($request->all(),
|
|
|
- [
|
|
|
- 'code' => 'required',
|
|
|
- 'store_id' => 'required'
|
|
|
- /* 'nickName' => 'required',
|
|
|
- 'avatar' => 'required',*/
|
|
|
- ],
|
|
|
- [
|
|
|
- 'code.required' => 'code不能为空!',
|
|
|
- 'store_id.required' => 'store_id不能为空!'
|
|
|
- /*'nickName.required' => 'nickName不能为空!',
|
|
|
- 'avatar.required' => 'avatar不能为空!',*/
|
|
|
- ]
|
|
|
- );
|
|
|
-
|
|
|
-
|
|
|
- if ($validator->fails()) {
|
|
|
- return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
- }
|
|
|
-
|
|
|
- $storeid = $request->get('store_id');
|
|
|
-
|
|
|
- $this->wechat_app = AlbumManufacturerModel::where('store_id',$storeid)->first();
|
|
|
- $config = [
|
|
|
- 'app_id' => $this->wechat_app->app_id,
|
|
|
- 'secret' => $this->wechat_app->app_secret,
|
|
|
-
|
|
|
- // 下面为可选项
|
|
|
- // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
|
|
|
- 'response_type' => 'array',
|
|
|
- ];
|
|
|
- $app = Factory::miniProgram($config);
|
|
|
-
|
|
|
-
|
|
|
- $code = $request->get('code');
|
|
|
- $session = $app->auth->session($code);
|
|
|
- \Log::info(json_encode($session));
|
|
|
- $openid = $session['openid'];
|
|
|
-
|
|
|
-
|
|
|
- $userinfo = AlbumUserModel::where('wechat_open_id', $openid)->where('store_id',$storeid)->first(['id', 'username','wechat_open_id','avatar']);
|
|
|
-
|
|
|
- if (!$userinfo) {
|
|
|
- $data['wechat_open_id'] = $openid;
|
|
|
- $data['username'] = $request->get('nickName');
|
|
|
- $data['avatar'] = $request->get('avatar');
|
|
|
- $data['is_dealer'] = 0;
|
|
|
|
|
|
- $userinfo = AlbumUserModel::create($data);
|
|
|
- }
|
|
|
-
|
|
|
- if (Auth::loginUsingId($userinfo->id)) {
|
|
|
- $user = Auth::user();
|
|
|
- $token = $user->createToken($user->id . '-' . $user->openid)->accessToken;
|
|
|
- return $this->api(compact('token', 'user', 'session_key'));
|
|
|
- } else {
|
|
|
-
|
|
|
- return $this->error(ErrorCode::INCORRECT_USER_OR_PASS);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* @api {post} /api/album/xyx_login 登陆(xyx_login)
|
| xqd
@@ -242,7 +151,7 @@ class AlbumController extends Controller
|
|
|
$check = AlbumUserModel::where('wechat_union_id',$decryptedData['unionId'])->first();
|
|
|
if(!$check){
|
|
|
$add['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
|
- $add['wechat_open_id'] = $res['openid'];
|
|
|
+ $add['open_id'] = $res['openid'];
|
|
|
$add['wechat_union_id'] = $decryptedData['unionId'];
|
|
|
$add['avatar'] = $datas['avatar'];
|
|
|
$add['is_agent'] = 0;
|
| xqd
@@ -299,7 +208,7 @@ class AlbumController extends Controller
|
|
|
$userAuth->up_agent_id = $request->input('agent_id');
|
|
|
}
|
|
|
$add_record['agent_id'] = $request->input('agent_id');
|
|
|
- $add_record['union_id'] = $check->wechat_union_id;
|
|
|
+ $add_record['open_id'] = $check->open_id;
|
|
|
$add_record['action'] = 4;
|
|
|
$add_record['store_id'] = $datas['store_id'];
|
|
|
$add_record['detail'] = null;
|
| xqd
@@ -311,7 +220,7 @@ class AlbumController extends Controller
|
|
|
if($user_agent){
|
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
|
try{
|
|
|
- $this->sendLogsMessage($datas['store_id'],$agent->wechat_open_id,4,$userAuth->username);
|
|
|
+ $this->sendLogsMessage($datas['store_id'],$agent->open_id,4,$userAuth->username);
|
|
|
}catch (\Exception $e){
|
|
|
|
|
|
}
|
| xqd
@@ -431,13 +340,13 @@ class AlbumController extends Controller
|
|
|
$select_info = ['cat_id'=>$cat_id,'style'=>$style];
|
|
|
if($userAuth->up_agent_id!=0&&$cat_id!="undefined"&&$style!="undefined"){
|
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
- $add_record['open_id'] = $userAuth->wechat_open_id;
|
|
|
+ $add_record['open_id'] = $userAuth->open_id;
|
|
|
$add_record['action'] = 2;
|
|
|
$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['open_id'] = $userAuth->open_id;
|
|
|
$cat_record['store_id'] = $store_id;
|
|
|
$cat_record['style_id'] = $style;
|
|
|
$cat_record['cat_id'] = $cat_id;
|
| xqd
@@ -445,7 +354,7 @@ class AlbumController extends Controller
|
|
|
$user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
|
try{
|
|
|
- $this->sendLogsMessage($store_id,$agent->wechat_open_id,2,$userAuth->username);
|
|
|
+ $this->sendLogsMessage($store_id,$agent->open_id,2,$userAuth->username);
|
|
|
}catch (\Exception $e){
|
|
|
|
|
|
}
|
| xqd
@@ -571,7 +480,7 @@ class AlbumController extends Controller
|
|
|
$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['open_id'] = $userAuth->open_id;
|
|
|
$add_record['action'] = 3;
|
|
|
$add_record['store_id'] = $store_id;
|
|
|
$add_record['detail'] = json_encode($select_info);
|
| xqd
@@ -579,7 +488,7 @@ class AlbumController extends Controller
|
|
|
$user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
|
try{
|
|
|
- $this->sendLogsMessage($store_id,$agent->wechat_open_id,3,$userAuth->username);
|
|
|
+ $this->sendLogsMessage($store_id,$agent->open_id,3,$userAuth->username);
|
|
|
}catch (\Exception $e){
|
|
|
|
|
|
}
|
| xqd
@@ -774,7 +683,7 @@ class AlbumController extends Controller
|
|
|
case '1':
|
|
|
if(!$request->input('user_id')) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!');
|
|
|
$user = AlbumUserModel::find(request('user_id'));
|
|
|
- $query = $query->where('open_id',$user->wechat_open_id);
|
|
|
+ $query = $query->where('open_id',$user->open_id);
|
|
|
break;
|
|
|
case '2':
|
|
|
if(!$request->input('start_time')||!$request->input('end_time')) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!');
|
| xqd
@@ -828,7 +737,7 @@ class AlbumController extends Controller
|
|
|
$action = '查看了您的电话'.$phone.',并且点击了拨号';
|
|
|
}
|
|
|
|
|
|
- $user = AlbumUserModel::where([['wechat_open_id',$val->open_id],['store_id',$val->store_id]])->select(['username','avatar','phone'])->first();
|
|
|
+ $user = AlbumUserModel::where([['open_id',$val->open_id],['store_id',$val->store_id]])->select(['username','avatar','phone'])->first();
|
|
|
// dd(111);
|
|
|
$data_res[] = [
|
|
|
'time'=>$val->created_at,
|
| xqd
@@ -1001,7 +910,7 @@ class AlbumController extends Controller
|
|
|
* "username":"王小贱",
|
|
|
* "avatar":"awdawdawdawdawdawd",头像
|
|
|
* "phone":"1123123123123"
|
|
|
- * "wechat_open_id":"1123123123123"
|
|
|
+ * "open_id":"1123123123123"
|
|
|
* }
|
|
|
* "count":6,
|
|
|
* "action":[
|
| xqd
@@ -1048,7 +957,7 @@ class AlbumController extends Controller
|
|
|
$users = Array();
|
|
|
if($count_user){
|
|
|
foreach($count_user as $key=>$val){
|
|
|
- $user = AlbumUserModel::where([['wechat_open_id',$val->open_id],['store_id',$val->store_id]])->select(['id','username','avatar','phone','wechat_open_id'])->first();
|
|
|
+ $user = AlbumUserModel::where([['open_id',$val->open_id],['store_id',$val->store_id]])->select(['id','username','avatar','phone','open_id'])->first();
|
|
|
$customer = CustomerDetailsModel::where([['store_id',$store_id],['open_id',$val->open_id],['agent_id',$user_agent->id]])->first(['purpose_level','comment','tips']);
|
|
|
if($customer){
|
|
|
$user->purpose_level = $customer->purpose_level;
|
| xqd
@@ -1226,7 +1135,7 @@ class AlbumController extends Controller
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$data = $request->input();
|
|
|
- $data['open_id'] = $userAuth->wechat_open_id;
|
|
|
+ $data['open_id'] = $userAuth->open_id;
|
|
|
$res = AlbumFormId::create($data);
|
|
|
if($res){
|
|
|
$d = [
|
| xqd
@@ -1289,14 +1198,14 @@ class AlbumController extends Controller
|
|
|
$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['open_id'] = $userAuth->open_id;
|
|
|
$add_record['action'] = 1;
|
|
|
$add_record['store_id'] = $data['store_id'];
|
|
|
$add_record['detail'] = json_encode($select_info);
|
|
|
$user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
|
try{
|
|
|
- $this->sendLogsMessage($data['store_id'],$agent->wechat_open_id,1,$userAuth->username);
|
|
|
+ $this->sendLogsMessage($data['store_id'],$agent->open_id,1,$userAuth->username);
|
|
|
}catch (\Exception $e){
|
|
|
|
|
|
}
|
| xqd
@@ -1639,7 +1548,7 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
if($userAuth->up_agent_id!=0){
|
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
- $add_record['open_id'] = $userAuth->wechat_open_id;
|
|
|
+ $add_record['open_id'] = $userAuth->open_id;
|
|
|
$add_record['action'] = $data['type'];
|
|
|
$add_record['store_id'] = 1;
|
|
|
$add_record['detail'] = json_encode($select_info);
|
| xqd
@@ -1649,7 +1558,7 @@ class AlbumController extends Controller
|
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
|
if($res){
|
|
|
try{
|
|
|
- $this->sendLogsMessage($data['store_id'],$agent->wechat_open_id,$data['type'],$userAuth->username);
|
|
|
+ $this->sendLogsMessage($data['store_id'],$agent->open_id,$data['type'],$userAuth->username);
|
|
|
}catch (\Exception $e){
|
|
|
|
|
|
}
|
| xqd
@@ -1668,7 +1577,7 @@ class AlbumController extends Controller
|
|
|
*/
|
|
|
private function sendLogsMessage($storeid,$open_id,$action,$name)
|
|
|
{
|
|
|
- $user = AlbumUserModel::where('wechat_open_id',$open_id)->first();
|
|
|
+ $user = AlbumUserModel::where('open_id',$open_id)->first();
|
|
|
$formId = AlbumFormId::where([['open_id',$open_id]])->first();
|
|
|
if($user&&$formId){
|
|
|
$content = '';
|
| xqd
@@ -1973,7 +1882,7 @@ class AlbumController extends Controller
|
|
|
$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']);
|
|
|
if(!empty($customer)){
|
|
|
- $user = AlbumUserModel::where([['store_id',$store_id],['wechat_open_id',$open_id]])->first();
|
|
|
+ $user = AlbumUserModel::where([['store_id',$store_id],['open_id',$open_id]])->first();
|
|
|
$customer->phone = $user->phone;
|
|
|
}
|
|
|
return $this->api(compact('customer'));
|