feat(quote): 师傅报价支持加价模式与工钱口径优化

- 加价计算:CommissionService 新增 calcQuoteMarkupByOrder,师傅端录入净报价,平台自动计入服务费并生成用户端应付报价
- 订单与结算:PaymentService 与 Master 控制器在选择报价与完成服务时联动刷新佣金快照,确保师傅到手收益准确
- 后台与小程序:后台订单详情展示师傅净报价与服务费明细,师傅端订单列表与详情统一定义工钱口径为预计工钱/实结工钱
这个提交包含在:
2026-11-27 17:46:12 +08:00
父节点 894da56623
当前提交 4e69f326e5
共有 10 个文件被更改,包括 694 次插入 和 79 次删除

查看文件

@@ -0,0 +1,37 @@
-- ==============================================================================
-- Phase 33: 师傅报价净价外加平台服务费模式 (方案A:用户价 = 师傅净报价 + 外加抽成)
-- ==============================================================================
-- 1. fa_order_quote 新增 master_amount(师傅净报价)
SET @col_exists_ma := (
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'fa_order_quote'
AND COLUMN_NAME = 'master_amount'
);
SET @sql_ma := IF(
@col_exists_ma = 0,
'ALTER TABLE `fa_order_quote` ADD COLUMN `master_amount` decimal(10,2) NOT NULL DEFAULT ''0.00'' COMMENT ''师傅净报价(不含平台加价)'' AFTER `master_id`',
'SELECT 1'
);
PREPARE stmt_ma FROM @sql_ma;
EXECUTE stmt_ma;
DEALLOCATE PREPARE stmt_ma;
-- 2. fa_order_quote 新增 platform_fee(平台外加服务费/抽成)
SET @col_exists_pf := (
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'fa_order_quote'
AND COLUMN_NAME = 'platform_fee'
);
SET @sql_pf := IF(
@col_exists_pf = 0,
'ALTER TABLE `fa_order_quote` ADD COLUMN `platform_fee` decimal(10,2) NOT NULL DEFAULT ''0.00'' COMMENT ''平台外加服务费(元)'' AFTER `master_amount`',
'SELECT 1'
);
PREPARE stmt_pf FROM @sql_pf;
EXECUTE stmt_pf;
DEALLOCATE PREPARE stmt_pf;

查看文件

@@ -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,

查看文件

