Browse Source

active subscribe bugs

zz 6 years ago
parent
commit
961d48398b

+ 9 - 6
app/Http/Middleware/ReadOauth.php

@@ -101,10 +101,10 @@ class ReadOauth
             }
             return redirect()->to($redirect);
         }
-
+        $uri_send_order_id = 0;
         if (strpos($uri, '/yun/') !== false) {
             $uri_send_order_id = (int)str_ireplace('/yun/', '', $uri);
-            Redis::hset('book_read:' . $uid_cookie, 'send_order_id', $uri_send_order_id);
+            //Redis::hset('book_read:' . $uid_cookie, 'send_order_id', $uri_send_order_id);
         }
 
         //禁止明文访问
@@ -122,7 +122,7 @@ class ReadOauth
              Log::info($user_info);*/
             $back = $request->get('back', '');
             if ($openid && $appid && $distribution_channel_id && $uid_cookie) {
-                $this->apidAndOpenId($distribution_channel_id, $appid, $openid, $uid_cookie);
+                $this->apidAndOpenId($distribution_channel_id, $appid, $openid, $uid_cookie,$uri_send_order_id);
                 $channel = ChannelService::getById($distribution_channel_id);
                 $is_yq_move = $this->isQyMove($channel, $distribution_channel_id);
                 if ($is_yq_move) {
@@ -324,7 +324,7 @@ class ReadOauth
         return $arg;
     }
 
-    private function apidAndOpenId($distribution_channel_id, $appid, $openid, $uid)
+    private function apidAndOpenId($distribution_channel_id, $appid, $openid, $uid,$send_order_id)
     {
         $appid_info = OfficialAccountService::officialAccountByAppid(['appid' => $appid]);
         if (!$appid_info)
@@ -341,14 +341,14 @@ class ReadOauth
             return false;
         }*/
 
-        $send_order_id = ReadRecordService::getSendOrderId($uid);
+        /*$send_order_id = ReadRecordService::getSendOrderId($uid);
         if ($send_order_id) {
             try {
                 Redis::hset('force_subscribe_from_send_order_id', $appid . '_' . $uid, $send_order_id);
             } catch (\Exception $e) {
             }
 
-        }
+        }*/
         $user_info = ForceSubscribeService::getUserInfoAll($appid, $openid);
         $forcesubuserdata = [
             'appid' => $appid,
@@ -358,6 +358,9 @@ class ReadOauth
             'openid' => $openid,
             'official_account_id' => 1
         ];
+        if($send_order_id){
+            $forcesubuserdata['send_order_id'] = $send_order_id;
+        }
         if ($user_info) {
             isset($user_info['province']) && !empty($user_info['province']) && $forcesubuserdata['province'] = $user_info['province'];
             isset($user_info['nickname']) && !empty($user_info['nickname']) && $forcesubuserdata['nickname'] = $user_info['nickname'];

+ 12 - 5
app/Modules/OfficialAccount/Services/ForceSubscribeService.php

@@ -203,13 +203,20 @@ class ForceSubscribeService
                     if (empty($bid)) {
                         # code...
                         $bid = '0';
+                    }else{
+                        Redis::hdel('force_subscribe_from_bid',$forceSubscribeUsersPrams['appid'].'_'.$forceSubscribeUsersPrams['uid']);
                     }
-
-                    $sendOrderId = Redis::hget('force_subscribe_from_send_order_id',$forceSubscribeUsersPrams['appid'].'_'.$forceSubscribeUsersPrams['uid']);
-                    if (empty($sendOrderId)) {
-                        # code...
-                        $sendOrderId = '0';
+                    if(isset($forceSubscribeUsersPrams['send_order_id']) && !empty($forceSubscribeUsersPrams['send_order_id'])){
+                        $sendOrderId = $forceSubscribeUsersPrams['send_order_id'];
+                    }else{
+                        $sendOrderId = Redis::hget('force_subscribe_from_send_order_id',$forceSubscribeUsersPrams['appid'].'_'.$forceSubscribeUsersPrams['uid']);
+                        if (empty($sendOrderId)) {
+                            $sendOrderId = '0';
+                        }else{
+                            Redis::hdel('force_subscribe_from_send_order_id',$forceSubscribeUsersPrams['appid'].'_'.$forceSubscribeUsersPrams['uid']);
+                        }
                     }
+
                     if($bid && $sendOrderId){
                         $send_order_bid = Redis::hget('sendOrderIdToBid',$sendOrderId);
                         if(!$send_order_bid){