修改确认订单逻辑
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
</view>
|
||||
|
||||
|
||||
{{cartStore.orderCostSummary}}
|
||||
|
||||
<!-- 详情 -->
|
||||
<orderInfo :useVipPrice="cartStore.useVipPrice" :packfee="packfee" :shifu="shifu" :nowCarts="cartStore.carts"
|
||||
ref="orderInfoAfterRef" :freeCheck="freeCheck" :listinfo="listinfo" :orderVIP="orderVIP"
|
||||
@@ -47,6 +49,8 @@
|
||||
v-if="(listinfo.status == 'unpaid'||!listinfo.id) && orderVIP.freeDineConfig.enable"
|
||||
@changeFree="changeFree">
|
||||
</rechargeFree>
|
||||
<!-- 充值享优惠 -->
|
||||
<ChargeVue @updateChargeSel="updateChargeSel" @updateRechargeId="updateRechargeId" v-else></ChargeVue>
|
||||
<!-- 支付方式 -->
|
||||
<paymentMethodes ref="paymentMethodref" :orderVIP="orderVIP" @groupChange="groupChange"
|
||||
:changeFreeenable="isBwc" v-if="listinfo.status == 'unpaid'||!listinfo.id">
|
||||
@@ -56,7 +60,7 @@
|
||||
<view class="fixedview_one flex-start">
|
||||
<view class="fixedview_oneone"> 实付金额: </view>
|
||||
<view class="fixedview_onetow">
|
||||
<text>¥</text>{{listinfo.totalCost}}
|
||||
<text>¥</text>{{cartStore.orderCostSummary.finalPayAmount}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-colum-end u-flex u-flex-y-center">
|
||||
@@ -110,7 +114,11 @@
|
||||
import {
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
|
||||
import {
|
||||
BigNumber
|
||||
} from 'bignumber.js';
|
||||
import ChargeVue from './components/charge.vue';
|
||||
import {pay} from '@/utils/pay.js'
|
||||
function onback() {
|
||||
closeSocket()
|
||||
back()
|
||||
@@ -122,6 +130,7 @@
|
||||
'border-radius': '106rpx',
|
||||
'border': '2rpx solid #E8AD7B'
|
||||
}
|
||||
import _ from "lodash";
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
@@ -140,9 +149,10 @@
|
||||
import {
|
||||
APIgetOrderById,
|
||||
APIputuserorder,
|
||||
APIhistoryOrder
|
||||
APIhistoryOrder,rechargePayOrder
|
||||
} from '@/common/api/order/index.js'
|
||||
import {
|
||||
APIusershopInfodetail,
|
||||
APIshopUserInfo
|
||||
} from '@/common/api/member.js'
|
||||
import {
|
||||
@@ -156,6 +166,19 @@
|
||||
useWebSocket
|
||||
} from '@/stores/carts-websocket.js';
|
||||
const cartStore = useCartsStore()
|
||||
|
||||
|
||||
//充值相关
|
||||
const rechargeItem=ref(null)
|
||||
const rechargeId=ref(null)
|
||||
|
||||
function updateRechargeId(e){
|
||||
rechargeId.value=e
|
||||
}
|
||||
function updateChargeSel(e){
|
||||
rechargeItem.value=e
|
||||
}
|
||||
|
||||
async function onMessage(Message) {
|
||||
cartStore.onMessage(Message, cartsSocket)
|
||||
listinfo.totalPrices = historyTotalPrices * 1 + cartStore.totalPrice * 1
|
||||
@@ -324,8 +347,10 @@
|
||||
listinfo.tableName = tableRes.name;
|
||||
}
|
||||
}
|
||||
cartStore.setOldOrder(res);
|
||||
socketInit()
|
||||
console.log(res);
|
||||
|
||||
getOrderInfoAfterCalcInit(res)
|
||||
}
|
||||
|
||||
@@ -609,12 +634,12 @@
|
||||
//先付
|
||||
if (isPayBefor()) {
|
||||
console.log('isPayBefor');
|
||||
console.log(cartStore.isEmpty);
|
||||
// 购物车有数据
|
||||
if (!cartStore.isEmpty) {
|
||||
const res = await createOrder()
|
||||
goToPay()
|
||||
}
|
||||
|
||||
goToPay()
|
||||
|
||||
} else {
|
||||
//后付
|
||||
@@ -725,7 +750,7 @@
|
||||
shopUserId: orderVIP.value.id,
|
||||
orderId: listinfo.id,
|
||||
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
|
||||
amount: listinfo.totalCost, // 最终订单金额
|
||||
amount: cartStore.orderCostSummary.finalPayAmount, // 最终订单金额
|
||||
returnUrl: '', //跳转地址
|
||||
buyerRemark: '',
|
||||
seatNum: is_type.value == 0 ? listinfo.seatNum : 0, //用餐人数
|
||||
@@ -739,27 +764,44 @@
|
||||
orderId: listinfo.id,
|
||||
vipPrice: cartStore.useVipPrice ? 1 : 0, //是否使用会员价0否1是
|
||||
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
|
||||
seatNum: is_type.value == 0 ? listinfo.seatNum : 0, //用餐人数
|
||||
originAmount: listinfo.originAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
seatNum: is_type.value == 0 ? cartStore.seatFeeConfig.personCount : 0, //用餐人数
|
||||
originAmount: cartStore.orderCostSummary.goodsRealAmount , //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
|
||||
discountAmount: 0, //手动优惠金额 写死0
|
||||
productCouponDiscountAmount: listinfo.Productroll, //商品优惠券抵扣金额
|
||||
fullCouponDiscountAmount: listinfo.coupondiscountAmount, //满减优惠券抵扣金额
|
||||
couponList: uniqueIds.value, //用户使用的卡券
|
||||
orderAmount: listinfo.totalCost, // 最终订单金额
|
||||
productCouponDiscountAmount: cartStore.orderCostSummary.productCouponDeduction, //商品优惠券抵扣金额
|
||||
otherCouponDiscountAmount: cartStore.orderCostSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
||||
couponList: cartStore.backendCoupons.map(v => v.id), //用户使用的卡券
|
||||
orderAmount: cartStore.orderCostSummary.finalPayAmount, // 最终订单金额
|
||||
roundAmount: 0, //抹零金额 减免多少钱
|
||||
pointsDiscountAmount: listinfo.pointsDiscountAmount, //积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsDiscountAmount: cartStore.orderCostSummary
|
||||
.pointDeductionAmount, //积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsNum: listinfo.pointsNum, //(扣除各类折扣 enable_deduction后使用)
|
||||
remark: '', //用户备注
|
||||
}
|
||||
console.log('topay checkOrderPay', checkOrderPay);
|
||||
try {
|
||||
await storeMemberpay.actionsltPayOrder({
|
||||
checkOrderPay,
|
||||
payType: paymentmethod.payType,
|
||||
buyerRemark: '',
|
||||
returnUrl: ''
|
||||
})
|
||||
if(rechargeItem.value.id&&rechargeId.value){
|
||||
//充值支付
|
||||
const payRes= await rechargePayOrder({
|
||||
checkOrderPay,
|
||||
payType: paymentmethod.payType,
|
||||
buyerRemark: '',
|
||||
returnUrl: '',
|
||||
rechargeId:rechargeId.value,
|
||||
rechargeDetailId:rechargeItem.value.id,
|
||||
shopUserId:orderVIP.value.id,
|
||||
shopId: orderVIP.value.shopId,
|
||||
})
|
||||
pay(payRes)
|
||||
}else{
|
||||
await storeMemberpay.actionsltPayOrder({
|
||||
checkOrderPay,
|
||||
payType: paymentmethod.payType,
|
||||
buyerRemark: '',
|
||||
returnUrl: ''
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
pay_unlock()
|
||||
//TODO handle the exception
|
||||
@@ -787,21 +829,24 @@
|
||||
// 余额支付
|
||||
const accountPayevent = async (pwd) => {
|
||||
ispws.value = false;
|
||||
|
||||
|
||||
let checkOrderPay = {
|
||||
userId: uni.cache.get('userInfo').id,
|
||||
orderId: listinfo.id,
|
||||
vipPrice: cartStore.useVipPrice ? 1 : 0, //是否使用会员价0否1是
|
||||
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
|
||||
seatNum: is_type.value == 0 ? listinfo.seatNum : 0, //用餐人数
|
||||
originAmount: listinfo.originAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
seatNum: is_type.value == 0 ? cartStore.seatFeeConfig.personCount : 0, //用餐人数
|
||||
originAmount: cartStore.orderCostSummary.goodsRealAmount , //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
|
||||
discountAmount: 0, //手动优惠金额 写死0
|
||||
productCouponDiscountAmount: listinfo.Productroll, //商品优惠券抵扣金额
|
||||
fullCouponDiscountAmount: listinfo.coupondiscountAmount, //满减优惠券抵扣金额
|
||||
couponList: uniqueIds.value, //用户使用的卡券
|
||||
orderAmount: listinfo.totalCost, // 最中订单金额
|
||||
productCouponDiscountAmount: cartStore.orderCostSummary.productCouponDeduction, //商品优惠券抵扣金额
|
||||
otherCouponDiscountAmount: cartStore.orderCostSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
||||
couponList: cartStore.backendCoupons.map(v => v.id), //用户使用的卡券
|
||||
orderAmount: cartStore.orderCostSummary.finalPayAmount, // 最终订单金额
|
||||
roundAmount: 0, //抹零金额 减免多少钱
|
||||
pointsDiscountAmount: listinfo.pointsDiscountAmount, //积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsDiscountAmount: cartStore.orderCostSummary
|
||||
.pointDeductionAmount, //积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsNum: listinfo.pointsNum, //(扣除各类折扣 enable_deduction后使用)
|
||||
remark: '', //用户备注
|
||||
}
|
||||
@@ -852,8 +897,16 @@
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
|
||||
orderorderInfo()
|
||||
|
||||
|
||||
orderorderInfo()
|
||||
uni.$off('selCoupon')
|
||||
uni.$on('selCoupon', function(data) {
|
||||
console.log('selCoupon', data)
|
||||
orderInfoAfterRef.value.dataprocessing(_.cloneDeep(data))
|
||||
cartStore.setCoupons(_.cloneDeep(data))
|
||||
})
|
||||
|
||||
});
|
||||
let options = {}
|
||||
|
||||
@@ -904,12 +957,19 @@
|
||||
async function init(opt) {
|
||||
Object.assign(options, opt)
|
||||
listinfo.id = options.orderId;
|
||||
console.log('init', listinfo);
|
||||
console.log('options', options);
|
||||
if (options.shopId) {
|
||||
// 每次进来全局更新shopId
|
||||
uni.cache.set('shopId', options.shopId, 30)
|
||||
uni.$on('returnData', handleReturnData);
|
||||
}
|
||||
//获取店铺信息
|
||||
const shopInfoRes = await APIusershopInfodetail({
|
||||
shopId: options.shopId
|
||||
})
|
||||
if (shopInfoRes) {
|
||||
cartStore.shopInfo = shopInfoRes.shopInfo;
|
||||
}
|
||||
// * 获取会员信息
|
||||
await storeuser.actionsproductqueryProduct()
|
||||
await nextTick()
|
||||
|
||||
Reference in New Issue
Block a user