shish 2 tháng trước cách đây
mục cha
commit
e1c72ee386
1 tập tin đã thay đổi với 32 bổ sung61 xóa
  1. 32 61
      biz-ghs/order/classes/OrderClass.php

+ 32 - 61
biz-ghs/order/classes/OrderClass.php

@@ -1313,35 +1313,21 @@ class OrderClass extends BaseClass
             foreach ($list as $key => $val) {
                 $price = $val['price'];
                 $totalPrice = stringUtil::calcAdd($totalPrice, $price);
-                $currentBigNum = $val['bigNum'] ?? 0;
-                $currentSmallNum = $val['smallNum'] ?? 0;
+                $kind++;
+                $currentBigNum = $val['bigNum'];
+                $currentSmallNum = $val['smallNum'];
                 $unitType = $val['xhUnitType'] ?? 0;
                 $refundNum = $val['refundNum'] ?? 0;
-                $refundBigNum = 0;
-                $refundSmallNum = 0;
-                if ($unitType == dict::getDict('unitType', 'small')) {
-                    $refundSmallNum = $refundNum;
+                if ($unitType == 0) {
+                    $currentBigNum = bcsub($currentBigNum, $refundNum);
                 } else {
-                    $refundBigNum = $refundNum;
-                }
-                $currentBigNum = stringUtil::calcSub($currentBigNum, $refundBigNum);
-                $currentSmallNum = stringUtil::calcSub($currentSmallNum, $refundSmallNum);
-                if ($currentBigNum < 0) {
-                    $currentBigNum = 0;
-                }
-                if ($currentSmallNum < 0) {
-                    $currentSmallNum = 0;
+                    $currentSmallNum = bcsub($currentSmallNum, $refundNum);
                 }
+                $totalBigNum = stringUtil::calcAdd($totalBigNum, $currentBigNum);
+                $totalSmallNum = stringUtil::calcAdd($totalSmallNum, $currentSmallNum);
                 //赠送数量
                 $giveNum = $val['giveNum'] ?? 0;
-                $currentTotalBigNum = stringUtil::calcAdd($currentBigNum, $giveNum);
-                if ($currentTotalBigNum > 0 || $currentSmallNum > 0) {
-                    $kind++;
-                }
-                $totalBigNum = stringUtil::calcAdd($totalBigNum, $currentTotalBigNum);
-                $totalSmallNum = stringUtil::calcAdd($totalSmallNum, $currentSmallNum);
-                $list[$key]['refundBigNum'] = $refundBigNum;
-                $list[$key]['refundSmallNum'] = $refundSmallNum;
+                $totalBigNum = bcadd($totalBigNum, $giveNum);
                 $list[$key]['property'] = '';
 
                 //小菊
@@ -1555,10 +1541,7 @@ class OrderClass extends BaseClass
         $ratioType = $current['ratioType'] === null ? -1 : intval($current['ratioType']);
         $ratio = $current['ratio'];
 
-        $lastNum = stringUtil::calcSub($itemNum, $refundNum);
-        if ($lastNum < 0) {
-            $lastNum = 0;
-        }
+        $lastNum = bcsub($itemNum, $refundNum);
 
         if (!empty($remark)) {
             $show = $name . ' ' . $lastNum . $unitName . "【" . $remark . "】";
@@ -1985,7 +1968,7 @@ class OrderClass extends BaseClass
         $content = "<CB>" . $currentName . "</CB>";
         $content .= "<CB>销售单</CB><BR><BR>";
 
-        $respond = self::getPrintData($orderInfo, $debtAmount, $showItem, false);
+        $respond = self::getPrintData($orderInfo, $debtAmount, $showItem);
         $content .= '<B>' . $respond['sendNum'] . ' ' . $fromTypeName . '</B><BR>';
         $content .= '--------------------------------<BR>';
 
@@ -2181,7 +2164,7 @@ class OrderClass extends BaseClass
     }
 
     //打印数据 ssh 20210702
-    public static function getPrintData($val, $debtAmount, $showItem, $loadRefundList = true)
+    public static function getPrintData($val, $debtAmount, $showItem)
     {
         $giveList = [];
         $printProduct = [];
@@ -2194,16 +2177,6 @@ class OrderClass extends BaseClass
                 $giveNum = $itemVal['giveNum'] ?? 0;
                 $xhUnitName = $itemVal['xhUnitName'] ?? '扎';
                 $refundNum = $itemVal['refundNum'] ?? 0;
-                $refundBigNum = $itemVal['refundBigNum'] ?? 0;
-                $refundSmallNum = $itemVal['refundSmallNum'] ?? 0;
-                if (isset($itemVal['refundBigNum']) == false && isset($itemVal['refundSmallNum']) == false) {
-                    $unitType = $itemVal['xhUnitType'] ?? 0;
-                    if ($unitType == dict::getDict('unitType', 'small')) {
-                        $refundSmallNum = $refundNum;
-                    } else {
-                        $refundBigNum = $refundNum;
-                    }
-                }
                 $remark = $itemVal['remark'] ?? '';
 
                 if ($bigNum > 0) {
@@ -2214,7 +2187,7 @@ class OrderClass extends BaseClass
                         'count' => floatval($bigNum) . $xhUnitName,
                         'price' => floatval($bigTotalPrice),
                         'unitPrice' => floatval($bigUnitPrice),
-                        'refundNum' => $refundBigNum,
+                        'refundNum' => $refundNum,
                         'unitName' => $xhUnitName,
                         'itemNum' => $bigNum,
                         'remark' => $remark,
@@ -2230,7 +2203,7 @@ class OrderClass extends BaseClass
                         'count' => floatval($smallNum) . '支',
                         'price' => floatval($smallTotalPrice),
                         'unitPrice' => floatval($smallUnitPrice),
-                        'refundNum' => $refundSmallNum,
+                        'refundNum' => $refundNum,
                         'unitName' => '支',
                         'itemNum' => $smallNum,
                         'remark' => $remark,
@@ -2255,25 +2228,23 @@ class OrderClass extends BaseClass
 
         $relateOrderSn = $val['orderSn'] ?? '';
         $refundList = [];
-        if ($loadRefundList == true) {
-            $refundData = RefundOrderClass::getAllByCondition(['relateOrderSn' => $relateOrderSn], null, '*', null, true);
-            if (!empty($refundData)) {
-                foreach ($refundData as $refund) {
-                    $refundOrderSn = $refund->orderSn ?? '';
-                    $refundProductList = RefundOrderItemClass::getAllByCondition(['orderSn' => $refundOrderSn], null, '*');
-                    if (!empty($refundProductList)) {
-                        foreach ($refundProductList as $currentRefund) {
-                            $num = $currentRefund['xhNum'] ?? 0;
-                            $unitName = $currentRefund['xhUnitName'] ?? '';
-                            $unitPrice = $currentRefund['xhUnitPrice'] ?? 0;
-                            $currentPrice = bcmul($unitPrice, $num, 2);
-                            $refundList[] = [
-                                'name' => $currentRefund['name'] ?? '',
-                                'num' => floatval($num) . $unitName . '*' . floatval($unitPrice),
-                                'count' => floatval($num) . $unitName,
-                                'price' => floatval($currentPrice),
-                            ];
-                        }
+        $refundData = RefundOrderClass::getAllByCondition(['relateOrderSn' => $relateOrderSn], null, '*', null, true);
+        if (!empty($refundData)) {
+            foreach ($refundData as $refund) {
+                $refundOrderSn = $refund->orderSn ?? '';
+                $refundProductList = RefundOrderItemClass::getAllByCondition(['orderSn' => $refundOrderSn], null, '*');
+                if (!empty($refundProductList)) {
+                    foreach ($refundProductList as $currentRefund) {
+                        $num = $currentRefund['xhNum'] ?? 0;
+                        $unitName = $currentRefund['xhUnitName'] ?? '';
+                        $unitPrice = $currentRefund['xhUnitPrice'] ?? 0;
+                        $currentPrice = bcmul($unitPrice, $num, 2);
+                        $refundList[] = [
+                            'name' => $currentRefund['name'] ?? '',
+                            'num' => floatval($num) . $unitName . '*' . floatval($unitPrice),
+                            'count' => floatval($num) . $unitName,
+                            'price' => floatval($currentPrice),
+                        ];
                     }
                 }
             }
@@ -3255,4 +3226,4 @@ XL;
         //noticeUtil::push("orderIds = {$sameTimeIdsStr}, sameTimeIdsStr: {$sameTimeIdsStr}");
     }
 
-}
+}