Explorar o código

退款零售端花材处理

林琦海 %!s(int64=5) %!d(string=hai) anos
pai
achega
aac462612d

+ 13 - 0
biz-hd/cg/classes/CgRefundSnClass.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizHd\cg\classes;
+
+use Yii;
+use bizGhs\base\classes\BaseClass;
+class CgRefundSnClass extends BaseClass
+{
+
+    public static $baseFile = '\bizHd\cg\models\CgRefundSn';
+
+
+}

+ 15 - 0
biz-hd/cg/models/CgRefundSn.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizHd\cg\models;
+
+use bizHd\base\models\Base;
+
+class CgRefundSn extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhCgRefundSn';
+    }
+
+}

+ 24 - 1
biz-hd/cg/services/CgRefundService.php

@@ -80,7 +80,7 @@ class CgRefundService extends BaseService
         $cgRefund = CgRefundClass::add($data, true);
         if($ghsItemInfo){
             //写入cgRefundItem, 转hdProductId
-            $ghsItemInfo = ProductClass::toggleProductList($ghsItemInfo, $cg->shopId, $cg->sjId);
+            $ghsItemInfo = self::toggleProductList($ghsItemInfo, $cg->shopId, $cg->sjId);
             //将hdProductId =》productId
             foreach ($ghsItemInfo as $k=>$v){
                 $ghsItemInfo[$k]['productId'] =$v['hdProductId'];
@@ -214,4 +214,27 @@ class CgRefundService extends BaseService
 
     }
 
+
+    //供货商productId 转 hdProductId [{productId:1,...}]
+    public static function toggleProductList($ghsItemInfo,$hdShopId,$hdSjId)
+    {
+        $productIds = array_column($ghsItemInfo, "productId");
+        $productData = ProductClass::getProductByIds($productIds);
+        $itemIds = [];
+        $productMap = [];
+        foreach ($productData as $v){
+            $itemIds[] = $v['itemId'];
+            $productMap[$v['id']] = $v['itemId'];
+        }
+
+        $hdProductData = ProductClass::getProductInfoByItemIds($itemIds, $hdShopId);
+        $hdProductData = array_column($hdProductData, null, "itemId");
+
+        foreach ($ghsItemInfo as $k => $v) {
+            $itemId =$productMap[$v['productId']];
+            $hdProductId = $hdProductData[$itemId]['id'];
+            $ghsItemInfo[$k]['hdProductId'] = $hdProductId;
+        }
+        return $ghsItemInfo;
+    }
 }

+ 2 - 1
common/components/orderSn.php

@@ -5,6 +5,7 @@ namespace common\components;
 use biz\sj\classes\CashSnClass;
 use bizGhs\order\classes\OrderClass;
 use bizHd\cg\classes\CgRefundClass;
+use bizHd\cg\classes\CgRefundSnClass;
 use bizHd\purchase\classes\PurchaseClearSnClass;
 use biz\recharge\classes\RechargeSnClass;
 use bizGhs\check\classes\CheckSnClass;
@@ -253,7 +254,7 @@ class orderSn
         if (getenv('YII_ENV', 'local') == 'production') {
             $prefix = 'CGTK';
         }
-        $respond = CgRefundClass::add(['id' => null]);
+        $respond = CgRefundSnClass::add(['id' => null]);
         $id = $respond['id'] ?? 0;
         if (empty($id)) {
             util::fail('退款单号没有生成');