Commit bf5016f0 by 张立顺

feat 异常审批接口对接

1 parent 5b5f6b56
// components/orderPromptPop/orderPromptPop.js
const FULL_PAY_TYPE_LIST = [
{
label: '收款方为门店收款',
value: '3'
},
{
label: '收款方为嘀加且属于对公转账收款',
value: '4'
},
{
label: '收款方为嘀加二维码收款',
value: '5',
tips: '适用于已有交易收款流水需补录订单时'
},
{
label: '特殊收款',
value: '6',
tips: '仅用于无法关联流水或混合支付场景,请谨慎选择。'
}
]
const DJ_QR_ONLY_PAY_TYPE_LIST = FULL_PAY_TYPE_LIST.filter(item => item.value === '5')
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean
type: Boolean,
observer(n) {
if (n) {
this.applyDjQrOnlyPresentation(this.properties.djQrOnlyMode)
}
}
},
/** 异常流水锁单态:仅允许嘀加二维码收款 */
djQrOnlyMode: {
type: Boolean,
value: false,
observer(n) {
if (this.data.show) {
this.applyDjQrOnlyPresentation(n)
}
}
},
popupSlotStyle: {
type: String,
......@@ -23,6 +61,7 @@ Component({
type: Object,
value: {},
observer: function (v) {
if (this.properties.djQrOnlyMode) return
// 是否是扫码核销或再次下单,是的话不显示补录入口
if (Object.keys(v)?.length) {
let { payTypeList } = this.data
......@@ -47,33 +86,36 @@ Component({
*/
data: {
infoData: {},
payTypeList: [
{
label: '收款方为门店收款',
value: '3'
},
{
label: '收款方为嘀加且属于对公转账收款',
value: '4'
},
{
label: '收款方为嘀加二维码收款',
value: '5',
tips: '适用于已有交易收款流水需补录订单时'
},
{
label: '特殊收款',
value: '6',
tips: '仅用于无法关联流水或混合支付场景,请谨慎选择。'
}
]
payTypeList: FULL_PAY_TYPE_LIST.map(item => ({ ...item }))
},
/**
* 组件的方法列表
*/
methods: {
/**
* 锁单态仅展示嘀加二维码,并预选已支付 + 嘀加二维码
* @param {boolean} djQrOnlyMode
*/
applyDjQrOnlyPresentation(djQrOnlyMode) {
if (djQrOnlyMode) {
this.setData({
payTypeList: DJ_QR_ONLY_PAY_TYPE_LIST.map(item => ({ ...item })),
includesChildHeight: 'var(--fontSize870)',
infoData: { payFlag: '2', payType: '5' }
})
return
}
this.setData({
payTypeList: FULL_PAY_TYPE_LIST.map(item => ({ ...item })),
includesChildHeight: 'var(--fontSize1020)',
infoData: {}
})
},
chooseParent(e) {
if (this.properties.djQrOnlyMode) {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
let { type } = e.currentTarget.dataset
this.setData({
'infoData.payFlag': type
......@@ -81,6 +123,9 @@ Component({
},
chooseChild(e) {
let { type } = e.currentTarget.dataset
if (this.properties.djQrOnlyMode && String(type) !== '5') {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
this.setData({
'infoData.payType': type
})
......@@ -90,6 +135,10 @@ Component({
},
confirm() {
let { infoData } = this.data
const { djQrOnlyMode } = this.properties
if (djQrOnlyMode && String(infoData.payType) !== '5') {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
if (!infoData.payFlag || (infoData.payFlag == 2 && !infoData.payType)) {
return wx.$util.showToast('请选择订单收款方式')
}
......
......@@ -4,7 +4,7 @@
<view>确认订单收款方式</view>
</view>
<view class="prompt_content">
<view class="select_item">
<view class="select_item" wx:if="{{ !djQrOnlyMode }}">
<block wx:if="{{infoData.payFlag == 1}}">
<image class="radio-icon" src="/components/images/radio.png" />
</block>
......
......@@ -19,6 +19,7 @@ import { trackDynamicFormMenuEntry } from '../../utils/dynamicFormMenus.js'
import { SCENE_TYPE } from './constants.js'
import { resolveActionType } from './resolveActionType.js'
import { openWorkReportTemp } from './workReportHandler.js'
import { openOrderPromptWithRestrictState } from '../../tabIndex/services/newOrderAbnormalFlowRestrict.service.js'
export { resolveActionType }
......@@ -86,7 +87,7 @@ export function createEquityMenuJumpHandler(page) {
) {
return
}
page.setData({ showPromptDialog: true })
await openOrderPromptWithRestrictState(page)
},
defeatOrder: async (item, ctx) => {
const { merchantBrand } = ctx
......
/**
* 新建工单弹窗确认/取消(与 jumpHandlers create_order 对称)
*/
import { checkAbnormalFlowLock } from '../../store/ModalToQueueControl.js'
import { confirmOrderPrompt } from '../../tabIndex/services/orderPromptConfirm.service.js'
/**
* @param {Object} pageCtx - index Component 实例
* @param {Object} detail - order-prompt-popup confirm 事件 detail
*/
export async function handleOrderPromptConfirm(pageCtx, detail = {}) {
const { payFlag, payType } = detail
const { mode } = pageCtx.data
const { mode, orderPromptDjQrOnlyMode } = pageCtx.data
const thisPage = wx.$router.getPageInstance()
const paymentMethod = payFlag != 2 ? 1 : payType
if (payFlag == 1 || payType == 3 || payType == 4 || payType == 6) {
const flowLocked = await checkAbnormalFlowLock({ paymentMethod })
if (flowLocked) return
wx.$router.go(mode ? 'createOrderCarQuotationSimple' : 'createOrderCarQuotation', {
paymentMethod
})
} else {
thisPage.tipsEvent && thisPage.tipsEvent()
}
await confirmOrderPrompt(
detail,
{
onNavigateCreate: paymentMethod => {
wx.$router.go(
mode ? 'createOrderCarQuotationSimple' : 'createOrderCarQuotation',
{ paymentMethod }
)
},
onOpenRecordingPopup: () => {
thisPage.tipsEvent && thisPage.tipsEvent()
}
},
orderPromptDjQrOnlyMode
)
const paymentMethod = detail.payFlag != 2 ? 1 : detail.payType
thisPage.setData({ paymentMethod })
}
......
......@@ -91,7 +91,7 @@
<tips-bottom style="width: 100%;box-sizing: border-box;" tipsProps="{{ tipsPropsConfig }}" beforeClick="inspectionOfProhibitionBill" />
</view> -->
<!-- 异常流水吸底提醒(仅首页 Tab) -->
<view class="abnormal-flow-tip-wrap" wx:if="{{ abnormalFlowTips.show && tabIndex === 0 }}">
<view class="abnormal-flow-tip-wrap" wx:if="{{ abnormalFlowTips.show && tabIndex == 0 }}">
<abnormal-flow-tips
show="{{ abnormalFlowTips.show }}"
count="{{ abnormalFlowTips.count }}"
......
......@@ -84,9 +84,9 @@
position: fixed;
left: 0;
width: 100%;
bottom: calc(var(--fontSize100) + env(safe-area-inset-bottom));
bottom: calc(var(--fontSize100) + constant(safe-area-inset-bottom));
z-index: 10;
bottom: calc(var(--fontSize100) + env(safe-area-inset-bottom));
z-index: 100;
box-sizing: border-box;
}
.waitOrderCon {
......
// packageEquity/pages/beforeCreate/beforeCreate.js
import { getSystemInfo as fetchSystemInfo } from '~/utils/systemInfo'
import { openOrderPromptWithRestrictState } from '~/tabIndex/services/newOrderAbnormalFlowRestrict.service.js'
import { confirmOrderPrompt } from '~/tabIndex/services/orderPromptConfirm.service.js'
Page({
/**
* 页面的初始数据
*/
data: {
tipsProps: false,
paymentMethod: null
paymentMethod: null,
orderPromptDjQrOnlyMode: false
},
/**
......@@ -45,26 +49,28 @@ Page({
deviceOrientation: e.deviceOrientation,
});
},
jump() {
this.setData({
showPromptDialog: true
})
async jump() {
await openOrderPromptWithRestrictState(this)
},
promptHandleConfirm(e) {
let { payFlag, payType } = e.detail
let { mode } = this.data
let paymentMethod = payFlag != 2 ? 1 : payType
if (payFlag == 1 || payType == 3 || payType == 4 || payType == 6) {
wx.$router.go(
mode ? "createOrderCarQuotationSimple" : "createOrderCarQuotation",
{paymentMethod}
);
} else {
this.tipsEvent()
}
this.setData({
paymentMethod
})
async promptHandleConfirm(e) {
const { mode, orderPromptDjQrOnlyMode } = this.data
await confirmOrderPrompt(
e.detail,
{
onNavigateCreate: paymentMethod => {
wx.$router.go(
mode ? 'createOrderCarQuotationSimple' : 'createOrderCarQuotation',
{ paymentMethod }
)
},
onOpenRecordingPopup: () => {
this.tipsEvent()
}
},
orderPromptDjQrOnlyMode
)
const paymentMethod = e.detail.payFlag != 2 ? 1 : e.detail.payType
this.setData({ paymentMethod })
},
promptCancel() {
this.setData({
......
......@@ -15,5 +15,5 @@
</view>
<record-list model:showPopup="{{showPopup}}" deviceOrientation="{{deviceOrientation}}" mode="{{mode}}"></record-list>
<order-prompt-popup wx:if="{{ showPromptDialog }}" show="{{ showPromptDialog }}" bindconfirm="promptHandleConfirm" bindcancel="promptCancel" popupSlotStyle="height: calc(100% - var(--fontSize160));" height="var(--fontSize540);" includesChildHeight="var(--fontSize1060);"></order-prompt-popup>
<order-prompt-popup wx:if="{{ showPromptDialog }}" show="{{ showPromptDialog }}" bindconfirm="promptHandleConfirm" bindcancel="promptCancel" popupSlotStyle="height: calc(100% - var(--fontSize160));" height="var(--fontSize540);" includesChildHeight="var(--fontSize1060);" dj-qr-only-mode="{{ orderPromptDjQrOnlyMode }}"></order-prompt-popup>
<order-no-popup wx:if="{{ tipsProps }}" show="{{ tipsProps }}" title="请选择交易参考号" bind:success="navigator" orderNoList="{{ orderNoList }}" />
\ No newline at end of file
......@@ -26,6 +26,8 @@ const IMG_URL2 = ImgUrl + '/';
import carLifeApi from "../../../carEquityApi";
import commonApi from "~/api/api";
import { withTabRefreshInFlight } from "../../../services/tabRefreshService.js";
import { openOrderPromptWithRestrictState } from "~/tabIndex/services/newOrderAbnormalFlowRestrict.service.js";
import { confirmOrderPrompt } from "~/tabIndex/services/orderPromptConfirm.service.js";
function getSceneNameForQuotationItem(item) {
if (!item) return "";
......@@ -347,23 +349,28 @@ Component({
// showPromptDialog: true
// })
// }
this.setData({
showPromptDialog: true,
});
await openOrderPromptWithRestrictState(this);
},
promptHandleConfirm(e) {
let { payFlag, payType } = e.detail;
let { mode } = this.data;
let thisPage = wx.$router.getPageInstance();
let paymentMethod = payFlag != 2 ? 1 : payType;
if (payFlag == 1 || payType == 3 || payType == 4 || payType == 6) {
wx.$router.go(mode ? "createOrderCarQuotationSimple" : "createOrderCarQuotation", { paymentMethod });
} else {
thisPage.tipsEvent && thisPage.tipsEvent();
}
thisPage.setData({
paymentMethod,
});
async promptHandleConfirm(e) {
const { mode, orderPromptDjQrOnlyMode } = this.data;
const thisPage = wx.$router.getPageInstance();
await confirmOrderPrompt(
e.detail,
{
onNavigateCreate: paymentMethod => {
wx.$router.go(
mode ? "createOrderCarQuotationSimple" : "createOrderCarQuotation",
{ paymentMethod }
);
},
onOpenRecordingPopup: () => {
thisPage.tipsEvent && thisPage.tipsEvent();
},
},
orderPromptDjQrOnlyMode
);
const paymentMethod = e.detail.payFlag != 2 ? 1 : e.detail.payType;
thisPage.setData({ paymentMethod });
},
promptCancel() {
this.setData({
......
......@@ -471,4 +471,5 @@
popupSlotStyle="height: calc(100% - var(--fontSize160));"
height="var(--fontSize540);"
includesChildHeight="var(--fontSize1060);"
dj-qr-only-mode="{{ orderPromptDjQrOnlyMode }}"
></order-prompt-popup>
\ No newline at end of file
......@@ -40,6 +40,7 @@ import {
buildHomeRefreshFingerprint,
withHomeRefreshDedup
} from '../../services/homeRefreshService.js'
import { openOrderPromptWithRestrictState } from '../../../tabIndex/services/newOrderAbnormalFlowRestrict.service.js'
import {
buildEquityMenusAsync,
createEquityMenuJumpHandler,
......@@ -434,7 +435,7 @@ Component({
}
})
},
onTodoGoto(e) {
async onTodoGoto(e) {
const action = resolveTodoGotoAction(e.detail.id, {
mode: this.data.mode,
merchantBrand: this.data.merchantBrand
......@@ -446,7 +447,7 @@ Component({
}
wx.$router.go(action.route, action.params)
} else if (action.type === 'showPromptDialog') {
this.setData({ showPromptDialog: true })
await openOrderPromptWithRestrictState(this)
}
},
onTodoPackup() {
......
......@@ -73,7 +73,8 @@
bindcancel="promptCancel"
popupSlotStyle="height: calc(100% - var(--fontSize160));"
height="var(--fontSize540);"
includesChildHeight="var(--fontSize1020);"></order-prompt-popup>
includesChildHeight="var(--fontSize1020);"
dj-qr-only-mode="{{ orderPromptDjQrOnlyMode }}"></order-prompt-popup>
<report-template-popup show="{{ showReportPopup }}"
templateList="{{ reportTemplateList }}"
bind:cancel="onReportPopupCancel"
......
......@@ -9,6 +9,8 @@ import {
checkStudyTask,
checkOrderLockGate
} from '~/store/ModalToQueueControl'
import { openOrderPromptWithRestrictState } from '~/tabIndex/services/newOrderAbnormalFlowRestrict.service.js'
import { confirmOrderPrompt } from '~/tabIndex/services/orderPromptConfirm.service.js'
import commonApi from '~/api/api'
import { normalizeMarketingFlagOnItem } from '~/utils/marketingFlag'
Page({
......@@ -164,8 +166,7 @@ Page({
if (await wx.$globalDataFunction.inspectionOfProhibitionBill())
return
if (scan) {
this.setData({
showPromptDialog: true,
await openOrderPromptWithRestrictState(this, {
sceneObj: scene
})
} else {
......@@ -287,10 +288,7 @@ Page({
return /**禁止提单 */
// 点击的新增工单做下单引导
if (flag == 'new') {
this.setData({
showPromptDialog: true,
sceneObj: {}
})
await openOrderPromptWithRestrictState(this, { sceneObj: {} })
return
}
// 是微信支付直接跳转确认页面
......@@ -315,22 +313,27 @@ Page({
wx.$router.go('tabWorkOrder.' + name, item)
}
},
promptHandleConfirm(e) {
let { payFlag, payType } = e.detail
let paymentMethod = payFlag != 2 ? 1 : payType
let { sceneObj } = this.data
if (payFlag == 1 || payType == 3 || payType == 4 || payType == 6) {
let params = { paymentMethod }
if (Object.keys(sceneObj)?.length) {
params.scene = sceneObj
}
wx.$router.go('tabWorkOrder.createOrder', params)
} else {
this.tipsEvent()
}
this.setData({
paymentMethod
})
async promptHandleConfirm(e) {
const { sceneObj, orderPromptDjQrOnlyMode } = this.data
await confirmOrderPrompt(
e.detail,
{
onNavigateCreate: paymentMethod => {
const params = { paymentMethod }
if (Object.keys(sceneObj || {})?.length) {
params.scene = sceneObj
}
wx.$router.go('tabWorkOrder.createOrder', params)
},
onOpenRecordingPopup: () => {
this.tipsEvent()
}
},
orderPromptDjQrOnlyMode
)
const paymentMethod =
e.detail.payFlag != 2 ? 1 : e.detail.payType
this.setData({ paymentMethod })
},
promptCancel() {
this.setData({
......
......@@ -235,5 +235,5 @@
</view>
</modal>
<recording-order-popup wx:if="{{ showOrderpop }}" show="{{ showOrderpop }}" bind:success="navigator" title="请选择交易参考号" />
<order-prompt-popup wx:if="{{ showPromptDialog }}" show="{{ showPromptDialog }}" bindcancel="promptCancel" bindconfirm="promptHandleConfirm" sceneObj="{{ sceneObj }}"></order-prompt-popup>
<order-prompt-popup wx:if="{{ showPromptDialog }}" show="{{ showPromptDialog }}" bindcancel="promptCancel" bindconfirm="promptHandleConfirm" sceneObj="{{ sceneObj }}" dj-qr-only-mode="{{ orderPromptDjQrOnlyMode }}"></order-prompt-popup>
<study-permission-modal id="customModal" />
\ No newline at end of file
......@@ -7,6 +7,8 @@ import {
checkStudyTask,
checkOrderLockGate
} from '~/store/ModalToQueueControl'
import { openOrderPromptWithRestrictState } from '~/tabIndex/services/newOrderAbnormalFlowRestrict.service.js'
import { confirmOrderPrompt } from '~/tabIndex/services/orderPromptConfirm.service.js'
const app = getApp()
const IMG_URL =
'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
......@@ -110,18 +112,11 @@ Page({
show: true,
title: '请选择录单入口',
tabTitleShow: false,
success: res => {
success: async res => {
// 跳转新增订单页面 并带特定参数
let { selectType } = this.data
if (selectType == 1) {
// wx.$router.go("tabWorkOrder.createOrder", {
// scene,
// ...item,
// });
this.setData({
showPromptDialog: true,
sceneObj: item
})
await openOrderPromptWithRestrictState(this, { sceneObj: item })
} else {
console.log(
{
......@@ -140,22 +135,25 @@ Page({
'#modal2'
)
},
promptHandleConfirm(e) {
let { payFlag, payType } = e.detail
let { sceneObj } = this.data
let paymentMethod = payFlag != 2 ? 1 : payType
if (payFlag == 1 || payType == 3 || payType == 4 || payType == 6) {
let params = {
paymentMethod,
...sceneObj
}
wx.$router.go('tabWorkOrder.createOrder', params)
} else {
this.tipsEvent()
}
this.setData({
paymentMethod
})
async promptHandleConfirm(e) {
const { sceneObj, orderPromptDjQrOnlyMode } = this.data
await confirmOrderPrompt(
e.detail,
{
onNavigateCreate: paymentMethod => {
wx.$router.go('tabWorkOrder.createOrder', {
paymentMethod,
...sceneObj
})
},
onOpenRecordingPopup: () => {
this.tipsEvent()
}
},
orderPromptDjQrOnlyMode
)
const paymentMethod = e.detail.payFlag != 2 ? 1 : e.detail.payType
this.setData({ paymentMethod })
},
promptCancel() {
this.setData({
......
......@@ -159,5 +159,5 @@
</view>
</view>
</modal>
<order-prompt-popup wx:if="{{ showPromptDialog }}" show="{{ showPromptDialog }}" bindcancel="promptCancel" bindconfirm="promptHandleConfirm" sceneObj="{{sceneObj}}" popupSlotStyle="height: calc(100% - var(--fontSize160));" height="var(--fontSize540);" includesChildHeight="var(--fontSize1060);"></order-prompt-popup>
<order-prompt-popup wx:if="{{ showPromptDialog }}" show="{{ showPromptDialog }}" bindcancel="promptCancel" bindconfirm="promptHandleConfirm" sceneObj="{{sceneObj}}" popupSlotStyle="height: calc(100% - var(--fontSize160));" height="var(--fontSize540);" includesChildHeight="var(--fontSize1060);" dj-qr-only-mode="{{ orderPromptDjQrOnlyMode }}"></order-prompt-popup>
<study-permission-modal id="customModal" />
\ No newline at end of file
......@@ -19,6 +19,7 @@ import {
import { trackDynamicFormMenuEntry } from '../../utils/dynamicFormMenus.js'
import { resolveActionType } from './resolveActionType.js'
import { openWorkReportTemp } from './workReportHandler.js'
import { openOrderPromptWithRestrictState } from '../services/newOrderAbnormalFlowRestrict.service.js'
export { resolveActionType }
......@@ -165,7 +166,7 @@ export function createMenuJumpHandler(page) {
return
}
if (target === 'tabWorkOrder.createOrder') {
page.setData({ showPromptDialog: true, sceneObj: {} })
await openOrderPromptWithRestrictState(page, { sceneObj: {} })
} else {
wx.$router.go(target, { params: routerParams })
}
......
......@@ -14,14 +14,15 @@ import {
import {
checkDailyReport,
checkStudyTask,
checkOrderLockGate,
checkAbnormalFlowLock
checkOrderLockGate
} from '~/store/ModalToQueueControl'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
import {
loadAbnormalFlowTipState,
dismissAbnormalFlowTip
} from '../../services/abnormalFlowTipService.js'
import { openOrderPromptWithRestrictState } from '../../services/newOrderAbnormalFlowRestrict.service.js'
import { confirmOrderPrompt } from '../../services/orderPromptConfirm.service.js'
import { ABNORMAL_FLOW_LOCK_BYPASS } from '~/utils/abnormalFlowLock.helpers.js'
import {
......@@ -103,6 +104,7 @@ Page({
isPad: false,
isWait: false, // 今日待办等:非 canSelectMultiStore 且非技师(loginRole 7)
sceneObj: {},
orderPromptDjQrOnlyMode: false,
showReportPopup: false,
abnormalFlowTips: { show: false, count: 0, tipsText: '' },
reportTemplateList: [],
......@@ -171,7 +173,7 @@ Page({
if (lockCheck) return false
//开单提醒
if (await wx.$globalDataFunction.inspectionOfProhibitionBill()) return
this.setData({ showPromptDialog: true, sceneObj: {} })
await openOrderPromptWithRestrictState(this, { sceneObj: {} })
// wx.$router.go('tabWorkOrder.createOrder')
break
case 4:
......@@ -431,25 +433,26 @@ Page({
return this._menuJump(e)
},
async promptHandleConfirm(e) {
let { payFlag, payType } = e.detail
let { sceneObj } = this.data
let paymentMethod = payFlag != 2 ? 1 : payType
if (payFlag == 1 || payType == 3 || payType == 4 || payType == 6) {
const flowLocked = await checkAbnormalFlowLock({ paymentMethod })
if (flowLocked) return
let params = {
paymentMethod
}
if (Object.keys(sceneObj)?.length) {
params.scene = sceneObj
}
wx.$router.go('tabWorkOrder.createOrder', params)
} else {
this.tipsEvent()
}
this.setData({
paymentMethod
})
const { sceneObj, orderPromptDjQrOnlyMode } = this.data
await confirmOrderPrompt(
e.detail,
{
onNavigateCreate: paymentMethod => {
const params = { paymentMethod }
if (Object.keys(sceneObj || {})?.length) {
params.scene = sceneObj
}
wx.$router.go('tabWorkOrder.createOrder', params)
},
onOpenRecordingPopup: () => {
this.tipsEvent()
}
},
orderPromptDjQrOnlyMode
)
const paymentMethod =
e.detail.payFlag != 2 ? 1 : e.detail.payType
this.setData({ paymentMethod })
},
promptCancel() {
this.setData({
......@@ -472,11 +475,11 @@ Page({
show: true,
title: '请选择录单入口',
tabTitleShow: false,
success: res => {
success: async res => {
// 跳转新增订单页面 并带特定参数
let { selectType } = this.data
if (selectType == 1) {
this.setData({ showPromptDialog: true, sceneObj: scene })
await openOrderPromptWithRestrictState(this, { sceneObj: scene })
} else {
wx.$router.go('tabWorkOrder.defeatOrder', {
scene,
......
......@@ -494,6 +494,7 @@
bindcancel="promptCancel"
bindconfirm="promptHandleConfirm"
sceneObj="{{ sceneObj }}"
dj-qr-only-mode="{{ orderPromptDjQrOnlyMode }}"
></order-prompt-popup>
<study-permission-modal id="customModal" />
<report-template-popup
......
/**
* @file 异常流水首页吸底提醒编排(调 API + setData,供 tabIndex / equityPage 复用)
*/
import commonApi from '~/api/api'
import { waitInputOrderUnionCount } from '~/api/abnormalFlowDeclaration.js'
import {
buildAbnormalFlowTipText,
hasUnprocessedAbnormalFlow,
......@@ -38,7 +38,7 @@ function resolveMerchantId(userInfo) {
}
/**
* onShow 拉取异常流水提醒状态并写入页面(union.count)
* onShow 拉取异常流水提醒(dj.api.smartcarlife.weapp.waitinputorder.union.count)
* @param {Object} page - Page / Component 实例
* @returns {Promise<{ show: boolean, count: number }>}
*/
......@@ -62,8 +62,7 @@ export function loadAbnormalFlowTipState(page) {
return Promise.resolve({ show: false, count: 0 })
}
return commonApi
.waitInputOrderUnionCount()
return waitInputOrderUnionCount()
.then(res => {
const data = res?.data || {}
const count = resolveAbnormalFlowTipCount(data)
......
/**
* @file 新建工单异常流水限制态拉取(调 API,不调 setData)
*/
import {
checkAbnormalFlowShopLock,
waitInputOrderUnionCount
} from '~/api/abnormalFlowDeclaration.js'
import { shouldRestrictNewOrderToDjQrOnly } from '~/utils/abnormalFlowLock.helpers.js'
/**
* 解析门店 id(精品 / 权益字段略有差异)
* @param {Object} userInfo
* @returns {string|number}
*/
function resolveMerchantId(userInfo = {}) {
return (
userInfo.shopMerchantId ||
userInfo.default4SStoreInfo?.merchantId ||
''
)
}
/**
* 拉取新建工单是否仅允许嘀加二维码收款
* @returns {Promise<{ djQrOnlyMode: boolean }>}
*/
export async function loadNewOrderRestrictState() {
const userInfo = wx.$util?.getUserInfo?.() || {}
const merchantId = resolveMerchantId(userInfo)
if (!merchantId) {
return { djQrOnlyMode: false }
}
try {
const [lockRes, countRes] = await Promise.all([
checkAbnormalFlowShopLock({ merchantId }),
waitInputOrderUnionCount()
])
const djQrOnlyMode = shouldRestrictNewOrderToDjQrOnly(
lockRes?.data,
countRes?.data
)
return { djQrOnlyMode }
} catch {
return { djQrOnlyMode: false }
}
}
/**
* 打开新建工单收款弹窗前拉取限制态并 setData
* @param {Object} page - Page / Component 实例
* @param {Object} [patch] - 合并进 setData(如 sceneObj)
* @returns {Promise<{ djQrOnlyMode: boolean }>}
*/
export async function openOrderPromptWithRestrictState(page, patch = {}) {
const { djQrOnlyMode } = await loadNewOrderRestrictState()
page.setData({
showPromptDialog: true,
orderPromptDjQrOnlyMode: djQrOnlyMode,
...patch
})
return { djQrOnlyMode }
}
/**
* @file 新建工单收款弹窗纯函数(无 wx / store 依赖,供单测)
*/
/**
* 从弹窗 detail 解析 paymentMethod(与现网各页一致)
* @param {{ payFlag?: string|number, payType?: string|number }} detail
* @returns {string|number}
*/
export function resolveOrderPromptPaymentMethod(detail = {}) {
const { payFlag, payType } = detail
return payFlag != 2 ? 1 : payType
}
/**
* 是否走嘀加二维码补录弹窗(recordingOrderPopup)
* @param {{ payFlag?: string|number, payType?: string|number }} detail
* @returns {boolean}
*/
export function shouldOpenRecordingOrderPopup(detail = {}) {
const { payFlag, payType } = detail
if (payFlag == 1) return false
return payType == 5
}
/**
* djQrOnlyMode 下是否非法收款选择
* @param {{ payType?: string|number }} detail
* @param {boolean} [djQrOnlyMode]
* @returns {boolean}
*/
export function isInvalidDjQrOnlySelection(detail = {}, djQrOnlyMode = false) {
return djQrOnlyMode && String(detail.payType) !== '5'
}
/**
* @file 新建工单收款方式弹窗确认编排(flow lock + 嘀加二维码补录分支)
*/
import { checkAbnormalFlowLock } from '~/store/ModalToQueueControl.js'
import {
isInvalidDjQrOnlySelection,
shouldOpenRecordingOrderPopup
} from './orderPromptConfirm.helpers.js'
const DJ_QR_RESTRICT_TOAST =
'存在异常流水未处理,请选择嘀加二维码收款'
export {
resolveOrderPromptPaymentMethod,
shouldOpenRecordingOrderPopup,
isInvalidDjQrOnlySelection
} from './orderPromptConfirm.helpers.js'
/**
* order-prompt-popup 确认:锁单态仅允许嘀加二维码;其它路径双保险 flow lock
* @param {Object} detail - { payFlag, payType }
* @param {Object} handlers
* @param {Function} handlers.onNavigateCreate - (paymentMethod) => void | Promise<void>
* @param {Function} handlers.onOpenRecordingPopup - () => void | Promise<void>
* @param {boolean} [djQrOnlyMode=false]
* @returns {Promise<boolean>} false 表示被拦截
*/
export async function confirmOrderPrompt(
detail,
handlers,
djQrOnlyMode = false
) {
const paymentMethod =
detail.payFlag != 2 ? 1 : detail.payType
if (isInvalidDjQrOnlySelection(detail, djQrOnlyMode)) {
wx.$util?.showToast?.(DJ_QR_RESTRICT_TOAST)
return false
}
if (shouldOpenRecordingOrderPopup(detail)) {
await handlers.onOpenRecordingPopup?.()
return true
}
const flowLocked = await checkAbnormalFlowLock({ paymentMethod })
if (flowLocked) return false
await handlers.onNavigateCreate?.(paymentMethod)
return true
}
......@@ -7,6 +7,8 @@ import {
checkStudyTask,
checkOrderLockGate
} from '~/store/ModalToQueueControl'
import { openOrderPromptWithRestrictState } from '~/tabIndex/services/newOrderAbnormalFlowRestrict.service.js'
import { confirmOrderPrompt } from '~/tabIndex/services/orderPromptConfirm.service.js'
import commonApi from '~/api/api'
const IMG_URL =
'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
......@@ -135,7 +137,7 @@ Page({
show: true,
title: '请选择录单入口',
tabTitleShow: false,
success: res => {
success: async res => {
// 跳转新增订单页面 并带特定参数
let { selectTypeOrder } = this.data
console.log(item, 'showSelectType')
......@@ -143,7 +145,7 @@ Page({
// orderInfo.selectPayType = 2
// }
if (selectTypeOrder == 1) {
this.setData({ showPromptDialog: true })
await openOrderPromptWithRestrictState(this)
} else {
let orderInfo = this.deleteOrderInfo()
wx.$router.go('tabWorkOrder.defeatOrder', {
......@@ -185,19 +187,26 @@ Page({
copyOrderInfo.againOrder = true
return copyOrderInfo
},
promptHandleConfirm(e) {
// 处理页面跳转参数
let orderInfo = this.deleteOrderInfo()
let { payFlag, payType } = e.detail
let paymentMethod = payFlag != 2 ? 1 : payType
if (payFlag == 1 || payType == 3 || payType == 4 || payType == 6) {
wx.$router.go('tabWorkOrder.createOrder', { paymentMethod, ...orderInfo })
} else {
this.tipsEvent()
}
this.setData({
paymentMethod
})
async promptHandleConfirm(e) {
const orderInfo = this.deleteOrderInfo()
const { orderPromptDjQrOnlyMode } = this.data
await confirmOrderPrompt(
e.detail,
{
onNavigateCreate: paymentMethod => {
wx.$router.go('tabWorkOrder.createOrder', {
paymentMethod,
...orderInfo
})
},
onOpenRecordingPopup: () => {
this.tipsEvent()
}
},
orderPromptDjQrOnlyMode
)
const paymentMethod = e.detail.payFlag != 2 ? 1 : e.detail.payType
this.setData({ paymentMethod })
},
promptCancel() {
this.setData({
......
......@@ -467,6 +467,7 @@
height="var(--fontSize540);"
includesChildHeight="var(--fontSize1060);"
sceneObj="{{ orderInfo }}"
dj-qr-only-mode="{{ orderPromptDjQrOnlyMode }}"
></order-prompt-popup>
<ConstructionDetailModal
visible="{{ constructionVisible }}"
......
......@@ -36,11 +36,26 @@ describe('abnormalFlowLock.helpers', async () => {
)
})
it('unprocessed prefers notDeclaredCount', () => {
assert.equal(hasUnprocessedAbnormalFlow({ notDeclaredCount: 2 }), true)
assert.equal(hasUnprocessedAbnormalFlow({ notDeclaredCount: 0 }), false)
it('unprocessed prefers totalCount for home tip', () => {
assert.equal(
hasUnprocessedAbnormalFlow({ totalCount: 3, notDeclaredCount: 0 }),
true
)
assert.equal(
hasUnprocessedAbnormalFlow({ totalCount: 0, notDeclaredCount: 2 }),
false
)
assert.equal(hasUnprocessedAbnormalFlow({ totalCount: 0 }), false)
assert.equal(hasUnprocessedAbnormalFlow({ abnormalFlowNum: 2 }), true)
assert.equal(
resolveAbnormalFlowTipCount({
totalCount: 3,
notDeclaredCount: 9,
abnormalFlowNum: 1
}),
3
)
assert.equal(
resolveAbnormalFlowTipCount({ notDeclaredCount: 4, abnormalFlowNum: 9 }),
4
)
......@@ -68,6 +83,37 @@ describe('abnormalFlowLock.helpers', async () => {
assert.match(buildAbnormalFlowTipText(3), /3笔异常流水/)
})
it('shouldRestrictNewOrderToDjQrOnly when lock on and pending flows', async () => {
const { shouldRestrictNewOrderToDjQrOnly } = await import(
'../utils/abnormalFlowLock.helpers.js'
)
assert.equal(
shouldRestrictNewOrderToDjQrOnly(
{ lockControlEnabled: 'Y', lockFlowFlag: 'Y' },
{ totalCount: 2 }
),
true
)
assert.equal(
shouldRestrictNewOrderToDjQrOnly(
{ lockControlEnabled: 'Y', lockFlowFlag: 'Y' },
{ totalCount: 0 }
),
false
)
assert.equal(
shouldRestrictNewOrderToDjQrOnly(false, { totalCount: 5 }),
false
)
assert.equal(
shouldRestrictNewOrderToDjQrOnly(
{ lockControlEnabled: 'N', lockFlowFlag: 'Y' },
{ notDeclaredCount: 3 }
),
false
)
})
it('exports bypass constants', () => {
assert.equal(ABNORMAL_FLOW_LOCK_BYPASS.ADDITION_RECORD, 'additionRecord')
})
......
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
describe('orderPromptConfirm.helpers', async () => {
const {
resolveOrderPromptPaymentMethod,
shouldOpenRecordingOrderPopup,
isInvalidDjQrOnlySelection
} = await import('../tabIndex/services/orderPromptConfirm.helpers.js')
it('resolveOrderPromptPaymentMethod', () => {
assert.equal(resolveOrderPromptPaymentMethod({ payFlag: 1 }), 1)
assert.equal(
resolveOrderPromptPaymentMethod({ payFlag: 2, payType: '5' }),
'5'
)
assert.equal(
resolveOrderPromptPaymentMethod({ payFlag: 2, payType: 3 }),
3
)
})
it('shouldOpenRecordingOrderPopup only for dj qr', () => {
assert.equal(shouldOpenRecordingOrderPopup({ payFlag: 1 }), false)
assert.equal(
shouldOpenRecordingOrderPopup({ payFlag: 2, payType: 3 }),
false
)
assert.equal(
shouldOpenRecordingOrderPopup({ payFlag: 2, payType: '5' }),
true
)
})
it('isInvalidDjQrOnlySelection', () => {
assert.equal(isInvalidDjQrOnlySelection({ payType: 3 }, true), true)
assert.equal(isInvalidDjQrOnlySelection({ payType: '5' }, true), false)
assert.equal(isInvalidDjQrOnlySelection({ payType: 3 }, false), false)
})
})
......@@ -90,14 +90,16 @@ export function isAbnormalFlowLockActive(apiData) {
}
/**
* 是否存在未处理异常流水(用于首页提醒)
* 优先 notDeclaredCount(union.count),兼容旧字段
* 是否存在未处理异常流水(用于首页吸底提醒)
* 优先 union.count 的 totalCount;清单 Tab 仍用 notDeclaredCount / declaredCount
* @param {Object} [apiData]
* @returns {boolean}
*/
export function hasUnprocessedAbnormalFlow(apiData) {
if (!apiData) return false
if (apiData.hasUnprocessedFlow === true) return true
const total = Number(apiData.totalCount)
if (Number.isFinite(total)) return total > 0
const notDeclared = Number(apiData.notDeclaredCount)
if (Number.isFinite(notDeclared)) return notDeclared > 0
const num = Number(apiData.abnormalFlowNum)
......@@ -105,11 +107,13 @@ export function hasUnprocessedAbnormalFlow(apiData) {
}
/**
* 从 union.count 解析提醒条数
* 从 union.count 解析首页吸底提醒条数(优先 totalCount)
* @param {Object} [apiData]
* @returns {number}
*/
export function resolveAbnormalFlowTipCount(apiData = {}) {
const total = Number(apiData.totalCount)
if (Number.isFinite(total)) return total
const notDeclared = Number(apiData.notDeclaredCount)
if (Number.isFinite(notDeclared)) return notDeclared
const num = Number(apiData.abnormalFlowNum)
......@@ -153,6 +157,19 @@ export function shouldBypassAbnormalFlowLock(context = {}) {
}
/**
* 新建工单收款弹窗是否仅允许嘀加二维码(锁单 ON + 有待报备)
* @param {boolean|Object|null|undefined} shopLockData - checkShopLock 返回值
* @param {Object} [countData] - union.count 返回值
* @returns {boolean}
*/
export function shouldRestrictNewOrderToDjQrOnly(shopLockData, countData) {
return (
isAbnormalFlowLockActive(shopLockData) &&
hasUnprocessedAbnormalFlow(countData)
)
}
/**
* 构建首页提醒文案
* @param {number} count
* @returns {string}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!