|
@@ -39,9 +39,10 @@ class OrderService
|
|
|
*
|
|
|
* 初始化订单信息,包括用户钱包、技师信息、项目信息、地址信息和订单金额等
|
|
|
*
|
|
|
- * @param int $userId 用户ID
|
|
|
- * @param array $data 订单数据
|
|
|
+ * @param int $userId 用户ID
|
|
|
+ * @param array $data 订单数据
|
|
|
* @return array 返回初始化的订单信息
|
|
|
+ *
|
|
|
* @throws \Exception 初始化失败时抛出异常
|
|
|
*/
|
|
|
public function initialize(int $userId, array $data): array
|
|
@@ -174,9 +175,9 @@ class OrderService
|
|
|
{
|
|
|
$coach = CoachUser::where('id', $coachId)
|
|
|
->where('state', 'enable')
|
|
|
- ->whereHas('info', fn($q) => $q->where('state', 'approved'))
|
|
|
- ->whereHas('qual', fn($q) => $q->where('state', 'approved'))
|
|
|
- ->whereHas('real', fn($q) => $q->where('state', 'approved'))
|
|
|
+ ->whereHas('info', fn ($q) => $q->where('state', 'approved'))
|
|
|
+ ->whereHas('qual', fn ($q) => $q->where('state', 'approved'))
|
|
|
+ ->whereHas('real', fn ($q) => $q->where('state', 'approved'))
|
|
|
->firstOrFail();
|
|
|
|
|
|
return $coach;
|
|
@@ -260,9 +261,8 @@ class OrderService
|
|
|
'remark' => '余额支付',
|
|
|
]);
|
|
|
|
|
|
- $user->wallet->decrement('total_balance', $order->balance_amount)
|
|
|
- ->decrement('available_balance', $order->balance_amount)
|
|
|
- ->save();
|
|
|
+ $user->wallet->decrement('total_balance', $order->balance_amount);
|
|
|
+ $user->wallet->decrement('available_balance', $order->balance_amount);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -730,10 +730,10 @@ class OrderService
|
|
|
try {
|
|
|
// 1. 校验技师
|
|
|
$coach = CoachUser::where('state', 'enable')
|
|
|
- ->whereHas('info', fn($q) => $q->where('state', 'approved'))
|
|
|
- ->whereHas('real', fn($q) => $q->where('state', 'approved'))
|
|
|
- ->whereHas('qual', fn($q) => $q->where('state', 'approved'))
|
|
|
- ->with(['projects' => fn($q) => $q->where('project_id', $projectId)])
|
|
|
+ ->whereHas('info', fn ($q) => $q->where('state', 'approved'))
|
|
|
+ ->whereHas('real', fn ($q) => $q->where('state', 'approved'))
|
|
|
+ ->whereHas('qual', fn ($q) => $q->where('state', 'approved'))
|
|
|
+ ->with(['projects' => fn ($q) => $q->where('project_id', $projectId)])
|
|
|
->find($coachId);
|
|
|
|
|
|
abort_if(! $coach, 404, '技师不存在或状态异常');
|
|
@@ -761,7 +761,7 @@ class OrderService
|
|
|
? bcmul($fee, '2', 2)
|
|
|
: $fee;
|
|
|
} catch (Exception $e) {
|
|
|
- Log::error(__CLASS__ . '->' . __FUNCTION__ . '计算路费失败:', [
|
|
|
+ Log::error(__CLASS__.'->'.__FUNCTION__.'计算路费失败:', [
|
|
|
'message' => $e->getMessage(),
|
|
|
'coach_id' => $coachId,
|
|
|
'project_id' => $projectId,
|
|
@@ -904,7 +904,7 @@ class OrderService
|
|
|
'delivery_fee' => $deliveryFee,
|
|
|
];
|
|
|
} catch (Exception $e) {
|
|
|
- Log::error(__CLASS__ . '->' . __FUNCTION__ . '计算订单金额失败:', [
|
|
|
+ Log::error(__CLASS__.'->'.__FUNCTION__.'计算订单金额失败:', [
|
|
|
'message' => $e->getMessage(),
|
|
|
'user_id' => $userId,
|
|
|
'project_id' => $projectId,
|
|
@@ -1044,7 +1044,7 @@ class OrderService
|
|
|
WalletPaymentRecord::create([
|
|
|
'order_id' => $order->id,
|
|
|
'wallet_id' => $wallet->id,
|
|
|
- 'payment_no' => 'balance_' . $order->id,
|
|
|
+ 'payment_no' => 'balance_'.$order->id,
|
|
|
'payment_method' => 'balance',
|
|
|
'total_amount' => $order->balance_amount,
|
|
|
'actual_amount' => 0,
|