Commit 05a97df055771583326a64d1cc444e79f4d7a116

Authored by 泉州测试
1 parent 2c9b18a8

fix库存优化

packageA/pages/goodsInfo/goodsInfo.js
@@ -865,23 +865,21 @@ Page({ @@ -865,23 +865,21 @@ Page({
865 865
866 // if(!this.data.openSpecModal_ind) { 866 // if(!this.data.openSpecModal_ind) {
867 if(this.data.prom_type == 1) { 867 if(this.data.prom_type == 1) {
  868 +
868 this.data.sele_g.viplimited = this.data.sele_g.buy_limit; 869 this.data.sele_g.viplimited = this.data.sele_g.buy_limit;
869 870
870 - if(!this.data.is_normal) { 871 + // 检查redis库存量
  872 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
  873 + if (res.data.code == 0) {
  874 + redisNum = res.data.data;
  875 + };
  876 + });
  877 +
  878 + if(redisNum > 0 && !this.data.is_normal) {
871 // 输入的数量 879 // 输入的数量
872 var t = th.data.goodsInputNum; 880 var t = th.data.goodsInputNum;
873 881
874 - // 检查redis库存量  
875 - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +  
876 - os.stoid + "/1/" + prom_id,  
877 - {}  
878 - ).then(res => {  
879 - if (res.data.code == 0) {  
880 - redisNum = res.data.data;  
881 - };  
882 - });  
883 -  
884 - if (redisNum > 0 && t > redisNum) { 882 + if (t > redisNum) {
885 wx.showModal({ 883 wx.showModal({
886 title: '超出活动库存', 884 title: '超出活动库存',
887 }); 885 });
@@ -901,7 +899,7 @@ Page({ @@ -901,7 +899,7 @@ Page({
901 }); 899 });
902 900
903 // 跳过<立即购买> 购物车 901 // 跳过<立即购买> 购物车
904 - if(action !="buy"){ 902 + if (action !="buy") {
905 903
906 // 输入的数量 + 购物车同款商品的数量 904 // 输入的数量 + 购物车同款商品的数量
907 var maxNum = parseInt(t) + parseInt(cartGoodsNum); 905 var maxNum = parseInt(t) + parseInt(cartGoodsNum);
@@ -918,41 +916,47 @@ Page({ @@ -918,41 +916,47 @@ Page({
918 916
919 } 917 }
920 918
921 - if (redisNum > 0 && maxNum > redisNum) { 919 + if (maxNum > redisNum) {
922 wx.showModal({ 920 wx.showModal({
923 title: '超出活动库存', 921 title: '超出活动库存',
924 }); 922 });
925 return false; 923 return false;
926 } 924 }
927 925
928 - } 926 + } else {
  927 + // 以下为立即购买
  928 + // 每人限购数
  929 + th.data.sele_g.viplimited = th.data.sele_g.buy_limit;
  930 + // 已经付款的单数
  931 + var gd_buy_num = th.data.sele_g.buy_num;
929 932
930 - // 以下为立即购买  
931 - // 每人限购数  
932 - th.data.sele_g.viplimited = th.data.sele_g.buy_limit; 933 + // 是否超出活动库存
  934 + if (t + gd_buy_num > redisNum) {
  935 + wx.showModal({
  936 + title: '超出活动库存',
  937 + });
  938 + return false;
  939 + }
933 940
934 - // 是否开启个人限购  
935 - if (th.data.sele_g.viplimited > 0) {  
936 - // 已经付款的单数  
937 - var gd_buy_num = th.data.sele_g.buy_num; 941 + // 是否开启个人限购
  942 + if (th.data.sele_g.viplimited > 0) {
938 943
939 - if (t + gd_buy_num > th.data.sele_g.viplimited) {  
940 - wx.showModal({  
941 - title: '超出活动限购数量',  
942 - });  
943 -  
944 - let num = th.data.sele_g.viplimited - gd_buy_num;  
945 - if (num <= 0) num = 1;  
946 - th.setData({goodsInputNum: num});  
947 - return false; 944 + if (t + gd_buy_num > th.data.sele_g.viplimited) {
  945 + wx.showModal({
  946 + title: '超出活动限购数量',
  947 + });
  948 +
  949 + let num = th.data.sele_g.viplimited - gd_buy_num;
  950 + if (num <= 0) num = 1;
  951 + th.setData({goodsInputNum: num});
  952 + return false;
  953 + }
  954 +
  955 +
  956 + };
948 } 957 }
949 -  
950 958
951 }; 959 };
952 -  
953 -  
954 -  
955 - };  
956 }; 960 };
957 961
958 962