This commit is contained in:
mkm 2024-01-21 13:47:28 +08:00
parent f6b72481c0
commit 2b012abae7

View File

@ -950,6 +950,30 @@ class StoreOrderCreateRepository extends StoreOrderRepository
$user->save();
}
if ($groupOrder['consumption_money'] > 0) {
$balance=0;
$store_consumption_user= Db::name('store_consumption_user')->where('coupon_user_id',$groupOrder['coupon_user_id'])->where('status',0)->find();
if($store_consumption_user){
if($store_consumption_user['type']==1){
if($store_consumption_user['balance']>$groupOrder['consumption_money']){
$balance=['balance'=>bcsub($store_consumption_user['balance'],$groupOrder['consumption_money'],2)];
Db::name('store_consumption_user')->where('coupon_user_id',$groupOrder['coupon_user_id'])->update();
}else{
$balance=['balance'=>0,'status'=>1];
Db::name('store_consumption_user')->where('coupon_user_id',$groupOrder['coupon_user_id'])->update();
}
}
app()->make(UserBillRepository::class)->decBill($user['uid'], 'consumption', 'deduction', [
'link_id' => $groupOrder['group_order_id'],
'status' => 1,
'title' => '购买商品',
'number' => $groupOrder['consumption_money'],
'mark' => '购买商品使用红包抵扣' . floatval($groupOrder['consumption_money']) . '元',
'balance' => $balance
]);
}
foreach ($orderList as $k => $order) {
$orderList[$k]['group_order_id'] = $groupOrder->group_order_id;
}
@ -981,6 +1005,22 @@ class StoreOrderCreateRepository extends StoreOrderRepository
];
}
if ($order['consumption_money'] > 0) {
$bills[] = [
'uid' => $uid,
'link_id' => $_order->order_id,
'pm' => 0,
'title' => '红包抵扣',
'category' => 'mer_integral',
'type' => 'deduction',
'number' => $order['consumption_money'],
'balance' => 0,
'mark' => '购买商品使用积分抵扣' .$order['consumption_money']. '元',
'mer_id' => $order['mer_id'],
'status' => 1
];
}
//创建发票信息
if (isset($receipt_data[$_order['mer_id']])) {
app()->make(StoreOrderReceiptRepository::class)->add($receipt_data[$_order['mer_id']], $_order);