Commit bf17db94 by Lin

Merge branch 'SAAS+V5.8.2' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into feature/strategy-center
2 parents 2060bf8c 926f5dd7
##
### 仅给自动化流程时使用
请根据 git diff 为此处改动编写单元测试代码。
## 要求:
1. 严格遵循 /.ai/rules/JEST_TESTING.md 和 /.ai/rules/TESTING_GUIDE.md 中的规范
2. 使用 Jest 测试框架,遵循 AAA 模式(Arrange-Act-Assert)
3. 测试文件命名:*.spec.js,存放在与被测文件同级目录
## Mock 规范(必须遵守):
- 在测试文件顶部按顺序执行:定义 mock 函数 → jest.mock() → require() 导入被测试模块
- 每次测试前使用 jest.clearAllMocks() 重置 mock
- 组件测试在 afterEach 中调用 wrapper.destroy()
## 输出格式:
1. 📂 测试文件路径:[完整路径]
2. 📝 测试代码:[完整的测试代码,可直接运行]
......@@ -7,3 +7,7 @@ indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{yml,yaml}]
indent_style = space
indent_size = 2
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
# 基础工具
RUN apt-get update && apt-get install -y \
curl \
git \
nano \
ca-certificates \
bash \
unzip \
jq \
&& rm -rf /var/lib/apt/lists/*
# Volta
ENV VOLTA_HOME=/root/.volta
ENV PATH=$VOLTA_HOME/bin:$PATH
RUN curl https://get.volta.sh | bash
# 安装 Node14
RUN volta install node@14
# 默认 Node22
RUN volta install node@22
# Claude Code
RUN npm install -g @anthropic-ai/claude-code
# 触发一次 claude 命令让它生成初始的 ~/.claude.json(如果它还没生成的话)
# 并使用 jq 安全地注入 hasCompletedOnboarding 字段,不破坏原有内容
RUN mkdir -p /root && \
touch /root/.claude.json && \
(echo '{}' > /root/.claude.json) && \
jq '. + {"hasCompletedOnboarding": true}' /root/.claude.json > /root/.claude.json.tmp && \
mv /root/.claude.json.tmp /root/.claude.json
WORKDIR /workspace
CMD ["/bin/bash"]
services:
ai-worker:
build:
context: .
dockerfile: ../build/Dockerfile.unit.test
container_name: ai-worker
working_dir: /workspace
volumes:
- ./workspace:/workspace
environment:
- ANTHROPIC_AUTH_TOKEN
- ANTHROPIC_BASE_URL=https://dashscope.aliyuncs.com/apps/anthropic
- ANTHROPIC_MODEL=qwen3.5-plus
- ANTHROPIC_SMALL_FAST_MODEL=qwen3.5-flash
- ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen3.5-flash
- ANTHROPIC_DEFAULT_SONNET_MODEL=qwen3.5-plus
- ANTHROPIC_DEFAULT_OPUS_MODEL=qwen3.5-plus
- CLAUDE_CODE_SUBAGENT_MODEL=qwen3.5-plus
# 保持容器在前台常驻,防止执行完立刻退出崩溃
command: sh -c "tail -f /dev/null"
restart: unless-stopped
......@@ -143,7 +143,6 @@
</el-tag>
<span v-else>-</span>
</div>
</template>
<template v-else-if="sub.formatter">
<span v-if="sub.html" v-html="sub.formatter(scope.row)" />
......@@ -259,7 +258,6 @@
</div>
</template>
<template v-else-if="item.formatter">
<span v-if="item.html" v-html="item.formatter(scope.row)" />
......
......@@ -93,10 +93,12 @@ import {
} from '../utils/divisionTestStepProgress'
import {
buildStep2DisplayMerchants,
buildStep3VerifyMerchants,
isTotalProfitAmountValid
buildStep3VerifyMerchants
} from '../utils/buildStep2DisplayMerchants'
import { buildStep3SubmitMerchants } from '../utils/validateStep3Amounts'
import {
buildStep3SubmitMerchants,
isStep3AmountTotalConsistent
} from '../utils/validateStep3Amounts'
import {
buildDivisionRuleTestParams,
buildDivisionRuleTestRetestParams,
......@@ -514,10 +516,6 @@ export default {
return
}
if (this.viewStep === 2) {
if (!isTotalProfitAmountValid(this.step2Merchants)) {
this.$message.warning('金额不一致,请确认后重新操作')
return
}
this.maxReachedStep = 3
this.setViewStep(3)
}
......@@ -531,6 +529,10 @@ export default {
const rawList = resolveDivisionTestMerchantDivisions(this.testObj)
const formMerchants = step3.getSubmitMerchants()
if (!isStep3AmountTotalConsistent(formMerchants, rawList)) {
this.$message.warning('金额不一致,请确认后重新操作')
return
}
const testMerchantDivisions = buildStep3SubmitMerchants(rawList, formMerchants)
const params = buildDivisionRuleTestMoneyValidParams({
testObj: this.testObj,
......
......@@ -79,3 +79,45 @@ export function buildStep3SubmitMerchants(displayMerchants, formMerchants) {
}
})
}
function roundMoney(n) {
return Math.round(n * 100) / 100
}
function parseMoney(value) {
const n = parseFloat(value)
return Number.isFinite(n) ? n : 0
}
/** 待确认商户接口返回 divisionMoney 合计 */
export function sumExpectedDivisionMoney(rawList) {
return roundMoney(
getStep3PendingMerchants(rawList).reduce(
(sum, m) => sum + parseMoney(m.divisionMoney),
0
)
)
}
/** 待确认商户用户填写 confirmDivisionMoney 合计 */
export function sumConfirmDivisionMoney(formMerchants, rawList) {
const formMap = new Map()
;(formMerchants || []).forEach((m) => {
const key = step3MerchantKey(m)
if (key) formMap.set(key, m)
})
return roundMoney(
getStep3PendingMerchants(rawList).reduce((sum, m) => {
const key = step3MerchantKey(m)
const form = formMap.get(key) || m
return sum + parseMoney(form.confirmDivisionMoney)
}, 0)
)
}
/** 用户填写合计与接口 divisionMoney 合计是否一致 */
export function isStep3AmountTotalConsistent(formMerchants, rawList) {
const expected = sumExpectedDivisionMoney(rawList)
const actual = sumConfirmDivisionMoney(formMerchants, rawList)
return Math.abs(actual - expected) < 0.001
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!