shish 4 лет назад
Родитель
Сommit
07113ee117
1 измененных файлов с 39 добавлено и 0 удалено
  1. 39 0
      console/controllers/CgController.php

+ 39 - 0
console/controllers/CgController.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace console\controllers;
+
+use bizGhs\order\classes\PurchaseOrderItemClass;
+use yii\console\Controller;
+use Yii;
+
+class CgController extends Controller
+{
+
+    //供货商 ./yii cg/ghs-cg-update
+    public function actionGhsCgUpdate()
+    {
+        $list = PurchaseOrderItemClass::getAllByCondition([], null, '*', null, true);
+        if (!empty($list)) {
+            foreach ($list as $key => $val) {
+                $itemInfo = $val->itemInfo ?? '';
+                if (empty($itemInfo)) {
+                    continue;
+                }
+                $itemInfo = '{"itemName":"\u6a59\u8272\u592a\u9633\u82b1","itemCover":"item\/tyh\/cstyh.png","bigNum":50,"smallNum":0,"bigNumStock":15,"smallNumStock":"0","itemUnit":2,"ratio":"20","rank":"A","bigUnit":"\u624e","smallUnit":"\u652f","purchaseWeight":55,"itemWeight":"1.10"}';
+                $arr = json_decode($itemInfo, true);
+                $name = $arr['itemName'] ?? '';
+                $cover = $arr['itemCover'] ?? '';
+                $num = $val->itemNum ?? 0;
+                $bigPrice = $val->bigPrice ?? 0;
+                $totalPrice = bcmul($bigPrice, $num, 2);
+                $val->name = $name;
+                $val->cover = $cover;
+                $val->totalPrice = $totalPrice;
+                $val->save();
+                echo "id:" . $val->id;
+                die;
+            }
+        }
+    }
+
+}