소스 검색

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

shish 3 년 전
부모
커밋
4c822b7078
2개의 변경된 파일79개의 추가작업 그리고 8개의 파일을 삭제
  1. 54 8
      console/controllers/GhsInitController.php
  2. 25 0
      console/controllers/ItemController.php

+ 54 - 8
console/controllers/GhsInitController.php

@@ -7,16 +7,62 @@
 namespace console\controllers;
 
 use biz\item\classes\PtItemClass;
+use biz\shop\classes\ShopClass;
+use bizGhs\custom\classes\CustomClass;
+use bizGhs\ghs\classes\GhsClass;
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\classes\ItemClassClass;
 use bizGhs\product\classes\ProductClass;
 use common\services\xhItemService;
 use yii\console\Controller;
+
 class GhsInitController extends Controller
 {
 
-    public function actionInit()
+    public function actionChangePtStyle()
     {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $shopList = ShopClass::getAllByCondition(['id>' => 0], null, '*', 'id');
+        $ghsList = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
+        if (!empty($ghsList)) {
+            foreach ($ghsList as $ghs) {
+                $ownShopId = $ghs->ownShopId ?? 0;
+                if (isset($shopList[$ownShopId]) == false) {
+                    echo "没有找到供货商门店\n";
+                    continue;
+                }
+                $shop = $shopList[$ownShopId];
+                $ptStyle = $shop['ptStyle'] ?? 0;
+                if (empty($ptStyle)) {
+                    echo "没有找到ptStyle \n";
+                    continue;
+                }
+                $ghs->ownPtStyle = $ptStyle;
+                $ghs->save();
+                echo "ok \n";
+            }
+        }
+        $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
+        if (!empty($customList)) {
+            foreach ($customList as $custom) {
+                $ownShopId = $custom->ownShopId ?? 0;
+                if (isset($shopList[$ownShopId]) == false) {
+                    echo "没有找到客户门店\n";
+                    continue;
+                }
+                $shop = $shopList[$ownShopId];
+                $ptStyle = $shop['ptStyle'] ?? 0;
+                if (empty($ptStyle)) {
+                    echo "没有找到ptStyle \n";
+                    continue;
+                }
+                $custom->ownPtStyle = $ptStyle;
+                $custom->save();
+                echo "ok \n";
+            }
+        }
     }
 
     //清空某个商户的product
@@ -26,20 +72,20 @@ class GhsInitController extends Controller
 
     public function actionPtUnit()
     {
-        $res = ProductClass::getAllList("*","");
-        foreach ($res as $v){
+        $res = ProductClass::getAllList("*", "");
+        foreach ($res as $v) {
             $id = $v['id'];
             $obigU = $v['bigUnit'];
             $oSmallU = $v['smallUnit'];
             $bigUname = xhItemService::getUnitName($obigU);
             $smallUName = xhItemService::getUnitName($oSmallU);
             $data = [
-                'bigUnitId'=>$obigU,
-                'smallUnitId'=>$oSmallU,
-                'bigUnit'=>$bigUname,
-                'smallUnit'=>$smallUName,
+                'bigUnitId' => $obigU,
+                'smallUnitId' => $oSmallU,
+                'bigUnit' => $bigUname,
+                'smallUnit' => $smallUName,
             ];
-            ProductClass::updateById($id,$data);
+            ProductClass::updateById($id, $data);
         }
         echo "done";
     }

+ 25 - 0
console/controllers/ItemController.php

@@ -30,6 +30,31 @@ class ItemController extends Controller
 
     public $sjId, $shopId, $sj;
 
+    //包装纸丝带同步 ssh 20230525
+    public function actionPaperSync()
+    {
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $oldItemList = ItemClass::getAllByCondition(['classId' => 26013, 'delStatus' => 0], null, '*');
+            foreach ($oldItemList as $oldItem) {
+                unset($oldItem['id']);
+                $oldItem['classId'] = 31106;
+                $oldItem['stock'] = 0;
+                $oldItem['status'] = 2;
+                $oldItem['mainId'] = 4553;
+                $oldItem['sjId'] = 16936;
+                $oldItem['shopId'] = 0;
+                ItemClass::add($oldItem);
+            }
+            $transaction->commit();
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            $msg = $e->getMessage();
+            echo "报错了:" . $msg;
+        }
+    }
+
     public function actionWaste()
     {
         ini_set('memory_limit', '2045M');