Commit 80a5e4a5 by 张立顺

docs: expand customer request cleanup contract

1 parent 68155f6e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
> **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. > **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:** Remove `customer.updatedDate`, `customer.goodsOrder`, and `customer.actualDeliveryDate` from every create-order API request without mutating page state or removing unrelated customer fields. **Goal:** Remove the complete requested set of customer audit, query, scene, WeChat, merchant, staff, order-filter, and delivery metadata from every create-order API request without mutating page state or removing unrelated customer fields.
**Architecture:** Extend the existing customer-property denylist used by the pure `buildSubmitPayload` serialization helper. Verify behavior at that boundary so every submission route receives the same cleanup. **Architecture:** Extend the existing customer-property denylist used by the pure `buildSubmitPayload` serialization helper. Verify behavior at that boundary so every submission route receives the same cleanup.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## Global Constraints ## Global Constraints
- Remove only `customer.updatedDate`, `customer.goodsOrder`, and `customer.actualDeliveryDate` in addition to the customer properties already cleaned. - Remove the explicitly requested customer metadata fields while preserving the existing cleanup for `buyTime`, `createdDate`, and `actualDeliveryDate`.
- Do not modify the page's `orderObj` or customer archive echo data. - Do not modify the page's `orderObj` or customer archive echo data.
- Preserve unrelated customer fields. - Preserve unrelated customer fields.
- Apply the cleanup to normal payment, prerecorded, correction, and supplement submissions through their shared payload builder. - Apply the cleanup to normal payment, prerecorded, correction, and supplement submissions through their shared payload builder.
...@@ -21,31 +21,38 @@ ...@@ -21,31 +21,38 @@
**Files:** **Files:**
- Modify: `tabWorkOrder/pages/createOrder/services/submitPayload.helpers.js` - Modify: `tabWorkOrder/pages/createOrder/services/submitPayload.helpers.js`
- Test: `tabWorkOrder/pages/createOrder/tests/submitPayload.helpers.test.mjs` - Test: `tabWorkOrder/pages/createOrder/tests/lowPriceSubmitFlow.integration.test.mjs`
**Interfaces:** **Interfaces:**
- Consumes: `buildSubmitPayload(orderObj, context)` and `SUBMIT_CUSTOMER_PROPERTIES_TO_DELETE` from `submitPayload.helpers.js`. - Consumes: `buildSubmitPayload(orderObj, context)` and `SUBMIT_CUSTOMER_PROPERTIES_TO_DELETE` from `submitPayload.helpers.js`.
- Produces: A cloned request object that omits `customer.updatedDate`, `customer.goodsOrder`, and `customer.actualDeliveryDate` while preserving other customer properties. - Produces: A cloned request object that omits every customer property in `SUBMIT_CUSTOMER_PROPERTIES_TO_DELETE` while preserving other customer properties.
- [ ] **Step 1: Write the failing regression test** - [ ] **Step 1: Write the failing API-boundary regression test**
Extend `baseOrder.customer` and `IT-WO-SUB-005` as follows: Add a low-price submit-flow test that captures the real `createWithPay` argument with the complete removal contract:
```js ```js
customer: { const removedCustomerFields = [
buyTime: 'x', 'buyTime', 'createdDate', 'createdBy', 'updatedBy', 'updatedDate',
createdDate: 'y', 'deletedFlag', 'baseSceneCode', 'sceneType', 'businessType', 'qwGroupId',
updatedDate: 'z', 'qwGroupName', 'wxId', 'wxName', 'deliveryDate', 'inviteDate', 'keyword',
goodsOrder: { orderCode: 'GO1' }, 'buyTimeStr', 'totalCustomer', 'merchantIds', 'yqMerchantIds',
actualDeliveryDate: '2026-08-17', 'sellerUserIds', 'goodsOrder', 'sceneTypes', 'customerPhoneList',
customerName: 'retained customer', 'staffUuid', 'merchantId', 'orderDate', 'orderCodes', 'actualDeliveryDate'
plateNumber: 'P' ]
const customer = Object.fromEntries(
removedCustomerFields.map(field => [field, `remove-${field}`])
)
globalThis.__WORK_ORDER_MOCK_API__.createWithPay = payload => {
submittedPayload = payload
return { code: 0, data: { orderCode: 'LP-CUSTOMER-CLEANUP' } }
} }
page.data.orderObj.customer = { ...customer, customerName: 'retained customer' }
assert.equal(out.customer.updatedDate, undefined) await new SubmitContext(page).executeAfterApproval({ save: false })
assert.equal(out.customer.goodsOrder, undefined) removedCustomerFields.forEach(field => {
assert.equal(out.customer.actualDeliveryDate, undefined) assert.equal(Object.hasOwn(submittedPayload.customer, field), false, field)
assert.equal(out.customer.customerName, 'retained customer') })
assert.equal(submittedPayload.customer.customerName, 'retained customer')
``` ```
- [ ] **Step 2: Run the focused test and verify RED** - [ ] **Step 2: Run the focused test and verify RED**
...@@ -53,10 +60,10 @@ assert.equal(out.customer.customerName, 'retained customer') ...@@ -53,10 +60,10 @@ assert.equal(out.customer.customerName, 'retained customer')
Run: Run:
```powershell ```powershell
node --test --test-name-pattern "strips audit fields on build" tabWorkOrder/pages/createOrder/tests/submitPayload.helpers.test.mjs node --test --test-name-pattern "strips customer metadata from the actual order API request" tabWorkOrder/pages/createOrder/tests/lowPriceSubmitFlow.integration.test.mjs
``` ```
Expected: `IT-WO-SUB-005` fails because `customer.actualDeliveryDate` is still present. Expected: the API-boundary test fails first for `createdBy`, which is still present in the captured request argument.
- [ ] **Step 3: Implement the minimal cleanup** - [ ] **Step 3: Implement the minimal cleanup**
...@@ -66,8 +73,32 @@ Change the customer denylist to: ...@@ -66,8 +73,32 @@ Change the customer denylist to:
export const SUBMIT_CUSTOMER_PROPERTIES_TO_DELETE = [ export const SUBMIT_CUSTOMER_PROPERTIES_TO_DELETE = [
'buyTime', 'buyTime',
'createdDate', 'createdDate',
'createdBy',
'updatedBy',
'updatedDate', 'updatedDate',
'deletedFlag',
'baseSceneCode',
'sceneType',
'businessType',
'qwGroupId',
'qwGroupName',
'wxId',
'wxName',
'deliveryDate',
'inviteDate',
'keyword',
'buyTimeStr',
'totalCustomer',
'merchantIds',
'yqMerchantIds',
'sellerUserIds',
'goodsOrder', 'goodsOrder',
'sceneTypes',
'customerPhoneList',
'staffUuid',
'merchantId',
'orderDate',
'orderCodes',
'actualDeliveryDate' 'actualDeliveryDate'
] ]
``` ```
...@@ -91,6 +122,6 @@ Expected: all non-live tests pass, live tests remain explicitly skipped, closure ...@@ -91,6 +122,6 @@ Expected: all non-live tests pass, live tests remain explicitly skipped, closure
- [ ] **Step 6: Commit only this task's files** - [ ] **Step 6: Commit only this task's files**
```powershell ```powershell
git add -- tabWorkOrder/pages/createOrder/services/submitPayload.helpers.js tabWorkOrder/pages/createOrder/tests/submitPayload.helpers.test.mjs docs/superpowers/plans/2026-08-17-remove-customer-submit-fields.md git add -- tabWorkOrder/pages/createOrder/services/submitPayload.helpers.js tabWorkOrder/pages/createOrder/tests/lowPriceSubmitFlow.integration.test.mjs docs/superpowers/plans/2026-08-17-remove-customer-submit-fields.md
git commit -m "fix: remove customer order metadata from submit payload" git commit -m "fix: strip customer metadata from order requests"
``` ```
...@@ -2,17 +2,27 @@ ...@@ -2,17 +2,27 @@
## Goal ## Goal
The create-order page must omit `customer.updatedDate`, `customer.goodsOrder`, and `customer.actualDeliveryDate` from every order submission request while leaving the page's customer archive data unchanged. The create-order page must omit customer-only audit, query, scene, WeChat, merchant, staff, order-filter, and delivery metadata from every order submission request while leaving the page's customer archive data unchanged.
## Design ## Design
Add `updatedDate`, `goodsOrder`, and `actualDeliveryDate` to the existing `SUBMIT_CUSTOMER_PROPERTIES_TO_DELETE` list in `submitPayload.helpers.js`. `buildSubmitPayload` already deep-clones `orderObj` and removes the listed customer properties at the final request serialization boundary, so the page state and customer profile echo remain untouched. Keep all removal rules in the existing `SUBMIT_CUSTOMER_PROPERTIES_TO_DELETE` list in `submitPayload.helpers.js`. In addition to the previously removed fields, strip these explicitly requested properties:
```text
createdBy, updatedBy, updatedDate, deletedFlag, baseSceneCode, sceneType,
businessType, qwGroupId, qwGroupName, wxId, wxName, deliveryDate,
inviteDate, keyword, buyTimeStr, totalCustomer, merchantIds, yqMerchantIds,
sellerUserIds, goodsOrder, sceneTypes, customerPhoneList, staffUuid,
merchantId, orderDate, orderCodes
```
`buildSubmitPayload` already deep-clones `orderObj` and removes the listed customer properties at the final request serialization boundary, so the page state and customer profile echo remain untouched. Existing cleanup for `buyTime`, `createdDate`, and `actualDeliveryDate` remains in place.
This applies consistently to normal payment, prerecorded, correction, and supplement submissions because all of them use the same payload builder. Root-level `updatedDate` continues to be removed by the existing root cleanup rule. This applies consistently to normal payment, prerecorded, correction, and supplement submissions because all of them use the same payload builder. Root-level `updatedDate` continues to be removed by the existing root cleanup rule.
## Verification ## Verification
Extend the submit-payload unit test fixture with `customer.updatedDate`, `customer.goodsOrder`, and `customer.actualDeliveryDate`, then assert that the generated request omits all three while preserving an unrelated customer field. Run the focused unit test, the create-order test suite, and the full work-order verification suite. Add an integration test that submits through `SubmitContext.executeAfterApproval`, captures the object passed to `createWithPay`, supplies every customer property in the complete removal list, asserts each property is absent from the actual API argument, and verifies an unrelated customer field remains. Run the focused integration test, the create-order test suite, and the full work-order verification suite.
## Out of scope ## Out of scope
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!