Commit d01195f1adcf32f0fe591187f4591685bf16802f

Authored by yvan.ni
1 parent 4376a930

虚拟商品的优化

... ... @@ -1308,7 +1308,6 @@ App({
1308 1308 var stoid=this.globalData.setting.stoid;
1309 1309 var user_id=this.globalData.user_id;
1310 1310  
1311   -
1312 1311 this.getConfig2(async function (e){
1313 1312 if(e && e.switch_list) conf=JSON.parse(e.switch_list);
1314 1313 if(conf && conf.express_searchtype==1){
... ... @@ -1319,6 +1318,43 @@ App({
1319 1318 th.goto(url);
1320 1319  
1321 1320 })
  1321 + },
  1322 +
  1323 + //---- 判断是不是虚拟商品狗阿米 -----
  1324 + is_virtual(gd){
  1325 + if(gd.is_virtual==2) return true;
  1326 + return false;
  1327 + },
  1328 +
  1329 + /**
  1330 + *
  1331 + * @param gd 商品
  1332 + * @param act 活动
  1333 + * @param get_type 0默认 1是加和减的时候
  1334 + */
  1335 + get_limit_qty(gd,act,get_type){
  1336 + var islimit=gd.erp_islimit; //是不是限购
  1337 + var limittype=gd.erp_limittype; //不低于0、倍数1
  1338 + var limitqty=gd.erp_limitqty; //起购量
  1339 +
  1340 + //-- 如果有活动的时候 --
  1341 + if(act){
  1342 + islimit=act.islimit;
  1343 + limittype=act.limittype;
  1344 + limitqty=act.limitqty;
  1345 + }
  1346 +
  1347 + //-- 不是限购的时候,返回1--
  1348 + if(!islimit) return 1;
  1349 + //-- 默认的时候 --
  1350 + if(!get_type) return limitqty;
  1351 + //不低于的时候,加减的时候
  1352 + if(!limittype) return 1;
  1353 + //倍数,加减的时候
  1354 + return limitqty;
1322 1355 }
1323 1356  
  1357 +
  1358 +
  1359 +
1324 1360 });
... ...
packageA/pages/goodsInfo/goodsInfo.js
... ... @@ -3894,507 +3894,7 @@ Page({
3894 3894 });
3895 3895 },
3896 3896  
3897   -
3898   -
3899   -
3900   -
3901   -
3902   -
3903   - //-- 加入购物的函数 --
3904   - add_cart_func: function (t) {
3905   - var i = getApp().request;
3906   - if (oo.user_id == null) {
3907   - return s.my_warnning("还未登录!", 0, this);
3908   - }
3909   -
3910   - if (!getApp().globalData.userInfo) {
3911   - return s.my_warnning("还未登录!", 0, this);
3912   - }
3913   -
3914   - var e = this,
3915   - th = e,
3916   - a = 0,
3917   - o = this.data.sele_g;
3918   - a = o.goods_id;
3919   -
3920   - //----------添加到购物车时,要判断限购数量,--------
3921   - e.get_buy_num(o, function (ee) {
3922   - //---判断商品是否超出限购---
3923   - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
3924   - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) {
3925   - // wx.showModal({
3926   - // title: '提示',
3927   - // content: '超出活动限购数量'
3928   - // });
3929   - getApp().my_warnning('超出活动限购数量', 0, self);
3930   - return false;
3931   - }
3932   - }
3933   - //---判断商品是否超出活动限购---
3934   - if ((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) {
3935   - if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) {
3936   - // wx.showModal({
3937   - // title: '提示',
3938   - // content: '超出活动限购数量'
3939   - // });
3940   - getApp().my_warnning('超出活动限购数量', 0, self);
3941   - return false;
3942   - }
3943   - }
3944   -
3945   - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th);
3946   - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined)
3947   - th.setData({
3948   - sto_sele_name: ""
3949   - });
3950   - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th);
3951   -
3952   - //--------------此时操作的数据------------
3953   - var newd = {
3954   - goods_id: o.goods_id,
3955   - goods_num: th.data.goodsInputNum,
3956   - pick_id: th.data.sto_sele_id,
3957   - user_id: oo.user_id,
3958   - store_id: th.data.stoid,
3959   - goods_price: o.shop_price,
3960   - member_goods_price: o.shop_price,
3961   - goods_name: o.goods_name,
3962   - goods_sn: o.goods_sn,
3963   - sku: o.sku,
3964   - prom_id: th.data.sele_g.prom_id,
3965   - prom_type: th.data.sele_g.prom_type,
3966   - };
3967   -
3968   - //---是不是从收藏夹出来的---
3969   - if (th.data.c_guide_id) {
3970   - newd['guide_id'] = th.data.c_guide_id;
3971   - newd['guide_type'] = 2;
3972   - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3;
3973   - } else {
3974   - if (getApp().globalData.guide_id) {
3975   - newd['guide_id'] = getApp().globalData.guide_id;
3976   - newd['guide_type'] = 0;
3977   - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1;
3978   - }
3979   - }
3980   - if(getApp().globalData.groupchat_id){
3981   - newd['groupchat_id'] = getApp().globalData.groupchat_id;
3982   - }
3983   - //让商品带上房间号
3984   - //让商品带上房间号
3985   - if (th.data.sys_switch.is_skuroom_id == 1) {
3986   - if (th.data.data.goods_id == getApp().globalData.room_goods_id) {
3987   - newd.room_id = getApp().globalData.room_id;
3988   - }
3989   - } else {
3990   - if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id;
3991   - }
3992   -
3993   - //如果是积分够,is_integral_normal就要有积分购普通购买字段
3994   - if (o.prom_type == 4) {
3995   - newd.is_integral_normal = 1;
3996   - }
3997   -
3998   - //如果有线下取价
3999   - if (o.offline_price) {
4000   - newd.offline_price = o.offline_price;
4001   - newd.pricing_type = o.pricing_type;
4002   - }
4003   -
4004   - //-----如果是秒杀,团购,积分购,拼团-----
4005   - if (th.data.prom_type == 1 || th.data.prom_type == 2) {
4006   -
4007   - if (th.data.openSpecModal_flash_normal) {
4008   -
4009   - newd.prom_type = 0;
4010   - newd.prom_id = 0;
4011   -
4012   - //---如果是线下门店销售的时候---
4013   - if (th.data.sales_rules == 2) {
4014   - var pick = th.get_pick_from_list(th.data.sto_sele_id)
4015   - //---通过接口获取门店的线下库存信息--
4016   - getApp().request.get("/api/weshop/goods/getWareStorages", {
4017   - data: {
4018   - storageNos: pick.pickup_no,
4019   - wareIds: encodeURIComponent(th.data.sele_g.erpwareid),
4020   - storeId: os.stoid
4021   - },
4022   - success: function (res) {
4023   - if (res.data.code == 0) {
4024   - if (res.data.data.pageData.length > 0) {
4025   - var CanOutQty = res.data.data.pageData[0].CanOutQty;
4026   - if (CanOutQty < e.data.goodsInputNum) {
4027   - return s.my_warnning("库存不足!", 0, th);
4028   - }
4029   - //在调一次接口,读取商品的预出库的数量,lock
4030   - getApp().request.get("/api/weshop/order/ware/lock/page", {
4031   - data: {
4032   - store_id: os.stoid,
4033   - wareId: th.data.sele_g.goods_id,
4034   - storageId: pick.pickup_id,
4035   - pageSize: 1000
4036   - },
4037   - success: function (res_data) {
4038   - if (res_data.data.code == 0 && res_data.data.data.total > 0) {
4039   -
4040   - var lock = 0;
4041   - for (var i in res_data.data.data.pageData) {
4042   - lock += res_data.data.data.pageData[i].outQty;
4043   - }
4044   -
4045   - if (CanOutQty <= lock) {
4046   - return s.my_warnning("库存不足!", 0, th);
4047   - }
4048   - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock);
4049   - } else {
4050   - th.add_cart_next(e, t, a, o, newd, CanOutQty);
4051   - }
4052   - }
4053   - })
4054   - } else {
4055   - return s.my_warnning("库存不足!", 0, th);
4056   - }
4057   -
4058   - }
4059   - }
4060   - })
4061   - } else {
4062   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
4063   - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
4064   - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
4065   - }
4066   -
4067   - return false;
4068   - }
4069   -
4070   -
4071   - newd.goods_price = th.data.prom_price;
4072   - newd.member_goods_price = th.data.prom_price,
4073   - newd.prom_type = th.data.prom_type;
4074   - newd.prom_id = th.data.prom_id;
4075   -
4076   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
4077   - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
4078   -
4079   - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
4080   -
4081   - } else if (o.prom_type == 7) {
4082   -
4083   - //判断进行中的活动,是不是要判断线下库存
4084   - th.check_zh_acting(function (ee) {
4085   - newd.prom_id = 0;
4086   - newd.prom_type = 0;
4087   - if (ee && th.data.sele_g.act) {
4088   - newd.prom_id = th.data.sele_g.act.id;
4089   - newd.prom_type = 7;
4090   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
4091   - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
4092   - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
4093   - return false;
4094   - } else {
4095   - //---如果是线下门店销售的时候---
4096   - if (th.data.sales_rules == 2) {
4097   - var pick = th.get_pick_from_list(th.data.sto_sele_id)
4098   - //---通过接口获取门店的线下库存信息--
4099   - getApp().request.get("/api/weshop/goods/getWareStorages", {
4100   - data: {
4101   - storageNos: pick.pickup_no,
4102   - wareIds: encodeURIComponent(th.data.sele_g.erpwareid),
4103   - storeId: os.stoid
4104   - },
4105   - success: function (res) {
4106   - if (res.data.code == 0) {
4107   - if (res.data.data.pageData.length > 0) {
4108   - var CanOutQty = res.data.data.pageData[0].CanOutQty;
4109   - if (CanOutQty < e.data.goodsInputNum) {
4110   - return s.my_warnning("库存不足!", 0, th);
4111   - }
4112   - //在调一次接口,读取商品的预出库的数量,lock
4113   - getApp().request.get("/api/weshop/order/ware/lock/page", {
4114   - data: {
4115   - store_id: os.stoid,
4116   - wareId: th.data.sele_g.goods_id,
4117   - storageId: pick.pickup_id,
4118   - pageSize: 1000
4119   - },
4120   - success: function (res_data) {
4121   - if (res_data.data.code == 0 && res_data.data.data.total > 0) {
4122   -
4123   - var lock = 0;
4124   - for (var i in res_data.data.data.pageData) {
4125   - lock += res_data.data.data.pageData[i].outQty;
4126   - }
4127   -
4128   - if (CanOutQty <= lock) {
4129   - return s.my_warnning("库存不足!", 0, th);
4130   - }
4131   - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock);
4132   - } else {
4133   - th.add_cart_next(e, t, a, o, newd, CanOutQty);
4134   - }
4135   - }
4136   - })
4137   - } else {
4138   - return s.my_warnning("库存不足!", 0, th);
4139   - }
4140   -
4141   - }
4142   - }
4143   - })
4144   - } else {
4145   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
4146   - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
4147   - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
4148   - }
4149   - }
4150   - })
4151   -
4152   - }
4153   - else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type == 10) {
4154   - newd.prom_type = 0;
4155   - newd.prom_id = 0;
4156   -
4157   - if (th.data.prom_type == 10) {
4158   - newd.prom_type = th.data.prom_type;
4159   - newd.prom_id = th.data.prom_id;
4160   - }
4161   -
4162   - //---如果是线下门店销售的时候---
4163   - if (th.data.sales_rules == 2) {
4164   - var pick = th.get_pick_from_list(th.data.sto_sele_id)
4165   - //---通过接口获取门店的线下库存信息--
4166   - getApp().request.get("/api/weshop/goods/getWareStorages", {
4167   - data: {
4168   - storageNos: pick.pickup_no,
4169   - wareIds: encodeURIComponent(th.data.sele_g.erpwareid),
4170   - storeId: os.stoid
4171   - },
4172   - success: function (res) {
4173   - if (res.data.code == 0) {
4174   - if (res.data.data.pageData.length > 0) {
4175   - var CanOutQty = res.data.data.pageData[0].CanOutQty;
4176   - if (CanOutQty < e.data.goodsInputNum) {
4177   - return s.my_warnning("库存不足!", 0, th);
4178   - }
4179   - //在调一次接口,读取商品的预出库的数量,lock
4180   - getApp().request.get("/api/weshop/order/ware/lock/page", {
4181   - data: {
4182   - store_id: os.stoid,
4183   - wareId: th.data.sele_g.goods_id,
4184   - storageId: pick.pickup_id,
4185   - pageSize: 1000
4186   - },
4187   - success: function (res_data) {
4188   - if (res_data.data.code == 0 && res_data.data.data.total > 0) {
4189   -
4190   - var lock = 0;
4191   - for (var i in res_data.data.data.pageData) {
4192   - lock += res_data.data.data.pageData[i].outQty;
4193   - }
4194   -
4195   - if (CanOutQty <= lock) {
4196   - return s.my_warnning("库存不足!", 0, th);
4197   - }
4198   - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock);
4199   - } else {
4200   - th.add_cart_next(e, t, a, o, newd, CanOutQty);
4201   - }
4202   - }
4203   - })
4204   - } else {
4205   - return s.my_warnning("库存不足!", 0, th);
4206   - }
4207   -
4208   - }
4209   - }
4210   - })
4211   - } else {
4212   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
4213   - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
4214   - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
4215   - }
4216   - }
4217   - })
4218   - },
4219   -
4220   - //---加入购物车的最后一步---
4221   - add_cart_next(e, t, a, o, newd, CanOutQty) {
4222   - var th = this, i = getApp().request;
4223   - //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------
4224   - if ((o.prom_type != 1 || o.prom_id <= 0) && ((o.prom_type != 6 && o.prom_type != 4 && o.prom_type != 2 ) || th.data.is_normal)) {
4225   - var conf = th.data.bconfig;
4226   - if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) {
4227   - var s_list = JSON.parse(conf.switch_list);
4228   - var now = ut.gettimestamp();
4229   -
4230   -
4231   - var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/');
4232   - var end = new Date(str);
4233   - end = Date.parse(end) / 1000;
4234   -
4235   - //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下--
4236   - if (parseInt(s_list.rank_switch) == 2 && end > now) {
4237   - var card_price = o[getApp().globalData.userInfo['card_field']];
4238   - //如果会员有等级价
4239   - if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null
4240   - && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) {
4241   - newd.goods_price = card_price;
4242   - newd.member_goods_price = card_price;
4243   - }
4244   - }
4245   - }
4246   - }
4247   -
4248   - //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d);
4249   - if ("add" == t.currentTarget.dataset.action) {
4250   -
4251   - if (th.data.prom_goods) {
4252   - newd.prom_type = 3;
4253   - newd.prom_id = th.data.prom_goods[0].prom_id;
4254   - }
4255   -
4256   - //----先看会员在购物车中是否加入了该商品-----
4257   - i.get("/api/weshop/cart/page", {
4258   - data: {
4259   - store_id: e.data.stoid,
4260   - user_id: oo.user_id,
4261   - goods_id: a,
4262   - pick_id: e.data.sto_sele_id,
4263   - prom_type:(newd.prom_type?newd.prom_type:0),
4264   - state: 0
4265   - },
4266   - success: function (re) {
4267   -
4268   - //-------如果购物车中有相关的数据---------
4269   - if (re.data.data.total > 0) {
4270   -
4271   - var item = re.data.data.pageData[0];
4272   -
4273   - //判断数量,要看下购物车中有没有该商品
4274   - if (CanOutQty) {
4275   - if (item.goods_num + th.data.goodsInputNum > CanOutQty) {
4276   - return s.my_warnning("库存不足!", 0, th);
4277   - }
4278   - } else {
4279   - if (item.goods_num + th.data.goodsInputNum > o.store_count) {
4280   - return s.my_warnning("库存不足!", 0, th);
4281   - }
4282   - }
4283   -
4284   - var updata = {
4285   - id: item.id,
4286   - goods_num: e.data.goodsInputNum + item.goods_num,
4287   - goods_price: newd.goods_price,
4288   - member_goods_price: newd.goods_price,
4289   - store_id: th.data.stoid,
4290   - };
4291   -
4292   - //---是不是从收藏夹出来的---
4293   - if (th.data.c_guide_id) {
4294   - updata['guide_id'] = th.data.c_guide_id;
4295   - updata['guide_type'] = 3; //加入购物车之后就变成了3
4296   - } else {
4297   - if (getApp().globalData.guide_id) {
4298   - updata['guide_id'] = getApp().globalData.guide_id;
4299   - updata['guide_type'] = 0;
4300   - }
4301   - }
4302   - if(getApp().globalData.groupchat_id){
4303   - updata['groupchat_id'] = getApp().globalData.groupchat_id;
4304   - }
4305   - i.put("/api/weshop/cart/update", {
4306   - data: updata,
4307   - success: function (t) {
4308   - getApp().my_warnning('加入购物车成功', 1, th, 450);
4309   - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
4310   - th.setData({
4311   - cartGoodsNum: c_num
4312   - });
4313   - th.closeSpecModal();
4314   - }
4315   - });
4316   - } else {
4317   -
4318   -
4319   - i.post("/api/weshop/cart/save", {
4320   - data: newd,
4321   - success: function (t) {
4322   - getApp().my_warnning('加入购物车成功', 1, th, 450);
4323   - var c_num = th.data.cartGoodsNum + e.data.goodsInputNum;
4324   - th.setData({
4325   - cartGoodsNum: c_num
4326   - });
4327   - th.closeSpecModal();
4328   - }
4329   - });
4330   - }
4331   - }
4332   - });
4333   -
4334   - }
4335   - else {
4336   -
4337   - //这一步主要是要让立即购买 走 购物车的逻辑 参与活动
4338   - if (newd.prom_type == 10 || newd.prom_type == 7) {
4339   - //----先看会员在购物车中是否加入了该商品,立即购买的-----
4340   - getApp().request.get("/api/weshop/cart/page", {
4341   - data: {
4342   - store_id: e.data.stoid,
4343   - user_id: oo.user_id,
4344   - state: 1
4345   - },
4346   - success: function (res) {
4347   - //-------如果购物车中有相关的数据---------
4348   - if (res.data.code == 0 && res.data.data.total > 0) {
4349   - for (let j in res.data.data.pageData) {
4350   - let item_j = res.data.data.pageData[j];
4351   - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id;
4352   - getApp().request.delete(url, {});
4353   - }
4354   - }
4355   - newd.state = 1;
4356   - getApp().request.post("/api/weshop/cart/save", {
4357   - data: newd,
4358   - success: function (t) {
4359   - th.closeSpecModal();
4360   - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1");
4361   - }
4362   - });
4363   - },
4364   - })
4365   - return false;
4366   - }
4367   -
4368   - if (th.data.prom_goods) {
4369   - var prom_d = th.data.prom_goods;
4370   - for (var i in prom_d) {
4371   - //判断活动有俩种条件,0元 1件
4372   - var condition_t = prom_d[i].prom_type;
4373   - switch (condition_t) {
4374   - case 0: //按钱
4375   - if (newd.goods_price >= condition_t) {
4376   - newd.prom_type = 3;
4377   - newd.prom_id = prom_d[i].prom_id;
4378   - }
4379   - break
4380   - case 1://按购买数量
4381   - if (newd.goods_num >= condition_t) {
4382   - newd.prom_type = 3;
4383   - newd.prom_id = prom_d[i].prom_id;
4384   - }
4385   - break;
4386   - }
4387   - }
4388   -
4389   - }
4390   -
4391   - newd['pick_name'] = th.data.sto_sele_name;
4392   - newd['pick_dis'] = th.data.sto_sele_distr;
4393   - th.buyNow(newd);
4394   - }
4395   - },
4396   -
4397   -
  3897 +
