| xqd
@@ -292,6 +292,11 @@ class AlbumController extends Controller
|
|
|
$add_record['store_id'] = $datas['store_id'];
|
|
|
$add_record['detail'] = null;
|
|
|
AlbumWatchRecord::create($add_record);
|
|
|
+ try{
|
|
|
+ $this->sendLogsMessage($datas['store_id'],$userAuth->wechat_open_id,4);
|
|
|
+ }catch (\Exception $e){
|
|
|
+
|
|
|
+ }
|
|
|
}else{
|
|
|
$userAuth->up_agent_id = 0;
|
|
|
}
|
| xqd
@@ -408,6 +413,11 @@ class AlbumController extends Controller
|
|
|
$add_record['store_id'] = $store_id;
|
|
|
$add_record['detail'] = json_encode($select_info);
|
|
|
AlbumWatchRecord::create($add_record);
|
|
|
+ try{
|
|
|
+ $this->sendLogsMessage($store_id,$userAuth->wechat_open_id,2);
|
|
|
+ }catch (\Exception $e){
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
if(isset($data['keywords'])&&!empty($data['keywords'])) {
|
|
|
$keywords = '%'.$data['keywords'].'%';
|
| xqd
@@ -514,8 +524,10 @@ class AlbumController extends Controller
|
|
|
if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'goods_id' => 'required',
|
|
|
+ 'store_id' => 'required',
|
|
|
],[
|
|
|
'goods_id.required'=>'缺少商品参数',
|
|
|
+ 'store_id_id.required'=>'缺少STORE参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
| xqd
@@ -530,6 +542,11 @@ class AlbumController extends Controller
|
|
|
$add_record['store_id'] = $store_id;
|
|
|
$add_record['detail'] = json_encode($select_info);
|
|
|
AlbumWatchRecord::create($add_record);
|
|
|
+ try{
|
|
|
+ $this->sendLogsMessage($store_id,$userAuth->wechat_open_id,3);
|
|
|
+ }catch (\Exception $e){
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
$goods = AlbumProductModel::where([['id',$goods_id],['store_id',$store_id]])->first();
|
|
|
if(!empty($goods) && $userAuth->is_dealer != 1){
|
| xqd
@@ -1070,6 +1087,11 @@ class AlbumController extends Controller
|
|
|
$add_record['action'] = 1;
|
|
|
$add_record['store_id'] = $data['store_id'];
|
|
|
$add_record['detail'] = json_encode($select_info);
|
|
|
+ try{
|
|
|
+ $this->sendLogsMessage($data['store_id'],$userAuth->wechat_open_id,1);
|
|
|
+ }catch (\Exception $e){
|
|
|
+
|
|
|
+ }
|
|
|
AlbumWatchRecord::create($add_record);
|
|
|
}
|
|
|
$check_user = AlbumUserModel::find($userAuth->id);
|
| xqd
@@ -1446,6 +1468,11 @@ class AlbumController extends Controller
|
|
|
// dd($add_record);
|
|
|
$res = AlbumWatchRecord::create($add_record);
|
|
|
if($res){
|
|
|
+ try{
|
|
|
+ $this->sendLogsMessage($data['store_id'],$userAuth->wechat_open_id,$data['type']);
|
|
|
+ }catch (\Exception $e){
|
|
|
+
|
|
|
+ }
|
|
|
return $this->api(['msg'=>'success']);
|
|
|
}else{
|
|
|
return $this->api(['msg'=>'error']);
|
| xqd
@@ -1453,4 +1480,68 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param $storeid
|
|
|
+ * @param $open_id
|
|
|
+ * @param $action 1 收藏 2查看类目 3查看商品 4登陆 5点击图片 6 点击导航 7一键拨号
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ */
|
|
|
+ private function sendLogsMessage($storeid,$open_id,$action)
|
|
|
+ {
|
|
|
+ $user = AlbumUserModel::where('wechat_open_id',$open_id)->first();
|
|
|
+ $formId = AlbumFormId::where([['open_id',$open_id]])->first();
|
|
|
+ if($user&&$formId){
|
|
|
+ $content = '';
|
|
|
+ switch ($action){
|
|
|
+ case 1:
|
|
|
+ $content = '有用户收藏了您的产品';
|
|
|
+ break;
|
|
|
+ case 2;
|
|
|
+ $content = '有用户查看了您的产品列表';
|
|
|
+ break;
|
|
|
+ case 3;
|
|
|
+ $content = '有用户查看了您的商品';
|
|
|
+ break;
|
|
|
+ case 4;
|
|
|
+ $content = '有用户进入了您的画册';
|
|
|
+ break;
|
|
|
+ case 5;
|
|
|
+ $content = '有用户点击了您的某款产品详情';
|
|
|
+ break;
|
|
|
+ case 6;
|
|
|
+ $content = '有用户点击了导航到您的位置';
|
|
|
+ break;
|
|
|
+ case 7;
|
|
|
+ $content = '有用户点击了您的号码';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $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);
|
|
|
+ $res = $app->template_message->send([
|
|
|
+ 'touser' => $open_id,
|
|
|
+ 'template_id' => '9PDTfnhsRvdNwpPMIcYLL7wQF4SZkB8-9ZhXUfthbmw',
|
|
|
+ 'page' => 'pages/logs/logs',
|
|
|
+ 'form_id' => $formId->form_id,
|
|
|
+ 'data' => [
|
|
|
+ 'keyword1' => $user->username,
|
|
|
+ 'keyword2' => $content,
|
|
|
+ 'keyword3' => date('Y-m-d H:i'),
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+ dd($res);
|
|
|
+ if($res){
|
|
|
+
|
|
|
+ $formId->delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|