Преглед изворни кода

fix: 活动计算忽略小金额订单功能去掉,添加日志

joe пре 4 година
родитељ
комит
c944d837e7
1 измењених фајлова са 19 додато и 10 уклоњено
  1. 19 10
      crmeb/services/async/ActivityCalc.php

+ 19 - 10
crmeb/services/async/ActivityCalc.php

@@ -99,14 +99,14 @@ abstract class ActivityCalc {
                 $orders[$oid] += 1;
             }
 
-            if ($ppaid <= 1.0) {
-                Log::warning("impossible price, order: ". $p['id']);
-                continue;
-            }
-            if ($pcost <= 0.1) {
-                Log::warning("impossible cost, order: ". $p['id']);
-                continue;
-            }
+            // if ($ppaid <= 1.0) {
+            //     Log::warning("impossible price, order: ". $p['id']);
+            //     continue;
+            // }
+            // if ($pcost <= 0.1) {
+            //     Log::warning("impossible cost, order: ". $p['id']);
+            //     continue;
+            // }
 
             // 按一个规则, 把商品分为两份, 其中一份中奖
             if ($this->leaningJudge($counter, $p, $attrInfo)) {
@@ -119,7 +119,7 @@ abstract class ActivityCalc {
                 $right_cost = bcadd($right_cost, $pcost, 2);
             }
         } // foreach
-
+        
         // 利润
         $left_profit = bcsub($left_spent, $left_cost, 2);
         $right_profit = bcsub($right_spent, $right_cost, 2);
@@ -134,9 +134,18 @@ abstract class ActivityCalc {
         if ($left_profit > $right_profit) {
             $winners = $right;
             $losers = $left;
+            $profit = $right_profit;
         }
 
         $result = $this->getResult($winners == $left);
+
+        log::warning('products:' . json_encode($products) 
+            . ' left:' . json_encode($left) . ' left_spent:' . $left_spent
+            . ' left_cost:' . $left_cost . ' left_profit:' . $left_profit
+            . ' right' . json_encode($right) . ' right_spent:' . $right_spent
+            . ' right_cost:' . $right_cost . ' right_profit:' . $right_profit
+            . ' diff_money:' . $diff_money . ' profit:' . $profit . ' result:' . $result);
+
         // 保存开奖结果
         SystemAwardHistory::create([
             'activity' => $this->getName(),
@@ -160,7 +169,7 @@ abstract class ActivityCalc {
             $this->execute($p, $single, false);
         }
 
-        Log::warning('activity ' . $this->getNameCN() . ' calc finished. result:');
+        Log::warning('activity ' . $this->getNameCN() . ' calc finished. result:' . $result);
     }
 
     protected function execute($product, $single=true, $win=true) {