修复限时折扣问题
This commit is contained in:
@@ -141,9 +141,9 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
deep: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -152,21 +152,23 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
enableRewards: 0, //是否开启
|
||||
pointsPerYuan: 0,
|
||||
maxDeductionAmount: Infinity,
|
||||
maxDeductionRatio: 0 ,//积分抵扣比例
|
||||
minPaymentAmount:0,//门槛
|
||||
maxDeductionRatio: 0, //积分抵扣比例
|
||||
minPaymentAmount: 0, //门槛
|
||||
});
|
||||
|
||||
function setPointDeductionRule(args) {
|
||||
const {
|
||||
equivalentPoints,
|
||||
maxDeductionAmount,enableRewards,minPaymentAmount,
|
||||
maxDeductionAmount,
|
||||
enableRewards,
|
||||
minPaymentAmount,
|
||||
maxDeductionRatio
|
||||
} = args
|
||||
pointDeductionRule.value.pointsPerYuan =equivalentPoints||0;
|
||||
pointDeductionRule.value.maxDeductionAmount = maxDeductionAmount||0;
|
||||
pointDeductionRule.value.maxDeductionRatio = maxDeductionRatio||0;
|
||||
pointDeductionRule.value.enableRewards = enableRewards||0;
|
||||
pointDeductionRule.value.minPaymentAmount = minPaymentAmount||0;
|
||||
pointDeductionRule.value.pointsPerYuan = equivalentPoints || 0;
|
||||
pointDeductionRule.value.maxDeductionAmount = maxDeductionAmount || 0;
|
||||
pointDeductionRule.value.maxDeductionRatio = maxDeductionRatio || 0;
|
||||
pointDeductionRule.value.enableRewards = enableRewards || 0;
|
||||
pointDeductionRule.value.minPaymentAmount = minPaymentAmount || 0;
|
||||
}
|
||||
|
||||
// 初始配置:默认无减免(固定金额 0 元)
|
||||
@@ -309,15 +311,55 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
// 用于记录已经处理过的消息的 msg_id
|
||||
const processedMessageIds = new Set();
|
||||
|
||||
|
||||
// 发送消息
|
||||
let socketSendMsg = (data) => {
|
||||
|
||||
}
|
||||
|
||||
//购物车商品信息补全初始化
|
||||
function cartsGoodsInfoInit(arr) {
|
||||
console.log('cartsGoodsInfoInit', arr)
|
||||
carts.value = arr
|
||||
.map((v) => {
|
||||
|
||||
const item = getProductDetails(v);
|
||||
if (!item) {
|
||||
return null
|
||||
}
|
||||
const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount(v, limitTimeDiscount
|
||||
.value,
|
||||
shopInfo.value,
|
||||
shopUserInfo.value, 'product_id');
|
||||
return {
|
||||
...item,
|
||||
is_time_discount: is_time_discount ? 1 : 0
|
||||
}
|
||||
})
|
||||
.filter((v) => v);
|
||||
|
||||
const result = []
|
||||
if (arr && Array.isArray(arr)) {
|
||||
carts.value = arr
|
||||
.map((v) => {
|
||||
return getProductDetails(v);
|
||||
})
|
||||
.filter((v) => v);
|
||||
for (let cart of arr) {
|
||||
const findItem = carts.value.find(v => v.id == cart.id)
|
||||
if (findItem && findItem.is_time_discount != cart.is_time_discount) {
|
||||
result.push({
|
||||
id: cart.id,
|
||||
is_time_discount: findItem.is_time_discount
|
||||
})
|
||||
}
|
||||
}
|
||||
if (result.length > 0) {
|
||||
socketSendMsg({
|
||||
type: "shopping",
|
||||
operate_type: "bulk_edit",
|
||||
data: {
|
||||
cart: result
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -341,8 +383,6 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
const msgData = Message.data;
|
||||
// 初始化
|
||||
if (Message.operate_type == "init") {
|
||||
console.log("carts init Message", Message);
|
||||
console.log("carts init", msgData);
|
||||
if (!oldOrder.value.id) {
|
||||
limitTimeDiscount.value = Message.time_dis_info;
|
||||
}
|
||||
@@ -670,7 +710,8 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
orderCostSummary,
|
||||
setCoupons,
|
||||
userPoints,
|
||||
setUserPoints,pointDeductionRule,
|
||||
setUserPoints,
|
||||
pointDeductionRule,
|
||||
setPointDeductionRule,
|
||||
setOldOrder,
|
||||
//返回商品信息
|
||||
@@ -699,5 +740,6 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
//限时折扣
|
||||
limitTimeDiscount,
|
||||
shopUserInfo,
|
||||
socketSendMsg,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user