Sfoglia il codice sorgente

售后同意,退回善豆

lizhen_gitee 4 giorni fa
parent
commit
028b37e486

+ 17 - 0
addons/shopro/service/order/OrderRefund.php

@@ -139,6 +139,10 @@ class OrderRefund
         // 查找符合条件的 pays 并从中退指定金额
         $this->refundPaysByMoney((string)$refund_money, $data);
 
+        //退回善豆支付的
+//        dd($item->goods_bean_amount);
+        $this->refundPaysByBean($item->goods_bean_amount,$data);
+
         // 订单商品退款后
         $eventData = [
             'order' => $this->order, 
@@ -171,7 +175,20 @@ class OrderRefund
         }
     }
 
+    public function refundPaysByBean(string $refund_money,$data = [])
+    {
+        // 商城订单,已支付的 pay 记录
+        $pays = PayModel::typeOrder()->paid()->where('pay_type','bean')->where('order_id', $this->order->id)->lock(true)->select();
 
+        $refund = new PayRefund($this->order->user_id);
+        foreach ($pays as $key => $pay) {
+            $refund->Refund($pay, $refund_money, [
+                'refund_type' => $data['refund_type'] ?? $this->default_refund_type,
+                'platform' => $this->order->platform,
+                'remark' => $data['remark'] ?? ''
+            ]);
+        }
+    }
 
 
     /**

+ 1 - 0
application/admin/model/shopro/order/Aftersale.php

@@ -303,6 +303,7 @@ class Aftersale extends Common
         $current_goods_amount = bcmul($data['goods_price'], (string)$data['goods_num'], 2);
         $total_amount = bcadd($current_goods_amount, $data['dispatch_fee'], 2);
         $suggest_refund_fee = bcsub($total_amount, $data['discount_fee'], 2);        // (商品金额 + 运费金额) - 总优惠(活动,优惠券,包邮优惠)
+        $suggest_refund_fee = bcsub($suggest_refund_fee, $data['goods_bean_amount'], 2);        // 再减一次善豆金额
 
         return $suggest_refund_fee;
     }