优化代课下单优惠券选择

This commit is contained in:
gyq
2025-11-14 18:13:38 +08:00
parent a3cbe7576e
commit 18d2a73073
6 changed files with 28 additions and 27 deletions

View File

@@ -5,7 +5,6 @@ import { useUserStoreHook } from "@/store/modules/user";
import productApi from "@/api/product/index";
import shopUserApi from '@/api/account/shopUser'
import limitTimeDiscountApi from '@/api/market/limitTimeDiscount.js'
import * as UTILS from "@/utils/coupon-utils.js";
import { BigNumber } from "bignumber.js";
import _ from "lodash";
// 导入工具库及相关类型
@@ -16,7 +15,8 @@ import {
BackendCoupon,
ActivityConfig,
OrderExtraConfig, MerchantReductionConfig, MerchantReductionType,
GoodsType, FullReductionActivity
GoodsType, FullReductionActivity,
couponUtils
} from "ysk-utils";
// import {
@@ -253,10 +253,9 @@ export const useCartsStore = defineStore("carts", () => {
})
// 获取满减活动
const fullReductionRes = await limitTimeDiscountApi.getDiscountActivity({
fullReductionActivities.value = await limitTimeDiscountApi.getDiscountActivity({
shopId: localStorage.getItem("shopId")
});
fullReductionActivities.value = fullReductionRes?.data || [];
if (limitDiscountRes.value !== null) {
checkLinkFinished().then(() => {
@@ -431,13 +430,13 @@ export const useCartsStore = defineStore("carts", () => {
console.log('setCoupons', cps);
let goodsCoupon = cps.filter((v) => v.type == 2);
let otherCoupon = cps.filter((v) => v.type != 2);
const canDikouGoodsArr = UTILS.returnCanDikouGoods(allGoods.value, [], vipUser.value);
const canDikouGoodsArr = couponUtils.returnCanDikouGoods(allGoods.value, [], vipUser.value);
//商品订单金额
const goodsOrderPrice = new BigNumber(orderCostSummary.value.goodsOriginalAmount)
.minus(orderCostSummary.value.goodsDiscountAmount)
.toFixed(2);
goodsCoupon = goodsCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, vipUser.value, goodsOrderPrice, [], shopUser.userInfo);
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, vipUser.value, goodsOrderPrice, [], shopUser.userInfo);
return {
...v,
discount,
@@ -445,7 +444,7 @@ export const useCartsStore = defineStore("carts", () => {
};
});
otherCoupon = otherCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, vipUser.value, goodsOrderPrice, goodsCoupon, shopUser.userInfo);
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, vipUser.value, goodsOrderPrice, goodsCoupon, shopUser.userInfo);
return {
...v,
discount,