代客下单修改,问题修复

This commit is contained in:
2025-11-18 14:55:26 +08:00
parent 67ec915181
commit 93273b796f
17 changed files with 174 additions and 117 deletions

View File

@@ -87,7 +87,7 @@
<view class="u-m-t-32">
<view class="u-flex u-row-right">
<text>总计</text>
<text class="font-bold u-font-32">{{originAmount.toFixed(2)}}</text>
<text class="font-bold u-font-32">{{data.payAmount||data.orderAmount}}</text>
</view>
<view class="u-flex u-row-right u-m-t-24" v-if="data.status == 'unpaid'||data.status == 'done'">
<view class="print" @click.stop="print(item)">重新打印</view>

View File

@@ -58,7 +58,10 @@
</view>
<view
class="border-bottom-dashed u-p-b-30 u-p-t-30"
v-if="orderCostSummary.fullReduction.actualAmount&&orderCostSummary.fullReduction.usedThreshold"
v-if="
orderCostSummary.fullReduction.actualAmount &&
orderCostSummary.fullReduction.usedThreshold
"
>
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between">
<view>满减活动</view>
@@ -67,20 +70,27 @@
</view>
</view>
</view>
<view class="border-bottom-dashed u-p-b-30 u-p-t-30">
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between" @click="toQuan">
<view>优惠券</view>
<view class="color-999 u-flex u-col-center">
<text v-if="orderCostSummary.couponDeductionAmount <= 0"
<text
class="color-red"
v-if="orderCostSummary.fullReduction.usedThreshold"
>满减活动不可与优惠券同享</text
>
<text v-else-if="orderCostSummary.couponDeductionAmount <= 0"
>选择优惠券</text
>
<text class="color-red" v-else>
-¥{{ orderCostSummary.couponDeductionAmount }}
</text>
<view class="u-flex u-col-center">
<view
class="u-flex u-col-center"
v-if="!orderCostSummary.fullReduction.usedThreshold"
>
<uni-icons type="right" color="#999"></uni-icons>
</view>
</view>
@@ -229,9 +239,9 @@
<view class="" v-if="accountPoints.calcRes.usable">
<text class="color-red">*</text>
<text class="" v-if="accountPoints.calcRes.equivalentPoints"
>100积分等于{{
to2(accountPoints.calcRes.equivalentPoints * 100)
}}元,</text
>{{
accountPoints.calcRes.equivalentPoints
}}积分等于1元,</text
>
<text>
最大抵扣积分{{ accountPoints.calcRes.maxUsablePoints }}
@@ -360,7 +370,8 @@ import {
consumeAwardPoints,
} from "@/http/api/points.js";
import yskUtils from "ysk-utils";
// import yskUtils from "ysk-utils";
import yskUtils from "@/lib/index";
const websocketUtil = inject("websocketUtil"); // 注入 WebSocket 工具类实例
const modal = reactive({
@@ -431,14 +442,14 @@ async function getDiscountActivity() {
shopId: uni.getStorageSync("shopId"),
});
if (res.code == 200) {
fullReductionActivities.value = res.data?[res.data]:[];
fullReductionActivities.value = res.data ? [res.data] : [];
}
}
onLoad(async (opt) => {
Object.assign(order, opt);
Object.assign(options, opt);
await getPayType();
await getDiscountActivity()
await getDiscountActivity();
console.log("pays.payTypes.list");
init();
});
@@ -503,6 +514,7 @@ async function init() {
});
}
pageData.seatNum = order.seatNum;
seatFeeConfig.personCount = order.seatNum;
}
/**
@@ -524,22 +536,6 @@ const coupAllPrice = computed(() => {
return n;
});
/**
* 菜品打包费
*/
const packAmount = computed(() => {
if (pageData.goodsList) {
let price = pageData.goodsList
.filter((v) => v.packNumber > 0 && v.status !== "return")
.reduce((a, b) => {
console.log(b);
return a + ((b.packAmount || 0) * b.packNumber).toFixed(2) * 1;
}, 0);
// console.log("菜品打包费===",price)
return price;
}
});
/**
* 桌位费
*/
@@ -548,29 +544,6 @@ const tableFee = computed(() => {
return order.seatNum > 0 ? order.seatNum * pageData.shopInfo.tableFee : 0;
});
/**
* 菜品金额
*/
const originPrice = computed(() => {
if (pageData.goodsList) {
let goodsPrice = pageData.goodsList
.filter((v) => v.price != 0 && v.status !== "return")
.reduce((a, b) => {
return a + parseFloat(mathFloorPrice(b.num * b.price, b));
}, 0);
// console.log("菜品原金额===",goodsPrice)
return (
parseFloat(goodsPrice) +
parseFloat(tableFee.value) +
parseFloat(packAmount.value)
).toFixed(2);
}
});
// 计算商家减免前金额使用bignumber.js确保精度
const returnMerchantReductionBeforeMoney = computed(() => {
const total = BigNumber(orderCostSummary.value.finalPayAmount).plus(
@@ -715,6 +688,14 @@ watch(
}
}
);
watch(
() => pageData.user.id,
(newval) => {
if (newval) {
getCalcUsablePoints();
}
}
);
watch(
() => orderCostSummary.value.finalPayAmount,
(newval) => {
@@ -787,10 +768,12 @@ function getPayParam() {
: "",
discountActAmount: orderCostSummary.value.fullReduction.actualAmount, //满减抵扣金额
discountActId: (orderCostSummary.value.fullReduction.usedActivity&&orderCostSummary.value.fullReduction.usedThreshold)
? orderCostSummary.value.fullReduction.usedActivity.id
: null,
vipPrice:isVip.value? 1 : 0, // 是否使用会员价
discountActId:
orderCostSummary.value.fullReduction.usedActivity &&
orderCostSummary.value.fullReduction.usedThreshold
? orderCostSummary.value.fullReduction.usedActivity.id
: null,
vipPrice: isVip.value ? 1 : 0, // 是否使用会员价
limitRate:
order.limitRate && order.limitRate.id
? {
@@ -852,7 +835,7 @@ async function getPayType() {
}
pays.payTypes.list.push({
...v,
disabled
disabled,
});
}
});
@@ -919,20 +902,20 @@ function changeAccountPoints() {
* 选择优惠券
*/
function toQuan() {
console.log("toQuan", order);
console.log("pageData.user", pageData.user);
if(orderCostSummary.value.usedActivity){
return infoBox.showToast("满减活动不可与优惠券同享")
if (orderCostSummary.value.fullReduction.usedThreshold) {
return infoBox.showToast("满减活动不可与优惠券同享");
}
if (!order.userId && !pageData.user.id) {
return infoBox.showToast("请先选择会员", 0.5).then(() => {
chooseUser();
});
}
uni.setStorageSync("selCoupon", selCoupon.value);
go.to("PAGES_ORDER_QUAN", {
orderId: order.id,
shopUserId: pageData.user.id,
orderPrice: (payPrice.value * 1 + coupAllPrice.value * 1).toFixed(2),
orderPrice: BigNumber(payPrice.value).plus(BigNumber(orderCostSummary.value.couponDeductionAmount)).decimalPlaces(2, BigNumber.ROUND_DOWN)
});
}
@@ -1016,7 +999,6 @@ function uodateCartAndHistory() {
history: [],
cart: [],
};
console.log("uodateCartAndHistory", pageData.user);
for (let cart of pageData.goodsList) {
const canUseLimitTimeDiscount = yskUtils.limitUtils.canUseLimitTimeDiscount(
cart,
@@ -1027,14 +1009,14 @@ function uodateCartAndHistory() {
)
? 1
: 0;
console.log("uodateCartAndHistory", pageData.user);
if (canUseLimitTimeDiscount != cart.is_time_discount) {
newData.cart.push({
if (canUseLimitTimeDiscount != cart.isTimeDiscount) {
newData.history.push({
id: cart.id,
is_time_discount: canUseLimitTimeDiscount,
});
}
}
if (newData.history.length <= 0 && newData.cart.length <= 0) {
return;
}
@@ -1062,8 +1044,7 @@ function getShopUserDetail() {
});
}
const newUserDiscountRes=ref(null)
const newUserDiscountRes = ref(null);
//获取用户新客立减
function getNewUserDiscount() {
getDiscountByUserId({
@@ -1391,7 +1372,7 @@ function onMessage() {
websocketUtil.offMessage();
websocketUtil.onMessage((res) => {
let msg = JSON.parse(res);
console.log("onMessage", msg);
switch (msg.operate_type) {
case "pad_init":
getHistoryAndUpdateGoodsList();
@@ -1402,6 +1383,9 @@ function onMessage() {
case "pad_edit":
case "edit":
break;
case "bulk_edit":
getHistoryAndUpdateGoodsList();
break;
case "pad_del":
case "del":
break;

View File

@@ -336,12 +336,7 @@ const limitTimeDiscount = reactive({ id: "" });
const quansSelArr = computed(() => {
return [couponSel.value, goodsCouponSel.value].filter((v) => v.id);
});
const querForm = ref({
searchValue: "",
shopId: "",
shopName: "",
statusActiveIndex: 0,
});
const list = reactive({
page: 1,
size: 10,
@@ -372,8 +367,9 @@ function formatCoupon() {
for (let i = 0; i < couponList.value.length; i++) {
const coupon = couponList.value[i];
console.log('quansSelArr',quansSelArr.value)
const selCoupon =
myQuan.types.sel != 1
myQuan.types.sel ==1
? quansSelArr.value.filter((v) => v.type != 2)
: quansSelArr.value.filter((v) => v.type == 2);
const canuseResult = yskUtils.couponUtils.returnCouponCanUse({
@@ -585,6 +581,14 @@ async function getShopUser() {
}
onLoad(async (opt) => {
Object.assign(option, opt);
const selCoupon=uni.getStorageSync("selCoupon")||[];
for(let i=0;i<selCoupon.length;i++){
if(selCoupon[i].type==2){
goodsCouponSel.value=selCoupon[i];
}else{
couponSel.value=selCoupon[i];
}
}
await getShopUser();
getQuan();
});