feat(quote): 师傅报价支持加价模式与工钱口径优化
- 加价计算:CommissionService 新增 calcQuoteMarkupByOrder,师傅端录入净报价,平台自动计入服务费并生成用户端应付报价 - 订单与结算:PaymentService 与 Master 控制器在选择报价与完成服务时联动刷新佣金快照,确保师傅到手收益准确 - 后台与小程序:后台订单详情展示师傅净报价与服务费明细,师傅端订单列表与详情统一定义工钱口径为预计工钱/实结工钱
这个提交包含在:
@@ -594,13 +594,15 @@ class PaymentService
|
||||
) {
|
||||
$autoRefundDuplicate = true;
|
||||
} else {
|
||||
$quoteAmount = round((float)$quote['amount'], 2);
|
||||
$finalPayAmt = max(0, round($quoteAmount - (float)$lockedOrder['discount_amount'], 2));
|
||||
$quoteAmount = round((float)$quote['amount'], 2);
|
||||
$masterQuoteAmt = round((float)$quote['master_amount'], 2);
|
||||
$finalPayAmt = max(0, round($quoteAmount - (float)$lockedOrder['discount_amount'], 2));
|
||||
$paidAmt = round((float)$lockedPay['amount'], 2);
|
||||
$snapRefreshed = CommissionService::refreshQuoteOrderSnapshotOnAmountConfirmed(
|
||||
$finalPayAmt > 0 ? $finalPayAmt : $quoteAmount,
|
||||
$lockedOrder['commission_snapshot'] ?? null,
|
||||
$lockedOrder['commission_rate'] ?? null
|
||||
$lockedOrder['commission_rate'] ?? null,
|
||||
$quote
|
||||
);
|
||||
|
||||
$remark = '客户已选择 ' . $master['realname'] . ' 的报价 ¥' . $quoteAmount . '(微信支付 ¥' . $paidAmt . '),等待师傅联系';
|
||||
@@ -632,7 +634,7 @@ class PaymentService
|
||||
->where('status', 'wait')->update(['status' => 'reject']);
|
||||
|
||||
self::sendNotify('user', (int)$lockedOrder['user_id'], '已选定服务师傅', $remark, 'order', $orderId);
|
||||
self::sendNotify('master', (int)$master['id'], '您的报价已被选中', '订单 ' . $lockedOrder['order_no'] . ' 客户已选择您的报价 ¥' . $quoteAmount . ' 并完成支付托管,请尽快联系客户', 'order', $orderId);
|
||||
self::sendNotify('master', (int)$master['id'], '您的报价已被选中', '订单 ' . $lockedOrder['order_no'] . ' 客户已选择您的报价 ¥' . $masterQuoteAmt . ' 并完成支付托管,请尽快联系客户', 'order', $orderId);
|
||||
}
|
||||
} elseif ($scene === 'diff') {
|
||||
if ((int)$lockedOrder['diff_status'] !== 1 || (int)$lockedOrder['status'] === OrderStatus::CANCELLED) {
|
||||
@@ -2120,12 +2122,14 @@ class PaymentService
|
||||
throw new \InvalidArgumentException('报价状态已变更,请刷新重试');
|
||||
}
|
||||
|
||||
$quoteAmount = round((float)$quote['amount'], 2);
|
||||
$payAmount = max(0, round($quoteAmount - (float)$lockedOrder['discount_amount'], 2));
|
||||
$quoteAmount = round((float)$quote['amount'], 2);
|
||||
$masterQuoteAmt = round((float)$quote['master_amount'], 2);
|
||||
$payAmount = max(0, round($quoteAmount - (float)$lockedOrder['discount_amount'], 2));
|
||||
$snapRefreshed = CommissionService::refreshQuoteOrderSnapshotOnAmountConfirmed(
|
||||
$payAmount > 0 ? $payAmount : $quoteAmount,
|
||||
$lockedOrder['commission_snapshot'] ?? null,
|
||||
$lockedOrder['commission_rate'] ?? null
|
||||
$lockedOrder['commission_rate'] ?? null,
|
||||
$quote
|
||||
);
|
||||
$remark = '客户已选择 ' . $master['realname'] . ' 的报价 ¥' . $quoteAmount . ',等待师傅联系';
|
||||
|
||||
@@ -2153,7 +2157,7 @@ class PaymentService
|
||||
->where('status', 'wait')->update(['status' => 'reject']);
|
||||
|
||||
self::sendNotify('user', (int)$lockedOrder['user_id'], '已选定服务师傅', $remark, 'order', $orderId);
|
||||
self::sendNotify('master', (int)$master['id'], '您的报价已被选中', '订单 ' . $lockedOrder['order_no'] . ' 客户已选择您的报价 ¥' . $quoteAmount . ',请尽快联系客户', 'order', $orderId);
|
||||
self::sendNotify('master', (int)$master['id'], '您的报价已被选中', '订单 ' . $lockedOrder['order_no'] . ' 客户已选择您的报价 ¥' . $masterQuoteAmt . ',请尽快联系客户', 'order', $orderId);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
@@ -2666,14 +2670,15 @@ class PaymentService
|
||||
} elseif ($scene === 'quote') {
|
||||
// 与微信支付路径(confirmOrderPay scene=quote)口径保持一致:
|
||||
// 报价单状态置 accept(枚举白名单),订单状态置已接单(3)并锁定报价师傅,结算基数=报价金额
|
||||
$newPayTotal = round((float)$lockedOrder['pay_amount'] + $payAmount, 2);
|
||||
$snapRefreshed = CommissionService::refreshQuoteOrderSnapshotOnAmountConfirmed(
|
||||
(float)$quote['amount'],
|
||||
$newPayTotal > 0 ? $newPayTotal : (float)$quote['amount'],
|
||||
$lockedOrder['commission_snapshot'] ?? null,
|
||||
$lockedOrder['commission_rate'] ?? null
|
||||
$lockedOrder['commission_rate'] ?? null,
|
||||
$quote
|
||||
);
|
||||
Db::name('order_quote')->where('id', $quoteId)->update(['status' => 'accept']);
|
||||
Db::name('order_quote')->where('order_id', $orderId)->where('id', '<>', $quoteId)->where('status', 'wait')->update(['status' => 'reject']);
|
||||
$newPayTotal = round((float)$lockedOrder['pay_amount'] + $payAmount, 2);
|
||||
$quoteOrderUpdate = [
|
||||
'status' => OrderStatus::ACCEPTED,
|
||||
'master_id' => $masterId,
|
||||
|
||||
在新工单中引用
屏蔽一个用户