Переглянути джерело

fix: 活動 calc, 帶文檔和測試

joe 4 роки тому
батько
коміт
3c6c9198cc

+ 4 - 2
app/admin/controller/Test.php

@@ -9,6 +9,8 @@ use crmeb\utils\Redis;
 use think\facade\Log;
 use app\api\controller\board\UserBoardController;
 use app\models\redis\SystemCarousel;
+use crmeb\services\async\LuckyExtACalc;
+use crmeb\services\async\LuckyExtBCalc;
 use crmeb\services\async\task\WechatNotify;
 use think\facade\Config;
 use RobThree\Auth\TwoFactorAuth;
@@ -31,7 +33,7 @@ class Test
     }
 
     protected function test_calc() {
-        $activities = [new ClearanceCalc(), new LuckyCalc()];
+        $activities = [new ClearanceCalc(), new LuckyCalc(), new LuckyExtACalc(), new LuckyExtBCalc()];
         foreach($activities as $activity) {
             $activity->calc();
         }
@@ -66,6 +68,6 @@ class Test
 
     public function test()
     {
-        $this->test_2fa();
+        // $this->test_calc();
     }
 }

+ 3 - 3
crmeb/services/async/ActivityCalc.php

@@ -57,7 +57,7 @@ abstract class ActivityCalc {
         $pNum = count($products);
         $minNum = $this->getMinimalProductNum();
         if ($pNum < $minNum) {
-            Log::warning("not enough order. product num: $pNum, $minNum needed, stop activity: $this->getNameCN()");
+            Log::warning("not enough order. product num: $pNum, $minNum needed, stop activity:" . $this->getNameCN());
             return;
         }
 
@@ -167,7 +167,7 @@ abstract class ActivityCalc {
             }
             Redis::hSet($KEY, $this->getName(), $remain + $profit);
 
-            Log::warning("$this->getName(): single order[product]. dice:$dice, remain:$remain, pay_count:$products[0]['pay_count']");
+            Log::warning($this->getName() . ": single order[product]. dice:$dice, remain:$remain, pay_count:" . $products[0]['pay_count']);
         }
 
         $result = $this->getResult($winners == $left);
@@ -202,7 +202,7 @@ abstract class ActivityCalc {
             $this->execute($p, $single, false);
         }
 
-        Log::warning("activity $this->getNameCN() calc finished. result: $result");
+        Log::warning("activity" . $this->getNameCN() . " calc finished. result: $result");
     }
 
     protected function execute($product, $single=true, $win=true) {

+ 2 - 1
docs/TODO.md

@@ -53,4 +53,5 @@
 
 ## update:
 
-- ALTER TABLE twong.eb_system_admin ADD secret varchar(100) NULL COMMENT '2FA secret';
+- ALTER TABLE twong.eb_system_admin ADD secret varchar(100) NULL COMMENT '2FA secret';
+- ALTER TABLE twong.eb_system_award_history MODIFY COLUMN profit decimal(8,2) DEFAULT 0 NOT NULL COMMENT '本次盈利';