fix: 代客下单修改

This commit is contained in:
2025-10-09 16:48:13 +08:00
parent 5cd5265ffb
commit 4b9fc0ad3f
11 changed files with 436 additions and 246 deletions

View File

@@ -358,7 +358,7 @@ function handleSubmit() {
} else {
delete formData.id;
RoleApi.add({ ...formData, menuIdList: checkedMenuIds })
RoleApi.add({ ...formData, menuIdList: [] })
.then(() => {
ElMessage.success("新增成功");
handleCloseDialog();

View File

@@ -125,7 +125,9 @@
<el-button
type="primary"
size="large"
:disabled="!carts.isLinkFinshed || showOrder"
:disabled="
!carts.isLinkFinshed || showOrder || (carts.oldOrder.detailMap.length && !showOrder)
"
@click="createOrder('more-pay')"
>
更多支付

View File

@@ -0,0 +1,84 @@
<template>
<div>
<el-table ref="refTable" empty-text="无可用优惠券" :data="data" max-height="40vh">
<el-table-column type="index" label="">
<template v-slot="scope">
<el-checkbox
@change="couponClick($event, scope.row)"
:model-value="scope.row.id == couponSel.id"
></el-checkbox>
</template>
</el-table-column>
<el-table-column type="index" label="#"></el-table-column>
<el-table-column prop="name" label="券名称"></el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope">
{{ UTILS.returnCoupType(scope.row) }}
</template>
</el-table-column>
<el-table-column prop="discountAmount" label="抵扣" align="center">
<template v-slot="scope">
<span class="color-red">{{ scope.row.discountAmount }}</span>
</template>
</el-table-column>
<el-table-column label="商品信息" width="120">
<template v-slot="scope">
<div class="u-flex" v-if="scope.row.type == 2">
<div v-if="scope.row.useFoods.length">
<div class="u-flex">
<el-image
:src="scope.row.productImg"
fit="cover"
style="width: 40px; height: 40px"
></el-image>
</div>
<div class="u-p-l-10">
<div class="">{{ scope.row.productName }}</div>
<div class="">x{{ scope.row.discountNum || 1 }}</div>
</div>
</div>
<div v-else>任意商品 x{{ scope.row.discountNum || 1 }}</div>
</div>
</template>
</el-table-column>
<el-table-column prop="discountAmount" label="最大抵扣金额" align="center">
<template v-slot="scope">
<span class="color-red">{{ scope.row.maxDiscountAmount }}</span>
</template>
</el-table-column>
<el-table-column prop="discountAmount" label="限制" width="180">
<template v-slot="scope">
<div class="u-flex">
<span>支付满</span>
<span class="color-red no-wrap">
{{ scope.row.fullAmount }}
</span>
<span>元可用</span>
</div>
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述"></el-table-column>
</el-table>
</div>
</template>
<script setup>
import * as UTILS from "@/utils/coupon-utils.js";
defineProps({
data: {
type: Array,
default: () => [],
},
couponSel: {
type: Object,
default: () => {},
},
});
const emits = defineEmits(["couponClick"]);
function couponClick(checked, row) {
emit("couponClick", checked, row);
}
</script>

View File

@@ -148,11 +148,12 @@ function init(key) {
const emits = defineEmits(["confirm"]);
function confirm() {
console.log(form.value);
if (discountType.value == 1) {
emits("confirm", { discount: form.value.discount });
} else {
emits("confirm", { discountAmount: form.value.reduceMoney });
}
// if (discountType.value == 1) {
// emits("confirm", { discount: form.value.discount });
// } else {
// }
emits("confirm", { discountAmount: form.value.reduceMoney });
close();
}
function open(data) {

View File

@@ -47,6 +47,7 @@
v-if="score.sel == 1"
v-model="usePointsNumber"
step-strictly
:step="pointsRes.equivalentPoints"
placeholder="请输入积分抵扣数量"
:min="pointsRes.minDeductionPoints"
:max="pointsRes.maxUsablePoints"
@@ -80,9 +81,10 @@
<el-icon><ArrowDown /></el-icon>
</div>
</div>
<div class="u-m-t-20" v-if="quansSelArr.length > 0">
{{ carts.orderCostSummary }}
<div class="u-m-t-20" v-if="carts.coupons.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div>
<el-table empty-text="未选择优惠券" :data="quansSelArr">
<el-table empty-text="未选择优惠券" :data="carts.coupons">
<el-table-column type="index" width="50" label="#"></el-table-column>
<el-table-column prop="name" label="券名称"></el-table-column>
<el-table-column label="券类型" width="80">
@@ -294,8 +296,6 @@ function refCouponConfirm(e, goodsList) {
quansSelArr.value = e;
checkOrderPay.discountAmount = 0;
checkOrderPay.discount = 0;
score.sel = -1;
usePointsNumber.value = 0;
}
function delQuan(row) {
const index = quansSelArr.value.findIndex((v) => v.id == row.id);
@@ -340,8 +340,7 @@ function returnMerchantReductionDiscount() {
const total =
goodsOriginalAmount - // 商品原价总和
goodsDiscountAmount - // 减去商品折扣
couponDeductionAmount - // 减去优惠券抵扣
pointDeductionAmount; // 减去积分抵扣
couponDeductionAmount; // 减去优惠券抵扣
return total <= 0 ? 0 : total;
}
@@ -436,7 +435,6 @@ async function pointsInit() {
carts.pointDeductionRule.pointsPerYuan = res.equivalentPoints;
usePointsNumber.value = res.usable ? res.maxUsablePoints : 0;
carts.userPoints = usePointsNumber.value;
if (res.usable) {
pointsToMoney();
} else {
@@ -491,6 +489,12 @@ watch(
pointsInit();
}
);
watch(
() => usePointsNumber.value,
(newval) => {
carts.userPoints = newval;
}
);
function canUsePayType(item) {
if (currentpayMoney.value * 1 == 0) {
return item.payType == "cash" ? false : true;
@@ -512,6 +516,7 @@ function changePayType(i) {
}
function returnPayParams() {
console.log("carts.orderCostSummary", carts.orderCostSummary);
return {
money: currentpayMoney.value * 1,
shopId: localStorage.getItem("shopId"),
@@ -522,17 +527,15 @@ function returnPayParams() {
// discountRatio: (checkOrderPay.discount / 100).toFixed(2),
discountRatio: 0,
seatNum: props.perpole * 1,
originAmount: carts.payMoney * 1 + seatAmount.value * 1,
originAmount: carts.orderCostSummary.goodsRealAmount,
discountAmount: discountAmount.value,
productCouponDiscountAmount: productCouponDiscountAmount.value * 1,
otherCouponDiscountAmount:
carts.orderCostSummary.couponDeductionAmount - productCouponDiscountAmount.value * 1,
orderAmount: currentpayMoney.value * 1,
productCouponDiscountAmount: carts.orderCostSummary.productCouponDeduction,
otherCouponDiscountAmount: carts.orderCostSummary.fullCouponDeduction,
orderAmount: carts.orderCostSummary.finalPayAmount, // 最终订单金额
roundAmount: props.orderInfo.roundAmount,
pointsDiscountAmount: pointsDiscountAmount.value * 1,
pointsNum: usePointsNumber.value * 1,
fullCouponDiscountAmount: fullCouponDiscountAmount.value * 1,
couponList: quansSelArr.value.map((v) => v.id),
pointsDiscountAmount: carts.orderCostSummary.pointDeductionAmount, //积分抵扣金额
pointsNum: carts.orderCostSummary.pointUsed,
couponList: carts.coupons.map((v) => v.id),
userId: props.user.userId || "",
allPack: carts.dinnerType == "take-out" ? 1 : 0,
},
@@ -667,11 +670,7 @@ const fullCouponDiscountAmount = computed(() => {
//商品券抵扣金额
const productCouponDiscountAmount = computed(() => {
// 优先从 Store 扩展字段取,若无则用 props 数据(过渡方案)
return (
carts.orderCostSummary.productCouponDeduction ||
props.orderInfo.productCouponDiscountAmount ||
0
);
return carts.orderCostSummary.productCouponDeduction;
});
//除开客座费,打包费总金额
const totalMoney = computed(() => {
@@ -717,6 +716,7 @@ watch(
}
);
onMounted(() => {
carts.payParamsInit();
getPaytype();
});
defineExpose({

View File

@@ -4,7 +4,12 @@
<div class="">
<el-tabs v-model="activeName" @tab-click="tabClick">
<el-tab-pane label="优惠券(单选)" name="youhui">
<el-table ref="refTable" empty-text="无可用优惠券" :data="quans.coupon">
<el-table
ref="refTable"
empty-text="无可用优惠券"
:data="quans.coupon"
max-height="40vh"
>
<el-table-column type="index" label="">
<template v-slot="scope">
<el-checkbox
@@ -50,6 +55,7 @@
empty-text="无可用商品券"
:data="quans.productCoupon"
style="width: 100%"
max-height="40vh"
>
<el-table-column width="80">
<template v-slot="scope">
@@ -103,7 +109,7 @@
</el-tabs>
<div v-if="quansSelArr.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div>
<el-table empty-text="未选择优惠券" :data="quansSelArr">
<el-table empty-text="未选择优惠券" :data="quansSelArr" max-height="20vh">
<el-table-column type="index" width="50" label="#"></el-table-column>
<el-table-column prop="name" label="券名称"></el-table-column>
<el-table-column label="券类型" width="80">
@@ -171,11 +177,12 @@
</template>
<script setup>
import couponApi from "@/api/account/coupon";
import { OrderPriceCalculator } from "@/utils/goods";
import { BigNumber } from "bignumber.js";
import * as UTILS from "@/utils/goods-utils.js";
import * as UTILS from "@/utils/coupon-utils.js";
import { ElMessageBox } from "element-plus";
import * as quanUtil from "../quan_util.js";
import { useUserStoreHook } from "@/store/modules/user";
const shopUser = useUserStoreHook();
const props = defineProps({
title: {
type: String,
@@ -260,13 +267,15 @@ async function getcoup() {
quans.value.coupon = res
.filter((v) => v.type != 2)
.filter((coupon) => {
return UTILS.returnCouponCanUse({
const { canUse, msg } = UTILS.returnCouponCanUse({
canDikouGoodsArr,
coupon,
orderPrice: orderPrice.value,
user: props.user,
selCoupon: quansSelArr.value,
shopInfo: shopUser.userInfo,
});
return canUse;
})
.map((v) => {
const discount = UTILS.returnCouponDiscount(
@@ -274,7 +283,8 @@ async function getcoup() {
v,
props.user,
orderPrice.value,
quansSelArr.value
quansSelArr.value,
shopUser.userInfo
);
return {
...v,
@@ -285,13 +295,15 @@ async function getcoup() {
quans.value.productCoupon = res
.filter((v) => v.type == 2)
.filter((coupon) => {
return UTILS.returnCouponCanUse({
const { canUse, msg } = UTILS.returnCouponCanUse({
canDikouGoodsArr,
coupon,
orderPrice: orderPrice.value,
user: props.user,
selCoupon: [],
selCoupon: quansSelArr.value,
shopInfo: shopUser.userInfo,
});
return canUse;
})
.map((v) => {
const findGoods = goodsArr.find((goods) => goods.productId == v.proId);
@@ -300,7 +312,8 @@ async function getcoup() {
v,
props.user,
orderPrice.value,
[]
quansSelArr.value,
shopUser.userInfo
);
return {
...v,

View File

@@ -495,6 +495,7 @@ async function clearOldOrder(params) {
type: res1 ? "success" : "error",
message: res1 ? "删除成功" : "删除失败",
});
showOrder.value = false;
clearOldOrderCallback();
} catch (error) {
clearOldOrderCallback();