Commit f938835f by cen

fix: 折扣

1 parent 8a7d1821
...@@ -161,7 +161,7 @@ const pathEnum = { ...@@ -161,7 +161,7 @@ const pathEnum = {
pad: '/rop-dj-pad/', pad: '/rop-dj-pad/',
clue: '/rop-scrm-clue/', clue: '/rop-scrm-clue/',
evaluation: '/gsc-vcp-pad-facade', evaluation: '/gsc-vcp-pad-facade',
staffMiniprogram: '/rop-dj-staff-miniprogram/', staffMiniprogram: '/rop-dj-staff-miniprogram/'
} }
const CONFIG_ENV_MAP = { const CONFIG_ENV_MAP = {
1: 'develop', 1: 'develop',
......
...@@ -118,7 +118,7 @@ export default { ...@@ -118,7 +118,7 @@ export default {
// 计算最终价格 // 计算最终价格
computedPrice() { computedPrice() {
const basePrice = parseFloat(this.basePrice || 0) const basePrice = parseFloat(this.basePrice || 0)
if (!basePrice) return '-' if (!basePrice) return '¥0.00'
// 打折策略 // 打折策略
if (this.strategyType === 'discount') { if (this.strategyType === 'discount') {
...@@ -291,9 +291,9 @@ export default { ...@@ -291,9 +291,9 @@ export default {
let v = this.localState[key] let v = this.localState[key]
if (key === 'discountAmount' || key === 'deductAmount') { if (key === 'discountAmount' || key === 'deductAmount') {
// 折扣金额/抵扣金额:限制 0.01 到商品原价(直接截断,不四舍五入) // 折扣金额/抵扣金额:限制 0 到商品原价(直接截断,不四舍五入)
if (!v || (typeof v === 'string' && v.trim() === '')) { if (!v || (typeof v === 'string' && v.trim() === '')) {
v = '0.01' v = '0'
} }
// 限制只能输入数字和小数点 // 限制只能输入数字和小数点
v = String(v).replace(/[^\d.]/g, '') v = String(v).replace(/[^\d.]/g, '')
...@@ -393,7 +393,7 @@ export default { ...@@ -393,7 +393,7 @@ export default {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: toRpx(24) toRpx(24) 0 toRpx(24); padding: toRpx(24) toRpx(24) 0 toRpx(24);
border-top: toRpx(3) dashed #E4E7EB; border-top: toRpx(3) dashed #e4e7eb;
box-sizing: border-box; box-sizing: border-box;
} }
......
...@@ -235,6 +235,7 @@ export default { ...@@ -235,6 +235,7 @@ export default {
}) })
const carBrandList = uni.$storage.get('carBrandList') const carBrandList = uni.$storage.get('carBrandList')
const carChildsBrandIds = carBrandList.map(i => i.id) const carChildsBrandIds = carBrandList.map(i => i.id)
const { sceneType } = uni.$storage.get('userInfo')
let params = { let params = {
merchantId: shopMerchantId, merchantId: shopMerchantId,
pageNum, pageNum,
...@@ -242,6 +243,7 @@ export default { ...@@ -242,6 +243,7 @@ export default {
carModel: carModel || '', carModel: carModel || '',
orderStatus: 3, orderStatus: 3,
merchantOrder, merchantOrder,
sceneType: sceneType,
historyOrderGoodsTypes: this.historyOrderGoodsTypes historyOrderGoodsTypes: this.historyOrderGoodsTypes
} }
if (!params.merchantOrder) { if (!params.merchantOrder) {
......
...@@ -197,13 +197,13 @@ export default { ...@@ -197,13 +197,13 @@ export default {
// 回显订单类型(orderType:1 正常订单,2 打折策略,3 买赠策略,4 冲量活动,5 组合付款) // 回显订单类型(orderType:1 正常订单,2 打折策略,3 买赠策略,4 冲量活动,5 组合付款)
const orderTypeMap = { const orderTypeMap = {
'1': '正常订单', 1: '正常订单',
'2': '打折策略', 2: '打折策略',
'3': '买赠策略', 3: '买赠策略',
'4': '冲量活动', 4: '冲量活动',
'5': '组合付款' 5: '组合付款'
} }
const orderTypeCode = data.orderType ? String(data.orderType) : (this.orderObj.orderTypeCode || '1') const orderTypeCode = data.orderType ? String(data.orderType) : this.orderObj.orderTypeCode || '1'
orderObj.orderTypeCode = orderTypeCode orderObj.orderTypeCode = orderTypeCode
orderObj.djOrderType = orderTypeMap[orderTypeCode] || '正常订单' orderObj.djOrderType = orderTypeMap[orderTypeCode] || '正常订单'
// 回显表单中“订单类型”这一行的展示文案 // 回显表单中“订单类型”这一行的展示文案
...@@ -424,9 +424,9 @@ export default { ...@@ -424,9 +424,9 @@ export default {
} }
this.getSelectOrderGoodsList() this.getSelectOrderGoodsList()
if (!paramsData.id) this.getConfig() if (!paramsData.id) this.getConfig()
this.getShopMerchantPointConfig() this.getShopMerchantPointConfig()
this.orderSettingList() this.orderSettingList()
}, },
async orderSettingList() { async orderSettingList() {
...@@ -678,7 +678,7 @@ export default { ...@@ -678,7 +678,7 @@ export default {
checkOrderStrategyAndTotal() { checkOrderStrategyAndTotal() {
const orderTypeCode = String(this.orderObj.orderTypeCode || '') const orderTypeCode = String(this.orderObj.orderTypeCode || '')
const skuGoods = this.orderObj.skuGoods || [] const skuGoods = this.orderObj.skuGoods || []
// 检查订单总价 // 检查订单总价
const total = parseFloat(this.orderObj.total || 0) const total = parseFloat(this.orderObj.total || 0)
if (total < 0.01) { if (total < 0.01) {
...@@ -688,7 +688,7 @@ export default { ...@@ -688,7 +688,7 @@ export default {
}) })
return false return false
} }
// 如果是打折策略(2)、买赠策略(3)、组合付款(5),需要验证策略配置 // 如果是打折策略(2)、买赠策略(3)、组合付款(5),需要验证策略配置
if (orderTypeCode === '2') { if (orderTypeCode === '2') {
// 打折策略:至少存在一项SKU为"比例折扣"或"折扣金额" // 打折策略:至少存在一项SKU为"比例折扣"或"折扣金额"
...@@ -710,7 +710,7 @@ export default { ...@@ -710,7 +710,7 @@ export default {
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) { } else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
goods = item.multipleSpecificationsGoods.goods goods = item.multipleSpecificationsGoods.goods
} }
if (goods) { if (goods) {
const strategyConfig = goods.strategyConfig || {} const strategyConfig = goods.strategyConfig || {}
if (strategyConfig.mode === 'ratio' && strategyConfig.discountRatio) { if (strategyConfig.mode === 'ratio' && strategyConfig.discountRatio) {
...@@ -720,7 +720,7 @@ export default { ...@@ -720,7 +720,7 @@ export default {
} }
} }
}) })
if (!hasDiscount) { if (!hasDiscount) {
uni.showToast({ uni.showToast({
title: '至少存在一项SKU为"比例折扣"或"折扣金额"', title: '至少存在一项SKU为"比例折扣"或"折扣金额"',
...@@ -746,7 +746,7 @@ export default { ...@@ -746,7 +746,7 @@ export default {
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) { } else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
goods = item.multipleSpecificationsGoods.goods goods = item.multipleSpecificationsGoods.goods
} }
if (goods) { if (goods) {
const strategyConfig = goods.strategyConfig || {} const strategyConfig = goods.strategyConfig || {}
if (strategyConfig.isGift === '1') { if (strategyConfig.isGift === '1') {
...@@ -754,7 +754,7 @@ export default { ...@@ -754,7 +754,7 @@ export default {
} }
} }
}) })
if (!hasGift) { if (!hasGift) {
uni.showToast({ uni.showToast({
title: '至少存在一项SKU为"赠品"', title: '至少存在一项SKU为"赠品"',
...@@ -780,7 +780,7 @@ export default { ...@@ -780,7 +780,7 @@ export default {
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) { } else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
goods = item.multipleSpecificationsGoods.goods goods = item.multipleSpecificationsGoods.goods
} }
if (goods) { if (goods) {
const strategyConfig = goods.strategyConfig || {} const strategyConfig = goods.strategyConfig || {}
if (strategyConfig.mode === 'deduct' && strategyConfig.deductAmount) { if (strategyConfig.mode === 'deduct' && strategyConfig.deductAmount) {
...@@ -788,7 +788,7 @@ export default { ...@@ -788,7 +788,7 @@ export default {
} }
} }
}) })
if (!hasDeduct) { if (!hasDeduct) {
uni.showToast({ uni.showToast({
title: '至少存在一项SKU为"抵扣金额"', title: '至少存在一项SKU为"抵扣金额"',
...@@ -797,7 +797,7 @@ export default { ...@@ -797,7 +797,7 @@ export default {
return false return false
} }
} }
return true return true
}, },
async submit() { async submit() {
...@@ -951,7 +951,15 @@ export default { ...@@ -951,7 +951,15 @@ export default {
} }
} }
// '5' 组合付款:没有 discountType 和 discountValue // '5' 组合付款:有抵扣时 discountType=2、discountValue=抵扣金额,无抵扣时 discountType=3
if (orderType === '5') {
if (strategyConfig.mode === 'deduct' && strategyConfig.deductAmount) {
result.discountType = 2
result.discountValue = parseFloat(strategyConfig.deductAmount)
} else {
result.discountType = 3
}
}
return result return result
}, },
...@@ -1081,69 +1089,69 @@ export default { ...@@ -1081,69 +1089,69 @@ export default {
} }
return parseFloat(strVal) return parseFloat(strVal)
}, },
// 计算所有产品的总价 // 计算所有产品的总价
changeTotalPrice() { changeTotalPrice() {
let total = 0 let total = 0
const orderType = String(this.orderObj.orderTypeCode || '') const orderType = String(this.orderObj.orderTypeCode || '')
// 打折(2)/ 买赠(3)/ 组合付款(5)使用优惠后的价格,否则使用原价 // 打折(2)/ 买赠(3)/ 组合付款(5)使用优惠后的价格,否则使用原价
const useFinalPrice = orderType === '2' || orderType === '3' || orderType === '5' const useFinalPrice = orderType === '2' || orderType === '3' || orderType === '5'
// 遍历所有商品 // 遍历所有商品
const productFields = ['skuGoods'] const productFields = ['skuGoods']
productFields.forEach(slotName => { productFields.forEach(slotName => {
const productList = this.orderObj[slotName] const productList = this.orderObj[slotName]
if (Array.isArray(productList) && productList.length > 0) { if (Array.isArray(productList) && productList.length > 0) {
// 计算每个产品的价格 * 数量,并累加到总价 // 计算每个产品的价格 * 数量,并累加到总价
productList.forEach(item => { productList.forEach(item => {
// 单个商品(goodsFlag == 1) // 单个商品(goodsFlag == 1)
if (item.goods && item.goods.sellPrice) { if (item.goods && item.goods.sellPrice) {
const goods = item.goods const goods = item.goods
const number = parseInt(goods.number || 1) const number = parseInt(goods.number || 1)
console.log(goods, '---单商品') console.log(goods, '---单商品')
if (useFinalPrice && goods.finalPrice !== undefined && goods.finalPrice !== null) { if (useFinalPrice && goods.finalPrice !== undefined && goods.finalPrice !== null) {
// 使用优惠后的总价(单位:元) // 使用优惠后的总价(单位:元)
total = NP.plus(total, parseFloat(goods.finalPrice || 0)) total = NP.plus(total, parseFloat(goods.finalPrice || 0))
} else { } else {
// 使用原始价格(单价 * 数量,单位:元) // 使用原始价格(单价 * 数量,单位:元)
total = NP.plus(total, NP.times(goods.sellPrice, number)) total = NP.plus(total, NP.times(goods.sellPrice, number))
}
} }
// 套餐商品(goodsFlag == 3) }
else if (item.packageGoods && item.packageGoods.goodsList && item.packageGoods.goodsList.length > 0) { // 套餐商品(goodsFlag == 3)
console.log(item.packageGoods, '套餐') else if (item.packageGoods && item.packageGoods.goodsList && item.packageGoods.goodsList.length > 0) {
const packageNumber = parseInt(item.packageGoods.number || 1) console.log(item.packageGoods, '套餐')
item.packageGoods.goodsList.forEach(goods => { const packageNumber = parseInt(item.packageGoods.number || 1)
if (goods.sellPrice) { item.packageGoods.goodsList.forEach(goods => {
if (useFinalPrice && goods.finalPrice !== undefined && goods.finalPrice !== null) { if (goods.sellPrice) {
// 使用优惠后的总价(finalPrice 已经是按数量计算后的总价,单位:元) if (useFinalPrice && goods.finalPrice !== undefined && goods.finalPrice !== null) {
total = NP.plus(total, parseFloat(goods.finalPrice || 0)) // 使用优惠后的总价(finalPrice 已经是按数量计算后的总价,单位:元)
} else { total = NP.plus(total, parseFloat(goods.finalPrice || 0))
// 使用原始价格(单价 * 套餐数量) } else {
total = NP.plus(total, NP.times(goods.sellPrice, packageNumber)) // 使用原始价格(单价 * 套餐数量)
} total = NP.plus(total, NP.times(goods.sellPrice, packageNumber))
} }
})
}
// 多规格商品(goodsFlag == 2)
else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) {
console.log(item.multipleSpecificationsGoods, '多规格')
const goods = item.multipleSpecificationsGoods.goods
const number = parseInt(item.multipleSpecificationsGoods.number || 1)
if (useFinalPrice && goods.finalPrice !== undefined && goods.finalPrice !== null) {
// 使用优惠后的总价(单位:元)
total = NP.plus(total, parseFloat(goods.finalPrice || 0))
} else {
// 使用原始价格(单价 * 数量)
total = NP.plus(total, NP.times(goods.sellPrice, number))
} }
})
}
// 多规格商品(goodsFlag == 2)
else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) {
console.log(item.multipleSpecificationsGoods, '多规格')
const goods = item.multipleSpecificationsGoods.goods
const number = parseInt(item.multipleSpecificationsGoods.number || 1)
if (useFinalPrice && goods.finalPrice !== undefined && goods.finalPrice !== null) {
// 使用优惠后的总价(单位:元)
total = NP.plus(total, parseFloat(goods.finalPrice || 0))
} else {
// 使用原始价格(单价 * 数量)
total = NP.plus(total, NP.times(goods.sellPrice, number))
} }
}) }
} })
}) }
console.log(total, 'total') })
// 更新总价(单位:元,保留两位小数) console.log(total, 'total')
this.orderObj.total = (Math.round(total * 100) / 100).toFixed(2) // 更新总价(单位:元,保留两位小数)
}, this.orderObj.total = (Math.round(total * 100) / 100).toFixed(2)
},
// 获取园区店支付方式 // 获取园区店支付方式
async getConfig() { async getConfig() {
......
...@@ -21,30 +21,34 @@ ...@@ -21,30 +21,34 @@
<view class="flex errorBox" v-if="orderCardDetail.oldOrderCode"> <view class="flex errorBox" v-if="orderCardDetail.oldOrderCode">
<view class="order-list align-center flex-1"> <view class="order-list align-center flex-1">
<text>原错误订单编号</text> <text>原错误订单编号</text>
<text class="priceName">{{ orderCardDetail.oldOrderCode }}</text> <text class="priceName">{{ orderCardDetail.oldOrderCode }}</text>
</view> </view>
<view class="order-list align-center flex-1"> <view class="order-list align-center flex-1">
<text>原错误订单总价</text> <text>原错误订单总价</text>
<text class="priceName">¥{{orderCardDetail.oldOrderFinalPrice }}</text> <text class="priceName">¥{{ orderCardDetail.oldOrderFinalPrice }}</text>
</view> </view>
</view> </view>
<view class="order-card-bottom-box"> <view class="order-card-bottom-box">
<view class="info-box"> <view class="info-box">
<view class="order-list align-center"> <view class="order-list align-center">
<view class="order flex align-center"> <view class="order flex align-center">
<view class="order-label">订单类型 </view> <view class="order-label">订单类型</view>
<view class="order-value flex">{{ orderTypeText[orderCardDetail.orderType] }} <view class="order-value flex">
<view class="flex align-center errorTips" v-if="orderCardDetail.abnormalFlag == true"><view class="sprite-icon icon-errortips"></view>异常</view> {{ orderTypeText[orderCardDetail.orderType] }}
</view> <view class="flex align-center errorTips" v-if="orderCardDetail.abnormalFlag == true">
<view class="sprite-icon icon-errortips"></view>
异常
</view>
</view> </view>
</view>
</view> </view>
<view class="order-list align-center"> <view class="order-list align-center">
<view class="order flex align-center"> <view class="order flex align-center">
<view class="order-label">审批状态 </view> <view class="order-label">审批状态</view>
<view class="order-value flex">{{ goodsOrderApplyStatus[orderCardDetail.approveStatus] }}</view> <view class="order-value flex">{{ goodsOrderApplyStatus[orderCardDetail.approveStatus] || '-' }}</view>
</view> </view>
</view> </view>
<view class="order-list align-center" v-for="(item, sindex) in orderCardDetail.deliveryId ? pointsMultiObj : orderObj" :key="sindex"> <view class="order-list align-center" v-for="(item, sindex) in orderCardDetail.deliveryId ? pointsMultiObj : orderObj" :key="sindex" v-if="(item.key !== 'remark' || orderCardDetail.orderStatus === '-1') && (item.key !== 'payTime' || orderCardDetail.orderStatus === '3' || orderCardDetail.orderStatus === '5')">
<view v-if="item.key == 'remark' || item.key == 'payTime' || item.key == 'createdTime'"> <view v-if="item.key == 'remark' || item.key == 'payTime' || item.key == 'createdTime'">
<view class="order flex align-center" v-if="item.key == 'remark' && orderCardDetail.orderStatus == '-1'"> <view class="order flex align-center" v-if="item.key == 'remark' && orderCardDetail.orderStatus == '-1'">
<view class="order-label">{{ item.label }}</view> <view class="order-label">{{ item.label }}</view>
...@@ -58,7 +62,6 @@ ...@@ -58,7 +62,6 @@
<view>{{ orderCardDetail[item.key] || '' }}</view> <view>{{ orderCardDetail[item.key] || '' }}</view>
</view> </view>
</view> </view>
<!-- &&( item.orderStatus == '3'||item.orderStatus =='5') -->
<view class="order flex align-center" v-if="item.key == 'createdTime'"> <view class="order flex align-center" v-if="item.key == 'createdTime'">
<view class="order-label">{{ item.label }}</view> <view class="order-label">{{ item.label }}</view>
<view class="order-value"> <view class="order-value">
...@@ -103,7 +106,7 @@ ...@@ -103,7 +106,7 @@
</view> </view>
<view class="refund-box" v-if="orderCardDetail.refundAmount"> <view class="refund-box" v-if="orderCardDetail.refundAmount">
部分退款 部分退款
<text class="unit">¥</text> <text class="refund-box-unit">¥</text>
{{ orderCardDetail.refundAmount }} {{ orderCardDetail.refundAmount }}
</view> </view>
<!-- 已录单未签名 --> <!-- 已录单未签名 -->
...@@ -1342,8 +1345,22 @@ export default { ...@@ -1342,8 +1345,22 @@ export default {
} }
.errorTips { .errorTips {
color: #eb4e4e; color: #eb4e4e;
font-size: toRpx(24); font-size: toRpx(24);
font-weight: 400; font-weight: 400;
margin-left: toRpx(16); margin-left: toRpx(16);
}
.refund-box {
margin-left: toRpx(16);
background: #fff2e0;
padding: toRpx(4) toRpx(8);
color: #f7a431;
font-size: toRpx(24);
font-weight: 500;
font-family: 'numberBold';
border-radius: toRpx(4);
}
.refund-box .refund-box-unit {
font-size: toRpx(24);
} }
</style> </style>
...@@ -118,7 +118,7 @@ export default { ...@@ -118,7 +118,7 @@ export default {
// 计算最终价格 // 计算最终价格
computedPrice() { computedPrice() {
const basePrice = parseFloat(this.basePrice || 0) const basePrice = parseFloat(this.basePrice || 0)
if (!basePrice) return '-' if (!basePrice) return '¥0.00'
// 打折策略 // 打折策略
if (this.strategyType === 'discount') { if (this.strategyType === 'discount') {
...@@ -291,9 +291,9 @@ export default { ...@@ -291,9 +291,9 @@ export default {
let v = this.localState[key] let v = this.localState[key]
if (key === 'discountAmount' || key === 'deductAmount') { if (key === 'discountAmount' || key === 'deductAmount') {
// 折扣金额/抵扣金额:限制 0.01 到商品原价(直接截断,不四舍五入) // 折扣金额/抵扣金额:限制 0 到商品原价(直接截断,不四舍五入)
if (!v || (typeof v === 'string' && v.trim() === '')) { if (!v || (typeof v === 'string' && v.trim() === '')) {
v = '0.01' v = '0'
} }
// 限制只能输入数字和小数点 // 限制只能输入数字和小数点
v = String(v).replace(/[^\d.]/g, '') v = String(v).replace(/[^\d.]/g, '')
...@@ -313,9 +313,9 @@ export default { ...@@ -313,9 +313,9 @@ export default {
const basePrice = parseFloat(this.basePrice || 0) const basePrice = parseFloat(this.basePrice || 0)
let amount = parseFloat(v) let amount = parseFloat(v)
// 限制最小值为 0.01 // 限制最小值为 0
if (isNaN(amount) || amount < 0.01) { if (isNaN(amount) || amount < 0) {
v = '0.01' v = '0'
} }
// 限制最大值为基础价格 // 限制最大值为基础价格
else if (basePrice > 0 && amount > basePrice) { else if (basePrice > 0 && amount > basePrice) {
...@@ -393,7 +393,7 @@ export default { ...@@ -393,7 +393,7 @@ export default {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: toRpx(24) toRpx(24) 0 toRpx(24); padding: toRpx(24) toRpx(24) 0 toRpx(24);
border-top: toRpx(3) dashed #E4E7EB; border-top: toRpx(3) dashed #e4e7eb;
box-sizing: border-box; box-sizing: border-box;
} }
...@@ -490,7 +490,7 @@ export default { ...@@ -490,7 +490,7 @@ export default {
} }
.amount-input-inner { .amount-input-inner {
width: toRpx(140); width: toRpx(250);
padding-left: toRpx(8); padding-left: toRpx(8);
text-align: right; text-align: right;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!