4398 3898 click_contact:function () {
4399 3899 getApp().globalData.no_clear=1;
4400 3900 },
... ...
packageA/pages/prom_list/prom_list.js
... ... @@ -351,7 +351,7 @@ Page({
351 351  
352 352 //获取统一条形码,普通商品和优惠促销的商品
353 353 //默认门店要拿下门店库存
354   - if (that.data.sales_rules >= 2) {
  354 + if (!getApp().is_virtual(t.data.data) && !t.data.data.whsle_id && that.data.sales_rules >= 2) {
355 355 //--等待某个值只运行---,这里有可能因为导航的时间太久,而不能计算门店库存
356 356 getApp().waitfor2(that, "wait_for_user_store", "fir_def_store", function () {
357 357  
... ...
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
... ... @@ -575,7 +575,9 @@ Page({
575 575 var that = this, th = this;
576 576 getApp().getConfig2(function (e) {
577 577 var sales_rules = e.sales_rules;
578   - if (sales_rules >= 2) {
  578 +
  579 + //虚拟商品, 代发商品不计算
  580 + if (!getApp().is_virtual(that.data.fir_goods) && !that.data.fir_goods.whsle_id && sales_rules >= 2) {
579 581 getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () {
580 582 var lock = 0, plist = null;
581 583 var gd = that.data.fir_goods;
... ... @@ -1672,7 +1674,7 @@ Page({
1672 1674 return false;
1673 1675 } else {
1674 1676 //---如果是线下门店销售的时候---
1675   - if (th.data.sales_rules >= 2) {
  1677 + if(!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id && th.data.sales_rules >= 2) {
1676 1678 var pick = th.get_pick_from_list(th.data.sto_sele_id)
1677 1679 //---通过接口获取门店的线下库存信息--
1678 1680 // getApp().request.get("/api/weshop/goods/getWareStorages", {
... ... @@ -1748,7 +1750,7 @@ Page({
1748 1750 newd.prom_id = 0;
1749 1751  
1750 1752 //---如果是线下门店销售的时候---
1751   - if (th.data.sales_rules >= 2) {
  1753 + if(!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id && th.data.sales_rules >= 2) {
1752 1754 var pick = th.get_pick_from_list(th.data.sto_sele_id)
1753 1755 //---通过接口获取门店的线下库存信息--
1754 1756 // getApp().request.get("/api/weshop/goods/getWareStorages", {
... ... @@ -2269,8 +2271,9 @@ Page({
2269 2271 }
2270 2272 }
2271 2273 var e = th.data.sele_g.store_count;
2272   - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
2273   - if (th.data.sales_rules >= 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
  2274 + var p_type = parseInt(th.data.prom_type); //&& p_type!=1 && p_type!=4
  2275 + if (!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id &&
  2276 + th.data.sales_rules >= 2 && ( [1,2,4,6,8,9].indexOf(p_type)==-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
2274 2277 if (!th.data.def_pick_store) {
2275 2278 wx.showModal({ title: '请选择门店', });
2276 2279 return false;
... ... @@ -2350,8 +2353,9 @@ Page({
2350 2353 }
2351 2354  
2352 2355 var e = th.data.sele_g.store_count;
2353   - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
2354   - if (th.data.sales_rules >= 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
  2356 + var p_type = parseInt(th.data.prom_type); //&& p_type!=1 && p_type!=4
  2357 + if (!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id &&
  2358 + th.data.sales_rules >= 2 && ([1,2,4,6,8,9].indexOf(p_type)== -1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
2355 2359 if (!th.data.def_pick_store) {
2356 2360 wx.showModal({ title: '请选择门店', });
2357 2361 return false;
... ... @@ -2983,7 +2987,7 @@ Page({
2983 2987  
2984 2988  
2985 2989 //默认门店要拿下门店库存
2986   - if (that.data.sales_rules >= 2 && that.data.def_pick_store) {
  2990 + if (!getApp().is_virtual(item) && !item.whsle_id && that.data.sales_rules >= 2 && that.data.def_pick_store) {
2987 2991 var lock = 0, plist = null;
2988 2992 // //先读取门店的lock,采用链式写法,少用await
2989 2993 // getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
... ... @@ -3213,7 +3217,8 @@ Page({
3213 3217 th.setData({ all_pick_list: e.data.data.pageData });
3214 3218  
3215 3219 //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购--
3216   - if (th.data.sales_rules >= 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 9 && th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) {
  3220 + if (!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id &&
  3221 + th.data.sales_rules >= 2 && !th.data.is_newsales_rules && ([1,2,4,6,8,9].indexOf(th.data.prom_type)== -1 || is_normal == 1) {
3217 3222 setTimeout(function () {
3218 3223 th.deal_pickup_dline(e);
3219 3224 }, 800)
... ...
packageC/pages/presell/cart/cart2.js
... ... @@ -129,7 +129,8 @@ Page({
129 129 dis_config:null,
130 130 bn_use_commission:0, //是不是使用佣金
131 131  
132   - same_ok:1
  132 + same_ok:1,
  133 + appoint_pick_keyid: '',
133 134  
134 135 },
135 136 onLoad: function (t) {
... ... @@ -248,7 +249,8 @@ Page({
248 249 sales_rules: ee.sales_rules,
249 250 rank_switch: json_d.rank_switch,
250 251 is_default_logistics: is_default_logistics,
251   - is_same_city: is_same_city
  252 + is_same_city: is_same_city,
  253 + appoint_pick_keyid: json_d.appoint_pick_keyid
252 254 });
253 255  
254 256 var rank_switch = json_d.rank_switch;
... ... @@ -1276,7 +1278,7 @@ Page({
1276 1278 if (gg.is_pd_normal) goods.is_pd_normal = 1;
1277 1279  
1278 1280 //如果不立即购买或者秒杀,如果是线下库存购买的时候
1279   - if (goods.prom_type != 1 && goods.prom_type != 6 && goods.prom_type != 8 && th.data.sales_rules == 2) {
  1281 + if ([1,2,4,6,8,9].indexOf(goods.prom_type)== -1 && th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id && !getApp().is_virtual(th.data.bn_goods)) {
1280 1282 var isok = 1;
1281 1283 await th.check_store_num(goods.goods_id, th.data.bn_pick, gg.goods_num, function (res) {
1282 1284 isok = res;
... ... @@ -1544,7 +1546,7 @@ Page({
1544 1546 }
1545 1547  
1546 1548 //如果不立即购买或者秒杀,如果是线下库存购买的时候
1547   - if (goods.prom_type == 0 && th.data.sales_rules == 2) {
  1549 + if (goods.prom_type == 0 && th.data.sales_rules >= 2 && !g_item.whsle_id && !getApp().is_virtual(g_item)) {
1548 1550 var isok = 1;
1549 1551 await th.check_store_num(goods.goods_id, t_item.pickup_id, goods.goods_num, function (res) {
1550 1552 isok = res;
... ... @@ -1721,26 +1723,38 @@ Page({
1721 1723 })
1722 1724  
1723 1725 },
  1726 +
  1727 +
  1728 +
1724 1729 //---确认线下门店的数量足不足---
1725 1730 async check_store_num(goods_id, pick, goods_num, func) {
1726 1731 var lock = 0, pick_no, plist, erpwareid;
  1732 +
  1733 + var lock_rq = { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 };
  1734 + if (this.data.sales_rules == 3) {
  1735 + lock_rq.appoint_pick_keyid = this.data.appoint_pick_keyid;
  1736 + delete lock_rq.storageId
  1737 + }
1727 1738 //先读取门店的lock
1728 1739 await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
1729   - data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 }
  1740 + data:lock_rq
1730 1741 }).then(res => {
1731 1742 if (res.data.code == 0 && res.data.data.total > 0) {
1732 1743 for (var i in res.data.data.pageData)
1733 1744 lock += res.data.data.pageData[i].outQty;
1734 1745 }
1735 1746 })
1736   - //先获取门店的编号
1737   - await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, {
1738   - data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick }
1739   - }).then(res => {
1740   - if (res.data.code == 0) {
1741   - pick_no = res.data.data.pickup_no;
1742   - }
1743   - })
  1747 +
  1748 + if (this.data.sales_rules == 2) {
  1749 + //先获取门店的编号
  1750 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, {
  1751 + data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
  1752 + }).then(res => {
  1753 + if (res.data.code == 0) {
  1754 + pick_no = res.data.data.pickup_no;
  1755 + }
  1756 + })
  1757 + }
1744 1758 //先获取商品的线下库存
1745 1759 await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, {
1746 1760 data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick }
... ... @@ -1749,9 +1763,16 @@ Page({
1749 1763 erpwareid = res.data.data.erpwareid;
1750 1764 }
1751 1765 })
  1766 +
  1767 + var sto_rq = { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 };
  1768 + if (this.data.sales_rules == 3) {
  1769 + sto_rq.storageIds = this.data.appoint_pick_keyid;
  1770 + delete sto_rq.storageNos
  1771 + }
  1772 +
1752 1773 //读取线下的门店库存
1753 1774 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
1754   - data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 }
  1775 + data: sto_rq
1755 1776 }).then(res => {
1756 1777 if (res.data.code == 0) {
1757 1778 plist = res.data.data.pageData[0];
... ...
packageC/pages/presell/goodsInfo/goodsInfo.js
... ... @@ -395,6 +395,8 @@ Page({
395 395 is_closecoupon: json_d.is_closecoupon,
396 396 is_newsales_rules: json_d.is_newsales_rules,
397 397 is_retail_price: json_d.is_retail_price || 0,
  398 + appoint_pick_keyid: json_d.appoint_pick_keyid
  399 +
398 400 });
399 401 // ee.init(gid);
400 402 //------几人评价-------
... ... @@ -1992,7 +1994,8 @@ Page({
1992 1994 th.setData({ all_pick_list: e.data.data.pageData });
1993 1995  
1994 1996 //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购 预售--
1995   - if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4 && th.data.prom_type != 8) || is_normal == 1)) {
  1997 + if(!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id
  1998 + && th.data.sales_rules >= 2 && !th.data.is_newsales_rules && ([1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 || is_normal == 1)) {
1996 1999 setTimeout(function () {
1997 2000 th.deal_pickup_dline(e);
1998 2001 }, 800)
... ... @@ -2199,7 +2202,8 @@ Page({
2199 2202  
2200 2203 //------------处理线下门店库存--------
2201 2204 deal_pickup_dline(e) {
2202   - var pkno = [], th = this;
  2205 + var pkno = [],
  2206 + th = this;
2203 2207 if (!th.data.sele_g) return false;
2204 2208  
2205 2209 if (this.data.def_pick_store) {
... ... @@ -2219,78 +2223,165 @@ Page({
2219 2223  
2220 2224 var g_distr_type = th.data.sele_g.distr_type;
2221 2225 var lock = [];
  2226 +
  2227 + var lock_rq = {
  2228 + store_id: os.stoid,
  2229 + wareId: th.data.sele_g.goods_id,
  2230 + pageSize: 1000
  2231 + };
  2232 +
  2233 + if (th.data.sales_rules == 3) {
  2234 + lock_rq.appoint_pick_keyid = th.data.appoint_pick_keyid;
  2235 + }
  2236 +
2222 2237 //先读取门店的lock,采用链式写法,少用await
2223 2238 getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
2224   - data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, pageSize: 1000 }
  2239 + data: lock_rq
2225 2240 }).then(res => {
2226 2241 if (res.data.code == 0 && res.data.data.total > 0) {
2227 2242 lock = res.data.data.pageData
2228 2243 }
  2244 + var sto_rq = {
  2245 + wareIds: encodeURIComponent(th.data.sele_g.erpwareid),
  2246 + storeId: os.stoid,
  2247 + pageSize: 2000
  2248 + }
  2249 +
  2250 + if (th.data.sales_rules == 3) {
  2251 + sto_rq.storageIds = th.data.appoint_pick_keyid;
  2252 + } else {
  2253 + sto_rq.storageNos = pkno_str;
  2254 + }
  2255 +
  2256 +
2229 2257 //---通过接口获取门店的线下库存信息--
2230 2258 return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
2231   - data: { storageNos: pkno_str, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid, pageSize: 2000 }
  2259 + data: sto_rq
2232 2260 })
2233 2261 }).then(res => {
2234 2262  
2235 2263 wx.hideLoading();
2236 2264 if (res.data.code == 0) {
  2265 +
2237 2266 if (res.data.data.pageData && res.data.data.pageData.length > 0) {
2238   - var plist = res.data.data.pageData;
  2267 +
2239 2268 var def_pick_store = th.data.def_pick_store;
2240   - //以原来的数组为外循环,保证距离的顺序
2241   - for (var kk in o_plist) {
2242   - for (var ii in plist) {
2243   - //线下的门店小心
2244   - var n_item = plist[ii];
2245   - if (n_item.StorageNo == o_plist[kk].pickup_no) {
2246   -
2247   - //拿到锁库的数量
2248   - var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock);
2249   - //可出库数大于预出库库存的数量,可以判断为有库存
2250   - if (n_item.CanOutQty > lock_num) {
2251   - o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num;
2252   - new_list.push(o_plist[kk]);
2253   - //--如果找到默认门店,同时也应该判断配送方式对不对--
2254   - if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
2255   - th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num;
2256   - if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id)
2257   - th.setData({ def_pick_store: th.data.fir_def_store })
2258   - is_find_def_store = 1;
  2269 + var plist = res.data.data.pageData;
  2270 + if (th.data.sales_rules == 3) {
  2271 + var lock_num = 0;
  2272 + var Qty = 0;
  2273 + //-- 计算锁住的库存 --
  2274 + for (var i in lock) lock_num += lock[i].outQty;
  2275 + Qty = plist[0].CanOutQty - lock_num;
  2276 +
  2277 + if (Qty > 0) {
  2278 + for (var kk in o_plist) {
  2279 + o_plist[kk].CanOutQty = Qty;
  2280 + new_list.push(o_plist[kk]);
  2281 + }
  2282 + if (th.data.fir_def_store &&
  2283 + (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || (th.data.def_pick_store && th.data.def_pick_store.distr_type == g_distr_type))) {
  2284 + th.data.fir_def_store.Qty=Qty;
  2285 + if (def_pick_store && def_pick_store.pickup_id == th.data.fir_def_store.pickup_id)
  2286 + th.setData({
  2287 + def_pick_store: th.data.fir_def_store
  2288 + })
  2289 + is_find_def_store = 1;
  2290 + }
  2291 +
  2292 + } else {
  2293 + th.setData({
  2294 + all_sto: null,
  2295 + only_pk: null,
  2296 + def_pickpu_list: null
  2297 + });
  2298 + return false;
  2299 + }
  2300 +
  2301 + } else {
  2302 +
  2303 +
  2304 + //以原来的数组为外循环,保证距离的顺序
  2305 + for (var kk in o_plist) {
  2306 + for (var ii in plist) {
  2307 + //线下的门店小心
  2308 + var n_item = plist[ii];
  2309 + if (n_item.StorageNo == o_plist[kk].pickup_no) {
  2310 +
  2311 + //拿到锁库的数量
  2312 + var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock);
  2313 + //可出库数大于预出库库存的数量,可以判断为有库存
  2314 + if (n_item.CanOutQty > lock_num) {
  2315 + o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num;
  2316 + new_list.push(o_plist[kk]);
  2317 + //--如果找到默认门店,同时也应该判断配送方式对不对--
  2318 + if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
  2319 + th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num;
  2320 + if (def_pick_store && def_pick_store.pickup_id == th.data.fir_def_store.pickup_id)
  2321 + th.setData({
  2322 + def_pick_store: th.data.fir_def_store
  2323 + })
  2324 + is_find_def_store = 1;
  2325 + }
2259 2326 }
  2327 + break;
2260 2328 }
2261   - break;
2262 2329 }
2263 2330 }
  2331 +
2264 2332 }
2265 2333  
2266 2334 //数据组装下
2267   - var em = {}; em.data = {}; em.data.data = {};
  2335 + var em = {};
  2336 + em.data = {};
  2337 + em.data.data = {};
2268 2338 em.data.data.total = new_list.length;
2269 2339 em.data.data.pageData = new_list;
2270 2340  
  2341 +
2271 2342 //--如果找到默认门店,同时也应该判断配送方式对不对--
2272   - if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
  2343 + if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id &&
  2344 + (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
2273 2345 th.data.fir_def_store.CanOutQty = 0;
2274 2346 //--当选择的门店是客户默认的门店的时候--
2275 2347 if (th.data.def_pick_store && th.data.fir_def_store.pickup_id == th.data.def_pick_store.pickup_id) {
2276   - th.setData({ def_pick_store: th.data.fir_def_store });
  2348 + th.setData({
  2349 + def_pick_store: th.data.fir_def_store
  2350 + });
2277 2351 em.data.data.pageData.unshift(th.data.def_pick_store);
2278 2352 } else {
2279 2353 em.data.data.pageData.splice(1, 0, th.data.fir_def_store);
2280 2354 }
2281 2355 }
2282 2356  
  2357 + for (let j = 0; j < em.data.data.pageData.length; j++) {
  2358 + var iu = em.data.data.pageData[j];
  2359 + if (iu.CanOutQty <= 0) iu.is_no_qyt = 1;
  2360 +
  2361 + }
  2362 +
2283 2363 //---把数组组装进去---
2284 2364 th.deal_pickup(em);
  2365 +
2285 2366 } else {
2286   - th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null })
  2367 + th.setData({
  2368 + all_sto: null,
  2369 + only_pk: null,
  2370 + def_pickpu_list: null
  2371 + })
2287 2372 }
  2373 +
2288 2374 } else {
2289   - th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null })
  2375 + th.setData({
  2376 + all_sto: null,
  2377 + only_pk: null,
  2378 + def_pickpu_list: null
  2379 + })
2290 2380 }
2291 2381 })
2292 2382 },
2293 2383  
  2384 +
2294 2385 find_lock_num(pick_id, lock) {
2295 2386 var lock_num = 0;
2296 2387 if (!lock) return 0;
... ...
packageC/pages/presell/list/list.wxml
... ... @@ -33,7 +33,7 @@
33 33 </navigator>
34 34 <view class="kill-cont">
35 35 <navigator class="goods-name ellipsis-2"
36   - url="/packageC/pages/presell/pregoodsInfo/goodsInfo?goods_id={{item.goods_id}}&pre_id={{item.id}}">{{item.goods_name}}</navigator>
  36 + url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{item.goods_id}}&pre_id={{item.id}}">{{item.goods_name}}</navigator>
37 37 <view class="flex-vertical xc-strip-frame">
38 38 <view class="xc-strip-blank rel">
39 39  
... ...
packageC/pages/presell/pregoodsInfo/goodsInfo.js
... ... @@ -1916,7 +1916,7 @@ Page({
1916 1916 th.setData({ all_pick_list: e.data.data.pageData });
1917 1917  
1918 1918 //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购--
1919   - if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) {
  1919 + if (th.data.sales_rules >= 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) {
1920 1920 setTimeout(function () {
1921 1921 th.deal_pickup_dline(e);
1922 1922 }, 800)
... ... @@ -2121,9 +2121,10 @@ Page({
2121 2121 }
2122 2122 },
2123 2123  
2124   - //------------处理线下门店库存--------
  2124 + //------------处理线下门店库存--------
2125 2125 deal_pickup_dline(e) {
2126   - var pkno = [], th = this;
  2126 + var pkno = [],
  2127 + th = this;
2127 2128 if (!th.data.sele_g) return false;
2128 2129  
2129 2130 if (this.data.def_pick_store) {
... ... @@ -2143,78 +2144,166 @@ Page({
2143 2144  
2144 2145 var g_distr_type = th.data.sele_g.distr_type;
2145 2146 var lock = [];
  2147 +
  2148 + var lock_rq = {
  2149 + store_id: os.stoid,
  2150 + wareId: th.data.sele_g.goods_id,
  2151 + pageSize: 1000
  2152 + };
  2153 +
  2154 + if (th.data.sales_rules == 3) {
  2155 + lock_rq.appoint_pick_keyid = th.data.appoint_pick_keyid;
  2156 + }
  2157 +
2146 2158 //先读取门店的lock,采用链式写法,少用await
2147 2159 getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
2148   - data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, pageSize: 1000 }
  2160 + data: lock_rq
2149 2161 }).then(res => {
2150 2162 if (res.data.code == 0 && res.data.data.total > 0) {
2151 2163 lock = res.data.data.pageData
2152 2164 }
  2165 + var sto_rq = {
  2166 + wareIds: encodeURIComponent(th.data.sele_g.erpwareid),
  2167 + storeId: os.stoid,
  2168 + pageSize: 2000
  2169 + }
  2170 +
  2171 + if (th.data.sales_rules == 3) {
  2172 + sto_rq.storageIds = th.data.appoint_pick_keyid;
  2173 + } else {
  2174 + sto_rq.storageNos = pkno_str;
  2175 + }
  2176 +
  2177 +
2153 2178 //---通过接口获取门店的线下库存信息--
2154 2179 return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
2155   - data: { storageNos: pkno_str, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid, pageSize: 2000 }
  2180 + data: sto_rq
2156 2181 })
2157 2182 }).then(res => {
2158 2183  
2159 2184 wx.hideLoading();
2160 2185 if (res.data.code == 0) {
  2186 +
2161 2187 if (res.data.data.pageData && res.data.data.pageData.length > 0) {
2162   - var plist = res.data.data.pageData;
  2188 +
2163 2189 var def_pick_store = th.data.def_pick_store;
2164   - //以原来的数组为外循环,保证距离的顺序
2165   - for (var kk in o_plist) {
2166   - for (var ii in plist) {
2167   - //线下的门店小心
2168   - var n_item = plist[ii];
2169   - if (n_item.StorageNo == o_plist[kk].pickup_no) {
2170   -
2171   - //拿到锁库的数量
2172   - var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock);
2173   - //可出库数大于预出库库存的数量,可以判断为有库存
2174   - if (n_item.CanOutQty > lock_num) {
2175   - o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num;
2176   - new_list.push(o_plist[kk]);
2177   - //--如果找到默认门店,同时也应该判断配送方式对不对--
2178   - if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
2179   - th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num;
2180   - if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id)
2181   - th.setData({ def_pick_store: th.data.fir_def_store })
2182   - is_find_def_store = 1;
  2190 + var plist = res.data.data.pageData;
  2191 + if (th.data.sales_rules == 3) {
  2192 + var lock_num = 0;
  2193 + var Qty = 0;
  2194 + //-- 计算锁住的库存 --
  2195 + for (var i in lock) lock_num += lock[i].outQty;
  2196 + Qty = plist[0].CanOutQty - lock_num;
  2197 +
  2198 + if (Qty > 0) {
  2199 + for (var kk in o_plist) {
  2200 + o_plist[kk].CanOutQty = Qty;
  2201 + new_list.push(o_plist[kk]);
  2202 + }
  2203 + if (th.data.fir_def_store &&
  2204 + (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || (th.data.def_pick_store && th.data.def_pick_store.distr_type == g_distr_type))) {
  2205 + th.data.fir_def_store.Qty=Qty;
  2206 + if (def_pick_store && def_pick_store.pickup_id == th.data.fir_def_store.pickup_id)
  2207 + th.setData({
  2208 + def_pick_store: th.data.fir_def_store
  2209 + })
  2210 + is_find_def_store = 1;
  2211 + }
  2212 +
  2213 + } else {
  2214 + th.setData({
  2215 + all_sto: null,
  2216 + only_pk: null,
  2217 + def_pickpu_list: null
  2218 + });
  2219 + return false;
  2220 + }
  2221 +
  2222 + } else {
  2223 +
  2224 +
  2225 + //以原来的数组为外循环,保证距离的顺序
  2226 + for (var kk in o_plist) {
  2227 + for (var ii in plist) {
  2228 + //线下的门店小心
  2229 + var n_item = plist[ii];
  2230 + if (n_item.StorageNo == o_plist[kk].pickup_no) {
  2231 +
  2232 + //拿到锁库的数量
  2233 + var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock);
  2234 + //可出库数大于预出库库存的数量,可以判断为有库存
  2235 + if (n_item.CanOutQty > lock_num) {
  2236 + o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num;
  2237 + new_list.push(o_plist[kk]);
  2238 + //--如果找到默认门店,同时也应该判断配送方式对不对--
  2239 + if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
  2240 + th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num;
  2241 + if (def_pick_store && def_pick_store.pickup_id == th.data.fir_def_store.pickup_id)
  2242 + th.setData({
  2243 + def_pick_store: th.data.fir_def_store
  2244 + })
  2245 + is_find_def_store = 1;
  2246 + }
2183 2247 }
  2248 + break;
2184 2249 }
2185   - break;
2186 2250 }
2187 2251 }
  2252 +
2188 2253 }
2189 2254  
2190 2255 //数据组装下
2191   - var em = {}; em.data = {}; em.data.data = {};
  2256 + var em = {};
  2257 + em.data = {};
  2258 + em.data.data = {};
2192 2259 em.data.data.total = new_list.length;
2193 2260 em.data.data.pageData = new_list;
2194 2261  
  2262 +
2195 2263 //--如果找到默认门店,同时也应该判断配送方式对不对--
2196   - if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
  2264 + if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id &&
  2265 + (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
2197 2266 th.data.fir_def_store.CanOutQty = 0;
2198 2267 //--当选择的门店是客户默认的门店的时候--
2199 2268 if (th.data.def_pick_store && th.data.fir_def_store.pickup_id == th.data.def_pick_store.pickup_id) {
2200   - th.setData({ def_pick_store: th.data.fir_def_store });
  2269 + th.setData({
  2270 + def_pick_store: th.data.fir_def_store
  2271 + });
2201 2272 em.data.data.pageData.unshift(th.data.def_pick_store);
2202 2273 } else {
2203 2274 em.data.data.pageData.splice(1, 0, th.data.fir_def_store);
2204 2275 }
2205 2276 }
2206 2277  
  2278 + for (let j = 0; j < em.data.data.pageData.length; j++) {
  2279 + var iu = em.data.data.pageData[j];
  2280 + if (iu.CanOutQty <= 0) iu.is_no_qyt = 1;
  2281 +
  2282 + }
  2283 +
2207 2284 //---把数组组装进去---
2208 2285 th.deal_pickup(em);
  2286 +
2209 2287 } else {
2210   - th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null })
  2288 + th.setData({
  2289 + all_sto: null,
  2290 + only_pk: null,
  2291 + def_pickpu_list: null
  2292 + })
2211 2293 }
  2294 +
2212 2295 } else {
2213   - th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null })
  2296 + th.setData({
  2297 + all_sto: null,
  2298 + only_pk: null,
  2299 + def_pickpu_list: null
  2300 + })
2214 2301 }
2215 2302 })
2216 2303 },
2217 2304  
  2305 +
  2306 +
2218 2307 find_lock_num(pick_id, lock) {
2219 2308 var lock_num = 0;
2220 2309 if (!lock) return 0;
... ...
packageE/pages/cart/cart2/cart2.js
... ... @@ -3990,7 +3990,8 @@ Page({
3990 3990  
3991 3991  
3992 3992 //如果不立即购买或者秒杀,如果是线下库存购买的时候
3993   - if (goods.prom_type != 1 && goods.prom_type != 6 && goods.prom_type != 2 && th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id) {
  3993 + if (goods.prom_type != 1 && goods.prom_type != 6 && goods.prom_type != 2
  3994 + && th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id && !getApp().is_virtual(th.data.bn_goods)) {
3994 3995 var isok = 1;
3995 3996 await th.check_store_num(goods.goods_id, th.data.bn_pick, gg.goods_num, function (res) {
3996 3997 isok = res;
... ... @@ -4336,7 +4337,7 @@ Page({
4336 4337 }
4337 4338  
4338 4339 //如果不立即购买或者秒杀,如果是线下库存购买的时候
4339   - if (goods.prom_type == 0 && th.data.sales_rules >= 2) {
  4340 + if (goods.prom_type == 0 && th.data.sales_rules >= 2 && !g_item.whsle_id && !getApp().is_virtual(g_item) ) {
4340 4341 var isok = 1;
4341 4342 await th.check_store_num(goods.goods_id, t_item.pickup_id, goods.goods_num, function (res) {
4342 4343 isok = res;
... ...
pages/cart/cart/cart.js
... ... @@ -2043,7 +2043,7 @@ Page({
2043 2043 var txt = "requestData[" + pitems + "].goods[" + i + "].selected";
2044 2044  
2045 2045 var gd_info = item[i];
2046   - if (th.data.sales_rules >= 2 && !gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1 && !gd_info.selected) {
  2046 + if (!getApp().is_virtual(gd_info) && th.data.sales_rules >= 2 && !gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1 && !gd_info.selected) {
2047 2047 var ob = {};
2048 2048 await th.check_down_line_next(gd_info, pitems, i, gd_info.erpwareid, function (res) {
2049 2049 ob = res;
... ... @@ -2227,7 +2227,7 @@ Page({
2227 2227 var gd_info = a;
2228 2228  
2229 2229 var erpwareid = gd_info.erpwareid;
2230   - if (th.data.sales_rules >= 2 && !gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1 && !a.selected) {
  2230 + if (!getApp().is_virtual(gd_info) && th.data.sales_rules >= 2 && !gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1 && !a.selected) {
2231 2231 var ob = {};
2232 2232 await th.check_down_line_next(gd_info, pitems, item, erpwareid, function (res) {
2233 2233 ob = res;
... ... @@ -2537,7 +2537,7 @@ Page({
2537 2537  
2538 2538 function normal_check(store_count, goodsinfo, wareIds) {
2539 2539 //--- 看一下是不是线下库存 ---
2540   - if (th.data.sales_rules >= 2 && !goodsinfo.whsle_id) {
  2540 + if (!getApp().is_virtual(goodsinfo) && th.data.sales_rules >= 2 && !goodsinfo.whsle_id) {
2541 2541 th.check_down_line(t, pitem, item, wareIds);
2542 2542 } else {
2543 2543 if (t.goods_num > store_count) {
... ... @@ -3372,8 +3372,8 @@ Page({
3372 3372 ab = 1;
3373 3373  
3374 3374 //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算,赠品不要进行调用线下库存---
3375   - if ((i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3 || i_arr[j].prom_type == 5 || i_arr[j].prom_type == 7 ||
3376   - i_arr[j].need_downlow_num) && th.data.sales_rules >= 2 && i_arr[j].is_gift != 1 && !i_arr[j].whsle_id) {
  3375 + if ((i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3 || i_arr[j].prom_type == 5 || i_arr[j].prom_type == 7 || i_arr[j].prom_type == 10 ||
  3376 + i_arr[j].need_downlow_num) && !getApp().is_virtual(i_arr[j]) && th.data.sales_rules >= 2 && i_arr[j].is_gift != 1 && !i_arr[j].whsle_id) {
3377 3377 //--获取商品的线下商品ID--
3378 3378  
3379 3379 var gd = null;
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -558,7 +558,7 @@ Page({
558 558 th = this;
559 559 getApp().getConfig2(function (e) {
560 560 var sales_rules = e.sales_rules;
561   - if (sales_rules >= 2 && [1, 2, 4, 6, 8, 9].indexOf(th.data.prom_type) == -1 && !th.data.sele_g.whsle_id) {
  561 + if (!getApp().is_virtual(th.data.sele_g) && sales_rules >= 2 && [1, 2, 4, 6, 8, 9].indexOf(th.data.prom_type) == -1 && !th.data.sele_g.whsle_id) {
562 562 getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () {
563 563 var lock = 0,
564 564 plist = null;
... ... @@ -1104,16 +1104,8 @@ Page({
1104 1104  
1105 1105 //获取统一条形码,普通商品和优惠促销的商品
1106 1106 if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9 || ee.data.data.prom_type == 10) {
1107   - //默认门店要拿下门店库存
1108   - if (that.data.sales_rules == 2 && that.data.is_newsales_rules) {
1109   - //获取门店
1110   - ee.get_sto();
1111   -
1112   - } else {
1113   - //获取门店
1114   - ee.get_sto();
1115   - }
1116 1107  
  1108 + ee.get_sto();
1117 1109 ee.get_sku(o.stoid, t.data.data, gid);
1118 1110 ee.check_has_flash();
1119 1111  
... ... @@ -1680,7 +1672,7 @@ Page({
1680 1672 newd.is_pd_normal = 1;
1681 1673  
1682 1674 //---如果是线下门店销售的时候---
1683   - if (th.data.sales_rules >= 2) {
  1675 + if (!getApp().is_virtual(th.data.sele_g) && th.data.sales_rules >= 2) {
1684 1676 var pick = th.get_pick_from_list(th.data.sto_sele_id)
1685 1677 //---通过接口获取门店的线下库存信息--
1686 1678 th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) {
... ... @@ -1778,7 +1770,7 @@ Page({
1778 1770 return false;
1779 1771 } else {
1780 1772 //---如果是线下门店销售的时候---
1781   - if (th.data.sales_rules >= 2) {
  1773 + if (!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id && th.data.sales_rules >= 2) {
1782 1774 var pick = th.get_pick_from_list(th.data.sto_sele_id)
1783 1775  
1784 1776 th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) {
... ... @@ -1837,7 +1829,7 @@ Page({
1837 1829 }
1838 1830  
1839 1831 //---如果是线下门店销售的时候---
1840   - if (th.data.sales_rules >= 2 && !th.data.sele_g.whsle_id) {
  1832 + if ( !getApp().is_virtual(th.data.sele_g) && th.data.sales_rules >= 2 && !th.data.sele_g.whsle_id) {
1841 1833 var pick = th.get_pick_from_list(th.data.sto_sele_id)
1842 1834 //---通过接口获取门店的线下库存信息--
1843 1835 // getApp().request.get("/api/weshop/goods/getWareStorages", {
... ... @@ -2496,7 +2488,8 @@ Page({
2496 2488 }
2497 2489 var e = th.data.sele_g.store_count;
2498 2490 var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
2499   - if (th.data.sales_rules >= 2 && (p_type != 1 && p_type != 4 && p_type != 6 && p_type != 2 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
  2491 + if (!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id && th.data.sales_rules >= 2 &&
  2492 + ([1,2,4,6,8,9].indexOf(p_type)==-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
2500 2493 if (!th.data.def_pick_store) {
2501 2494 wx.showToast({
2502 2495 title: '请选择门店',
... ... @@ -2612,7 +2605,8 @@ Page({
2612 2605  
2613 2606 var e = th.data.sele_g.store_count;
2614 2607 var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
2615   - if (th.data.sales_rules >= 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
  2608 + if (!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id && th.data.sales_rules >= 2 &&
  2609 + ([1,2,4,6,8,9].indexOf(p_type)==-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
2616 2610 if (!th.data.def_pick_store) {
2617 2611 wx.showModal({
2618 2612 title: '请选择门店',
... ... @@ -3342,7 +3336,7 @@ Page({
3342 3336 if (!item.whsle_id && [1,2,4,6].indexOf(item.prom_type)==-1) that.check_is_youhui(gid, that.data.is_normal);
3343 3337  
3344 3338 //默认门店要拿下门店库存
3345   - if (that.data.sales_rules >= 2 && that.data.def_pick_store && !that.data.sele_g.whsle_id && [1,2,4,6].indexOf(item.prom_type)==-1) {
  3339 + if (!getApp().is_virtual(th.data.sele_g) && that.data.sales_rules >= 2 && that.data.def_pick_store && !that.data.sele_g.whsle_id && [1,2,4,6].indexOf(item.prom_type)==-1) {
3346 3340 var lock = 0,
3347 3341 plist = null;
3348 3342  
... ... @@ -3643,7 +3637,7 @@ Page({
3643 3637 });
3644 3638  
3645 3639 //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购--
3646   - if (th.data.sales_rules >= 2 && !th.data.is_newsales_rules && !th.data.sele_g.whsle_id && ([1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 || is_normal == 1)) {
  3640 + if (!getApp().is_virtual(th.data.sele_g) && th.data.sales_rules >= 2 && !th.data.is_newsales_rules && !th.data.sele_g.whsle_id && ([1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 || is_normal == 1)) {
3647 3641 setTimeout(function () {
3648 3642 th.deal_pickup_dline(e);
3649 3643 }, 800)
... ... @@ -3939,7 +3933,7 @@ Page({
3939 3933 }
3940 3934 if (th.data.fir_def_store &&
3941 3935 (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || (th.data.def_pick_store && th.data.def_pick_store.distr_type == g_distr_type))) {
3942   - th.data.fir_def_store.Qty;
  3936 + th.data.fir_def_store.Qty=Qty;
3943 3937 if (def_pick_store && def_pick_store.pickup_id == th.data.fir_def_store.pickup_id)
3944 3938 th.setData({
3945 3939 def_pick_store: th.data.fir_def_store
... ... @@ -5026,7 +5020,6 @@ Page({
5026 5020 getApp().confirmBox("拼团商品至少要买" + qnum + "件!");
5027 5021 return false;
5028 5022 }
5029   -
5030 5023 }
5031 5024  
5032 5025 th.addcart_pt_func();
... ...
pages/user/order_list/order_list.js
... ... @@ -1041,7 +1041,7 @@ Page({
1041 1041 }
1042 1042  
1043 1043 //--如果是线下库存的时候--
1044   - if (th.data.conf.sales_rules >= 2 && !gg.whsle_id) {
  1044 + if (!getApp().is_virtual(gg) && th.data.conf.sales_rules >= 2 && !gg.whsle_id) {
1045 1045 var ob = {};
1046 1046 await th.check_down_line_next(gg, good.goods_num, order.pickup_id, function (obj) {
1047 1047 ob = obj;
... ... @@ -1667,7 +1667,7 @@ Page({
1667 1667  
1668 1668  
1669 1669 //判断是不是线下库存的购买, 是不是秒杀活动
1670   - if (th.data.sales_rules >= 2 && !prom && !good.whsle_id) {
  1670 + if (!getApp().is_virtual(good) && th.data.sales_rules >= 2 && !prom && !good.whsle_id) {
1671 1671  
1672 1672 //-- 看一下购物车上有多少商品 --
1673 1673 var cart_num = 0;
... ...