Commit f938835f by cen

fix: 折扣

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