Commit 0eefb76e7d6641796d61c3a5e5586bb0c5c0dd94
1 parent
6622bf17
超出优惠促销商品限购的优化
Showing
2 changed files
with
60 additions
and
95 deletions
packageE/pages/cart/cart2/cart2.js
... | ... | @@ -4975,6 +4975,7 @@ Page({ |
4975 | 4975 | //--赠品的时候,阶梯促销会右重复的情况,还有组合购的时候拆分出去的 -- |
4976 | 4976 | if (check_map[txt] && goods.prom_type != 10) { |
4977 | 4977 | getApp().confirmBox(goods.goods_name + "计算金额错误,请重新刷新"); |
4978 | + th.setData({ submit: 0 }) | |
4978 | 4979 | return false; |
4979 | 4980 | } else { |
4980 | 4981 | check_map[txt] = 1; |
... | ... | @@ -4990,36 +4991,47 @@ Page({ |
4990 | 4991 | if(mo_num>goods.goods_num){ |
4991 | 4992 | getApp().confirmBox(goods.goods_name + "的未达到起订数量"); |
4992 | 4993 | th.data.is_summit_ing = 0; |
4994 | + th.setData({ submit: 0 }) | |
4993 | 4995 | return false; |
4994 | 4996 | } |
4995 | 4997 | if(steep>1 && (goods.goods_num-mo_num)%steep!=0 ){ |
4996 | 4998 | getApp().confirmBox(goods.goods_name + "的购买的数量不是起订量的倍数"); |
4997 | 4999 | th.data.is_summit_ing = 0; |
5000 | + th.setData({ submit: 0 }) | |
4998 | 5001 | return false; |
4999 | 5002 | } |
5000 | 5003 | |
5001 | 5004 | //-- 要判断一下优惠促销的商品的限购 -- |
5002 | 5005 | if(goods.prom_type==3){ |
5003 | - | |
5004 | - var pro_gd_limit_num=1; | |
5005 | - | |
5006 | - //-- 获取会员之前优惠促销商品买了多少件 -- | |
5007 | - var pro_by_num=0; | |
5008 | - var lrs= { | |
5009 | - store_id: os.stoid,user_id: getApp().globalData.user_id, | |
5010 | - goods_id: goods.goods_id, prom_type: 3, | |
5011 | - prom_id: goods.prom_id, isnew:1 | |
5012 | - }; | |
5013 | - var gd_limit_rs=await getApp().promiseGet('/api/weshop/ordergoods/getUserBuyGoodsNum',{data:lrs}); | |
5014 | - | |
5015 | - if(gd_limit_rs && gd_limit_rs.data.code==0){ | |
5016 | - pro_by_num=gd_limit_rs.data.data.promgoodsbuynum | |
5006 | + var pro_gd_limit_num=0; | |
5007 | + var p_limit_rs= await getApp().request.promisePost('/api/weshop/promgoods/getPromGoodsLimitNum',{ | |
5008 | + data:{ | |
5009 | + store_id:os.stoid,goods_id:goods.goods_id,prom_id:goods.prom_id,prom_type:3 | |
5010 | + } | |
5011 | + }) | |
5012 | + if(p_limit_rs && p_limit_rs.data.code==0){ | |
5013 | + pro_gd_limit_num=p_limit_rs.data.data | |
5017 | 5014 | } |
5015 | + //-- 如果有商品限购的时候 -- | |
5016 | + if(pro_gd_limit_num>0){ | |
5017 | + //-- 获取会员之前优惠促销商品买了多少件 -- | |
5018 | + var pro_by_num=0; | |
5019 | + var lrs= { | |
5020 | + store_id: os.stoid,user_id: getApp().globalData.user_id, | |
5021 | + goods_id: goods.goods_id, prom_type: 3, | |
5022 | + prom_id: goods.prom_id, isnew:1 | |
5023 | + }; | |
5024 | + var gd_limit_rs=await getApp().promiseGet('/api/weshop/ordergoods/getUserBuyGoodsNum',{data:lrs}); | |
5025 | + if(gd_limit_rs && gd_limit_rs.data.code==0){ | |
5026 | + pro_by_num=gd_limit_rs.data.data.promgoodsbuynum | |
5027 | + } | |
5018 | 5028 | |
5019 | - if(pro_gd_limit_num>0 && pro_gd_limit_num<pro_by_num+goods.goods_num){ | |
5029 | + if(pro_gd_limit_num>0 && pro_gd_limit_num<pro_by_num+goods.goods_num){ | |
5020 | 5030 | getApp().confirmBox(goods.goods_name + "超优惠促销限购,无法购买"); |
5021 | 5031 | th.data.is_summit_ing = 0; |
5032 | + th.setData({ submit: 0 }) | |
5022 | 5033 | return false; |
5034 | + } | |
5023 | 5035 | } |
5024 | 5036 | } |
5025 | 5037 | |
... | ... | @@ -5034,6 +5046,7 @@ Page({ |
5034 | 5046 | if (!isok) { |
5035 | 5047 | getApp().confirmBox(goods.goods_name + "的门店库存不足"); |
5036 | 5048 | th.data.is_summit_ing = 0; |
5049 | + th.setData({ submit: 0 }) | |
5037 | 5050 | return false; |
5038 | 5051 | } |
5039 | 5052 | } | ... | ... |
pages/goods/goodsInfo/goodsInfo.js
... | ... | @@ -7781,88 +7781,40 @@ Page({ |
7781 | 7781 | if(th.data.user_pre_buynum >= fir_act.limit_num){ |
7782 | 7782 | is_yh_out_limit=1; |
7783 | 7783 | } |
7784 | - | |
7785 | 7784 | } |
7786 | - // var more_arr = []; | |
7787 | - // //减价 | |
7788 | - // if (fir_act.money > 0){ | |
7789 | - // | |
7790 | - // more_arr.push({ | |
7791 | - // text:'减价' + fir_act.money + '元', | |
7792 | - // is_fir:1 | |
7793 | - // }); | |
7794 | - // } | |
7795 | - // if (fir_act.sale > 0) { | |
7796 | - // more_arr.push({ | |
7797 | - // text:'打' + fir_act.sale + '折', | |
7798 | - // is_fir:1 | |
7799 | - // }); | |
7800 | - // } | |
7801 | - // if (fir_act.past == 1) { | |
7802 | - // more_arr.push({ | |
7803 | - // text:'包邮', | |
7804 | - // is_fir:1 | |
7805 | - // }); | |
7806 | - // } | |
7807 | - // if (fir_act.intValue > 0){ | |
7808 | - // more_arr.push({ | |
7809 | - // text:'送' + fir_act.intValue + '积分', | |
7810 | - // is_fir:1 | |
7811 | - // }); | |
7812 | - // } | |
7813 | - // if (fir_act.couponId > 0) { | |
7814 | - // more_arr.push({ | |
7815 | - // text:'送' + fir_act.couponMoney + '元优惠券', | |
7816 | - // is_quan:1 | |
7817 | - // }); | |
7818 | - // } | |
7819 | - // | |
7820 | - // if (fir_act.gift_id) { | |
7821 | - // var is_more_gf = fir_act.gift_id.split(',') | |
7822 | - // if (is_more_gf.length > 1) { | |
7823 | - // more_arr.push({ | |
7824 | - // text:'送赠品', | |
7825 | - // is_gift:1, | |
7826 | - // prom_id:fir_act.prom_id | |
7827 | - // }); | |
7828 | - // } else { | |
7829 | - // more_arr.push({ | |
7830 | - // text:'送' + fir_act.goods_name + ' x' + fir_act.zp_num, | |
7831 | - // is_gift:1, | |
7832 | - // prom_id:fir_act.prom_id | |
7833 | - // }); | |
7834 | - // } | |
7835 | - // } | |
7836 | - // if (fir_act.lb_id){ | |
7837 | - // more_arr.push({ | |
7838 | - // text:'送' + fir_act.lbtitle, | |
7839 | - // lb_id:fir_act.lb_id | |
7840 | - // }); | |
7841 | - // } | |
7842 | - // if (fir_act.zxlb_id){ | |
7843 | - // more_arr.push({ | |
7844 | - // text:'送' + fir_act.zxlbtitle, | |
7845 | - // zxlb_id:fir_act.zxlb_id | |
7846 | - // }); | |
7847 | - // } | |
7848 | - // if (fir_act.monthgiftbag_id){ | |
7849 | - // more_arr.push({ | |
7850 | - // text:'送' + fir_act.monthgiftbag_title, | |
7851 | - // monthgiftbag_id:fir_act.monthgiftbag_id | |
7852 | - // }); | |
7853 | - // } | |
7854 | - var more_arr=ut.format_yh_act(fir_act); | |
7855 | - //-- 开始组装数据 -- | |
7856 | - th.add_cx_prom_group({ | |
7857 | - id: fir_act.prom_id, | |
7858 | - condition: fir_act.condition + (fir_act.prom_type == 1 ? '件' : '元'), | |
7859 | - limit: '每人' + (fir_act.limit_num ? '限参与' + fir_act.limit_num + '次' : '参与不限次'), | |
7860 | - more: more_arr, | |
7785 | + | |
7786 | + //如果是有限购的时候 | |
7787 | + if (fir_act.gd_limit_num>0 && !is_yh_out_limit){ | |
7788 | + var lrs= { | |
7789 | + store_id: os.stoid, | |
7790 | + user_id: user_id, | |
7791 | + goods_id: gid, | |
7861 | 7792 | prom_type: 3, |
7862 | - promGoodsListsDtos:r_data.promGoodsLists, | |
7863 | - is_yh_out_limit:is_yh_out_limit | |
7864 | - }); | |
7865 | - //} | |
7793 | + prom_id: fir_act.prom_id, isnew:1 | |
7794 | + }; | |
7795 | + var gd_limit_rs=await getApp().promiseGet('/api/weshop/ordergoods/getUserBuyGoodsNum',{data:lrs}); | |
7796 | + var pro_by_num=0; | |
7797 | + if(gd_limit_rs && gd_limit_rs.data.code==0){ | |
7798 | + pro_by_num=gd_limit_rs.data.data.promgoodsbuynum | |
7799 | + } | |
7800 | + if(pro_by_num >= fir_act.gd_limit_num){ | |
7801 | + is_yh_out_limit=1; | |
7802 | + } | |
7803 | + } | |
7804 | + //-- 如果超出限购,就不显示了 -- | |
7805 | + if(!is_yh_out_limit) { | |
7806 | + var more_arr = ut.format_yh_act(fir_act); | |
7807 | + //-- 开始组装数据 -- | |
7808 | + th.add_cx_prom_group({ | |
7809 | + id: fir_act.prom_id, | |
7810 | + condition: fir_act.condition + (fir_act.prom_type == 1 ? '件' : '元'), | |
7811 | + limit: '每人' + (fir_act.limit_num ? '限参与' + fir_act.limit_num + '次' : '参与不限次'), | |
7812 | + more: more_arr, | |
7813 | + prom_type: 3, | |
7814 | + promGoodsListsDtos: r_data.promGoodsLists, | |
7815 | + is_yh_out_limit: is_yh_out_limit | |
7816 | + }); | |
7817 | + } | |
7866 | 7818 | |
7867 | 7819 | } |
7868 | 7820 | ... | ... |