Jelajahi Sumber

变更成本和收入

shish 2 tahun lalu
induk
melakukan
b92ef822d4

+ 6 - 1
app-ghs/controllers/ProductController.php

@@ -1490,7 +1490,12 @@ class ProductController extends BaseController
         }
         $info->belongCost = $belongCost;
         $info->save();
+
+        //队列方式去处理
+        $redisKey = 'change_belong_cost_item_list';
+        $value = $id . '_' . $belongCost;
+        Yii::$app->redis->executeCommand('LPUSH', [$redisKey, $value]);
         util::complete('修改成功');
     }
 
-}
+}

+ 22 - 0
biz-ghs/order/classes/OrderItemClass.php

@@ -407,4 +407,26 @@ class OrderItemClass extends BaseClass
         return $respond;
     }
 
+    public static function refreshBelongCost()
+    {
+        $customerCachedKey = 'change_belong_cost_item_list';
+        $belongList = [];
+        while ($count = Yii::$app->redis->executeCommand('LLEN', [$customerCachedKey])) {
+            $string = Yii::$app->redis->executeCommand('RPOP', [$customerCachedKey]);
+            $arr = explode('_', $string);
+            if (count($arr) == 2) {
+                $belongList[] = ['id' => $arr[0], 'belongCost' => $arr[1]];
+            }
+        }
+        if (empty($belongList)) {
+            return false;
+        }
+        foreach ($belongList as $info) {
+            $id = $info['id'];
+            $belongCost = $info['belongCost'];
+            noticeUtil::push('变更花材的成本和收入' . $id . ' ' . $belongCost, '15280215347');
+            self::updateByCondition(['belongCost' => $id, 'belongCost' => $belongCost]);
+        }
+    }
+
 }

+ 5 - 0
console/controllers/GlobalController.php

@@ -26,6 +26,8 @@ class GlobalController extends Controller
     // ./yii global/run
     public function actionRun()
     {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
 
         //库存预警每天下午3点通知一次
         $hour = date("Hi");
@@ -33,6 +35,9 @@ class GlobalController extends Controller
             ProductClass::allShopStockWarningFromQueue();
         }
 
+        //花材变成收入还是成本,需要刷新订单花材表
+        OrderItemClass::refreshBelongCost();
+
         if ((int)date('i') % 20 == 0) {
             //不知道为什么线上付的结账单,老是会被取消,要恢复回来!!!!!!!!!!!!!!!!!!!!
             $sql = "update xhClear set status=2 where status=3 and thirdNo!=''";