diff --git a/packageA/pages/details_serviceCard/details_serviceCard.js b/packageA/pages/details_serviceCard/details_serviceCard.js index e51822a..ac80b52 100644 --- a/packageA/pages/details_serviceCard/details_serviceCard.js +++ b/packageA/pages/details_serviceCard/details_serviceCard.js @@ -726,7 +726,7 @@ Page({ }; }); if(it.prom_type==2) - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gid + "/" + prom_id, {}).then(res => { + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + it.card_id + "/" + it.prom_id, {}).then(res => { if (res.data.code == 0) { console.log('当前的t团购活动信息:', res.data.data); act_details = res.data.data; diff --git a/packageG/pages/group_buy/goodsInfo/goodsInfo.js b/packageG/pages/group_buy/goodsInfo/goodsInfo.js index 3462ecc..50ffe5f 100644 --- a/packageG/pages/group_buy/goodsInfo/goodsInfo.js +++ b/packageG/pages/group_buy/goodsInfo/goodsInfo.js @@ -1095,88 +1095,75 @@ Page({ }); } - // 秒杀活动 - if (this.data.prom_type == 1) { - // 如果是秒杀活动下的单独购买,is_normal为1 - if (this.data.openSpecModal_flash_normal) this.data.is_normal = 1; - - if (this.data.is_normal) {// 单独购买 - this.setData({ - goodsInputNum: t, + //团购活动 + // 获取redis当前可以购买的数量 + // 如果数量为0,设置和显示已抢光 + // 否则,进一步判断是否超出限购或超出库存 + await this.getactLen().then(async function (res) { + // res: redis可购买数量 + // console.log('当前可以购买的数量:', res); + if (res <= 0) { + // 可购买数量<=0, 设置和显示已抢光 + th.setData({ + prom_r_null: 1, }); - } else {// 秒杀购买 - - // 获取redis当前可以购买的数量 - // 如果数量为0,设置和显示已抢光 - // 否则,进一步判断是否超出限购或超出库存 - await this.getactLen().then(async function (res) { - // res: redis可购买数量 - // console.log('当前可以购买的数量:', res); - if (res <= 0) { - // 可购买数量<=0, 设置和显示已抢光 - th.setData({ - prom_r_null: 1, - }); - } else { - // 可购买数量>0 - // 计算自己还可以购买的数量 - // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b - // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 - // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 - let actInfo = th.data.sele_g; - await th.get_buy_num2().then(function (data) { - let limited = actInfo.buy_limit == 0 ? 100000 : actInfo.buy_limit; // 限购数量a - let promcardbuynum = data.data.data.promcardbuynum; - let buyedNum = promcardbuynum; // 自己已经购买的数量b - let canBuyNum = limited - buyedNum; // 自己还可购买的数量c - - if (canBuyNum <= 0) { - canBuyNum = 0; - } - ; - - if (limited > res) { - if (t > res) { // t当前增减的数量 - // wx.showModal({ - // title: '超出活动库存', - // }); - getApp().my_warnning('超出活动库存', 0, self); - th.setData({ - goodsInputNum: res || 1, - }); - return false; - } - - } - + } else { + // 可购买数量>0 + // 计算自己还可以购买的数量 + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 + let actInfo = th.data.sele_g; + await th.get_buy_num2().then(function (data) { + let limited = actInfo.buy_limit == 0 ? 100000 : actInfo.buy_limit; // 限购数量a + let promcardbuynum = data.data.data.promcardbuynum; + let buyedNum = promcardbuynum; // 自己已经购买的数量b + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c + + if (canBuyNum <= 0) { + canBuyNum = 0; + } + ; - if (limited <= res) { - if (t > canBuyNum) { - // wx.showModal({ - // title: '超出限购数量', - // }); - getApp().my_warnning('超出限购数量', 0, self); - th.setData({ - goodsInputNum: canBuyNum || 1, - }); - return false; - } + if (limited > res) { + if (t > res) { // t当前增减的数量 + // wx.showModal({ + // title: '超出活动库存', + // }); + getApp().my_warnning('超出活动库存', 0, self); + th.setData({ + goodsInputNum: res || 1, + }); + return false; + } - } + } + if (limited <= res) { + if (t > canBuyNum) { + // wx.showModal({ + // title: '超出限购数量', + // }); + getApp().my_warnning('超出限购数量', 0, self); th.setData({ - goodsInputNum: t, + goodsInputNum: canBuyNum || 1, }); - }); + return false; + } + } - ; - }); + + th.setData({ + goodsInputNum: t, + }); + }); } + }) + - } }, @@ -1526,7 +1513,7 @@ Page({ } //如果有秒杀的指定门店 - if (th.data.prom_type == 1 && th.data.prom_act && th.data.prom_act.pick_up_lists && e.data.data.pageData.length && !is_normal) { + if (th.data.prom_type == 2 && th.data.prom_act && th.data.prom_act.pick_up_lists && e.data.data.pageData.length && !is_normal) { var pick_up_lists = th.data.prom_act.pick_up_lists; for (var kq = 0; kq < e.data.data.pageData.length; kq++) { var it0 = e.data.data.pageData[kq]; @@ -3085,7 +3072,6 @@ Page({ } }, - get_buy_num2: async function () { var th = this, user_id = getApp().globalData.user_id; //----获取活动购买数---- @@ -3095,7 +3081,8 @@ Page({ user_id: user_id, card_id: th.data.options.goods_id, prom_type: th.data.options.prom_type, - prom_id: th.data.options.prom_id + prom_id: th.data.options.prom_id, + isnew:1 }, //-----获取----- success: function (tt) { diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 36ef7bd..1bd6535 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -3197,7 +3197,7 @@ Page({ //用户已经成功付款购买的数量 var gd_buy_num = 0; - await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id=" + t.store_id + "&user_id=" + getApp().globalData.user_id + "&card_id=" + t.card_id + "&prom_type=" + t.prom_type + "&prom_id=" + t.prom_id, {}).then(tt => { + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id=" + t.store_id + "&isnew=1&user_id=" + getApp().globalData.user_id + "&card_id=" + t.card_id + "&prom_type=" + t.prom_type + "&prom_id=" + t.prom_id, {}).then(tt => { if (tt.data.code == 0) { gd_buy_num = !tt.data.data.promcardbuynum ? 0 : tt.data.data.promcardbuynum; th.setData({ diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index f36e3ed..310c841 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -3133,14 +3133,14 @@ Page({ for (const it of list) { //秒杀 - if (it.prom_type == 1) { + if ([1,2].includes(it.prom_type)) { let act_details = null; let redis_num = 0; let promcardbuynum = 0; let qty = it.qty; - - await getApp().request.promiseGet('/api/ms/flash_sale/getNew/' + store_id + '/' + user_id + '/' + it.prom_id, {}).then(res => { + if(it.prom_type==1) + await getApp().request.promiseGet('/api/ms/flash_sale/getNew/' + store_id + '/' + user_id + '/' + it.prom_id, {}).then(res => { if (res.data.code == 0) { act_details = res.data.data; @@ -3191,6 +3191,46 @@ Page({ } }); + if(it.prom_type==2) + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + it.card_id + "/" + it.prom_id, {}).then(res => { + if (res.data.code == 0) { + console.log('当前的t团购活动信息:', res.data.data); + act_details = res.data.data; + if (act_details.is_end == 1) { + wx.showModal({ + title: '提示', + content: '活动已结束,无法支付,请取消订单!', + showCancel: false, + }); + flag = false; + return false; + }; + var t_now = ut.gettimestamp(); + if (act_details.is_end == 1 || act_details.start_time > t_now || act_details.end_time < t_now) { + wx.showModal({ + title: '提示', + content: '活动发生了变化,无法支付,请取消订单,重新购买!', + showCancel: false, + }); + flag = false; + return false; + } + + //指定门店的控制 + if (act_details.pick_up_lists) { + var idx0=act_details.pick_up_lists.findIndex(function (e){ + return e.pickup_id==it.pickup_id; + }) + if(idx0<0){ + getApp().confirmBox(it.service_name + "秒杀活动的门店不可售"); + th.setData({ paying: 0 }); + flag = false; + return false; + } + } + + }; + }); if(act_details && act_details.buy_limit>0 && flag){ await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {