采用最新结算函数优化代客下单

This commit is contained in:
gyq
2025-11-14 18:14:27 +08:00
parent bec6bd6668
commit 7c7fc3ef0f
13 changed files with 369 additions and 17189 deletions

View File

@@ -93,8 +93,8 @@ import { ref, reactive, computed } from 'vue'
import { useGoods } from '@/store/goods.js'
import { findCoupon } from '@/api/account.js'
import { ElMessage, ElMessageBox } from 'element-plus'
import * as UTILS from '@/utils/coupon-utils.js';
import { useUser } from "@/store/user.js";
import { couponUtils } from "ysk-utils";
const props = defineProps({
orderList: {
@@ -255,13 +255,13 @@ function updateSelCoupon() {
if (!shopInfo.isMemberPrice) {
shopInfo = {};
}
const canDikouGoodsArr = UTILS.returnCanDikouGoods(goodsStore.cartInfo.allGoods, [], user);
const canDikouGoodsArr = couponUtils.returnCanDikouGoods(goodsStore.cartInfo.allGoods, [], user);
if (newval.length >= 2) {
let goodsCoupon = newval.filter((v) => v.type == 2);
let otherCoupon = newval.filter((v) => v.type != 2);
goodsCoupon = goodsCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(
const discount = couponUtils.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
@@ -276,7 +276,7 @@ function updateSelCoupon() {
};
});
otherCoupon = otherCoupon.map((v) => {
const canuseResult = UTILS.returnCouponCanUse({
const canuseResult = couponUtils.returnCouponCanUse({
canDikouGoodsArr,
coupon: v,
orderPrice: orderPrice.value,
@@ -285,7 +285,7 @@ function updateSelCoupon() {
shopInfo: shopInfo,
});
const discount = UTILS.returnCouponDiscount(
const discount = couponUtils.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
@@ -382,10 +382,10 @@ function formatCoupon() {
console.log('goodsOrderPrice==========', goodsOrderPrice);
const canDikouGoodsArr = UTILS.returnCanDikouGoods(goodsStore.cartInfo.allGoods, [], user);
const canDikouGoodsArr = couponUtils.returnCanDikouGoods(goodsStore.cartInfo.allGoods, [], user);
for (let i = 0; i < couponList.value.length; i++) {
const coupon = couponList.value[i];
const canuseResult = UTILS.returnCouponCanUse({
const canuseResult = couponUtils.returnCouponCanUse({
canDikouGoodsArr,
coupon,
goodsOrderPrice,
@@ -416,7 +416,7 @@ function formatCoupon() {
}
//商品券
canUseGoodsCoupon = canUseGoodsCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
return {
...v,
discount,
@@ -425,7 +425,7 @@ function formatCoupon() {
});
//非商品券
canUseDiscountCoupon = canUseDiscountCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
return {
...v,
discount,

View File

@@ -438,23 +438,30 @@ async function payTypeChange(index, item) {
// 更新支付参数
function upadatePayData() {
// console.log(goodsStore.cartInfo);
payData.value.checkOrderPay = {
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0,
orderId: goodsStore.orderListInfo.id,
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价
allPack: goodsStore.allSelected, // 是否整单打包
// discountRatio: (checkOrderPay.discount / 100).toFixed(2),
discountRatio: 0,
seatNum: goodsStore.allSelected ? 0 : goodsStore.tableInfo.num,
originAmount: goodsStore.cartInfo.costSummary.goodsRealAmount,
discountAmount: discountRateNumber.value,
productCouponDiscountAmount: goodsStore.cartInfo.costSummary.productCouponDeduction,
otherCouponDiscountAmount: goodsStore.cartInfo.costSummary.fullCouponDeduction,
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount, // 最终订单金额
roundAmount: 0,
pointsDiscountAmount: goodsStore.cartInfo.costSummary.pointDeductionAmount, //积分抵扣金额
pointsNum: goodsStore.cartInfo.costSummary.pointUsed,
discountActAmount: goodsStore.cartInfo.costSummary.fullReduction.actualAmount, // 满减活动金额
discountActId: goodsStore.cartInfo.costSummary.fullReduction.usedThreshold !== undefined ? goodsStore.cartInfo.costSummary.fullReduction.usedThreshold.activityId : '', // 满减活动id
couponList: couponResList1.value.map(item => item.id),
userId: goodsStore.vipUserInfo.userId || '',
seatNum: goodsStore.allSelected ? 0 : goodsStore.tableInfo.num, // 用餐人数
originAmount: formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
discountAmount: discountRateNumber.value, // 手动优惠金额
productCouponDiscountAmount: goodsStore.cartInfo.costSummary.productCouponDeduction, //商品优惠券抵扣金额
otherCouponDiscountAmount: goodsStore.cartInfo.costSummary.fullCouponDeduction, //其他优惠券抵扣金额
couponList: couponResList1.value.map(item => item.id), // 用户使用的卡券
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount, // 订单金额
roundAmount: 0, // 抹零金额 减免多少钱
pointsDiscountAmount: goodsStore.cartInfo.costSummary.pointDeductionAmount, // 积分抵扣金额(tb_points_basic_setting表)
pointsNum: goodsStore.cartInfo.costSummary.pointUsed, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
isPrint: 1
allPack: goodsStore.allSelected,
limitRate: goodsStore.limitDiscountRes,
newCustomerDiscountId: goodsStore.newCustomerDiscount !== null ? goodsStore.newCustomerDiscount.id : '', // 新客立减Id
newCustomerDiscountAmount: goodsStore.newCustomerDiscount !== null ? goodsStore.newCustomerDiscount.amount : 0, // 新客立减金额
vipDiscountAmount: goodsStore.cartInfo.costSummary.vipDiscountAmount, // 超级会员折扣
}
}

View File

@@ -17,10 +17,28 @@
</el-form-item>
</el-form>
<el-table :data="tableData.list" height="400px" border stripe v-loading="tableData.loading">
<el-table-column prop="nickName" label="昵称" width="150px" />
<el-table-column prop="nickName" label="昵称" width="200px">
<template #default="scope">
<div class="center">
<el-avatar :src="scope.row.headImg" :size="20"></el-avatar>
<span>{{ scope.row.nickName }}</span>
<el-tag type="success" size="small" disable-transitions v-if="scope.row.new"></el-tag>
</div>
</template>
</el-table-column>
<el-table-column prop="phone" label="手机" width="150px" />
<el-table-column prop="code" label="编号" width="150px" />
<el-table-column prop="level" label="等级" />
<!-- <el-table-column prop="code" label="编号" width="150px" /> -->
<el-table-column prop="level" label="等级">
<template #default="scope">
<span v-if="scope.row.isVip">
<span v-if="scope.row.memberLevelName">
{{ scope.row.memberLevelName }}
</span>
<span v-else></span>
</span>
<span v-else></span>
</template>
</el-table-column>
<el-table-column prop="accountPoints" label="积分" />
<el-table-column prop="amount" label="余额" width="120px">
<template v-slot="scope">
@@ -115,4 +133,12 @@ function show() {
defineExpose({
show
})
</script>
</script>
<style scoped lang="scss">
.center {
display: flex;
align-items: center;
gap: 10px;
}
</style>