Commit 8212b00070610d2c61067123b60cbe03f8c749cd
1 parent
fc79a0b7
1、优惠促销商品的限购的判断,优惠促销超出限购的时候,普通商品购买待支付的时候,bug优化(商品限购和活动限购)
2、优惠促销商品普通商品购买的时候。待支付的bug优化
Showing
3 changed files
with
121 additions
and
28 deletions
packageE/pages/cart/cart2/cart2.js
... | ... | @@ -5103,6 +5103,26 @@ Page({ |
5103 | 5103 | } |
5104 | 5104 | } |
5105 | 5105 | |
5106 | + //看一下有没有活动不参与的,要记录到order_more表中 | |
5107 | + let can_cx=t_item.show_can_cx; | |
5108 | + let is_user_no_yhcx=null; | |
5109 | + for(let iu in can_cx){ | |
5110 | + if(can_cx[iu].no_cj_prom){ | |
5111 | + | |
5112 | + if(!is_user_no_yhcx) is_user_no_yhcx=[]; | |
5113 | + is_user_no_yhcx.push({ | |
5114 | + prom_id:can_cx[iu].cur_act.prom_id, | |
5115 | + prom_type:can_cx[iu].cur_act.prom_type, | |
5116 | + }) | |
5117 | + break; | |
5118 | + } | |
5119 | + } | |
5120 | + //如果有活动不参与的,要记录到order_more表中 | |
5121 | + if(is_user_no_yhcx){ | |
5122 | + item.is_user_no_yhcx=JSON.stringify(is_user_no_yhcx); | |
5123 | + } | |
5124 | + | |
5125 | + | |
5106 | 5126 | //代发商品的集合 |
5107 | 5127 | var df_goods = []; |
5108 | 5128 | var df_price = 0; |
... | ... | @@ -5112,7 +5132,8 @@ Page({ |
5112 | 5132 | //此单的组合活动汇总 |
5113 | 5133 | var zh_map_count={}; |
5114 | 5134 | var check_map = {}; |
5115 | - let groupchat_ids=[] | |
5135 | + let groupchat_ids=[]; | |
5136 | + | |
5116 | 5137 | |
5117 | 5138 | //-------------让商品添加到商品列表-------------------- |
5118 | 5139 | for (var k = 0; k < t_item.goods.length; k++) { |
... | ... | @@ -5473,6 +5494,8 @@ Page({ |
5473 | 5494 | } |
5474 | 5495 | // debugger |
5475 | 5496 | var str = JSON.stringify(pdata); |
5497 | + | |
5498 | + | |
5476 | 5499 | |
5477 | 5500 | wx.showLoading({ title: "加载中" }); |
5478 | 5501 | th.setData({ submit: 1, }) | ... | ... |
pages/user/order_detail/order_detail.js
... | ... | @@ -178,6 +178,7 @@ Page({ |
178 | 178 | r.use_commission=res.data.data.use_commission; |
179 | 179 | r.pre_cut=res.data.data.pre_cut; //预存款 |
180 | 180 | r.pre_json=res.data.data.pre_json; //预存款 |
181 | + r.is_user_no_yhcx = res.data.data.is_user_no_yhcx; //判断订单是不是优惠促销不参与 | |
181 | 182 | } |
182 | 183 | }) |
183 | 184 | |
... | ... | @@ -911,6 +912,7 @@ Page({ |
911 | 912 | }) |
912 | 913 | |
913 | 914 | |
915 | + //商品的订单列表的活动类型,和gg参与的类型不一致 | |
914 | 916 | if(good.prom_type != gg.prom_type && good.prom_id != gg.prom_id){ |
915 | 917 | //如果商品有单独的活动的是偶 |
916 | 918 | switch (gg.prom_type){ |
... | ... | @@ -923,17 +925,31 @@ Page({ |
923 | 925 | case 3: |
924 | 926 | var prom=null; |
925 | 927 | var yh_check=1; |
926 | - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => { | |
927 | - if (res.data.code == 0) { prom = res.data.data; } | |
928 | - }) | |
929 | - if (prom && prom.limit_num) { | |
930 | - var limit_num = prom.limit_num; | |
931 | - var user_pre_buynum = await this.getUserBuyPromNum_pre(prom.id) | |
932 | - if (limit_num>0 && user_pre_buynum >= limit_num) { | |
928 | + | |
929 | + | |
930 | + //如果有优惠促销的普通购买的时候 | |
931 | + if(order.is_user_no_yhcx && good.prom_type==0 && order.is_user_no_yhcx!='0' && order.is_user_no_yhcx!='null' ){ | |
932 | + let obj=JSON.parse(order.is_user_no_yhcx); | |
933 | + //obj数组使用find函数快速查找 | |
934 | + if(obj.find((item)=>{return item.prom_id==gg.prom_id && item.prom_type==3})){ | |
933 | 935 | yh_check=0; |
934 | 936 | } |
935 | 937 | } |
936 | 938 | |
939 | + //判断优惠促销活动的限购 | |
940 | + if(yh_check){ | |
941 | + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => { | |
942 | + if (res.data.code == 0) { prom = res.data.data; } | |
943 | + }) | |
944 | + if (prom && prom.limit_num) { | |
945 | + var limit_num = prom.limit_num; | |
946 | + var user_pre_buynum = await this.getUserBuyPromNum_pre(prom.id) | |
947 | + if (limit_num>0 && user_pre_buynum >= limit_num) { | |
948 | + yh_check=0; | |
949 | + } | |
950 | + } | |
951 | + } | |
952 | + | |
937 | 953 | //--- 要判断一下优惠促销的商品的限购 --- |
938 | 954 | if(yh_check){ |
939 | 955 | var pro_gd_limit_num=0; |
... | ... | @@ -957,7 +973,7 @@ Page({ |
957 | 973 | if(gd_limit_rs && gd_limit_rs.data.code==0){ |
958 | 974 | pro_by_num=gd_limit_rs.data.data.promgoodsbuynum |
959 | 975 | } |
960 | - if(pro_gd_limit_num<=pro_by_num){ | |
976 | + if(pro_gd_limit_num<pro_by_num+good.goods_num){ | |
961 | 977 | yh_check=0; |
962 | 978 | } |
963 | 979 | } |
... | ... | @@ -966,6 +982,9 @@ Page({ |
966 | 982 | //-- 优惠促销活动没有超出限购的话 -- |
967 | 983 | if(yh_check){ |
968 | 984 | if(!the_yh_map[gg.prom_id]) the_yh_map[gg.prom_id]=[]; |
985 | + if(prom) good.discount_field=prom.discount_field; | |
986 | + good.r_shop_price=gg.shop_price; | |
987 | + good.r_market_price=gg.market_price; | |
969 | 988 | the_yh_map[gg.prom_id].push(good); |
970 | 989 | } |
971 | 990 | |
... | ... | @@ -1020,7 +1039,6 @@ Page({ |
1020 | 1039 | } |
1021 | 1040 | } |
1022 | 1041 | |
1023 | - | |
1024 | 1042 | //如果有普通商品要判断能不到达到优惠促销的条件 |
1025 | 1043 | if(Object.keys(the_yh_map).length){ |
1026 | 1044 | for (let rkey in the_yh_map) { |
... | ... | @@ -1028,7 +1046,17 @@ Page({ |
1028 | 1046 | var all_num=0; |
1029 | 1047 | |
1030 | 1048 | for(var ij=0;ij<the_yh_map[rkey].length;ij++){ |
1031 | - all_price+=the_yh_map[rkey][ij].goods_price * the_yh_map[rkey][ij].goods_num; | |
1049 | + var t_price=the_yh_map[rkey][ij].goods_price; | |
1050 | + switch (the_yh_map[rkey][ij].discount_field){ | |
1051 | + case 1: | |
1052 | + t_price=the_yh_map[rkey][ij].r_shop_price; | |
1053 | + break; | |
1054 | + case 2: | |
1055 | + t_price=the_yh_map[rkey][ij].r_market_price; | |
1056 | + break; | |
1057 | + } | |
1058 | + | |
1059 | + all_price+=t_price * the_yh_map[rkey][ij].goods_num; | |
1032 | 1060 | all_num+= the_yh_map[rkey][ij].goods_num; |
1033 | 1061 | } |
1034 | 1062 | |
... | ... | @@ -1051,8 +1079,6 @@ Page({ |
1051 | 1079 | } |
1052 | 1080 | |
1053 | 1081 | } |
1054 | - | |
1055 | - | |
1056 | 1082 | //-- 判断活动是不是OK -- |
1057 | 1083 | if (!t_ok) { |
1058 | 1084 | th.setData({ paying: 0 }); return false; |
... | ... | @@ -2366,8 +2392,24 @@ Page({ |
2366 | 2392 | //-- 查看物流 -- |
2367 | 2393 | go_wuliu:function (e) { |
2368 | 2394 | getApp().go_wuliu(e); |
2369 | - } | |
2395 | + }, | |
2370 | 2396 | |
2397 | + //优惠促销用户参与次数,is_buy=1,表示只获取支付了的 | |
2398 | + async getUserBuyPromNum_pre(prom_id,is_buy) { | |
2399 | + var userInfo = getApp().globalData.userInfo; | |
2400 | + var url = `/api/weshop/ordergoods/getUserBuyPromNum?is_all=1&store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=3&prom_id=${prom_id}`; | |
2401 | + if(is_buy){ | |
2402 | + url = `/api/weshop/ordergoods/getUserBuyPromNum?store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=3&prom_id=${prom_id}`; | |
2403 | + } | |
2404 | + let res = await getApp().request.promiseGet(url, { | |
2405 | + data: {} | |
2406 | + }); | |
2407 | + let user_pre_buynum = 0 | |
2408 | + if (res.data.code == 0 && res.data.data) { | |
2409 | + user_pre_buynum = res.data.data.userbuynum | |
2410 | + } | |
2411 | + return user_pre_buynum | |
2412 | + } | |
2371 | 2413 | |
2372 | 2414 | |
2373 | 2415 | ... | ... |
pages/user/order_list/order_list.js
... | ... | @@ -412,6 +412,7 @@ Page({ |
412 | 412 | data[ind].use_commission = res.data.data.use_commission; |
413 | 413 | data[ind].pre_cut = res.data.data.pre_cut; //是否使用预存,如果是使用预存不能单品退,只能整单退 |
414 | 414 | data[ind].pre_json = res.data.data.pre_json; //是否使用预存,如果是使用预存不能单品退,只能整单退 |
415 | + data[ind].is_user_no_yhcx = res.data.data.is_user_no_yhcx; //判断订单是不是优惠促销不参与 | |
415 | 416 | } |
416 | 417 | }) |
417 | 418 | |
... | ... | @@ -1203,6 +1204,7 @@ Page({ |
1203 | 1204 | }) |
1204 | 1205 | |
1205 | 1206 | |
1207 | + //商品的订单列表的活动类型,和gg参与的类型不一致 | |
1206 | 1208 | if(good.prom_type != gg.prom_type && good.prom_id != gg.prom_id){ |
1207 | 1209 | //如果商品有单独的活动的是偶 |
1208 | 1210 | switch (gg.prom_type){ |
... | ... | @@ -1215,16 +1217,30 @@ Page({ |
1215 | 1217 | case 3: |
1216 | 1218 | var prom=null; |
1217 | 1219 | var yh_check=1; |
1218 | - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => { | |
1219 | - if (res.data.code == 0) { prom = res.data.data; } | |
1220 | - }) | |
1221 | - if (prom && prom.limit_num) { | |
1222 | - var limit_num = prom.limit_num; | |
1223 | - var user_pre_buynum = await this.getUserBuyPromNum_pre(prom.id) | |
1224 | - if (limit_num>0 && user_pre_buynum >= limit_num) { | |
1225 | - yh_check=0; | |
1226 | - } | |
1227 | - } | |
1220 | + | |
1221 | + | |
1222 | + //如果有优惠促销的普通购买的时候 | |
1223 | + if(order.is_user_no_yhcx && good.prom_type==0 && order.is_user_no_yhcx!='0' && order.is_user_no_yhcx!='null' ){ | |
1224 | + let obj=JSON.parse(order.is_user_no_yhcx); | |
1225 | + //obj数组使用find函数快速查找 | |
1226 | + if(obj.find((item)=>{return item.prom_id==gg.prom_id && item.prom_type==3})){ | |
1227 | + yh_check=0; | |
1228 | + } | |
1229 | + } | |
1230 | + | |
1231 | + //判断优惠促销活动的限购 | |
1232 | + if(yh_check){ | |
1233 | + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => { | |
1234 | + if (res.data.code == 0) { prom = res.data.data; } | |
1235 | + }) | |
1236 | + if (prom && prom.limit_num) { | |
1237 | + var limit_num = prom.limit_num; | |
1238 | + var user_pre_buynum = await this.getUserBuyPromNum_pre(prom.id) | |
1239 | + if (limit_num>0 && user_pre_buynum >= limit_num) { | |
1240 | + yh_check=0; | |
1241 | + } | |
1242 | + } | |
1243 | + } | |
1228 | 1244 | |
1229 | 1245 | //--- 要判断一下优惠促销的商品的限购 --- |
1230 | 1246 | if(yh_check){ |
... | ... | @@ -1249,7 +1265,7 @@ Page({ |
1249 | 1265 | if(gd_limit_rs && gd_limit_rs.data.code==0){ |
1250 | 1266 | pro_by_num=gd_limit_rs.data.data.promgoodsbuynum |
1251 | 1267 | } |
1252 | - if(pro_gd_limit_num<=pro_by_num){ | |
1268 | + if(pro_gd_limit_num<pro_by_num+good.goods_num){ | |
1253 | 1269 | yh_check=0; |
1254 | 1270 | } |
1255 | 1271 | } |
... | ... | @@ -1258,11 +1274,12 @@ Page({ |
1258 | 1274 | //-- 优惠促销活动没有超出限购的话 -- |
1259 | 1275 | if(yh_check){ |
1260 | 1276 | if(!the_yh_map[gg.prom_id]) the_yh_map[gg.prom_id]=[]; |
1277 | + if(prom) good.discount_field=prom.discount_field; | |
1278 | + good.r_shop_price=gg.shop_price; | |
1279 | + good.r_market_price=gg.market_price; | |
1261 | 1280 | the_yh_map[gg.prom_id].push(good); |
1262 | 1281 | } |
1263 | 1282 | |
1264 | - good.discount_field=prom.discount_field; | |
1265 | - | |
1266 | 1283 | break |
1267 | 1284 | case 7: |
1268 | 1285 | //获取组合购活动 |
... | ... | @@ -1315,6 +1332,7 @@ Page({ |
1315 | 1332 | } |
1316 | 1333 | |
1317 | 1334 | |
1335 | + | |
1318 | 1336 | //如果有普通商品要判断能不到达到优惠促销的条件 |
1319 | 1337 | if(Object.keys(the_yh_map).length){ |
1320 | 1338 | for (let rkey in the_yh_map) { |
... | ... | @@ -1322,7 +1340,17 @@ Page({ |
1322 | 1340 | var all_num=0; |
1323 | 1341 | |
1324 | 1342 | for(var ij=0;ij<the_yh_map[rkey].length;ij++){ |
1325 | - all_price+=the_yh_map[rkey][ij].goods_price * the_yh_map[rkey][ij].goods_num; | |
1343 | + var t_price=the_yh_map[rkey][ij].goods_price; | |
1344 | + switch (the_yh_map[rkey][ij].discount_field){ | |
1345 | + case 1: | |
1346 | + t_price=the_yh_map[rkey][ij].r_shop_price; | |
1347 | + break; | |
1348 | + case 2: | |
1349 | + t_price=the_yh_map[rkey][ij].r_market_price; | |
1350 | + break; | |
1351 | + } | |
1352 | + | |
1353 | + all_price+=t_price * the_yh_map[rkey][ij].goods_num; | |
1326 | 1354 | all_num+= the_yh_map[rkey][ij].goods_num; |
1327 | 1355 | } |
1328 | 1356 | ... | ... |