Bläddra i källkod

加桌逻辑变动

tgz 3 år sedan
förälder
incheckning
239d42f218
1 ändrade filer med 29 tillägg och 8 borttagningar
  1. 29 8
      app/Modules/User/Services/UserService.php

+ 29 - 8
app/Modules/User/Services/UserService.php

@@ -58,19 +58,40 @@ class UserService
     {
         myLog('incrAddDeskTop')->info('qappAddDesktop', compact('uid', 'status'));
         $log = QappUserAddDestop::where('uid', $uid)->orderBy('id', 'desc')->first();
-        if ((!$log && $status == 1) || ($log && $log->status != $status)) {
-            if ($status == 1) {
+        
+        if (!$log) {
+            //第一次加桌 没有任何记录,加桌状态为1
+            if($status == 1){
+                $job = new UserAddDeskJob($uid);
+                dispatch($job)->onConnection('rabbitmq')->onQueue('qapp_user_add_desk')->delay(now()->addMinutes(3));
+            }
+            //第一次加桌 没有任何记录,加桌状态为0
+            if($status == 0){
+                QappUserAddDestop::create([
+                    'uid' => $uid,
+                    'status' => $status,
+                ]);
+            }
+        }else{
+            //如果有记录,但是都是0 没有1的记录
+            $oneexists = QappUserAddDestop::where('uid', $uid)->where('status', 1)->exists();
+            if(!$oneexists && $status == 1){
                 $job = new UserAddDeskJob($uid);
                 dispatch($job)->onConnection('rabbitmq')->onQueue('qapp_user_add_desk')->delay(now()->addMinutes(3));
             }
-        }
 
-        if($status == 0){
-            QappUserAddDestop::create([
-                'uid' => $uid,
-                'status' => $status,
-            ]);
+            //有加桌记录 最近一次加桌状态和和此次状态是否相等
+            if($log->status != $status){
+                //不相等 插入记录
+                QappUserAddDestop::create([
+                    'uid' => $uid,
+                    'status' => $status,
+                ]);
+            }
+            //相等 不做处理
+            return false;
         }
+        
         // 加桌统计
         if (!$log && $status === 1) {
             QappAddDeskTopService::incrAddDeskTop($uid, QuickConst::FIELD_ADD_DESKTOP);