Commit c1b8754a9bfb9b4e9839f21fe32516c58cf3a7b9
1 parent
f92e05ec
指定门店的优化,限购的优化
Showing
4 changed files
with
105 additions
and
78 deletions
packageA/pages/details_serviceCard/details_serviceCard.js
@@ -726,7 +726,7 @@ Page({ | @@ -726,7 +726,7 @@ Page({ | ||
726 | }; | 726 | }; |
727 | }); | 727 | }); |
728 | if(it.prom_type==2) | 728 | if(it.prom_type==2) |
729 | - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gid + "/" + prom_id, {}).then(res => { | 729 | + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + it.card_id + "/" + it.prom_id, {}).then(res => { |
730 | if (res.data.code == 0) { | 730 | if (res.data.code == 0) { |
731 | console.log('当前的t团购活动信息:', res.data.data); | 731 | console.log('当前的t团购活动信息:', res.data.data); |
732 | act_details = res.data.data; | 732 | act_details = res.data.data; |
packageG/pages/group_buy/goodsInfo/goodsInfo.js
@@ -1095,88 +1095,75 @@ Page({ | @@ -1095,88 +1095,75 @@ Page({ | ||
1095 | }); | 1095 | }); |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | - // 秒杀活动 | ||
1099 | - if (this.data.prom_type == 1) { | ||
1100 | - // 如果是秒杀活动下的单独购买,is_normal为1 | ||
1101 | - if (this.data.openSpecModal_flash_normal) this.data.is_normal = 1; | ||
1102 | - | ||
1103 | - if (this.data.is_normal) {// 单独购买 | ||
1104 | - this.setData({ | ||
1105 | - goodsInputNum: t, | 1098 | + //团购活动 |
1099 | + // 获取redis当前可以购买的数量 | ||
1100 | + // 如果数量为0,设置和显示已抢光 | ||
1101 | + // 否则,进一步判断是否超出限购或超出库存 | ||
1102 | + await this.getactLen().then(async function (res) { | ||
1103 | + // res: redis可购买数量 | ||
1104 | + // console.log('当前可以购买的数量:', res); | ||
1105 | + if (res <= 0) { | ||
1106 | + // 可购买数量<=0, 设置和显示已抢光 | ||
1107 | + th.setData({ | ||
1108 | + prom_r_null: 1, | ||
1106 | }); | 1109 | }); |
1107 | - } else {// 秒杀购买 | ||
1108 | - | ||
1109 | - // 获取redis当前可以购买的数量 | ||
1110 | - // 如果数量为0,设置和显示已抢光 | ||
1111 | - // 否则,进一步判断是否超出限购或超出库存 | ||
1112 | - await this.getactLen().then(async function (res) { | ||
1113 | - // res: redis可购买数量 | ||
1114 | - // console.log('当前可以购买的数量:', res); | ||
1115 | - if (res <= 0) { | ||
1116 | - // 可购买数量<=0, 设置和显示已抢光 | ||
1117 | - th.setData({ | ||
1118 | - prom_r_null: 1, | ||
1119 | - }); | ||
1120 | - } else { | ||
1121 | - // 可购买数量>0 | ||
1122 | - // 计算自己还可以购买的数量 | ||
1123 | - // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b | ||
1124 | - // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 | ||
1125 | - // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 | ||
1126 | - let actInfo = th.data.sele_g; | ||
1127 | - await th.get_buy_num2().then(function (data) { | ||
1128 | - let limited = actInfo.buy_limit == 0 ? 100000 : actInfo.buy_limit; // 限购数量a | ||
1129 | - let promcardbuynum = data.data.data.promcardbuynum; | ||
1130 | - let buyedNum = promcardbuynum; // 自己已经购买的数量b | ||
1131 | - let canBuyNum = limited - buyedNum; // 自己还可购买的数量c | ||
1132 | - | ||
1133 | - if (canBuyNum <= 0) { | ||
1134 | - canBuyNum = 0; | ||
1135 | - } | ||
1136 | - ; | ||
1137 | - | ||
1138 | - if (limited > res) { | ||
1139 | - if (t > res) { // t当前增减的数量 | ||
1140 | - // wx.showModal({ | ||
1141 | - // title: '超出活动库存', | ||
1142 | - // }); | ||
1143 | - getApp().my_warnning('超出活动库存', 0, self); | ||
1144 | - th.setData({ | ||
1145 | - goodsInputNum: res || 1, | ||
1146 | - }); | ||
1147 | - return false; | ||
1148 | - } | ||
1149 | - | ||
1150 | - } | ||
1151 | - | 1110 | + } else { |
1111 | + // 可购买数量>0 | ||
1112 | + // 计算自己还可以购买的数量 | ||
1113 | + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b | ||
1114 | + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 | ||
1115 | + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 | ||
1116 | + let actInfo = th.data.sele_g; | ||
1117 | + await th.get_buy_num2().then(function (data) { | ||
1118 | + let limited = actInfo.buy_limit == 0 ? 100000 : actInfo.buy_limit; // 限购数量a | ||
1119 | + let promcardbuynum = data.data.data.promcardbuynum; | ||
1120 | + let buyedNum = promcardbuynum; // 自己已经购买的数量b | ||
1121 | + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c | ||
1122 | + | ||
1123 | + if (canBuyNum <= 0) { | ||
1124 | + canBuyNum = 0; | ||
1125 | + } | ||
1126 | + ; | ||
1152 | 1127 | ||
1153 | - if (limited <= res) { | ||
1154 | - if (t > canBuyNum) { | ||
1155 | - // wx.showModal({ | ||
1156 | - // title: '超出限购数量', | ||
1157 | - // }); | ||
1158 | - getApp().my_warnning('超出限购数量', 0, self); | ||
1159 | - th.setData({ | ||
1160 | - goodsInputNum: canBuyNum || 1, | ||
1161 | - }); | ||
1162 | - return false; | ||
1163 | - } | 1128 | + if (limited > res) { |
1129 | + if (t > res) { // t当前增减的数量 | ||
1130 | + // wx.showModal({ | ||
1131 | + // title: '超出活动库存', | ||
1132 | + // }); | ||
1133 | + getApp().my_warnning('超出活动库存', 0, self); | ||
1134 | + th.setData({ | ||
1135 | + goodsInputNum: res || 1, | ||
1136 | + }); | ||
1137 | + return false; | ||
1138 | + } | ||
1164 | 1139 | ||
1165 | - } | 1140 | + } |
1166 | 1141 | ||
1167 | 1142 | ||
1143 | + if (limited <= res) { | ||
1144 | + if (t > canBuyNum) { | ||
1145 | + // wx.showModal({ | ||
1146 | + // title: '超出限购数量', | ||
1147 | + // }); | ||
1148 | + getApp().my_warnning('超出限购数量', 0, self); | ||
1168 | th.setData({ | 1149 | th.setData({ |
1169 | - goodsInputNum: t, | 1150 | + goodsInputNum: canBuyNum || 1, |
1170 | }); | 1151 | }); |
1171 | - }); | 1152 | + return false; |
1153 | + } | ||
1154 | + | ||
1172 | } | 1155 | } |
1173 | - ; | ||
1174 | - }); | ||
1175 | 1156 | ||
1157 | + | ||
1158 | + th.setData({ | ||
1159 | + goodsInputNum: t, | ||
1160 | + }); | ||
1161 | + }); | ||
1176 | } | 1162 | } |
1177 | 1163 | ||
1164 | + }) | ||
1165 | + | ||
1178 | 1166 | ||
1179 | - } | ||
1180 | 1167 | ||
1181 | 1168 | ||
1182 | }, | 1169 | }, |
@@ -1526,7 +1513,7 @@ Page({ | @@ -1526,7 +1513,7 @@ Page({ | ||
1526 | } | 1513 | } |
1527 | 1514 | ||
1528 | //如果有秒杀的指定门店 | 1515 | //如果有秒杀的指定门店 |
1529 | - if (th.data.prom_type == 1 && th.data.prom_act && th.data.prom_act.pick_up_lists && e.data.data.pageData.length && !is_normal) { | 1516 | + if (th.data.prom_type == 2 && th.data.prom_act && th.data.prom_act.pick_up_lists && e.data.data.pageData.length && !is_normal) { |
1530 | var pick_up_lists = th.data.prom_act.pick_up_lists; | 1517 | var pick_up_lists = th.data.prom_act.pick_up_lists; |
1531 | for (var kq = 0; kq < e.data.data.pageData.length; kq++) { | 1518 | for (var kq = 0; kq < e.data.data.pageData.length; kq++) { |
1532 | var it0 = e.data.data.pageData[kq]; | 1519 | var it0 = e.data.data.pageData[kq]; |
@@ -3085,7 +3072,6 @@ Page({ | @@ -3085,7 +3072,6 @@ Page({ | ||
3085 | } | 3072 | } |
3086 | }, | 3073 | }, |
3087 | 3074 | ||
3088 | - | ||
3089 | get_buy_num2: async function () { | 3075 | get_buy_num2: async function () { |
3090 | var th = this, user_id = getApp().globalData.user_id; | 3076 | var th = this, user_id = getApp().globalData.user_id; |
3091 | //----获取活动购买数---- | 3077 | //----获取活动购买数---- |
@@ -3095,7 +3081,8 @@ Page({ | @@ -3095,7 +3081,8 @@ Page({ | ||
3095 | user_id: user_id, | 3081 | user_id: user_id, |
3096 | card_id: th.data.options.goods_id, | 3082 | card_id: th.data.options.goods_id, |
3097 | prom_type: th.data.options.prom_type, | 3083 | prom_type: th.data.options.prom_type, |
3098 | - prom_id: th.data.options.prom_id | 3084 | + prom_id: th.data.options.prom_id, |
3085 | + isnew:1 | ||
3099 | }, | 3086 | }, |
3100 | //-----获取----- | 3087 | //-----获取----- |
3101 | success: function (tt) { | 3088 | success: function (tt) { |
pages/cart/cart/cart.js
@@ -3197,7 +3197,7 @@ Page({ | @@ -3197,7 +3197,7 @@ Page({ | ||
3197 | 3197 | ||
3198 | //用户已经成功付款购买的数量 | 3198 | //用户已经成功付款购买的数量 |
3199 | var gd_buy_num = 0; | 3199 | var gd_buy_num = 0; |
3200 | - 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 => { | 3200 | + 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 => { |
3201 | if (tt.data.code == 0) { | 3201 | if (tt.data.code == 0) { |
3202 | gd_buy_num = !tt.data.data.promcardbuynum ? 0 : tt.data.data.promcardbuynum; | 3202 | gd_buy_num = !tt.data.data.promcardbuynum ? 0 : tt.data.data.promcardbuynum; |
3203 | th.setData({ | 3203 | th.setData({ |
pages/user/order_list/order_list.js
@@ -3133,14 +3133,14 @@ Page({ | @@ -3133,14 +3133,14 @@ Page({ | ||
3133 | 3133 | ||
3134 | for (const it of list) { | 3134 | for (const it of list) { |
3135 | //秒杀 | 3135 | //秒杀 |
3136 | - if (it.prom_type == 1) { | 3136 | + if ([1,2].includes(it.prom_type)) { |
3137 | let act_details = null; | 3137 | let act_details = null; |
3138 | let redis_num = 0; | 3138 | let redis_num = 0; |
3139 | let promcardbuynum = 0; | 3139 | let promcardbuynum = 0; |
3140 | let qty = it.qty; | 3140 | let qty = it.qty; |
3141 | 3141 | ||
3142 | - | ||
3143 | - await getApp().request.promiseGet('/api/ms/flash_sale/getNew/' + store_id + '/' + user_id + '/' + it.prom_id, {}).then(res => { | 3142 | + if(it.prom_type==1) |
3143 | + await getApp().request.promiseGet('/api/ms/flash_sale/getNew/' + store_id + '/' + user_id + '/' + it.prom_id, {}).then(res => { | ||
3144 | 3144 | ||
3145 | if (res.data.code == 0) { | 3145 | if (res.data.code == 0) { |
3146 | act_details = res.data.data; | 3146 | act_details = res.data.data; |
@@ -3191,6 +3191,46 @@ Page({ | @@ -3191,6 +3191,46 @@ Page({ | ||
3191 | 3191 | ||
3192 | } | 3192 | } |
3193 | }); | 3193 | }); |
3194 | + if(it.prom_type==2) | ||
3195 | + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + it.card_id + "/" + it.prom_id, {}).then(res => { | ||
3196 | + if (res.data.code == 0) { | ||
3197 | + console.log('当前的t团购活动信息:', res.data.data); | ||
3198 | + act_details = res.data.data; | ||
3199 | + if (act_details.is_end == 1) { | ||
3200 | + wx.showModal({ | ||
3201 | + title: '提示', | ||
3202 | + content: '活动已结束,无法支付,请取消订单!', | ||
3203 | + showCancel: false, | ||
3204 | + }); | ||
3205 | + flag = false; | ||
3206 | + return false; | ||
3207 | + }; | ||
3208 | + var t_now = ut.gettimestamp(); | ||
3209 | + if (act_details.is_end == 1 || act_details.start_time > t_now || act_details.end_time < t_now) { | ||
3210 | + wx.showModal({ | ||
3211 | + title: '提示', | ||
3212 | + content: '活动发生了变化,无法支付,请取消订单,重新购买!', | ||
3213 | + showCancel: false, | ||
3214 | + }); | ||
3215 | + flag = false; | ||
3216 | + return false; | ||
3217 | + } | ||
3218 | + | ||
3219 | + //指定门店的控制 | ||
3220 | + if (act_details.pick_up_lists) { | ||
3221 | + var idx0=act_details.pick_up_lists.findIndex(function (e){ | ||
3222 | + return e.pickup_id==it.pickup_id; | ||
3223 | + }) | ||
3224 | + if(idx0<0){ | ||
3225 | + getApp().confirmBox(it.service_name + "秒杀活动的门店不可售"); | ||
3226 | + th.setData({ paying: 0 }); | ||
3227 | + flag = false; | ||
3228 | + return false; | ||
3229 | + } | ||
3230 | + } | ||
3231 | + | ||
3232 | + }; | ||
3233 | + }); | ||
3194 | 3234 | ||
3195 | if(act_details && act_details.buy_limit>0 && flag){ | 3235 | if(act_details && act_details.buy_limit>0 && flag){ |
3196 | await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | 3236 | await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { |