Commit e603820c by 张立顺

docs: redesign low-price minimum validation

1 parent 70ccc780
# Low-Price Minimum Validation Policy 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:** Show the full low-price catalog and validate minimum-price eligibility only at submission, accepting the order when any submitted goods entry qualifies.
**Architecture:** Remove minimum-price eligibility filtering from the catalog path and remove validation calls from selection and price-edit interactions. Keep the existing per-goods predicate, change the order aggregation to `some`, and invoke it only from `checkGoods` before the existing submission checks.
**Tech Stack:** WeChat Mini Program JavaScript, ES modules, Node.js built-in test runner.
## Global Constraints
- Preserve the user's existing `config.js` and `yarn.lock` changes.
- A goods entry qualifies only when `validMinSellPrice === 'Y'` and current base price is strictly below a numeric `minSellPrice`.
- One qualifying submitted goods entry makes the whole low-price order eligible.
- Normal-order price validation and approval behavior must remain unchanged.
- Do not add dependencies or change APIs/layouts.
---
### Task 1: Change whole-order aggregation
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/services/lowPriceGoodsValidation.helpers.js`
- Test: `tabWorkOrder/pages/createOrder/tests/lowPriceGoodsValidation.helpers.test.mjs`
**Interfaces:**
- Consumes: `validateLowPriceGoods(goods): { valid, enabled, minPrice, currentPrice }`.
- Produces: `validateLowPriceGoodsList(goodsList): { valid, matchedGoods, invalidGoods, entries }` where `valid === matchedGoods.length > 0`.
- [ ] Write tests proving mixed goods pass, all-invalid goods fail, and empty goods fail.
- [ ] Run the helper test and verify it fails under the old all-match rule.
- [ ] Implement `matchedGoods` and the `some`-equivalent aggregate.
- [ ] Separate minimum-price presentation from eligibility errors so presentation never marks inputs invalid.
- [ ] Run the helper test and verify it passes.
### Task 2: Restore the full selectable catalog
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/createOrder.js`
- Delete: `tabWorkOrder/pages/createOrder/services/lowPriceCatalogFilter.helpers.js`
- Delete: `tabWorkOrder/pages/createOrder/tests/lowPriceCatalogFilter.helpers.test.mjs`
- Modify: `tabWorkOrder/pages/createOrder/tests/lowPriceCatalogFilter.integration.test.mjs`
**Interfaces:**
- Consumes: normalized `rawCatalogData` from `getSelectOrderGoodsList`.
- Produces: unchanged full catalog passed to `classifySelectOrderCatalog` for both low-price and normal orders.
- [ ] Change the low-price catalog integration expectation to all catalog entries and all SKUs.
- [ ] Run the integration test and verify it fails against the existing filter.
- [ ] Remove the filter import/call and use `rawCatalogData` directly.
- [ ] Delete the obsolete pure filter and its obsolete tests.
- [ ] Run catalog integration and classification tests.
### Task 3: Validate only during submission
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/createOrder.js`
- Modify: `tabWorkOrder/pages/createOrder/tests/lowPriceGoodsValidation.integration.test.mjs`
**Interfaces:**
- Consumes: `validateLowPriceGoodsList(goodsList)` from the pure helper.
- Produces: `checkGoods(...)` returns `LOW_PRICE_NOT_TRIGGERED_MESSAGE` only when no submitted entry qualifies.
- [ ] Update static and dynamic integration tests to require no validation calls from choose, input, blur, or total calculation paths.
- [ ] Run the integration test and verify it fails against the current live-validation calls.
- [ ] Remove `applyLowPriceGoodsRules` and all interactive validation calls.
- [ ] In the low-price `priceBlur` branch, only recalculate totals and return.
- [ ] Use `validateLowPriceGoodsList` in `checkGoods` without mutating input error fields.
- [ ] Run create-order tests and verify the mixed-pass/all-invalid-block behavior.
### Task 4: Verify the complete change
**Files:**
- Modify only if an in-scope regression is found.
- [ ] Run `npm run test:createOrder`.
- [ ] Run `npm run test:workOrder`.
- [ ] Run `git diff --check` and confirm only intended files are staged.
- [ ] Request a read-only code review and fix any Critical or Important findings.
# 低价单最低价格校验策略调整设计
## 目标
调整低价单创建页的最低价格规则:选品目录展示全部商品;选品、输入价格和输入框失焦时不执行最低价格校验;仅在提交订单时校验整单,并且只要一个实际提交商品满足最低价格条件即可继续提交。
## 规则定义
单个商品沿用现有“满足最低价格”定义:
- `validMinSellPrice === 'Y'`;
- `minSellPrice` 是有效数字;
- 当前基础单价是有效数字;
- 当前基础单价严格小于 `minSellPrice`。
当前基础单价仍按 `basePrice`、`sellPrice`、`price` 的顺序取值。折扣后的 `finalPrice` 不参与判断。
整单规则由“每个实际提交商品都满足”改为“至少一个实际提交商品满足”。单商品、多规格已选 SKU、套餐内每个子商品都作为独立候选项。没有选择商品、所有商品未开启校验、缺少最低价、价格无效或全部价格未低于最低价时,整单均不满足。
## 交互时机
- 获取选品目录时不检查 `validMinSellPrice`,普通商品、多规格 SKU 和套餐全部按接口数据展示。
- 选择或删除商品时不执行最低价格校验。
- 普通商品、SKU 或套餐子商品输入价格时不执行最低价格校验,也不弹最低价提示。
- 低价单价格输入框失焦时不执行最低价格校验,仅保留总价重算。
- 提交时执行一次整单校验:任一候选项满足即可继续原提交链路;没有候选项满足时返回现有提示文案 `价格未触发最低价,其他正常单请到生意助手侧录单`。
- 最低价信息文案可继续展示,但展示逻辑不设置 `errorTarget`、`checkError` 或 `basePriceError`,不产生输入框红色错误态。
## 数据流
选品接口响应 → 目录预处理 → 原目录分类 → 展示全部商品。
用户选品/改价/失焦 → 更新商品和总价 → 不执行最低价格判断。
用户提交 → 展开实际提交商品 → 对每个商品计算是否满足 → `some` 聚合 → 满足则继续提交,否则返回提示。
## 兼容范围
- 仅改变 `lowPriceFlag === 1` 的最低价格校验策略。
- 普通订单原有输入校验、价格审批和提交规则保持不变。
- 客户档案仅导入客户信息的逻辑保持不变。
- 不修改接口、不新增依赖、不调整选品和商品行布局。
## 测试设计
1. 纯函数测试:一项满足、一项不满足时整单有效;全部不满足或空商品时整单无效。
2. 目录集成测试:低价单和普通订单都保留未开启校验的单品、全部 SKU 和混合套餐。
3. 页面静态契约:选品、改单价、失焦和总价重算不调用最低价格校验;提交入口调用整单校验。
4. 页面动态测试:交互过程不提示、不设置错误态;混合商品提交通过;全部不满足时才返回提示。
5. 回归测试:创建订单、工单迁移、订单生命周期和静态依赖闭包全部通过。
## 非目标
- 不改变单个商品“严格低于最低价”的比较方式。
- 不改变正常订单的最低价和总部审批流程。
- 不改变低价单提示文案。
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!