Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0fc4cfda
authored
Aug 25, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat bug修复
1 parent
d4937187
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
520 additions
and
55 deletions
docs/generated/PROJECT-SUMMARY.md
docs/generated/domains/tabWorkOrder.md
docs/generated/knowledge-graph.json
tabWorkOrder/pages/createOrder/createOrder.js
tabWorkOrder/pages/createOrder/services/goodsChooseEcho.helpers.js
tabWorkOrder/pages/createOrder/tests/goodsChooseEcho.helpers.test.mjs
tabWorkOrder/pages/createOrder/tests/goodsPriceEcho.integration.test.mjs
tests/work-order-migration/shims/create-order-context-loader.mjs
tests/work-order-migration/shims/mock-api.mjs
tests/work-order-migration/shims/mock-util.mjs
docs/generated/PROJECT-SUMMARY.md
View file @
0fc4cfd
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
## 规模
## 规模
-
节点:99
11
-
节点:99
32
-
关系:227
80
-
关系:227
96
-
未解析:15
1
-
未解析:15
2
## 节点类型
## 节点类型
...
@@ -18,10 +18,10 @@
...
@@ -18,10 +18,10 @@
| domain | 15 |
| domain | 15 |
| endpoint | 399 |
| endpoint | 399 |
| globalState | 39 |
| globalState | 39 |
| method | 71
14
|
| method | 71
31
|
| module | 86
2
|
| module | 86
5
|
| page | 165 |
| page | 165 |
| test | 20
2
|
| test | 20
3
|
## 关系类型
## 关系类型
...
@@ -31,14 +31,14 @@
...
@@ -31,14 +31,14 @@
| calls | 2511 |
| calls | 2511 |
| callsApi | 775 |
| callsApi | 775 |
| callsEndpoint | 491 |
| callsEndpoint | 491 |
| contains | 186
6
|
| contains | 186
7
|
| coveredBy | 414 |
| coveredBy | 414 |
| declares | 71
24
|
| declares | 71
41
|
| definesApi | 715 |
| definesApi | 715 |
| documentedBy | 530 |
| documentedBy | 530 |
| imports | 1984 |
| imports | 1984 |
| navigatesTo | 240 |
| navigatesTo | 240 |
| readsState | 272
8
|
| readsState | 272
6
|
| usesComponent | 866 |
| usesComponent | 866 |
| writesState | 73 |
| writesState | 73 |
...
...
docs/generated/domains/tabWorkOrder.md
View file @
0fc4cfd
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
| component | 46 |
| component | 46 |
| apiOperation | 106 |
| apiOperation | 106 |
| globalState | 2 |
| globalState | 2 |
| test | 2
4
|
| test | 2
5
|
| document | 4 |
| document | 4 |
## 可定位实体
## 可定位实体
...
@@ -225,6 +225,7 @@
...
@@ -225,6 +225,7 @@
| test |
`tabWorkOrder/pages/createOrder/tests/customerDailyFields.ui.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/customerDailyFields.ui.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/customerProfileEffects.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/customerProfileEffects.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/goodsChooseEcho.helpers.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/goodsChooseEcho.helpers.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/goodsPriceEcho.integration.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/goodsPriceEdit.helpers.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/goodsPriceEdit.helpers.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/merchantStaffSelection.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/merchantStaffSelection.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/minPriceApproval.test.mjs`
|
| test |
`tabWorkOrder/pages/createOrder/tests/minPriceApproval.test.mjs`
|
...
...
docs/generated/knowledge-graph.json
View file @
0fc4cfd
This file is too large to display.
tabWorkOrder/pages/createOrder/createOrder.js
View file @
0fc4cfd
...
@@ -72,6 +72,7 @@ import { preprocessSelectOrderCatalogItem } from './services/selectOrderCatalogP
...
@@ -72,6 +72,7 @@ import { preprocessSelectOrderCatalogItem } from './services/selectOrderCatalogP
import
{
import
{
mergeSubOrderListForEcho
,
mergeSubOrderListForEcho
,
findCatalogSingleGoodsItem
,
findCatalogSingleGoodsItem
,
normalizeOrderMoney
,
resolveSubOrderUnitPrice
,
resolveSubOrderUnitPrice
,
applySubOrderDiscountEcho
applySubOrderDiscountEcho
}
from
'./services/goodsChooseEcho.helpers.js'
}
from
'./services/goodsChooseEcho.helpers.js'
...
@@ -2243,13 +2244,11 @@ Page({
...
@@ -2243,13 +2244,11 @@ Page({
e
.
price
=
unitPrice
e
.
price
=
unitPrice
e
.
sellPrice
=
unitPrice
e
.
sellPrice
=
unitPrice
}
}
}
else
if
(
!
e
.
price
)
{
}
else
{
const
unitPrice
=
resolveSubOrderUnitPrice
(
const
unitPrice
=
resolveSubOrderUnitPrice
(
e
,
false
)
e
,
if
(
unitPrice
!=
null
&&
unitPrice
!==
''
)
{
false
,
e
.
price
=
unitPrice
(
n
,
d
)
=>
wx
.
$util
.
decimal
(
n
,
d
)
}
)
e
.
price
=
unitPrice
}
}
e
.
sellPrice
=
e
.
price
e
.
sellPrice
=
e
.
price
e
.
goodsId
=
e
.
merchantGoodsId
e
.
goodsId
=
e
.
merchantGoodsId
...
@@ -2367,28 +2366,26 @@ Page({
...
@@ -2367,28 +2366,26 @@ Page({
if
(
orderObj
.
resetOrder
)
g
.
resetOrder
=
true
if
(
orderObj
.
resetOrder
)
g
.
resetOrder
=
true
if
(
orderObj
.
resetOrder
)
{
if
(
orderObj
.
resetOrder
)
{
// 再次编辑优先使用订单回显单价,避免被 originalPrice(目录原价)覆盖
// 再次编辑优先使用订单回显单价,避免被 originalPrice(目录原价)覆盖
const
count
=
Number
(
g
.
number
)
||
1
const
unitPrice
=
resolveSubOrderUnitPrice
(
g
,
true
)
const
unitPrice
=
g
.
sellPrice
||
g
.
sellPrice
===
0
?
g
.
sellPrice
:
g
.
totalPrice
||
g
.
totalPrice
===
0
?
Number
(
g
.
totalPrice
)
/
count
:
undefined
if
(
unitPrice
!=
null
&&
unitPrice
!==
''
)
{
if
(
unitPrice
!=
null
&&
unitPrice
!==
''
)
{
g
.
price
=
unitPrice
g
.
price
=
unitPrice
g
.
sellPrice
=
unitPrice
g
.
sellPrice
=
unitPrice
}
}
}
else
{
}
else
{
const
priceFromTotal
=
const
priceFromTotal
=
resolveSubOrderUnitPrice
(
g
.
totalPrice
||
g
.
totalPrice
===
0
{
?
Number
(
g
.
totalPrice
)
/
Number
(
g
.
number
)
totalPrice
:
g
.
totalPrice
,
:
undefined
number
:
g
.
number
},
false
)
const
echoedSellPrice
=
normalizeOrderMoney
(
g
.
sellPrice
)
g
.
sellPrice
=
g
.
sellPrice
=
g
.
sellPrice
||
g
.
sellPrice
===
0
echoedSellPrice
!==
undefined
?
g
.
s
ellPrice
?
echoedS
ellPrice
:
priceFromTotal
!==
undefined
:
priceFromTotal
!==
undefined
?
priceFromTotal
?
priceFromTotal
:
g
.
upgradePrice
:
normalizeOrderMoney
(
g
.
upgradePrice
)
g
.
price
=
g
.
price
=
priceFromTotal
!==
undefined
?
priceFromTotal
:
g
.
sellPrice
priceFromTotal
!==
undefined
?
priceFromTotal
:
g
.
sellPrice
}
}
...
@@ -2426,16 +2423,23 @@ Page({
...
@@ -2426,16 +2423,23 @@ Page({
})
})
e
.
goodsList
=
e
.
packageGoodsOrderList
e
.
goodsList
=
e
.
packageGoodsOrderList
e
.
upgradePrice
=
e
.
goodsList
.
reduce
((
prev
,
cur
)
=>
{
e
.
upgradePrice
=
e
.
goodsList
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
cur
.
sellPrice
return
NP
.
plus
(
prev
,
Number
(
cur
.
sellPrice
||
0
))
},
0
)
},
0
)
e
.
count
=
e
.
goodsList
.
length
?
e
.
goodsList
[
0
].
number
:
1
e
.
count
=
e
.
goodsList
.
length
?
e
.
goodsList
[
0
].
number
:
1
e
.
price
=
e
.
goodsList
.
reduce
((
prev
,
cur
)
=>
{
e
.
price
=
e
.
goodsList
.
reduce
((
prev
,
cur
)
=>
{
return
(
const
unitPrice
=
orderObj
.
resetOrder
prev
+
?
normalizeOrderMoney
(
cur
.
price
)
(
orderObj
.
resetOrder
:
resolveSubOrderUnitPrice
(
?
Number
(
cur
.
price
)
{
:
Number
(
cur
.
totalPrice
)
/
Number
(
cur
.
number
))
totalPrice
:
cur
.
totalPrice
,
number
:
cur
.
number
},
false
)
return
NP
.
plus
(
prev
,
unitPrice
!==
undefined
?
unitPrice
:
0
)
)
},
0
)
},
0
)
...
@@ -2469,17 +2473,18 @@ Page({
...
@@ -2469,17 +2473,18 @@ Page({
// 修复取值字段名字错误问题
// 修复取值字段名字错误问题
if
(
orderObj
.
resetOrder
)
{
if
(
orderObj
.
resetOrder
)
{
// 再次编辑优先使用订单回显单价,避免被 originalPrice(目录原价)覆盖
// 再次编辑优先使用订单回显单价,避免被 originalPrice(目录原价)覆盖
const
count
=
Number
(
e
.
number
)
||
1
const
unitPrice
=
resolveSubOrderUnitPrice
(
e
,
true
)
const
unitPrice
=
if
(
unitPrice
!=
null
&&
unitPrice
!==
''
)
{
e
.
sellPrice
??
(
e
.
totalPrice
?
Number
(
e
.
totalPrice
)
/
count
:
undefined
)
e
.
price
=
unitPrice
e
.
sellPrice
=
unitPrice
}
}
else
{
const
unitPrice
=
resolveSubOrderUnitPrice
(
e
,
false
)
if
(
unitPrice
!=
null
&&
unitPrice
!==
''
)
{
if
(
unitPrice
!=
null
&&
unitPrice
!==
''
)
{
e
.
price
=
unitPrice
e
.
price
=
unitPrice
//最低价
e
.
sellPrice
=
unitPrice
e
.
sellPrice
=
unitPrice
}
}
}
else
if
(
!
e
.
price
)
{
e
.
price
=
wx
.
$util
.
decimal
(
Number
(
e
.
totalPrice
/
e
.
number
),
2
)
//最低价
e
.
sellPrice
=
e
.
price
}
}
e
.
goodsId
=
e
.
merchantGoodsId
e
.
goodsId
=
e
.
merchantGoodsId
if
(
!
e
.
minSellPrice
)
e
.
minSellPrice
=
e
.
upgradeShopMinPrice
if
(
!
e
.
minSellPrice
)
e
.
minSellPrice
=
e
.
upgradeShopMinPrice
...
...
tabWorkOrder/pages/createOrder/services/goodsChooseEcho.helpers.js
View file @
0fc4cfd
...
@@ -6,6 +6,31 @@
...
@@ -6,6 +6,31 @@
import
NP
from
'number-precision'
import
NP
from
'number-precision'
/**
/**
* 将订单金额归一到分,避免接口回显和总价换算的浮点长尾进入输入框。
* 空值表示缺少价格;显式 0 保持为 0,交由价格校验处理。
* @param {number|string|null|undefined} value
* @returns {number|undefined}
*/
export
function
normalizeOrderMoney
(
value
)
{
if
(
value
===
null
||
value
===
undefined
||
(
typeof
value
===
'string'
&&
value
.
trim
()
===
''
)
)
{
return
undefined
}
const
amount
=
Number
(
value
)
if
(
!
Number
.
isFinite
(
amount
))
return
undefined
return
Math
.
round
(
Number
(
`
${
amount
}
e2`
))
/
100
}
function
resolveUnitPriceFromTotal
(
line
)
{
if
(
line
.
totalPrice
==
null
||
line
.
totalPrice
===
''
)
return
undefined
const
count
=
Number
(
line
.
number
)
||
1
return
normalizeOrderMoney
(
Number
(
line
.
totalPrice
)
/
count
)
}
/**
* 合并子单与套餐行(套餐在 packageGoodsList 时过滤 subOrder 内 packageName 行)
* 合并子单与套餐行(套餐在 packageGoodsList 时过滤 subOrder 内 packageName 行)
* @param {Array<object>|undefined} subOrderList
* @param {Array<object>|undefined} subOrderList
* @param {Array<object>|undefined} packageGoodsList
* @param {Array<object>|undefined} packageGoodsList
...
@@ -64,26 +89,20 @@ export function applySubOrderDiscountEcho(goods) {
...
@@ -64,26 +89,20 @@ export function applySubOrderDiscountEcho(goods) {
* 解析回显单价(再次编辑优先 sellPrice,否则 total/number)
* 解析回显单价(再次编辑优先 sellPrice,否则 total/number)
* @param {object} line subOrder 行
* @param {object} line subOrder 行
* @param {boolean} resetOrder 是否再次编辑
* @param {boolean} resetOrder 是否再次编辑
* @param {(n:number,d:number)=>number} [decimalFn] 可选 decimal 函数(页面 wx.$util.decimal)
* @returns {number|undefined}
* @returns {number|undefined}
*/
*/
export
function
resolveSubOrderUnitPrice
(
line
,
resetOrder
,
decimalFn
)
{
export
function
resolveSubOrderUnitPrice
(
line
,
resetOrder
)
{
const
count
=
Number
(
line
.
number
)
||
1
if
(
resetOrder
)
{
if
(
resetOrder
)
{
if
(
line
.
sellPrice
!=
null
&&
line
.
sellPrice
!==
''
)
{
if
(
line
.
sellPrice
!=
null
&&
line
.
sellPrice
!==
''
)
{
return
Number
(
line
.
sellPrice
)
return
normalizeOrderMoney
(
line
.
sellPrice
)
}
if
(
line
.
totalPrice
!=
null
&&
line
.
totalPrice
!==
''
)
{
return
Number
(
line
.
totalPrice
)
/
count
}
}
return
undefined
return
resolveUnitPriceFromTotal
(
line
)
}
}
if
(
line
.
price
!=
null
&&
line
.
price
!==
''
)
{
if
(
line
.
price
!=
null
&&
line
.
price
!==
''
)
{
return
Number
(
line
.
price
)
return
normalizeOrderMoney
(
line
.
price
)
}
}
if
(
line
.
totalPrice
!=
null
&&
line
.
number
)
{
if
(
line
.
totalPrice
!=
null
&&
line
.
number
)
{
const
raw
=
Number
(
line
.
totalPrice
)
/
Number
(
line
.
number
)
return
resolveUnitPriceFromTotal
(
line
)
return
decimalFn
?
decimalFn
(
raw
,
2
)
:
raw
}
}
return
undefined
return
undefined
}
}
...
...
tabWorkOrder/pages/createOrder/tests/goodsChooseEcho.helpers.test.mjs
View file @
0fc4cfd
...
@@ -88,4 +88,53 @@ describe('goodsChooseEcho.helpers', () => {
...
@@ -88,4 +88,53 @@ describe('goodsChooseEcho.helpers', () => {
)
)
assert.equal(isMultiSpecSubOrderLine({ specificationData: 'A;~;B' }), true)
assert.equal(isMultiSpecSubOrderLine({ specificationData: 'A;~;B' }), true)
})
})
it('IT-WO-ECHO-010: normalizes echoed unit-price float tails to cents', () => {
assert.equal(
resolveSubOrderUnitPrice(
{ price: 1999.9900000000002, totalPrice: 9999.95, number: 5 },
false
),
1999.99
)
assert.equal(
resolveSubOrderUnitPrice(
{ sellPrice: 1999.9900000000002, totalPrice: 9999.95, number: 5 },
true
),
1999.99
)
})
it('IT-WO-ECHO-011: normalizes total divided by quantity in both echo modes', () => {
assert.equal(
resolveSubOrderUnitPrice({ totalPrice: 9999.95, number: 5 }, false),
1999.99
)
assert.equal(
resolveSubOrderUnitPrice({ totalPrice: 9999.95, number: 5 }, true),
1999.99
)
})
it('IT-WO-ECHO-012: keeps explicit zero as the preferred echoed unit price', () => {
assert.equal(
resolveSubOrderUnitPrice({ price: 0, totalPrice: 100, number: 2 }, false),
0
)
assert.equal(
resolveSubOrderUnitPrice(
{ sellPrice: 0, totalPrice: 100, number: 2 },
true
),
0
)
})
it('IT-WO-ECHO-013: rejects empty and non-finite echoed prices', () => {
assert.equal(resolveSubOrderUnitPrice({ price: '' }, false), undefined)
assert.equal(resolveSubOrderUnitPrice({ sellPrice: null }, true), undefined)
assert.equal(resolveSubOrderUnitPrice({ price: 'invalid' }, false), undefined)
assert.equal(resolveSubOrderUnitPrice({ sellPrice: Infinity }, true), undefined)
})
})
})
tabWorkOrder/pages/createOrder/tests/goodsPriceEcho.integration.test.mjs
0 → 100644
View file @
0fc4cfd
import assert from 'node:assert/strict'
import { register } from 'node:module'
import test from 'node:test'
register(
'../../../../tests/work-order-migration/shims/create-order-context-loader.mjs',
import.meta.url
)
let pageConfig
globalThis.getApp = () => ({ globalData: {} })
globalThis.Page = config => {
pageConfig = config
}
globalThis.require = specifier => {
if (specifier === '~/utils/timeFormat/time-utils.js') {
return { getTodayDateStr: () => '2026-08-25' }
}
throw new Error(`Unexpected CommonJS dependency in page test: ${specifier}`)
}
globalThis.wx = {
getAccountInfoSync: () => ({
miniProgram: { appId: 'test-app-id', envVersion: 'develop' }
}),
getDeviceInfo: () => ({ platform: 'devtools' }),
getWindowInfo: () => ({ screenWidth: 375, windowWidth: 375 }),
getAppBaseInfo: () => ({ host: { env: '' }, SDKVersion: 'test' }),
getSystemInfoSync: () => ({ platform: 'devtools' }),
getStorageSync: () => '',
$util: {
decimal(value, fixed) {
const pow = Math.pow(10, fixed)
return Math.round(Number(value) * pow) / pow
},
getUserInfo: () => ({})
}
}
await import(`../createOrder.js?goods-price-echo=${Date.now()}`)
function createCatalog() {
return [
{
goodsFlag: 1,
goods: { merchantGoodsId: 'NORMAL-1', sellPrice: 2000 }
},
{
goodsFlag: 2,
multipleSpecificationsGoods: {
id: 'SPEC-1',
specificationGoodsMap: {
'A;~;B': [{ merchantGoodsId: 'SKU-1', sellPrice: 2000 }]
}
}
}
]
}
function createOrderObj({ resetOrder, unitPrice, totalPrice }) {
const directPrice = resetOrder ? undefined : unitPrice
const directSellPrice = resetOrder ? unitPrice : undefined
return {
lowPriceFlag: 1,
resetOrder,
subOrderList: [
{
merchantGoodsId: 'NORMAL-1',
number: 5,
totalPrice,
price: directPrice,
sellPrice: directSellPrice,
specificationData: ''
},
{
merchantGoodsId: 'SKU-1',
number: 5,
totalPrice,
price: directPrice,
sellPrice: directSellPrice,
specificationData: 'A;~;B'
}
],
packageGoodsList: [
{
packageCode: 'PACKAGE-1',
packageName: '精度测试套餐',
packageGoodsOrderList: [
{
merchantGoodsId: 'PACKAGE-GOODS-1',
number: 5,
totalPrice,
sellPrice: unitPrice
}
]
}
]
}
}
function createPage(orderObj) {
const catalog = createCatalog()
return {
...pageConfig,
data: {
...structuredClone(pageConfig.data),
orderObj,
goodsData: catalog,
copyGoodsData: catalog,
packageList: [],
positionTypeList: [],
marketingFlagMap: {},
activityIdMap: {}
},
setData(patch, callback) {
Object.assign(this.data, patch)
callback?.()
},
setGoodsTotal(goodsList) {
this.data.goodsList = goodsList
}
}
}
function readEchoedPrices(page) {
const ordinary = page.data.goodsList.find(item => item.goodsFlag === 1)
const multiSpec = page.data.goodsList.find(item => item.goodsFlag === 2)
const packageItem = page.data.goodsList.find(item => item.goodsFlag === 3)
return {
ordinary: ordinary.goods.sellPrice,
multiSpec: multiSpec.multipleSpecificationsGoods.goods.sellPrice,
packageChild: packageItem.packageGoods.goodsList[0].sellPrice,
packagePrice: packageItem.packageGoods.price,
packageTotalPrice: packageItem.totalPrice
}
}
test('IT-WO-PRICE-ECHO-001: pending-order direct prices are normalized for every goods type', () => {
const page = createPage(
createOrderObj({
resetOrder: false,
unitPrice: 1999.9900000000002,
totalPrice: 9999.95
})
)
pageConfig.getChooseList.call(page)
assert.deepEqual(readEchoedPrices(page), {
ordinary: 1999.99,
multiSpec: 1999.99,
packageChild: 1999.99,
packagePrice: 1999.99,
packageTotalPrice: 1999.99
})
})
test('IT-WO-PRICE-ECHO-002: edit-order total-price fallback is normalized for every goods type', () => {
const page = createPage(
createOrderObj({
resetOrder: true,
unitPrice: undefined,
totalPrice: 9999.95
})
)
pageConfig.getChooseList.call(page)
assert.deepEqual(readEchoedPrices(page), {
ordinary: 1999.99,
multiSpec: 1999.99,
packageChild: 1999.99,
packagePrice: 1999.99,
packageTotalPrice: 1999.99
})
})
test('IT-WO-PRICE-ECHO-003: explicit zero remains zero across goods types', () => {
for (const resetOrder of [false, true]) {
const page = createPage(
createOrderObj({ resetOrder, unitPrice: 0, totalPrice: 0 })
)
pageConfig.getChooseList.call(page)
assert.deepEqual(
readEchoedPrices(page),
{
ordinary: 0,
multiSpec: 0,
packageChild: 0,
packagePrice: 0,
packageTotalPrice: 0
},
`resetOrder=${resetOrder}`
)
}
})
test('IT-WO-PRICE-ECHO-004: exact cent prices remain unchanged across goods types', () => {
for (const resetOrder of [false, true]) {
const page = createPage(
createOrderObj({ resetOrder, unitPrice: 88.5, totalPrice: 442.5 })
)
pageConfig.getChooseList.call(page)
assert.deepEqual(
readEchoedPrices(page),
{
ordinary: 88.5,
multiSpec: 88.5,
packageChild: 88.5,
packagePrice: 88.5,
packageTotalPrice: 88.5
},
`resetOrder=${resetOrder}`
)
}
})
test('IT-WO-PRICE-ECHO-005: missing package sellPrice falls back to normalized total price', () => {
for (const missingSellPrice of [null, '']) {
const page = createPage(
createOrderObj({
resetOrder: false,
unitPrice: 1999.9900000000002,
totalPrice: 9999.95
})
)
page.data.orderObj.packageGoodsList[0].packageGoodsOrderList[0].sellPrice =
missingSellPrice
pageConfig.getChooseList.call(page)
const echoed = readEchoedPrices(page)
assert.equal(
echoed.packageChild,
1999.99,
`sellPrice=${JSON.stringify(missingSellPrice)}`
)
assert.equal(echoed.packagePrice, 1999.99)
assert.equal(echoed.packageTotalPrice, 1999.99)
}
})
tests/work-order-migration/shims/create-order-context-loader.mjs
0 → 100644
View file @
0fc4cfd
import { existsSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
const shimDir = path.dirname(fileURLToPath(import.meta.url))
const projectRoot = path.resolve(shimDir, '../../..')
const mockApiUrl = pathToFileURL(path.join(shimDir, 'mock-api.mjs')).href
const mockUtilUrl = pathToFileURL(path.join(shimDir, 'mock-util.mjs')).href
function resolveExistingModule(candidate) {
const candidates = [candidate, `${candidate}.js`, path.join(candidate, 'index.js')]
return candidates.find(item => existsSync(item))
}
export async function resolve(specifier, context, nextResolve) {
if (specifier === '~/utils/util' || specifier === '~/utils/util.js') {
return { shortCircuit: true, url: mockUtilUrl }
}
if (
specifier === '~/api/api' ||
specifier === '~/api/api.js' ||
(specifier === '../../api' && context.parentURL?.includes('/createOrder/'))
) {
return { shortCircuit: true, url: mockApiUrl }
}
if (specifier.startsWith('./') || specifier.startsWith('../')) {
const parentPath = fileURLToPath(context.parentURL)
const candidate = path.resolve(path.dirname(parentPath), specifier)
const tabWorkOrderApi = path.join(projectRoot, 'tabWorkOrder', 'api')
const projectApi = path.join(projectRoot, 'api', 'api')
if (
candidate === tabWorkOrderApi ||
candidate === `${tabWorkOrderApi}.js` ||
candidate === projectApi ||
candidate === `${projectApi}.js`
) {
return { shortCircuit: true, url: mockApiUrl }
}
}
if (specifier.startsWith('~/')) {
const mapped = resolveExistingModule(path.join(projectRoot, specifier.slice(2)))
if (mapped) {
return { shortCircuit: true, url: pathToFileURL(mapped).href }
}
}
if (
(specifier.startsWith('./') || specifier.startsWith('../')) &&
!/\.(?:m?js|json|node)$/.test(specifier)
) {
const parentPath = fileURLToPath(context.parentURL)
const mapped = resolveExistingModule(
path.resolve(path.dirname(parentPath), specifier)
)
if (mapped) {
return { shortCircuit: true, url: pathToFileURL(mapped).href }
}
}
return nextResolve(specifier, context)
}
tests/work-order-migration/shims/mock-api.mjs
0 → 100644
View file @
0fc4cfd
function configuredResponse(method, payload, fallback) {
const handler = globalThis.__WORK_ORDER_MOCK_API__?.[method]
return Promise.resolve(handler ? handler(payload) : fallback)
}
export default {
checkVinValidate() {
return Promise.resolve({
code: 0,
data: {
message: '校验成功',
data: { valid: true }
}
})
},
getSceneMerchantRefStoreList(data) {
return configuredResponse('getSceneMerchantRefStoreList', data, {
code: 0,
data: []
})
},
getMerchantRecordingSettings(data) {
return configuredResponse('getMerchantRecordingSettings', data, {
code: 0,
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: []
})
},
getPackageGoodsDetail(data) {
return configuredResponse('getPackageGoodsDetail', data, {
code: 0,
data: {}
})
},
getEmployeeList(data) {
return configuredResponse('getEmployeeList', data, {
code: 0,
data: []
})
},
getWorkPackageGoodsList(data) {
return configuredResponse('getWorkPackageGoodsList', data, {
code: 0,
data: { list: [], total: 0 }
})
},
getLastUserOrderInfo(data) {
return configuredResponse('getLastUserOrderInfo', data, {
code: 0,
data: null
})
},
createWithPay(data) {
return configuredResponse('createWithPay', data, {
code: 0,
data: {}
})
},
createPrerecordedOrder(data) {
return configuredResponse('createPrerecordedOrder', data, {
code: 0,
data: {}
})
}
}
tests/work-order-migration/shims/mock-util.mjs
0 → 100644
View file @
0fc4cfd
export default {}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment