shish 5 лет назад
Родитель
Сommit
48ea1fde63

+ 0 - 1
biz-ghs/order/services/OrderService.php

@@ -583,7 +583,6 @@ class OrderService extends BaseService
         $saleRefundId = $saleRefund->id;
 
         //零售采购单退款
-        //扣库存在这里实现
         $cgRefund = CgRefundService::addRefund($post, $order);
         $cgRefundId = $cgRefund->id;
 

+ 1 - 0
biz-ghs/order/services/RefundOrderService.php

@@ -142,6 +142,7 @@ class RefundOrderService extends BaseService
             }
 
             return $refund;
+
         } catch (\Exception $exception) {
             util::fail("操作失败" . $exception->getMessage());
         }

+ 8 - 10
biz-hd/cg/services/CgRefundService.php

@@ -3,11 +3,8 @@
 namespace bizHd\cg\services;
 
 use biz\ghs\classes\GhsClass;
-use biz\pt\classes\PtAssetClass;
-use biz\pt\classes\PtYeChangeClass;
 use biz\shop\classes\ShopCapitalClass;
 use biz\shop\classes\ShopClass;
-use biz\shop\classes\ShopYeChangeClass;
 use bizGhs\product\classes\ProductClass;
 use bizGhs\stock\classes\StockRecordClass;
 use bizHd\base\services\BaseService;
@@ -78,15 +75,15 @@ class CgRefundService extends BaseService
 
         //写入订单表
         $cgRefund = CgRefundClass::add($data, true);
-        if($ghsItemInfo){
+        if ($ghsItemInfo) {
             //写入cgRefundItem, 转hdProductId
             $ghsItemInfo = self::toggleProductList($ghsItemInfo, $cg->shopId, $cg->sjId);
             //将hdProductId =》productId
-            foreach ($ghsItemInfo as $k=>$v){
-                $ghsItemInfo[$k]['productId'] =$v['hdProductId'];
+            foreach ($ghsItemInfo as $k => $v) {
+                $ghsItemInfo[$k]['productId'] = $v['hdProductId'];
             }
             //退货,减库存
-            foreach ($ghsItemInfo as $k=>$v){
+            foreach ($ghsItemInfo as $k => $v) {
                 $stockInfo = ProductClass::decreaseStock($v['hdProductId'], $v['bigNum'], $v['smallNum']);
                 $ghsItemInfo[$k]['oldStock'] = $stockInfo['oldStock'];
                 $ghsItemInfo[$k]['newStock'] = $stockInfo['newStock'];
@@ -102,6 +99,7 @@ class CgRefundService extends BaseService
 
         }
         //--------end-----花材处理逻辑 linqh 2021.6.28------
+
         //门店总收入增加
         $currentTotalIncome = bcadd($shop->totalIncome, $refundPrice, 2);
         $shop->totalIncome = $currentTotalIncome;
@@ -216,13 +214,13 @@ class CgRefundService extends BaseService
 
 
     //供货商productId 转 hdProductId [{productId:1,...}]
-    public static function toggleProductList($ghsItemInfo,$hdShopId,$hdSjId)
+    public static function toggleProductList($ghsItemInfo, $hdShopId, $hdSjId)
     {
         $productIds = array_column($ghsItemInfo, "productId");
         $productData = ProductClass::getProductByIds($productIds);
         $itemIds = [];
         $productMap = [];
-        foreach ($productData as $v){
+        foreach ($productData as $v) {
             $itemIds[] = $v['itemId'];
             $productMap[$v['id']] = $v['itemId'];
         }
@@ -231,7 +229,7 @@ class CgRefundService extends BaseService
         $hdProductData = array_column($hdProductData, null, "itemId");
 
         foreach ($ghsItemInfo as $k => $v) {
-            $itemId =$productMap[$v['productId']];
+            $itemId = $productMap[$v['productId']];
             $hdProductId = $hdProductData[$itemId]['id'];
             $ghsItemInfo[$k]['hdProductId'] = $hdProductId;
         }