Commit 17eae35d by 张立顺

feat 低价单bug修复

1 parent eb17636f
Showing 43 changed files with 1672 additions and 97 deletions
账号 13510709443
\ No newline at end of file
......@@ -165,7 +165,7 @@ module.exports = {
/** 获取商户订单设置 */
getMerchantRecordingSettings(data) {
return api.post(
'dj.api.smartcarlife.recordingSettings.getMerchantRecordingSettings',
'dj.api.smartcarlife.order.field.lightChange.setting.list',
data
)
},
......
......@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布
* 5cdptest
*/
let index = 1;
let index = 2;
const accountInfo = wx.getAccountInfoSync();
const systemInfo = wx.getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion;
......
......@@ -44,12 +44,35 @@
进入下单页选择销售顾问或交付专员时,低价单直接回显前一步选定的 4S 店作为唯一合作
门店,并按该店加载员工;不再依赖“园区关联 4S 店”接口再次返回该门店。非低价单继续使用
原有门店查询逻辑。
在职员工接口返回的人员编号统一兼容 `uuid/staffUuid/staffUUID/userId/bussinessId/id`,空的
`uuid` 不会覆盖有效 `userId`;人员姓名兼容 `staffName/name/employeeName`。选择器显示的人员与
写入订单的 `userId/employeeName` 使用同一份规范化数据。
新建工单页底部只提供“直接下单”,不提供“建档”入口;客户信息仍通过页面内带档案图标的
“客户档案”选择器导入。未选档案时只在车主姓名行提示“请通过选择客户档案”,其余客户字段
不重复显示提示。客户档案列表、车型、商品、场景、礼券等需要门店参数的查询统一使用前一步
选中的 `merchantId`(4S 店)及 `yqMerchantId/sellerMerchantId`(园区店)。档案或历史订单回显
只更新客户和订单业务数据,不会覆盖已经选定的下单门店。
只导入客户信息、订单编号和备注,不带入场景、销售人员、商品和支付信息,也不会覆盖已经选定的
下单门店。
进入下单页时先把 `100101/精品升级/1` 作为完整本地兜底写入订单,再查询当前操作人最近使用的场景并保存其编码、名称和类型,随后按前一步选中的 4S 店查询可用场景列表并
完成展示回填;该展示任务不阻塞提交按钮。最近场景无效时使用该店首个可用场景;
门店场景列表为空或接口失败时保留进入页面时已经查询到的最近场景,不再二次清空;两个接口
均未取得完整场景时页面继续使用本地兜底。列表行未返回 `sceneType` 时依次使用最近场景
已有值和当前用户请求值,最近场景本身未返回类型时也使用当前用户请求值补齐。
该创建页是低价单专用入口,默认数据与 `onLoad` 都固定低价标记,不依赖调用方是否传递 `lowPriceFlag`;
点击“直接下单”不等待场景请求,直接使用页面当前完整场景进入本地校验或低价审批反馈,提交和审批确认均不再改写场景。
低价单按普通规则校验 `baseSceneCode`。页面订单类型默认且只能显示“低价订单”,底层兼容提交值保持
`djOrderType=1 + lowPriceFlag=1`。
选择客户档案只替换客户信息、订单编号和备注,不会改变进入页面时已确认的场景三字段。
客户档案确认固定走低价单白名单合并,不再调用普通订单 `onRoute`;销售顾问四字段只能由销售
顾问弹框的确认结果更新,其他订单回显不得覆盖。
车型、车架号、车牌号和手机号是否显示必填星号、是否在提交时拦截,统一使用员工版录单字段
接口 `dj.api.smartcarlife.order.field.lightChange.setting.list` 的动态配置。请求固定携带
`scene=1` 和所选 4S 店 `merchantId`,园区店 ID 仅用于筛选手机号默认配置;缓存同时按 4S 店和
园区店区分。接口明确配置为非必填的字段可留空,手机号可选但填写后仍校验格式;接口未返回
手机号字段时按员工版旧行为兜底为必填。
支付方式约定:
......@@ -117,4 +140,16 @@ npm run test:workOrder
| MR-WO-013 | 查看新建工单页底部操作区 | 只显示占满操作区的“直接下单”,不显示“建档”按钮 |
| MR-WO-014 | 未选择客户档案时查看客户区 | “客户档案”前显示档案图标,仅车主姓名行显示一次“请通过选择客户档案” |
| MR-WO-015 | 打开客户档案并选择客户/历史数据 | 列表请求使用前一步选中的 4S 店 ID,回填后仍保留下单 4S 店和所属园区店 |
| MR-WO-016 | 低价单选品、改价并直接下单 | 所有商品均显示最低价,选品回显不弹提醒;仅已开启最低价且录入价严格低于最低价时允许提交,否则改价时实时提示并阻断接口请求 |
| MR-WO-016 | 低价单选品、改价并直接下单 | 所有商品均显示最低价;输入和失焦不校验,提交时任一已开启最低价的商品低于最低价即可继续,否则提示统一文案并阻断接口请求 |
| MR-WO-017 | 门店 44210895 的员工版配置车牌为非必填,进入低价单客户区 | 使用 44210895 请求录单字段配置;车牌不显示星号、留空不拦截,其他字段各自按配置显示和校验 |
| MR-WO-018 | 选择门店进入低价单并直接提交 | 场景返回前页面已持有 `100101/精品升级/1` 本地兜底并可立即进入校验或审批;接口返回真实场景后提交真实值 |
| MR-WO-019 | 门店场景列表返回编码和名称但不返回 `sceneType` | 使用当前用户的精品场景类型完成回填,提交不提示“场景名称不能为空” |
| MR-WO-020 | 最近场景已含名称,门店列表匹配同一编码但未重复返回名称;随后选择客户档案 | 保留进入页确认的 `baseSceneCode/baseSceneName/sceneType`,档案中的场景字段不覆盖订单 |
| MR-WO-021 | 最近场景接口已返回完整场景,门店场景列表为空或请求失败;随后选择客户档案并提交 | 保留进入页场景编码、名称和类型,提交不提示“场景名称不能为空” |
| MR-WO-022 | 固定账号在开发者工具中重新打开下单页,`onLoad` 未携带入口参数;随后选择客户档案 | 场景请求前恢复低价单标识、4S 店 44210895 和园区店 44211025;档案只导入客户信息、订单编号和备注且不覆盖接口确认的场景 |
| MR-WO-023 | 场景接口为空、失败或返回其他完整场景,选择客户档案后提交 | 空或失败时保留页面本地兜底;接口返回完整场景时保留真实值;客户档案与提交链路均不覆盖当前场景 |
| MR-WO-024 | 进入低价下单页查看订单类型,路由未传或误传低价标识,场景接口尚未返回 | 页面仍固定为低价单且只能显示“低价订单”;点击不等待场景请求,使用页面已初始化的默认场景完成正常必填校验 |
| MR-WO-025 | 门店/销售顾问或转化人员的内部必填字段不完整时点击“直接下单” | 显示“销售顾问不能为空”或“转化人员不能为空”并定位到对应区域;任何未知必填键显示兜底提示,不再静默阻断 |
| MR-WO-026 | 在职员工接口返回空 `uuid`,但包含有效 `userId/name`;选择销售顾问后直接下单 | 选择态写入有效 `userId/employeeName`,提交不再误报“销售顾问不能为空” |
| MR-WO-027 | 选择包含历史订单数据的客户档案 | 只导入客户信息、`orderCode` 和备注;当前场景、销售人员、商品、支付信息均不被档案覆盖 |
| MR-WO-028 | 销售顾问初始化请求未返回前手动选择顾问,或上一单仅有顾问姓名没有人员编号 | 手选结果不被迟到的初始化响应覆盖;不完整的上一单人员信息不形成伪选中态 |
......@@ -212,7 +212,7 @@ flowchart TD
### 6.2 低价审批
`lowPriceFlag=1` 链路使用 [`lowPriceGoodsValidation.helpers.js`](../../tabWorkOrder/pages/createOrder/services/lowPriceGoodsValidation.helpers.js) 做整单资格校验,并用 `minPriceApproval.js` 按同一 `minSellPrice` 口径构建审批商品列表。校验通过后先展示审批确认弹层,用户确认后才请求下单接口;成功后返回低价单“待审批”页签。低价单订单类型固定为正常订单,商品价格小于 `0` 或大于 `100000` 元时阻止提交。
`lowPriceFlag=1` 链路使用 [`lowPriceGoodsValidation.helpers.js`](../../tabWorkOrder/pages/createOrder/services/lowPriceGoodsValidation.helpers.js) 做整单资格校验,并用 `minPriceApproval.js` 按同一 `minSellPrice` 口径构建审批商品列表。校验通过后先展示审批确认弹层,用户确认后才请求下单接口;成功后返回低价单“待审批”页签。低价单页面订单类型固定显示为“低价订单”,底层继续提交 `djOrderType=1 + lowPriceFlag=1`;页面先准备 `100101/精品升级/1` 本地兜底,再允许最近场景或门店可用场景覆盖,提交与审批确认不再改写场景。商品价格小于 `0` 或大于 `100000` 元时阻止提交。
## 7. 支付确认
......@@ -457,7 +457,7 @@ flowchart TD
|---|---|---|---|
| `serviceMerchant.getServiceBaseInfo` | 是 | 工单列表 `getCreateOrderSetting` 首次加载入口配置;`orderDetail` 加载详情后读取服务商配置 | 用于流量失效入口和质保卡展示,不参与首次下单 payload |
| `order.customerProfileInfo` | 是 | `createOrder.echoCustomerProfileIfNeeded`;选择客户或编辑/扫码等路由回显后,客户备注、VIN、车型任一为空且存在客户 ID 时调用 | 直接参与开单资料补全;失败被吞掉,不阻断选客户和提交 |
| `shopMerchantPointConfig.get` | 是 | `createOrder.onReady → getShopMerchantPointConfig` | 控制积分多角色文案/必填和可选订单类型;精品升级场景仍由前端固定限制为正常订单、内部结算 |
| `shopMerchantPointConfig.get` | 是 | `createOrder.onReady → getShopMerchantPointConfig` | 控制积分多角色文案/必填和可选订单类型;普通精品升级场景限制为正常订单、内部结算,低价入口固定显示“低价订单” |
| `order.field.lightChange.setting.list` | 部分可达 | `store.getYQorderInfo`;补录、战败、建档、订单信息更新等页面会调用 | 用于 VIN、车型、车牌动态必填和手机号配置;当前 `createOrder.getSetting` 只有定义、未被 `onLoad/onReady` 调用,直接新建页是否能获得最新配置依赖此前全局缓存,需补 UI 回归并由订单前端确认 |
| `order.search.containPackageGoods` | 是 | 精品工单列表加载/筛选;`CustomerInfo` 默认模式打开、搜索、分页 | 直接用于从历史工单选择客户,不是创建接口 |
| `vehicle.damage.upgrade.quotation.customer.page` | 否(精品开单) | 通用 `CustomerInfo` 仅在 `apiType=2` 时调用;当前只发现二手车评估和权益报价页传入该模式 | 当前 `createOrder` 未传 `apiType=2`,因此不属于精品升级开单链路 |
......
......@@ -2,7 +2,7 @@
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Complete the low-price order flow by restricting it to normal orders, requiring approval confirmation, returning successful submissions to the pending list, and rejecting invalid price boundaries.
**Goal:** Complete the low-price order flow by exposing only the low-price order business type, requiring approval confirmation, returning successful submissions to the pending list, and rejecting invalid price boundaries.
**Architecture:** Reuse the existing low-price approval sheet and pure approval-list builder. Add low-price-aware order-type helpers, a pure price-boundary helper consumed by both input and submit paths, and a small success-navigation helper so ordinary orders retain their current flow.
......@@ -13,7 +13,7 @@
- Preserve the user's existing `config.js` and `yarn.lock` changes.
- Use only `价格未触发最低价,其他正常单请到生意助手侧录单` when no goods triggers the minimum price.
- A low-price order is eligible when any submitted goods entry has `validMinSellPrice === 'Y'` and a current base price strictly below numeric `minSellPrice`.
- Low-price orders allow only order type `1` (`正常订单`).
- Low-price pages display only `低价订单`; the compatible payload remains `djOrderType=1 + lowPriceFlag=1`.
- Reject prices below `0` with `商品价格不能小于0元` and prices above `100000` with `商品价格不能大于100000元`.
- Do not add dependencies, APIs, or `import.meta` to mini-program runtime files.
......@@ -30,7 +30,7 @@
- Produces: `buildOrderTypePickerList(orderTypeList, createAllGoodsFlag, lowPriceFlag)`.
- Produces: `isAllowedLimitedOrderType(djOrderType, lowPriceFlag)`.
- [x] Change tests to require only normal order for `lowPriceFlag=1`, while normal restricted scenes retain normal and internal settlement.
- [x] Change tests to require only the “低价订单” display option for `lowPriceFlag=1`, while normal restricted scenes retain normal and internal settlement.
- [x] Run `node scripts/run-node-tests.mjs tabWorkOrder/pages/createOrder/tests/orderMerchantConfig.test.mjs` and verify the new assertions fail under the two-type implementation.
- [x] Add the optional `lowPriceFlag` argument and pass `orderObj.lowPriceFlag` from `applyOrderTypeConfig`; normalize low-price order data to type `1`.
- [x] Re-run the focused test and verify it passes.
......
# Low-Price Customer Required Settings Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Make low-price customer required fields use the selected 4S store's employee-app recording settings, including vehicle fields and phone configuration.
**Architecture:** Add one pure settings adapter that normalizes the employee-app response and builds the page's managed required fields. The store queries and caches by selected 4S store while using the park store only to select phone defaults; the create page consumes the normalized result without accumulating stale required fields.
**Tech Stack:** WeChat Mini Program JavaScript, ES modules, Node.js built-in test runner.
## Global Constraints
- Query required settings for the selected 4S store, not the park store.
- Use `dj.api.smartcarlife.order.field.lightChange.setting.list` with `scene: 1`.
- Preserve customer-profile-only import; do not import goods or payment information.
- Preserve unrelated user changes in `README.md` and `config.js`.
- Do not add dependencies, runtime `import.meta`, or make a git commit unless the user asks.
---
### Task 1: Normalize employee-app order settings
**Files:**
- Create: `utils/orderRequiredSettings.helpers.js`
- Create: `tabWorkOrder/pages/createOrder/tests/orderRequiredSettings.helpers.test.mjs`
**Interfaces:**
- Produces: `normalizeMerchantOrderSettings(data, { shopMerchantId, yqMerchantId }): object`.
- Produces: `buildCustomerRequiredList(settings, currentRequiredList): string[]`.
- Produces: `shouldValidateCustomerPhone(requiredList, phone): boolean`.
- [ ] **Step 1: Write failing pure tests**
```js
assert.deepEqual(
buildCustomerRequiredList(
{
carTypeRequiredFlag: 'Y',
standNoRequiredFlag: 'N',
plateNumRequiredFlag: 'N',
customerPhoneRequiredFlag: 'N'
},
['subShopMerchantId', 'plateNumber']
),
['subShopMerchantId', 'carBrand']
)
```
Add normalization assertions for `carBrand`, `carNo`, `plateNo`, phone aliases, boolean `isRequired`, and `yqPhoneConfig` selection.
- [ ] **Step 2: Run the pure test and verify RED**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderRequiredSettings.helpers.test.mjs`
Expected: FAIL because `utils/orderRequiredSettings.helpers.js` does not exist.
- [ ] **Step 3: Implement the minimal pure adapter**
```js
const FIELD_FLAG_MAP = {
carBrand: 'carTypeRequiredFlag',
carNo: 'standNoRequiredFlag',
plateNo: 'plateNumRequiredFlag',
customerPhone: 'customerPhoneRequiredFlag',
phone: 'customerPhoneRequiredFlag',
mobile: 'customerPhoneRequiredFlag'
}
```
Map explicit `true/false`, `1/0`, and `Y/N`; preserve non-managed required fields; default only `customerPhone` to required when the interface has no phone flag.
- [ ] **Step 4: Re-run the pure test and verify GREEN**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderRequiredSettings.helpers.test.mjs`
Expected: all assertions pass.
### Task 2: Query and cache by selected 4S store
**Files:**
- Modify: `api/api.js:165-171`
- Modify: `store/index.js:101-163`
- Modify: `tabWorkOrder/pages/createOrder/tests/orderSettingMerchantContext.test.mjs`
**Interfaces:**
- Consumes: `normalizeMerchantOrderSettings` from Task 1.
- Produces: `getYQorderInfo({ shopMerchantId, shopMerchantName, yqMerchantId }): Promise<object>`.
- [ ] **Step 1: Rewrite the store integration test for the real contract**
```js
const result = await getYQorderInfo({
shopMerchantId: 44210895,
shopMerchantName: '波波的单店门店',
yqMerchantId: 100
})
assert.deepEqual(requests, [{ scene: 1, merchantId: 44210895 }])
assert.equal(result.plateNumRequiredFlag, 'N')
assert.equal(app.globalData.YQorderSettingMerchantId, 44210895)
```
Also assert that `api/api.js` uses `dj.api.smartcarlife.order.field.lightChange.setting.list`.
- [ ] **Step 2: Run the focused test and verify RED**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderSettingMerchantContext.test.mjs`
Expected: FAIL because the request still uses the park store and the response is not normalized.
- [ ] **Step 3: Implement the store/API fix**
Use `{ scene: 1, merchantId: shopMerchantId }`, normalize `orderFieldSettingList`, filter phone config by `yqMerchantId`, and cache only when both selected store identities match.
- [ ] **Step 4: Re-run the focused test and verify GREEN**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderSettingMerchantContext.test.mjs`
Expected: all assertions pass.
### Task 3: Drive page required state from normalized settings
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/createOrder.js:209,1606-1684,2741-2774`
- Modify: `tabWorkOrder/pages/createOrder/createOrder.wxml:124-155`
- Create: `tabWorkOrder/pages/createOrder/tests/orderRequiredSettings.integration.test.mjs`
**Interfaces:**
- Consumes: `buildCustomerRequiredList` and `shouldValidateCustomerPhone` from Task 1.
- Page data: `requiredList` contains `carBrand`, `standNo`, `plateNumber`, and/or `customerPhone` only when configured, except the employee-app-compatible phone fallback.
- [ ] **Step 1: Write failing page and template tests**
Test that `getSetting()` passes `shopMerchantId: 44210895`, a `plateNo/isRequired=false` response removes `plateNumber`, and the WXML `required` property for all four customer rows reads `requiredList`.
Test phone behavior:
```js
assert.equal(page.checkRequired(false, optionalEmptyPhoneOrder), false)
assert.equal(page.checkRequired(false, optionalInvalidPhoneOrder), true)
```
- [ ] **Step 2: Run the integration test and verify RED**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderRequiredSettings.integration.test.mjs`
Expected: FAIL because page context uses the park ID, phone is hard-coded, and model/phone stars are not dynamic.
- [ ] **Step 3: Implement minimal page wiring**
Call:
```js
getYQorderInfo({
shopMerchantId: orderObj.merchantId,
shopMerchantName: orderObj.merchantName,
yqMerchantId: orderObj.yqMerchantId || orderObj.sellerMerchantId
})
```
Replace the managed customer portion of `requiredList`; validate phone format only when required or non-empty; fix the configured-phone `.find` callback without mutating the list; bind model and phone stars to `requiredList`.
- [ ] **Step 4: Re-run focused page tests and verify GREEN**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderRequiredSettings.integration.test.mjs`
Expected: all assertions pass.
### Task 4: Documentation and full verification
**Files:**
- Modify: `docs/tabWorkOrder/createOrder.md`
- Modify: `docs/order-creation/README.md`
- [ ] **Step 1: Document selected-4S-store configuration behavior**
Record the endpoint, request identity split, four managed fields, phone fallback, and that the customer remains profile-only.
- [ ] **Step 2: Run complete regression tests**
Run: `npm run test:workOrder`
Expected: exit code `0` with no failed tests.
- [ ] **Step 3: Run static compatibility checks**
Run `git diff --check`, scan modified runtime JavaScript for `import.meta`, and run `node --check` on the modified runtime files.
- [ ] **Step 4: Review final scope**
Confirm `README.md` and `config.js` remain untouched, customer import still excludes goods/payment data, and no migration manifest is required because this is a localized defect fix.
# 低价单默认场景提交修复实施计划
> 当前工作区包含同一需求链路的未提交修改,本次直接在现有分支完成,不创建新 worktree、不提交代码。
## 任务 1:用失败测试锁定提交参数缺失
**文件:**
- 修改:`tabWorkOrder/pages/createOrder/tests/submitPayload.helpers.test.mjs`
1. 构造包含 `baseSceneCode`、`baseSceneName`、`sceneType` 的低价单。
2. 断言 `buildSubmitPayload` 的结果保留三个场景字段。
3. 运行该测试并确认当前代码因删除 `baseSceneName` 而失败。
## 任务 2:用失败测试锁定默认场景初始化时序
**文件:**
- 新增:`tabWorkOrder/pages/createOrder/tests/defaultSceneInitialization.integration.test.mjs`
1. 加载真实 createOrder 页面逻辑,只在 HTTP/API 边界返回可控的最近场景和门店场景数据。
2. 以低价单所选 4S 店进入页面,断言场景列表请求使用所选门店。
3. 场景列表未返回时触发提交,断言提交不等待初始化 Promise,并使用固定场景进入校验或审批反馈。
4. 断言最近场景已返回时,当前门店场景列表为空或接口失败仍保留入口场景;两个接口均无场景时不能绕过必填校验。
5. 断言录单字段配置失败时使用默认必填配置并继续初始化场景。
6. 等待 `onLoad` 返回后,断言订单对象同时拥有场景编码、名称和类型。
7. 运行测试并确认当前提前提交和门店列表二次清空入口场景两种情况失败。
## 任务 3:最小实现修复
**文件:**
- 修改:`tabWorkOrder/pages/createOrder/createOrder.js`
- 修改:`tabWorkOrder/pages/createOrder/services/submitPayload.helpers.js`
1. 保存完整场景初始化 Promise 供 `onLoad` 收尾使用;低价单提交不等待该展示初始化任务。
2. 场景列表有效时更新场景;列表为空或失败时保留最近场景接口已经写入的入口场景。
3. 低价专用页提交保留 `baseSceneName`,并固定低价标识与场景三字段。
4. 运行任务 1、2 的测试并确认通过。
## 任务 4:兼容场景列表不返回场景类型
**文件:**
- 修改:`tabWorkOrder/pages/createOrder/tests/defaultSceneInitialization.integration.test.mjs`
- 修改:`tabWorkOrder/pages/createOrder/createOrder.js`
1. 增加场景行仅返回编码、名称和状态的回归用例,并确认旧代码会清空有效场景。
2. 场景类型按“列表行、订单已有值、当前用户请求值”的顺序回退。
3. 重新运行默认场景集成测试与完整工单测试。
## 任务 5:锁定客户档案选择前后的场景上下文
**文件:**
- 修改:`tabWorkOrder/pages/createOrder/tests/defaultSceneInitialization.integration.test.mjs`
- 修改:`tabWorkOrder/pages/createOrder/tests/customerProfileOnlyImport.integration.test.mjs`
- 修改:`tabWorkOrder/pages/createOrder/createOrder.js`
1. 最近场景预填编码、名称和类型,门店列表匹配到同一编码时允许沿用最近场景名称。
2. 门店列表无法匹配最近编码时仍选择列表首项,不把旧名称带给新编码。
3. 客户档案中的空场景字段不得覆盖进入页面已确认的场景三字段。
## 任务 6:固定低价单提交场景并回归验证
**文件:**
- 修改:`docs/tabWorkOrder/createOrder.md`
- 修改:`docs/order-creation/README.md`
1. 用失败测试锁定场景全空和接口回填其他场景两种提交情况。
2. 在 `SubmitContext` 执行本地必填校验前,仅对 `lowPriceFlag=1` 强制写入 `100101/精品升级/1`。
3. 记录固定提交场景约束,运行 createOrder 页面测试、低价单测试和迁移完整性测试。
4. 检查差异与工作区状态,确保未覆盖 `README.md`、`config.js` 等用户原有修改。
# Low-Price Order Type Display Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** 低价下单页的订单类型默认且只能显示“低价订单”,同时保持后端兼容的 `djOrderType=1 + lowPriceFlag=1`。
**Architecture:** 在现有纯函数 `buildOrderTypePickerList` 中区分低价业务身份与普通订单策略,低价单直接返回一个展示项;创建页默认数据与 `onLoad` 均固定低价业务身份,提交不再等待展示用场景初始化。共享函数保留普通订单兼容分支,但本页面没有普通订单路由。
**Tech Stack:** 微信小程序 JavaScript/WXML、Node.js `node:test`
## Global Constraints
- 低价页显示文案固定为“低价订单”。
- 低价页唯一选项为 `{ text: '低价订单', value: 1 }`。
- 提交字段保持 `djOrderType=1 + lowPriceFlag=1`。
- 本页面没有普通订单入口,即使路由缺失或误传 `lowPriceFlag` 也必须归一成低价单。
- 低价单本地必填列表移除 `baseSceneCode`,最终提交固定场景逻辑保持不变。
- 点击“直接下单”不得等待场景初始化请求,应立即进入校验或低价审批反馈。
- 当前工作区包含既有未提交改动,不创建 Git 提交。
---
### Task 1: 订单类型纯函数
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/services/orderMerchantConfig.js`
- Test: `tabWorkOrder/pages/createOrder/tests/orderMerchantConfig.test.mjs`
**Interfaces:**
- Consumes: `buildOrderTypePickerList(orderTypeList, createAllGoodsFlag, lowPriceFlag)`
- Produces: 低价单固定返回 `[{ text: '低价订单', value: 1 }]`
- [x] **Step 1: Write the failing test**
把低价单断言改成手工期望值:
```js
assert.deepEqual(buildOrderTypePickerList(all, 0, 1), [
{ text: '低价订单', value: 1 }
])
```
- [x] **Step 2: Run test to verify it fails**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderMerchantConfig.test.mjs`
Expected: FAIL,实际文案仍为“正常订单”。
- [x] **Step 3: Write minimal implementation**
导出统一低价订单展示项,并在 `lowPriceFlag=1` 分支返回新对象副本:
```js
export const LOW_PRICE_ORDER_TYPE_OPTION = Object.freeze({
text: '低价订单',
value: ORDER_TYPE_NORMAL
})
```
- [x] **Step 4: Run test to verify it passes**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderMerchantConfig.test.mjs`
Expected: PASS。
### Task 2: 创建页展示接线
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/createOrder.js`
- Test: `tabWorkOrder/pages/createOrder/tests/orderSettingMerchantContext.test.mjs`
**Interfaces:**
- Consumes: `LOW_PRICE_ORDER_TYPE_OPTION`
- Produces: `applyOrderTypeConfig` 对低价单写入 `orderTypeName='低价订单'`、`orderObj.djOrderType=1`
- [x] **Step 1: Write the failing integration test**
构造 `lowPriceFlag=1` 页面,调用真实 `applyOrderTypeConfig` 后断言:
```js
assert.equal(page.data.orderTypeName, '低价订单')
assert.deepEqual(page.data.orderTypePickerList, [
{ text: '低价订单', value: 1 }
])
assert.equal(page.data.orderObj.djOrderType, 1)
```
- [x] **Step 2: Run test to verify it fails**
Run: `node --test tabWorkOrder/pages/createOrder/tests/orderSettingMerchantContext.test.mjs`
Expected: FAIL,页面名称仍为“正常订单”。
- [x] **Step 3: Write minimal implementation**
在低价分支使用统一展示项,不修改场景字段或提交策略。
- [x] **Step 4: Run focused tests**
Run:
```powershell
node --test tabWorkOrder/pages/createOrder/tests/orderMerchantConfig.test.mjs
node --test tabWorkOrder/pages/createOrder/tests/orderSettingMerchantContext.test.mjs
node --test tabWorkOrder/pages/createOrder/tests/defaultSceneInitialization.integration.test.mjs
```
Expected: 全部 PASS。
### Task 3: 文档与完整回归
**Files:**
- Modify: `docs/tabWorkOrder/createOrder.md`
- Modify: `docs/order-creation/README.md`
**Interfaces:**
- Consumes: 已实现的低价单页面行为
- Produces: 与实现一致的维护文档和验收说明
- [x] **Step 1: Update behavior documentation**
明确低价单页面显示“低价订单”,底层仍提交 `djOrderType=1 + lowPriceFlag=1`,并注明与 `baseSceneCode` 必填校验互不相关。
- [x] **Step 2: Run complete regression**
Run: `npm run test:workOrder`
Expected: 所有自动化测试通过;仅既有真实环境测试保持跳过。
- [x] **Step 3: Check patch integrity**
Run: `git diff --check`
Expected: exit code 0。
### Task 4: 低价单场景本地校验放行
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/createOrder.js`
- Test: `tabWorkOrder/pages/createOrder/tests/defaultSceneInitialization.integration.test.mjs`
**Interfaces:**
- Consumes: 页面稳定低价入口判断 `isLowPriceOrder()`
- Produces: 低价单 `checkRequired` 不检查 `baseSceneCode`
- [x] **Step 1: Add a failing test for an empty low-price scene and a regression assertion for ordinary orders.**
- [x] **Step 2: Verify the low-price assertion fails with `baseSceneCode`.**
- [x] **Step 3: Filter `baseSceneCode` from the required target only when `isLowPriceOrder()` is true.**
- [x] **Step 4: Re-run the focused test and verify both branches pass.**
### Task 5: 专用低价入口与提交响应
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/createOrder.js`
- Test: `tabWorkOrder/pages/createOrder/tests/defaultSceneInitialization.integration.test.mjs`
**Interfaces:**
- Consumes: 任意页面路由参数、可能仍在等待的场景初始化 Promise
- Produces: 固定 `lowPriceFlag=1`、仅展示“低价订单”,点击后不等待场景接口并立即进入审批流程
- [x] **Step 1: 增加路由传 `lowPriceFlag=0` 时仍归一为低价单的失败测试。**
- [x] **Step 2: 增加场景列表请求挂起时提交仍立即完成同步校验并打开审批弹层的失败测试。**
- [x] **Step 3: 将页面默认数据和 `onLoad` 固定为低价单,移除提交对场景初始化 Promise 的等待。**
- [x] **Step 4: 运行入口、提交时序和完整创建订单回归。**
......@@ -2,7 +2,7 @@
## 目标
补全低价单创建链路的四项行为:低价单只能创建正常订单;满足最低价触发条件后先展示审批确认弹层;确认提交成功后返回低价单列表的“待审批”页签;负数和超过 `100000` 元的商品价格必须明确拒绝,不能静默去符号或截断。
补全低价单创建链路的四项行为:低价单页面只能展示和选择“低价订单”,底层继续使用兼容的 `djOrderType=1 + lowPriceFlag=1`;满足最低价触发条件后先展示审批确认弹层;确认提交成功后返回低价单列表的“待审批”页签;负数和超过 `100000` 元的商品价格必须明确拒绝,不能静默去符号或截断。
最低价未触发时只使用文案:`价格未触发最低价,其他正常单请到生意助手侧录单`。旧文案“订单中必须有个商品价格低于商品最低价才能提单”不再使用。
......@@ -14,7 +14,7 @@
## 订单类型
- 仅当 `Number(orderObj.lowPriceFlag) === 1` 时,订单类型选择器只保留 `{ text: '正常订单', value: 1 }`。
- 仅当 `Number(orderObj.lowPriceFlag) === 1` 时,订单类型选择器固定为 `{ text: '低价订单', value: 1 }`;其中 `value=1` 是后端兼容的内部策略值,不作为页面文案。
- 低价单初始化和门店配置刷新时都强制把 `djOrderType` 归一为 `1`,防止路由或历史数据带入内部结算。
- 普通精品升级订单仍保持原有“正常订单 + 内部结算”范围,不扩大本次改动影响。
......@@ -64,7 +64,7 @@
## 测试设计
1. 订单类型纯函数:低价单只保留正常订单,普通限制场景仍保留正常订单和内部结算。
1. 订单类型纯函数:低价单只返回“低价订单”,普通限制场景仍保留正常订单和内部结算。
2. 审批提交集成:首次提交只打开弹层、不调用 API;确认后只调用一次 API;审批商品列表和最低价资格使用同一 `minSellPrice` 口径。
3. 成功跳转:低价单成功返回并把列表切到待审批;普通订单仍进入 `confirmOrder`。
4. 金额纯函数及页面集成:负数和超上限明确失败且不截断,合法边界通过,错误未修正时提交被拦截。
......
......@@ -4,7 +4,7 @@
## 目标
在低价单创建页补充两项交互约束:从客户档案选择客户时只导入客户信息,不覆盖当前订单中的商品、套餐、支付和门店上下文;展示可选商品时,只展示已开启最低价格校验的商品,其中套餐必须保证每个子商品都已开启,多规格商品按 SKU 分别过滤。
在低价单创建页补充两项交互约束:从客户档案选择客户时只导入客户信息、订单编号和备注,不覆盖当前订单中的场景、销售人员、商品、套餐、支付和门店上下文;展示可选商品时,只展示已开启最低价格校验的商品,其中套餐必须保证每个子商品都已开启,多规格商品按 SKU 分别过滤。
## 适用范围
......
# 低价单客户字段动态必填配置设计
## 目标
低价单客户信息不再按园区配置或页面硬编码判断必填。车型、车架号、车牌号和手机号沿用员工版小程序的录单配置链路,并以创建低价单时所选 4S 店为准。
已知复现场景:4S 店“波波的单店门店”(`44210895`)在员工版小程序中车牌号非必填,低价单页面也不得显示必填星号或阻止提交。
## 根因
1. 低价单当前把所选园区店 ID 传给 `getYQorderInfo`,配置请求和缓存均按园区店维度执行;员工版实际按 4S 店 ID 请求。
2. 员工版接口返回 `orderFieldSettingList`,当前区域助手的 store 未将 `carBrand`、`carNo`、`plateNo` 等字段转换成创建页使用的必填标识。
3. 创建页的 `requiredList` 只追加开启项,不移除关闭项,切换配置或命中旧数据时可能保留错误星号。
4. 手机号仍被提交校验硬编码为必填,且手机号默认配置查找回调缺少返回值,无法可靠匹配所选 4S 店。
## 数据流
1. 创建页从 `orderObj.merchantId` 取得所选 4S 店 ID,从 `orderObj.yqMerchantId || orderObj.sellerMerchantId` 取得所属园区店 ID。
2. `getYQorderInfo` 使用员工版接口 `dj.api.smartcarlife.order.field.lightChange.setting.list`,请求参数为 `{ scene: 1, merchantId: 4S店ID }`。
3. store 将 `orderFieldSettingList` 统一映射:
- `carBrand` → `carTypeRequiredFlag` / 页面字段 `carBrand`
- `carNo` → `standNoRequiredFlag` / 页面字段 `standNo`
- `plateNo` → `plateNumRequiredFlag` / 页面字段 `plateNumber`
- `customerPhone`、`phone`、`mobile` → `customerPhoneRequiredFlag` / 页面字段 `customerPhone`
4. 手机号配置仍按园区店 ID 从 `yqPhoneConfig` 中选择,再由页面按所选 4S 店 ID 匹配 `shopMerchantPhoneList`。
5. 缓存同时记录 4S 店和园区店 ID,防止同一登录态下读取其他门店配置。
## 必填与校验规则
- 每次配置返回后只重建受配置管理的四个客户字段,保留 `subShopMerchantId` 等其他动态必填项,不再追加旧值。
- 接口明确返回 `isRequired=false` 时,页面不显示星号且空值不阻止提交。
- 手机号配置字段缺失时保持员工版兼容口径:手机号默认必填;若接口明确返回手机号非必填,则允许为空,但非空时仍校验 11 位手机号格式。
- 战败订单仍沿用原逻辑移除车型、车架号和车牌号必填要求。
- 配置请求失败时不错误增加车辆字段必填;手机号保持原兼容默认。
## 页面表现
- 车型、车架号、车牌号、手机号的必填星号统一由 `requiredList` 驱动。
- 客户信息仍只从客户档案导入,不恢复自由录入,不带入商品和支付信息。
- 低价商品、审批和提交后返回待审批列表等已实现行为不变。
## 测试
- 纯函数测试覆盖接口字段映射、显式关闭、手机号默认兼容及园区手机号配置筛选。
- store 集成测试验证请求使用 4S 店 `44210895`、`scene=1`,缓存按 4S 店/园区店隔离。
- 页面测试验证车牌配置为非必填时不进入 `requiredList`,手机号可选为空时不触发格式报错,非空非法手机号仍报错。
- 模板契约测试验证四个字段的星号均由 `requiredList` 控制。
# 低价单默认场景提交修复设计
## 背景
低价单进入下单页后会调用最近场景接口和门店场景列表接口,页面数据中可得到 `baseSceneCode`、`baseSceneName` 与 `sceneType`。当前提交时仍可能提示“场景名称不能为空”。
排查确认有五个原因:
1. 场景列表请求在 `onLoad` 中未等待完成,最近场景只先写入编码和类型,名称需要场景列表二次解析,存在提交时名称尚未回填的竞态。
2. `buildSubmitPayload` 将 `baseSceneName` 当作纯展示字段删除,即使页面已经回填名称,最终 API 参数也不会携带。
3. 场景列表接口的有效行可能只返回编码和名称,不返回 `sceneType`;页面曾把这种行误判为不完整场景并清空。
4. 最近场景接口已经返回场景名称,但页面只预填编码和类型;当门店场景列表匹配到同一编码却不重复返回展示名称时,页面仍会误清空已经确认的场景。
5. 门店场景列表为空或请求失败时,低价单额外清空最近场景接口已经写入的三项场景字段;员工版在相同情况下会保留入口场景,因此用户选择客户档案后提交才暴露为“场景名称不能为空”。
6. 微信开发者工具重新打开当前下单页时可能以空 `options` 执行 `onLoad`。此时不仅缺少场景入口参数,也没有 `lowPriceFlag` 和下单门店,选择客户档案会被误判成普通订单并走整单回显,覆盖低价单初始化状态。
7. 上述接口初始化和客户档案保护仍无法覆盖实际环境中的全部时序,页面提交前场景字段仍可能为空。产品最终确认低价单提交场景不会变化,改为提交时固定写入,不再依赖接口结果通过必填校验。
## 目标
- 低价单默认使用所选 4S 店、当前登录人手机号和场景类型请求可用场景。
- 最近场景有效时优先选中;没有最近场景或最近场景不属于当前门店时,沿用现有首个可用场景兜底。
- 页面默认场景初始化完成后,订单对象同时具备场景编码、名称和类型。
- 低价单提交在任何本地必填校验之前固定写入 `baseSceneCode='100101'`、`baseSceneName='精品升级'`、`sceneType=1`,并将三项一并传给下单接口。
## 方案
### 初始化时序
保留现有两级接口:先等待 `getRecentUserScene` 并成组保存其编码、名称和类型,再等待 `getUserScene`。第二级接口优先匹配最近场景编码;匹配到同一编码时,列表行未重复返回名称可继续使用最近场景名称,无法匹配且列表有有效行时按现有规则选择列表首项且不串用旧名称。场景列表为空或请求失败时不覆盖入口场景,与员工版保持一致。场景类型优先使用列表行返回值,其次使用最近场景已经写入订单的值,最后使用本次场景列表请求的当前用户场景类型。页面保存整段初始化 Promise 供 `onLoad` 完成展示回填;提交不等待该 Promise,而是直接固定提交场景后进入校验。
固定账号模式下,如果页面重开时未携带低价单标识、门店或编辑/扫码/补单等明确路由参数,则从固定账号资料恢复低价单入口上下文:4S 店 `44210895`、园区店 `44211025` 及对应名称,并固定 `lowPriceFlag=1`。恢复发生在场景与录单配置请求之前,确保后续接口使用正确 4S 店,客户档案确认也继续走“只导入客户信息、订单编号和备注”的低价单分支。已有明确路由参数时不做补写,避免影响编辑、扫码和补单入口。场景编码与名称仍由真实场景接口返回,不伪造固定场景值。
### 提交参数
该创建页是低价单专用入口。页面默认数据及 `onLoad` 都固定 `lowPriceFlag=1` 和低价单实例标记,不再依赖调用方路由参数,也不允许回退为普通订单。点击提交后不等待展示用场景初始化任务,立即在 `SubmitContext` 校验链启动前强制覆盖 `lowPriceFlag=1`、`baseSceneCode='100101'`、`baseSceneName='精品升级'`、`sceneType=1`。审批弹层确认时再次执行同一覆盖,保证真正发接口时不会依赖第一次点击留下的页面状态。因此本地 `checkRequired` 和最终 payload 读取到的是同一组固定值;即使订单对象中的低价标识或场景字段已丢失,也不再提示“场景名称不能为空”,场景接口挂起时点击也有即时反馈。
### 失败处理
门店场景列表失败或没有可用行时,页面展示阶段仍按照员工版既有行为保留最近场景接口已经确定的场景字段;该最近场景接口沿用员工版的“手机号+场景类型”参数,所选门店仅用于第二级列表补充或替换。若最近场景缺少 `sceneType`,使用本次请求的用户场景类型补齐。列表行缺少 `sceneType` 时按上述来源回退,不把有效场景误判为空。录单字段配置接口失败只回退默认必填配置,不中断场景初始化。提交阶段不再依赖这些接口结果,统一使用固定场景三字段。
客户档案确认仅替换客户域、订单编号和备注,忽略档案记录自带的场景、销售人员、商品和支付字段;进入页面完成确认的 `baseSceneCode/baseSceneName/sceneType` 保持不变。
## 验证
- 提交体单元测试:低价单的场景编码、名称、类型全部保留。
- 页面集成测试:最近场景和门店场景接口完成后,页面同时回填编码、名称、类型,并使用所选 4S 店请求。
- 提前点击测试:场景列表未返回时提交不等待,立即使用固定场景进入既有校验链或审批弹层。
- 降级测试:最近场景已返回时,门店场景列表为空或接口拒绝仍保留入口场景;两个接口均无场景时页面可保持空值,但低价单提交前会固定补齐;录单字段配置失败时场景仍能初始化。
- 回归创建订单、低价单和迁移测试,确认正常单及其他提交清理规则不受影响。
- 空参数重开测试:固定低价单及门店上下文在初始化接口前恢复,选择客户档案后不走普通整单回显,场景三字段保持不变。
- 空场景提交测试:三项场景字段均为空时,`checkRequired` 收到的订单已固定为 `100101/精品升级/1`。
- 标识丢失测试:进入低价单后即使 `orderObj.lowPriceFlag` 与场景三字段均被后续回显清空,页面稳定标记仍使提交校验和审批确认 payload 使用固定值。
- 专用入口测试:即使路由误传 `lowPriceFlag=0` 仍归一为低价单;场景列表请求挂起时提交不等待并立即进入审批确认。
# 低价单订单类型展示修正设计
## 问题
低价下单页当前把内部订单策略值 `djOrderType=1` 直接映射成“正常订单”,并把订单类型选择器过滤成仅剩“正常订单”。低价订单的业务身份实际由 `lowPriceFlag=1` 表示,因此页面把内部策略名称错误地当成了面向用户的订单类型名称。
该问题与“场景名称不能为空”无关:场景提示由 `baseSceneCode` 的本地必填校验触发,订单类型展示读取 `orderTypeName/orderTypePickerList`。
## 方案
该创建页是低价单专用入口,页面自身固定低价业务身份,不再依赖调用方是否携带或正确传递
`lowPriceFlag`。页面加载后:
- 订单类型名称固定为“低价订单”。
- 订单类型选择器只包含 `{ text: '低价订单', value: 1 }`。
- 内部提交字段继续使用 `djOrderType=1`,同时由既有提交逻辑保证 `lowPriceFlag=1`,不引入新的后端枚举值。
- 初始化、门店配置刷新以及低价档案回显后都不能把名称恢复为“正常订单”。
- 低价单本地必填校验不再包含 `baseSceneCode`,避免场景数据阻断后续订单类型与审批流程。最终提交前既有固定场景赋值保持不变。
- “直接下单”不等待仅用于页面展示的场景初始化请求,先固定提交场景再进入同步校验和低价审批流程,避免接口未返回时点击无响应。
本页面不存在普通订单入口;普通订单仍由员工版原有录单入口负责。共享纯函数继续保留普通订单兼容能力,
但不能使本页面回退成普通订单。
## 测试
- 纯函数测试验证低价单只返回“低价订单”,普通限制场景仍返回“正常订单 + 内部结算”。
- 页面接线测试验证低价单配置刷新后展示“低价订单”且 `djOrderType=1`。
- 页面入口测试验证即使路由传入 `lowPriceFlag=0`,也会归一为低价单。
- 提交时序测试验证场景请求挂起时点击仍立即进入审批流程,并使用固定提交场景。
- 完整运行 `npm run test:workOrder`,覆盖场景必填、低价审批和最终提交逻辑。
......@@ -19,7 +19,21 @@
| 4 | `merchantId` | Merchant | 商户入口预填 |
| 5 | 默认 | Default | 空白新建 |
`onLoad` → 若有 `orderCode` 则 `onRoute`;否则场景预填、`getUserSceneList`、销售默认人选。
`onLoad` 先把 `100101/精品升级/1` 作为完整本地兜底写入订单;若有 `orderCode` 则继续
`onRoute`,否则依次等待最近场景编码、名称、类型预填和 `getUserSceneList` 当前门店确认,再处理销售默认人选。场景列表按当前所选 4S 店请求;匹配到
最近场景同一编码时,列表行未重复返回名称可沿用最近场景名称;当列表行
未返回 `sceneType` 时,依次回退订单已有场景类型和当前用户请求场景类型,确保页面初始化完成时
`baseSceneCode/baseSceneName/sceneType` 已成组写入。该初始化 Promise 只用于 `onLoad` 收尾;
`submit` 不等待它,也不会改写场景。场景列表为空或接口失败时不会覆盖最近场景接口已确定的
`baseSceneCode/baseSceneName/sceneType`;两个接口均未取得完整场景时,页面继续使用本地兜底。
固定账号模拟开启时,开发者工具重新打开当前页面可能不再携带入口参数。创建页会在没有
`lowPriceFlag`、门店及编辑/扫码/补单等明确路由字段时,从固定账号恢复低价单上下文:
`lowPriceFlag=1`、4S 店 `44210895`、园区店/销售归属 `44211025`。恢复发生在录单配置和场景
请求之前;最近场景或门店首个可用场景会覆盖本地兜底,已有明确入口参数时不补写门店,避免影响其他流程。
页面在 `onLoad` 时保存稳定的低价单入口标记并同步准备完整场景,因此低价单仍按普通必填规则
校验 `baseSceneCode`。提交与审批确认直接使用当前 `orderObj`,不会重新补写或覆盖真实场景。
该创建页是低价单专用入口,默认数据和 `onLoad` 都强制低价业务身份;路由参数缺失或误传也不会进入普通订单分支。
工作台入口仍传递 `skipOrderGuards=true` 作为路由兼容标记。创建页提交模块本身不加载
日报、学习任务、异常订单和异常流水业务守卫,因此“直接下单”在本地订单数据校验通过后
......@@ -83,6 +97,8 @@ flowchart TD
- `~/utils/marketingFlag`、`orderSubOrderExtras`:活动价、子单营销字段
订单类型 `djOrderType`:打折 / 买赠 / 组合等影响 `order-goods-row` 展示与 `checkGoods` 规则。
低价入口的页面业务类型默认且只能显示“低价订单”,选择器固定为一项;为兼容现有接口,底层仍提交
`djOrderType=1 + lowPriceFlag=1`,不把内部策略值 `1` 显示成“正常订单”。
`lowPriceFlag=1` 时额外启用
[`lowPriceGoodsValidation.helpers.js`](../../tabWorkOrder/pages/createOrder/services/lowPriceGoodsValidation.helpers.js):
......@@ -104,12 +120,30 @@ flowchart TD
| 礼券 | `#coupon` + `orderCouponEffects`(换人/手机号变更清空) |
| 客户档案补全 | `customerProfileEffects` + `getCustomerProfileInfo` |
精品升级(`sceneType==1`):[`orderMerchantConfig.js`](../../tabWorkOrder/pages/createOrder/services/orderMerchantConfig.js) 限制订单类型为正常单 + 内部结算。
普通精品升级订单(`sceneType==1`):[`orderMerchantConfig.js`](../../tabWorkOrder/pages/createOrder/services/orderMerchantConfig.js) 限制订单类型为正常单 + 内部结算;低价入口单独固定为“低价订单”。
员工列表在进入选择器时统一为 `uuid/staffName`:优先使用有效 `uuid`,为空时兼容
`staffUuid/staffUUID/userId/bussinessId/id`,姓名兼容 `staffName/name/employeeName`。因此在职员工
接口即使使用 `userId/name` 返回,选择销售顾问后仍会把有效编号写入 `orderObj.userId`,不会出现
界面已选中但提交仍提示“销售顾问不能为空”。最近订单只有顾问姓名而没有人员编号时不生成默认
选中态;初始化请求晚于用户手选返回时,也不会覆盖用户已经选择的销售顾问。
低价单客户区只在车主姓名行显示一次“请通过选择客户档案”,并在“客户档案”前使用
`record.png` 图标。客户档案组件接收前置弹框所选 4S 店的 `merchantId`;档案或历史订单
回显后通过 `mergeLowPriceOrderContext` 恢复已选 4S/园区店,录单字段设置按所选园区店查询
并按园区 ID 缓存。
回显后通过 `mergeLowPriceOrderContext` 恢复已选 4S/园区店。客户档案只导入客户信息、订单编号
和备注,不带入档案订单中的场景、销售人员、商品和支付信息。
档案记录中即使包含空的场景字段,也不会覆盖进入页面时已经确认的
`baseSceneCode/baseSceneName/sceneType`。
该创建页是低价单专用页,客户档案确认不再进入普通订单的 `onRoute/setOrderObj` 回显链;已经
通过销售顾问弹框选定的 `merchantId/merchantName/userId/employeeName` 也会在其他订单回显中受到保护。
车型、车架号、车牌号和手机号的星号及提交必填校验由
[`orderRequiredSettings.helpers.js`](../../utils/orderRequiredSettings.helpers.js)
统一生成。页面调用 `dj.api.smartcarlife.order.field.lightChange.setting.list`,传
`scene=1` 和当前所选 4S 店 `merchantId`;所属园区 ID 只用于筛选 `yqPhoneConfig`。配置缓存同时
校验 4S 店和园区店,切换任一身份都会重新请求,避免把其他门店的必填星号带入当前低价单。
接口明确返回非必填时,页面不显示星号且空值不拦截;手机号若有值仍校验格式。为兼容员工版
旧数据,接口未返回手机号配置时默认保持手机号必填。
---
......@@ -127,6 +161,14 @@ flowchart TD
通过后 [`submitPayload.helpers.js`](../../tabWorkOrder/pages/createOrder/services/submitPayload.helpers.js) 清洗并选 API:
必填校验返回的门店、销售顾问和转化人员内部字段统一映射到页面可见提示;未知必填键也使用
“请完善必填信息”兜底,禁止出现校验已阻断但页面无提示、接口也未调用的静默分支。
手机号、VIN 和备注等已由校验函数给出精确提示的分支不会再追加通用提示。
低价单中的场景名称不是纯展示字段。提交体保留页面初始化得到的 `baseSceneName`,并与
`baseSceneCode`、`sceneType` 一同传给下单接口;普通订单及其他审计、列表展示字段继续按
原规则清理。
| 条件 | API |
|------|-----|
| 兼容建档 `save`(页面无入口) | `createPrerecordedOrder` |
......
......@@ -215,7 +215,7 @@
| 查询用户可用场景 | `getUserScene` | POST | `dj.api.smartcarlife.scene.config.getUserScene` | `sceneType`、`phone`、`merchantId` | 场景列表、`baseSceneCode` 等 | 初始化或门店/人员变化时;常规 | `tabWorkOrder/pages/createOrder/createOrder.js`、`tabWorkOrder/api.js` |
| 查询园区店支付配置 | `getYqStoreConfig` | GET | `dj.api.smarcarlife.yqMerchantConfig.detail` | `yqMerchantId` | `supportPayTypes` | 初始化、路由回显或园区店变化时;条件 | `tabWorkOrder/pages/createOrder/createOrder.js`、`tabWorkOrder/api.js` |
| 查询门店多角色及开单类型配置 | `getShopMerchantPointConfig` | POST | `dj.api.smartcarlife.shopMerchantPointConfig.get` | `merchantId=所选4S店ID` | `pointsMultiRole`、`createAllGoodsFlag` | `onReady`;条件 | `tabWorkOrder/pages/createOrder/createOrder.js`、`tabWorkOrder/api.js` |
| 查询录单字段设置 | `getYQorderInfo` → `getMerchantRecordingSettings` | POST | `dj.api.smartcarlife.recordingSettings.getMerchantRecordingSettings` | `merchantId=所选园区店ID`、对应园区店名称 | `orderFieldSettingList`、`yqPhoneConfig` | 首次进入所选园区时;按园区 ID 命中 `YQorderSetting` 缓存 | `tabWorkOrder/pages/createOrder/createOrder.js`、`store/index.js`、`api/api.js` |
| 查询录单字段设置 | `getYQorderInfo` → `getMerchantRecordingSettings` | POST | `dj.api.smartcarlife.order.field.lightChange.setting.list` | `scene=1`、`merchantId=所选4S店ID` | `orderFieldSettingList`、`yqPhoneConfig` | 进入所选 4S 店时;缓存同时校验 4S 店和园区店 ID | `tabWorkOrder/pages/createOrder/createOrder.js`、`store/index.js`、`api/api.js` |
| 查询商品部位字典 | `getPositionList` | POST | `dj.api.smartcarlife.goodsPosition.list` | 空对象 | 部位列表 | 加载可选商品/基础商品时;全局缓存 | `tabWorkOrder/pages/createOrder/createOrder.js`、`store/index.js`、`api/api.js` |
| 获取前端配置中心数据 | `setConfigInfo` | GET | `https://config-center-backend.glsx.com.cn/glsxAdmin/config` | `moduleUrl=dj-car-boutique-work-wechat-miniapp`、当前 `env` | `membraneTypeList` 等配置 | 加载商品时;全局缓存;非 ROP | `tabWorkOrder/pages/createOrder/createOrder.js`、`store/index.js` |
......@@ -239,10 +239,11 @@
`Goods`、`SkuGoods`、`SetMeal`、`OrderGoodsRow` 和学习提示组件在本页当前调用链中没有独立网络请求。
低价单商品价格规则:当 `orderObj.lowPriceFlag=1` 时,普通商品、已选多规格 SKU 和套餐全部
子商品都必须返回 `validMinSellPrice='Y'` 和有效 `minSellPrice`,录入基础单价必须严格小于
`minSellPrice`。商品行回显最低价;商品确认时静默校验且不弹提醒,改价时实时提示,提交前再整单校验。失败统一提示“价格未触发
最低价,其他正常单请到生意助手侧录单”,并在调用 `createWithPay/supplementOrder` 前终止。
低价单商品价格规则:当 `orderObj.lowPriceFlag=1` 时,普通商品、已选多规格 SKU 和套餐子商品
全部显示,不按 `validMinSellPrice` 过滤。录入和失焦阶段不做最低价资格校验;提交时只要任一项
`validMinSellPrice='Y'` 且录入基础单价严格小于有效 `minSellPrice`,整单即可继续。失败统一提示
“价格未触发最低价,其他正常单请到生意助手侧录单”,并在调用
`createWithPay/supplementOrder` 前终止。
该页面校验不新增接口,也不改变非低价工单的原最低价逻辑。
### 4.3 门店与员工选择
......@@ -252,7 +253,7 @@
| 查询园区店关联 4S 店 | `getSceneMerchantRefStoreList` | POST | `dj.api.scenemerchantref.query4SRefByYqShopByLogin` | `merchantId`、`scene` | 4S 店列表 | 非低价单销售/录单员模式选择门店;低价单直接使用前一步所选 4S 店,不调用本接口 | `tabWorkOrder/pages/createOrder/services/merchantStaffSelection.js`、`api/api.js` |
| 查询当前账号可见园区店 | `getYQList` | POST | `dj.api.smartcarlife.serviceMerchant.curYqList` | 无显式业务入参 | 园区店列表 | 非销售类模式选择园区店;条件 | `tabWorkOrder/pages/createOrder/services/merchantStaffSelection.js`、`api/api.js` |
| 查询上一笔工单人员信息 | `getLastUserOrderInfo` | POST | `dj.api.smartcarlife.order.getLastUser` | `sellerUserId` | `merchantId`、上一笔工单人员/门店信息 | 预填或恢复上次销售顾问;条件 | `tabWorkOrder/pages/createOrder/services/merchantStaffSelection.js`、`tabWorkOrder/api.js` |
| 查询在职员工 | `getEmployeeList` | POST | `dj.api.smartcarlife.employee.onTheJob.getByMerchantId` | `merchantId`;销售类模式传 `sceneList` | 员工数组、`uuid`、姓名、角色等 | 选定门店后加载销售顾问或录单员;条件 | `tabWorkOrder/pages/createOrder/services/merchantStaffSelection.js`、`api/api.js` |
| 查询在职员工 | `getEmployeeList` | POST | `dj.api.smartcarlife.employee.onTheJob.getByMerchantId` | `merchantId`;销售类模式传 `sceneList` | 员工数组;人员编号兼容 `uuid/staffUuid/staffUUID/userId/bussinessId/id`,姓名兼容 `staffName/name/employeeName` | 选定门店后加载销售顾问或录单员;条件 | `tabWorkOrder/pages/createOrder/services/merchantStaffSelection.js`、`api/api.js` |
### 4.4 动态提交接口
......
......@@ -2,6 +2,7 @@ import api from '~/api/api.js'
import { envIndex } from '~/config'
import { removeSystemStorage } from '~/utils/cache/storageApi'
import util from '~/utils/util.js'
import { normalizeMerchantOrderSettings } from '~/utils/orderRequiredSettings.helpers'
// console.log(wx)globalData
/** 判断是不是超管角色 */
......@@ -103,33 +104,43 @@ export const getYQorderInfo = (merchantContext = {}) => {
return new Promise((resolve, reject) => {
const userInfo = wx.$util.getUserInfo() || {}
const fallbackUser = userInfo.subLoginUser || userInfo
const hasExplicitMerchant = Boolean(merchantContext?.merchantId)
const merchantId = merchantContext?.merchantId || fallbackUser.merchantId
const merchantName =
merchantContext?.merchantName || fallbackUser.merchantName || ''
const cachedMerchantId = app.globalData.YQorderSettingMerchantId
const isSameMerchant =
merchantId &&
cachedMerchantId &&
String(cachedMerchantId) === String(merchantId)
const shopMerchantId =
merchantContext?.shopMerchantId ||
merchantContext?.merchantId ||
userInfo.shopMerchantId ||
fallbackUser.shopMerchantId ||
userInfo.merchantId
const yqMerchantId =
merchantContext?.yqMerchantId ||
merchantContext?.sellerMerchantId ||
fallbackUser.merchantId ||
userInfo.merchantId
const cachedShopMerchantId = app.globalData.YQorderSettingMerchantId
const cachedYqMerchantId = app.globalData.YQorderSettingYqMerchantId
const isSameShop =
shopMerchantId &&
cachedShopMerchantId &&
String(cachedShopMerchantId) === String(shopMerchantId)
const isSameYq =
String(cachedYqMerchantId ?? '') === String(yqMerchantId ?? '')
// 园区配置必须跟随本次下单所选园区;旧流程无显式门店时兼容未分店缓存。
if (
app.globalData.YQorderSetting &&
(isSameMerchant || (!hasExplicitMerchant && !cachedMerchantId))
isSameShop &&
isSameYq
) {
return resolve(app.globalData.YQorderSetting)
}
if (!merchantId) {
return reject(new Error('缺少园区店 merchantId,无法查询订单配置'))
if (!shopMerchantId) {
return reject(new Error('缺少4S门店 merchantId,无法查询订单配置'))
}
wx.$util.showLoading()
api
.getMerchantRecordingSettings({
merchantId,
merchantName
scene: 1,
merchantId: shopMerchantId
})
.then(res => {
wx.$util.hideLoading()
......@@ -139,20 +150,13 @@ export const getYQorderInfo = (merchantContext = {}) => {
return
}
const data = { ...(res.data || {}) }
let filterYqPhoneConfig = []
try {
filterYqPhoneConfig = Array.isArray(data.yqPhoneConfig)
? data.yqPhoneConfig
: JSON.parse(data.yqPhoneConfig || '[]')
} catch (error) {
filterYqPhoneConfig = []
}
data.yqPhoneConfig =
filterYqPhoneConfig?.find(item => item.yqMerchantId == merchantId)
?.shopMerchantPhoneList || false
const data = normalizeMerchantOrderSettings(res.data || {}, {
shopMerchantId,
yqMerchantId
})
app.globalData.YQorderSetting = data
app.globalData.YQorderSettingMerchantId = merchantId
app.globalData.YQorderSettingMerchantId = shopMerchantId
app.globalData.YQorderSettingYqMerchantId = yqMerchantId
resolve(app.globalData.YQorderSetting)
})
.catch(error => {
......
......@@ -128,11 +128,12 @@ value="{{ orderObj.remark }}"
valueAlign="right"
/>
<gl-cell border label="性别" value="{{ orderObj.customer.customerSex == 1 ? '男' : (orderObj.customer.customerSex == 2 ? '女' : '') }}" valueAlign="right" labelWidth="var(--fontSize140)" />
<gl-cell border valueAlign="right" label="手机号" value="{{ orderObj.customer.customerPhone }}" labelWidth="var(--fontSize140)" />
<gl-cell border valueAlign="right" label="手机号" required="{{ filter.isIncludesItem(requiredList ,'customerPhone') }}" value="{{ orderObj.customer.customerPhone }}" labelWidth="var(--fontSize140)" />
<gl-cell
border
valueAlign="right"
label="选择车型"
required="{{ filter.isIncludesItem(requiredList ,'carBrand') }}"
labelWidth="var(--fontSize140)"
value="{{ orderObj.customer.carSeriesName ? orderObj.customer.carBrand + ' - ' + orderObj.customer.carChildsBrandName + ' - ' + orderObj.customer.carSeriesName : '' }}"
/>
......
......@@ -6,7 +6,7 @@
*/
/**
* 客户档案选择仅替换客户域,不带入历史订单的商品、支付等字段。
* 客户档案选择只带入客户、订单编号和备注,不带入场景、人员、商品、支付等字段。
* @param {Object} [currentOrder]
* @param {Object} [selectedRecord]
* @returns {Object}
......@@ -18,6 +18,7 @@ export function buildCustomerOnlyOrder(currentOrder, selectedRecord) {
if (!customer.salesType) customer.salesType = 0
return {
...(currentOrder || {}),
orderCode: selectedRecord?.orderCode ?? '',
remark: selectedRecord?.remark ?? '',
customer
}
......
......@@ -7,6 +7,49 @@ const LOW_PRICE_CONTEXT_FIELDS = [
'sellerMerchantName'
]
export const LOW_PRICE_DEFAULT_SCENE = Object.freeze({
baseSceneCode: '100101',
baseSceneName: '精品升级',
sceneType: 1
})
const EXPLICIT_CREATE_ORDER_ENTRY_FIELDS = [
'lowPriceFlag',
...LOW_PRICE_CONTEXT_FIELDS,
'orderCode',
'scene',
'selectOutTradeNoArr',
'orderCreateType',
'supplementId',
'associateOrderCode',
'associateOrderType',
'outTradeNo',
'isAppointment'
]
function hasEntryValue(value) {
if (Array.isArray(value)) return value.length > 0
return value !== undefined && value !== null && value !== ''
}
export function restoreFixedLowPriceEntryContext(
source = {},
fixedContext = {}
) {
const routeOptions = source || {}
if (!Object.keys(fixedContext).length) return routeOptions
const hasExplicitEntry = EXPLICIT_CREATE_ORDER_ENTRY_FIELDS.some(field =>
hasEntryValue(routeOptions[field])
)
if (hasExplicitEntry) return routeOptions
return {
...fixedContext,
...routeOptions
}
}
export function buildLowPriceOrderPatch(source = {}) {
if (Number(source.lowPriceFlag) !== 1) return {}
......@@ -31,3 +74,24 @@ export function mergeLowPriceOrderContext(orderObj = {}, source = {}) {
...buildLowPriceOrderPatch(source)
}
}
export function hasCompleteOrderScene(orderObj = {}) {
return Boolean(
orderObj.baseSceneCode &&
orderObj.baseSceneName &&
orderObj.sceneType !== undefined &&
orderObj.sceneType !== null &&
orderObj.sceneType !== ''
)
}
export function applyLowPriceDefaultScene(orderObj = {}) {
if (Number(orderObj.lowPriceFlag) !== 1 || hasCompleteOrderScene(orderObj)) {
return orderObj
}
return {
...orderObj,
...LOW_PRICE_DEFAULT_SCENE
}
}
......@@ -21,6 +21,31 @@
*/
/**
* 将不同员工接口的字段统一为 picker 使用的 uuid/staffName。
* 在职员工接口可能返回 userId/name,旧员工接口返回 uuid/staffName。
* @param {StaffItem & Record<string, any>} staff
* @returns {StaffItem & Record<string, any>}
*/
export function normalizeStaffItem(staff = {}) {
const firstNonEmpty = values =>
values.find(value => value !== undefined && value !== null && value !== '')
return {
...staff,
uuid:
firstNonEmpty([
staff.uuid,
staff.staffUuid,
staff.staffUUID,
staff.userId,
staff.bussinessId,
staff.id
]) ?? '',
staffName:
firstNonEmpty([staff.staffName, staff.name, staff.employeeName]) ?? ''
}
}
/**
* @typedef {Object} StaffItem
* @property {string|number} uuid
* @property {string} staffName
......@@ -160,10 +185,13 @@ export function markMerchantActive(list, selectedId) {
* @param {string|number} selectedId
*/
export function markStaffActive(list, selectedId) {
return (list || []).map(item => ({
...item,
active: selectedId != null && selectedId !== '' && item.uuid == selectedId
}))
return (list || []).map(rawItem => {
const item = normalizeStaffItem(rawItem)
return {
...item,
active: selectedId != null && selectedId !== '' && item.uuid == selectedId
}
})
}
/**
......@@ -260,11 +288,13 @@ export function buildSalesSingleMerchantDefault(merchantList, staffList) {
*/
export function buildOrderPatch(mode, merchant, staff) {
const config = getModeConfig(mode)
// 选择确认是员工编号写入订单的最后边界,不能依赖上游列表已经完成字段规范化。
const normalizedStaff = normalizeStaffItem(staff)
return {
[config.merchantIdField]: merchant?.merchantId || '',
[config.merchantNameField]: merchant?.merchantName || '',
[config.staffIdField]: staff?.uuid ?? '',
[config.staffNameField]: staff?.staffName || ''
[config.staffIdField]: normalizedStaff.uuid,
[config.staffNameField]: normalizedStaff.staffName
}
}
......
......@@ -20,6 +20,7 @@ import {
hasStaffConflict,
markMerchantActive,
markStaffActive,
normalizeStaffItem,
resolveStaffMerchantScope,
resolveSelectedMerchant,
shouldEchoSystemStaff,
......@@ -40,6 +41,7 @@ export {
getSelectedStaff,
hasStaffConflict,
isSystemStaff,
normalizeStaffItem,
resolveStaffMerchantScope,
resolveSelectedMerchant,
shouldEchoSystemStaff,
......@@ -168,7 +170,9 @@ export async function fetchStaff(mode, merchantId, context = {}) {
throw new Error(res?.message || '获取员工列表失败')
}
const staffListRaw = res.data || []
const staffListRaw = (Array.isArray(res.data) ? res.data : []).map(
normalizeStaffItem
)
const fallbackContext = { ...context, merchantList, orderObj, keyWord }
const staffListAfterFallback = applySystemStaffFallbackIfNeeded(
mode,
......@@ -299,11 +303,18 @@ export async function resolveDefaultSelection(context = {}) {
const res = await api.getLastUserOrderInfo({ sellerUserId })
const last = res?.data
if (last && last.merchantId == userContext.shopMerchantId) {
return {
merchantId: last.merchantId || '',
merchantName: last.merchantName || '',
userId: last.userId || '',
employeeName: last.employeeName || ''
const normalizedLastStaff = normalizeStaffItem(last)
if (
normalizedLastStaff.uuid !== '' &&
normalizedLastStaff.uuid != null &&
normalizedLastStaff.staffName
) {
return {
merchantId: last.merchantId || '',
merchantName: last.merchantName || '',
userId: normalizedLastStaff.uuid,
employeeName: normalizedLastStaff.staffName
}
}
}
} catch (e) {}
......
......@@ -9,6 +9,12 @@ export const PREMIUM_UPGRADE_SCENE_TYPE = 1
/** 正常订单类型值(与 ORDER_TYPE.NORMAL 一致) */
export const ORDER_TYPE_NORMAL = 1
/** 低价单页面固定展示项;value 沿用后端正常策略值 */
export const LOW_PRICE_ORDER_TYPE_OPTION = Object.freeze({
text: '低价订单',
value: ORDER_TYPE_NORMAL
})
/** 内部结算类型值(与 ORDER_TYPE.INTERNAL_SETTLEMENT 一致) */
export const ORDER_TYPE_INTERNAL_SETTLEMENT = 6
......@@ -74,7 +80,7 @@ export function buildOrderTypePickerList(
lowPriceFlag
) {
if (Number(lowPriceFlag) === 1) {
return orderTypeList.filter(item => item.value == ORDER_TYPE_NORMAL)
return [{ ...LOW_PRICE_ORDER_TYPE_OPTION }]
}
if (createAllGoodsFlag === 0) {
return orderTypeList.filter(item =>
......
......@@ -59,6 +59,9 @@ export function buildSubmitPayload(orderObj, context = {}) {
}
SUBMIT_ROOT_PROPERTIES_TO_DELETE.forEach(prop => {
if (prop === 'baseSceneName' && Number(submitObj.lowPriceFlag) === 1) {
return
}
if (Object.prototype.hasOwnProperty.call(submitObj, prop)) {
delete submitObj[prop]
}
......
......@@ -12,10 +12,12 @@ import {
} from '../services/customerProfileEffects.js'
describe('customerProfileEffects', () => {
it('buildCustomerOnlyOrder replaces customer without importing historical order fields', () => {
it('buildCustomerOnlyOrder only imports customer, order code and remark', () => {
const current = {
lowPriceFlag: 1,
merchantId: 100,
userId: 'CURRENT-SALES',
employeeName: '当前销售顾问',
selectPayType: 3,
payeeType: 1,
remark: '旧客户备注',
......@@ -23,6 +25,11 @@ describe('customerProfileEffects', () => {
customer: { customerId: 1, customerName: '旧客户' }
}
const selected = {
orderCode: 'ARCHIVE-ORDER-001',
userId: 'HISTORY-SALES',
employeeName: '历史销售顾问',
baseSceneCode: 'HISTORY-SCENE',
baseSceneName: '历史场景',
selectPayType: 5,
payeeType: 0,
remark: '新客户备注',
......@@ -48,7 +55,12 @@ describe('customerProfileEffects', () => {
})
assert.equal(result.selectPayType, 3)
assert.equal(result.payeeType, 1)
assert.equal(result.orderCode, 'ARCHIVE-ORDER-001')
assert.equal(result.remark, '新客户备注')
assert.equal(result.userId, 'CURRENT-SALES')
assert.equal(result.employeeName, '当前销售顾问')
assert.equal(result.baseSceneCode, undefined)
assert.equal(result.baseSceneName, undefined)
assert.deepEqual(result.subOrderList, [{ goodsCode: 'CURRENT' }])
assert.equal(result.packageGoodsList, undefined)
assert.deepEqual(current.customer, {
......
......@@ -35,6 +35,8 @@ function createPage(pageConfig, lowPriceFlag) {
let profileEchoCustomerId
let routeCount = 0
const page = {
_isLowPriceCreateOrder: Number(lowPriceFlag) === 1,
isLowPriceOrder: pageConfig.isLowPriceOrder,
data: {
...pageConfig.data,
customerInfoBox: true,
......@@ -43,6 +45,16 @@ function createPage(pageConfig, lowPriceFlag) {
...pageConfig.data.orderObj,
lowPriceFlag,
merchantId: 100,
merchantName: '当前门店',
baseSceneCode: 'SCENE-CONFIRMED-ON-ENTRY',
baseSceneName: 'Confirmed low-price scene',
sceneType: 1,
userId: 'CURRENT-SALES',
employeeName: '当前销售顾问',
sellerUserId: 'CURRENT-CONVERTER',
sellerName: '当前转化人员',
sellerMerchantId: 101,
sellerMerchantName: '当前园区店',
selectPayType: 3,
payeeType: 1,
remark: '旧客户备注',
......@@ -73,6 +85,18 @@ function createPage(pageConfig, lowPriceFlag) {
}
const selectedRecord = {
orderCode: 'ARCHIVE-ORDER-001',
merchantId: 999,
merchantName: '历史门店',
baseSceneCode: '',
baseSceneName: '',
sceneType: '',
userId: 'HISTORY-SALES',
employeeName: '历史销售顾问',
sellerUserId: 'HISTORY-SELLER',
sellerName: '历史销售',
sellerMerchantId: 998,
sellerMerchantName: '历史园区店',
selectPayType: 5,
payeeType: 0,
remark: '新客户备注',
......@@ -101,8 +125,26 @@ describe('createOrder customer profile import', () => {
assert.equal(context.page.data.orderObj.customer.salesType, 0)
assert.equal(context.page.data.orderObj.remark, '新客户备注')
assert.equal(context.page.data.currentWordNumber, 5)
assert.equal(context.page.data.orderObj.orderCode, 'ARCHIVE-ORDER-001')
assert.equal(context.page.data.orderObj.userId, 'CURRENT-SALES')
assert.equal(context.page.data.orderObj.employeeName, '当前销售顾问')
assert.equal(context.page.data.orderObj.merchantId, 100)
assert.equal(context.page.data.orderObj.merchantName, '当前门店')
assert.equal(context.page.data.orderObj.sellerUserId, 'CURRENT-CONVERTER')
assert.equal(context.page.data.orderObj.sellerName, '当前转化人员')
assert.equal(context.page.data.orderObj.sellerMerchantId, 101)
assert.equal(context.page.data.orderObj.sellerMerchantName, '当前园区店')
assert.equal(context.page.data.orderObj.selectPayType, 3)
assert.equal(context.page.data.orderObj.payeeType, 1)
assert.equal(
context.page.data.orderObj.baseSceneCode,
'SCENE-CONFIRMED-ON-ENTRY'
)
assert.equal(
context.page.data.orderObj.baseSceneName,
'Confirmed low-price scene'
)
assert.equal(context.page.data.orderObj.sceneType, 1)
assert.deepEqual(context.page.data.orderObj.subOrderList, [
{ goodsCode: 'CURRENT' }
])
......@@ -113,7 +155,7 @@ describe('createOrder customer profile import', () => {
assert.equal(context.getRouteCount(), 0)
})
it('normal-order profile selection keeps the existing order routing path', async () => {
it('dedicated low-price page never routes a customer profile as an order', async () => {
const pageConfig = await loadPageConfig()
const context = createPage(pageConfig, 0)
......@@ -121,7 +163,17 @@ describe('createOrder customer profile import', () => {
detail: structuredClone(selectedRecord)
})
assert.equal(context.getRouteCount(), 1)
assert.equal(context.getRouteCount(), 0)
assert.equal(context.page.data.orderObj.customer.customerId, 2)
assert.equal(context.page.data.orderObj.orderCode, 'ARCHIVE-ORDER-001')
assert.equal(context.page.data.orderObj.remark, '新客户备注')
assert.equal(context.page.data.orderObj.userId, 'CURRENT-SALES')
assert.equal(context.page.data.orderObj.employeeName, '当前销售顾问')
assert.equal(context.page.data.orderObj.merchantId, 100)
assert.equal(context.page.data.orderObj.merchantName, '当前门店')
assert.equal(context.page.data.orderObj.sellerUserId, 'CURRENT-CONVERTER')
assert.equal(context.page.data.orderObj.sellerName, '当前转化人员')
assert.equal(context.page.data.orderObj.selectPayType, 3)
assert.equal(context.page.data.orderObj.payeeType, 1)
})
})
......@@ -37,6 +37,9 @@ function createPage(options = {}) {
orderObj: {
lowPriceFlag: options.lowPriceFlag ?? 1,
djOrderType: 1,
baseSceneCode: 'SCENE-LOW',
baseSceneName: '低价单默认场景',
sceneType: 1,
selectPayType: 1,
customer: {},
subOrderList: []
......@@ -93,11 +96,13 @@ describe('low-price approval submit flow', () => {
it('submits once after approval and returns the source list to pending', async () => {
let apiCalls = 0
let submittedPayload
let redirectTarget = ''
let backCalls = 0
let sourcePatch
globalThis.__WORK_ORDER_MOCK_API__.createWithPay = () => {
globalThis.__WORK_ORDER_MOCK_API__.createWithPay = payload => {
apiCalls += 1
submittedPayload = payload
return { code: 0, data: { orderCode: 'LP-1' } }
}
wx.$router.redirectTo = route => {
......@@ -117,6 +122,9 @@ describe('low-price approval submit flow', () => {
await new SubmitContext(page).executeAfterApproval({ save: false })
assert.equal(apiCalls, 1)
assert.equal(submittedPayload.baseSceneCode, 'SCENE-LOW')
assert.equal(submittedPayload.baseSceneName, '低价单默认场景')
assert.equal(submittedPayload.sceneType, 1)
assert.equal(redirectTarget, '')
assert.equal(backCalls, 1)
assert.deepEqual(sourcePatch, {
......@@ -129,10 +137,14 @@ describe('low-price approval submit flow', () => {
it('keeps ordinary order success on confirmOrder', async () => {
let redirectTarget = ''
globalThis.__WORK_ORDER_MOCK_API__.createWithPay = () => ({
code: 0,
data: { orderCode: 'NORMAL-1' }
})
let submittedPayload
globalThis.__WORK_ORDER_MOCK_API__.createWithPay = payload => {
submittedPayload = payload
return {
code: 0,
data: { orderCode: 'NORMAL-1' }
}
}
wx.$router.redirectTo = route => {
redirectTarget = route
}
......@@ -140,6 +152,9 @@ describe('low-price approval submit flow', () => {
await new SubmitContext(page).executeAfterApproval({ save: false })
assert.equal(submittedPayload.baseSceneCode, 'SCENE-LOW')
assert.equal(submittedPayload.baseSceneName, undefined)
assert.equal(submittedPayload.sceneType, 1)
assert.equal(redirectTarget, 'confirmOrder')
})
......
......@@ -44,3 +44,96 @@ test('低价单关联门店接口为空时仍回显前一步选中的 4S 店', a
delete globalThis.__WORK_ORDER_MOCK_API__
}
})
test('在职员工接口仅返回 userId/name 时仍规范化为可提交的销售顾问', async () => {
globalThis.__WORK_ORDER_MOCK_API__ = {
getEmployeeList() {
return {
code: 0,
data: [
{
uuid: '',
userId: 501,
name: '已选择的销售顾问'
}
]
}
}
}
try {
const { STAFF_MODE, fetchStaff, buildOrderPatch } = await import(
`../services/merchantStaffSelection.js?employee-shape=${Date.now()}`
)
const result = await fetchStaff(STAFF_MODE.SALES, 44210895, {
orderObj: {},
merchantList: [
{
merchantId: 44210895,
merchantName: '波波的单店门店',
active: true
}
]
})
assert.equal(result.staffList[0].uuid, 501)
assert.equal(result.staffList[0].staffName, '已选择的销售顾问')
assert.equal(result.staffList[0].active, true)
assert.deepEqual(
buildOrderPatch(
STAFF_MODE.SALES,
{
merchantId: 44210895,
merchantName: '波波的单店门店'
},
result.staffList[0]
),
{
merchantId: 44210895,
merchantName: '波波的单店门店',
userId: 501,
employeeName: '已选择的销售顾问'
}
)
} finally {
delete globalThis.__WORK_ORDER_MOCK_API__
}
})
test('上一单只有销售顾问姓名但没有人员编号时不生成伪选中状态', async () => {
globalThis.__WORK_ORDER_MOCK_API__ = {
getLastUserOrderInfo() {
return {
code: 0,
data: {
merchantId: 44210895,
merchantName: '波波的单店门店',
userId: '',
employeeName: '只有姓名的历史顾问'
}
}
}
}
try {
const { resolveDefaultSelection } = await import(
`../services/merchantStaffSelection.js?incomplete-last=${Date.now()}`
)
const patch = await resolveDefaultSelection({
orderObj: {
lowPriceFlag: 1,
merchantId: 44210895,
merchantName: '波波的单店门店'
},
userContext: {
operatorId: 'operator-1',
shopMerchantId: 44210895
},
orderCreateType: 'createdOrder'
})
assert.equal(patch, null)
} finally {
delete globalThis.__WORK_ORDER_MOCK_API__
}
})
......@@ -29,6 +29,25 @@ describe('merchantStaffSelection', () => {
})
})
it('buildOrderPatch normalizes raw sales staff fields at the write boundary', () => {
const patch = buildOrderPatch(
STAFF_MODE.SALES,
{ merchantId: 'm1', merchantName: '门店A' },
{
uuid: '',
userId: 'u-raw-1',
name: '原始接口销售顾问'
}
)
assert.deepEqual(patch, {
merchantId: 'm1',
merchantName: '门店A',
userId: 'u-raw-1',
employeeName: '原始接口销售顾问'
})
})
it('buildOrderPatch maps conversion fields', () => {
const patch = buildOrderPatch(
STAFF_MODE.CONVERSION,
......
......@@ -25,15 +25,17 @@ test('resolveCreateAllGoodsFlag: 非精品升级按接口', () => {
assert.equal(resolveCreateAllGoodsFlag(1, 0), 1)
})
test('buildOrderTypePickerList limits low-price orders to normal order', () => {
test('buildOrderTypePickerList exposes low-price order as the only low-price option', () => {
const all = [
{ text: '正常订单', value: 1 },
{ text: '打折策略', value: 2 },
{ text: '内部结算', value: 6 }
]
const limited = buildOrderTypePickerList(all, 0, 1)
assert.deepEqual(limited, [{ text: '正常订单', value: 1 }])
assert.deepEqual(buildOrderTypePickerList(all, 1, 1), [all[0]])
assert.deepEqual(limited, [{ text: '低价订单', value: 1 }])
assert.deepEqual(buildOrderTypePickerList(all, 1, 1), [
{ text: '低价订单', value: 1 }
])
assert.deepEqual(buildOrderTypePickerList(all, 0, 0), [all[0], all[2]])
assert.equal(buildOrderTypePickerList(all, 1).length, 3)
})
......
import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import {
buildCustomerRequiredList,
normalizeMerchantOrderSettings,
shouldValidateCustomerPhone
} from '../../../../utils/orderRequiredSettings.helpers.js'
describe('order required settings adapter', () => {
it('normalizes employee-app field keys and selects phone config by park store', () => {
const result = normalizeMerchantOrderSettings(
{
orderFieldSettingList: [
{ fieldKey: 'carBrand', isRequired: true },
{ fieldKey: 'carNo', isRequired: 0 },
{ fieldKey: 'plateNo', isRequired: false },
{ fieldKey: 'customerPhone', isRequired: 'N' }
],
yqPhoneConfig: JSON.stringify([
{
yqMerchantId: 100,
shopMerchantPhoneList: [
{ shopMerchantId: 44210895, phoneNumber: '13800000000' }
]
},
{
yqMerchantId: 200,
shopMerchantPhoneList: [
{ shopMerchantId: 999, phoneNumber: '13900000000' }
]
}
])
},
{ shopMerchantId: 44210895, yqMerchantId: 100 }
)
assert.deepEqual(result, {
carTypeRequiredFlag: 'Y',
standNoRequiredFlag: 'N',
plateNumRequiredFlag: 'N',
customerPhoneRequiredFlag: 'N',
shopMerchantId: 44210895,
yqMerchantId: 100,
yqPhoneConfig: [
{ shopMerchantId: 44210895, phoneNumber: '13800000000' }
]
})
})
it('supports phone aliases and direct legacy flags without changing explicit values', () => {
const result = normalizeMerchantOrderSettings(
{
carTypeRequiredFlag: 'N',
orderFieldSettingList: [
{ fieldKey: 'phone', isRequired: 1 },
{ fieldKey: 'mobile', isRequired: false }
],
yqPhoneConfig: []
},
{ shopMerchantId: 1, yqMerchantId: 2 }
)
assert.equal(result.carTypeRequiredFlag, 'N')
assert.equal(result.customerPhoneRequiredFlag, 'N')
assert.equal(result.yqPhoneConfig, false)
})
it('rebuilds managed required fields so a non-required plate never leaves a stale star', () => {
assert.deepEqual(
buildCustomerRequiredList(
{
carTypeRequiredFlag: 'Y',
standNoRequiredFlag: 'N',
plateNumRequiredFlag: 'N',
customerPhoneRequiredFlag: 'N'
},
['subShopMerchantId', 'plateNumber']
),
['subShopMerchantId', 'carBrand']
)
})
it('keeps phone required only as a compatibility fallback when the API omits its flag', () => {
assert.deepEqual(buildCustomerRequiredList({}, []), ['customerPhone'])
assert.deepEqual(
buildCustomerRequiredList({ customerPhoneRequiredFlag: 'N' }, []),
[]
)
})
it('validates an optional phone only after the customer enters a value', () => {
assert.equal(shouldValidateCustomerPhone([], ''), false)
assert.equal(shouldValidateCustomerPhone([], '123'), true)
assert.equal(shouldValidateCustomerPhone(['customerPhone'], ''), true)
})
})
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { register } from 'node:module'
import { beforeEach, describe, it } from 'node:test'
register(
'../../../../tests/work-order-migration/shims/create-order-context-loader.mjs',
import.meta.url
)
const app = { globalData: {} }
let pageConfig
globalThis.getApp = () => app
globalThis.Page = config => {
pageConfig = config
}
globalThis.wx = {
getAccountInfoSync: () => ({
miniProgram: { appId: 'test-app-id', envVersion: 'develop' }
}),
getAppBaseInfo: () => ({ host: { env: '' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
getWindowInfo: () => ({ windowHeight: 800 }),
getSystemInfoSync: () => ({ platform: 'devtools' }),
getStorageSync: () => '',
$track: { setTrackData() {} },
$util: {
debounce: fn => fn,
deepClone: value => structuredClone(value),
getUserInfo: () => ({
shopMerchantId: 888,
subLoginUser: { merchantId: 777 }
}),
hideLoading() {},
showLoading() {},
showToast() {}
}
}
await import(`../createOrder.js?required-settings=${Date.now()}`)
function createPage(overrides = {}) {
const page = {
...pageConfig,
data: {
...pageConfig.data,
requiredList: [],
orderObj: {
...pageConfig.data.orderObj,
userId: 1,
baseSceneCode: 'SCENE',
merchantId: 44210895,
merchantName: '波波的单店门店',
yqMerchantId: 100,
yqMerchantName: '测试园区店',
sellerUserId: 2,
sellerName: '转化人员',
sellerMerchantId: 100,
employeeName: '销售顾问',
payeeType: 1,
selectPayType: 1,
lowPriceFlag: 1,
customer: {
customerName: '测试客户',
customerPhone: '',
salesType: 0,
standNo: '',
plateNumber: '',
carBrand: ''
}
},
...overrides
},
setData(patch) {
Object.assign(this.data, patch)
},
showToast(message) {
this.messages.push(message)
},
messages: []
}
return page
}
describe('createOrder dynamic customer required fields', () => {
beforeEach(() => {
app.globalData = {}
globalThis.__WORK_ORDER_MOCK_API__ = undefined
})
it('uses store 44210895 settings and removes the plate star when plateNo is not required', async () => {
const requests = []
globalThis.__WORK_ORDER_MOCK_API__ = {
getMerchantRecordingSettings(params) {
requests.push(params)
return {
code: 0,
data: {
orderFieldSettingList: [
{ fieldKey: 'carBrand', isRequired: true },
{ fieldKey: 'carNo', isRequired: false },
{ fieldKey: 'plateNo', isRequired: false },
{ fieldKey: 'customerPhone', isRequired: false }
],
yqPhoneConfig: '[]'
}
}
}
}
const page = createPage({ requiredList: ['plateNumber'] })
pageConfig.getSetting.call(page)
await new Promise(resolve => setImmediate(resolve))
assert.deepEqual(requests, [{ scene: 1, merchantId: 44210895 }])
assert.deepEqual(page.data.requiredList, ['carBrand'])
})
it('loads the selected store settings during direct low-price page entry', async () => {
const requests = []
globalThis.__WORK_ORDER_MOCK_API__ = {
getMerchantRecordingSettings(params) {
requests.push(params)
return {
code: 0,
data: {
orderFieldSettingList: [
{ fieldKey: 'carBrand', isRequired: true },
{ fieldKey: 'carNo', isRequired: false },
{ fieldKey: 'plateNo', isRequired: false },
{ fieldKey: 'customerPhone', isRequired: false }
],
yqPhoneConfig: '[]'
}
}
}
}
const page = createPage()
page.applyOrderTypeConfig = () => {}
page.prefillRecentScene = async () => {}
page.getUserSceneList = () => {}
page.prefillLastSeller = () => {}
await pageConfig.onLoad.call(page, {
lowPriceFlag: 1,
merchantId: 44210895,
merchantName: '波波的单店门店',
yqMerchantId: 100,
sellerMerchantId: 100
})
await new Promise(resolve => setImmediate(resolve))
assert.deepEqual(requests, [{ scene: 1, merchantId: 44210895 }])
assert.deepEqual(page.data.requiredList, ['carBrand'])
})
it('clears stale vehicle requirements and restores the phone fallback when loading fails', async () => {
globalThis.__WORK_ORDER_MOCK_API__ = {
getMerchantRecordingSettings() {
return Promise.reject(new Error('settings unavailable'))
}
}
const page = createPage({
requiredList: ['subShopMerchantId', 'plateNumber'],
phoneShow: [{ shopMerchantId: 999, phoneNumber: '13900000000' }]
})
pageConfig.getSetting.call(page)
await new Promise(resolve => setImmediate(resolve))
assert.deepEqual(page.data.requiredList, [
'subShopMerchantId',
'customerPhone'
])
assert.equal(page.data.phoneShow, false)
})
it('allows an optional empty phone but still rejects a non-empty invalid phone', () => {
const page = createPage()
assert.equal(
pageConfig.checkRequired.call(page, false, structuredClone(page.data.orderObj)),
false
)
const invalidPhoneOrder = structuredClone(page.data.orderObj)
invalidPhoneOrder.customer.customerPhone = '123'
assert.equal(pageConfig.checkRequired.call(page, false, invalidPhoneOrder), true)
assert.deepEqual(page.messages, ['请输入正确的手机号'])
})
it('blocks an empty phone when the store explicitly requires it', () => {
const page = createPage({ requiredList: ['customerPhone'] })
assert.equal(
pageConfig.checkRequired.call(page, false, structuredClone(page.data.orderObj)),
true
)
assert.deepEqual(page.messages, ['请输入正确的手机号'])
})
it('binds all four customer stars to the dynamic required list', () => {
const template = readFileSync(new URL('../createOrder.wxml', import.meta.url), 'utf8')
for (const [label, field] of [
['手机号', 'customerPhone'],
['选择车型', 'carBrand'],
['车架号( VIN )', 'standNo'],
['车牌号', 'plateNumber']
]) {
const cell = template.match(
new RegExp(`<gl-cell[\\s\\S]*?label="${label.replace(/[()]/g, '\\$&')}"[\\s\\S]*?\\/>`)
)?.[0]
assert.ok(cell, `missing ${label} cell`)
assert.match(
cell,
new RegExp(`required="\\{\\{ filter\\.isIncludesItem\\(requiredList ,'${field}'\\) \\}\\}"`)
)
}
})
})
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { register } from 'node:module'
import test from 'node:test'
import { loadMiniProgramApi } from '../../../../tests/order-lifecycle/support/loadMiniProgramApi.mjs'
register(
'../../../../tests/work-order-migration/shims/create-order-context-loader.mjs',
import.meta.url
)
test('order settings use and cache the park store selected before low-price order creation', async () => {
test('order settings use the selected 4S store and normalize its employee-app settings', async () => {
const app = {
globalData: {
YQorderSetting: { marker: 'wrong-cache' },
YQorderSettingMerchantId: 999
YQorderSettingMerchantId: 999,
YQorderSettingYqMerchantId: 100
}
}
const requests = []
......@@ -27,6 +28,7 @@ test('order settings use and cache the park store selected before low-price orde
removeStorageSync: () => {},
$util: {
getUserInfo: () => ({
shopMerchantId: 888,
subLoginUser: { merchantId: 777, merchantName: '登录园区店' }
}),
showLoading: () => {},
......@@ -39,11 +41,20 @@ test('order settings use and cache the park store selected before low-price orde
return {
code: 0,
data: {
marker: 'selected-store-setting',
orderFieldSettingList: [
{ fieldKey: 'carBrand', isRequired: true },
{ fieldKey: 'carNo', isRequired: false },
{ fieldKey: 'plateNo', isRequired: false },
{ fieldKey: 'customerPhone', isRequired: false }
],
yqPhoneConfig: JSON.stringify([
{
yqMerchantId: 100,
shopMerchantPhoneList: [{ shopMerchantId: 201 }]
shopMerchantPhoneList: [{ shopMerchantId: 44210895 }]
},
{
yqMerchantId: 200,
shopMerchantPhoneList: [{ shopMerchantId: 20001 }]
}
])
}
......@@ -55,24 +66,50 @@ test('order settings use and cache the park store selected before low-price orde
`../../../../store/index.js?selected-order-setting=${Date.now()}`
)
const result = await getYQorderInfo({
merchantId: 100,
merchantName: '已选园区店'
shopMerchantId: 44210895,
shopMerchantName: '波波的单店门店',
yqMerchantId: 100
})
assert.deepEqual(requests, [
{ merchantId: 100, merchantName: '已选园区店' }
assert.deepEqual(requests, [{ scene: 1, merchantId: 44210895 }])
assert.equal(result.carTypeRequiredFlag, 'Y')
assert.equal(result.standNoRequiredFlag, 'N')
assert.equal(result.plateNumRequiredFlag, 'N')
assert.equal(result.customerPhoneRequiredFlag, 'N')
assert.deepEqual(result.yqPhoneConfig, [{ shopMerchantId: 44210895 }])
assert.equal(app.globalData.YQorderSettingMerchantId, 44210895)
assert.equal(app.globalData.YQorderSettingYqMerchantId, 100)
assert.equal(app.globalData.YQorderSetting.plateNumRequiredFlag, 'N')
await getYQorderInfo({ shopMerchantId: 44210895, yqMerchantId: 100 })
assert.equal(requests.length, 1)
const switchedParkResult = await getYQorderInfo({
shopMerchantId: 44210895,
yqMerchantId: 200
})
assert.equal(requests.length, 2)
assert.deepEqual(switchedParkResult.yqPhoneConfig, [
{ shopMerchantId: 20001 }
])
assert.equal(result.marker, 'selected-store-setting')
assert.deepEqual(result.yqPhoneConfig, [{ shopMerchantId: 201 }])
assert.equal(app.globalData.YQorderSettingMerchantId, 100)
assert.equal(app.globalData.YQorderSetting.marker, 'selected-store-setting')
})
test('createOrder passes the selected park store to the order-settings query', () => {
const source = readFileSync(new URL('../createOrder.js', import.meta.url), 'utf8')
test('the order-settings API forwards to the employee-app light-change endpoint', async () => {
const calls = []
const api = await loadMiniProgramApi('api/api.js', {
post(method, payload) {
calls.push({ method, payload })
return Promise.resolve({ code: 0, data: {} })
}
})
const payload = { scene: 1, merchantId: 44210895 }
await api.getMerchantRecordingSettings(payload)
assert.match(source, /const selectedYqMerchantId =\s*orderObj\.yqMerchantId \|\| orderObj\.sellerMerchantId/)
assert.match(source, /merchantId: selectedYqMerchantId/)
assert.match(source, /merchantName:\s*orderObj\.yqMerchantName \|\| orderObj\.sellerMerchantName/)
assert.match(source, /getYQorderInfo\(selectedYqMerchant\)/)
assert.deepEqual(calls, [
{
method: 'dj.api.smartcarlife.order.field.lightChange.setting.list',
payload
}
])
})
......@@ -39,6 +39,8 @@ test('customer or history echo keeps the store selected before low-price order c
sellerMerchantName: '已选园区店'
}
const page = {
_isLowPriceCreateOrder: true,
isLowPriceOrder: pageConfig.isLowPriceOrder,
data: {
...pageConfig.data,
orderObj: { ...pageConfig.data.orderObj, ...selectedStore },
......@@ -70,6 +72,7 @@ test('customer or history echo keeps the store selected before low-price order c
pageConfig.setOrderObj.call(page, incoming)
assert.equal(page.data.orderTypeName, '低价订单')
assert.equal(page.data.orderObj.customer.customerName, '张三')
assert.deepEqual(
{
......
......@@ -11,6 +11,7 @@ describe('submitPayload.helpers', () => {
orderCode: 'OC1',
sceneType: 1,
baseSceneCode: '100101',
baseSceneName: '精品接待场景',
subOrderList: [{}],
customerCouponCode: 'C1',
selectPayType: 1,
......@@ -54,6 +55,7 @@ describe('submitPayload.helpers', () => {
it('IT-WO-SUB-005: strips audit fields on build', () => {
const out = buildSubmitPayload(baseOrder, {})
assert.equal(out.profitAllocatinList, undefined)
assert.equal(out.baseSceneName, undefined)
assert.equal(out.customer.buyTime, undefined)
})
......@@ -119,5 +121,8 @@ describe('submitPayload.helpers', () => {
assert.equal(out.merchantId, 201)
assert.equal(out.yqMerchantId, 100)
assert.equal(out.sellerMerchantId, 100)
assert.equal(out.baseSceneCode, '100101')
assert.equal(out.baseSceneName, '精品接待场景')
assert.equal(out.sceneType, 1)
})
})
......@@ -54,6 +54,24 @@ describe('登录迁移前的固定用户模拟', async () => {
assert.equal(second._perm.isNormalStaff, true)
})
it('固定账号提供重新打开低价下单页所需的门店上下文', () => {
assert.equal(
typeof fixedUserMock?.createFixedLowPriceEntryContext,
'function',
'尚未实现 createFixedLowPriceEntryContext'
)
assert.deepEqual(fixedUserMock.createFixedLowPriceEntryContext(), {
lowPriceFlag: 1,
merchantId: 44210895,
merchantName: '波波的单店门店',
yqMerchantId: 44211025,
yqMerchantName: '流程测试园区门店',
sellerMerchantId: 44211025,
sellerMerchantName: '流程测试园区门店'
})
})
it('sessionId 完全沿用系统原有缓存读取', async () => {
const utilSource = await readFile(
new URL('../../utils/util.js', import.meta.url),
......
......@@ -13,8 +13,10 @@ import {
resolveApprovalStatusFilter
} from '../../pages/tabWorkOrder/services/lowPriceOrder.helpers.js'
import {
applyLowPriceDefaultScene,
buildLowPriceOrderPatch,
mergeLowPriceOrderContext
mergeLowPriceOrderContext,
restoreFixedLowPriceEntryContext
} from '../../tabWorkOrder/pages/createOrder/services/lowPriceOrderContext.helpers.js'
import { resolveDirectWorkOrderAction } from '../../pages/tab/workspace/services/workOrderEntry.helpers.js'
register(
......@@ -228,6 +230,92 @@ describe('创建页低价单上下文', () => {
assert.equal(result.lowPriceFlag, 1)
assert.equal(result.djOrderType, 1)
})
it('低价单场景不完整时在页面状态中使用固定精品升级场景', () => {
const result = applyLowPriceDefaultScene({
lowPriceFlag: 1,
baseSceneCode: 'SCENE-FROM-API',
baseSceneName: '',
sceneType: 7,
customer: { customerName: '张三' }
})
assert.deepEqual(result, {
lowPriceFlag: 1,
baseSceneCode: '100101',
baseSceneName: '精品升级',
sceneType: 1,
customer: { customerName: '张三' }
})
})
it('完整低价场景与普通订单场景都不被默认值改写', () => {
const lowPriceOrderObj = {
lowPriceFlag: 1,
baseSceneCode: 'SCENE-FROM-API',
baseSceneName: '接口场景',
sceneType: 7
}
const orderObj = {
lowPriceFlag: 0,
baseSceneCode: 'NORMAL-SCENE',
baseSceneName: '普通场景',
sceneType: 7
}
assert.equal(applyLowPriceDefaultScene(lowPriceOrderObj), lowPriceOrderObj)
assert.equal(applyLowPriceDefaultScene(orderObj), orderObj)
})
it('空入口恢复固定低价门店,但不覆盖编辑和显式普通单入口', () => {
const fixedContext = {
lowPriceFlag: 1,
merchantId: 44210895,
yqMerchantId: 44211025
}
assert.deepEqual(
restoreFixedLowPriceEntryContext({}, fixedContext),
fixedContext
)
assert.deepEqual(
restoreFixedLowPriceEntryContext(
{ paymentMethod: 1, skipOrderGuards: true },
fixedContext
),
{
...fixedContext,
paymentMethod: 1,
skipOrderGuards: true
}
)
assert.deepEqual(
restoreFixedLowPriceEntryContext(
{ orderCode: 'EDIT-001', merchantId: 9 },
fixedContext
),
{ orderCode: 'EDIT-001', merchantId: 9 }
)
assert.deepEqual(
restoreFixedLowPriceEntryContext({ lowPriceFlag: 0 }, fixedContext),
{ lowPriceFlag: 0 }
)
const explicitEntries = [
{ scene: 'couponId=1' },
{
orderCreateType: 'additionRecordOrder',
selectOutTradeNoArr: ['TRADE-001']
},
{ merchantId: 9, merchantName: 'Explicit store' }
]
explicitEntries.forEach(entry => {
assert.deepEqual(
restoreFixedLowPriceEntryContext(entry, fixedContext),
entry
)
})
})
})
describe('工作台低价单直达参数', () => {
......
......@@ -86,4 +86,17 @@ describe('精品工单迁移闭包', () => {
)
assert.match(createOrderSource, /tabWorkOrder\.ocr|\/tabWorkOrder\/pages\/ocr/)
})
it('主包共享 store 不依赖 tabWorkOrder 分包资源', async () => {
const storeSource = await readFile(
path.join(projectRoot, 'store/index.js'),
'utf8'
)
assert.doesNotMatch(
storeSource,
/from\s+['"]~\/tabWorkOrder\//,
'主包 store 不能静态导入 tabWorkOrder 分包模块'
)
})
})
......@@ -25,12 +25,36 @@ export default {
data: { yqPhoneConfig: '[]' }
})
},
getRecentUserScene(data) {
return configuredResponse('getRecentUserScene', data, {
code: 0,
data: null
})
},
getUserScene(data) {
return configuredResponse('getUserScene', data, {
code: 0,
data: []
})
},
getSelectOrderGoodsList(data) {
return configuredResponse('getSelectOrderGoodsList', data, {
code: 0,
data: []
})
},
getEmployeeList(data) {
return configuredResponse('getEmployeeList', data, {
code: 0,
data: []
})
},
getLastUserOrderInfo(data) {
return configuredResponse('getLastUserOrderInfo', data, {
code: 0,
data: null
})
},
createWithPay(data) {
return configuredResponse('createWithPay', data, {
code: 0,
......
......@@ -78,6 +78,19 @@ export function createFixedUserInfo() {
return JSON.parse(JSON.stringify(FIXED_USER_INFO))
}
export function createFixedLowPriceEntryContext() {
const userInfo = createFixedUserInfo()
return {
lowPriceFlag: 1,
merchantId: userInfo.shopMerchantId,
merchantName: userInfo.shopMerchantName,
yqMerchantId: userInfo.merchantId,
yqMerchantName: userInfo.merchantName,
sellerMerchantId: userInfo.merchantId,
sellerMerchantName: userInfo.merchantName
}
}
export function resolveRuntimeUserInfo(readStoredUserInfo) {
if (FIXED_USER_INFO_MOCK_ENABLED) return createFixedUserInfo()
return readStoredUserInfo()
......
const FIELD_FLAG_MAP = {
carBrand: 'carTypeRequiredFlag',
carNo: 'standNoRequiredFlag',
plateNo: 'plateNumRequiredFlag',
customerPhone: 'customerPhoneRequiredFlag',
phone: 'customerPhoneRequiredFlag',
mobile: 'customerPhoneRequiredFlag'
}
const MANAGED_REQUIRED_FIELDS = [
'carBrand',
'standNo',
'plateNumber',
'customerPhone'
]
const REQUIRED_FIELD_MAP = {
carTypeRequiredFlag: 'carBrand',
standNoRequiredFlag: 'standNo',
plateNumRequiredFlag: 'plateNumber'
}
function normalizeRequiredFlag(value) {
if (value === true || value === 1 || value === '1') return 'Y'
if (value === false || value === 0 || value === '0') return 'N'
if (typeof value === 'string') {
const flag = value.trim().toUpperCase()
if (flag === 'Y' || flag === 'N') return flag
}
}
function parsePhoneConfig(value) {
if (Array.isArray(value)) return value
if (!value) return []
try {
const result = typeof value === 'string' ? JSON.parse(value) : value
return Array.isArray(result) ? result : []
} catch (error) {
return []
}
}
export function normalizeMerchantOrderSettings(
data = {},
{ shopMerchantId, yqMerchantId } = {}
) {
const result = {}
Object.keys(data).forEach(key => {
if (key !== 'orderFieldSettingList' && key !== 'yqPhoneConfig') {
result[key] = data[key]
}
})
Object.keys(result).forEach(key => {
const flag = normalizeRequiredFlag(result[key])
if (key.endsWith('RequiredFlag') && flag) result[key] = flag
})
const fieldSettingList = Array.isArray(data.orderFieldSettingList)
? data.orderFieldSettingList
: []
fieldSettingList.forEach(item => {
const targetKey = FIELD_FLAG_MAP[item?.fieldKey] || item?.fieldKey
const flag = normalizeRequiredFlag(item?.isRequired)
if (targetKey && flag) result[targetKey] = flag
})
const selectedPhoneConfig = parsePhoneConfig(data.yqPhoneConfig).find(
item => String(item?.yqMerchantId) === String(yqMerchantId)
)
result.shopMerchantId = shopMerchantId
result.yqMerchantId = yqMerchantId
result.yqPhoneConfig = selectedPhoneConfig?.shopMerchantPhoneList || false
return result
}
export function buildCustomerRequiredList(
settings = {},
currentRequiredList = []
) {
const requiredList = currentRequiredList.filter(
field => !MANAGED_REQUIRED_FIELDS.includes(field)
)
Object.entries(REQUIRED_FIELD_MAP).forEach(([flagKey, field]) => {
if (normalizeRequiredFlag(settings[flagKey]) === 'Y') {
requiredList.push(field)
}
})
if (normalizeRequiredFlag(settings.customerPhoneRequiredFlag) !== 'N') {
requiredList.push('customerPhone')
}
return [...new Set(requiredList)]
}
export function shouldValidateCustomerPhone(requiredList = [], phone = '') {
return (
requiredList.includes('customerPhone') || String(phone ?? '').trim() !== ''
)
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!