调试信用购订单结算

This commit is contained in:
luofei 2023-07-08 17:52:48 +08:00
parent 9eafcde2c7
commit a4a27a0705
4 changed files with 13 additions and 4 deletions

View File

@ -28,7 +28,7 @@ class StoreOrderInterest extends BaseModel
{
$days = ceil((time() - strtotime($this->start_time)) / 86400);
$days = max($days ,0);
$money = bcmul($this->total_price, $this->rate, 2);
$money = bcmul($this->total_price, ($this->rate / 100), 2);
return bcmul($days, $money, 2);
}

View File

@ -84,7 +84,7 @@ class StoreGroupOrderRepository extends BaseRepository
public function detail($uid, $id, $flag = true)
{
$where = $this->getAll ? ['uid' => $uid] : ['paid' => 0, 'uid' => $uid];
return StoreGroupOrder::where($where)
$order = StoreGroupOrder::where($where)
->where('group_order_id', $id)
->where('is_del', 0)
->with(['orderList' => function (Relation $query) use ($flag) {
@ -93,8 +93,11 @@ class StoreGroupOrderRepository extends BaseRepository
})->with(['merchant' => function ($query) use ($flag) {
$flag && $query->field('mer_id,mer_name,settle_cycle,interest_rate');
}, 'orderProduct', 'presellOrder']);
}])
}, 'interest'])
->order('create_time DESC')->find();
$interest = $order->interest->calculateInterest();
$order['interest']['total_amount'] = bcadd($order->interest->total_price, $interest, 2);
return $order;
}
public function status($uid, $id)

View File

@ -1674,7 +1674,7 @@ class StoreOrderRepository extends BaseRepository
'orderProduct',
'presellOrder',
'merchant' => function ($query) {
return $query->field('mer_id,mer_name');
return $query->field('mer_id,mer_name,settle_cycle,interest_rate');
},
'community',
'receipt' => function ($query) {
@ -2497,6 +2497,9 @@ class StoreOrderRepository extends BaseRepository
$merchantRepo = app()->make(MerchantRepository::class);
$merchantRepo->unfreeze($groupOrder->interest->mer_id);
}
//订单结算之后,修改订单支付方式为真实的支付方式
$groupOrder->pay_type = $type;
$groupOrder->save();
}
$groupOrder->interest->save();
Db::commit();

View File

@ -46,6 +46,9 @@ class OrderSettlePaySuccessListen implements ListenerInterface
$merchantRepo = app()->make(MerchantRepository::class);
$merchantRepo->unfreeze($groupOrder->interest->mer_id);
}
//订单结算之后,修改订单支付方式为真实的支付方式
$groupOrder->pay_type = 1;
$groupOrder->save();
Db::commit();
} catch (\Exception $e) {
Db::rollback();