shish 4 лет назад
Родитель
Сommit
631e27c0de

+ 3 - 3
biz-ghs/order/services/RefundOrderService.php

@@ -95,7 +95,7 @@ class RefundOrderService extends BaseService
             RefundOrderItemClass::batchAddOrderItem($batchData);
 
             //花材销量统计变动
-            foreach($batchData as $refundItemInfo){
+            foreach ($batchData as $refundItemInfo) {
                 StatItemClass::refundReplace($refundItemInfo);
             }
         }
@@ -139,7 +139,7 @@ class RefundOrderService extends BaseService
         //当天和当月支出统计
         StatOutClass::updateOrInsert($shop, $refundPrice);
 
-        StatRefundClass::replace($shop, $refundPrice);
+        StatRefundClass::replace($shop, $payWay, $refundPrice);
 
         //记录总的退款金额
         $currentTkPrice = bcadd($order->tkPrice, $refundPrice, 2);
@@ -234,7 +234,7 @@ class RefundOrderService extends BaseService
             //门店余额减少
             ShopClass::saleRefundReduceBalance($shop, $refund, $refundPrice);
         } else {
-            util::fail('支付方式没有找到');
+            util::fail('此订单支付方式不支持退款');
         }
 
         return $refund;

+ 33 - 2
biz/stat/classes/StatRefundClass.php

@@ -4,6 +4,7 @@ namespace biz\stat\classes;
 
 use biz\base\classes\BaseClass;
 use biz\stat\models\StatRefund;
+use common\components\dict;
 
 class StatRefundClass extends BaseClass
 {
@@ -18,7 +19,7 @@ class StatRefundClass extends BaseClass
     }
 
     //退款统计 shish 20210827
-    public static function replace($shop, $amount, $date = null)
+    public static function replace($shop, $payWay, $amount, $date = null)
     {
         $sjId = $shop->sjId ?? 0;
         $shopId = $shop->id ?? 0;
@@ -33,8 +34,38 @@ class StatRefundClass extends BaseClass
         $unique->amount = $currentAmount;
         $unique->totalAmount = $shop->totalRefund;
         $unique->num += 1;
+
+        $map = dict::getDict('payWay');
+        switch ($payWay) {
+            case $map['wxPay']:
+                $current = bcadd($unique->wx, $amount, 2);
+                $unique->wx = $current;
+                break;
+            case $map['alipay']:
+                $current = bcadd($unique->alipay, $amount, 2);
+                $unique->alipay = $current;
+                break;
+            case $map['balancePay']:
+                $current = bcadd($unique->balance, $amount, 2);
+                $unique->balance = $current;
+                break;
+            case $map['debtPay']:
+                $current = bcadd($unique->debt, $amount, 2);
+                $unique->debt = $current;
+                break;
+            case $map['cash']:
+                $current = bcadd($unique->cash, $amount, 2);
+                $unique->cash = $current;
+                break;
+            case $map['bankCard']:
+                $current = bcadd($unique->bank, $amount, 2);
+                $unique->bank = $current;
+                break;
+            default:
+        }
+
         $unique->save();
-        StatRefundMonthClass::replace($shop, $amount, $time);
+        StatRefundMonthClass::replace($shop, $payWay, $amount, $time);
     }
 
 }

+ 32 - 1
biz/stat/classes/StatRefundMonthClass.php

@@ -3,6 +3,7 @@
 namespace biz\stat\classes;
 
 use biz\base\classes\BaseClass;
+use common\components\dict;
 use common\components\util;
 
 class StatRefundMonthClass extends BaseClass
@@ -11,7 +12,7 @@ class StatRefundMonthClass extends BaseClass
     public static $baseFile = '\biz\stat\models\StatRefundMonth';
 
     //退款统计 shish 20210827
-    public static function replace($shop, $amount, $date = null)
+    public static function replace($shop, $payWay, $amount, $date = null)
     {
         if ($date == null) {
             $time = date('Ym');
@@ -35,6 +36,36 @@ class StatRefundMonthClass extends BaseClass
         $unique->amount = $currentAmount;
         $unique->totalAmount = $shop->totalRefund;
         $unique->num += 1;
+
+        $map = dict::getDict('payWay');
+        switch ($payWay) {
+            case $map['wxPay']:
+                $current = bcadd($unique->wx, $amount, 2);
+                $unique->wx = $current;
+                break;
+            case $map['alipay']:
+                $current = bcadd($unique->alipay, $amount, 2);
+                $unique->alipay = $current;
+                break;
+            case $map['balancePay']:
+                $current = bcadd($unique->balance, $amount, 2);
+                $unique->balance = $current;
+                break;
+            case $map['debtPay']:
+                $current = bcadd($unique->debt, $amount, 2);
+                $unique->debt = $current;
+                break;
+            case $map['cash']:
+                $current = bcadd($unique->cash, $amount, 2);
+                $unique->cash = $current;
+                break;
+            case $map['bankCard']:
+                $current = bcadd($unique->bank, $amount, 2);
+                $unique->bank = $current;
+                break;
+            default:
+        }
+
         $unique->save();
     }
 

+ 1 - 1
console/controllers/RefundController.php

@@ -38,7 +38,7 @@ class RefundController extends Controller
                     $shop->totalRefund = $totalRefund;
                     $shop->save();
                     $date = date("Ymd", strtotime($addTime));
-                    StatRefundClass::replace($shop, $refundPrice, $date);
+                    StatRefundClass::replace($shop, $payWay, $refundPrice, $date);
                     $transaction->commit();
 
                 } catch (\Exception $e) {