问题修复,下单修复

This commit is contained in:
2025-09-29 16:54:35 +08:00
parent 719a513371
commit afa769579a
16 changed files with 417 additions and 167 deletions

View File

@@ -21,7 +21,7 @@
</view> </view>
<view class="icon icon3" v-if="props.item.couponType == 3"> <view class="icon icon3" v-if="props.item.couponType == 3">
<view class="top"> <view class="top">
<text class="num">{{ props.item.discountRate }}</text> <text class="num">{{ props.item.discountRate/10 }}</text>
</view> </view>
<view class="intro"> <view class="intro">
<text class="t">{{ props.item.fullAmount }}可用</text> <text class="t">{{ props.item.fullAmount }}可用</text>

View File

@@ -12,7 +12,7 @@
<scroll-view scroll-y="true" class="u-m-t-42" style="max-height: 50vh;"> <scroll-view scroll-y="true" class="u-m-t-42" style="max-height: 50vh;">
<view class="list"> <view class="list">
<view class="item u-flex u-m-b-32 u-col-center" v-for="(item,index) in list" :key="index"> <view class="item u-flex u-m-b-32 u-col-center" v-for="(item,index) in list" :key="index">
<view class="left"> <view class="left" style="min-width: 162rpx;">
<couponIcon :item="item.coupon" /> <couponIcon :item="item.coupon" />
<!-- <view class="red font-16 font-700" style="width: 122rpx;">第二件半价券</view> --> <!-- <view class="red font-16 font-700" style="width: 122rpx;">第二件半价券</view> -->
<view></view> <view></view>

View File

