Commit 858e127b by 张立顺

Merge branch 'SAAS+V5.8.3' of http://192.168.3.233:8090/saas_plus/dj-car-boutiqu…

…e-work-wechat into SAAS+V5.8.3
2 parents 2735007c 2a7b7a86
......@@ -388,6 +388,7 @@ Component({
if (c.active) {
if (c.goods) {
if (!c.count) c.count = 1
ensureCatalogUpgradePrice(c.goods)
c.goods.price = c.goods.sellPrice || 0
if (chooseGoodsList.length > 0) {
chooseGoodsList.map(x => {
......
......@@ -1928,8 +1928,9 @@ Page({
if (val.goodsFlag == 1) {
let subVal = val.goods
subVal.positionStr = subVal.position
subVal.upgradePrice = subVal.sellPrice
subVal.upgradePrice = subVal.upgradePrice ?? subVal.sellPrice
subVal.price = subVal.sellPrice
ensureCatalogUpgradePrice(subVal)
subVal.goodsId = subVal.merchantGoodsId
//前挡
if ([1].includes(subVal.merchantGoodsPosition)) {
......@@ -1975,10 +1976,12 @@ Page({
}
//套餐
if (val.goodsFlag == 3) {
val.packageGoods?.goodsList?.forEach(g => ensureCatalogUpgradePrice(g))
packageList.push(val)
}
//商品多规格
if (val.goodsFlag == 2) {
ensureCatalogUpgradePrice(val.multipleSpecificationsGoods)
val.multipleSpecificationsGoods.specificationList.forEach(
item => {
item.specificationSelectValueList = []
......@@ -2258,6 +2261,7 @@ Page({
matchedCatalogItem?.goods?.activityId ??
null
if (activityId != null) e.activityId = activityId
ensureCatalogUpgradePrice(e)
chooseList.push({
goodsFlag: 1,
goods: e,
......@@ -2611,6 +2615,7 @@ Page({
if (activityId != null) {
goodsInfo.activityId = activityId
}
ensureCatalogUpgradePrice(goodsInfo)
const row = {
...obj,
......
......@@ -58,9 +58,10 @@ describe('orderSubOrderExtras', () => {
})
it('resolveSubmitModifyFlag detects price change against catalogSellPrice', () => {
const goods = ensureCatalogUpgradePrice({ sellPrice: 100 })
const goods = ensureCatalogUpgradePrice({ sellPrice: 100, upgradePrice: 100 })
assert.equal(resolveSubmitModifyFlag(goods), 0)
goods.sellPrice = 120
goods.basePrice = 120
assert.equal(resolveSubmitModifyFlag(goods), 1)
})
......@@ -74,4 +75,14 @@ describe('orderSubOrderExtras', () => {
1
)
})
it('ensureCatalogUpgradePrice prefers upgradePrice over modified sellPrice', () => {
const goods = ensureCatalogUpgradePrice({
upgradePrice: 100,
sellPrice: 80,
basePrice: 80
})
assert.equal(goods.catalogSellPrice, 100)
assert.equal(resolveSubmitModifyFlag(goods), 1)
})
})
......@@ -7,15 +7,19 @@ import { isMarketingActive } from './marketingFlag.js'
/**
* 记录目录原价 catalogSellPrice,供 modifyFlag 比对(不覆盖已有值)
* 单品场景 createOrder 加载时会设 upgradePrice,亦可作为目录价回退
* 优先取接口 upgradePrice,避免提交时用改价后的 sellPrice 覆盖导致 modifyFlag 恒为 0
* @param {object} goods 单品 / 规格 SKU / 套餐子商品
* @returns {object}
*/
export function ensureCatalogUpgradePrice(goods = {}) {
if (!goods) return goods
const sellPrice = goods.sellPrice ?? goods.price
if (goods.catalogSellPrice == null && sellPrice != null) {
goods.catalogSellPrice = sellPrice
if (!goods || goods.catalogSellPrice != null) return goods
const catalogPrice =
goods.upgradePrice ??
goods.originalPrice ??
goods.sellPrice ??
goods.price
if (catalogPrice != null && catalogPrice !== '') {
goods.catalogSellPrice = catalogPrice
}
return goods
}
......@@ -72,13 +76,14 @@ export function appendSubmitActivityId(subOrder = {}, ctx = {}) {
}
/**
* 解析商品价格修改标识:对比当前单价与目录价
* 解析商品价格修改标识:对比当前单价与目录价(basePrice/sellPrice vs catalogSellPrice/upgradePrice)
* @param {object} goods
* @returns {0|1}
*/
export function resolveSubmitModifyFlag(goods = {}) {
const currentPrice = goods.sellPrice ?? goods.price
const catalogPrice = goods.catalogSellPrice ?? goods.upgradePrice
const currentPrice = goods.basePrice ?? goods.sellPrice ?? goods.price
const catalogPrice =
goods.catalogSellPrice ?? goods.upgradePrice ?? goods.originalPrice
if (currentPrice == null || catalogPrice == null) return 0
return Number(currentPrice) !== Number(catalogPrice) ? 1 : 0
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!