shish 4 роки тому
батько
коміт
f1487b9f20

+ 4 - 4
app-hd/controllers/RefundController.php

@@ -21,7 +21,7 @@ class RefundController extends BaseController
         $where['mainId'] = $this->mainId;
         $orderSn = $get['orderSn'] ?? '';
         if (!empty($orderSn)) {
-            $where['relateOrderSn'] = $orderSn;
+            $where['orderSn'] = $orderSn;
         }
         $list = HdRefundClass::getOrderList($where);
         util::success($list);
@@ -33,9 +33,9 @@ class RefundController extends BaseController
         $id = Yii::$app->request->get('id', 0);
         $refund = HdRefundClass::getById($id, true);
         HdRefundClass::valid($refund, $this->mainId);
-        $orderSn = $refund->orderSn ?? '';
-        $itemList = HdRefundItemClass::getItemListBySn($orderSn);
-        $goodsList = HdRefundGoodsClass::getGoodsListBySn($orderSn);
+        $refundSn = $refund->refundSn ?? '';
+        $itemList = HdRefundItemClass::getItemListBySn($refundSn);
+        $goodsList = HdRefundGoodsClass::getGoodsListBySn($refundSn);
         util::success(['info' => $refund, 'itemList' => $itemList, 'goodsList' => $goodsList]);
     }
 

+ 10 - 0
biz-hd/refund/services/HdRefundService.php

@@ -93,9 +93,11 @@ class HdRefundService extends BaseService
                 }
                 foreach ($itemInfoList as $currentProduct) {
                     $id = $currentProduct['productId'] ?? 0;
+                    $unitPrice = $currentProduct['unitPrice'] ?? 0;
                     $unitType = $currentProduct['unitType'] ?? 0;
                     $unitName = $currentProduct['unitName'] ?? '';
                     $currentRefundNum = $currentProduct['num'] ?? 0;
+                    $price = bcmul($currentRefundNum, $unitPrice, 2);
                     $name = $productInfo[$id]['name'] ?? '';
                     $ptItemId = $productInfo[$id]['itemId'] ?? 0;
                     $cover = $productInfo[$id]['cover'] ?? '';
@@ -130,6 +132,8 @@ class HdRefundService extends BaseService
                         'ratio' => $ratio,
                         'bigUnit' => $bigUnit,
                         'smallUnit' => $smallUnit,
+                        'unitPrice' => $unitPrice,
+                        'price' => $price,
                     ];
                     HdRefundItemClass::addData($thisItemData, $refundSn, $post);
                 }
@@ -140,8 +144,10 @@ class HdRefundService extends BaseService
                 $orderGoodsData = OrderGoodsClass::getAllByCondition(['orderSn' => $xsOrderSn], null, '*', 'goodsId', true);
                 foreach ($goodsInfoList as $currentGoods) {
                     $goodsId = $currentGoods['productId'] ?? 0;
+                    $unitPrice = $currentGoods['unitPrice'] ?? 0;
                     $name = $goodsData[$goodsId]['name'] ?? '';
                     $currentRefundNum = $currentGoods['num'] ?? 0;
+                    $price = bcmul($currentRefundNum, $unitPrice, 2);
                     $currentOrderGoods = $orderGoodsData[$goodsId] ?? [];
                     if (empty($currentOrderGoods)) {
                         util::fail('没有找到商品呢');
@@ -160,10 +166,14 @@ class HdRefundService extends BaseService
                     $saveGoods = [
                         'refundSn' => $refundSn,
                         'mainId' => $mainId,
+                        'sjId' => $sjId,
+                        'shopId' => $shopId,
                         'name' => $name,
                         'cover' => $cover,
                         'goodsId' => $goodsId,
                         'num' => $num,
+                        'unitPrice' => $unitPrice,
+                        'price' => $price,
                     ];
                     HdRefundGoodsClass::addData($saveGoods, $refundSn, $post);
                 }

+ 7 - 0
sql.txt

@@ -953,4 +953,11 @@ ALTER TABLE xhMain ADD `totalPdSub` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMEN
 ALTER TABLE xhMain ADD `totalWast` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '累计报损' AFTER `totalStockOut`;
 ALTER TABLE xhMain ADD `totalRefund` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '累计退款金额' AFTER `totalStockOut`;
 
+ALTER TABLE xhHdRefundItem ADD unitPrice DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '单价' AFTER `unitName`;
+ALTER TABLE xhHdRefundItem ADD price DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '总金额' AFTER `unitPrice`;
+ALTER TABLE xhHdRefundGoods ADD unitPrice DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '单价' AFTER `num`;
+ALTER TABLE xhHdRefundGoods ADD price DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '总金额' AFTER `unitPrice`;
+
+ALTER TABLE xhHdRefundItem MODIFY `num` INT NOT NULL DEFAULT 0 COMMENT '花材数量';
+
 ---ssh 20220424