@@ -6,7 +6,7 @@
<up-radio-group v-model="radiovalue" iconPlacement="right" @change="groupChanges" :size="28" <up-radio-group v-model="radiovalue" iconPlacement="right" @change="groupChanges" :size="28"
placement="column"> placement="column">
<block v-for="(item,index) in paymentMethodList" :key="index"> <block v-for="(item,index) in paymentMethodList" :key="index">
<view class="method_list" @click="groupChanges(item.type)" <view class="method_list" @click="groupChanges(item.type)" :class="{disabled:returnDisabled(item)}"
v-if="(index+1) == radiovalue?!changeFreeenable:true"> v-if="(index+1) == radiovalue?!changeFreeenable:true">
<view class="method_list_top"> <view class="method_list_top">
<view class="method_list_top_left"> <view class="method_list_top_left">
@@ -14,10 +14,9 @@
<view class="method_list_top_cen"> <view class="method_list_top_cen">
<view class="name"> {{ item.name }} </view> <view class="name"> {{ item.name }} </view>
<view class="method_list_bom" v-if="item.type == 1"> <view class="method_list_bom" v-if="item.type == 1">
<text class="balance" v-if="orderVIP.isVip == 1"> <text class="balance">
会员卡余额{{orderVIP?orderVIP.amount:0}}</text> 当前余额{{orderVIP?orderVIP.amount:0}}</text>
<text class="topUpNow" <text class="topUpNow" @click="goRecharge">去充值</text>
@click="goRecharge">{{orderVIP.isVip == 0?'注册会员':'去充值'}}</text>
</view> </view>
</view> </view>
</view> </view>
@@ -59,11 +58,24 @@
changeFreeenable: { changeFreeenable: {
type: Boolean, type: Boolean,
default: false default: false
},
disablePayType: {
type: Array,
default: () => {
return []
}
} }
}); });
function returnDisabled(item) {
if (props.disablePayType.includes(item.name)) {
return true
}else{
return false
}
}
const orderVIP = ref(null) const orderVIP = ref(null)
const emits = defineEmits(['customevent', 'groupChange']); const emits = defineEmits(['customevent', 'groupChange']);
watchEffect(() => { watchEffect(() => {
@@ -131,6 +143,13 @@
if (props.freeCheck && type == 1) { if (props.freeCheck && type == 1) {
return; return;
} }
const item=paymentMethodList.value.find(v=>v.type==type)
if(item&&returnDisabled(item)){
return uni.showToast({
title:"当前支付方式不可用",
icon:'none'
})
}
// if (props.payAmount <= 0 && type != 1) { // if (props.payAmount <= 0 && type != 1) {
// return; // return;
// } // }
@@ -142,16 +161,16 @@
// 去充值 // 去充值
const goRecharge = () => { const goRecharge = () => {
if(orderVIP.value.isVip){ if (orderVIP.value.isVip) {
uni.navigateTo({ uni.navigateTo({
url:'/pages/user/member/czzx?shopId='+orderVIP.value.shopId url: '/pages/user/member/czzx?shopId=' + orderVIP.value.shopId
}) })
return return
} }
uni.navigateTo({ uni.navigateTo({
url:'/user/vip/buy-vip?shopId='+orderVIP.value.shopId url: '/user/vip/buy-vip?shopId=' + orderVIP.value.shopId
}) })
// uni.pro.navigateTo('user/member/index', { // uni.pro.navigateTo('user/member/index', {
// shopId: orderVIP.value.shopId // shopId: orderVIP.value.shopId
// }) // })
@@ -185,7 +204,9 @@
.method_list { .method_list {
padding: 40rpx 0; padding: 40rpx 0;
box-sizing: border-box; box-sizing: border-box;
&.disabled{
opacity: .6;
}
.method_list_top { .method_list_top {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@@ -327,6 +327,7 @@ onShow(async () => {
uni.getLocation({ uni.getLocation({
type: 'wgs84', type: 'wgs84',
success: async (res) => { success: async (res) => {
console.log('getLocation',res);
let successres = await APIgeocodelocation({ let successres = await APIgeocodelocation({
lng: res.longitude, lng: res.longitude,
lat: res.latitude lat: res.latitude
@@ -344,29 +345,15 @@ onShow(async () => {
// 登录 // 登录
proxy.$isResolve(); proxy.$isResolve();
} }
},
fail(error) {
console.error('获取经纬度失败',error);
} }
}); });
indexsRef.value.getVipConfig(); indexsRef.value.getVipConfig();
} catch (error) { } catch (error) {
try {
let successres = await APIgeocodelocation({
lng: '',
lat: ''
});
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // "中国"
province: successres.addressComponent.province, //province: "陕西省"
address: successres.addressComponent.city, //district: "西安市"
district: successres.addressComponent.district, //district: "未央区"
lng: res.longitude,
lat: res.latitude
};
uni.cache.set('getLocationstorage', datastorage);
proxy.$isResolve();
}
} catch (error) {}
} }
await proxy.$onLaunched; await proxy.$onLaunched;
if (uni.cache.get('shopId')) { if (uni.cache.get('shopId')) {

View File

@@ -21,8 +21,8 @@
</view> </view>
<view class="font-12" v-if="item.rewardPoints"> <view class="font-12" v-if="item.rewardPoints">
<text></text> <text></text>
<text></text>
<text class="font-14">{{item.rewardPoints}}</text> <text class="font-14">{{item.rewardPoints}}</text>
<text>积分</text>
</view> </view>
<view class="font-12 color-666" v-if="item.couponInfoList.length"> <view class="font-12 color-666" v-if="item.couponInfoList.length">
<text></text> <text></text>

View File

@@ -117,7 +117,8 @@
v-if="item.icon" :src="item.icon" mode=""></u-image> v-if="item.icon" :src="item.icon" mode=""></u-image>
</view> </view>
<text class="name u-m-l-16 no-wrap"> {{ item.name }} </text> <text class="name u-m-l-16 no-wrap"> {{ item.name }} </text>
<text class="font-12 u-p-l-6" style="color: #666;margin-right: 16rpx;max-width: 360rpx;" v-if="item.type=='points'"> <text class=" u-p-l-6" style="color: #666;max-width: 400rpx;font-size: 10px;"
v-if="item.type=='points'">
可用积分{{pointsRes.accountPoints}}最大可抵扣{{maxPointDiscount}} 可用积分{{pointsRes.accountPoints}}最大可抵扣{{maxPointDiscount}}
</text> </text>
@@ -126,8 +127,17 @@
<!-- 优惠卷 --> <!-- 优惠卷 -->
<view class="favorable_right" v-if="item.type=='coupon'"> <view class="favorable_right" v-if="item.type=='coupon'">
<text class="favorable_right_text red" <template v-if="cartStore.orderCostSummary.couponDeductionAmount>0">
v-if="returnCouponDiscount>0">-{{returnCouponDiscount}}</text> <text
class="favorable_right_text red">-{{cartStore.orderCostSummary.couponDeductionAmount}}</text>
</template>
<template v-else>
<text class="favorable_right_text red" v-if="hasCouponCanUse">有可用优惠券</text>
<text class=" favorable_right_text " v-else>暂无可用优惠券</text>
</template>
<up-icon name="arrow-right" color="#575B66" size="16" <up-icon name="arrow-right" color="#575B66" size="16"
v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'||!listinfo.id"></up-icon> v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'||!listinfo.id"></up-icon>
@@ -142,14 +152,17 @@
<!-- 积分 --> <!-- 积分 -->
<view class="favorable_right u-flex u-col-center" v-if="item.type=='points'"> <view class="favorable_right u-flex u-col-center" v-if="item.type=='points'">
<up-icon name="checkmark-circle-fill" size="24rpx" v-if="usePoints" <template v-if="usePoints&&cartStore.orderCostSummary.pointDeductionAmount">
color="#FE7E00"></up-icon> <up-icon name="checkmark-circle-fill" size="24rpx" color="#FE7E00"></up-icon>
<text v-if="usePoints" class="red"> <text class="red">
-¥{{cartStore.orderCostSummary.pointDeductionAmount}} -¥{{cartStore.orderCostSummary.pointDeductionAmount}}
</text> </text>
</template>
<view v-else class="u-flex u-col-center"> <view v-else class="u-flex u-col-center">
<view class="round"></view> <view class="round"></view>
<text class="color-333 font-12 no-wrap">使用抵扣</text> <text class="color-333 font-12 no-wrap u-m-l-4">使用抵扣</text>
</view> </view>
</view> </view>
<!-- <view class="favorable_right" v-if="item.type=='points'"> <!-- <view class="favorable_right" v-if="item.type=='points'">
@@ -218,21 +231,6 @@
</view> </view>
</view> </view>
<view class="orderInfo">
<view class="">
<view class="t">
订单备注
</view>
<view class="u-m-t-18 ">
<up-textarea border="none" placeholder="请填写口味、偏好等要求" :type="'textarea'" v-model="listinfo.remark"
:clearable="true" />
</view>
</view>
</view>
<IntegralInput :visible="calcUsablePointsData.showModal" :minValue="calcUsablePointsData.minIntegral" <IntegralInput :visible="calcUsablePointsData.showModal" :minValue="calcUsablePointsData.minIntegral"
:maxValue="calcUsablePointsData.maxIntegral" :instructions="calcUsablePointsData.instructionText" :maxValue="calcUsablePointsData.maxIntegral" :instructions="calcUsablePointsData.instructionText"
@@ -260,8 +258,15 @@
watch, watch,
watchEffect, watchEffect,
defineExpose, defineExpose,
toRaw,
onMounted
} from 'vue' } from 'vue'
import {
returnHasCouponCanUse
} from '@/utils/coupon.js'
let hasCouponCanUse = ref(false)
const usePoints = ref(false) const usePoints = ref(false)
@@ -300,7 +305,7 @@
}, },
]) ])
const favorablelist = reactive([{ const favorablelist = ref([{
name: "新客立减", name: "新客立减",
type: "newUser", type: "newUser",
width: '40rpx', width: '40rpx',
@@ -390,15 +395,15 @@
// 操作优惠卷 // 操作优惠卷
const dataprocessing = (data) => { const dataprocessing = (data) => {
favorablelist[1].value = data favorablelist.value[1].value = data
} }
const returnCouponDiscount = computed(() => { const returnCouponDiscount = computed(() => {
if (!favorablelist[1].value) { if (!favorablelist.value[1].value) {
return 0 return 0
} }
return favorablelist[1].value.reduce((prve, cur) => { return favorablelist.value[1].value.reduce((prve, cur) => {
return prve + (cur.discountAmount || 0) return prve + (cur.discountAmount || 0)
}, 0) }, 0)
}) })
@@ -407,8 +412,8 @@
const bwcclear = () => { const bwcclear = () => {
IntegralInputclose() IntegralInputclose()
// 清空优惠卷 // 清空优惠卷
favorablelist[1].value = '' favorablelist.value[1].value = ''
favorablelist[1].value = '' favorablelist.value[1].value = ''
} }
const dinnerType = computed(() => { const dinnerType = computed(() => {
return is_type.value ? 'take-out' : 'dine-ine' return is_type.value ? 'take-out' : 'dine-ine'
@@ -418,10 +423,7 @@
const canDikouGoodsArr = props.nowCarts const canDikouGoodsArr = props.nowCarts
const goodsOrderPrice = props.listinfo.totalPrices const goodsOrderPrice = props.listinfo.totalPrices
// const user=uni.cache.get('shopUserInfo') // const user=uni.cache.get('shopUserInfo')
uni.setStorageSync('canDikouGoodsArr', canDikouGoodsArr)
uni.setStorageSync('goodsOrderPrice', goodsOrderPrice) uni.setStorageSync('goodsOrderPrice', goodsOrderPrice)
uni.setStorageSync('dinnerType', dinnerType.value)
if (props.isBwc) { if (props.isBwc) {
uni.showToast({ uni.showToast({
@@ -432,36 +434,13 @@
} }
switch (item.type) { switch (item.type) {
case 'coupon': case 'coupon':
// 清空积分
IntegralInputclose()
favorablelist[1].value = ''
emits('learcoupons', 'coupon') emits('learcoupons', 'coupon')
console.log('payAmount', props.listinfo.totalPrices, props.listinfo uni.pro.navigateTo('/pages/order/coupon', {})
.Productroll);
uni.pro.navigateTo('/pages/order/coupon', {
type: "confirm_order_coupon",
shopId: uni.cache.get('orderVIP').shopId,
shopUserId: props.orderVIP.id,
payAmount: (parseFloat(props.listinfo.totalPrices) - parseFloat(props.listinfo
.Productroll)).toFixed(2),
shoppingCart: JSON.stringify([...props.nowCarts, ...props.listinfo.combinedArray]),
})
break; break;
case 'points': case 'points':
chnageIsUsePoints() chnageIsUsePoints()
return return
IntegralInputclose()
if (calcUsablePointsData.usable == 0) {
uni.showToast({
title: calcUsablePointsData.unusableReason,
icon: 'none'
})
return false;
}
console.log('calcUsablePointsData:', calcUsablePointsData)
calcUsablePointsData.showModal = true
break;
} }
} }
@@ -479,27 +458,35 @@
const pointsRes = reactive({ const pointsRes = reactive({
accountPoints: 0 accountPoints: 0
}) })
getMaxPointsDiscount() const maxPointDiscount = ref(0)
const maxPointDiscount=ref(0) //积分可抵扣最大金额
async function getMaxPointsDiscount() { const maxMoney = computed(() => {
//积分可抵扣最大金额 return cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
const maxMoney = cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
.couponDeductionAmount .couponDeductionAmount
})
async function getMaxPointsDiscount() {
let res = await APImemberPointscalcUsablePoints({ let res = await APImemberPointscalcUsablePoints({
shopUserId: props.orderVIP.id, shopUserId: props.orderVIP.id,
orderAmount: maxMoney orderAmount: maxMoney.value
}) })
console.log(res); console.log(res);
Object.assign(pointsRes, res) Object.assign(pointsRes, res)
const maxUsablePoints = res.maxUsablePoints const maxUsablePoints = res.maxUsablePoints
maxPointDiscount.value=res.maxDeductionAmount maxPointDiscount.value = res.maxDeductionAmount
// props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({ // props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({
// points: maxUsablePoints, // points: maxUsablePoints,
// shopUserId: props.orderVIP.id, // shopUserId: props.orderVIP.id,
// orderAmount: maxMoney // orderAmount: maxMoney
// }) // })
cartStore.setUserPoints(maxUsablePoints) if (usePoints.value) {
cartStore.setUserPoints(maxUsablePoints)
}
} }
watch(() => maxMoney.value, (newval) => {
console.log('maxMoney.value', newval);
getMaxPointsDiscount()
})
watch(() => usePoints.value, (newval) => { watch(() => usePoints.value, (newval) => {
if (newval) { if (newval) {
getMaxPointsDiscount() getMaxPointsDiscount()
@@ -571,21 +558,47 @@
}); });
watch(() => props.listinfo.seatNum, (newval) => { watch(() => props.listinfo.seatNum, (newval) => {
cartStore.setSeatFeeConfig('personCount', newval || 1) cartStore.setSeatFeeConfig('personCount', newval || 0)
}) })
const newUserDiscount = ref(0) const newUserDiscount = ref(0)
const back_favorablelist = toRaw(favorablelist.value)
async function getConsumeDiscount() { async function getConsumeDiscount() {
const consumeDiscountRes = await consumeDiscount({ const consumeDiscountRes = await consumeDiscount({
shopId: uni.cache.get('shopId'), shopId: uni.cache.get('shopId'),
}) })
if (consumeDiscountRes&&consumeDiscountRes.isUse) { if (!consumeDiscountRes.isUse) {
favorablelist.value = back_favorablelist.filter(v => v.name != '新客立减')
}
if (consumeDiscountRes && consumeDiscountRes.isUse) {
newUserDiscount.value = consumeDiscountRes.amount newUserDiscount.value = consumeDiscountRes.amount
cartStore.newUserDiscount = consumeDiscountRes.amount || 0 cartStore.newUserDiscount = consumeDiscountRes.amount || 0
cartStore.consumeDiscount=consumeDiscountRes cartStore.consumeDiscount = consumeDiscountRes
} }
} }
getConsumeDiscount()
onMounted(async () => {
getConsumeDiscount()
//积分可抵扣最大金额
const goodsOrderPrice = cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
const dinnerType = cartStore.dinnerType
const shopInfo = cartStore.shopInfo
const shopId = cartStore.shopInfo.shopId
const user = uni.cache.get('shopUserInfo')
const shopUserId = user.id
const allGoods = cartStore.allGoods
hasCouponCanUse.value = await returnHasCouponCanUse({
goodsOrderPrice,
dinnerType,
shopId,
shopInfo,
shopUserId,
allGoods,
user
})
console.log('hasCouponCanUse', hasCouponCanUse.value);
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -44,6 +44,18 @@
:ordershopUserInfo='ordershopUserInfo' @istype="istype" @clickPointsamount='clickPointsamount' :ordershopUserInfo='ordershopUserInfo' @istype="istype" @clickPointsamount='clickPointsamount'
@learcoupons="learcoupons" :isBwc='isBwc'> @learcoupons="learcoupons" :isBwc='isBwc'>
</orderInfo> </orderInfo>
<!-- 订单备注 -->
<view class="orderInfo">
<view class="">
<view class="t">
订单备注
</view>
<view class="u-m-t-18 ">
<up-textarea border="none" placeholder="请填写口味、偏好等要求" :type="'textarea'" v-model="listinfo.remark"
:clearable="true" />
</view>
</view>
</view>
<!-- 霸王餐 --> <!-- 霸王餐 -->
<rechargeFree :freeDineConfig="orderVIP.freeDineConfig" :payAmount="listinfo.totalPrices" <rechargeFree :freeDineConfig="orderVIP.freeDineConfig" :payAmount="listinfo.totalPrices"
v-if="(listinfo.status == 'unpaid'||!listinfo.id) && orderVIP.freeDineConfig.enable" v-if="(listinfo.status == 'unpaid'||!listinfo.id) && orderVIP.freeDineConfig.enable"
@@ -51,17 +63,21 @@
</rechargeFree> </rechargeFree>
<!-- 充值享优惠 --> <!-- 充值享优惠 -->
<view v-else> <view v-else>
<ChargeVue @updateChargeSel="updateChargeSel" @updateRechargeId="updateRechargeId" v-if="(listinfo.status == 'unpaid'||!listinfo.id)"></ChargeVue> <ChargeVue @updateChargeSel="updateChargeSel" @updateRechargeId="updateRechargeId"
v-if="(listinfo.status == 'unpaid'||!listinfo.id)"></ChargeVue>
</view> </view>
<!-- 支付方式 --> <!-- 支付方式 -->
<paymentMethodes ref="paymentMethodref" :orderVIP="orderVIP" @groupChange="groupChange" <paymentMethodes ref="paymentMethodref" :orderVIP="orderVIP" @groupChange="groupChange"
:changeFreeenable="isBwc" v-if="listinfo.status == 'unpaid'||!listinfo.id"> :disablePayType="disablePayType" :changeFreeenable="isBwc" v-if="listinfo.status == 'unpaid'||!listinfo.id">
</paymentMethodes> </paymentMethodes>
<view class="fixedview"> <view class="fixedview">
<view class="flex-between" v-if="listinfo.status == 'unpaid'||!listinfo.id"> <view class="flex-between" v-if="listinfo.status == 'unpaid'||!listinfo.id">
<view class="fixedview_one flex-start"> <view class="fixedview_one flex-start">
<view class="fixedview_oneone"> 实付金额 </view> <view class="fixedview_oneone"> 实付金额 </view>
<view class="fixedview_onetow"> <view class="fixedview_onetow" v-if="rechargeItem.id">
<text>¥</text>{{rechargeItem.amount}}
</view>
<view class="fixedview_onetow" v-else>
<text>¥</text>{{cartStore.orderCostSummary.finalPayAmount}} <text>¥</text>{{cartStore.orderCostSummary.finalPayAmount}}
</view> </view>
</view> </view>
@@ -77,6 +93,12 @@
<text class="u-font-32 color-main u-m-l-16">加菜</text> <text class="u-font-32 color-main u-m-l-16">加菜</text>
</view> </view>
</up-button> </up-button>
<up-button shape="circle" v-if="listinfo.id&&listinfo.status=='unpaid'" plain
@tap="cancelOrder" :custom-style="customStyle">
<view class="u-flex u-flex-y-center">
<text class="u-font-32 color-main u-m-l-16">取消订单</text>
</view>
</up-button>
</template> </template>
<template v-else> <template v-else>
<up-button v-if="!cartStore.isEmpty" shape="circle" @click="onlyCreateOrder" plain <up-button v-if="!cartStore.isEmpty" shape="circle" @click="onlyCreateOrder" plain
@@ -123,6 +145,10 @@
import { import {
pay pay
} from '@/utils/pay.js' } from '@/utils/pay.js'
import * as UTILS from '@/utils/goods-utils.js'
import {
findCoupon
} from '@/common/api/market/coupon.js';
function onback() { function onback() {
closeSocket() closeSocket()
@@ -155,7 +181,8 @@
APIgetOrderById, APIgetOrderById,
APIputuserorder, APIputuserorder,
APIhistoryOrder, APIhistoryOrder,
rechargePayOrder rechargePayOrder,
APIcancelOrder
} from '@/common/api/order/index.js' } from '@/common/api/order/index.js'
import { import {
APIusershopInfodetail, APIusershopInfodetail,
@@ -171,9 +198,12 @@
import { import {
useWebSocket useWebSocket
} from '@/stores/carts-websocket.js'; } from '@/stores/carts-websocket.js';
const cartStore = useCartsStore() const cartStore = useCartsStore()
const disablePayType = ref([])
//充值相关 //充值相关
const rechargeItem = ref({ const rechargeItem = ref({
id: '' id: ''
@@ -187,6 +217,15 @@
function updateChargeSel(e) { function updateChargeSel(e) {
rechargeItem.value = e rechargeItem.value = e
} }
watch(() => rechargeItem.value.id, (newval) => {
//充值并付款时只能微信支付
if (newval) {
disablePayType.value = ['余额支付']
paymentMethodref.value.groupChanges(2)
} else {
disablePayType.value = []
}
})
async function onMessage(Message) { async function onMessage(Message) {
cartStore.onMessage(Message, cartsSocket) cartStore.onMessage(Message, cartsSocket)
@@ -566,6 +605,31 @@
} }
} }
//取消订单
const cancelOrder = async () => {
uni.showModal({
title: '取消订单',
content: '是否取消订单?',
showCancel: true,
success: async (res) => {
if (res.confirm) {
await APIcancelOrder({
shopId: listinfo.shopId,
orderId: listinfo.id
})
uni.showToast({
title: '取消订单成功',
icon: 'none'
})
setTimeout(() => {
uni.pro.switchTab('order/index')
}, 1000)
}
}
})
}
// 删除订单 // 删除订单
const APIputuserorderclick = async () => { const APIputuserorderclick = async () => {
await APIputuserorder(listinfo.id) await APIputuserorder(listinfo.id)
@@ -581,6 +645,7 @@
} }
// 生成订单 // 生成订单
const createOrder = async () => { const createOrder = async () => {
cartStore.carts = [];
const res = await storeMemberpay.actionscreateOrder({ const res = await storeMemberpay.actionscreateOrder({
dineMode: is_type.value == 0 ? 'dine-in' : 'take-out', //堂食 dine-in 外带 take-out 外卖 take-away dineMode: is_type.value == 0 ? 'dine-in' : 'take-out', //堂食 dine-in 外带 take-out 外卖 take-away
seatNum: uni.cache.get('dinersNum') ? uni.cache.get('dinersNum') : '', //用餐人数 seatNum: uni.cache.get('dinersNum') ? uni.cache.get('dinersNum') : '', //用餐人数
@@ -591,12 +656,12 @@
placeNum: listinfo.id ? (listinfo.placeNum * 1 + 1) : 1, //当前订单下单次数 placeNum: listinfo.id ? (listinfo.placeNum * 1 + 1) : 1, //当前订单下单次数
waitCall: '', //是否等叫 0 否 1 等叫 waitCall: '', //是否等叫 0 否 1 等叫
orderId: listinfo.id || '', orderId: listinfo.id || '',
tableCode: options.tableCode,
userId: uni.cache.get('userInfo').id || '' // userId: uni.cache.get('userInfo').id || '' //
}) })
// 清空购物车 // 清空购物车
if (res) { if (res) {
Object.assign(listinfo, res) Object.assign(listinfo, res)
// cartStore.carts=[];
// cartStore.setOldOrder(res) // cartStore.setOldOrder(res)
getOrderInfoAfterCalcInit(res) getOrderInfoAfterCalcInit(res)
@@ -651,7 +716,8 @@
//先付 //先付
if (isPayBefor()) { if (isPayBefor()) {
console.log('isPayBefor'); console.log('isPayBefor');
console.log(cartStore.isEmpty); console.log('cartStore.isEmpty', cartStore.isEmpty);
console.log('cartStore.carts', cartStore.carts);
// 购物车有数据 // 购物车有数据
if (!cartStore.isEmpty) { if (!cartStore.isEmpty) {
const res = await createOrder() const res = await createOrder()
@@ -661,8 +727,9 @@
}) })
cartStore.setOldOrder(res1) cartStore.setOldOrder(res1)
} }
nextTick(goToPay)
goToPay() // goToPay()
} else { } else {
//后付 //后付
@@ -806,14 +873,18 @@
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减 newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore
.consumeDiscount.id : '', .consumeDiscount.id : '',
remark: '', //用户备注 remark: listinfo.remark, //用户备注
} }
console.log('topay checkOrderPay', checkOrderPay); console.log('topay checkOrderPay', checkOrderPay);
try { try {
if (rechargeItem.value.id && rechargeId.value) { if (rechargeItem.value.id && rechargeId.value) {
//充值支付 //充值支付
const payRes = await rechargePayOrder({ const payRes = await rechargePayOrder({
checkOrderPay, checkOrderPay: {
...checkOrderPay,
userId: uni.cache.get('shopUserInfo').userId || ''
},
payType: paymentmethod.payType, payType: paymentmethod.payType,
buyerRemark: '', buyerRemark: '',
returnUrl: '', returnUrl: '',
@@ -832,7 +903,6 @@
buyerRemark: '', buyerRemark: '',
returnUrl: '' returnUrl: ''
}) })
pay_unlock()
} }
} catch (error) { } catch (error) {
@@ -886,7 +956,7 @@
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减 newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore.consumeDiscount newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore.consumeDiscount
.id : '', .id : '',
remark: '', //用户备注 remark: listinfo.remark, //用户备注
} }
try { try {
await storeMemberpay.balancePayOrder({ await storeMemberpay.balancePayOrder({
@@ -989,6 +1059,7 @@
}) })
async function init(opt) { async function init(opt) {
cartStore.clearOrderConfig()
Object.assign(options, opt) Object.assign(options, opt)
listinfo.id = options.orderId; listinfo.id = options.orderId;
console.log('options', options); console.log('options', options);
@@ -997,6 +1068,19 @@
uni.cache.set('shopId', options.shopId, 30) uni.cache.set('shopId', options.shopId, 30)
uni.$on('returnData', handleReturnData); uni.$on('returnData', handleReturnData);
} }
//如果已经生成订单,根据历史订信息设置相关配置
if (options.orderId) {
let res = await APIgetOrderById({
orderId: listinfo.id
})
if (res) {
uni.cache.set('tableCode', res.tableCode)
uni.cache.set('tableCode', res.seatNum)
options.tableCode = res.tableCode
cartStore.setSeatFeeConfig('personCount', res.seatNum)
cartStore.setDinnerType(res.dineMode || 'dine-in')
}
}
//获取店铺信息 //获取店铺信息
const shopInfoRes = await APIusershopInfodetail({ const shopInfoRes = await APIusershopInfodetail({
shopId: options.shopId shopId: options.shopId
@@ -1492,4 +1576,25 @@
} }
} }
.orderInfo {
background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;
margin-top: 32rpx;
padding: 32rpx 34rpx;
.t {
font-weight: bold;
font-size: 28rpx;
color: #333333;
flex-shrink: 0;
}
.info {
font-weight: 400;
font-size: 28rpx;
color: #666666;
}
}
</style> </style>

View File

@@ -323,13 +323,12 @@
let noUseGoodsCoupon = [] let noUseGoodsCoupon = []
let noUseDiscountCoupon = [] let noUseDiscountCoupon = []
const user = uni.cache.get('shopUserInfo') const user = uni.cache.get('shopUserInfo')
let shopInfo = uni.cache.get('shopInfo')||{} let shopInfo = uni.cache.get('shopInfo') || {}
if(!shopInfo.isMemberPrice){ if (!shopInfo.isMemberPrice) {
shopInfo={} shopInfo = {}
} }
const goodsOrderPrice = uni.getStorageSync('goodsOrderPrice') || 0 const goodsOrderPrice = uni.getStorageSync('goodsOrderPrice') || 0
const goodsList = uni.getStorageSync('canDikouGoodsArr') || [] const dinnerType = cartStore.dinnerType
const dinnerType = uni.getStorageSync('dinnerType')
const canDikouGoodsArr = UTILS.returnCanDikouGoods(cartStore.allGoods, [], user); const canDikouGoodsArr = UTILS.returnCanDikouGoods(cartStore.allGoods, [], user);
const shopId = uni.cache.get('shopId') const shopId = uni.cache.get('shopId')
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
@@ -339,7 +338,7 @@
coupon, coupon,
goodsOrderPrice, goodsOrderPrice,
user, user,
selCoupon: [], selCoupon: quansSelArr.value,
shopInfo shopInfo
}) })
const { const {
@@ -347,7 +346,7 @@
reason reason
} = canuseResult } = canuseResult
if (coupon.type == 2) { if (coupon.type == 2) {
if (canUse) { if (canUse || goodsCouponSel.value.id == coupon.id) {
canUseGoodsCoupon.push(coupon) canUseGoodsCoupon.push(coupon)
} else { } else {
noUseGoodsCoupon.push({ noUseGoodsCoupon.push({
@@ -356,7 +355,7 @@
}) })
} }
} else { } else {
if (canUse) { if (canUse || couponSel.value.id == coupon.id) {
canUseDiscountCoupon.push(coupon) canUseDiscountCoupon.push(coupon)
} else { } else {
noUseDiscountCoupon.push({ noUseDiscountCoupon.push({
@@ -373,7 +372,7 @@
v, v,
user, user,
goodsOrderPrice, goodsOrderPrice,
[], quansSelArr.value,
shopInfo shopInfo
); );
return { return {
@@ -505,15 +504,64 @@
} }
onShow(() => { onShow(() => {
const couponArr = cartStore.backendCoupons.filter(v => v.type != 2)
const goodsCouponArr = cartStore.backendCoupons.filter(v => v.type == 2)
if (couponArr.length) {
couponSel.value = couponArr[0]
}
if (goodsCouponArr.length) {
goodsCouponSel.value = goodsCouponArr[0]
}
getCouponList(); getCouponList();
}); });
onLoad(() => { onLoad(() => {
getCouponShopsAjax(); getCouponShopsAjax();
}); });
watch(() => quansSelArr.value, (newval) => { watch(() => quansSelArr.value, (newval) => {
uni.$emit('selCoupon', newval) const user = uni.cache.get('shopUserInfo')
let shopInfo = uni.cache.get('shopInfo') || {}
if (!shopInfo.isMemberPrice) {
shopInfo = {}
}
const goodsOrderPrice = uni.getStorageSync('goodsOrderPrice') || 0
const dinnerType = cartStore.dinnerType
const canDikouGoodsArr = UTILS.returnCanDikouGoods(cartStore.allGoods, [], user);
const shopId = uni.cache.get('shopId')
let goodsCoupon = newval.filter(v => v.type == 2)
let otherCoupon = newval.filter(v => v.type != 2)
goodsCoupon = goodsCoupon.map(v => {
const discount = UTILS.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
goodsOrderPrice,
[],
shopInfo
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
}
})
otherCoupon = otherCoupon.map(v => {
const discount = UTILS.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
goodsOrderPrice,
goodsCoupon,
shopInfo
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
}
})
uni.$emit('selCoupon', [...goodsCoupon, ...otherCoupon])
}, { }, {
deep: true deep: true
}) })

View File

@@ -244,7 +244,7 @@
</view> </view>
<view class="flex-end" v-if="item1.type == 'sku' || (item1.type == 'package' && item1.groupType == '1')"> <view class="flex-end" v-if="item1.type == 'sku' || (item1.type == 'package' && item1.groupType == '1')">
<view class="sku-wrap flex-center" @click.stop="clickspecifications(item1, index, index1)"> <view class="sku-wrap flex-center" @click.stop="clickspecifications(item1, index, index1)">
<text class="t" v-if="item1.groupType == '1'">选择套餐</text> <text class="t no-wrap" v-if="item1.groupType == '1'">选择套餐</text>
<text class="t" v-else>选规格</text> <text class="t" v-else>选规格</text>
<text class="dot num" v-if="item1.cartNumber > 0">{{ ifcartNumber(item1) < 99 ? ifcartNumber(item1) : '99+' }}</text> <text class="dot num" v-if="item1.cartNumber > 0">{{ ifcartNumber(item1) < 99 ? ifcartNumber(item1) : '99+' }}</text>
</view> </view>
@@ -1914,7 +1914,7 @@ function toHistory() {
border-radius: 32rpx; border-radius: 32rpx;
position: relative; position: relative;
align-items: center; align-items: center;
white-space: nowrap;
.t { .t {
font-size: 28rpx; font-size: 28rpx;
color: #fff; color: #fff;

View File

@@ -21,7 +21,7 @@
</view> </view>
<view class="icon icon3" v-if="props.item.type == 3"> <view class="icon icon3" v-if="props.item.type == 3">
<view class="top"> <view class="top">
<text class="num">{{ props.item.discountRate }}</text> <text class="num">{{ props.item.discountRate/10 }}</text>
</view> </view>
<view class="intro"> <view class="intro">
<text class="t">{{ props.item.fullAmount }}可用</text> <text class="t">{{ props.item.fullAmount }}可用</text>

View File

@@ -28,7 +28,7 @@ import {
export const useCartsStore = defineStore('cart', export const useCartsStore = defineStore('cart',
() => { () => {
// 商品订单会员 // 店铺信息
const shopInfo = ref(uni.cache.get('shopInfo') || { const shopInfo = ref(uni.cache.get('shopInfo') || {
isMemberPrice: 0, isMemberPrice: 0,
isTableFee: 1 isTableFee: 1
@@ -97,10 +97,10 @@ export const useCartsStore = defineStore('cart',
} }
//餐位费配置 //餐位费配置
const dinersNum = uni.cache.set('dinersNum') || 1 const dinersNum = uni.cache.get('dinersNum') || 0
const seatFeeConfig = ref({ const seatFeeConfig = ref({
pricePerPerson: shopInfo.value.tableFee || 1, pricePerPerson: shopInfo.value.tableFee || 0,
personCount: dinersNum, personCount: dinersNum||0,
isEnabled: !shopInfo.value.isTableFee isEnabled: !shopInfo.value.isTableFee
}) })
watch(() => shopInfo.value.isTableFee, (newval) => { watch(() => shopInfo.value.isTableFee, (newval) => {
@@ -555,7 +555,14 @@ export const useCartsStore = defineStore('cart',
return result; return result;
}); });
function clearOrderConfig(){
backendCoupons.value=[];
seatFeeConfig.value.personCount=uni.cache.get('dinersNum') || 0;
dinnerType.value='dine-in';
userPoints.value=0
}
return { return {
getTotalPackFee, getTotalPackFee,
@@ -582,6 +589,8 @@ export const useCartsStore = defineStore('cart',
//优惠券列表 //优惠券列表
backendCoupons, backendCoupons,
allGoods, allGoods,
//就餐类型
dinnerType,
setDinnerType, setDinnerType,
setSeatFeeConfig, setSeatFeeConfig,
seatFeeConfig, seatFeeConfig,
@@ -591,6 +600,8 @@ export const useCartsStore = defineStore('cart',
//新客立减金额 //新客立减金额
newUserDiscount, newUserDiscount,
getAllGoodsList, getAllGoodsList,
//清空配置
clearOrderConfig
}; };
} }

View File

@@ -132,6 +132,10 @@ export const Memberpay = defineStore('memberpay', {
buyerRemark: data.buyerRemark, buyerRemark: data.buyerRemark,
userId: uni.cache.get('userInfo').id || '' userId: uni.cache.get('userInfo').id || ''
}) })
if(!res){
console.log('支付失败');
reject(false)
}
if (res) { if (res) {
uni.showLoading({ uni.showLoading({
title: '加载中...', title: '加载中...',
@@ -235,7 +239,7 @@ export const Memberpay = defineStore('memberpay', {
seatNum: data.seatNum, //用餐人数 seatNum: data.seatNum, //用餐人数
packFee: data.packFee, //打包费 packFee: data.packFee, //打包费
originAmount: data.originAmount, //订单原金额(包含打包费) 不含折扣价格 不含餐位费 originAmount: data.originAmount, //订单原金额(包含打包费) 不含折扣价格 不含餐位费
tableCode: uni.cache.get('tableCode'), //台桌编码 tableCode:data.tableCode|| uni.cache.get('tableCode'), //台桌编码
dineMode: 'dine-in', //堂食 dine-in 外带 take-out 外卖 take-away dineMode: 'dine-in', //堂食 dine-in 外带 take-out 外卖 take-away
remark: data.remark, //备注 remark: data.remark, //备注
placeNum: data.placeNum, //当前订单下单次数 placeNum: data.placeNum, //当前订单下单次数

View File

@@ -31,7 +31,7 @@
<text class="color-000 font-14 font-700">会员专属权益</text> <text class="color-000 font-14 font-700">会员专属权益</text>
<view class="u-flex"> <view class="u-flex">
<text class="color-666 u-m-r-4 font-12">会员说明</text> <text class="color-666 u-m-r-4 font-12">会员说明</text>
<up-icon name="question-circle" size="12" @click="modelShow"></up-icon> <up-icon name="question-circle" size="12" @click="modelShow('会员说明')"></up-icon>
</view> </view>
</view> </view>
<view class="u-m-t-32"> <view class="u-m-t-32">
@@ -190,15 +190,7 @@
} }
model.show = true; model.show = true;
} }
const modelContent = ref(` const modelContent = ref(``)
1、可适用门店全部门店<br>
2、可适用商品部分商品<br>
3、可使用类型堂食<br>
4、可用时间段全时段可用<br>
5、限量规则每人限领3张每日可最多使用3张<br>
6、同享规则与限时折扣同享、与会员价同享<br>
7、其它说明这里是后台配置内容
`)
const state = reactive({ const state = reactive({
openType: 'CONDITION' openType: 'CONDITION'
}) })

View File

@@ -12,7 +12,7 @@
<view class="lv">{{memberLevel?memberLevel.name:''}}</view> <view class="lv">{{memberLevel?memberLevel.name:''}}</view>
<view class="time"> <view class="time">
<text>{{memberLevel?memberLevel.endTime:''}}到期 </text> <text>{{memberLevel?memberLevel.endTime:''}}到期 </text>
<text>月度会员</text> <text>{{memberLevel?memberLevel.memberName:''}}</text>
</view> </view>
<view class="rule u-m-t-40 u-flex u-flex-between u-flex-y-center"> <view class="rule u-m-t-40 u-flex u-flex-between u-flex-y-center">
<text class="color-one "> <text class="color-one ">
@@ -249,7 +249,7 @@
} }
} }
if (v.name == '会员折扣') { if (v.name == '会员折扣') {
v.desc = '全店折扣'+res.memberLevel.discount+'折' v.desc = '全店折扣'+(res.memberLevel.discount/10)+'折'
} }
return v return v
}) })
@@ -262,7 +262,7 @@
} }
} }
if (v.name == '会员折扣') { if (v.name == '会员折扣') {
v.desc = '全店折扣'+res.memberLevel.discount+'折' v.desc = '全店折扣'+(res.memberLevel.discount/10)+'折'
} }
return v return v
}) })
@@ -279,6 +279,7 @@
memberLevel.value = { memberLevel.value = {
...res1.memberLevel, ...res1.memberLevel,
endTime: res1.endTime, endTime: res1.endTime,
memberName:res1.memberName,
experience: res1.experience, experience: res1.experience,
nextExperienceValue: res1.nextExperienceValue nextExperienceValue: res1.nextExperienceValue
} }
@@ -298,8 +299,7 @@
} }
const index=memberLevelList.value.findIndex(v=>v.id==memberLevel.value.id) const index=memberLevelList.value.findIndex(v=>v.id==memberLevel.value.id)
console.log(index); if(index==-1||index>=memberLevelList.value.length-1){
if(index!=-1||index>=memberLevelList.value.length-1){
return null return null
} }
const next=memberLevelList.value[index+1] const next=memberLevelList.value[index+1]

45
utils/coupon.js Normal file
View File

@@ -0,0 +1,45 @@
import {
findCoupon
} from '@/common/api/market/coupon.js';
import * as UTILS from '@/utils/goods-utils.js'
export async function returnHasCouponCanUse(args) {
const {
goodsOrderPrice,
dinnerType,
shopId,
shopInfo,
shopUserId,
allGoods,
user
} = args
const res = await findCoupon({
shopUserId,
});
if(!res||res.length<=0){
return false
}
const canDikouGoodsArr = UTILS.returnCanDikouGoods(allGoods, [], user);
for (let i = 0; i < res.length; i++) {
const coupon = res[i]
const canuseResult = UTILS.returnCouponCanUse({
canDikouGoodsArr,
coupon,
goodsOrderPrice,
user,
selCoupon: [],
shopInfo
})
const {
canUse,
reason
} = canuseResult
if (canUse) {
return true
}
}
return false
}

View File

@@ -12,6 +12,9 @@ import _ from "lodash";
* @param {Object} shopInfo * @param {Object} shopInfo
*/ */
export function returnGoodsPrice(goods, user, shopInfo) { export function returnGoodsPrice(goods, user, shopInfo) {
if(!goods){
return 0
}
if (goods.discount_sale_amount * 1 > 0) { if (goods.discount_sale_amount * 1 > 0) {
return goods.discount_sale_amount; return goods.discount_sale_amount;
} }
@@ -65,22 +68,38 @@ export function returnCoupType(coupon) {
* @param user 用户信息 * @param user 用户信息
*/ */
export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) { export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
const goodsCouponGoods = selCoupon const types = [2, 4, 6];
.filter((v) => v.type == 2) // 收集已抵扣商品并关联对应的优惠券类型
.reduce((prve, cur) => { const goodsCouponGoods = selCoupon
prve.push(...cur.discount.hasDiscountGoodsArr); .filter((v) => types.includes(v.type))
return prve; .reduce((prev, cur) => {
}, []); // 给每个抵扣商品添加所属优惠券类型
const arr = _.cloneDeep(canDikouGoodsArr) const goodsWithType = cur.discount.hasDiscountGoodsArr.map(goods => ({
.map((v) => { ...goods,
const findCart = goodsCouponGoods.find((carts) => carts.id == v.id); couponType: cur.type // 记录该商品是被哪种类型的优惠券抵扣的
if (findCart) { }));
v.num -= findCart.num; prev.push(...goodsWithType);
} return prev;
return v; }, []);
})
.filter((v) => v.num > 0); const arr = _.cloneDeep(canDikouGoodsArr)
return arr; .map((v) => {
const findCart = goodsCouponGoods.find((carts) => carts.id == v.id);
if (findCart) {
// 根据优惠券类型判断扣减数量
if ([4, 6].includes(findCart.couponType)) {
// 类型4第二件半价或6买一送一数量减2
v.num -= 2;
} else {
// 其他类型如类型2商品券按原逻辑扣减对应数量
v.num -= findCart.num;
}
}
return v;
})
.filter((v) => v.num > 0); // 过滤掉数量<=0的商品
return arr;
} }
/** /**
@@ -151,12 +170,18 @@ export function returnCouponCanUse(args) {
// 商品券特殊验证 // 商品券特殊验证
if (coupon.type === 2) { if (coupon.type === 2) {
if (!(isDikouAll || canCalcGoodsArr.length > 0)) { if (!(isDikouAll || canCalcGoodsArr.length === 0)) {
return { return {
canUse: false, canUse: false,
reason: "没有符合条件的商品可抵扣" reason: "没有符合条件的商品可抵扣"
}; };
} }
if(canDikouGoodsArr.length<=0){
return {
canUse: false,
reason: "没有符合条件的商品可抵扣"
};
}
} }
// 买一送一券特殊验证 // 买一送一券特殊验证
@@ -241,7 +266,6 @@ export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user,sh
* @param selCoupon 已选择的优惠券列表 * @param selCoupon 已选择的优惠券列表
*/ */
export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon) { export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon) {
console.log('arr', arr);
const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user); const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user);
console.log('canDikouGoodsArr', canDikouGoodsArr); console.log('canDikouGoodsArr', canDikouGoodsArr);
if (coupon.type == 2) { if (coupon.type == 2) {
@@ -291,7 +315,7 @@ export function returnCouponZhekouDiscount(
// 2. 计算优惠比例1 - 折扣率例如8折的优惠比例是 1 - 0.8 = 0.2 // 2. 计算优惠比例1 - 折扣率例如8折的优惠比例是 1 - 0.8 = 0.2
const discountAmountRatio = new BigNumber(1).minus(discountRatio); const discountAmountRatio = new BigNumber(1).minus(discountRatio);
// 3. 计算折扣金额:商品订单金额 × 优惠比例 // 3. 计算折扣金额:商品订单金额 × 优惠比例
let discountPrice = new BigNumber(goodsOrderPrice).times(discountAmountRatio).toNumber(); let discountPrice = new BigNumber(goodsOrderPrice).times(discountAmountRatio).decimalPlaces(2, BigNumber.ROUND_FLOOR).toNumber();
if (maxDiscountAmount != 0) { if (maxDiscountAmount != 0) {
discountPrice = discountPrice >= maxDiscountAmount ? maxDiscountAmount : discountPrice; discountPrice = discountPrice >= maxDiscountAmount ? maxDiscountAmount : discountPrice;
} }