feat(quote): 师傅报价支持加价模式与工钱口径优化
- 加价计算:CommissionService 新增 calcQuoteMarkupByOrder,师傅端录入净报价,平台自动计入服务费并生成用户端应付报价 - 订单与结算:PaymentService 与 Master 控制器在选择报价与完成服务时联动刷新佣金快照,确保师傅到手收益准确 - 后台与小程序:后台订单详情展示师傅净报价与服务费明细,师傅端订单列表与详情统一定义工钱口径为预计工钱/实结工钱
这个提交包含在:
@@ -340,7 +340,8 @@
|
||||
<th>报价师傅</th>
|
||||
<th>联系电话</th>
|
||||
<th>服务评分</th>
|
||||
<th>报价金额</th>
|
||||
<th>用户端报价</th>
|
||||
<th>师傅净报价 / 服务费</th>
|
||||
<th>报价说明</th>
|
||||
<th>状态</th>
|
||||
<th>报价时间</th>
|
||||
@@ -353,6 +354,10 @@
|
||||
<td>{$qt.master_mobile|default='-'|htmlentities}</td>
|
||||
<td><span style="color:#d97706;"><i class="fa fa-star"></i> {$qt.master_score|default='5.0'}</span></td>
|
||||
<td><strong style="color:#ea580c;">¥{$qt.amount}</strong></td>
|
||||
<td>
|
||||
<span style="color:#10b981;font-weight:600;">¥{$qt.master_amount}</span>
|
||||
<small class="text-muted">(+平台服务费 ¥{$qt.platform_fee})</small>
|
||||
</td>
|
||||
<td>{$qt.description|default='-'|htmlentities}</td>
|
||||
<td>
|
||||
<span class="label {if $qt.status == 'accept' || $qt.status == 'selected'}label-success{elseif $qt.status == 'wait'/}label-warning{else/}label-default{/if}">{$qt.display_status|htmlentities}</span>
|
||||
|
||||
@@ -1285,6 +1285,12 @@ class Master extends MasterBase
|
||||
unset($row['verify_code']);
|
||||
$row['status_text'] = OrderStatus::label($row['status']);
|
||||
$row['pay_amount'] = (float)$row['pay_amount'];
|
||||
$ordCalc = CommissionService::calcByOrder($row);
|
||||
$row['master_fee'] = (int)($row['settle_status'] ?? 0) === 1
|
||||
? (float)$row['settle_amount']
|
||||
: (float)$ordCalc['settle_amount'];
|
||||
$row['settle_amount'] = (float)$row['master_fee'];
|
||||
unset($row['commission_rate'], $row['commission_snapshot']);
|
||||
$row['appoint_text'] = $row['appoint_time'] ? date('m-d H:i', (int)$row['appoint_time']) : '尽快上门';
|
||||
$row['urgent'] = (int)$row['urgent'];
|
||||
$row['masked_mobile'] = substr_replace($row['mobile'], '****', 3, 4);
|
||||
@@ -1423,22 +1429,29 @@ class Master extends MasterBase
|
||||
$this->error('您已报价,请勿重复提交');
|
||||
}
|
||||
|
||||
$masterAmount = round($amount, 2);
|
||||
$markup = CommissionService::calcQuoteMarkupByOrder($order, $masterAmount);
|
||||
$userAmount = round((float)$markup['user_amount'], 2);
|
||||
$platformFee = round((float)$markup['platform_fee'], 2);
|
||||
|
||||
Db::name('order_quote')->insert([
|
||||
'order_id' => $orderId,
|
||||
'master_id' => (int)$master['id'],
|
||||
'amount' => round($amount, 2),
|
||||
'description' => mb_substr($desc, 0, 500),
|
||||
'valid_hours' => $hours,
|
||||
'expire_time' => time() + $hours * 3600,
|
||||
'status' => 'wait',
|
||||
'createtime' => time(),
|
||||
'order_id' => $orderId,
|
||||
'master_id' => (int)$master['id'],
|
||||
'master_amount' => $masterAmount,
|
||||
'platform_fee' => $platformFee,
|
||||
'amount' => $userAmount,
|
||||
'description' => mb_substr($desc, 0, 500),
|
||||
'valid_hours' => $hours,
|
||||
'expire_time' => time() + $hours * 3600,
|
||||
'status' => 'wait',
|
||||
'createtime' => time(),
|
||||
]);
|
||||
|
||||
// 兼容旧流程:已支付但仍在待接单的报价单,收到首个报价时进入「报价中」
|
||||
if ((int)$order['status'] === OrderStatus::PENDING_ACCEPT) {
|
||||
$this->transit($order, OrderStatus::QUOTING, '收到师傅报价,订单进入报价中', [], 'master', (int)$master['id']);
|
||||
}
|
||||
$this->notify('user', (int)$order['user_id'], '收到新报价', '师傅 ' . $master['realname'] . ' 对订单 ' . $order['order_no'] . ' 报价 ¥' . round($amount, 2) . ',请前往订单详情选择', 'order', $orderId);
|
||||
$this->notify('user', (int)$order['user_id'], '收到新报价', '师傅 ' . $master['realname'] . ' 对订单 ' . $order['order_no'] . ' 报价 ¥' . $userAmount . ',请前往订单详情选择', 'order', $orderId);
|
||||
|
||||
$this->success('报价已提交');
|
||||
}
|
||||
@@ -1876,7 +1889,7 @@ class Master extends MasterBase
|
||||
}
|
||||
$list = Db::name('order_quote')->alias('q')
|
||||
->join('order o', 'o.id = q.order_id', 'LEFT')
|
||||
->field('q.*, o.order_no, o.service_name, o.pay_amount as order_amount, o.status as order_status, o.price_type, o.cat_id, o.urgent, o.commission_rate, o.commission_snapshot')
|
||||
->field('q.id, q.order_id, q.master_id, q.master_amount, q.description, q.valid_hours, q.expire_time, q.status, q.createtime, o.order_no, o.service_name, o.status as order_status')
|
||||
->where('q.master_id', $master['id'])
|
||||
->order('q.id desc')
|
||||
->limit(30)
|
||||
@@ -1884,16 +1897,10 @@ class Master extends MasterBase
|
||||
$statusText = ['wait' => '等待客户选择', 'accept' => '已被选中', 'reject' => '未被选中', 'expired' => '已过期'];
|
||||
foreach ($list as &$row) {
|
||||
$row['status_text'] = isset($statusText[$row['status']]) ? $statusText[$row['status']] : $row['status'];
|
||||
$row['amount'] = (float)$row['amount'];
|
||||
$qCalc = CommissionService::calcByOrder([
|
||||
'price_type' => $row['price_type'] ?: 'quote',
|
||||
'cat_id' => (int)($row['cat_id'] ?? 0),
|
||||
'urgent' => (int)($row['urgent'] ?? 0),
|
||||
'commission_rate' => $row['commission_rate'] ?? null,
|
||||
'commission_snapshot' => $row['commission_snapshot'] ?? '',
|
||||
], $row['amount']);
|
||||
$row['master_fee'] = (float)$qCalc['settle_amount'];
|
||||
unset($row['commission_rate'], $row['commission_snapshot']);
|
||||
$masterAmt = (float)$row['master_amount'];
|
||||
$row['amount'] = $masterAmt;
|
||||
$row['master_fee'] = $masterAmt;
|
||||
unset($row['master_amount']);
|
||||
$row['time_text'] = date('m-d H:i', (int)$row['createtime']);
|
||||
$row['expire_text'] = date('m-d H:i', (int)$row['expire_time']);
|
||||
}
|
||||
@@ -2508,8 +2515,8 @@ class Master extends MasterBase
|
||||
'countdown_seconds' => $countdownSeconds,
|
||||
'my_quote' => $myQuote ? [
|
||||
'id' => (int)$myQuote['id'],
|
||||
'amount' => (float)$myQuote['amount'],
|
||||
'master_fee' => (float)CommissionService::calcByOrder($order, (float)$myQuote['amount'])['settle_amount'],
|
||||
'amount' => (float)$myQuote['master_amount'],
|
||||
'master_fee' => (float)$myQuote['master_amount'],
|
||||
'description' => $myQuote['description'],
|
||||
'status' => $myQuote['status'],
|
||||
] : null,
|
||||
|
||||
@@ -299,44 +299,172 @@ class CommissionService
|
||||
}
|
||||
|
||||
/**
|
||||
* 报价单选定师傅报价并确认金额时:仅在订单自身的创单快照 candidate_tiers 内部重新定档(严禁读取后台新规则)
|
||||
* 基于师傅净报价计算用户端加价后总额(方案A:用户价 = 师傅净报价 + 外加平台服务费)
|
||||
*
|
||||
* @param float $finalAmount 选定报价后的订单金额
|
||||
* @param float $masterAmount 师傅提交的净报价(预期到手金额)
|
||||
* @param array $ruleItem 规则快照项
|
||||
* @return array ['master_amount' => float, 'platform_fee' => float, 'user_amount' => float, 'commission_rate' => float, 'rule_id' => int, 'rule_name' => string, 'calc_mode' => string]
|
||||
*/
|
||||
protected static function computeMarkupByRuleItem(float $masterAmount, array $ruleItem): array
|
||||
{
|
||||
$master = max(0.00, round($masterAmount, 2));
|
||||
$mode = in_array($ruleItem['calc_mode'] ?? 'percent', ['percent', 'fixed', 'mixed'], true)
|
||||
? $ruleItem['calc_mode']
|
||||
: 'percent';
|
||||
$rate = self::normalizeRate($ruleItem['commission_rate'] ?? 0);
|
||||
$fixed = round(max(0.00, (float)($ruleItem['fixed_fee'] ?? 0)), 2);
|
||||
$minC = round(max(0.00, (float)($ruleItem['min_commission'] ?? 0)), 2);
|
||||
$maxC = round(max(0.00, (float)($ruleItem['max_commission'] ?? 0)), 2);
|
||||
|
||||
if ($master <= 0) {
|
||||
return [
|
||||
'master_amount' => 0.00,
|
||||
'platform_fee' => 0.00,
|
||||
'user_amount' => 0.00,
|
||||
'commission_rate' => $mode === 'percent' ? $rate : 0.00,
|
||||
'rule_id' => (int)($ruleItem['rule_id'] ?? 0),
|
||||
'rule_name' => (string)($ruleItem['rule_name'] ?? '全局默认抽佣规则'),
|
||||
'calc_mode' => $mode,
|
||||
];
|
||||
}
|
||||
|
||||
if ($mode === 'fixed') {
|
||||
$rawFee = $fixed;
|
||||
} elseif ($mode === 'mixed') {
|
||||
$rawFee = round($master * $rate / 100 + $fixed, 2);
|
||||
} else {
|
||||
$rawFee = round($master * $rate / 100, 2);
|
||||
}
|
||||
|
||||
$platformFee = $rawFee;
|
||||
if ($minC > 0 && $platformFee < $minC) {
|
||||
$platformFee = $minC;
|
||||
}
|
||||
if ($maxC > 0 && $platformFee > $maxC) {
|
||||
$platformFee = $maxC;
|
||||
}
|
||||
$platformFee = round(max(0.00, $platformFee), 2);
|
||||
$userAmount = round($master + $platformFee, 2);
|
||||
$effectiveRate = $userAmount > 0
|
||||
? self::normalizeRate(round($platformFee / $userAmount * 100, 2))
|
||||
: $rate;
|
||||
|
||||
return [
|
||||
'master_amount' => $master,
|
||||
'platform_fee' => $platformFee,
|
||||
'user_amount' => $userAmount,
|
||||
'commission_rate' => $effectiveRate,
|
||||
'rule_id' => (int)($ruleItem['rule_id'] ?? 0),
|
||||
'rule_name' => (string)($ruleItem['rule_name'] ?? '全局默认抽佣规则'),
|
||||
'calc_mode' => $mode,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 报价单提交报价时:严格基于订单自身创单快照计算外加平台服务费与用户端展示价
|
||||
*
|
||||
* @param array $order fa_order 记录(含 commission_snapshot, commission_rate)
|
||||
* @param float $masterAmount 师傅输入的净报价(期望到手金额)
|
||||
* @return array ['master_amount' => float, 'platform_fee' => float, 'user_amount' => float, 'commission_rate' => float, 'rule_id' => int, 'rule_name' => string, 'calc_mode' => string]
|
||||
*/
|
||||
public static function calcQuoteMarkupByOrder(array $order, float $masterAmount): array
|
||||
{
|
||||
$master = max(0.00, round($masterAmount, 2));
|
||||
$snapshotJson = $order['commission_snapshot'] ?? null;
|
||||
$snapshotRate = $order['commission_rate'] ?? null;
|
||||
|
||||
if (is_string($snapshotJson) && trim($snapshotJson) !== '') {
|
||||
$snap = json_decode($snapshotJson, true);
|
||||
if (is_array($snap)) {
|
||||
if (!empty($snap['candidate_tiers']) && is_array($snap['candidate_tiers'])) {
|
||||
foreach ($snap['candidate_tiers'] as $tier) {
|
||||
if (!is_array($tier)) {
|
||||
continue;
|
||||
}
|
||||
$trial = self::computeMarkupByRuleItem($master, $tier);
|
||||
if (self::matchAmountRange($tier, $trial['user_amount'])) {
|
||||
return $trial;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($snap['fallback_rule']) && is_array($snap['fallback_rule']) && !empty($snap['candidate_tiers'])) {
|
||||
return self::computeMarkupByRuleItem($master, $snap['fallback_rule']);
|
||||
}
|
||||
if (!empty($snap['active_rule']) && is_array($snap['active_rule'])) {
|
||||
return self::computeMarkupByRuleItem($master, $snap['active_rule']);
|
||||
}
|
||||
if (!empty($snap['fallback_rule']) && is_array($snap['fallback_rule'])) {
|
||||
return self::computeMarkupByRuleItem($master, $snap['fallback_rule']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rate = ($snapshotRate !== null && trim((string)$snapshotRate) !== '' && is_numeric($snapshotRate))
|
||||
? self::normalizeRate($snapshotRate)
|
||||
: self::getGlobalRate();
|
||||
|
||||
return self::computeMarkupByRuleItem($master, [
|
||||
'rule_id' => 0,
|
||||
'rule_name' => '比例快照(' . number_format($rate, 2, '.', '') . '%)',
|
||||
'calc_mode' => 'percent',
|
||||
'commission_rate' => $rate,
|
||||
'fixed_fee' => 0.00,
|
||||
'min_commission' => 0.00,
|
||||
'max_commission' => 0.00,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 报价单选定师傅报价并确认金额时:在订单创单快照内部锁定阶梯与净价外加明细(严禁读取后台新规则)
|
||||
*
|
||||
* @param float $finalAmount 选定报价后的用户实付金额
|
||||
* @param mixed $existingSnapshotJson 订单表已有的 commission_snapshot
|
||||
* @param mixed $existingRate 订单表已有的 commission_rate
|
||||
* @return array ['commission_rate' => float, 'commission_snapshot' => string|null]
|
||||
* @param array $quoteRow 选中的 fa_order_quote 行(含 master_amount, platform_fee, amount)
|
||||
* @return array ['commission_rate' => float, 'commission_snapshot' => string]
|
||||
*/
|
||||
public static function refreshQuoteOrderSnapshotOnAmountConfirmed(float $finalAmount, $existingSnapshotJson, $existingRate): array
|
||||
public static function refreshQuoteOrderSnapshotOnAmountConfirmed(float $finalAmount, $existingSnapshotJson, $existingRate, array $quoteRow): array
|
||||
{
|
||||
$fallbackRate = ($existingRate !== null && trim((string)$existingRate) !== '' && is_numeric($existingRate))
|
||||
? self::normalizeRate($existingRate)
|
||||
: self::DEFAULT_RATE;
|
||||
|
||||
if (!is_string($existingSnapshotJson) || trim($existingSnapshotJson) === '') {
|
||||
return [
|
||||
'commission_rate' => $fallbackRate,
|
||||
'commission_snapshot' => null,
|
||||
$snap = (is_string($existingSnapshotJson) && trim($existingSnapshotJson) !== '')
|
||||
? json_decode($existingSnapshotJson, true)
|
||||
: null;
|
||||
|
||||
if (!is_array($snap)) {
|
||||
$snap = [
|
||||
'version' => 1,
|
||||
'snapshot_time' => time(),
|
||||
'include_diff_in_commission' => 1,
|
||||
'active_rule' => [
|
||||
'rule_id' => 0,
|
||||
'rule_name' => '比例快照(' . number_format($fallbackRate, 2, '.', '') . '%)',
|
||||
'min_amount' => 0.00,
|
||||
'max_amount' => 0.00,
|
||||
'calc_mode' => 'percent',
|
||||
'commission_rate' => $fallbackRate,
|
||||
'fixed_fee' => 0.00,
|
||||
'min_commission' => 0.00,
|
||||
'max_commission' => 0.00,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$snap = json_decode($existingSnapshotJson, true);
|
||||
if (!is_array($snap)) {
|
||||
return [
|
||||
'commission_rate' => $fallbackRate,
|
||||
'commission_snapshot' => $existingSnapshotJson,
|
||||
];
|
||||
}
|
||||
$userQuoteAmount = round(max(0.00, (float)($quoteRow['amount'] ?? $finalAmount)), 2);
|
||||
$masterAmount = round(max(0.00, (float)($quoteRow['master_amount'] ?? 0)), 2);
|
||||
$platformFee = round(max(0.00, (float)($quoteRow['platform_fee'] ?? ($userQuoteAmount - $masterAmount))), 2);
|
||||
|
||||
$chosen = null;
|
||||
if (!empty($snap['candidate_tiers']) && is_array($snap['candidate_tiers'])) {
|
||||
foreach ($snap['candidate_tiers'] as $tier) {
|
||||
if (is_array($tier) && self::matchAmountRange($tier, $finalAmount)) {
|
||||
if (is_array($tier) && self::matchAmountRange($tier, $userQuoteAmount)) {
|
||||
$chosen = $tier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($chosen === null) {
|
||||
if (!empty($snap['fallback_rule']) && is_array($snap['fallback_rule'])) {
|
||||
$chosen = $snap['fallback_rule'];
|
||||
@@ -345,20 +473,27 @@ class CommissionService
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($chosen)) {
|
||||
$snap['active_rule'] = $chosen;
|
||||
$snap['confirmed_quote_amount'] = round(max(0.00, $finalAmount), 2);
|
||||
$snap['confirmed_time'] = time();
|
||||
$newRate = self::calcDisplayRateForAmount($finalAmount, $chosen);
|
||||
return [
|
||||
'commission_rate' => $newRate,
|
||||
'commission_snapshot' => json_encode($snap, JSON_UNESCAPED_UNICODE),
|
||||
];
|
||||
}
|
||||
$snap['active_rule'] = $chosen;
|
||||
$snap['confirmed_quote_amount'] = round(max(0.00, $finalAmount), 2);
|
||||
$snap['confirmed_time'] = time();
|
||||
$snap['quote_pricing_mode'] = 'markup';
|
||||
$snap['quote_markup'] = [
|
||||
'master_amount' => $masterAmount,
|
||||
'platform_fee' => $platformFee,
|
||||
'user_amount' => $userQuoteAmount,
|
||||
'rule_id' => (int)($chosen['rule_id'] ?? 0),
|
||||
'rule_name' => (string)($chosen['rule_name'] ?? '全局默认抽佣规则'),
|
||||
'calc_mode' => (string)($chosen['calc_mode'] ?? 'percent'),
|
||||
'config_rate' => self::normalizeRate($chosen['commission_rate'] ?? $fallbackRate),
|
||||
];
|
||||
|
||||
$newRate = $finalAmount > 0
|
||||
? self::normalizeRate(round(min($finalAmount, $platformFee) / $finalAmount * 100, 2))
|
||||
: self::calcDisplayRateForAmount($userQuoteAmount, $chosen);
|
||||
|
||||
return [
|
||||
'commission_rate' => $fallbackRate,
|
||||
'commission_snapshot' => $existingSnapshotJson,
|
||||
'commission_rate' => $newRate,
|
||||
'commission_snapshot' => json_encode($snap, JSON_UNESCAPED_UNICODE),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -469,8 +604,45 @@ class CommissionService
|
||||
if (is_string($snapshotJson) && trim($snapshotJson) !== '') {
|
||||
$snap = json_decode($snapshotJson, true);
|
||||
if (is_array($snap) && !empty($snap['active_rule']) && is_array($snap['active_rule'])) {
|
||||
$calcBase = $totalAmount;
|
||||
$includeDiff = isset($snap['include_diff_in_commission']) ? (int)$snap['include_diff_in_commission'] : 1;
|
||||
|
||||
// 净价外加模式报价单:基础部分保证师傅按其净报价全额结算,现场增项差价继续沿用现行抽佣规则
|
||||
if ($overrideAmount === null && ($snap['quote_pricing_mode'] ?? '') === 'markup' && !empty($snap['quote_markup']) && is_array($snap['quote_markup'])) {
|
||||
$masterBase = round(max(0.00, (float)($snap['quote_markup']['master_amount'] ?? 0)), 2);
|
||||
$diffAmt = ((int)($order['diff_status'] ?? 0) === 2)
|
||||
? round(max(0.00, (float)($order['diff_amount'] ?? 0)), 2)
|
||||
: 0.00;
|
||||
if ($diffAmt > $totalAmount) {
|
||||
$diffAmt = $totalAmount;
|
||||
}
|
||||
$basePaid = round(max(0.00, $totalAmount - $diffAmt), 2);
|
||||
$baseMasterSettle = round(min($basePaid, $masterBase), 2);
|
||||
$baseComm = round(max(0.00, $basePaid - $baseMasterSettle), 2);
|
||||
|
||||
$diffComm = 0.00;
|
||||
if ($diffAmt > 0 && $includeDiff === 1) {
|
||||
$diffCalc = self::computeCommissionByRuleItem($diffAmt, $diffAmt, $snap['active_rule']);
|
||||
$diffComm = $diffCalc['commission'];
|
||||
}
|
||||
|
||||
$totalComm = round(min($totalAmount, max(0.00, $baseComm + $diffComm)), 2);
|
||||
$totalSettle = round(max(0.00, $totalAmount - $totalComm), 2);
|
||||
$effectiveRate = $totalAmount > 0
|
||||
? self::normalizeRate(round($totalComm / $totalAmount * 100, 2))
|
||||
: 0.00;
|
||||
$calcBase = $includeDiff === 1 ? $totalAmount : $basePaid;
|
||||
|
||||
return [
|
||||
'commission_rate' => $effectiveRate,
|
||||
'commission' => $totalComm,
|
||||
'settle_amount' => $totalSettle,
|
||||
'calc_mode' => (string)($snap['active_rule']['calc_mode'] ?? 'percent'),
|
||||
'rule_name' => (string)($snap['active_rule']['rule_name'] ?? '报价外加服务费'),
|
||||
'calc_base_amount' => $calcBase,
|
||||
];
|
||||
}
|
||||
|
||||
$calcBase = $totalAmount;
|
||||
if ($overrideAmount === null && $includeDiff === 0 && (int)($order['diff_status'] ?? 0) === 2) {
|
||||
$diffAmt = round(max(0.00, (float)($order['diff_amount'] ?? 0)), 2);
|
||||
if ($diffAmt > 0 && $calcBase >= $diffAmt) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
在新工单中引用
屏蔽一个用户