Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
regional-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d3eb2eee
authored
Aug 20, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat bug修复
1 parent
433f6635
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
1054 additions
and
537 deletions
app.js
components/orderPromptPop/orderMerchantContext.helpers.js
docs/order-creation/README.md
docs/order-lifecycle/test-acceptance.md
pages/tab/workspace/workspace.js
tabWorkOrder/pages/confirmOrder/confirmOrder.wxml
tabWorkOrder/pages/confirmOrder/confirmOrder.wxss
tabWorkOrder/pages/createOrder/components/merchant-staff-picker/merchant-staff-picker.js
tabWorkOrder/pages/createOrder/createOrder.js
tabWorkOrder/pages/createOrder/createOrder.wxml
tabWorkOrder/pages/createOrder/routeStrategy.js
tabWorkOrder/pages/createOrder/services/lowPriceOrderContext.helpers.js
tabWorkOrder/pages/createOrder/services/minPriceApproval.js
tabWorkOrder/pages/createOrder/submitStrategy.js
tabWorkOrder/pages/createOrder/tests/authoritativeOrderDetail.integration.test.mjs
tabWorkOrder/pages/createOrder/tests/customerProfileOnlyTemplate.test.mjs
tabWorkOrder/pages/createOrder/tests/defaultSceneInitialization.integration.test.mjs
tabWorkOrder/pages/createOrder/tests/lowPriceCatalogFilter.integration.test.mjs
tabWorkOrder/pages/createOrder/tests/lowPriceSubmitFlow.integration.test.mjs
tabWorkOrder/pages/createOrder/tests/merchantStaffPicker.component.test.mjs
tabWorkOrder/pages/createOrder/tests/minPriceApproval.test.mjs
tabWorkOrder/pages/createOrder/tests/orderRequiredSettings.integration.test.mjs
tabWorkOrder/pages/createOrder/tests/pendingOrderEditEcho.integration.test.mjs
tests/work-order-migration/confirm-order-wechat-action.test.mjs
tests/work-order-migration/fixed-user-info-mock.test.mjs
tests/work-order-migration/low-price-order-flow.test.mjs
tests/work-order-migration/real-login-user-info.test.mjs
tests/work-order-migration/shims/mock-api.mjs
tests/work-order-migration/shims/real-login-dependencies.mjs
tests/work-order-migration/shims/real-login-loader.mjs
utils/fixedUserInfoMock.js
utils/util.js
app.js
View file @
d3eb2ee
...
@@ -12,7 +12,6 @@ import router from './router/index.js'
...
@@ -12,7 +12,6 @@ import router from './router/index.js'
// 判断小程序是否需要更新
// 判断小程序是否需要更新
import
getUpdateManager
from
'./utils/lib/wxUpdateManager'
import
getUpdateManager
from
'./utils/lib/wxUpdateManager'
import
util
from
'./utils/util.js'
import
util
from
'./utils/util.js'
import
{
installFixedUserInfoMock
}
from
'./utils/fixedUserInfoMock.js'
import
wxApi
from
'./utils/utils_wx'
import
wxApi
from
'./utils/utils_wx'
// 实例化对象存储
// 实例化对象存储
import
{
Storage
}
from
'~/utils/cache/storage'
import
{
Storage
}
from
'~/utils/cache/storage'
...
@@ -89,12 +88,7 @@ App({
...
@@ -89,12 +88,7 @@ App({
wx
.
$eventbus
=
eventbus
wx
.
$eventbus
=
eventbus
wx
.
$areaList
=
areaList
wx
.
$areaList
=
areaList
wx
.
$track
=
$Track
wx
.
$track
=
$Track
const
fixedUserInfo
=
installFixedUserInfoMock
({
let
userInfo
=
util
.
getStorageSync
(
'dj_boutique_user_info'
)
setLegacyUserInfo
:
userInfo
=>
util
.
setUserInfo
(
userInfo
),
setCurrentUserInfo
:
userInfo
=>
$Storage
.
set
(
'userInfo'
,
userInfo
)
})
let
userInfo
=
fixedUserInfo
||
util
.
getStorageSync
(
'dj_boutique_user_info'
)
// ,this.globalData, userInfo
// ,this.globalData, userInfo
userInfo
&&
this
.
gobalCheckYqdSuper
(
userInfo
)
userInfo
&&
this
.
gobalCheckYqdSuper
(
userInfo
)
wx
.
$versionConfig
=
new
Version
({
wx
.
$versionConfig
=
new
Version
({
...
...
components/orderPromptPop/orderMerchantContext.helpers.js
View file @
d3eb2ee
...
@@ -107,7 +107,7 @@ export function filterOrderMerchantOptions(options, keyword) {
...
@@ -107,7 +107,7 @@ export function filterOrderMerchantOptions(options, keyword) {
const
normalizedKeyword
=
String
(
keyword
||
''
).
trim
().
toLowerCase
()
const
normalizedKeyword
=
String
(
keyword
||
''
).
trim
().
toLowerCase
()
if
(
!
normalizedKeyword
)
return
[...(
options
||
[])]
if
(
!
normalizedKeyword
)
return
[...(
options
||
[])]
return
(
options
||
[]).
filter
(
item
=>
return
(
options
||
[]).
filter
(
item
=>
`
${
item
.
merchantName
||
''
}
${
item
.
yqMerchantName
||
''
}
`
`
${
item
.
merchantName
||
''
}
`
.
toLowerCase
()
.
toLowerCase
()
.
includes
(
normalizedKeyword
)
.
includes
(
normalizedKeyword
)
)
)
...
...
docs/order-creation/README.md
View file @
d3eb2ee
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
低价单上下文固定携带
`lowPriceFlag=1`
。选中的 4S 店写入
`merchantId`
,所属园区店写入
低价单上下文固定携带
`lowPriceFlag=1`
。选中的 4S 店写入
`merchantId`
,所属园区店写入
`yqMerchantId`
和下单字段
`sellerMerchantId`
;这些值会继续传入待补录查询、普通下单和
`yqMerchantId`
和下单字段
`sellerMerchantId`
;这些值会继续传入待补录查询、普通下单和
补录下单,不再从
临时固定
用户的默认门店推导。
补录下单,不再从
登录
用户的默认门店推导。
低价单的普通商品、多规格 SKU 和套餐子商品中,只要任一项开启最低价
低价单的普通商品、多规格 SKU 和套餐子商品中,只要任一项开启最低价
(
`validMinSellPrice='Y'`
),且录入基础单价严格小于
`minSellPrice`
,整单即可继续。选品后商品行显示
(
`validMinSellPrice='Y'`
),且录入基础单价严格小于
`minSellPrice`
,整单即可继续。选品后商品行显示
...
@@ -95,17 +95,14 @@
...
@@ -95,17 +95,14 @@
未迁移:战败单、签名、客户画像、客户资料修改、发票、施工单新建与独立施工详情页面。
未迁移:战败单、签名、客户画像、客户资料修改、发票、施工单新建与独立施工详情页面。
工单详情“工单信息”标题后不展示退款或纠错操作按钮。确认施工成功后刷新当前详情页。
工单详情“工单信息”标题后不展示退款或纠错操作按钮。确认施工成功后刷新当前详情页。
##
临时用户模拟
##
登录用户上下文
登录功能尚未迁入,当前通过
`utils/fixedUserInfoMock.js`
启用固定身份模式。小程序启动时
小程序使用
`pages/wxLogin/wxLogin`
的微信手机号、验证码或账号密码真实登录链路。
只初始化旧缓存
`dj_boutique_user_info`
和当前环境下的
`userInfo`
。
登录成功后,接口返回的用户写入
`dj_boutique_user_info`
;
`wx.$util.getUserInfo()`
只读取
`wx.$util.getUserInfo()`
每次返回一份独立的固定用户副本;会话不属于该模拟范围,
该缓存,没有登录信息时返回
`null`
。
`App.onLaunch()`
不再创建或写入任何用户身份。
`wx.$util.getSessionId()`
继续直接读取系统原有的
`dj_boutique_sessionId`
,启动时不会覆盖
旧、新 session 缓存。
该模拟只提供页面流程需要的用户和默认门店上下文,不提供会话、验证码或接口签名,也不会
`wx.$util.getSessionId()`
继续读取登录接口写入的
`dj_boutique_sessionId`
。低价单页面只使用
把完整用户对象输出到日志。登录功能迁入后,应关闭
`FIXED_USER_INFO_MOCK_ENABLED`
,
登录用户上下文和显式路由参数,不会在空入口补入测试账号、默认园区或默认 4S 店。
移除用户双缓存初始化,再运行本页列出的完整回归命令。
## 自动化命令
## 自动化命令
...
...
docs/order-lifecycle/test-acceptance.md
View file @
d3eb2ee
# 区域助手精品工单迁移自动化测试验收表
# 区域助手精品工单迁移自动化测试验收表
> 验收日期:2026-08-
07
> 验收日期:2026-08-
18
> 目标项目/分支:`regional-assistant` / `SAAS+V5.8.5`
> 目标项目/分支:`regional-assistant` / `SAAS+V5.8.5`
> 运行时:Node 24 LTS(项目 Volta 基线 `24.18.0`;本次执行 `24.1
4
.0`)
> 运行时:Node 24 LTS(项目 Volta 基线 `24.18.0`;本次执行 `24.1
9
.0`)
> 安全约定:
除本地固定身份模拟外,
真实环境账号、验证码和会话只从运行时环境变量读取,仓库和测试输出不得保存这些值。
> 安全约定:真实环境账号、验证码和会话只从运行时环境变量读取,仓库和测试输出不得保存这些值。
本文档只记录目标项目的可达范围。来源项目的施工单新建、领单、出库、完工、返工、签名、
本文档只记录目标项目的可达范围。来源项目的施工单新建、领单、出库、完工、返工、签名、
客户画像、发票和战败单页面不属于本次迁移,不得用来源仓库的历史执行结果冒充目标验收。
客户画像、发票和战败单页面不属于本次迁移,不得用来源仓库的历史执行结果冒充目标验收。
...
@@ -11,20 +11,20 @@
...
@@ -11,20 +11,20 @@
-
**已覆盖**
:目标仓库中存在可重复运行的自动化断言。
-
**已覆盖**
:目标仓库中存在可重复运行的自动化断言。
-
**已执行**
:本次已在 Node 24 下运行;默认安全开关关闭时,真实 API/UI 用例只会跳过。
-
**已执行**
:本次已在 Node 24 下运行;默认安全开关关闭时,真实 API/UI 用例只会跳过。
-
**受数据阻塞**
:需要测试环境账号、业务数据、支付设备或已授权的微信开发者工具。
-
**受数据阻塞**
:需要测试环境账号、业务数据、支付设备或已授权的微信开发者工具。
-
**
临时身份模拟**
:登录未迁入期间只提供固定用户;sessionId 沿用系统登录态,不替代真实 E2E 的运行时授权和签名
。
-
**
真实登录上下文**
:应用启动时不预写用户;用户与 sessionId 均来自登录接口及其运行时缓存
。
## 1. 执行结果摘要
## 1. 执行结果摘要
| 层级 | Node 24 命令/入口 | 结果 | 说明 |
| 层级 | Node 24 命令/入口 | 结果 | 说明 |
|---|---|---|---|
|---|---|---|---|
| 迁移契约 |
`npm run test:workOrderMigration`
|
54/54 通过 | 创建页无业务守卫依赖、低价提单列表/统计、菜单隐藏、两套产品图标、下单门店及筛选接口参数、弹层响应式滚动、9 个接口接线、Sass 编译语法,以及返回、固定用户/系统
session、工作台统计、OCR、详情和迁移闭包 |
| 迁移契约 |
`npm run test:workOrderMigration`
|
66/66 通过 | 创建页无业务守卫依赖、低价提单列表/统计、菜单隐藏、两套产品图标、下单门店及筛选接口参数、弹层响应式滚动、9 个接口接线、Sass 编译语法,以及返回、真实登录用户/
session、工作台统计、OCR、详情和迁移闭包 |
| 创建页单测 |
`npm run test:createOrder`
| 1
32/132
通过 | 路由、底部操作区、客户档案图标与单一空态、低价门店上下文、销售顾问门店继承、园区配置缓存、三类商品最低价严格边界与回显、表单、回显、提交清洗和支付分支 |
| 创建页单测 |
`npm run test:createOrder`
| 1
94/194
通过 | 路由、底部操作区、客户档案图标与单一空态、低价门店上下文、销售顾问门店继承、园区配置缓存、三类商品最低价严格边界与回显、表单、回显、提交清洗和支付分支 |
| 生命周期目标套件 |
`npm run test:orderLifecycle`
| 69 通过、3 跳过、0 失败 | 跳过项为 2 个真实 API 用例和 1 个小程序 UI 用例 |
| 生命周期目标套件 |
`npm run test:orderLifecycle`
| 69 通过、3 跳过、0 失败 | 跳过项为 2 个真实 API 用例和 1 个小程序 UI 用例 |
| 合并执行 |
`npm run test:workOrder`
|
255 通过、3 跳过、0 失败 | 共 258
项,并完成静态闭包检查 |
| 合并执行 |
`npm run test:workOrder`
|
329 通过、3 跳过、0 失败 | 共 332
项,并完成静态闭包检查 |
| 静态依赖闭包 |
`npm run check:workOrderClosure`
| 通过 | 扫描 23
4
个运行文件;缺失依赖、死路由、缺失公共 API 均为 0 |
| 静态依赖闭包 |
`npm run check:workOrderClosure`
| 通过 | 扫描 23
6
个运行文件;缺失依赖、死路由、缺失公共 API 均为 0 |
| 真实 API/UI | 显式安全开关 | 未执行 | 本次没有使用账号、验证码、业务数据或开发者工具授权 |
| 真实 API/UI | 显式安全开关 | 未执行 | 本次没有使用账号、验证码、业务数据或开发者工具授权 |
上述命令由 Node
`24.1
4
.0`
实际执行,满足
`>=24 <25`
引擎范围;项目 Volta 固定基线仍为
上述命令由 Node
`24.1
9
.0`
实际执行,满足
`>=24 <25`
引擎范围;项目 Volta 固定基线仍为
`24.18.0`
。开发机默认 Node 版本不作为验收依据。
`24.18.0`
。开发机默认 Node 版本不作为验收依据。
## 2. 逐场景验收表
## 2. 逐场景验收表
...
@@ -63,8 +63,8 @@
...
@@ -63,8 +63,8 @@
| AC-30 | 上传前强制 Node 24 与闭包检查 |
`upload-config.test.mjs`
| 是 | 是 | 否 |
`wx-upload-guard.js`
存在并执行检查 |
| AC-30 | 上传前强制 Node 24 与闭包检查 |
`upload-config.test.mjs`
| 是 | 是 | 否 |
`wx-upload-guard.js`
存在并执行检查 |
| AC-31 | 真实测试环境创建/撤销 |
`IT-OL-LIVE-001`
| 是 | 否 | 是 | 需显式开关、授权测试账号和可清理订单数据 |
| AC-31 | 真实测试环境创建/撤销 |
`IT-OL-LIVE-001`
| 是 | 否 | 是 | 需显式开关、授权测试账号和可清理订单数据 |
| AC-32 | 真实测试环境纠错 |
`IT-OL-LIVE-002`
| 是 | 否 | 是 | 需显式开关、授权测试账号和可清理订单数据 |
| AC-32 | 真实测试环境纠错 |
`IT-OL-LIVE-002`
| 是 | 否 | 是 | 需显式开关、授权测试账号和可清理订单数据 |
| AC-33 | 小程序 UI 登录并点击新增工单 |
`IT-OL-UI-LIVE-001`
| 是 | 否 | 是(工具) |
登录链路尚未迁入;固定用户只支持本地页面流程,真实 UI 用例继续等待登录和工具
条件 |
| AC-33 | 小程序 UI 登录并点击新增工单 |
`IT-OL-UI-LIVE-001`
| 是 | 否 | 是(工具) |
真实登录链路已接通;真实 UI 用例仍需微信开发者工具、授权测试账号和对应环境
条件 |
| AC-34 |
固定用户读取与用户双缓存初始化 |
`fixed-user-info-mock.test.mjs`
| 是 | 是 | 否 | 用户 getter 返回独立副本并初始化两类用户缓存;session getter 直接读取系统原缓存且启动不覆盖会话缓存
|
| AC-34 |
真实登录用户读取与启动隔离 |
`real-login-user-info.test.mjs`
| 是 | 是 | 否 | 未登录时 getter 返回
`null`
,登录后返回接口缓存用户,应用启动不预写任何身份
|
| AC-35 | 门店运营管理点击“低价提单” |
`workspace-source-contract.test.mjs`
、静态闭包 | 是 | 是 | 否 | 菜单紧跟新增工单,使用产品紫色图标并通过本地
`path`
直达低价提单列表 |
| AC-35 | 门店运营管理点击“低价提单” |
`workspace-source-contract.test.mjs`
、静态闭包 | 是 | 是 | 否 | 菜单紧跟新增工单,使用产品紫色图标并通过本地
`path`
直达低价提单列表 |
| AC-36 | 低价提单列表顶部返回 |
`work-order-list-page.test.mjs`
| 是 | 是 | 否 | 固定返回按钮并调用
`wx.navigateBack()`
|
| AC-36 | 低价提单列表顶部返回 |
`work-order-list-page.test.mjs`
| 是 | 是 | 否 | 固定返回按钮并调用
`wx.navigateBack()`
|
| AC-37 | 低价提单列表提供低价单新建并移除扫码 |
`work-order-list-page.test.mjs`
、静态闭包 | 是 | 是 | 否 | 有“新建低价单”入口,无扫码核销入口 |
| AC-37 | 低价提单列表提供低价单新建并移除扫码 |
`work-order-list-page.test.mjs`
、静态闭包 | 是 | 是 | 否 | 有“新建低价单”入口,无扫码核销入口 |
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
[
`environmentGuard.mjs`
](
../../tests/order-lifecycle/support/environmentGuard.mjs
)
和
[
`environmentGuard.mjs`
](
../../tests/order-lifecycle/support/environmentGuard.mjs
)
和
[
`testConfig.mjs`
](
../../tests/order-lifecycle/e2e/testConfig.mjs
)
:
[
`testConfig.mjs`
](
../../tests/order-lifecycle/e2e/testConfig.mjs
)
:
固定用户模拟不提供或覆盖 sessionId;真实 E2E 仍必须使用
系统登录态及对应环境授权、验证码和签名条件。
真实 E2E 必须使用登录接口生成的
系统登录态及对应环境授权、验证码和签名条件。
1.
未开启显式开关时用例跳过。
1.
未开启显式开关时用例跳过。
2.
非允许测试域名、非批准园区/门店/场景会在发请求前失败。
2.
非允许测试域名、非批准园区/门店/场景会在发请求前失败。
...
...
pages/tab/workspace/workspace.js
View file @
d3eb2ee
...
@@ -290,6 +290,8 @@ Page({
...
@@ -290,6 +290,8 @@ Page({
let
userInfo
=
wx
.
$util
.
getUserInfo
();
let
userInfo
=
wx
.
$util
.
getUserInfo
();
let
{
approvalMenus
,
storeManagementMenus
}
=
this
.
data
;
let
{
approvalMenus
,
storeManagementMenus
}
=
this
.
data
;
if
(
userInfo
.
sceneType
==
0
)
{
if
(
userInfo
.
sceneType
==
0
)
{
// 权益场景不展示低价提单入口
storeManagementMenus
=
storeManagementMenus
.
filter
((
item
)
=>
item
.
name
!=
"低价提单"
);
if
(
storeManagementMenus
.
every
((
item
)
=>
item
.
name
!=
"接待记录"
))
{
if
(
storeManagementMenus
.
every
((
item
)
=>
item
.
name
!=
"接待记录"
))
{
storeManagementMenus
.
push
({
storeManagementMenus
.
push
({
name
:
"接待记录"
,
name
:
"接待记录"
,
...
...
tabWorkOrder/pages/confirmOrder/confirmOrder.wxml
View file @
d3eb2ee
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<wxs src="../../index.wxs" module="filter" />
<wxs src="../../index.wxs" module="filter" />
<glsx-privacy appletName="嘀加区域助手" bind:agreeClick="agreeClick" bind:disagreeClick="disagreeClick"></glsx-privacy>
<glsx-privacy appletName="嘀加区域助手" bind:agreeClick="agreeClick" bind:disagreeClick="disagreeClick"></glsx-privacy>
<block wx:if="{{ flag }}">
<block wx:if="{{ flag }}">
<view class="main {{ isFullSucreen
&&!perm.hasPermission.isSuper(userInfo) && userInfo.userType == 2?'isFullSucreenCom':
'' }}">
<view class="main {{ isFullSucreen
? 'isFullSucreenCom' :
'' }}">
<view class="status-box">
<view class="status-box">
<block wx:if="{{ orderInfo.selectPayType == 3 || orderInfo.selectPayType == 1 }}">
<block wx:if="{{ orderInfo.selectPayType == 3 || orderInfo.selectPayType == 1 }}">
<view class="content">等待客户付款</view>
<view class="content">等待客户付款</view>
...
@@ -227,19 +227,23 @@
...
@@ -227,19 +227,23 @@
</view>
</view>
</block> -->
</block> -->
</view>
</view>
<
block wx:if="{{ !perm.hasPermission.isSuper(userInfo) && userInfo.userType == 2 }}"
>
<
!-- 确认页始终保留一个确认入口;只有修改订单继续受原角色权限限制。 --
>
<view class="btn-box {{ orderInfo['status'] == 3?'tips-btn':'confirm-btn'}} {{isFullSucreen?'isFullSucreen-btn':
'' }}">
<view class="btn-box confirm-btn {{ orderInfo['status'] == 3 ? 'tips-btn' : '' }} {{ isFullSucreen ? 'isFullSucreen-btn' :
'' }}">
<view class="tips" wx:if="{{ (orderInfo['status'] == 3 )
&& showTips }}">
<view class="tips" wx:if="{{ orderInfo['status'] == 3
&& showTips }}">
<image class="tipsIcon" src="{{ IMG_URL }}images/tips.png" />
<image class="tipsIcon" src="{{ IMG_URL }}images/tips.png" />
<view class="contentText">超过24h未支付将关闭此订单。</view>
<view class="contentText">超过24h未支付将关闭此订单。</view>
<image class="closeIcon" bindtap="closeTips" src="../../images/closeIcon.png" />
<image class="closeIcon" bindtap="closeTips" src="../../images/closeIcon.png" />
</view>
</view>
<block wx:if="{{ orderInfo.status == 1
}}">
<block wx:if="{{ orderInfo.status == 1 && !perm.hasPermission.isSuper(userInfo) && userInfo.userType == 2
}}">
<view class="btn text-center change" bindtap="edit">修改</view>
<view class="btn text-center change" bindtap="edit">修改</view>
</block>
</block>
<view class="btn text-center" style="width:{{ orderInfo.status == 1||orderInfo.status == 3 ? '' : '100%' }}" bindtap="next">确认</view>
<view
class="btn text-center {{ orderInfo.status == 1 && !perm.hasPermission.isSuper(userInfo) && userInfo.userType == 2 ? '' : 'single-confirm-btn' }}"
bindtap="next"
>
确认
</view>
</view>
</view>
</block>
</block>
</block>
<!-- 待支付提示 -->
<!-- 待支付提示 -->
<!-- <block wx:if="{{item.status && orderInfo['status'] == 3}}">
<!-- <block wx:if="{{item.status && orderInfo['status'] == 3}}">
...
...
tabWorkOrder/pages/confirmOrder/confirmOrder.wxss
View file @
d3eb2ee
...
@@ -17,6 +17,10 @@
...
@@ -17,6 +17,10 @@
color: #323233;
color: #323233;
}
}
.confirm-btn .single-confirm-btn {
width: calc(100% - var(--fontSize64));
}
.pay_change {
.pay_change {
font-family: PingFangSC-Regular;
font-family: PingFangSC-Regular;
font-size: 14px;
font-size: 14px;
...
...
tabWorkOrder/pages/createOrder/components/merchant-staff-picker/merchant-staff-picker.js
View file @
d3eb2ee
...
@@ -214,6 +214,12 @@ Component({
...
@@ -214,6 +214,12 @@ Component({
wx
.
$util
.
showToast
(
merchantTitle
||
'请选择合作门店'
)
wx
.
$util
.
showToast
(
merchantTitle
||
'请选择合作门店'
)
return
return
}
}
// 员工列表可能在打开弹窗时已默认选中,未经过 onStaffTap,
// 确认入口仍需执行同一套销售/交付人员互斥校验。
if
(
hasStaffConflict
(
mode
,
this
.
properties
.
orderObj
,
staff
.
uuid
))
{
wx
.
$util
.
showToast
(
getModeConfig
(
mode
).
conflictMessage
)
return
}
this
.
triggerEvent
(
'confirm'
,
{
merchant
,
staff
,
mode
})
this
.
triggerEvent
(
'confirm'
,
{
merchant
,
staff
,
mode
})
},
},
...
...
tabWorkOrder/pages/createOrder/createOrder.js
View file @
d3eb2ee
...
@@ -68,14 +68,9 @@ import {
...
@@ -68,14 +68,9 @@ import {
applyLowPriceDefaultScene
,
applyLowPriceDefaultScene
,
hasCompleteOrderScene
,
hasCompleteOrderScene
,
LOW_PRICE_DEFAULT_SCENE
,
LOW_PRICE_DEFAULT_SCENE
,
mergeLowPriceOrderContext
,
mergeLowPriceOrderContext
restoreFixedLowPriceEntryContext
}
from
'./services/lowPriceOrderContext.helpers'
}
from
'./services/lowPriceOrderContext.helpers'
import
{
import
{
FIXED_USER_INFO_MOCK_ENABLED
,
createFixedLowPriceEntryContext
}
from
'~/utils/fixedUserInfoMock.js'
import
{
normalizeSceneColumns
,
normalizeSceneColumns
,
resolveAutoScene
,
resolveAutoScene
,
toSceneFields
toSceneFields
...
@@ -89,7 +84,8 @@ import {
...
@@ -89,7 +84,8 @@ import {
mergeSubOrderListForEcho
,
mergeSubOrderListForEcho
,
findCatalogSingleGoodsItem
,
findCatalogSingleGoodsItem
,
resolveSubOrderUnitPrice
,
resolveSubOrderUnitPrice
,
applySubOrderDiscountEcho
applySubOrderDiscountEcho
,
isMultiSpecSubOrderLine
}
from
'./services/goodsChooseEcho.helpers.js'
}
from
'./services/goodsChooseEcho.helpers.js'
import
{
isMarketingGoodsPriceLocked
}
from
'./services/goodsPriceEdit.helpers.js'
import
{
isMarketingGoodsPriceLocked
}
from
'./services/goodsPriceEdit.helpers.js'
import
{
import
{
...
@@ -116,15 +112,28 @@ import {
...
@@ -116,15 +112,28 @@ import {
import
NP
from
'number-precision'
import
NP
from
'number-precision'
const
app
=
getApp
()
const
app
=
getApp
()
let
time
=
null
let
time
=
null
const
LOW_PRICE_OPTIONAL_VEHICLE_FIELDS
=
[
'standNo'
,
'plateNumber'
]
function
omitLowPriceOptionalVehicleFields
(
requiredList
=
[])
{
return
requiredList
.
filter
(
field
=>
!
LOW_PRICE_OPTIONAL_VEHICLE_FIELDS
.
includes
(
field
)
)
}
let
toastList
=
{
let
toastList
=
{
userId
:
'销售顾问不能为空'
,
userId
:
'销售顾问不能为空'
,
merchantId
:
'销售顾问不能为空'
,
employeeName
:
'销售顾问不能为空'
,
baseSceneCode
:
'场景名称不能为空'
,
baseSceneCode
:
'场景名称不能为空'
,
baseSceneName
:
'场景名称不能为空'
,
subShopMerchantId
:
'二级流量方不能为空'
,
subShopMerchantId
:
'二级流量方不能为空'
,
deliveryUserId
:
'交付专员不能为空'
,
deliveryUserId
:
'交付专员不能为空'
,
customerName
:
'车主姓名不能为空'
,
customerName
:
'车主姓名不能为空'
,
salesType
:
'客户来源不能为空'
,
salesType
:
'客户来源不能为空'
,
customerPhone
:
'手机号不能为空'
,
customerPhone
:
'手机号不能为空'
,
sellerUserId
:
'转化人员不能为空'
,
sellerUserId
:
'转化人员不能为空'
,
sellerName
:
'转化人员不能为空'
,
sellerMerchantId
:
'转化人员不能为空'
,
customerCouponCode
:
'精品礼券不能为空'
,
customerCouponCode
:
'精品礼券不能为空'
,
carBrand
:
'车型不能为空'
,
carBrand
:
'车型不能为空'
,
standNo
:
'车架号( VIN码 )不能为空'
,
standNo
:
'车架号( VIN码 )不能为空'
,
...
@@ -132,12 +141,6 @@ let toastList = {
...
@@ -132,12 +141,6 @@ let toastList = {
payeeType
:
'收款方不能为空'
,
payeeType
:
'收款方不能为空'
,
selectPayType
:
'支付方式不能为空'
selectPayType
:
'支付方式不能为空'
}
}
const
REQUIRED_TOAST_ALIASES
=
Object
.
freeze
({
merchantId
:
'userId'
,
employeeName
:
'userId'
,
sellerName
:
'sellerUserId'
,
sellerMerchantId
:
'sellerUserId'
})
import
{
validateVin
,
formatVinInput
}
from
'~/utils/vinVaildate'
import
{
validateVin
,
formatVinInput
}
from
'~/utils/vinVaildate'
const
phoneRex
=
/^
[
1
]([
3-9
])[
0-9
]{9}
$/
const
phoneRex
=
/^
[
1
]([
3-9
])[
0-9
]{9}
$/
// orderSource 订单来源(1后台录入,2移动端预录客户,3移动端升级下单,4再次下单)
// orderSource 订单来源(1后台录入,2移动端预录客户,3移动端升级下单,4再次下单)
...
@@ -1421,10 +1424,9 @@ Page({
...
@@ -1421,10 +1424,9 @@ Page({
// checkRequired 对手机号、VIN、备注会先自行给出精确提示并返回 true。
// checkRequired 对手机号、VIN、备注会先自行给出精确提示并返回 true。
// 此处只处理具体字段名,避免随后用通用文案覆盖原提示。
// 此处只处理具体字段名,避免随后用通用文案覆盖原提示。
if
(
typeof
key
!==
'string'
||
!
key
)
return
if
(
typeof
key
!==
'string'
||
!
key
)
return
const
messageKey
=
toastList
[
key
]
?
key
:
REQUIRED_TOAST_ALIASES
[
key
]
this
.
showToast
(
toastList
[
key
]
||
'请完善必填信息'
)
this
.
showToast
(
toastList
[
messageKey
]
||
'请完善必填信息'
)
wx
.
pageScrollTo
({
wx
.
pageScrollTo
({
selector
:
`.
${
messageKey
||
key
}
`
selector
:
`.
${
key
}
`
})
})
},
},
...
@@ -1670,17 +1672,17 @@ Page({
...
@@ -1670,17 +1672,17 @@ Page({
},
},
checkRequired
(
save
,
obj
)
{
checkRequired
(
save
,
obj
)
{
// 导入动态校验字段
// 导入动态校验字段
let
{
requiredList
}
=
this
.
data
const
requiredList
=
omitLowPriceOptionalVehicleFields
(
const
orderRequiredList
=
requiredList
.
filter
(
this
.
data
.
requiredList
key
=>
!
[
'baseSceneCode'
,
'baseSceneName'
].
includes
(
key
)
)
)
// let target = save ? ['userId', 'merchantId', 'employeeName', ...requiredList, 'customerName', 'customerPhone', 'sellerUserId', 'sellerName', 'sellerMerchantId']
// let target = save ? ['userId', 'merchantId', 'employeeName', ...requiredList, 'customerName', 'customerPhone', 'sellerUserId', 'sellerName', 'sellerMerchantId']
// : ['userId', 'merchantId', 'employeeName', ...requiredList, 'customerName', 'customerPhone', 'sellerUserId', 'sellerName', 'sellerMerchantId', 'customerCouponCode']
// : ['userId', 'merchantId', 'employeeName', ...requiredList, 'customerName', 'customerPhone', 'sellerUserId', 'sellerName', 'sellerMerchantId', 'customerCouponCode']
let
target
=
[
let
target
=
[
'userId'
,
'userId'
,
'baseSceneCode'
,
'merchantId'
,
'merchantId'
,
'employeeName'
,
'employeeName'
,
...
orderR
equiredList
,
...
r
equiredList
,
'customerName'
,
'customerName'
,
'salesType'
,
'salesType'
,
'sellerUserId'
,
'sellerUserId'
,
...
@@ -1703,8 +1705,7 @@ Page({
...
@@ -1703,8 +1705,7 @@ Page({
this
.
showToast
(
'备注不能为空'
)
this
.
showToast
(
'备注不能为空'
)
return
true
return
true
}
}
// Customer-profile fields only fill customer validation values. They must
// customer 只补充客户字段,同名订单字段以订单层选择为准。
// never shadow order-level selections such as merchant, staff, or scene.
obj
=
{
obj
=
{
...(
obj
.
customer
||
{}),
...(
obj
.
customer
||
{}),
...
obj
...
obj
...
@@ -1758,8 +1759,9 @@ Page({
...
@@ -1758,8 +1759,9 @@ Page({
* 路由/接口回显写入 orderObj(编辑、再次下单、扫码礼券等)。
* 路由/接口回显写入 orderObj(编辑、再次下单、扫码礼券等)。
* 含礼券字段从 customerCoupon 回显的逻辑。
* 含礼券字段从 customerCoupon 回显的逻辑。
* @param {Object} options 订单详情或路由入参
* @param {Object} options 订单详情或路由入参
* @param {{authoritativeDetail?: boolean}} [meta] 已存订单详情是否覆盖页面暂存上下文
*/
*/
setOrderObj
(
options
)
{
setOrderObj
(
options
,
{
authoritativeDetail
=
false
}
=
{}
)
{
this
.
_setOrderObjInvoked
=
true
this
.
_setOrderObjInvoked
=
true
let
{
let
{
scene
,
scene
,
...
@@ -1903,9 +1905,21 @@ Page({
...
@@ -1903,9 +1905,21 @@ Page({
if
(
options
.
yqMerchantId
&&
options
.
isAppointment
)
{
if
(
options
.
yqMerchantId
&&
options
.
isAppointment
)
{
orderObj
.
sellerMerchantId
=
options
.
yqMerchantId
orderObj
.
sellerMerchantId
=
options
.
yqMerchantId
}
}
// 低价工单的下单门店由进入页面前的弹框确定;客户档案、历史订单等回显
// 新建单导入客户/历史数据时,保留当前手选门店上下文。
// 只补充业务数据,不能反向覆盖已选 4S 店及园区店上下文。
// 重新打开已存订单时,详情中的门店和转化人员必须保持权威,
// 不能被列表摘要或详情请求期间注入的登录人默认值覆盖。
if
(
authoritativeDetail
)
{
if
(
this
.
_isLowPriceCreateOrder
||
Number
(
prevOrderObj
.
lowPriceFlag
)
===
1
||
Number
(
orderObj
.
lowPriceFlag
)
===
1
)
{
orderObj
.
lowPriceFlag
=
1
orderObj
.
djOrderType
=
LOW_PRICE_ORDER_TYPE_OPTION
.
value
}
}
else
{
orderObj
=
mergeLowPriceOrderContext
(
orderObj
,
prevOrderObj
)
orderObj
=
mergeLowPriceOrderContext
(
orderObj
,
prevOrderObj
)
}
// 销售顾问只能由销售顾问弹框修改;客户档案及其他订单回显不得覆盖已完成的手选结果。
// 销售顾问只能由销售顾问弹框修改;客户档案及其他订单回显不得覆盖已完成的手选结果。
const
hasSelectedSalesAdvisor
=
const
hasSelectedSalesAdvisor
=
prevOrderObj
.
userId
!==
undefined
&&
prevOrderObj
.
userId
!==
undefined
&&
...
@@ -1916,7 +1930,11 @@ Page({
...
@@ -1916,7 +1930,11 @@ Page({
prevOrderObj
.
merchantId
!==
null
&&
prevOrderObj
.
merchantId
!==
null
&&
prevOrderObj
.
merchantId
!==
''
&&
prevOrderObj
.
merchantId
!==
''
&&
prevOrderObj
.
merchantName
prevOrderObj
.
merchantName
if
(
this
.
isLowPriceOrder
()
&&
hasSelectedSalesAdvisor
)
{
if
(
!
authoritativeDetail
&&
this
.
isLowPriceOrder
()
&&
hasSelectedSalesAdvisor
)
{
orderObj
.
userId
=
prevOrderObj
.
userId
orderObj
.
userId
=
prevOrderObj
.
userId
orderObj
.
employeeName
=
prevOrderObj
.
employeeName
orderObj
.
employeeName
=
prevOrderObj
.
employeeName
orderObj
.
merchantId
=
prevOrderObj
.
merchantId
orderObj
.
merchantId
=
prevOrderObj
.
merchantId
...
@@ -1995,10 +2013,6 @@ Page({
...
@@ -1995,10 +2013,6 @@ Page({
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
:
async
function
(
options
)
{
onLoad
:
async
function
(
options
)
{
options
=
restoreFixedLowPriceEntryContext
(
options
,
FIXED_USER_INFO_MOCK_ENABLED
?
createFixedLowPriceEntryContext
()
:
{}
)
// 当前页面是低价单专用入口,不依赖调用方是否携带 lowPriceFlag。
// 当前页面是低价单专用入口,不依赖调用方是否携带 lowPriceFlag。
options
=
{
...
options
,
lowPriceFlag
:
1
}
options
=
{
...
options
,
lowPriceFlag
:
1
}
this
.
_isLowPriceCreateOrder
=
true
this
.
_isLowPriceCreateOrder
=
true
...
@@ -2172,6 +2186,12 @@ Page({
...
@@ -2172,6 +2186,12 @@ Page({
positionTypeList
,
positionTypeList
,
baseConfigData
baseConfigData
})
})
const
echoSavedOrderGoods
=
()
=>
{
const
{
first
,
orderObj
=
{}
}
=
this
.
data
const
hasSavedGoods
=
orderObj
.
subOrderList
?.
length
||
orderObj
.
packageGoodsList
?.
length
if
(
first
&&
hasSavedGoods
)
this
.
getChooseList
()
}
merchantId
&&
merchantId
&&
api
api
.
getSelectOrderGoodsList
({
.
getSelectOrderGoodsList
({
...
@@ -2212,15 +2232,24 @@ Page({
...
@@ -2212,15 +2232,24 @@ Page({
}
}
}
}
this
.
setData
(
patch
,
async
()
=>
{
this
.
setData
(
patch
,
async
()
=>
{
try
{
await
this
.
syncCreateOrderMarketingFlags
()
await
this
.
syncCreateOrderMarketingFlags
()
if
(
first
)
{
}
catch
(
error
)
{
this
.
getChooseList
()
console
.
error
(
'sync create-order marketing flags failed:'
,
error
)
}
finally
{
if
(
first
)
this
.
getChooseList
()
}
}
})
})
}
else
{
}
else
{
echoSavedOrderGoods
()
wx
.
$util
.
showToast
(
message
)
wx
.
$util
.
showToast
(
message
)
}
}
})
})
.
catch
(
error
=>
{
console
.
error
(
'get select-order goods failed:'
,
error
)
echoSavedOrderGoods
()
wx
.
$util
.
showToast
(
'商品列表加载失败'
)
})
wx
.
hideLoading
()
wx
.
hideLoading
()
},
},
async
getOrderBaseGoodsList
(
merchantId
,
sceneType
=
this
.
data
.
orderObj
.
sceneType
)
{
async
getOrderBaseGoodsList
(
merchantId
,
sceneType
=
this
.
data
.
orderObj
.
sceneType
)
{
...
@@ -2386,7 +2415,7 @@ Page({
...
@@ -2386,7 +2415,7 @@ Page({
}
}
// 是普通商品
// 是普通商品
if
(
e
&&
!
e
.
packageName
)
{
if
(
e
&&
!
e
.
packageName
)
{
if
(
e
.
specificationData
.
indexOf
(
';~;'
)
==
-
1
)
{
if
(
!
isMultiSpecSubOrderLine
(
e
)
)
{
// 修复取值字段名字错误问题
// 修复取值字段名字错误问题
if
(
orderObj
.
resetOrder
)
{
if
(
orderObj
.
resetOrder
)
{
const
unitPrice
=
resolveSubOrderUnitPrice
(
e
,
true
)
const
unitPrice
=
resolveSubOrderUnitPrice
(
e
,
true
)
...
@@ -2611,12 +2640,13 @@ Page({
...
@@ -2611,12 +2640,13 @@ Page({
})
})
}
}
if
(
e
&&
!
e
.
packageName
)
{
if
(
e
&&
!
e
.
packageName
)
{
const
isMultiSpec
=
isMultiSpecSubOrderLine
(
e
)
console
.
log
(
console
.
log
(
e
.
specificationData
,
e
.
specificationData
,
e
,
e
,
e
.
specificationData
.
indexOf
(
';~;'
)
>
-
1
isMultiSpec
)
)
if
(
e
.
specificationData
.
indexOf
(
';~;'
)
>
-
1
)
{
if
(
isMultiSpec
)
{
// 修复取值字段名字错误问题
// 修复取值字段名字错误问题
if
(
orderObj
.
resetOrder
)
{
if
(
orderObj
.
resetOrder
)
{
// 再次编辑优先使用订单回显单价,避免被 originalPrice(目录原价)覆盖
// 再次编辑优先使用订单回显单价,避免被 originalPrice(目录原价)覆盖
...
@@ -2855,9 +2885,11 @@ Page({
...
@@ -2855,9 +2885,11 @@ Page({
return
strVal
return
strVal
},
},
getSetting
()
{
getSetting
()
{
//
动态获取 车型 车架 车牌 是否必填
//
低价单的车架号、车牌号固定选填,仅车型和手机号读取必填配置。
let
{
requiredList
,
orderObj
=
{}
}
=
this
.
data
let
{
requiredList
,
orderObj
=
{}
}
=
this
.
data
const
fallbackRequiredList
=
buildCustomerRequiredList
({},
requiredList
)
const
fallbackRequiredList
=
omitLowPriceOptionalVehicleFields
(
buildCustomerRequiredList
({},
requiredList
)
)
this
.
setData
({
this
.
setData
({
requiredList
:
fallbackRequiredList
,
requiredList
:
fallbackRequiredList
,
phoneShow
:
false
phoneShow
:
false
...
@@ -2877,9 +2909,11 @@ Page({
...
@@ -2877,9 +2909,11 @@ Page({
return
getYQorderInfo
(
selectedMerchantContext
)
return
getYQorderInfo
(
selectedMerchantContext
)
.
then
(
merchantSettingInfo
=>
{
.
then
(
merchantSettingInfo
=>
{
this
.
setData
({
this
.
setData
({
requiredList
:
buildCustomerRequiredList
(
requiredList
:
omitLowPriceOptionalVehicleFields
(
buildCustomerRequiredList
(
merchantSettingInfo
,
merchantSettingInfo
,
fallbackRequiredList
fallbackRequiredList
)
),
),
phoneShow
:
wx
.
$util
.
deepClone
(
merchantSettingInfo
.
yqPhoneConfig
)
phoneShow
:
wx
.
$util
.
deepClone
(
merchantSettingInfo
.
yqPhoneConfig
)
})
})
...
...
tabWorkOrder/pages/createOrder/createOrder.wxml
View file @
d3eb2ee
...
@@ -139,22 +139,46 @@ value="{{ orderObj.remark }}"
...
@@ -139,22 +139,46 @@ value="{{ orderObj.remark }}"
/>
/>
<gl-cell
<gl-cell
wx:if="{{ orderObj.selectPayType !=0 }}"
wx:if="{{ orderObj.selectPayType !=0 }}"
required="{{ filter.isIncludesItem(requiredList ,'standNo') }}"
border
border
iconSrc="{{ scanIcon }}"
bindtitleClick="navOcr"
valueAlign="right"
valueAlign="right"
label="车架号( VIN )"
label="车架号( VIN )"
data-type="standNo"
labelWidth="var(--fontSize280)"
labelWidth="var(--fontSize280)"
>
<input
placeholder="点击输入"
class="input"
placeholder-class="placeholder-class"
value="{{ orderObj.customer.standNo }}"
value="{{ orderObj.customer.standNo }}"
/>
bindinput="input"
data-name="customer.standNo"
maxlength="17"
always-embed
></input>
</gl-cell>
<gl-cell
<gl-cell
wx:if="{{ orderObj.selectPayType !=0 }}"
wx:if="{{ orderObj.selectPayType !=0 }}"
required="{{ filter.isIncludesItem(requiredList ,'plateNumber') }}"
border
border
valueAlign="right"
valueAlign="right"
iconSrc="{{ scanIcon }}"
bindtitleClick="navOcr"
data-type="plateNumber"
label="车牌号"
label="车牌号"
labelWidth="var(--fontSize240)"
labelWidth="var(--fontSize240)"
>
<input
placeholder="点击输入"
class="input"
placeholder-class="placeholder-class"
value="{{ orderObj.customer.plateNumber }}"
value="{{ orderObj.customer.plateNumber }}"
/>
bindinput="input"
data-name="customer.plateNumber"
maxlength="8"
always-embed
></input>
</gl-cell>
<gl-cell wx:if="{{ orderObj.selectPayType !=0 }}" border label="是否体验" value="{{ orderObj.customer.experienceFlag == 'Y' ? '是' : (orderObj.customer.experienceFlag == 'N' ? '否' : '') }}" valueAlign="right" labelWidth="var(--fontSize140)" />
<gl-cell wx:if="{{ orderObj.selectPayType !=0 }}" border label="是否体验" value="{{ orderObj.customer.experienceFlag == 'Y' ? '是' : (orderObj.customer.experienceFlag == 'N' ? '否' : '') }}" valueAlign="right" labelWidth="var(--fontSize140)" />
</view>
</view>
<view class="box" wx:if="{{ orderObj.userId && orderObj.baseSceneCode }}">
<view class="box" wx:if="{{ orderObj.userId && orderObj.baseSceneCode }}">
...
@@ -861,11 +885,11 @@ value="{{ orderObj.remark }}"
...
@@ -861,11 +885,11 @@ value="{{ orderObj.remark }}"
<image wx:if="{{ item.marketingFlag == 1 }}" class="marketing-icon" src="/tabWorkOrder/images/activeIcon.png" mode="aspectFit" />
<image wx:if="{{ item.marketingFlag == 1 }}" class="marketing-icon" src="/tabWorkOrder/images/activeIcon.png" mode="aspectFit" />
</view>
</view>
<view class="approval-sheet__price-col">
<view class="approval-sheet__price-col">
<view class="approval-sheet__price">¥ {{ item.totalPrice }}</view>
<view class="approval-sheet__price">¥ {{ item.totalPrice
Text
}}</view>
</view>
</view>
</view>
</view>
<view class="approval-sheet__meta">
<view class="approval-sheet__meta">
<view class="approval-sheet__min-price" wx:if="{{ item.marketingFlag == 1 }}">活动价 ¥ {{ item.activityPrice }}</view>
<view class="approval-sheet__min-price" wx:if="{{ item.marketingFlag == 1 }}">活动价 ¥ {{ item.activityPrice
Text
}}</view>
<view class="approval-sheet__count">共 {{ item.count }} 件</view>
<view class="approval-sheet__count">共 {{ item.count }} 件</view>
</view>
</view>
</view>
</view>
...
@@ -876,7 +900,7 @@ value="{{ orderObj.remark }}"
...
@@ -876,7 +900,7 @@ value="{{ orderObj.remark }}"
<image wx:if="{{ item.marketingFlag == 1 }}" class="marketing-icon" src="/tabWorkOrder/images/activeIcon.png" mode="aspectFit" />
<image wx:if="{{ item.marketingFlag == 1 }}" class="marketing-icon" src="/tabWorkOrder/images/activeIcon.png" mode="aspectFit" />
</view>
</view>
<view class="approval-sheet__price-col">
<view class="approval-sheet__price-col">
<view class="approval-sheet__price">¥ {{ item.totalPrice }}</view>
<view class="approval-sheet__price">¥ {{ item.totalPrice
Text
}}</view>
</view>
</view>
</view>
</view>
<view
<view
...
@@ -890,11 +914,11 @@ value="{{ orderObj.remark }}"
...
@@ -890,11 +914,11 @@ value="{{ orderObj.remark }}"
<view class="approval-sheet__child-name text-hide">{{ child.name }}</view>
<view class="approval-sheet__child-name text-hide">{{ child.name }}</view>
</view>
</view>
<view class="approval-sheet__price-col">
<view class="approval-sheet__price-col">
<view class="approval-sheet__price">¥ {{ child.totalPrice }}</view>
<view class="approval-sheet__price">¥ {{ child.totalPrice
Text
}}</view>
</view>
</view>
</view>
</view>
<view class="approval-sheet__meta">
<view class="approval-sheet__meta">
<view class="approval-sheet__min-price" wx:if="{{ child.marketingFlag == 1 }}">活动价 ¥ {{ child.activityPrice }}</view>
<view class="approval-sheet__min-price" wx:if="{{ child.marketingFlag == 1 }}">活动价 ¥ {{ child.activityPrice
Text
}}</view>
<view class="approval-sheet__count">共 {{ child.count }} 件</view>
<view class="approval-sheet__count">共 {{ child.count }} 件</view>
</view>
</view>
</view>
</view>
...
...
tabWorkOrder/pages/createOrder/routeStrategy.js
View file @
d3eb2ee
...
@@ -190,25 +190,34 @@ EditOrderStrategy.prototype = Object.create(BaseStrategy.prototype)
...
@@ -190,25 +190,34 @@ EditOrderStrategy.prototype = Object.create(BaseStrategy.prototype)
EditOrderStrategy
.
prototype
.
constructor
=
EditOrderStrategy
EditOrderStrategy
.
prototype
.
constructor
=
EditOrderStrategy
EditOrderStrategy
.
prototype
.
specificHandle
=
async
function
(
res
)
{
EditOrderStrategy
.
prototype
.
specificHandle
=
async
function
(
res
)
{
var
result
=
await
api
.
getOrderDetail
({
try
{
// 待跟进低价单需要普通商品和套餐的完整快照。
// order.detail 不包含完整套餐时,会导致重新进入后商品回显为空。
var
result
=
await
api
.
getPackageGoodsDetail
({
orderCode
:
res
.
orderCode
orderCode
:
res
.
orderCode
})
})
console
.
log
(
'EditOrderStrategy fetch result:'
,
result
)
console
.
log
(
'EditOrderStrategy fetch result:'
,
result
)
var
code
=
result
.
code
var
code
=
result
.
code
var
data
=
result
.
data
var
data
=
result
.
data
if
(
code
==
0
)
{
if
(
code
==
0
&&
data
)
{
// data.customer.customerName = res.customerName // 原代码注释
return
data
return
data
// 返回新的 res 数据源
}
}
return
res
wx
.
$util
.
showToast
(
result
.
message
||
'订单详情加载失败'
)
}
catch
(
error
)
{
console
.
error
(
'EditOrderStrategy fetch failed:'
,
error
)
wx
.
$util
.
showToast
(
'订单详情加载失败'
)
}
// 不用列表摘要兜底渲染可提交表单,避免缺少商品时误提交。
return
false
}
}
EditOrderStrategy
.
prototype
.
finalHandle
=
function
(
res
)
{
EditOrderStrategy
.
prototype
.
finalHandle
=
function
(
res
)
{
this
.
page
.
setData
({
this
.
page
.
setData
({
returnFun
:
true
returnFun
:
true
})
})
this
.
page
.
setOrderObj
(
res
)
// 编辑已存订单时服务端详情是权威数据,列表摘要/登录人默认值不能覆盖。
this
.
page
.
setOrderObj
(
res
,
{
authoritativeDetail
:
true
})
}
}
/**
/**
...
...
tabWorkOrder/pages/createOrder/services/lowPriceOrderContext.helpers.js
View file @
d3eb2ee
...
@@ -13,43 +13,6 @@ export const LOW_PRICE_DEFAULT_SCENE = Object.freeze({
...
@@ -13,43 +13,6 @@ export const LOW_PRICE_DEFAULT_SCENE = Object.freeze({
sceneType
:
1
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
=
{})
{
export
function
buildLowPriceOrderPatch
(
source
=
{})
{
if
(
Number
(
source
.
lowPriceFlag
)
!==
1
)
return
{}
if
(
Number
(
source
.
lowPriceFlag
)
!==
1
)
return
{}
...
...
tabWorkOrder/pages/createOrder/services/minPriceApproval.js
View file @
d3eb2ee
...
@@ -3,9 +3,28 @@
...
@@ -3,9 +3,28 @@
* 纯函数:不 setData、不访问页面实例
* 纯函数:不 setData、不访问页面实例
*/
*/
import
NP
from
'number-precision'
import
{
DISCOUNT_TYPE
}
from
'../productStrategy.js'
import
{
DISCOUNT_TYPE
}
from
'../productStrategy.js'
/**
/**
* 审批弹层金额统一保留两位精度;数值用于后续提交,文本用于页面固定两位展示。
* @param {number|string} value
* @returns {number}
*/
function
normalizeApprovalMoney
(
value
)
{
const
amount
=
Number
(
value
||
0
)
return
Number
.
isFinite
(
amount
)
?
NP
.
round
(
amount
,
2
)
:
0
}
/**
* @param {number|string} value
* @returns {string}
*/
function
formatApprovalMoney
(
value
)
{
return
normalizeApprovalMoney
(
value
).
toFixed
(
2
)
}
/**
* 取用于比价的单价(与 performValidation / priceBlur 一致,优先 basePrice)
* 取用于比价的单价(与 performValidation / priceBlur 一致,优先 basePrice)
* @param {object} goods
* @param {object} goods
* @returns {number|string|null}
* @returns {number|string|null}
...
@@ -103,18 +122,24 @@ function resolveGoodsDisplayName(goods = {}, lineItem = {}) {
...
@@ -103,18 +122,24 @@ function resolveGoodsDisplayName(goods = {}, lineItem = {}) {
/**
/**
* @param {object} goods
* @param {object} goods
* @param {number} [lineCount]
* @param {number} [lineCount]
* @returns {{ name: string, unitPrice: number,
totalPrice: number, activityPrice: number
, count: number, marketingFlag: number }}
* @returns {{ name: string, unitPrice: number,
unitPriceText: string, totalPrice: number, totalPriceText: string, activityPrice: number, activityPriceText: string
, count: number, marketingFlag: number }}
*/
*/
function
mapApprovalGoodsRow
(
goods
,
lineCount
=
1
)
{
function
mapApprovalGoodsRow
(
goods
,
lineCount
=
1
)
{
const
unitPrice
=
Number
(
resolveApprovalCheckPrice
(
goods
)
||
0
)
const
unitPrice
=
normalizeApprovalMoney
(
resolveApprovalCheckPrice
(
goods
)
)
// 行 count 为当前 UI 数量;goods.number 可能是订单回显旧值
// 行 count 为当前 UI 数量;goods.number 可能是订单回显旧值
const
count
=
Number
(
lineCount
||
goods
.
count
||
goods
.
number
||
1
)
const
count
=
Number
(
lineCount
||
goods
.
count
||
goods
.
number
||
1
)
const
totalPrice
=
normalizeApprovalMoney
(
NP
.
times
(
unitPrice
,
count
))
const
activityPrice
=
normalizeApprovalMoney
(
resolveApprovalActivityPrice
(
goods
)
)
return
{
return
{
name
:
resolveGoodsDisplayName
(
goods
),
name
:
resolveGoodsDisplayName
(
goods
),
unitPrice
,
unitPrice
,
// 审批弹层总价展示按当前商品行单价,不再随数量联动
unitPriceText
:
formatApprovalMoney
(
unitPrice
),
totalPrice
:
unitPrice
,
totalPrice
,
activityPrice
:
resolveApprovalActivityPrice
(
goods
),
totalPriceText
:
formatApprovalMoney
(
totalPrice
),
activityPrice
,
activityPriceText
:
formatApprovalMoney
(
activityPrice
),
count
,
count
,
marketingFlag
:
goods
.
marketingFlag
==
1
?
1
:
0
marketingFlag
:
goods
.
marketingFlag
==
1
?
1
:
0
}
}
...
@@ -170,22 +195,27 @@ export function buildMinPriceApprovalList(goodsList = []) {
...
@@ -170,22 +195,27 @@ export function buildMinPriceApprovalList(goodsList = []) {
if
(
line
.
goodsFlag
===
3
&&
line
.
packageGoods
?.
goodsList
?.
length
)
{
if
(
line
.
goodsFlag
===
3
&&
line
.
packageGoods
?.
goodsList
?.
length
)
{
const
packageGoodsList
=
line
.
packageGoods
.
goodsList
const
packageGoodsList
=
line
.
packageGoods
.
goodsList
const
children
=
[]
const
children
=
[]
const
count
=
Number
(
line
.
count
||
1
)
packageGoodsList
.
forEach
(
sub
=>
{
packageGoodsList
.
forEach
(
sub
=>
{
if
(
!
needsPackageSubMinPriceApproval
(
sub
))
return
if
(
!
needsPackageSubMinPriceApproval
(
sub
))
return
children
.
push
(
mapApprovalGoodsRow
(
sub
,
sub
.
number
||
line
.
count
||
1
))
children
.
push
(
mapApprovalGoodsRow
(
sub
,
count
))
})
})
if
(
!
children
.
length
)
return
if
(
!
children
.
length
)
return
const
pkg
=
line
.
packageGoods
const
pkg
=
line
.
packageGoods
const
totalPrice
=
children
.
reduce
(
const
totalPrice
=
normalizeApprovalMoney
(
(
sum
,
child
)
=>
sum
+
child
.
totalPrice
,
children
.
reduce
(
(
sum
,
child
)
=>
NP
.
plus
(
sum
,
child
.
totalPrice
),
0
0
)
)
)
result
.
push
({
result
.
push
({
type
:
'package'
,
type
:
'package'
,
name
:
pkg
.
packageAlias
||
pkg
.
packageName
||
''
,
name
:
pkg
.
packageAlias
||
pkg
.
packageName
||
''
,
count
,
totalPrice
,
totalPrice
,
totalPriceText
:
formatApprovalMoney
(
totalPrice
),
marketingFlag
:
line
.
marketingFlag
==
1
?
1
:
0
,
marketingFlag
:
line
.
marketingFlag
==
1
?
1
:
0
,
children
children
})
})
...
...
tabWorkOrder/pages/createOrder/submitStrategy.js
View file @
d3eb2ee
...
@@ -4,10 +4,7 @@ import { buildSubmitGoodsSnapshot } from './services/submitGoodsSnapshot'
...
@@ -4,10 +4,7 @@ import { buildSubmitGoodsSnapshot } from './services/submitGoodsSnapshot'
import
{
prepareSubmitPayload
}
from
'./services/submitPayload.helpers.js'
import
{
prepareSubmitPayload
}
from
'./services/submitPayload.helpers.js'
import
{
buildMinPriceApprovalList
}
from
'./services/minPriceApproval.js'
import
{
buildMinPriceApprovalList
}
from
'./services/minPriceApproval.js'
import
{
shouldUseMinPriceApprovalFlow
}
from
'./services/orderMerchantConfig.js'
import
{
shouldUseMinPriceApprovalFlow
}
from
'./services/orderMerchantConfig.js'
import
{
import
{
applyLowPriceDefaultScene
}
from
'./services/lowPriceOrderContext.helpers.js'
LOW_PRICE_DEFAULT_SCENE
,
applyLowPriceDefaultScene
}
from
'./services/lowPriceOrderContext.helpers.js'
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// 辅助构造函数:校验结果
// 辅助构造函数:校验结果
...
@@ -295,16 +292,7 @@ SubmitContext.prototype.finishSubmit = async function (
...
@@ -295,16 +292,7 @@ SubmitContext.prototype.finishSubmit = async function (
SubmitContext
.
prototype
.
prepareSubmitData
=
function
(
save
)
{
SubmitContext
.
prototype
.
prepareSubmitData
=
function
(
save
)
{
const
data
=
this
.
page
.
data
const
data
=
this
.
page
.
data
// 低价单接口当前固定要求精品升级场景。请求体在最后一步重新写入,
return
prepareSubmitPayload
(
data
.
orderObj
,
{
// 不依赖页面场景接口、客户档案回显或审批弹层期间的状态。
const
orderObj
=
this
.
isLowPriceOrder
()
?
{
...(
data
.
orderObj
||
{}),
lowPriceFlag
:
1
,
...
LOW_PRICE_DEFAULT_SCENE
}
:
data
.
orderObj
return
prepareSubmitPayload
(
orderObj
,
{
save
,
save
,
isErrorOrder
:
data
.
isErrorOrder
,
isErrorOrder
:
data
.
isErrorOrder
,
orderCreateType
:
data
.
orderCreateType
,
orderCreateType
:
data
.
orderCreateType
,
...
...
tabWorkOrder/pages/createOrder/tests/authoritativeOrderDetail.integration.test.mjs
0 → 100644
View file @
d3eb2ee
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.wx = {
getAccountInfoSync: () => ({
miniProgram: { appId: 'test-app-id', envVersion: 'develop' }
}),
getSystemInfoSync: () => ({ platform: 'devtools' }),
getStorageSync: () => '',
setNavigationBarTitle() {},
enableAlertBeforeUnload() {},
$util: {
getUserInfo: () => ({}),
showLoading() {}
}
}
await import(`../createOrder.js?authoritative-detail=${Date.now()}`)
function createPage(listSnapshot) {
return {
...pageConfig,
_isLowPriceCreateOrder: true,
data: {
...pageConfig.data,
orderObj: {
...pageConfig.data.orderObj,
...listSnapshot
},
orderTypeList: [{ text: '精品订单', value: 1 }]
},
setData(patch, callback) {
Object.assign(this.data, patch)
callback?.()
},
echoCustomerProfileIfNeeded: async () => {},
getSelectOrderGoodsList() {}
}
}
test('重新打开已存低价单时详情门店、销售顾问和转化人员不被列表摘要覆盖', () => {
const page = createPage({
lowPriceFlag: 1,
merchantId: 'LIST-SHOP',
merchantName: '列表摘要门店',
yqMerchantId: 'LOGIN-PARK',
yqMerchantName: '广联数科(内部使用)',
sellerMerchantId: 'LOGIN-PARK',
sellerMerchantName: '广联数科(内部使用)',
userId: 'LIST-ADVISOR',
employeeName: '列表销售顾问'
})
const detail = {
orderCode: 'ORDER-EDIT-1',
lowPriceFlag: 1,
merchantId: 'DETAIL-SHOP',
merchantName: '波波的单店门店',
yqMerchantId: 'BOUND-PARK',
yqMerchantName: '门店绑定园区',
sellerMerchantId: 'FLOW-PARK',
sellerMerchantName: '流程测试园区门店',
sellerUserId: 'ZHOU',
sellerName: '周大虾',
userId: 'DETAIL-ADVISOR',
employeeName: '订单销售顾问',
djOrderType: 1,
customer: {
customerName: '测试客户',
customerSex: 1,
experienceFlag: 'Y',
salesType: 0
},
subOrderList: [{ merchantGoodsId: 'GOODS-1' }]
}
pageConfig.setOrderObj.call(page, detail, { authoritativeDetail: true })
assert.deepEqual(
{
merchantId: page.data.orderObj.merchantId,
merchantName: page.data.orderObj.merchantName,
yqMerchantId: page.data.orderObj.yqMerchantId,
yqMerchantName: page.data.orderObj.yqMerchantName,
sellerMerchantId: page.data.orderObj.sellerMerchantId,
sellerMerchantName: page.data.orderObj.sellerMerchantName,
sellerUserId: page.data.orderObj.sellerUserId,
sellerName: page.data.orderObj.sellerName,
userId: page.data.orderObj.userId,
employeeName: page.data.orderObj.employeeName
},
{
merchantId: 'DETAIL-SHOP',
merchantName: '波波的单店门店',
yqMerchantId: 'BOUND-PARK',
yqMerchantName: '门店绑定园区',
sellerMerchantId: 'FLOW-PARK',
sellerMerchantName: '流程测试园区门店',
sellerUserId: 'ZHOU',
sellerName: '周大虾',
userId: 'DETAIL-ADVISOR',
employeeName: '订单销售顾问'
}
)
assert.equal(page.data.orderObj.lowPriceFlag, 1)
assert.equal(page.data.orderObj.djOrderType, 1)
assert.deepEqual(page.data.orderObj.subOrderList, detail.subOrderList)
})
test('普通商品详情未返回 specificationData 时仍能回显', () => {
const page = createPage({ lowPriceFlag: 1 })
page.data.orderObj = {
lowPriceFlag: 1,
subOrderList: [
{
merchantGoodsId: 'GOODS-WITHOUT-SPEC',
upgradeGoodsName: '回显商品',
upgradeGoodsPosition: 1,
number: 1,
totalPrice: 88,
price: 88,
discountType: 3,
goodsInfo: {}
}
],
packageGoodsList: []
}
page.data.goodsData = []
page.data.copyGoodsData = []
page.data.packageList = []
page.data.positionTypeList = []
page.setGoodsTotal = goodsList => {
page.data.goodsList = goodsList
}
pageConfig.getChooseList.call(page)
assert.equal(page.data.goodsList.length, 1)
assert.equal(page.data.goodsList[0].goodsFlag, 1)
assert.equal(
page.data.goodsList[0].goods.merchantGoodsId,
'GOODS-WITHOUT-SPEC'
)
assert.equal(page.data.first, false)
})
test('含套餐详情可转换为页面套餐商品行', () => {
const page = createPage({ lowPriceFlag: 1 })
page.data.orderObj = {
lowPriceFlag: 1,
subOrderList: [],
packageGoodsList: [
{
packageCode: 'PACKAGE-1',
packageName: '玻璃套餐',
packageGoodsOrderList: [
{
merchantGoodsId: 'PACKAGE-GOODS-1',
number: 1,
totalPrice: 68,
sellPrice: 68,
discountType: 3,
goodsInfo: { goodsTypeName: '前挡' }
}
]
}
]
}
page.data.goodsData = []
page.data.copyGoodsData = []
page.data.packageList = []
page.data.positionTypeList = []
page.setGoodsTotal = goodsList => {
page.data.goodsList = goodsList
}
pageConfig.getChooseList.call(page)
assert.equal(page.data.goodsList.length, 1)
assert.equal(page.data.goodsList[0].goodsFlag, 3)
assert.equal(page.data.goodsList[0].packageGoods.packageCode, 'PACKAGE-1')
assert.equal(
page.data.goodsList[0].packageGoods.goodsList[0].merchantGoodsId,
'PACKAGE-GOODS-1'
)
})
test('多规格详情按规格键和 SKU 回显已选商品', () => {
const page = createPage({ lowPriceFlag: 1 })
const catalogItem = {
goodsFlag: 2,
multipleSpecificationsGoods: {
id: 'SPEC-GROUP-1',
baseGoodsName: '多规格商品',
specificationGoodsMap: {
'黑色;~;标准': [
{
merchantGoodsId: 'SKU-1',
sellPrice: 120,
goodsName: '多规格商品-黑色'
}
]
}
}
}
page.data.orderObj = {
lowPriceFlag: 1,
subOrderList: [
{
merchantGoodsId: 'SKU-1',
goodsName: '多规格商品',
specificationData: '黑色;~;标准',
number: 1,
count: 1,
price: 88,
sellPrice: 88,
discountType: 3
}
],
packageGoodsList: []
}
page.data.goodsData = [catalogItem]
page.data.copyGoodsData = [catalogItem]
page.data.otherProduct = [catalogItem]
page.data.packageList = []
page.data.positionTypeList = []
page.data.marketingFlagMap = {}
page.data.activityIdMap = {}
page.setGoodsTotal = goodsList => {
page.data.goodsList = goodsList
}
pageConfig.getChooseList.call(page)
assert.equal(page.data.goodsList.length, 1)
assert.equal(page.data.goodsList[0].goodsFlag, 2)
assert.equal(
page.data.goodsList[0].multipleSpecificationsGoods.goods.merchantGoodsId,
'SKU-1'
)
assert.equal(
page.data.goodsList[0].multipleSpecificationsGoods.goods.sellPrice,
88
)
})
tabWorkOrder/pages/createOrder/tests/customerProfileOnlyTemplate.test.mjs
View file @
d3eb2ee
...
@@ -18,7 +18,7 @@ const end = template.indexOf(
...
@@ -18,7 +18,7 @@ const end = template.indexOf(
const customerSection = template.slice(start, end)
const customerSection = template.slice(start, end)
describe('createOrder customer information template', () => {
describe('createOrder customer information template', () => {
it('keeps
customer archive as the only manual customer-data entry
', () => {
it('keeps
archive fields read-only while allowing VIN and plate input
', () => {
assert.ok(start >= 0)
assert.ok(start >= 0)
assert.ok(end > start)
assert.ok(end > start)
assert.match(customerSection, /bindtitleClick="showCustomPop"/)
assert.match(customerSection, /bindtitleClick="showCustomPop"/)
...
@@ -42,15 +42,17 @@ describe('createOrder customer information template', () => {
...
@@ -42,15 +42,17 @@ describe('createOrder customer information template', () => {
assert.match(customerSection, /orderObj\.customer\.carSeriesName \? orderObj\.customer\.carBrand \+ ' - ' \+ orderObj\.customer\.carChildsBrandName \+ ' - ' \+ orderObj\.customer\.carSeriesName : ''/)
assert.match(customerSection, /orderObj\.customer\.carSeriesName \? orderObj\.customer\.carBrand \+ ' - ' \+ orderObj\.customer\.carChildsBrandName \+ ' - ' \+ orderObj\.customer\.carSeriesName : ''/)
assert.match(customerSection, /label="车架号\( VIN \)"/)
assert.match(customerSection, /label="车架号\( VIN \)"/)
assert.match(customerSection, /value="\{\{ orderObj\.customer\.standNo \}\}"/)
assert.match(customerSection, /value="\{\{ orderObj\.customer\.standNo \}\}"/)
assert.match(customerSection, /data-name="customer\.standNo"/)
assert.match(customerSection, /label="车牌号"/)
assert.match(customerSection, /label="车牌号"/)
assert.match(customerSection, /value="\{\{ orderObj\.customer\.plateNumber \}\}"/)
assert.match(customerSection, /value="\{\{ orderObj\.customer\.plateNumber \}\}"/)
assert.match(customerSection, /data-name="customer\.plateNumber"/)
assert.match(customerSection, /label="是否体验"/)
assert.match(customerSection, /label="是否体验"/)
assert.match(customerSection, /orderObj\.customer\.experienceFlag == 'Y' \? '是' : \(orderObj\.customer\.experienceFlag == 'N' \? '否' : ''\)/)
assert.match(customerSection, /orderObj\.customer\.experienceFlag == 'Y' \? '是' : \(orderObj\.customer\.experienceFlag == 'N' \? '否' : ''\)/)
assert.
doesNotMatch(customerSection, /<input/
)
assert.
equal(customerSection.match(/<input/g)?.length, 2
)
assert.doesNotMatch(customerSection, /bind:click="toSelectCustomerSource"/)
assert.doesNotMatch(customerSection, /bind:click="toSelectCustomerSource"/)
assert.doesNotMatch(customerSection, /bindtap="changeGender"/)
assert.doesNotMatch(customerSection, /bindtap="changeGender"/)
assert.doesNotMatch(customerSection, /data-show-name="carBrandBox"/)
assert.doesNotMatch(customerSection, /data-show-name="carBrandBox"/)
assert.
doesNotMatch(customerSection, /bindtitleClick="navOcr"/
)
assert.
equal(customerSection.match(/bindtitleClick="navOcr"/g)?.length, 2
)
assert.doesNotMatch(customerSection, /bindtap="changeExperience"/)
assert.doesNotMatch(customerSection, /bindtap="changeExperience"/)
})
})
...
...
tabWorkOrder/pages/createOrder/tests/defaultSceneInitialization.integration.test.mjs
View file @
d3eb2ee
...
@@ -136,7 +136,7 @@ test('the dedicated create page normalizes every route to a low-price order', as
...
@@ -136,7 +136,7 @@ test('the dedicated create page normalizes every route to a low-price order', as
])
])
})
})
test('low-price required-field validation
does not block on scene fields
', () => {
test('low-price required-field validation
uses the order-level scene
', () => {
const page = createPage()
const page = createPage()
page._isLowPriceCreateOrder = true
page._isLowPriceCreateOrder = true
page.data.requiredList = ['baseSceneCode', 'baseSceneName']
page.data.requiredList = ['baseSceneCode', 'baseSceneName']
...
@@ -157,16 +157,22 @@ test('low-price required-field validation does not block on scene fields', () =>
...
@@ -157,16 +157,22 @@ test('low-price required-field validation does not block on scene fields', () =>
}
}
}
}
assert.equal(pageConfig.checkRequired.call(page, false, orderObj), false)
assert.equal(
pageConfig.checkRequired.call(page, false, orderObj),
'baseSceneCode'
)
})
})
test('customer profile fields cannot override selected order merchant during validation', () => {
test('customer profile fields cannot override selected order merchant
or scene
during validation', () => {
const page = createPage()
const page = createPage()
page.data.requiredList = []
page.data.requiredList = []
const orderObj = {
const orderObj = {
userId: '14b46ce8a57c47328d7552b8a3dd5950',
userId: '14b46ce8a57c47328d7552b8a3dd5950',
merchantId: 44210895,
merchantId: 44210895,
employeeName: 'selected sales advisor',
employeeName: 'selected sales advisor',
baseSceneCode: 'SCENE-SELECTED',
baseSceneName: 'selected scene',
sceneType: 1,
sellerUserId: 2,
sellerUserId: 2,
sellerName: 'conversion staff',
sellerName: 'conversion staff',
sellerMerchantId: 100,
sellerMerchantId: 100,
...
@@ -473,7 +479,7 @@ test('non-staff order echo cannot overwrite a manually selected sales advisor',
...
@@ -473,7 +479,7 @@ test('non-staff order echo cannot overwrite a manually selected sales advisor',
assert.equal(page.data.orderObj.merchantName, '波波的单店门店')
assert.equal(page.data.orderObj.merchantName, '波波的单店门店')
})
})
test('create-order required-field validation
does not block on scene fields
', () => {
test('create-order required-field validation
still requires a scene
', () => {
const page = createPage()
const page = createPage()
page._isLowPriceCreateOrder = false
page._isLowPriceCreateOrder = false
page.data.requiredList = []
page.data.requiredList = []
...
@@ -494,7 +500,10 @@ test('create-order required-field validation does not block on scene fields', ()
...
@@ -494,7 +500,10 @@ test('create-order required-field validation does not block on scene fields', ()
}
}
}
}
assert.equal(pageConfig.checkRequired.call(page, false, orderObj), false)
assert.equal(
pageConfig.checkRequired.call(page, false, orderObj),
'baseSceneCode'
)
})
})
test('direct low-price entry waits for the selected store scene name before finishing initialization', async () => {
test('direct low-price entry waits for the selected store scene name before finishing initialization', async () => {
...
@@ -731,7 +740,7 @@ test('submit preserves a real low-price scene before required-field validation',
...
@@ -731,7 +740,7 @@ test('submit preserves a real low-price scene before required-field validation',
assert.equal(orderSeenByRequiredValidation.sceneType, 7)
assert.equal(orderSeenByRequiredValidation.sceneType, 7)
})
})
test('approval confirmation submits the
fix
ed low-price scene', async () => {
test('approval confirmation submits the
select
ed low-price scene', async () => {
let submittedPayload
let submittedPayload
globalThis.__WORK_ORDER_MOCK_API__ = {
globalThis.__WORK_ORDER_MOCK_API__ = {
createWithPay(payload) {
createWithPay(payload) {
...
@@ -765,9 +774,9 @@ test('approval confirmation submits the fixed low-price scene', async () => {
...
@@ -765,9 +774,9 @@ test('approval confirmation submits the fixed low-price scene', async () => {
await pageConfig.onConfirmMinPriceApprovalSubmit.call(page)
await pageConfig.onConfirmMinPriceApprovalSubmit.call(page)
assert.equal(submittedPayload.lowPriceFlag, 1)
assert.equal(submittedPayload.lowPriceFlag, 1)
assert.equal(submittedPayload.baseSceneCode, '
100101
')
assert.equal(submittedPayload.baseSceneCode, '
SCENE-REAL
')
assert.equal(submittedPayload.baseSceneName, '
精品升级
')
assert.equal(submittedPayload.baseSceneName, '
接口返回场景
')
assert.equal(submittedPayload.sceneType,
1
)
assert.equal(submittedPayload.sceneType,
7
)
})
})
test('approval confirmation restores a missing dedicated low-price scene before the request', async () => {
test('approval confirmation restores a missing dedicated low-price scene before the request', async () => {
...
@@ -1000,86 +1009,28 @@ test('a matching selected-store scene keeps the complete recent scene metadata',
...
@@ -1000,86 +1009,28 @@ test('a matching selected-store scene keeps the complete recent scene metadata',
assert.equal(page.data.orderObj.sceneType, 1)
assert.equal(page.data.orderObj.sceneType, 1)
})
})
test('reopening without route options restores fixed low-price context before customer profile import', async () => {
test('reopening without route options does not manufacture a fixed merchant identity', async () => {
const settingRequests = []
const sceneRequests = []
globalThis.__WORK_ORDER_MOCK_API__ = {
globalThis.__WORK_ORDER_MOCK_API__ = {
getMerchantRecordingSettings(params) {
getMerchantRecordingSettings() {
settingRequests.push(params)
return {
return {
code: 0,
code: 0,
data: { orderFieldSettingList: [], yqPhoneConfig: '[]' }
data: { orderFieldSettingList: [], yqPhoneConfig: '[]' }
}
}
},
},
getRecentUserScene() {
getRecentUserScene() {
return {
return { code: 0, data: null }
code: 0,
data: {
baseSceneCode: 'SCENE-REOPENED',
baseSceneName: 'Reopened low-price scene',
sceneType: 1
}
}
},
},
getUserScene(params) {
getUserScene() {
sceneRequests.push(params)
return { code: 0, data: [] }
return {
code: 0,
data: [
{
baseSceneCode: 'SCENE-REOPENED',
name: 'Reopened low-price scene',
sceneType: 1,
status: 1
}
]
}
}
}
}
}
const page = createPage()
const page = createPage()
let normalRouteCount = 0
page.onRoute = async () => {
normalRouteCount += 1
}
page.settingPayType = () => {}
page.echoCustomerProfileIfNeeded = async () => {}
await pageConfig.onLoad.call(page, {})
await pageConfig.onLoad.call(page, {})
assert.equal(page.data.orderObj.lowPriceFlag, 1)
assert.equal(page.data.orderObj.lowPriceFlag, 1)
assert.equal(page.data.orderObj.merchantId, 44210895)
assert.equal(page.data.orderObj.merchantId, undefined)
assert.equal(page.data.orderObj.merchantName, '波波的单店门店')
assert.equal(page.data.orderObj.merchantName, undefined)
assert.equal(page.data.orderObj.yqMerchantId, 44211025)
assert.equal(page.data.orderObj.yqMerchantId, undefined)
assert.equal(page.data.orderObj.sellerMerchantId, 44211025)
assert.equal(page.data.orderObj.sellerMerchantId, undefined)
assert.deepEqual(settingRequests, [{ scene: 1, merchantId: 44210895 }])
assert.deepEqual(sceneRequests, [
{
sceneType: '1',
phone: '13900000000',
merchantId: 44210895
}
])
delete page.data.orderObj.lowPriceFlag
await pageConfig.chooseCustomerInfo.call(page, {
detail: {
baseSceneCode: '',
baseSceneName: '',
sceneType: '',
selectPayType: 5,
subOrderList: [{ goodsCode: 'HISTORY' }],
customer: {
customerId: 2,
customerName: 'Reopened customer',
customerPhone: '13800000000'
}
}
})
assert.equal(normalRouteCount, 0)
assert.equal(page.data.orderObj.baseSceneCode, 'SCENE-REOPENED')
assert.equal(page.data.orderObj.baseSceneName, 'Reopened low-price scene')
assert.equal(page.data.orderObj.sceneType, 1)
})
})
tabWorkOrder/pages/createOrder/tests/lowPriceCatalogFilter.integration.test.mjs
View file @
d3eb2ee
...
@@ -210,4 +210,34 @@ describe('createOrder low-price catalog display', () => {
...
@@ -210,4 +210,34 @@ describe('createOrder low-price catalog display', () => {
assert.equal(page.data.otherProduct.length, 0)
assert.equal(page.data.otherProduct.length, 0)
assert.equal(page.data.packageList.length, 0)
assert.equal(page.data.packageList.length, 0)
})
})
it('still echoes saved-order goods when the current catalog request fails', async () => {
const pageConfig = await loadPageConfig()
globalThis.__WORK_ORDER_MOCK_API__ = {
getSelectOrderGoodsList: () => ({ code: 500, message: 'catalog failed' }),
}
const page = createPage(pageConfig, 1)
page.data.first = true
page.data.orderObj.subOrderList = [
{
merchantGoodsId: 'SAVED-GOODS',
upgradeGoodsName: 'saved goods',
number: 1,
totalPrice: 80,
price: 80,
discountType: 3,
goodsInfo: {},
},
]
let echoCount = 0
page.getChooseList = () => {
echoCount += 1
}
globalThis.wx.$util.showToast = () => {}
await pageConfig.getSelectOrderGoodsList.call(page, 100, 1)
await new Promise((resolve) => setImmediate(resolve))
assert.equal(echoCount, 1)
})
})
})
tabWorkOrder/pages/createOrder/tests/lowPriceSubmitFlow.integration.test.mjs
View file @
d3eb2ee
...
@@ -149,8 +149,8 @@ describe('low-price approval submit flow', () => {
...
@@ -149,8 +149,8 @@ describe('low-price approval submit flow', () => {
await new SubmitContext(page).executeAfterApproval({ save: false })
await new SubmitContext(page).executeAfterApproval({ save: false })
assert.equal(apiCalls, 1)
assert.equal(apiCalls, 1)
assert.equal(submittedPayload.baseSceneCode, '
100101
')
assert.equal(submittedPayload.baseSceneCode, '
SCENE-LOW
')
assert.equal(submittedPayload.baseSceneName, '
精品升级
')
assert.equal(submittedPayload.baseSceneName, '
低价单默认场景
')
assert.equal(submittedPayload.sceneType, 1)
assert.equal(submittedPayload.sceneType, 1)
assert.equal(redirectTarget, 'confirmOrder')
assert.equal(redirectTarget, 'confirmOrder')
assert.deepEqual(redirectData, { orderCode: 'LP-1' })
assert.deepEqual(redirectData, { orderCode: 'LP-1' })
...
...
tabWorkOrder/pages/createOrder/tests/merchantStaffPicker.component.test.mjs
View file @
d3eb2ee
...
@@ -82,3 +82,57 @@ test('同一次打开重复同步 show=true 时只加载一次人员数据', asy
...
@@ -82,3 +82,57 @@ test('同一次打开重复同步 show=true 时只加载一次人员数据', asy
delete globalThis.Component
delete globalThis.Component
}
}
})
})
test('默认选中的交付专员与销售顾问相同时确认也会拦截', async () => {
let componentConfig
const toastMessages = []
const confirmEvents = []
globalThis.Component = config => {
componentConfig = config
}
globalThis.wx = {
$util: {
showToast(message) {
toastMessages.push(message)
}
}
}
try {
await import(
`../components/merchant-staff-picker/merchant-staff-picker.js?confirm-conflict=${Date.now()}`
)
const instance = createComponentInstance(componentConfig, {
show: true,
mode: 'delivery',
orderObj: {
userId: 'staff-1',
userName: '秋椰0818'
},
userContext: {},
pointsMultiRole: 'Y',
orderCreateType: 'createdOrder'
})
instance.data.merchantTitle = '请选择合作门店'
instance.data.staffTitle = '请选择交付专员'
instance.data.merchantList = [
{ merchantId: 44210895, merchantName: '波波的单店门店', active: true }
]
instance.data.staffList = [
{ uuid: 'staff-1', staffName: '秋椰0818', active: true }
]
instance.triggerEvent = (name, detail) => {
confirmEvents.push({ name, detail })
}
instance.onConfirm()
assert.deepEqual(toastMessages, [
'销售顾问/录单员与交付专员不能选取同一人'
])
assert.deepEqual(confirmEvents, [])
} finally {
delete globalThis.Component
delete globalThis.wx
}
})
tabWorkOrder/pages/createOrder/tests/minPriceApproval.test.mjs
View file @
d3eb2ee
...
@@ -80,7 +80,7 @@ test('needsMinPriceApproval uses minSellPrice instead of a stale upgrade price',
...
@@ -80,7 +80,7 @@ test('needsMinPriceApproval uses minSellPrice instead of a stale upgrade price',
)
)
})
})
test('buildMinPriceApprovalList
prefers line count over stale goods.number
', () => {
test('buildMinPriceApprovalList
uses current line count for displayed total
', () => {
const list = buildMinPriceApprovalList([
const list = buildMinPriceApprovalList([
{
{
goodsFlag: 1,
goodsFlag: 1,
...
@@ -97,7 +97,7 @@ test('buildMinPriceApprovalList prefers line count over stale goods.number', ()
...
@@ -97,7 +97,7 @@ test('buildMinPriceApprovalList prefers line count over stale goods.number', ()
}
}
])
])
assert.equal(list[0].count, 2)
assert.equal(list[0].count, 2)
assert.equal(list[0].totalPrice,
1
00)
assert.equal(list[0].totalPrice,
2
00)
})
})
test('buildMinPriceApprovalList collects singles and packages', () => {
test('buildMinPriceApprovalList collects singles and packages', () => {
...
@@ -268,3 +268,126 @@ test('package approval only includes subs below minSellPrice', () => {
...
@@ -268,3 +268,126 @@ test('package approval only includes subs below minSellPrice', () => {
assert.equal(list[0].children[0].name, 'super改色膜')
assert.equal(list[0].children[0].name, 'super改色膜')
assert.equal(list[0].totalPrice, 0.1)
assert.equal(list[0].totalPrice, 0.1)
})
})
test('package approval totals use money-safe addition and two-decimal precision', () => {
const list = buildMinPriceApprovalList([
{
goodsFlag: 3,
count: 1,
packageGoods: {
packageName: '新模板导入验证套餐YYY',
goodsList: [
{
validMinSellPrice: 'Y',
minSellPrice: 2000,
sellPrice: 1999.98,
upgradeGoodsName: '0728新模板C品'
},
{
validMinSellPrice: 'Y',
minSellPrice: 1500,
sellPrice: 1498.99,
upgradeGoodsName: '0728新模板D品'
}
]
}
}
])
assert.equal(list[0].children[0].totalPrice, 1999.98)
assert.equal(list[0].children[1].totalPrice, 1498.99)
assert.equal(list[0].totalPrice, 3498.97)
assert.equal(list[0].totalPriceText, '3498.97')
})
test('approval rows mirror current quantities and totals for every goods type', () => {
const list = buildMinPriceApprovalList([
{
goodsFlag: 1,
count: 4,
goods: {
validMinSellPrice: 'Y',
minSellPrice: 1000,
sellPrice: 999.99,
number: 1,
upgradeGoodsName: '普通商品'
}
},
{
goodsFlag: 2,
count: 3,
multipleSpecificationsGoods: {
goods: {
validMinSellPrice: 'Y',
minSellPrice: 1500,
sellPrice: 1498.99,
number: 1,
upgradeGoodsName: '多规格商品'
}
}
},
{
goodsFlag: 3,
count: 5,
packageGoods: {
packageName: '套餐商品',
goodsList: [
{
validMinSellPrice: 'Y',
minSellPrice: 2000,
sellPrice: 1999.98,
number: 2,
upgradeGoodsName: '套餐子商品C'
},
{
validMinSellPrice: 'Y',
minSellPrice: 1500,
sellPrice: 1498.99,
number: 2,
upgradeGoodsName: '套餐子商品D'
}
]
}
}
])
assert.deepEqual(
list.map(item => ({
type: item.type,
count: item.count,
totalPrice: item.totalPrice,
totalPriceText: item.totalPriceText
})),
[
{
type: 'single',
count: 4,
totalPrice: 3999.96,
totalPriceText: '3999.96'
},
{
type: 'single',
count: 3,
totalPrice: 4496.97,
totalPriceText: '4496.97'
},
{
type: 'package',
count: 5,
totalPrice: 17494.85,
totalPriceText: '17494.85'
}
]
)
assert.deepEqual(
list[2].children.map(item => ({
count: item.count,
totalPrice: item.totalPrice,
totalPriceText: item.totalPriceText
})),
[
{ count: 5, totalPrice: 9999.9, totalPriceText: '9999.90' },
{ count: 5, totalPrice: 7494.95, totalPriceText: '7494.95' }
]
)
})
tabWorkOrder/pages/createOrder/tests/orderRequiredSettings.integration.test.mjs
View file @
d3eb2ee
...
@@ -116,6 +116,38 @@ describe('createOrder dynamic customer required fields', () => {
...
@@ -116,6 +116,38 @@ describe('createOrder dynamic customer required fields', () => {
assert.deepEqual(page.data.requiredList, ['carBrand'])
assert.deepEqual(page.data.requiredList, ['carBrand'])
})
})
it('ignores VIN and plate required settings on the low-price page', async () => {
globalThis.__WORK_ORDER_MOCK_API__ = {
getMerchantRecordingSettings() {
return {
code: 0,
data: {
orderFieldSettingList: [
{ fieldKey: 'carNo', isRequired: true },
{ fieldKey: 'plateNo', isRequired: true },
{ fieldKey: 'customerPhone', isRequired: false }
],
yqPhoneConfig: '[]'
}
}
}
}
const page = createPage()
pageConfig.getSetting.call(page)
await new Promise(resolve => setImmediate(resolve))
assert.deepEqual(page.data.requiredList, [])
assert.equal(
pageConfig.checkRequired.call(
page,
false,
structuredClone(page.data.orderObj)
),
false
)
})
it('loads the selected store settings during direct low-price page entry', async () => {
it('loads the selected store settings during direct low-price page entry', async () => {
const requests = []
const requests = []
globalThis.__WORK_ORDER_MOCK_API__ = {
globalThis.__WORK_ORDER_MOCK_API__ = {
...
@@ -189,6 +221,22 @@ describe('createOrder dynamic customer required fields', () => {
...
@@ -189,6 +221,22 @@ describe('createOrder dynamic customer required fields', () => {
assert.deepEqual(page.messages, ['请输入正确的手机号'])
assert.deepEqual(page.messages, ['请输入正确的手机号'])
})
})
it('ignores stale VIN and plate requirements during submission validation', () => {
const page = createPage({
requiredList: ['standNo', 'plateNumber']
})
assert.equal(
pageConfig.checkRequired.call(
page,
false,
structuredClone(page.data.orderObj)
),
false
)
assert.deepEqual(page.messages, [])
})
it('blocks an empty phone when the store explicitly requires it', () => {
it('blocks an empty phone when the store explicitly requires it', () => {
const page = createPage({ requiredList: ['customerPhone'] })
const page = createPage({ requiredList: ['customerPhone'] })
...
@@ -199,14 +247,12 @@ describe('createOrder dynamic customer required fields', () => {
...
@@ -199,14 +247,12 @@ describe('createOrder dynamic customer required fields', () => {
assert.deepEqual(page.messages, ['请输入正确的手机号'])
assert.deepEqual(page.messages, ['请输入正确的手机号'])
})
})
it('
binds all four customer
stars to the dynamic required list', () => {
it('
only binds phone and model
stars to the dynamic required list', () => {
const template = readFileSync(new URL('../createOrder.wxml', import.meta.url), 'utf8')
const template = readFileSync(new URL('../createOrder.wxml', import.meta.url), 'utf8')
for (const [label, field] of [
for (const [label, field] of [
['手机号', 'customerPhone'],
['手机号', 'customerPhone'],
['选择车型', 'carBrand'],
['选择车型', 'carBrand']
['车架号( VIN )', 'standNo'],
['车牌号', 'plateNumber']
]) {
]) {
const cell = template.match(
const cell = template.match(
new RegExp(`<gl-cell[\\s\\S]*?label="${label.replace(/[()]/g, '\\$&')}"[\\s\\S]*?\\/>`)
new RegExp(`<gl-cell[\\s\\S]*?label="${label.replace(/[()]/g, '\\$&')}"[\\s\\S]*?\\/>`)
...
@@ -217,5 +263,18 @@ describe('createOrder dynamic customer required fields', () => {
...
@@ -217,5 +263,18 @@ describe('createOrder dynamic customer required fields', () => {
new RegExp(`required="\\{\\{ filter\\.isIncludesItem\\(requiredList ,'${field}'\\) \\}\\}"`)
new RegExp(`required="\\{\\{ filter\\.isIncludesItem\\(requiredList ,'${field}'\\) \\}\\}"`)
)
)
}
}
for (const [label, field] of [
['车架号( VIN )', 'customer.standNo'],
['车牌号', 'customer.plateNumber']
]) {
const labelIndex = template.indexOf(`label="${label}"`)
const cellStart = template.lastIndexOf('<gl-cell', labelIndex)
const cellEnd = template.indexOf('</gl-cell>', labelIndex)
const cell = template.slice(cellStart, cellEnd + '</gl-cell>'.length)
assert.ok(cell, `missing ${label} input cell`)
assert.doesNotMatch(cell, /\brequired(?:After)?(?:\s|=)/)
assert.match(cell, new RegExp(`data-name="${field.replace('.', '\\.')}"`))
}
})
})
})
})
tabWorkOrder/pages/createOrder/tests/pendingOrderEditEcho.integration.test.mjs
0 → 100644
View file @
d3eb2ee
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
)
const toastMessages = []
globalThis.wx = {
$util: {
showToast(message) {
toastMessages.push(message)
}
}
}
const { RouteContext } = await import(`../routeStrategy.js?edit-echo=${Date.now()}`)
function createRoutePage() {
const setOrderObjCalls = []
const page = {
data: {
orderObj: {
lowPriceFlag: 1,
merchantId: 'LIST-SHOP',
merchantName: '列表摘要门店',
sellerMerchantId: 'LOGIN-PARK',
sellerMerchantName: '广联数科(内部使用)'
},
orderTypeList: [{ value: 1, text: '低价订单' }],
tipsProps: {},
isAlreadyExistOrder: false
},
setData(patch, callback) {
Object.assign(this.data, patch)
callback?.()
},
setOrderObj(orderObj, options) {
setOrderObjCalls.push({ orderObj, options })
},
getSetting() {}
}
return { page, setOrderObjCalls }
}
test('待跟进低价单使用含套餐详情并将完整商品交给编辑回显', async () => {
const requests = []
const detail = {
orderCode: '260702144042889',
lowPriceFlag: 1,
merchantId: 'DETAIL-SHOP',
merchantName: '波波的单店门店',
sellerMerchantId: 'FLOW-PARK',
sellerMerchantName: '流程测试园区门店',
sellerUserId: 'ZHOU',
sellerName: '周大虾',
customer: {},
subOrderList: [{ merchantGoodsId: 'GOODS-1' }],
packageGoodsList: [
{
packageCode: 'PACKAGE-1',
packageGoodsOrderList: [{ merchantGoodsId: 'GOODS-2' }]
}
]
}
globalThis.__WORK_ORDER_MOCK_API__ = {
getPackageGoodsDetail(payload) {
requests.push(payload)
return { code: 0, data: detail }
}
}
const { page, setOrderObjCalls } = createRoutePage()
await new RouteContext(page).execute({
orderCode: detail.orderCode,
page: 'edit',
lowPriceFlag: 1,
merchantId: 'LIST-SHOP',
sellerMerchantId: 'LOGIN-PARK',
sellerMerchantName: '广联数科(内部使用)'
})
assert.deepEqual(requests, [{ orderCode: detail.orderCode }])
assert.equal(setOrderObjCalls.length, 1)
assert.equal(setOrderObjCalls[0].orderObj, detail)
assert.deepEqual(setOrderObjCalls[0].options, { authoritativeDetail: true })
assert.deepEqual(setOrderObjCalls[0].orderObj.subOrderList, detail.subOrderList)
assert.deepEqual(
setOrderObjCalls[0].orderObj.packageGoodsList,
detail.packageGoodsList
)
assert.deepEqual(toastMessages, [])
delete globalThis.__WORK_ORDER_MOCK_API__
})
test('详情加载失败时不用列表摘要渲染可提交表单', async () => {
globalThis.__WORK_ORDER_MOCK_API__ = {
getPackageGoodsDetail() {
return { code: 500, message: '详情加载失败' }
}
}
const { page, setOrderObjCalls } = createRoutePage()
await new RouteContext(page).execute({
orderCode: 'FAILED-ORDER',
page: 'edit',
lowPriceFlag: 1,
merchantId: 'LIST-SHOP'
})
assert.equal(setOrderObjCalls.length, 0)
assert.equal(page.data.flag, undefined)
assert.equal(toastMessages.at(-1), '详情加载失败')
delete globalThis.__WORK_ORDER_MOCK_API__
})
tests/work-order-migration/confirm-order-wechat-action.test.mjs
0 → 100644
View file @
d3eb2ee
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { describe, it } from 'node:test'
const template = readFileSync(
new URL(
'../../tabWorkOrder/pages/confirmOrder/confirmOrder.wxml',
import.meta.url
),
'utf8'
)
const styles = readFileSync(
new URL(
'../../tabWorkOrder/pages/confirmOrder/confirmOrder.wxss',
import.meta.url
),
'utf8'
)
describe('confirmOrder confirmation action', () => {
it('always renders exactly one confirmation action independent of payment type and role', () => {
const confirmationActions = template.match(/bindtap="next"/g) || []
assert.equal(confirmationActions.length, 1)
assert.match(template, /<view class="btn-box confirm-btn/)
const footer = template.slice(template.indexOf('<view class="btn-box confirm-btn'))
assert.doesNotMatch(footer, /wx:if="\{\{ orderInfo\.selectPayType/)
assert.doesNotMatch(
footer,
/wx:if="\{\{ !perm\.hasPermission\.isSuper\(userInfo\)/
)
})
it('keeps order editing inside the original operator permission gate', () => {
assert.match(
template,
/<block wx:if="\{\{ orderInfo\.status == 1 && !perm\.hasPermission\.isSuper\(userInfo\) && userInfo\.userType == 2 \}\}">\s*<view class="btn text-center change" bindtap="edit">修改<\/view>/
)
assert.equal((template.match(/bindtap="edit"/g) || []).length, 1)
})
it('reserves the bottom safe area and renders a lone action full width', () => {
assert.match(template, /isFullSucreen \? 'isFullSucreenCom' : ''/)
assert.match(
styles,
/\.confirm-btn \.single-confirm-btn \{\s*width: calc\(100% - var\(--fontSize64\)\);\s*\}/
)
})
})
tests/work-order-migration/fixed-user-info-mock.test.mjs
deleted
100644 → 0
View file @
433f663
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { describe, it } from 'node:test'
async function loadOptionalModule(relativePath) {
try {
return await import(relativePath)
} catch (error) {
if (error?.code === 'ERR_MODULE_NOT_FOUND') return null
throw error
}
}
describe('登录迁移前的固定用户模拟', async () => {
const fixedUserMock = await loadOptionalModule(
'../../utils/fixedUserInfoMock.js'
)
it('忽略旧缓存并返回需求指定的固定用户', () => {
assert.equal(
typeof fixedUserMock?.resolveRuntimeUserInfo,
'function',
'尚未实现 resolveRuntimeUserInfo'
)
const userInfo = fixedUserMock.resolveRuntimeUserInfo(() => {
throw new Error('固定用户模式不应读取登录缓存')
})
assert.ok(userInfo.accountName === '18372203315')
assert.equal(userInfo.merchantId, 44211025)
assert.equal(userInfo.shopMerchantId, 44210895)
assert.equal(userInfo.sceneType, 1)
assert.equal(userInfo.subLoginUser.sceneType, 7)
assert.equal(userInfo.subLoginUser.subLoginUser, null)
assert.equal(userInfo._perm.isNormalStaff, true)
assert.equal(userInfo.default4SStoreInfo.merchantId, 44210895)
})
it('每次读取都返回互不影响的用户副本', () => {
assert.equal(
typeof fixedUserMock?.resolveRuntimeUserInfo,
'function',
'尚未实现 resolveRuntimeUserInfo'
)
const first = fixedUserMock.resolveRuntimeUserInfo(() => null)
const second = fixedUserMock.resolveRuntimeUserInfo(() => null)
first.subLoginUser.sceneType = 0
first._perm.isNormalStaff = false
assert.equal(second.subLoginUser.sceneType, 7)
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),
'utf8'
)
assert.equal('resolveRuntimeSessionId' in fixedUserMock, false)
assert.match(
utilSource,
/const getSessionId = \(\) => \{\s*return wx\.getStorageSync\('dj_boutique_sessionId'\)\s*\}/
)
assert.doesNotMatch(utilSource, /resolveRuntimeSessionId/)
})
it('启动时把独立副本写入旧缓存和新缓存', () => {
assert.equal(
typeof fixedUserMock?.installFixedUserInfoMock,
'function',
'尚未实现 installFixedUserInfoMock'
)
let legacyUser
let currentUser
const installedUser = fixedUserMock.installFixedUserInfoMock({
setLegacyUserInfo(value) {
legacyUser = value
},
setCurrentUserInfo(value) {
currentUser = value
},
setLegacySessionId() {},
setCurrentSessionId() {}
})
assert.deepEqual(legacyUser, installedUser)
assert.deepEqual(currentUser, installedUser)
assert.notEqual(legacyUser, currentUser)
assert.notEqual(legacyUser, installedUser)
assert.notEqual(currentUser, installedUser)
legacyUser.subLoginUser.sceneType = 0
assert.equal(currentUser.subLoginUser.sceneType, 7)
assert.equal(installedUser.subLoginUser.sceneType, 7)
})
it('启动固定用户模拟不会覆盖旧缓存和新缓存中的系统 sessionId', () => {
const sessionWrites = []
fixedUserMock.installFixedUserInfoMock({
setLegacyUserInfo() {},
setCurrentUserInfo() {},
setLegacySessionId(value) {
sessionWrites.push(['legacy', value])
},
setCurrentSessionId(value) {
sessionWrites.push(['current', value])
}
})
assert.deepEqual(sessionWrites, [])
})
})
tests/work-order-migration/low-price-order-flow.test.mjs
View file @
d3eb2ee
...
@@ -15,8 +15,7 @@ import {
...
@@ -15,8 +15,7 @@ import {
import {
import {
applyLowPriceDefaultScene,
applyLowPriceDefaultScene,
buildLowPriceOrderPatch,
buildLowPriceOrderPatch,
mergeLowPriceOrderContext,
mergeLowPriceOrderContext
restoreFixedLowPriceEntryContext
} from '../../tabWorkOrder/pages/createOrder/services/lowPriceOrderContext.helpers.js'
} from '../../tabWorkOrder/pages/createOrder/services/lowPriceOrderContext.helpers.js'
import { resolveDirectWorkOrderAction } from '../../pages/tab/workspace/services/workOrderEntry.helpers.js'
import { resolveDirectWorkOrderAction } from '../../pages/tab/workspace/services/workOrderEntry.helpers.js'
register(
register(
...
@@ -340,55 +339,6 @@ describe('创建页低价单上下文', () => {
...
@@ -340,55 +339,6 @@ describe('创建页低价单上下文', () => {
assert.equal(applyLowPriceDefaultScene(orderObj), orderObj)
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('工作台低价单直达参数', () => {
describe('工作台低价单直达参数', () => {
...
...
tests/work-order-migration/real-login-user-info.test.mjs
0 → 100644
View file @
d3eb2ee
import assert from 'node:assert/strict'
import { register } from 'node:module'
import { beforeEach, describe, it } from 'node:test'
register('./shims/real-login-loader.mjs', import.meta.url)
const storage = new Map()
let appConfig
globalThis.__REAL_LOGIN_STORAGE_WRITES__ = []
globalThis.App = config => {
appConfig = config
}
globalThis.wx = {
getStorageSync(key) {
return storage.get(key) || ''
},
setStorageSync(key, value) {
storage.set(key, value)
globalThis.__REAL_LOGIN_STORAGE_WRITES__.push([key, value])
},
getSystemInfoSync() {
return { statusBarHeight: 0 }
}
}
const util = (await import(`../../utils/util.js?real-login=${Date.now()}`)).default
await import(`../../app.js?real-login=${Date.now()}`)
describe('真实登录用户上下文', () => {
beforeEach(() => {
storage.clear()
globalThis.__REAL_LOGIN_STORAGE_WRITES__.length = 0
})
it('未登录且没有用户缓存时返回 null', () => {
assert.equal(util.getUserInfo(), null)
})
it('登录后返回接口写入缓存的实际用户', () => {
const loggedInUser = {
accountName: 'real-account',
uuid: 'real-user-uuid',
merchantId: 10001
}
storage.set('dj_boutique_user_info', JSON.stringify(loggedInUser))
assert.deepEqual(util.getUserInfo(), loggedInUser)
})
it('小程序启动时不提前写入任何用户身份', () => {
appConfig.onLaunch()
const userWrites = globalThis.__REAL_LOGIN_STORAGE_WRITES__.filter(
([key]) => key === 'dj_boutique_user_info' || key === 'userInfo'
)
assert.deepEqual(userWrites, [])
})
})
tests/work-order-migration/shims/mock-api.mjs
View file @
d3eb2ee
...
@@ -43,6 +43,12 @@ export default {
...
@@ -43,6 +43,12 @@ export default {
data: []
data: []
})
})
},
},
getPackageGoodsDetail(data) {
return configuredResponse('getPackageGoodsDetail', data, {
code: 0,
data: {}
})
},
getEmployeeList(data) {
getEmployeeList(data) {
return configuredResponse('getEmployeeList', data, {
return configuredResponse('getEmployeeList', data, {
code: 0,
code: 0,
...
...
tests/work-order-migration/shims/real-login-dependencies.mjs
0 → 100644
View file @
d3eb2ee
function defaultDependency() {
return { captureException() {} }
}
export default defaultDependency
export class Storage {
set(key, value) {
globalThis.__REAL_LOGIN_STORAGE_WRITES__?.push([key, value])
}
}
export class Version {}
export class Track {}
export const areaList = {}
export const hasPermission = {}
export const LOGIN_ROLE = {}
export function createPermissionHelpers() {
return {}
}
export function setSystem_info() {}
export function removeSystemStorage() {}
export function rmNoSignInUuid() {}
export function getNoSignInUuid() {
return ''
}
export function checkYqdSuper() {}
export function checkScene() {
return false
}
tests/work-order-migration/shims/real-login-loader.mjs
0 → 100644
View file @
d3eb2ee
import path from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
const shimDir = path.dirname(fileURLToPath(import.meta.url))
const dependencyUrl = pathToFileURL(
path.join(shimDir, 'real-login-dependencies.mjs')
).href
export async function resolve(specifier, context, nextResolve) {
const parentUrl = context.parentURL || ''
const isApp = /\/app\.js(?:\?|$)/.test(parentUrl)
const isUtil = /\/utils\/util\.js(?:\?|$)/.test(parentUrl)
if (isApp && specifier === './utils/util.js') {
return nextResolve(specifier, context)
}
if (isApp || isUtil) {
return { shortCircuit: true, url: dependencyUrl }
}
return nextResolve(specifier, context)
}
utils/fixedUserInfoMock.js
deleted
100644 → 0
View file @
433f663
export
const
FIXED_USER_INFO_MOCK_ENABLED
=
true
const
FIXED_USER_INFO
=
{
accountName
:
'18372203315'
,
merchantId
:
44211025
,
accountLevel
:
4
,
userType
:
2
,
phone
:
'18372203315'
,
name
:
'0523ymt'
,
duty
:
null
,
merchantName
:
'流程测试园区门店'
,
channelType
:
2
,
isSuper
:
false
,
uuid
:
'6825aaebf4f04f6a8a4c3d5a9b26c914'
,
createdDate
:
'2023-09-19 18:25:40'
,
permissionMerchantIds
:
[
44211025
],
subLoginUser
:
{
accountName
:
'18372203315'
,
merchantId
:
44211025
,
accountLevel
:
4
,
userType
:
2
,
phone
:
'18372203315'
,
name
:
'0523ymt'
,
duty
:
null
,
merchantName
:
'流程测试园区门店'
,
channelType
:
2
,
isSuper
:
false
,
uuid
:
'6825aaebf4f04f6a8a4c3d5a9b26c914'
,
createdDate
:
'2023-09-19 18:25:40'
,
permissionMerchantIds
:
[
44211025
],
subLoginUser
:
null
,
merchantAccountList
:
[
'6'
],
loginRole
:
null
,
shopMerchantId
:
44210895
,
shopMerchantName
:
'波波的单店门店'
,
sceneType
:
7
,
loginRoleOnSelectMerchant
:
null
,
bussinessId
:
7838
},
merchantAccountList
:
[
'6'
],
loginRole
:
null
,
shopMerchantId
:
44210895
,
shopMerchantName
:
'波波的单店门店'
,
sceneType
:
1
,
loginRoleOnSelectMerchant
:
null
,
bussinessId
:
7838
,
_perm
:
{
isSuper
:
false
,
canSelectMultiStore
:
false
,
canSelectMultiStoreForStaffDaily
:
false
,
canSkipValidation
:
false
,
canViewViolation
:
false
,
staffAbled
:
false
,
canViewMentorship
:
false
,
canViewRecruit
:
false
,
canSelectMultiStoreWithTechnician
:
false
,
isNotMentor
:
true
,
isNotTechnician
:
true
,
isTechnician
:
false
,
isNormalStaff
:
true
},
isLog
:
true
,
default4SStoreInfo
:
{
merchantId
:
44210895
,
merchantName
:
'波波的单店门店'
},
default4SStoreInfo_crowdFunding
:
{
merchantId
:
44210895
,
merchantName
:
'波波的单店门店'
},
default4SStoreInfo_newCarConversion
:
{
merchantId
:
44210895
,
merchantName
:
'波波的单店门店'
}
}
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
()
}
export
function
installFixedUserInfoMock
({
setLegacyUserInfo
,
setCurrentUserInfo
})
{
if
(
!
FIXED_USER_INFO_MOCK_ENABLED
)
return
null
const
installedUser
=
createFixedUserInfo
()
setLegacyUserInfo
(
createFixedUserInfo
())
setCurrentUserInfo
(
createFixedUserInfo
())
return
installedUser
}
utils/util.js
View file @
d3eb2ee
...
@@ -6,9 +6,6 @@ import $router from '../router/index'
...
@@ -6,9 +6,6 @@ import $router from '../router/index'
import
{
import
{
Storage
Storage
}
from
'~/utils/cache/storage'
}
from
'~/utils/cache/storage'
import
{
resolveRuntimeUserInfo
}
from
'./fixedUserInfoMock.js'
const
$Storage
=
new
Storage
()
const
$Storage
=
new
Storage
()
/**emoji正则 */
/**emoji正则 */
const
emojiReg
=
/
([^\u
0020-
\u
007E
\u
00A0-
\u
00BE
\u
2E80-
\u
A4CF
\u
F900-
\u
FAFF
\u
FE30-
\u
FE4F
\u
FF00-
\u
FFEF
\u
0080-
\u
009F
\u
2000-
\u
201f
\u
2026
\u
2022
\u
20ac
])
/g
const
emojiReg
=
/
([^\u
0020-
\u
007E
\u
00A0-
\u
00BE
\u
2E80-
\u
A4CF
\u
F900-
\u
FAFF
\u
FE30-
\u
FE4F
\u
FF00-
\u
FFEF
\u
0080-
\u
009F
\u
2000-
\u
201f
\u
2026
\u
2022
\u
20ac
])
/g
...
@@ -98,10 +95,8 @@ const promise = callBack => {
...
@@ -98,10 +95,8 @@ const promise = callBack => {
}
}
const
getUserInfo
=
()
=>
{
const
getUserInfo
=
()
=>
{
return
resolveRuntimeUserInfo
(()
=>
{
const
user
=
wx
.
getStorageSync
(
'dj_boutique_user_info'
)
||
null
const
user
=
wx
.
getStorageSync
(
'dj_boutique_user_info'
)
||
null
return
JSON
.
parse
(
user
)
return
JSON
.
parse
(
user
)
})
}
}
const
removeSellerInfo
=
()
=>
{
const
removeSellerInfo
=
()
=>
{
wx
.
removeStorageSync
(
'dj_boutique_seller_info'
)
wx
.
removeStorageSync
(
'dj_boutique_seller_info'
)
...
...
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