shish 3 年 前
コミット
0b1d1d8427

+ 9 - 12
biz-ghs/order/services/RefundOrderService.php

@@ -64,9 +64,6 @@ class RefundOrderService extends BaseService
             if (empty($postProduct)) {
                 util::fail('没有退款花材');
             }
-            $ids = array_column($postProduct, 'productId');
-            $productInfo = ProductClass::getByids($ids, null, 'id');
-
             $saleOrderSn = $order->orderSn ?? '';
             $orderItemData = OrderItemClass::getAllByCondition(['orderSn' => $saleOrderSn], null, '*', 'productId', true);
             if (empty($orderItemData)) {
@@ -75,6 +72,15 @@ class RefundOrderService extends BaseService
 
             foreach ($postProduct as $currentProduct) {
                 $id = $currentProduct['productId'] ?? 0;
+                if (isset($orderItemData[$id]) == false) {
+                    util::fail('没有找到退款的花材');
+                }
+                $currentInfo = $orderItemData[$id];
+                $name = $currentInfo->name;
+                $ptItemId = $currentInfo->itemId;
+                $ratio = $currentInfo->ratio;
+                $itemCost = $currentInfo->cost;
+
                 $num = $currentProduct['num'] ?? 0;
                 $xhUnitName = $currentProduct['unitName'] ?? '';
                 $xhUnitPrice = $currentProduct['unitPrice'] ?? '';
@@ -82,15 +88,6 @@ class RefundOrderService extends BaseService
 
                 $xhPrice = bcmul($num, $xhUnitPrice, 2);
 
-                $name = $productInfo[$id]['name'] ?? '';
-                $ptItemId = $productInfo[$id]['itemId'] ?? 0;
-                $itemCost = $productInfo[$id]['cost'] ?? 0;
-                $ratio = $productInfo[$id]['ratio'] ?? 0;
-
-                if (isset($orderItemData[$id]) == false) {
-                    util::fail('没有找到退款的花材');
-                }
-
                 $itemNum = $num;
                 if ($unitType == dict::getDict('unitType', 'small')) {
                     $itemNum = bcdiv($num, $ratio, 2);

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

@@ -187,25 +187,29 @@ class CgRefundService extends BaseService
             $cgItemInfo = PurchaseItemClass::getAllByCondition(['orderSn' => $cgOrderSn], null, '*', 'productId', true);
 
             foreach ($productList as $info) {
-                $unitType = $info['unitType'] ?? 0;
-                $num = $info['num'] ?? 0;
-                $unitPrice = $info['unitPrice'] ?? 0;
-                $unitName = $info['unitName'] ?? '';
                 $productId = $info['productId'] ?? 0;
-                $ptItemId = $info['ptItemId'] ?? 0;
-
                 if (isset($cgItemInfo[$productId]) == false) {
                     util::fail('没有找到花材哦!');
                 }
+                $currentInfo = $cgItemInfo[$productId];
+                $ptItemId = $currentInfo->itemId;
+                $name = $currentInfo->name;
+                $cover = $currentInfo->cover;
+                $ratio = $currentInfo->ratio;
+
+                $unitType = $info['unitType'] ?? 0;
+                $num = $info['num'] ?? 0;
+                $unitPrice = $info['unitPrice'] ?? 0;
+                $unitName = $info['unitName'] ?? '';
 
                 $refundData = [];
                 $refundData['orderSn'] = $refundOrderSn;
                 $refundData['itemId'] = $ptItemId;
                 $refundData['productId'] = $productId;
-                $refundData['name'] = $info['name'] ?? '';
-                $refundData['cover'] = $info['cover'] ?? '';
-                $refundData['itemCost'] = $info['cost'] ?? 0;
-                $refundData['ratio'] = $info['ratio'] ?? 0;
+                $refundData['name'] = $name;
+                $refundData['cover'] = $cover;
+                $refundData['itemCost'] = $unitPrice;
+                $refundData['ratio'] = $ratio;
                 $refundData['mainId'] = $mainId;
                 $refundData['shopId'] = $shopId;
                 $refundData['sjId'] = $sjId;