瀏覽代碼

wesmiler 更新第5期更新代码合并

wesmiler 4 年之前
父節點
當前提交
ba445be3e1
共有 2 個文件被更改,包括 23 次插入18 次删除
  1. 19 14
      app/weixin/model/Member.php
  2. 4 4
      app/weixin/service/Member.php

+ 19 - 14
app/weixin/model/Member.php

@@ -2538,21 +2538,26 @@ class Member extends Model
 
 
         $time = isset($firstSign['created_at'])? $firstSign['created_at'] : '';
         $time = isset($firstSign['created_at'])? $firstSign['created_at'] : '';
         if($firstSign && $time) {
         if($firstSign && $time) {
-
-            // 签到后清除月份总消费
-            $totalCost = AccountLog::where(['user_id' => $userId, 'status' => 2, 'account_type' => 1, 'change_type' => 2])
-                ->where('created_at', '>=', $time)
-                ->where('created_at', '<', date('Y-m-01'))
-                ->sum('money');
-
-            $totalClearSign = AccountLog::where(['user_id' => $userId, 'type' => 12, 'status' => 2])
+            $check = AccountLog::where(['user_id' => $userId, 'type'=> 13, 'status' => 2])
                 ->where('created_at', '>=', $time)
                 ->where('created_at', '>=', $time)
-                ->where('created_at', '<', date('Y-m-01'))
-                ->sum('money');
-
-            $clearRedheart = ($totalClearSign - $totalCost);
-            $datas['sign_clear'] = $clearRedheart;
-
+                ->find();
+            if(empty($check)){
+                $datas['show_clear'] = 0;
+            }else{
+                // 签到后清除月份总消费
+                $totalCost = AccountLog::where(['user_id' => $userId, 'status' => 2, 'account_type' => 1, 'change_type' => 2])
+                    ->where('created_at', '>=', $time)
+                    ->where('created_at', '<=', date('Y-m-01 02:00:00'))
+                    ->sum('money');
+
+                $totalClearSign = AccountLog::where(['user_id' => $userId, 'type' => 12, 'status' => 2])
+                    ->where('created_at', '>=', $time)
+                    ->where('created_at', '<=', date('Y-m-01 02:00:00'))
+                    ->sum('money');
+
+                $clearRedheart = ($totalClearSign - $totalCost);
+                $datas['sign_clear'] = $clearRedheart;
+            }
         }
         }
 
 
         $totalSign = AccountLog::where(['user_id' => $userId, 'type' => 12, 'status' => 2])
         $totalSign = AccountLog::where(['user_id' => $userId, 'type' => 12, 'status' => 2])

+ 4 - 4
app/weixin/service/Member.php

@@ -395,7 +395,7 @@ class Member
         // 最早
         // 最早
         $firstSign = AccountLog::where(['user_id'=> $userId,'type'=> 12,'status'=> 2])
         $firstSign = AccountLog::where(['user_id'=> $userId,'type'=> 12,'status'=> 2])
             ->where('created_at','>=', $month)
             ->where('created_at','>=', $month)
-            ->where('created_at','<', date('Y-m-01'))
+            ->where('created_at','<=', date('Y-m-01 02:00:00'))
             ->order('created_at','asc')
             ->order('created_at','asc')
             ->find();
             ->find();
         $time = isset($firstSign['created_at'])? $firstSign['created_at'] : '';
         $time = isset($firstSign['created_at'])? $firstSign['created_at'] : '';
@@ -407,13 +407,13 @@ class Member
         // 签到后总消费
         // 签到后总消费
         $totalCost = AccountLog::where(['user_id'=> $userId,'status'=> 2,'account_type'=> 1,'change_type'=>2])
         $totalCost = AccountLog::where(['user_id'=> $userId,'status'=> 2,'account_type'=> 1,'change_type'=>2])
             ->where('created_at','>=', $time)
             ->where('created_at','>=', $time)
-            ->where('created_at','<', date('Y-m-01'))
+            ->where('created_at','<', date('Y-m-01 02:00:00'))
             ->sum('money');
             ->sum('money');
 
 
 
 
         $totalSign = AccountLog::where(['user_id'=> $userId,'type'=> 12,'status'=> 2])
         $totalSign = AccountLog::where(['user_id'=> $userId,'type'=> 12,'status'=> 2])
             ->where('created_at','>=', $time)
             ->where('created_at','>=', $time)
-            ->where('created_at','<', date('Y-m-01'))
+            ->where('created_at','<', date('Y-m-01 02:00:00'))
             ->sum('money');
             ->sum('money');
 
 
         // 清除还有未消费爱心
         // 清除还有未消费爱心
@@ -434,7 +434,7 @@ class Member
                 'user_id' => $userId,
                 'user_id' => $userId,
                 'money' => $clearRedheart,
                 'money' => $clearRedheart,
                 'balance' => $redheart,
                 'balance' => $redheart,
-                'created_at' => date('Y-m-d H:i:s'),
+                'created_at' => date('Y-m-01 01:i:s'),
                 'remark' => "签到爱心过期扣除",
                 'remark' => "签到爱心过期扣除",
             ];
             ];
             PRedis::set("cache:signs:clearLog:{$userId}", ['log' => $accountData,'user'=> $info], 86400);
             PRedis::set("cache:signs:clearLog:{$userId}", ['log' => $accountData,'user'=> $info], 86400);