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