@@ -247,11 +247,11 @@ async function fulfillAndVerify(mToken, uToken, orderId) {
const quoteId = sql(`SELECT id FROM fa_order_quote WHERE order_id=${orderQ} AND master_id=${masterId} ORDER BY id DESC LIMIT 1`);
assert(Number(quoteId) > 0, 'M3 报价单已生成', 'quote_id=' + quoteId);
// M3 用户选定报价并一次性托管全额(首付0元,托管金额=报价全额)
const diffExpect = QUOTE_AMT;
// M3 用户选定报价并一次性托管全额(方案A:师傅净报价150 + 平台10%服务费15 = 用户托管165)
const diffExpect = Math.round(QUOTE_AMT * 1.1 * 100) / 100;
const choose = await api('/order/chooseQuote', { method: 'POST', token: uToken, data: { order_id: orderQ, quote_id: quoteId, pay_type: 'balance' } });
assert(choose.code === 1 && choose.data && choose.data.paid === true, 'M3 选定报价并完成支付托管', choose.code === 1 ? `托管¥${choose.data.amount} (期望${diffExpect})` : choose.msg);
assert(choose.code === 1 && Math.abs(Number(choose.data.amount) - diffExpect) < 0.01, 'M3 托管金额=报价全额(0元首付不预收)', `托管¥${choose.data ? choose.data.amount : '?'}`);
assert(choose.code === 1 && Math.abs(Number(choose.data.amount) - diffExpect) < 0.01, 'M3 托管金额=报价+服务费(0元首付不预收)', `托管¥${choose.data ? choose.data.amount : '?'}`);
const boundMaster = Number(sql(`SELECT master_id FROM fa_order WHERE id=${orderQ}`));
assert(boundMaster === Number(masterId), 'M3 选报价后订单锁定报价师傅', 'master_id=' + boundMaster);
const stQ2 = Number(sql(`SELECT status FROM fa_order WHERE id=${orderQ}`));
@@ -266,8 +266,8 @@ async function fulfillAndVerify(mToken, uToken, orderId) {
const rQ = await fulfillAndVerify(mToken, uToken, orderQ);
assert(rQ.ok === true, 'M3 履约全链路 → 已完成', rQ.error || '');
const settleQ = Number(sql(`SELECT settle_amount FROM fa_order WHERE id=${orderQ}`));
const expectQ = Math.round(QUOTE_AMT * 0.9 * 100) / 100;
assert(Math.abs(settleQ - expectQ) < 0.01, 'M3 结算基数=选定报价金额×90%', `结算${settleQ} (期望${expectQ})`);
const expectQ = QUOTE_AMT;
assert(Math.abs(settleQ - expectQ) < 0.01, 'M3 结算基数=选定师傅净报价', `结算${settleQ} (期望${expectQ})`);
// 汇总
console.log('\n════════════════════════════════════════════════════════');

394
tests/quote_markup_test.php 普通文件
查看文件

@@ -0,0 +1,394 @@
<?php
/**
* 方案A(师傅净价外加平台服务费)全链路回归测试
* 运行:php tests/quote_markup_test.php
*/
define('APP_PATH', __DIR__ . '/../server/application/');
require __DIR__ . '/../server/thinkphp/base.php';
\think\App::initCommon();
use think\Db;
use app\common\library\CommissionService;
use app\common\library\OrderStatus;
use app\common\library\PaymentService;
$pass = 0;
$fail = 0;
$fails = [];
function check($name, $cond, $detail = '')
{
global $pass, $fail, $fails;
if ($cond) {
$pass++;
echo " [PASS] {$name}" . ($detail !== '' ? " -> {$detail}" : '') . "\n";
} else {
$fail++;
$fails[] = "{$name} ({$detail})";
echo " [FAIL] {$name}" . ($detail !== '' ? " -> {$detail}" : '') . "\n";
}
}
function approx($a, $b, $eps = 0.01)
{
return abs((float)$a - (float)$b) < $eps;
}
echo "════════════════════════════════════════════════════════\n";
echo " 方案A:师傅报价外加抽成模式 自动化回归测试\n";
echo "════════════════════════════════════════════════════════\n";
$createdOrderIds = [];
$createdQuoteIds = [];
$createdPayIds = [];
$createdLogIds = [];
$createdMsgIds = [];
$createdWalletLogIds = [];
try {
// 1. 纯算法测试:基础 10% 规则
echo "\n■ 1. CommissionService 算法单元测试\n";
$snapMatch = CommissionService::matchOrderSnapshot([
'price_type' => 'quote',
'customer_type' => 'personal',
'cat_id' => 0,
'urgent' => 0,
'order_amount' => 0,
]);
$mockOrder = [
'price_type' => 'quote',
'commission_rate' => $snapMatch['commission_rate'],
'commission_snapshot' => $snapMatch['commission_snapshot'],
];
$m200 = CommissionService::calcQuoteMarkupByOrder($mockOrder, 200.00);
check('师傅报200(10%规则):master_amount=200', approx($m200['master_amount'], 200.00), $m200['master_amount']);
check('师傅报200(10%规则):platform_fee=20', approx($m200['platform_fee'], 20.00), $m200['platform_fee']);
check('师傅报200(10%规则):user_amount=220', approx($m200['user_amount'], 220.00), $m200['user_amount']);
check('师傅报200(10%规则):有效抽成率=9.09%', approx($m200['commission_rate'], 9.09), $m200['commission_rate']);
// 选标快照刷新 + 结算
$quoteRowNew = [
'id' => 999,
'master_amount' => $m200['master_amount'],
'platform_fee' => $m200['platform_fee'],
'amount' => $m200['user_amount'],
];
$refreshed = CommissionService::refreshQuoteOrderSnapshotOnAmountConfirmed(
220.00,
$mockOrder['commission_snapshot'],
$mockOrder['commission_rate'],
$quoteRowNew
);
$settledOrder = [
'pay_amount' => 220.00,
'total_amount' => 220.00,
'diff_status' => 0,
'diff_amount' => 0.00,
'commission_rate' => $refreshed['commission_rate'],
'commission_snapshot' => $refreshed['commission_snapshot'],
];
$calcBase = CommissionService::calcByOrder($settledOrder);
check('无增项全额结算:师傅实得=200.00', approx($calcBase['settle_amount'], 200.00), $calcBase['settle_amount']);
check('无增项全额结算:平台抽佣=20.00', approx($calcBase['commission'], 20.00), $calcBase['commission']);
// 2. 叠加现场增项补差价(增项仍按现行10%抽佣)
echo "\n■ 2. 增项补差价联动与优惠券边界\n";
$settledWithDiff = $settledOrder;
$settledWithDiff['pay_amount'] = 320.00;
$settledWithDiff['total_amount'] = 320.00;
$settledWithDiff['diff_status'] = 2;
$settledWithDiff['diff_amount'] = 100.00;
$calcDiff = CommissionService::calcByOrder($settledWithDiff);
check('叠加增项100:师傅实得=290.00(200+90)', approx($calcDiff['settle_amount'], 290.00), $calcDiff['settle_amount']);
check('叠加增项100:平台抽佣=30.00(20+10)', approx($calcDiff['commission'], 30.00), $calcDiff['commission']);
// 优惠券抵扣10元(用户实付210)
$refreshedCoupon = CommissionService::refreshQuoteOrderSnapshotOnAmountConfirmed(
210.00,
$mockOrder['commission_snapshot'],
$mockOrder['commission_rate'],
$quoteRowNew
);
$calcCoupon = CommissionService::calcByOrder([
'pay_amount' => 210.00,
'total_amount' => 220.00,
'diff_status' => 0,
'diff_amount' => 0.00,
'commission_rate' => $refreshedCoupon['commission_rate'],
'commission_snapshot' => $refreshedCoupon['commission_snapshot'],
]);
check('用户用10元优惠券实付210:师傅仍实得=200.00', approx($calcCoupon['settle_amount'], 200.00), $calcCoupon['settle_amount']);
check('用户用10元优惠券实付210:平台实收抽佣=10.00', approx($calcCoupon['commission'], 10.00), $calcCoupon['commission']);
// 3. 金额阶梯与混合/固定费规则验证
echo "\n■ 3. 多维阶梯与混合计佣校验\n";
$tierSnap = [
'version' => 1,
'snapshot_time' => time(),
'include_diff_in_commission' => 1,
'active_rule' => [
'rule_id' => 101, 'rule_name' => '小额档', 'min_amount' => 0, 'max_amount' => 200,
'calc_mode' => 'percent', 'commission_rate' => 10.00, 'fixed_fee' => 0, 'min_commission' => 0, 'max_commission' => 0,
],
'fallback_rule' => [
'rule_id' => 0, 'rule_name' => '兜底', 'min_amount' => 0, 'max_amount' => 0,
'calc_mode' => 'percent', 'commission_rate' => 10.00, 'fixed_fee' => 0, 'min_commission' => 0, 'max_commission' => 0,
],
'candidate_tiers' => [
[
'rule_id' => 101, 'rule_name' => '小额档', 'min_amount' => 0, 'max_amount' => 200,
'calc_mode' => 'percent', 'commission_rate' => 10.00, 'fixed_fee' => 0, 'min_commission' => 0, 'max_commission' => 0,
],
[
'rule_id' => 102, 'rule_name' => '大额封顶档', 'min_amount' => 200.01, 'max_amount' => 0,
'calc_mode' => 'mixed', 'commission_rate' => 8.00, 'fixed_fee' => 5.00, 'min_commission' => 0, 'max_commission' => 30.00,
],
],
];
$tierOrder = ['price_type' => 'quote', 'commission_rate' => 10.00, 'commission_snapshot' => json_encode($tierSnap, JSON_UNESCAPED_UNICODE)];
$mBig = CommissionService::calcQuoteMarkupByOrder($tierOrder, 500.00);
// 500 * 8% + 5 = 45 -> 封顶30 -> user_amount = 530
check('阶梯+混合+封顶规则:platform_fee=30.00', approx($mBig['platform_fee'], 30.00), $mBig['platform_fee']);
check('阶梯+混合+封顶规则:user_amount=530.00', approx($mBig['user_amount'], 530.00), $mBig['user_amount']);
// 4. 数据库真实链路闭环(余额选标支付 -> 通知文案校验 -> 结算计算)
echo "\n■ 4. 余额选标与通知文案数据库闭环测试\n";
$user = Db::name('user')->order('id asc')->find();
$master = Db::name('master')->where('verify_status', 'pass')->order('id asc')->find();
if ($user && $master) {
$now = time();
$origUserMoney = (float)$user['money'];
Db::name('user')->where('id', (int)$user['id'])->update(['money' => $origUserMoney + 500.00]);
$orderNo = 'QMT' . date('YmdHis') . mt_rand(1000, 9999);
$orderId = (int)Db::name('order')->insertGetId([
'order_no' => $orderNo,
'user_id' => (int)$user['id'],
'master_id' => 0,
'cat_id' => 1,
'service_id' => 0,
'service_name' => '方案A测试报价单',
'price_type' => 'quote',
'contact' => '测试业主',
'mobile' => '13800000000',
'province' => '贵州省',
'city' => '遵义市',
'district' => '汇川区',
'address' => '测试路1号',
'base_amount' => 0,
'total_amount' => 0,
'pay_amount' => 0,
'commission_rate' => $snapMatch['commission_rate'],
'commission_snapshot' => $snapMatch['commission_snapshot'],
'status' => OrderStatus::QUOTING,
'pay_status' => 0,
'verify_code' => '123456',
'createtime' => $now,
'updatetime' => $now,
]);
$createdOrderIds[] = $orderId;
$quoteId = (int)Db::name('order_quote')->insertGetId([
'order_id' => $orderId,
'master_id' => (int)$master['id'],
'master_amount' => 200.00,
'platform_fee' => 20.00,
'amount' => 220.00,
'description' => '回归测试报价',
'valid_hours' => 24,
'expire_time' => $now + 86400,
'status' => 'wait',
'createtime' => $now,
]);
$createdQuoteIds[] = $quoteId;
$orderRow = Db::name('order')->where('id', $orderId)->find();
$payRes = PaymentService::payOrderByBalance($orderRow, (int)$user['id'], 'quote', $quoteId);
check('余额选标支付成功', !empty($payRes['paid']) && approx($payRes['amount'], 220.00), 'paid=' . ($payRes['amount'] ?? 'null'));
$afterOrder = Db::name('order')->where('id', $orderId)->find();
check('选标后订单pay_amount=220.00', approx($afterOrder['pay_amount'], 220.00), $afterOrder['pay_amount']);
check('选标后订单master_id已锁定', (int)$afterOrder['master_id'] === (int)$master['id'], $afterOrder['master_id']);
$afterSettle = CommissionService::calcByOrder($afterOrder);
check('选标后预计结算金额:师傅得200.00', approx($afterSettle['settle_amount'], 200.00), $afterSettle['settle_amount']);
check('选标后预计平台抽佣:20.00', approx($afterSettle['commission'], 20.00), $afterSettle['commission']);
// 验证微信回调路径通知也用净报价,同时模拟清理余额
Db::name('user')->where('id', (int)$user['id'])->update(['money' => $origUserMoney]);
$createdPayIds = Db::name('pay_order')->where('order_id', $orderId)->column('id');
$createdLogIds = Db::name('order_log')->where('order_id', $orderId)->column('id');
$createdMsgIds = Db::name('message')->where('order_id', $orderId)->column('id');
$createdWalletLogIds = Db::name('wallet_log')->where('order_id', $orderId)->column('id');
} else {
check('数据库存在测试账号与师傅记录', false, '跳过DB闭环');
}
// 5. 真实 HTTP API 端到端链路测试(用户创单 -> 师傅报价 -> 双端详情/列表 -> 余额选标 -> 核销入账)
echo "\n■ 5. 真实 HTTP API 端到端链路测试\n";
$apiBase = 'http://yjyf:9560/api';
$httpJson = function ($path, $method = 'GET', $data = null, $headers = []) use ($apiBase) {
$opts = [
'http' => [
'method' => $method,
'timeout' => 5,
'ignore_errors' => true,
'header' => implode("\r\n", array_merge(['Content-Type: application/x-www-form-urlencoded'], $headers)),
],
];
if ($data !== null) {
$opts['http']['content'] = http_build_query($data);
}
$raw = @file_get_contents($apiBase . $path, false, stream_context_create($opts));
return $raw ? json_decode($raw, true) : null;
};
$stamp = substr((string)time(), -6) . mt_rand(10, 99);
$uMobile = '139' . $stamp;
$mMobile = '137' . $stamp;
$uLogin = $httpJson('/auth/login', 'POST', ['mobile' => $uMobile, 'password' => 'QmTest@123']);
$mMasterLogin = $httpJson('/master_auth/login', 'POST', ['mobile' => $mMobile, 'password' => 'QmTest@123']);
$uIdNew = (int)($uLogin['data']['userinfo']['id'] ?? 0);
$mIdNew = (int)($mMasterLogin['data']['masterinfo']['id'] ?? 0);
$uTok = $uLogin['data']['token'] ?? '';
$mTok = $mMasterLogin['data']['token'] ?? '';
$addrIdNew = 0;
if ($uIdNew > 0 && $mIdNew > 0 && $uTok !== '' && $mTok !== '') {
// 给新用户设余额、支付密码,并使新师傅通过实名审核且处于听单状态
Db::name('user')->where('id', $uIdNew)->update(['money' => 500.00]);
\app\common\library\AccountSecurity::ensure($uIdNew);
Db::name('user_security')->where('user_id', $uIdNew)->update([
'payment_password_hash' => password_hash('123456', PASSWORD_DEFAULT),
]);
Db::name('master')->where('id', $mIdNew)->update([
'realname' => 'E2E测试师傅',
'city' => '遵义市',
'lng' => '106.927',
'lat' => '27.725',
'work_status' => 'on',
'verify_status' => 'pass',
'money' => 0.00,
]);
$addrRes = $httpJson('/address/save', 'POST', [
'contact' => 'E2E测试', 'mobile' => $uMobile, 'province' => '贵州省', 'city' => '遵义市',
'district' => '汇川区', 'address' => '测试大道88号', 'floor' => 2, 'has_elevator' => 1, 'lng' => '106.927', 'lat' => '27.725',
], ['token: ' . $uTok]);
$addrIdNew = (int)($addrRes['data']['id'] ?? 0);
$svcRow = Db::name('service')->where('status', 'normal')->order('id asc')->find();
$ordCreate = $httpJson('/order/create', 'POST', [
'service_id' => (int)$svcRow['id'],
'address_id' => $addrIdNew,
'price_type' => 'quote',
], ['token: ' . $uTok]);
$ordIdNew = (int)($ordCreate['data']['order_id'] ?? 0);
check('HTTP 创建报价单成功', $ordIdNew > 0, 'order_id=' . $ordIdNew);
if ($ordIdNew > 0) {
$createdOrderIds[] = $ordIdNew;
$qSub = $httpJson('/master/quote', 'POST', [
'order_id' => $ordIdNew, 'amount' => 200, 'description' => 'HTTP测试报价', 'valid_hours' => 24,
], ['token: ' . $mTok]);
check('HTTP 师傅提交净报价200成功', ($qSub['code'] ?? 0) === 1, $qSub['msg'] ?? '');
$uDet = $httpJson('/order/detail?id=' . $ordIdNew, 'GET', null, ['token: ' . $uTok]);
$uQuoteAmt = (float)($uDet['data']['quotes'][0]['amount'] ?? 0);
check('HTTP 用户端详情看到加价后报价=220', approx($uQuoteAmt, 220.00), $uQuoteAmt);
$mDetBefore = $httpJson('/master/orderDetail?id=' . $ordIdNew, 'GET', null, ['token: ' . $mTok]);
$mQuoteAmt = (float)($mDetBefore['data']['my_quote']['amount'] ?? 0);
$mQuoteFee = (float)($mDetBefore['data']['my_quote']['master_fee'] ?? 0);
check('HTTP 师傅端详情my_quote仅显示200(无抽成感)', approx($mQuoteAmt, 200.00) && approx($mQuoteFee, 200.00), "amt={$mQuoteAmt}, fee={$mQuoteFee}");
$mQuotesRes = $httpJson('/master/quotes', 'GET', null, ['token: ' . $mTok]);
$mQRow = $mQuotesRes['data']['list'][0] ?? null;
check('HTTP 师傅端我的报价列表显示200/200', $mQRow && approx($mQRow['amount'], 200.00) && approx($mQRow['master_fee'], 200.00), $mQRow ? "{$mQRow['amount']}/{$mQRow['master_fee']}" : 'null');
$qIdNew = (int)($uDet['data']['quotes'][0]['id'] ?? 0);
$chooseRes = $httpJson('/order/chooseQuote', 'POST', [
'order_id' => $ordIdNew, 'quote_id' => $qIdNew, 'pay_type' => 'balance', 'payment_password' => '123456',
], ['token: ' . $uTok]);
check('HTTP 用户选标支付托管220成功', ($chooseRes['code'] ?? 0) === 1 && approx($chooseRes['data']['amount'] ?? 0, 220.00), $chooseRes['msg'] ?? '');
$mOrdersRes = $httpJson('/master/orders?status=active', 'GET', null, ['token: ' . $mTok]);
$mOrdRow = $mOrdersRes['data']['list'][0] ?? null;
check('HTTP 师傅端我的订单列表master_fee=200(非220)', $mOrdRow && approx($mOrdRow['master_fee'], 200.00), $mOrdRow ? $mOrdRow['master_fee'] : 'null');
// 履约并核销结算
$httpJson('/master/contact', 'POST', ['order_id' => $ordIdNew], ['token: ' . $mTok]);
$httpJson('/master/schedule', 'POST', ['order_id' => $ordIdNew, 'appoint_time' => time() + 3600], ['token: ' . $mTok]);
$httpJson('/master/arrive', 'POST', ['order_id' => $ordIdNew, 'lng' => '106.927', 'lat' => '27.725'], ['token: ' . $mTok]);
$httpJson('/master/startJob', 'POST', ['order_id' => $ordIdNew], ['token: ' . $mTok]);
$httpJson('/master/finish', 'POST', ['order_id' => $ordIdNew, 'images' => ['https://example.com/1.jpg']], ['token: ' . $mTok]);
$vCode = Db::name('order')->where('id', $ordIdNew)->value('verify_code');
$verRes = $httpJson('/master/verifyCode', 'POST', ['order_id' => $ordIdNew, 'verify_code' => $vCode], ['token: ' . $mTok]);
check('HTTP 核销结算师傅实得=200.00', ($verRes['code'] ?? 0) === 1 && approx($verRes['data']['settle_amount'] ?? 0, 200.00) && approx($verRes['data']['balance'] ?? 0, 200.00), json_encode($verRes['data'] ?? [], JSON_UNESCAPED_UNICODE));
$settleDb = Db::name('settle')->where('order_id', $ordIdNew)->find();
check('HTTP 结算单落库(实付220/抽佣20/结算200)', $settleDb && approx($settleDb['order_amount'], 220.00) && approx($settleDb['commission'], 20.00) && approx($settleDb['settle_amount'], 200.00), $settleDb ? "{$settleDb['order_amount']}/{$settleDb['commission']}/{$settleDb['settle_amount']}" : 'null');
// 检查通知表:给师傅的选标通知不含220
$mNotifies = Db::name('message')->where('order_id', $ordIdNew)->where('receive_type', 'master')->select();
$noLeak220 = true;
foreach ($mNotifies as $mn) {
if (strpos((string)$mn['content'], '220') !== false) {
$noLeak220 = false;
}
}
check('HTTP 师傅站内消息未泄露用户加价金额220', $noLeak220, count($mNotifies) . '条');
// 清理 E2E 临时记录
Db::name('settle')->where('order_id', $ordIdNew)->delete();
Db::name('order_media')->where('order_id', $ordIdNew)->delete();
Db::name('order_quote')->where('order_id', $ordIdNew)->delete();
Db::name('pay_order')->where('order_id', $ordIdNew)->delete();
Db::name('order_log')->where('order_id', $ordIdNew)->delete();
Db::name('message')->where('order_id', $ordIdNew)->delete();
Db::name('wallet_log')->where('order_id', $ordIdNew)->delete();
Db::name('order')->where('id', $ordIdNew)->delete();
}
if ($addrIdNew > 0) Db::name('address')->where('id', $addrIdNew)->delete();
Db::name('master_token')->where('master_id', $mIdNew)->delete();
Db::name('master')->where('id', $mIdNew)->delete();
Db::name('user_security')->where('user_id', $uIdNew)->delete();
Db::name('user_token')->where('user_id', $uIdNew)->delete();
Db::name('user')->where('id', $uIdNew)->delete();
} else {
check('HTTP 登录创建测试账号成功', false, json_encode([$uLogin, $mMasterLogin], JSON_UNESCAPED_UNICODE));
}
} finally {
// 清理测试构造的数据
if ($createdWalletLogIds) {
Db::name('wallet_log')->whereIn('id', $createdWalletLogIds)->delete();
}
if ($createdMsgIds) {
Db::name('message')->whereIn('id', $createdMsgIds)->delete();
}
if ($createdLogIds) {
Db::name('order_log')->whereIn('id', $createdLogIds)->delete();
}
if ($createdPayIds) {
Db::name('pay_order')->whereIn('id', $createdPayIds)->delete();
}
if ($createdQuoteIds) {
Db::name('order_quote')->whereIn('id', $createdQuoteIds)->delete();
}
if ($createdOrderIds) {
Db::name('order')->whereIn('id', $createdOrderIds)->delete();
}
}
echo "\n════════════════════════════════════════════════════════\n";
echo " 结果汇总: PASS {$pass} / FAIL {$fail}\n";
if ($fail > 0) {
echo " 失败项:\n";
foreach ($fails as $f) {
echo " - {$f}\n";
}
}
echo "════════════════════════════════════════════════════════\n";
exit($fail > 0 ? 1 : 0);

查看文件

@@ -89,9 +89,9 @@
<view class="ft">
<view class="amt-box">
<text class="amt-label">订单金额</text>
<text class="amt-label">{{ Number(o.settle_status) === 1 ? '实结工钱' : '预计工钱' }}</text>
<text class="amt-symbol">¥</text>
<text class="amt-val">{{ Number(o.pay_amount || o.total_amount || 0).toFixed(2) }}</text>
<text class="amt-val">{{ Number(Number(o.settle_status) === 1 ? o.settle_amount : o.master_fee).toFixed(2) }}</text>
</view>
<view class="ops" @tap.stop>

查看文件

@@ -154,11 +154,7 @@
</view>
<view class="kv-row">
<text class="kv-k">我的报价</text>
<text class="kv-v">¥{{ Number(order.my_quote.amount).toFixed(2) }}</text>
</view>
<view class="kv-row">
<text class="kv-k">预计到手收益</text>
<text class="kv-v price">¥{{ Number(order.my_quote.master_fee !== undefined ? order.my_quote.master_fee : order.my_quote.amount).toFixed(2) }}</text>
<text class="kv-v price">¥{{ Number(order.my_quote.amount).toFixed(2) }}</text>
</view>
<view class="kv-row" v-if="order.my_quote.description">
<text class="kv-k">报价说明</text>

查看文件

@@ -64,12 +64,11 @@
<text class="q-desc" v-if="q.description">报价说明:{{ q.description }}</text>
</view>
<view class="amt-box">
<text class="amt-label">预计到手</text>
<text class="amt-label">我的报价</text>
<view class="amt-val-row">
<text class="amt-symbol">¥</text>
<text class="q-amt">{{ Number(q.master_fee !== undefined ? q.master_fee : (q.amount || 0)).toFixed(2) }}</text>
<text class="q-amt">{{ Number(q.amount || 0).toFixed(2) }}</text>
</view>
<text class="q-meta">报价 ¥{{ Number(q.amount || 0).toFixed(2) }}</text>
</view>
</view>