Преглед на файлове

红包 退款金额优化

shish преди 4 години
родител
ревизия
eba23f6fb2
променени са 2 файла, в които са добавени 30 реда и са изтрити 0 реда
  1. 15 0
      biz-ghs/order/services/RefundOrderService.php
  2. 15 0
      biz-hd/cg/services/CgRefundService.php

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

@@ -187,6 +187,21 @@ class RefundOrderService extends BaseService
             }
 
         } elseif ($payWay == dict::getDict('payWay', 'balancePay')) {
+
+            $currentRefund = bcadd($order->refundPrice, $refundPrice, 2);
+            $order->refundPrice = $currentRefund;
+            $currentActPrice = bcsub($order->actPrice, $refundPrice, 2);
+            if ($currentActPrice < 0) {
+                util::fail('退款金额有问题!');
+            }
+            $currentRealPrice = bcsub($order->realPrice, $refundPrice, 2);
+            if ($currentRealPrice < 0) {
+                util::fail('退款金额有问题');
+            }
+            $order->actPrice = $currentActPrice;
+            $order->realPrice = $currentRealPrice;
+            $order->save();
+
             //门店余额减少
             ShopClass::saleRefundReduceBalance($shop, $refund, $refundPrice);
         } else {

+ 15 - 0
biz-hd/cg/services/CgRefundService.php

@@ -246,6 +246,21 @@ class CgRefundService extends BaseService
 
         } elseif ($payWay == dict::getDict('payWay', 'balancePay')) {
 
+            //采购单总金额还要减去退款
+            $currentRefund = bcadd($cg->refundPrice, $refundPrice, 2);
+            $cg->refundPrice = $currentRefund;
+            $currentActPrice = bcsub($cg->actPrice, $refundPrice, 2);
+            if ($currentActPrice < 0) {
+                util::fail('退款金额有问题!');
+            }
+            $cg->actPrice = $currentActPrice;
+            $currentRealPrice = bcsub($cg->realPrice, $refundPrice, 2);
+            if ($currentRealPrice < 0) {
+                util::fail('退款金额有问题,请排查');
+            }
+            $cg->realPrice = $currentRealPrice;
+            $cg->save();
+
             //门店余额增加
             ShopClass::cgRefundAddBalance($shop, $refundPrice, $cgRefund, $ghs);