Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b5e3dca5
authored
Jun 30, 2026
by
岑成威
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 更换活动标识逻辑
1 parent
86174213
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
855 additions
and
50 deletions
components/Goods/Goods.js
components/SkuGoods/Goods.js
config.js
tabWorkOrder/pages/createOrder/createOrder.js
tabWorkOrder/pages/createOrder/createOrder.wxml
tabWorkOrder/pages/createOrder/services/minPriceApproval.js
tabWorkOrder/pages/createOrder/tests/minPriceApproval.test.mjs
tabWorkOrder/pages/orderDetail/orderDetail.wxml
tabWorkOrder/pages/refundApply/refundApply.js
tabWorkOrder/pages/refundApply/refundApply.sass
tabWorkOrder/pages/refundApply/refundApply.wxml
tabWorkOrder/pages/refundApply/services/refundApplyMarketing.js
tabWorkOrder/pages/refundApply/services/refundApplyMarketing.pure.mjs
tabWorkOrder/pages/refundApply/tests/refundApplyMarketing.test.mjs
tabWorkOrder/utils/loadMarketingFlagMap.js
utils/orderSubOrderExtras.js
components/Goods/Goods.js
View file @
b5e3dca
import
{
ensureCatalogUpgradePrice
}
from
'~/utils/orderSubOrderExtras'
import
{
ensureCatalogUpgradePrice
,
seedMarketingActivitySellPrice
}
from
'~/utils/orderSubOrderExtras'
import
{
normalizeMarketingFlagOnItem
}
from
'~/utils/marketingFlag'
import
{
normalizeMarketingFlagOnItem
}
from
'~/utils/marketingFlag'
Component
({
Component
({
...
@@ -115,6 +115,9 @@ Component({
...
@@ -115,6 +115,9 @@ Component({
if
(
goodsArr
.
length
==
1
)
{
if
(
goodsArr
.
length
==
1
)
{
goodsList
[
index
].
active
=
true
goodsList
[
index
].
active
=
true
goodsList
[
index
].
multipleSpecificationsGoods
.
goods
=
goodsArr
[
0
]
goodsList
[
index
].
multipleSpecificationsGoods
.
goods
=
goodsArr
[
0
]
seedMarketingActivitySellPrice
(
goodsList
[
index
].
multipleSpecificationsGoods
.
goods
)
ensureCatalogUpgradePrice
(
ensureCatalogUpgradePrice
(
goodsList
[
index
].
multipleSpecificationsGoods
.
goods
goodsList
[
index
].
multipleSpecificationsGoods
.
goods
)
)
...
@@ -134,6 +137,7 @@ Component({
...
@@ -134,6 +137,7 @@ Component({
//多个多规格商品时出现弹窗
//多个多规格商品时出现弹窗
goodsList
[
index
].
active
=
false
goodsList
[
index
].
active
=
false
goodsArr
.
forEach
(
item
=>
{
goodsArr
.
forEach
(
item
=>
{
seedMarketingActivitySellPrice
(
item
)
ensureCatalogUpgradePrice
(
item
)
ensureCatalogUpgradePrice
(
item
)
item
.
count
=
1
item
.
count
=
1
item
.
active
=
false
item
.
active
=
false
...
...
components/SkuGoods/Goods.js
View file @
b5e3dca
// packageEquity/pages/carQuotation/components/skuGoods/Goods.js
// packageEquity/pages/carQuotation/components/skuGoods/Goods.js
import
{
getSystemInfoSync
}
from
'~/utils/systemInfo'
import
{
getSystemInfoSync
}
from
'~/utils/systemInfo'
import
{
normalizeMarketingMetaOnItem
}
from
'~/utils/marketingFlag'
import
{
normalizeMarketingMetaOnItem
}
from
'~/utils/marketingFlag'
import
{
seedMarketingActivitySellPrice
}
from
'~/utils/orderSubOrderExtras'
Component
({
Component
({
/**
/**
* 组件的属性列表
* 组件的属性列表
...
@@ -158,6 +159,7 @@ Component({
...
@@ -158,6 +159,7 @@ Component({
price
=
Math
.
round
(
price
*
100
)
price
=
Math
.
round
(
price
*
100
)
}
}
c
.
multipleSpecificationsGoods
.
goods
.
price
=
price
c
.
multipleSpecificationsGoods
.
goods
.
price
=
price
seedMarketingActivitySellPrice
(
c
.
multipleSpecificationsGoods
.
goods
)
if
(
chooseGoodsList
.
length
>
0
)
{
if
(
chooseGoodsList
.
length
>
0
)
{
chooseGoodsList
.
map
(
x
=>
{
chooseGoodsList
.
map
(
x
=>
{
if
(
x
.
goodsFlag
==
2
&&
x
.
multipleSpecificationsGoods
)
{
if
(
x
.
goodsFlag
==
2
&&
x
.
multipleSpecificationsGoods
)
{
...
...
config.js
View file @
b5e3dca
...
@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false
...
@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false
* 4预发布
* 4预发布
* 5cdptest
* 5cdptest
*/
*/
let
index
=
1
;
let
index
=
2
;
const
accountInfo
=
wx
.
getAccountInfoSync
();
const
accountInfo
=
wx
.
getAccountInfoSync
();
const
systemInfo
=
getSystemInfoSync
();
const
systemInfo
=
getSystemInfoSync
();
const
envName
=
accountInfo
.
miniProgram
.
envVersion
;
const
envName
=
accountInfo
.
miniProgram
.
envVersion
;
...
...
tabWorkOrder/pages/createOrder/createOrder.js
View file @
b5e3dca
This diff is collapsed.
Click to expand it.
tabWorkOrder/pages/createOrder/createOrder.wxml
View file @
b5e3dca
...
@@ -945,7 +945,7 @@ value="{{ orderObj.remark }}"
...
@@ -945,7 +945,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.unit
Price }}</view>
<view class="approval-sheet__price">¥ {{ item.total
Price }}</view>
</view>
</view>
</view>
</view>
<view class="approval-sheet__meta">
<view class="approval-sheet__meta">
...
@@ -972,10 +972,9 @@ value="{{ orderObj.remark }}"
...
@@ -972,10 +972,9 @@ value="{{ orderObj.remark }}"
<view class="approval-sheet__row">
<view class="approval-sheet__row">
<view class="approval-sheet__name-wrap">
<view class="approval-sheet__name-wrap">
<view class="approval-sheet__child-name text-hide">{{ child.name }}</view>
<view class="approval-sheet__child-name text-hide">{{ child.name }}</view>
<image wx:if="{{ child.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">¥ {{ child.
unit
Price }}</view>
<view class="approval-sheet__price">¥ {{ child.
total
Price }}</view>
</view>
</view>
</view>
</view>
<view class="approval-sheet__meta">
<view class="approval-sheet__meta">
...
...
tabWorkOrder/pages/createOrder/services/minPriceApproval.js
View file @
b5e3dca
...
@@ -25,7 +25,21 @@ export function resolveApprovalCheckPrice(goods = {}) {
...
@@ -25,7 +25,21 @@ export function resolveApprovalCheckPrice(goods = {}) {
}
}
/**
/**
* 是否需总部审批:validMinSellPrice === 'Y' 且输入价 < minSellPrice
* 审批比价用的最低售价:再次编辑时 minSellPrice 可能被回显逻辑压低,优先用目录最低价
* @param {object} goods
* @returns {number}
*/
export
function
resolveApprovalMinSellPrice
(
goods
=
{})
{
return
Number
(
goods
.
upgradeShopMinPrice
??
goods
.
catalogMinSellPrice
??
goods
.
minSellPrice
??
0
)
}
/**
* 是否需总部审批:validMinSellPrice === 'Y' 且输入价 < 最低售价
* @param {object} goods
* @param {object} goods
* @returns {boolean}
* @returns {boolean}
*/
*/
...
@@ -34,7 +48,7 @@ export function needsMinPriceApproval(goods = {}) {
...
@@ -34,7 +48,7 @@ export function needsMinPriceApproval(goods = {}) {
if
(
goods
.
discountType
===
DISCOUNT_TYPE
.
GIFT
)
return
false
if
(
goods
.
discountType
===
DISCOUNT_TYPE
.
GIFT
)
return
false
const
checkPrice
=
resolveApprovalCheckPrice
(
goods
)
const
checkPrice
=
resolveApprovalCheckPrice
(
goods
)
if
(
checkPrice
===
null
||
checkPrice
===
''
)
return
false
if
(
checkPrice
===
null
||
checkPrice
===
''
)
return
false
return
Number
(
checkPrice
)
<
Number
(
goods
.
minSellPrice
||
0
)
return
Number
(
checkPrice
)
<
resolveApprovalMinSellPrice
(
goods
)
}
}
/**
/**
...
@@ -43,14 +57,32 @@ export function needsMinPriceApproval(goods = {}) {
...
@@ -43,14 +57,32 @@ export function needsMinPriceApproval(goods = {}) {
* @returns {number}
* @returns {number}
*/
*/
export
function
resolveApprovalActivityPrice
(
goods
=
{})
{
export
function
resolveApprovalActivityPrice
(
goods
=
{})
{
const
raw
=
if
(
goods
.
activitySellPrice
!=
null
&&
goods
.
activitySellPrice
!==
''
)
{
return
Number
(
goods
.
activitySellPrice
||
0
)
}
const
isMarketingGoods
=
goods
.
marketingFlag
==
1
&&
goods
.
activityId
!=
null
if
(
isMarketingGoods
)
{
// 活动价只用快照或目录 sellPrice,catalogSellPrice 可能是 upgradePrice(目录原价)
if
(
goods
.
activitySellPrice
!=
null
&&
goods
.
activitySellPrice
!==
''
)
{
return
Number
(
goods
.
activitySellPrice
)
}
return
Number
(
goods
.
sellPrice
||
0
)
}
const
unitPrice
=
goods
.
catalogSellPrice
??
goods
.
catalogSellPrice
??
goods
.
upgradePrice
??
goods
.
originalPrice
??
goods
.
price
??
goods
.
sellPrice
??
goods
.
sellPrice
??
0
goods
.
upgradePrice
??
return
Number
(
raw
||
0
)
goods
.
originalPrice
if
(
unitPrice
!=
null
&&
unitPrice
!==
''
)
{
return
Number
(
unitPrice
||
0
)
}
// 兜底:部分回显数据仅有 price,且在再次编辑场景可能是总价,按数量还原单价
if
(
goods
.
price
!=
null
&&
goods
.
price
!==
''
)
{
const
count
=
Number
(
goods
.
count
||
goods
.
number
||
1
)
||
1
return
Number
(
goods
.
price
||
0
)
/
count
}
return
0
}
}
/**
/**
...
@@ -74,14 +106,17 @@ function resolveGoodsDisplayName(goods = {}, lineItem = {}) {
...
@@ -74,14 +106,17 @@ function resolveGoodsDisplayName(goods = {}, lineItem = {}) {
/**
/**
* @param {object} goods
* @param {object} goods
* @param {number} [lineCount]
* @param {number} [lineCount]
* @returns {{ name: string, unitPrice: number, activityPrice: number, count: number, marketingFlag: number }}
* @returns {{ name: string, unitPrice: number,
totalPrice: number,
activityPrice: number, count: number, marketingFlag: number }}
*/
*/
function
mapApprovalGoodsRow
(
goods
,
lineCount
=
1
)
{
function
mapApprovalGoodsRow
(
goods
,
lineCount
=
1
)
{
const
unitPrice
=
Number
(
resolveApprovalCheckPrice
(
goods
)
||
0
)
const
unitPrice
=
Number
(
resolveApprovalCheckPrice
(
goods
)
||
0
)
const
count
=
Number
(
goods
.
number
||
lineCount
||
1
)
// 行 count 为当前 UI 数量;goods.number 可能是订单回显旧值
const
count
=
Number
(
lineCount
||
goods
.
count
||
goods
.
number
||
1
)
return
{
return
{
name
:
resolveGoodsDisplayName
(
goods
),
name
:
resolveGoodsDisplayName
(
goods
),
unitPrice
,
unitPrice
,
// 审批弹层总价展示按当前商品行单价,不再随数量联动
totalPrice
:
unitPrice
,
activityPrice
:
resolveApprovalActivityPrice
(
goods
),
activityPrice
:
resolveApprovalActivityPrice
(
goods
),
count
,
count
,
marketingFlag
:
goods
.
marketingFlag
==
1
?
1
:
0
marketingFlag
:
goods
.
marketingFlag
==
1
?
1
:
0
...
@@ -89,6 +124,20 @@ function mapApprovalGoodsRow(goods, lineCount = 1) {
...
@@ -89,6 +124,20 @@ function mapApprovalGoodsRow(goods, lineCount = 1) {
}
}
/**
/**
* 套餐子项是否需审批:与 PackageProductStrategy.validateSubItemPrice 一致
* 使用 minSellPrice 比价,不用 upgradeShopMinPrice(避免未触发子项误入弹层)
* @param {object} goods 套餐 packageGoods.goodsList 子项
* @returns {boolean}
*/
export
function
needsPackageSubMinPriceApproval
(
goods
=
{})
{
if
(
!
goods
||
goods
.
validMinSellPrice
!==
'Y'
)
return
false
if
(
goods
.
discountType
===
DISCOUNT_TYPE
.
GIFT
)
return
false
const
checkPrice
=
resolveApprovalCheckPrice
(
goods
)
if
(
checkPrice
===
null
||
checkPrice
===
''
)
return
false
return
Number
(
checkPrice
)
<
Number
(
goods
.
minSellPrice
||
0
)
}
/**
* 从页面 goodsList 收集需审批商品(提交弹层展示)
* 从页面 goodsList 收集需审批商品(提交弹层展示)
* @param {Array<object>} goodsList
* @param {Array<object>} goodsList
* @returns {Array<{ type: 'single'|'package', name: string, unitPrice?: number, activityPrice?: number, count?: number, totalPrice?: number, marketingFlag: number, children?: Array<object> }>}
* @returns {Array<{ type: 'single'|'package', name: string, unitPrice?: number, activityPrice?: number, count?: number, totalPrice?: number, marketingFlag: number, children?: Array<object> }>}
...
@@ -104,7 +153,6 @@ export function buildMinPriceApprovalList(goodsList = []) {
...
@@ -104,7 +153,6 @@ export function buildMinPriceApprovalList(goodsList = []) {
result
.
push
({
result
.
push
({
type
:
'single'
,
type
:
'single'
,
...
row
,
...
row
,
totalPrice
:
row
.
unitPrice
*
row
.
count
,
marketingFlag
:
line
.
marketingFlag
==
1
?
1
:
row
.
marketingFlag
marketingFlag
:
line
.
marketingFlag
==
1
?
1
:
row
.
marketingFlag
})
})
return
return
...
@@ -112,12 +160,11 @@ export function buildMinPriceApprovalList(goodsList = []) {
...
@@ -112,12 +160,11 @@ export function buildMinPriceApprovalList(goodsList = []) {
if
(
line
.
goodsFlag
===
2
&&
line
.
multipleSpecificationsGoods
?.
goods
)
{
if
(
line
.
goodsFlag
===
2
&&
line
.
multipleSpecificationsGoods
?.
goods
)
{
const
goods
=
line
.
multipleSpecificationsGoods
.
goods
const
goods
=
line
.
multipleSpecificationsGoods
.
goods
if
(
!
needsMinPriceApproval
(
goods
))
return
if
(
!
needs
PackageSub
MinPriceApproval
(
goods
))
return
const
row
=
mapApprovalGoodsRow
(
goods
,
line
.
count
)
const
row
=
mapApprovalGoodsRow
(
goods
,
line
.
count
)
result
.
push
({
result
.
push
({
type
:
'single'
,
type
:
'single'
,
...
row
,
...
row
,
totalPrice
:
row
.
unitPrice
*
row
.
count
,
marketingFlag
:
line
.
marketingFlag
==
1
?
1
:
row
.
marketingFlag
marketingFlag
:
line
.
marketingFlag
==
1
?
1
:
row
.
marketingFlag
})
})
return
return
...
@@ -127,14 +174,14 @@ export function buildMinPriceApprovalList(goodsList = []) {
...
@@ -127,14 +174,14 @@ export function buildMinPriceApprovalList(goodsList = []) {
const
packageGoodsList
=
line
.
packageGoods
.
goodsList
const
packageGoodsList
=
line
.
packageGoods
.
goodsList
const
children
=
[]
const
children
=
[]
packageGoodsList
.
forEach
(
sub
=>
{
packageGoodsList
.
forEach
(
sub
=>
{
if
(
!
needsMinPriceApproval
(
sub
))
return
if
(
!
needs
PackageSub
MinPriceApproval
(
sub
))
return
children
.
push
(
mapApprovalGoodsRow
(
sub
,
sub
.
number
||
line
.
count
||
1
))
children
.
push
(
mapApprovalGoodsRow
(
sub
,
sub
.
number
||
line
.
count
||
1
))
})
})
if
(
!
children
.
length
)
return
if
(
!
children
.
length
)
return
const
pkg
=
line
.
packageGoods
const
pkg
=
line
.
packageGoods
const
totalPrice
=
children
.
reduce
(
const
totalPrice
=
children
.
reduce
(
(
sum
,
child
)
=>
sum
+
child
.
unitPrice
*
child
.
count
,
(
sum
,
child
)
=>
sum
+
child
.
totalPrice
,
0
0
)
)
...
...
tabWorkOrder/pages/createOrder/tests/minPriceApproval.test.mjs
View file @
b5e3dca
...
@@ -6,6 +6,7 @@ const require = createRequire(import.meta.url)
...
@@ -6,6 +6,7 @@ const require = createRequire(import.meta.url)
const {
const {
buildMinPriceApprovalList,
buildMinPriceApprovalList,
needsMinPriceApproval,
needsMinPriceApproval,
needsPackageSubMinPriceApproval,
resolveApprovalCheckPrice,
resolveApprovalCheckPrice,
resolveApprovalActivityPrice
resolveApprovalActivityPrice
} = require('../services/minPriceApproval.js')
} = require('../services/minPriceApproval.js')
...
@@ -59,10 +60,49 @@ test('resolveApprovalActivityPrice uses catalog sellPrice not modified price', (
...
@@ -59,10 +60,49 @@ test('resolveApprovalActivityPrice uses catalog sellPrice not modified price', (
sellPrice: 100,
sellPrice: 100,
minSellPrice: 200
minSellPrice: 200
}),
}),
288
100
)
assert.equal(
resolveApprovalActivityPrice({
price: 598,
number: 2
}),
299
)
)
})
})
test('needsMinPriceApproval uses upgradeShopMinPrice after reset echo', () => {
assert.equal(
needsMinPriceApproval({
validMinSellPrice: 'Y',
upgradeShopMinPrice: 200,
minSellPrice: 100,
sellPrice: 100
}),
true
)
})
test('buildMinPriceApprovalList prefers line count over stale goods.number', () => {
const list = buildMinPriceApprovalList([
{
goodsFlag: 1,
count: 2,
goods: {
validMinSellPrice: 'Y',
upgradeShopMinPrice: 200,
minSellPrice: 200,
catalogSellPrice: 299,
sellPrice: 100,
number: 1,
upgradeGoodsName: '太阳膜'
}
}
])
assert.equal(list[0].count, 2)
assert.equal(list[0].totalPrice, 100)
})
test('buildMinPriceApprovalList collects singles and packages', () => {
test('buildMinPriceApprovalList collects singles and packages', () => {
const list = buildMinPriceApprovalList([
const list = buildMinPriceApprovalList([
{
{
...
@@ -138,3 +178,94 @@ test('package approval only shows low-price children', () => {
...
@@ -138,3 +178,94 @@ test('package approval only shows low-price children', () => {
assert.equal(list[0].children[0].name, '车窗膜')
assert.equal(list[0].children[0].name, '车窗膜')
assert.equal(list[0].totalPrice, 179)
assert.equal(list[0].totalPrice, 179)
})
})
test('buildMinPriceApprovalList multi-spec uses activitySellPrice and minSellPrice rule', () => {
const list = buildMinPriceApprovalList([
{
goodsFlag: 2,
count: 1,
marketingFlag: 1,
multipleSpecificationsGoods: {
goods: {
validMinSellPrice: 'Y',
minSellPrice: 100,
upgradeShopMinPrice: 200,
sellPrice: 0.1,
activitySellPrice: 30,
marketingFlag: 1,
activityId: 9,
upgradeGoodsName: '多规格SKU'
}
}
}
])
assert.equal(list.length, 1)
assert.equal(list[0].type, 'single')
assert.equal(list[0].activityPrice, 30)
assert.equal(list[0].unitPrice, 0.1)
})
test('resolveApprovalActivityPrice uses activitySellPrice for marketing package sub', () => {
assert.equal(
resolveApprovalActivityPrice({
marketingFlag: 1,
activityId: 9,
activitySellPrice: 30,
catalogSellPrice: 200,
upgradePrice: 200,
sellPrice: 0.1
}),
30
)
})
test('needsPackageSubMinPriceApproval uses minSellPrice not upgradeShopMinPrice', () => {
validMinSellPrice: 'Y',
minSellPrice: 30,
upgradeShopMinPrice: 200,
sellPrice: 40
}),
false
)
assert.equal(
needsPackageSubMinPriceApproval({
validMinSellPrice: 'Y',
minSellPrice: 66,
upgradeShopMinPrice: 200,
sellPrice: 0.1
}),
true
)
})
test('package approval only includes subs below minSellPrice', () => {
const list = buildMinPriceApprovalList([
{
goodsFlag: 3,
count: 1,
packageGoods: {
packageName: '测试套餐',
goodsList: [
{
validMinSellPrice: 'Y',
minSellPrice: 66,
upgradeShopMinPrice: 200,
sellPrice: 0.1,
upgradeGoodsName: 'super改色膜'
},
{
validMinSellPrice: 'Y',
minSellPrice: 30,
upgradeShopMinPrice: 200,
sellPrice: 40,
upgradeGoodsName: '1'
}
]
}
}
])
assert.equal(list.length, 1)
assert.equal(list[0].children.length, 1)
assert.equal(list[0].children[0].name, 'super改色膜')
assert.equal(list[0].totalPrice, 0.1)
})
tabWorkOrder/pages/orderDetail/orderDetail.wxml
View file @
b5e3dca
...
@@ -41,18 +41,7 @@
...
@@ -41,18 +41,7 @@
</block>
</block>
<block wx:if="{{ orderInfo.goodsOrderApplyStatus==1 || orderInfo.goodsOrderApplyStatus==2 }}">
<block wx:if="{{ orderInfo.goodsOrderApplyStatus==1 || orderInfo.goodsOrderApplyStatus==2 }}">
<view class="timeline">
<view class="timeline">
<view class="timeline-item">
<view class="timeline-left">
<view class="dot-wrapper">
<view class="dot {{ orderInfo.goodsOrderApplyStatus==1?'step-active':'step-done' }}"></view>
</view>
<view class="statusLine {{ orderInfo.goodsOrderApplyStatus==2?'step-done':'' }}"></view>
</view>
<view class="timeline-content">
<view>区域经理</view>
<view class="status {{ orderInfo.goodsOrderApplyStatus==1?'warning':'success' }}">{{orderInfo.goodsOrderApplyStatus==1?'审批中':'审批通过'}}</view>
</view>
</view>
<view class="timeline-item">
<view class="timeline-item">
<view class="timeline-left">
<view class="timeline-left">
<view class="dot-wrapper">
<view class="dot-wrapper">
...
@@ -60,7 +49,7 @@
...
@@ -60,7 +49,7 @@
</view>
</view>
</view>
</view>
<view class="timeline-content">
<view class="timeline-content">
<view>
线上
运营</view>
<view>运营</view>
<view class="status warning" wx:if="{{ orderInfo.goodsOrderApplyStatus==2 }}">审批中</view>
<view class="status warning" wx:if="{{ orderInfo.goodsOrderApplyStatus==2 }}">审批中</view>
</view>
</view>
</view>
</view>
...
...
tabWorkOrder/pages/refundApply/refundApply.js
View file @
b5e3dca
...
@@ -5,7 +5,7 @@ import NP from "number-precision";
...
@@ -5,7 +5,7 @@ import NP from "number-precision";
import
qs
from
"~/utils/lib/qs"
;
import
qs
from
"~/utils/lib/qs"
;
import
api
from
"~/api/api.js"
;
import
api
from
"~/api/api.js"
;
import
reportPageTrackMixin
from
"~/mixins/reportPageTrackMixin"
;
import
reportPageTrackMixin
from
"~/mixins/reportPageTrackMixin"
;
import
{
normalizeMarketingFlagOnItem
}
from
"~/utils/marketingFla
g"
;
import
{
enrichRefundSubOrderMarketingFlags
,
fetchOrderDetailData
}
from
"./services/refundApplyMarketin
g"
;
const
IMG_URL
=
"https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/"
;
const
IMG_URL
=
"https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/"
;
let
toastList
=
{
let
toastList
=
{
payee
:
"收款人姓名不能为空"
,
payee
:
"收款人姓名不能为空"
,
...
@@ -173,23 +173,36 @@ Page({
...
@@ -173,23 +173,36 @@ Page({
val
.
upgradeGoodsName
=
listShowSpecificationData
?
`
${
val
.
upgradeGoodsName
}
(
${
listShowSpecificationData
}
)`
:
val
.
upgradeGoodsName
;
val
.
upgradeGoodsName
=
listShowSpecificationData
?
`
${
val
.
upgradeGoodsName
}
(
${
listShowSpecificationData
}
)`
:
val
.
upgradeGoodsName
;
return
val
;
return
val
;
});
});
this
.
normalizeSubOrderList
(
res
.
data
);
const
marketingOptions
=
{
orderCode
:
options
?.
orderCode
,
merchantId
:
options
?.
shopMerchantId
,
};
const
orderDetailData
=
await
fetchOrderDetailData
(
marketingOptions
.
orderCode
);
const
subOrderList
=
await
this
.
enrichSubOrderMarketingFlags
(
res
.
data
||
[],
{
...
marketingOptions
,
orderDetailData
,
});
// 处理退款记录商品规格
// 处理退款记录商品规格
result
?.
data
?.
forEach
((
val
)
=>
{
const
refundedOrderList
=
result
?.
data
||
[];
for
(
const
val
of
refundedOrderList
)
{
if
(
val
.
refundTime
)
val
.
refundTime
=
dayjs
(
val
.
refundTime
).
format
(
"YYYY-MM-DD HH:mm:ss"
);
if
(
val
.
refundTime
)
val
.
refundTime
=
dayjs
(
val
.
refundTime
).
format
(
"YYYY-MM-DD HH:mm:ss"
);
val
?.
refundApplyDetailList
?.
forEach
((
v
)
=>
{
val
?.
refundApplyDetailList
?.
forEach
((
v
)
=>
{
let
listShowSpecificationData
=
this
.
filterSpeciation
(
v
);
let
listShowSpecificationData
=
this
.
filterSpeciation
(
v
);
v
.
upgradeGoodsName
=
listShowSpecificationData
?
`
${
v
.
goodsName
}
(
${
listShowSpecificationData
}
)`
:
v
.
goodsName
;
v
.
upgradeGoodsName
=
listShowSpecificationData
?
`
${
v
.
goodsName
}
(
${
listShowSpecificationData
}
)`
:
v
.
goodsName
;
});
});
await
this
.
enrichSubOrderMarketingFlags
(
val
.
refundApplyDetailList
||
[],
{
...
marketingOptions
,
orderDetailData
,
});
});
}
this
.
setData
({
this
.
setData
({
"infoData.subOrderList"
:
res
.
data
||
[]
,
"infoData.subOrderList"
:
subOrderList
,
"infoData.orderCode"
:
options
?.
orderCode
,
"infoData.orderCode"
:
options
?.
orderCode
,
"infoData.shopMerchantName"
:
options
?.
shopMerchantName
,
"infoData.shopMerchantName"
:
options
?.
shopMerchantName
,
"infoData.shopMerchantId"
:
options
?.
shopMerchantId
,
"infoData.shopMerchantId"
:
options
?.
shopMerchantId
,
"infoData.yqMerchantName"
:
userInfo
?.
merchantName
,
"infoData.yqMerchantName"
:
userInfo
?.
merchantName
,
"infoData.yqMerchantId"
:
userInfo
?.
merchantId
,
"infoData.yqMerchantId"
:
userInfo
?.
merchantId
,
"infoData.refundedOrderList"
:
re
sult
?.
data
||
[]
,
"infoData.refundedOrderList"
:
re
fundedOrderList
,
// 退款人
// 退款人
"infoData.payee"
:
options
?.
refundName
||
""
,
"infoData.payee"
:
options
?.
refundName
||
""
,
initialRefundName
:
options
?.
refundName
||
""
,
initialRefundName
:
options
?.
refundName
||
""
,
...
@@ -218,13 +231,22 @@ Page({
...
@@ -218,13 +231,22 @@ Page({
wx
.
$util
.
showToast
(
message
);
wx
.
$util
.
showToast
(
message
);
return
;
return
;
}
}
data
?.
refundedOrderList
?.
forEach
((
val
)
=>
{
const
marketingOptions
=
{
orderCode
:
data
?.
orderCode
,
merchantId
:
data
?.
shopMerchantId
,
};
const
orderDetailData
=
await
fetchOrderDetailData
(
marketingOptions
.
orderCode
);
for
(
const
val
of
data
?.
refundedOrderList
||
[])
{
if
(
val
.
refundTime
)
val
.
refundTime
=
dayjs
(
val
.
refundTime
).
format
(
"YYYY-MM-DD HH:mm:ss"
);
if
(
val
.
refundTime
)
val
.
refundTime
=
dayjs
(
val
.
refundTime
).
format
(
"YYYY-MM-DD HH:mm:ss"
);
val
?.
refundApplyDetailList
?.
forEach
((
v
)
=>
{
val
?.
refundApplyDetailList
?.
forEach
((
v
)
=>
{
let
listShowSpecificationData
=
this
.
filterSpeciation
(
v
);
let
listShowSpecificationData
=
this
.
filterSpeciation
(
v
);
v
.
upgradeGoodsName
=
listShowSpecificationData
?
`
${
v
.
goodsName
}
(
${
listShowSpecificationData
}
)`
:
v
.
goodsName
;
v
.
upgradeGoodsName
=
listShowSpecificationData
?
`
${
v
.
goodsName
}
(
${
listShowSpecificationData
}
)`
:
v
.
goodsName
;
});
});
await
this
.
enrichSubOrderMarketingFlags
(
val
.
refundApplyDetailList
||
[],
{
...
marketingOptions
,
orderDetailData
,
});
});
}
let
subOrderList
=
[];
let
subOrderList
=
[];
// 审核不通过并且是驻店进入页面 获取子订单数据
// 审核不通过并且是驻店进入页面 获取子订单数据
if
(
res
.
data
.
afterStatus
==
5
&&
!
wx
.
$hasPermission
?.
canViewRecruit
?.(
userInfo
))
{
if
(
res
.
data
.
afterStatus
==
5
&&
!
wx
.
$hasPermission
?.
canViewRecruit
?.(
userInfo
))
{
...
@@ -243,7 +265,10 @@ Page({
...
@@ -243,7 +265,10 @@ Page({
}
}
});
});
});
});
this
.
normalizeSubOrderList
(
subOrderList
);
subOrderList
=
await
this
.
enrichSubOrderMarketingFlags
(
subOrderList
,
{
...
marketingOptions
,
orderDetailData
,
});
}
}
}
else
{
}
else
{
const
refundApplyDetailList
=
(
data
?.
refundApplyDetailList
||
[]).
map
((
val
)
=>
{
const
refundApplyDetailList
=
(
data
?.
refundApplyDetailList
||
[]).
map
((
val
)
=>
{
...
@@ -253,7 +278,10 @@ Page({
...
@@ -253,7 +278,10 @@ Page({
val
.
checked
=
true
;
val
.
checked
=
true
;
return
val
;
return
val
;
});
});
subOrderList
=
this
.
normalizeSubOrderList
(
refundApplyDetailList
);
subOrderList
=
await
this
.
enrichSubOrderMarketingFlags
(
refundApplyDetailList
,
{
...
marketingOptions
,
orderDetailData
,
});
}
}
// 处理主订单总支付金额 用于显示可选可退总金额
// 处理主订单总支付金额 用于显示可选可退总金额
this
.
setOrderPayPrice
(
subOrderList
);
this
.
setOrderPayPrice
(
subOrderList
);
...
@@ -279,13 +307,13 @@ Page({
...
@@ -279,13 +307,13 @@ Page({
}
catch
(
error
)
{}
}
catch
(
error
)
{}
},
},
/**
/**
* 退款明细子单
归一化活动标(接口可能在套餐子商品或顶层
)
* 退款明细子单
补强活动标(工单子单优先,与工单详情 orderDetail 一致
)
* @param {Array<object>} list goodsSubOrder / refundApplyDetail 列表
* @param {Array<object>} list goodsSubOrder / refundApplyDetail 列表
* @returns {Array<object>}
* @param {{ orderCode?: string, merchantId?: string|number }} [options]
* @returns {Promise<Array<object>>}
*/
*/
normalizeSubOrderList
(
list
=
[])
{
async
enrichSubOrderMarketingFlags
(
list
=
[],
options
=
{})
{
list
.
forEach
((
item
)
=>
normalizeMarketingFlagOnItem
(
item
));
return
enrichRefundSubOrderMarketingFlags
(
list
,
options
);
return
list
;
},
},
// 处理规格数据
// 处理规格数据
...
...
tabWorkOrder/pages/refundApply/refundApply.sass
View file @
b5e3dca
...
@@ -166,6 +166,21 @@ page {
...
@@ -166,6 +166,21 @@ page {
.sub_item
{
.sub_item
{
color
:
#666666
;
color
:
#666666
;
line-height
:
var
(
--
fontSize36
)
;
line-height
:
var
(
--
fontSize36
)
;
.goods-name-with-icon
{
display
:
flex
;
align-items
:
center
;
min-width
:
0
;
}
.goods-name-text
{
flex
:
0
1
auto
;
min-width
:
0
;
}
.marketing-icon
{
width
:
var
(
--
fontSize56
)
;
height
:
var
(
--
fontSize28
)
;
flex-shrink
:
0
;
margin-left
:
var
(
--
fontSize8
)
;
}
}
}
&
:last-child
{
&
:last-child
{
margin-bottom
:
0
;
margin-bottom
:
0
;
...
...
tabWorkOrder/pages/refundApply/refundApply.wxml
View file @
b5e3dca
...
@@ -170,9 +170,11 @@
...
@@ -170,9 +170,11 @@
wx:for-item="li"
wx:for-item="li"
wx:for-key="{{ idx }}"
wx:for-key="{{ idx }}"
wx:key="idx">
wx:key="idx">
<view>
<view class="goods-name-with-icon">
{{ li.upgradeGoodsName }}支付金额 ¥{{ li.finalPrice }},申请退款 ¥{{ li.refundAmount }}
<view class="goods-name-text">{{ li.upgradeGoodsName }}</view>
<image wx:if="{{ li.marketingFlag == 1 }}" class="marketing-icon" src="/tabWorkOrder/images/activeIcon.png" mode="aspectFit" />
</view>
</view>
<view>支付金额 ¥{{ li.finalPrice }},申请退款 ¥{{ li.refundAmount }}</view>
</view>
</view>
<view class="sub_item" wx:if="{{ item.refundTime }}">
<view class="sub_item" wx:if="{{ item.refundTime }}">
{{ item.refundTime }}退款成功,实际退款 ¥{{ item.payAmount }}
{{ item.refundTime }}退款成功,实际退款 ¥{{ item.payAmount }}
...
...
tabWorkOrder/pages/refundApply/services/refundApplyMarketing.js
0 → 100644
View file @
b5e3dca
/**
* @file 退款申请页商品活动标:从 packageGoodsDetail 工单子单合并 marketingFlag
* 服务层:不 setData、不 getPageInstance
*/
import
tabWorkOrderApi
from
'~/tabWorkOrder/api'
import
{
isMarketingActive
,
normalizeMarketingFlagOnItem
,
resolveMarketingFlag
,
MARKETING_FLAG_ACTIVE
}
from
'~/utils/marketingFlag'
import
{
loadMarketingMetaMaps
}
from
'../../../utils/loadMarketingFlagMap'
/**
* 接口成功(code 可能为 number 0 或 string "0")
* @param {*} code
* @returns {boolean}
*/
function
isApiSuccess
(
code
)
{
return
code
==
0
||
code
===
'0'
}
/**
* 读取接口可能落在 goodsInfo / goods 上的活动标
* @param {object} item
* @returns {number}
*/
function
readItemMarketingFlag
(
item
=
{})
{
normalizeMarketingFlagOnItem
(
item
)
if
(
isMarketingActive
(
item
.
marketingFlag
))
return
MARKETING_FLAG_ACTIVE
const
nested
=
item
.
goodsInfo
?.
marketingFlag
??
item
.
goods
?.
marketingFlag
??
item
.
multipleSpecificationsGoods
?.
marketingFlag
return
isMarketingActive
(
nested
)
?
MARKETING_FLAG_ACTIVE
:
0
}
/**
* 退款子单与工单子单是否为同一商品(兼容 subOrderCode 数字/字符串)
* @param {object} refundItem
* @param {object} orderItem
* @returns {boolean}
*/
export
function
isSameRefundGoods
(
refundItem
=
{},
orderItem
=
{})
{
if
(
refundItem
.
subOrderCode
!=
null
&&
orderItem
.
subOrderCode
!=
null
&&
String
(
refundItem
.
subOrderCode
)
===
String
(
orderItem
.
subOrderCode
)
)
{
return
true
}
if
(
refundItem
.
merchantGoodsId
!=
null
&&
orderItem
.
merchantGoodsId
!=
null
&&
String
(
refundItem
.
merchantGoodsId
)
===
String
(
orderItem
.
merchantGoodsId
)
)
{
return
true
}
if
(
refundItem
.
upgradeGoodsId
!=
null
&&
orderItem
.
upgradeGoodsId
!=
null
&&
String
(
refundItem
.
upgradeGoodsId
)
===
String
(
orderItem
.
upgradeGoodsId
)
)
{
return
true
}
if
(
refundItem
.
merchantGoodsCode
&&
orderItem
.
merchantGoodsCode
&&
String
(
refundItem
.
merchantGoodsCode
)
===
String
(
orderItem
.
merchantGoodsCode
)
)
{
return
true
}
if
(
refundItem
.
upgradeGoodsCommodityCode
&&
orderItem
.
upgradeGoodsCommodityCode
&&
String
(
refundItem
.
upgradeGoodsCommodityCode
)
===
String
(
orderItem
.
upgradeGoodsCommodityCode
)
)
{
return
true
}
if
(
refundItem
.
upgradeGoodsCode
&&
orderItem
.
upgradeGoodsCode
&&
String
(
refundItem
.
upgradeGoodsCode
)
===
String
(
orderItem
.
upgradeGoodsCode
)
)
{
return
true
}
return
false
}
/**
* 退款行是否为套餐整包(与 packageGoodsDetail.packageGoodsList 对应)
* @param {object} refundItem
* @param {object} pkg
* @returns {boolean}
*/
export
function
isSamePackageRefundRow
(
refundItem
=
{},
pkg
=
{})
{
if
(
refundItem
.
packageCode
&&
pkg
.
packageCode
&&
String
(
refundItem
.
packageCode
)
===
String
(
pkg
.
packageCode
)
)
{
return
true
}
if
(
pkg
.
packageName
&&
refundItem
.
packageName
&&
String
(
refundItem
.
packageName
)
===
String
(
pkg
.
packageName
)
)
{
return
true
}
if
(
pkg
.
packageName
&&
refundItem
.
upgradeGoodsName
&&
String
(
refundItem
.
upgradeGoodsName
)
===
String
(
pkg
.
packageName
)
)
{
return
true
}
if
(
pkg
.
subOrderCode
&&
refundItem
.
subOrderCode
&&
String
(
pkg
.
subOrderCode
)
===
String
(
refundItem
.
subOrderCode
)
)
{
return
true
}
return
false
}
/**
* 从 packageGoodsDetail 响应解析单条退款商品的活动标
* @param {object} refundItem goodsSubOrder / refundApplyDetail 行
* @param {object} [orderData] packageGoodsDetail.data
* @param {Record<string, number>} [catalogFlagMap]
* @returns {0|1}
*/
export
function
resolveRefundItemMarketingFlag
(
refundItem
=
{},
orderData
=
{},
catalogFlagMap
=
{}
)
{
const
direct
=
readItemMarketingFlag
(
refundItem
)
if
(
direct
===
MARKETING_FLAG_ACTIVE
)
return
MARKETING_FLAG_ACTIVE
for
(
const
item
of
orderData
.
subOrderList
||
[])
{
if
(
!
isSameRefundGoods
(
refundItem
,
item
))
continue
if
(
readItemMarketingFlag
(
item
)
===
MARKETING_FLAG_ACTIVE
)
{
return
MARKETING_FLAG_ACTIVE
}
}
for
(
const
pkg
of
orderData
.
packageGoodsList
||
[])
{
if
(
isSamePackageRefundRow
(
refundItem
,
pkg
)
&&
readItemMarketingFlag
(
pkg
)
===
MARKETING_FLAG_ACTIVE
)
{
return
MARKETING_FLAG_ACTIVE
}
for
(
const
child
of
pkg
.
packageGoodsOrderList
||
[])
{
if
(
!
isSameRefundGoods
(
refundItem
,
child
))
continue
if
(
readItemMarketingFlag
(
child
)
===
MARKETING_FLAG_ACTIVE
)
{
return
MARKETING_FLAG_ACTIVE
}
}
}
return
resolveMarketingFlag
(
catalogFlagMap
,
refundItem
)
===
MARKETING_FLAG_ACTIVE
?
MARKETING_FLAG_ACTIVE
:
0
}
/**
* 将 packageGoodsDetail 活动标合并进退款明细(返回新对象,便于 setData 刷新)
* @param {Array<object>} list
* @param {object} [orderData]
* @param {Record<string, number>} [catalogFlagMap]
* @returns {Array<object>}
*/
export
function
applyMarketingFlagsToRefundItems
(
list
=
[],
orderData
=
{},
catalogFlagMap
=
{}
)
{
return
list
.
map
((
item
)
=>
({
...
item
,
marketingFlag
:
resolveRefundItemMarketingFlag
(
item
,
orderData
,
catalogFlagMap
)
}))
}
/**
* 拉取 packageGoodsDetail 工单数据
* @param {string} orderCode
* @returns {Promise<object|null>}
*/
export
async
function
fetchOrderDetailData
(
orderCode
)
{
if
(
!
orderCode
)
return
null
try
{
const
res
=
await
tabWorkOrderApi
.
getPackageGoodsDetail
({
orderCode
})
if
(
isApiSuccess
(
res
?.
code
))
return
res
.
data
||
{}
}
catch
(
err
)
{
console
.
warn
(
'fetchOrderDetailData failed'
,
err
)
}
return
null
}
/** @deprecated 使用 fetchOrderDetailData */
export
async
function
fetchOrderMarketingFlagMap
(
orderCode
)
{
const
data
=
await
fetchOrderDetailData
(
orderCode
)
return
data
||
{}
}
/**
* 退款明细列表活动标补强(packageGoodsDetail 优先,目录映射兜底)
* @param {Array<object>} list
* @param {{ orderCode?: string, merchantId?: string|number, sceneType?: number, baseSceneCode?: string, orderDetailData?: object|null }} options
* @returns {Promise<Array<object>>}
*/
export
async
function
enrichRefundSubOrderMarketingFlags
(
list
=
[],
options
=
{})
{
const
{
orderCode
,
merchantId
,
sceneType
=
1
,
baseSceneCode
=
''
,
orderDetailData
:
presetOrderData
}
=
options
const
orderData
=
presetOrderData
!==
undefined
?
presetOrderData
||
{}
:
(
await
fetchOrderDetailData
(
orderCode
))
||
{}
const
resolvedMerchantId
=
merchantId
??
orderData
.
merchantId
const
resolvedSceneType
=
orderData
.
sceneType
??
sceneType
const
resolvedBaseSceneCode
=
orderData
.
baseSceneCode
??
baseSceneCode
let
catalogFlagMap
=
{}
const
needsCatalog
=
list
.
some
(
(
item
)
=>
resolveRefundItemMarketingFlag
(
item
,
orderData
,
{})
!==
MARKETING_FLAG_ACTIVE
)
if
(
needsCatalog
&&
resolvedMerchantId
)
{
const
{
marketingFlagMap
}
=
await
loadMarketingMetaMaps
(
resolvedMerchantId
,
{
sceneType
:
resolvedSceneType
,
baseSceneCode
:
resolvedBaseSceneCode
})
catalogFlagMap
=
marketingFlagMap
||
{}
}
return
applyMarketingFlagsToRefundItems
(
list
,
orderData
,
catalogFlagMap
)
}
tabWorkOrder/pages/refundApply/services/refundApplyMarketing.pure.mjs
0 → 100644
View file @
b5e3dca
/**
* @file 退款申请活动标纯函数(node:test 用;与 refundApplyMarketing.js 逻辑保持一致)
*/
const MARKETING_FLAG_ACTIVE = 1
function isMarketingActive(flag) {
return flag == 1 || flag === '1'
}
function resolvePackageMarketingFlag(item) {
if (!item) return 0
if (isMarketingActive(item.marketingFlag)) return MARKETING_FLAG_ACTIVE
const pkg = item.packageGoods
if (pkg && isMarketingActive(pkg.marketingFlag)) return MARKETING_FLAG_ACTIVE
const children =
item.packageGoodsOrderList ||
item.goodsList ||
pkg?.goodsList ||
pkg?.packageGoodsOrderList ||
[]
return children.some((child) => isMarketingActive(child?.marketingFlag))
? MARKETING_FLAG_ACTIVE
: 0
}
function normalizeMarketingFlagOnItem(item) {
if (!item) return item
const isPackage =
item.goodsFlag === 3 ||
item.packageGoods ||
item.packageGoodsOrderList?.length ||
(item.packageName &&
(item.goodsList?.length || item.packageGoodsOrderList?.length))
if (isPackage) {
item.marketingFlag = resolvePackageMarketingFlag(item)
return item
}
if (isMarketingActive(item.marketingFlag)) {
item.marketingFlag = MARKETING_FLAG_ACTIVE
return item
}
const nested =
item.goodsInfo?.marketingFlag ??
item.goods?.marketingFlag ??
item.multipleSpecificationsGoods?.marketingFlag
if (isMarketingActive(nested)) {
item.marketingFlag = MARKETING_FLAG_ACTIVE
}
return item
}
function readItemMarketingFlag(item = {}) {
normalizeMarketingFlagOnItem(item)
if (isMarketingActive(item.marketingFlag)) return MARKETING_FLAG_ACTIVE
const nested =
item.goodsInfo?.marketingFlag ??
item.goods?.marketingFlag ??
item.multipleSpecificationsGoods?.marketingFlag
return isMarketingActive(nested) ? MARKETING_FLAG_ACTIVE : 0
}
function resolveMarketingFlag(map = {}, goods = {}) {
if (!goods || !map) return 0
const id = goods.merchantGoodsId || goods.id || goods.goodsId
if (id != null && map[String(id)] === MARKETING_FLAG_ACTIVE) {
return MARKETING_FLAG_ACTIVE
}
return 0
}
export function isSameRefundGoods(refundItem = {}, orderItem = {}) {
if (
refundItem.subOrderCode != null &&
orderItem.subOrderCode != null &&
String(refundItem.subOrderCode) === String(orderItem.subOrderCode)
) {
return true
}
if (
refundItem.merchantGoodsId != null &&
orderItem.merchantGoodsId != null &&
String(refundItem.merchantGoodsId) === String(orderItem.merchantGoodsId)
) {
return true
}
if (
refundItem.upgradeGoodsId != null &&
orderItem.upgradeGoodsId != null &&
String(refundItem.upgradeGoodsId) === String(orderItem.upgradeGoodsId)
) {
return true
}
if (
refundItem.merchantGoodsCode &&
orderItem.merchantGoodsCode &&
String(refundItem.merchantGoodsCode) === String(orderItem.merchantGoodsCode)
) {
return true
}
if (
refundItem.upgradeGoodsCommodityCode &&
orderItem.upgradeGoodsCommodityCode &&
String(refundItem.upgradeGoodsCommodityCode) ===
String(orderItem.upgradeGoodsCommodityCode)
) {
return true
}
return false
}
export function isSamePackageRefundRow(refundItem = {}, pkg = {}) {
if (
refundItem.packageCode &&
pkg.packageCode &&
String(refundItem.packageCode) === String(pkg.packageCode)
) {
return true
}
if (
pkg.packageName &&
refundItem.upgradeGoodsName &&
String(refundItem.upgradeGoodsName) === String(pkg.packageName)
) {
return true
}
return false
}
export function resolveRefundItemMarketingFlag(
refundItem = {},
orderData = {},
catalogFlagMap = {}
) {
if (readItemMarketingFlag(refundItem) === MARKETING_FLAG_ACTIVE) {
return MARKETING_FLAG_ACTIVE
}
for (const item of orderData.subOrderList || []) {
if (!isSameRefundGoods(refundItem, item)) continue
if (readItemMarketingFlag(item) === MARKETING_FLAG_ACTIVE) {
return MARKETING_FLAG_ACTIVE
}
}
for (const pkg of orderData.packageGoodsList || []) {
if (
isSamePackageRefundRow(refundItem, pkg) &&
readItemMarketingFlag(pkg) === MARKETING_FLAG_ACTIVE
) {
return MARKETING_FLAG_ACTIVE
}
}
return resolveMarketingFlag(catalogFlagMap, refundItem) === MARKETING_FLAG_ACTIVE
? MARKETING_FLAG_ACTIVE
: 0
}
export function applyMarketingFlagsToRefundItems(
list = [],
orderData = {},
catalogFlagMap = {}
) {
return list.map((item) => ({
...item,
marketingFlag: resolveRefundItemMarketingFlag(item, orderData, catalogFlagMap)
}))
}
tabWorkOrder/pages/refundApply/tests/refundApplyMarketing.test.mjs
0 → 100644
View file @
b5e3dca
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import {
isSameRefundGoods,
resolveRefundItemMarketingFlag,
applyMarketingFlagsToRefundItems
} from '../services/refundApplyMarketing.pure.mjs'
const orderData = {
subOrderList: [{ subOrderCode: 'S1', marketingFlag: 1, merchantGoodsId: 100 }],
packageGoodsList: [
{
packageName: '活动套餐',
marketingFlag: 1,
packageCode: 'PKG01',
packageGoodsOrderList: [{ subOrderCode: 'C1', marketingFlag: 0 }]
}
]
}
describe('isSameRefundGoods', () => {
it('matches subOrderCode across number and string', () => {
assert.equal(
isSameRefundGoods({ subOrderCode: 1001 }, { subOrderCode: '1001' }),
true
)
})
})
describe('resolveRefundItemMarketingFlag', () => {
it('reads marketingFlag from packageGoodsDetail subOrderList', () => {
assert.equal(
resolveRefundItemMarketingFlag({ subOrderCode: 'S1' }, orderData),
1
)
})
it('matches merchantGoodsId when subOrderCode differs', () => {
assert.equal(
resolveRefundItemMarketingFlag({ merchantGoodsId: 100 }, orderData),
1
)
})
it('reads package marketingFlag by packageName in upgradeGoodsName', () => {
assert.equal(
resolveRefundItemMarketingFlag({ upgradeGoodsName: '活动套餐' }, orderData),
1
)
})
})
describe('resolveRefundItemMarketingFlag with packageGoodsDetail payload', () => {
const packageGoodsDetail = {
merchantId: 44210895,
sceneType: 1,
baseSceneCode: '100101',
subOrderList: [
{
subOrderCode: 'S26062517242071700',
merchantGoodsId: 67373,
merchantGoodsCode: 'MG2026042711030223110',
upgradeGoodsId: 10771,
upgradeGoodsCommodityCode: 'U2603171122461640004',
upgradeGoodsName: 'testD',
marketingFlag: 1
}
],
packageGoodsList: null
}
it('matches goodsSubOrder row by subOrderCode', () => {
assert.equal(
resolveRefundItemMarketingFlag(
{ subOrderCode: 'S26062517242071700', upgradeGoodsName: 'testD' },
packageGoodsDetail
),
1
)
})
it('matches goodsSubOrder row by merchantGoodsCode when subOrderCode missing', () => {
assert.equal(
resolveRefundItemMarketingFlag(
{ merchantGoodsCode: 'MG2026042711030223110', upgradeGoodsName: 'testD' },
packageGoodsDetail
),
1
)
})
})
describe('applyMarketingFlagsToRefundItems', () => {
it('returns new objects with marketingFlag for setData', () => {
const source = [{ subOrderCode: 'S1', upgradeGoodsName: 'A' }]
const result = applyMarketingFlagsToRefundItems(source, orderData, {})
assert.notEqual(result[0], source[0])
assert.equal(result[0].marketingFlag, 1)
assert.equal(source[0].marketingFlag, undefined)
})
it('uses catalog map when order detail misses', () => {
const result = applyMarketingFlagsToRefundItems(
[{ merchantGoodsId: 99 }],
{},
{ 99: 1 }
)
assert.equal(result[0].marketingFlag, 1)
})
})
tabWorkOrder/utils/loadMarketingFlagMap.js
View file @
b5e3dca
...
@@ -23,7 +23,7 @@ export async function loadMarketingMetaMaps(merchantId, options = {}) {
...
@@ -23,7 +23,7 @@ export async function loadMarketingMetaMaps(merchantId, options = {}) {
sceneType
,
sceneType
,
baseSceneCode
baseSceneCode
})
})
if
(
result
?.
code
==
=
0
)
{
if
(
result
?.
code
==
0
)
{
const
{
flagMap
,
activityIdMap
}
=
buildMarketingMetaMaps
(
result
.
data
||
[])
const
{
flagMap
,
activityIdMap
}
=
buildMarketingMetaMaps
(
result
.
data
||
[])
return
{
marketingFlagMap
:
flagMap
,
activityIdMap
}
return
{
marketingFlagMap
:
flagMap
,
activityIdMap
}
}
}
...
...
utils/orderSubOrderExtras.js
View file @
b5e3dca
...
@@ -25,6 +25,66 @@ export function ensureCatalogUpgradePrice(goods = {}) {
...
@@ -25,6 +25,66 @@ export function ensureCatalogUpgradePrice(goods = {}) {
}
}
/**
/**
* 活动商品写入审批弹层「活动价」快照(selectOrderGoods.list 的 sellPrice)
* 与改价后的 sellPrice 分离,避免 ensureCatalogUpgradePrice 落到 upgradePrice
* @param {object} goods 页面商品 / 套餐子项
* @param {object} [catalogGoods] 选品目录对应子项
* @returns {object}
*/
export
function
seedMarketingActivitySellPrice
(
goods
=
{},
catalogGoods
)
{
if
(
!
goods
)
return
goods
const
catalog
=
catalogGoods
||
goods
const
marketingFlag
=
catalog
.
marketingFlag
??
goods
.
marketingFlag
const
activityId
=
catalog
.
activityId
??
goods
.
activityId
if
(
!
isMarketingActive
(
marketingFlag
)
||
activityId
==
null
||
activityId
===
''
)
{
return
goods
}
const
activityPrice
=
catalog
.
sellPrice
??
catalog
.
price
??
goods
.
sellPrice
??
goods
.
price
if
(
activityPrice
!=
null
&&
activityPrice
!==
''
)
{
goods
.
activitySellPrice
=
Number
(
activityPrice
)
}
return
goods
}
/**
* 多规格:为 specificationGoodsMap 内全部 SKU 写入活动价快照与目录价
* @param {object} multipleSpecificationsGoods
* @returns {object}
*/
export
function
seedMultiSpecSkuCatalogPrices
(
multipleSpecificationsGoods
=
{})
{
const
map
=
multipleSpecificationsGoods
.
specificationGoodsMap
if
(
!
map
||
typeof
map
!==
'object'
)
return
multipleSpecificationsGoods
Object
.
values
(
map
).
forEach
(
skuList
=>
{
if
(
!
Array
.
isArray
(
skuList
))
return
skuList
.
forEach
(
sku
=>
{
seedMarketingActivitySellPrice
(
sku
)
ensureCatalogUpgradePrice
(
sku
)
})
})
return
multipleSpecificationsGoods
}
/**
* 再次编辑订单:用选品目录价写入 catalogSellPrice,避免订单回显价污染审批「活动价」
* @param {object} goods 订单回显商品
* @param {object} [catalogGoods] 选品目录 goods
* @returns {object}
*/
export
function
seedCatalogSellPriceFromCatalog
(
goods
=
{},
catalogGoods
=
{})
{
if
(
!
goods
)
return
goods
const
catalogPrice
=
// 活动商品优先取目录 sellPrice,避免取到目录原价(upgradePrice)
catalogGoods
.
sellPrice
??
catalogGoods
.
upgradePrice
??
catalogGoods
.
price
if
(
catalogPrice
!=
null
&&
catalogPrice
!==
''
)
{
goods
.
catalogSellPrice
=
Number
(
catalogPrice
)
}
return
goods
}
/**
* 解析提单子单活动标识:0-否,1-是
* 解析提单子单活动标识:0-否,1-是
* @param {object} ctx
* @param {object} ctx
* @param {object} [ctx.lineItem] goodsList 行
* @param {object} [ctx.lineItem] goodsList 行
...
...
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