|
@@ -744,8 +744,29 @@ class StoreOrderRepository extends BaseRepository
|
|
|
});
|
|
|
event('order.take', compact('order'));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ //超过应付尾款折扣比,以红包米的形式发放
|
|
|
+ public function grant(StoreOrder $order, User $user)
|
|
|
+ {
|
|
|
+ if($order->residue_percentage <= 0){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ $residue_percentage = abs($order->residue_percentage);
|
|
|
+ $max_discount = systemConfig('max_discount');
|
|
|
+ if($max_discount && $residue_percentage > $max_discount){
|
|
|
+ $residue_percentage = $max_discount;
|
|
|
+ }
|
|
|
+ $integral = $residue_percentage * $order->total_price / 100;
|
|
|
+ if($integral){
|
|
|
+ app()->make(UserBillRepository::class)->incBill($user->uid, 'integral', 'rebate', [
|
|
|
+ 'link_id' => $order->order_id,
|
|
|
+ 'status' => 0,
|
|
|
+ 'title' => '超出比例发放红包米',
|
|
|
+ 'number' => $integral,
|
|
|
+ 'mark' => '分销超出折扣比,返利'.$integral.'红包米',
|
|
|
+ 'balance' => $user->integral
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 获取订单列表头部统计数据
|
|
|
* @Author:Qinii
|