Commit 80cbc1b6df01b1c0873a1d81fc025968e1cb5bcb
1 parent
27d72475
虚拟商品起订量的优化
Showing
9 changed files
with
557 additions
and
240 deletions
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
| ... | ... | @@ -1572,7 +1572,7 @@ Page({ |
| 1572 | 1572 | // title: '提示', |
| 1573 | 1573 | // content: '超出商品限购' |
| 1574 | 1574 | // }); |
| 1575 | - getApp().my_warnning('超出商品限购', 0, th); | |
| 1575 | + getApp().my_warnning('超出商品限购', 0, th); | |
| 1576 | 1576 | return false; |
| 1577 | 1577 | } |
| 1578 | 1578 | } |
| ... | ... | @@ -1583,7 +1583,7 @@ Page({ |
| 1583 | 1583 | // title: '提示', |
| 1584 | 1584 | // content: '超出商品活动限购' |
| 1585 | 1585 | // }); |
| 1586 | - getApp().my_warnning('超出商品活动限购', 0, th); | |
| 1586 | + getApp().my_warnning('超出商品活动限购', 0, th); | |
| 1587 | 1587 | return false; |
| 1588 | 1588 | } |
| 1589 | 1589 | } |
| ... | ... | @@ -1752,43 +1752,7 @@ Page({ |
| 1752 | 1752 | //---如果是线下门店销售的时候--- |
| 1753 | 1753 | if(!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id && th.data.sales_rules >= 2) { |
| 1754 | 1754 | var pick = th.get_pick_from_list(th.data.sto_sele_id) |
| 1755 | - //---通过接口获取门店的线下库存信息-- | |
| 1756 | - // getApp().request.get("/api/weshop/goods/getWareStorages", { | |
| 1757 | - // data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }, | |
| 1758 | - // success: function (res) { | |
| 1759 | - // if (res.data.code == 0) { | |
| 1760 | - // if (res.data.data.pageData.length > 0) { | |
| 1761 | - // var CanOutQty = res.data.data.pageData[0].CanOutQty; | |
| 1762 | - // if (CanOutQty < e.data.goodsInputNum) { | |
| 1763 | - // return s.my_warnning("库存不足!", 0, th); | |
| 1764 | - // } | |
| 1765 | - // //在调一次接口,读取商品的预出库的数量,lock | |
| 1766 | - // getApp().request.get("/api/weshop/order/ware/lock/page", { | |
| 1767 | - // data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 }, | |
| 1768 | - // success: function (res_data) { | |
| 1769 | - // if (res_data.data.code == 0 && res_data.data.data.total > 0) { | |
| 1770 | - // | |
| 1771 | - // var lock = 0; | |
| 1772 | - // for (var i in res_data.data.data.pageData) { | |
| 1773 | - // lock += res_data.data.data.pageData[i].outQty; | |
| 1774 | - // } | |
| 1775 | - // | |
| 1776 | - // if (CanOutQty <= lock) { | |
| 1777 | - // return s.my_warnning("库存不足!", 0, th); | |
| 1778 | - // } | |
| 1779 | - // th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | |
| 1780 | - // } else { | |
| 1781 | - // th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 1782 | - // } | |
| 1783 | - // } | |
| 1784 | - // }) | |
| 1785 | - // } else { | |
| 1786 | - // return s.my_warnning("库存不足!", 0, th); | |
| 1787 | - // } | |
| 1788 | - // | |
| 1789 | - // } | |
| 1790 | - // } | |
| 1791 | - // }) | |
| 1755 | + | |
| 1792 | 1756 | |
| 1793 | 1757 | |
| 1794 | 1758 | th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { |
| ... | ... | @@ -2190,11 +2154,20 @@ Page({ |
| 2190 | 2154 | |
| 2191 | 2155 | //----------增加购买数量----------- |
| 2192 | 2156 | addCartNum: function (t) { |
| 2193 | - this.checkCartNum(this.data.goodsInputNum + 1); | |
| 2157 | + | |
| 2158 | + var add_num=1; | |
| 2159 | + if(this.data.is_normal == 1){ | |
| 2160 | + add_num=getApp().get_limit_qty(this.data.sele_g,0,1); | |
| 2161 | + } | |
| 2162 | + this.checkCartNum(this.data.goodsInputNum + add_num); | |
| 2194 | 2163 | }, |
| 2195 | 2164 | //----------减少购买数量----------- |
| 2196 | 2165 | subCartNum: function (t) { |
| 2197 | - this.checkCartNum(this.data.goodsInputNum - 1); | |
| 2166 | + var add_num=1; | |
| 2167 | + if(this.data.is_normal == 1){ | |
| 2168 | + add_num=getApp().get_limit_qty(this.data.sele_g,0,1); | |
| 2169 | + } | |
| 2170 | + this.checkCartNum(this.data.goodsInputNum - add_num); | |
| 2198 | 2171 | }, |
| 2199 | 2172 | //----------输入框输入购买数量----------- |
| 2200 | 2173 | inputCartNum: function (t) { |
| ... | ... | @@ -2218,6 +2191,7 @@ Page({ |
| 2218 | 2191 | //------检查数量是不是超出限购------ |
| 2219 | 2192 | checkCartNum: function (t) { |
| 2220 | 2193 | var th = this; |
| 2194 | + var mo_num=getApp().get_limit_qty(th.data.sele_g); | |
| 2221 | 2195 | this.get_buy_num(this.data.sele_g, async function () { |
| 2222 | 2196 | |
| 2223 | 2197 | //--判断商品是否超出限购-- |
| ... | ... | @@ -2286,9 +2260,20 @@ Page({ |
| 2286 | 2260 | if (e < t) { |
| 2287 | 2261 | wx.showModal({ title: '库存不足', }); |
| 2288 | 2262 | if (e < 0) e = 0; |
| 2263 | + | |
| 2264 | + if(th.data.is_normal == 1){ | |
| 2265 | + if(e<mo_num) e=mo_num; | |
| 2266 | + } | |
| 2267 | + | |
| 2289 | 2268 | th.setData({ goodsInputNum: e }); return false; |
| 2290 | 2269 | } |
| 2291 | 2270 | t > e || 0 == e ? t = e : t < 1 && (t = 1); |
| 2271 | + | |
| 2272 | + //只有普通商品才有起购数 | |
| 2273 | + if(th.data.is_normal == 1){ | |
| 2274 | + if(t<mo_num) t=mo_num; | |
| 2275 | + } | |
| 2276 | + | |
| 2292 | 2277 | th.setData({ goodsInputNum: t }); |
| 2293 | 2278 | th.is_show_more_buy(); |
| 2294 | 2279 | |
| ... | ... | @@ -4303,7 +4288,10 @@ Page({ |
| 4303 | 4288 | // ind == 1 为普通购买 |
| 4304 | 4289 | openSpecModel_pt: function (e) { |
| 4305 | 4290 | |
| 4306 | - this.setData({ open_ind_store: 9, goodsInputNum: 1 }); | |
| 4291 | + | |
| 4292 | + var mo_num=getApp().get_limit_qty(this.data.sele_g); | |
| 4293 | + | |
| 4294 | + this.setData({ open_ind_store: 9, goodsInputNum: mo_num }); | |
| 4307 | 4295 | // 判断是否有待支付订单 |
| 4308 | 4296 | var aid = this.data.group_id; |
| 4309 | 4297 | var switOn = true; |
| ... | ... | @@ -4477,172 +4465,252 @@ Page({ |
| 4477 | 4465 | //----------添加到购物车时,要判断限购数量,-------- |
| 4478 | 4466 | e.get_buy_num(o, async function (ee) { |
| 4479 | 4467 | |
| 4480 | - //---判断商品是否超出限购--- | |
| 4481 | - // if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | |
| 4482 | - // if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | |
| 4483 | - // wx.showModal({ | |
| 4484 | - // title: '提示', | |
| 4485 | - // content: '超出商品限购' | |
| 4486 | - // }); | |
| 4487 | - | |
| 4488 | - // var num = th.data.prom_buy_limit - th.data.prom_buy_num; | |
| 4489 | - // if (num < 0) num = 0; | |
| 4490 | - // th.setData({ goodsInputNum: num }) | |
| 4491 | - // return false; | |
| 4492 | - // } | |
| 4493 | - // } | |
| 4468 | + //---判断商品是否超出限购--- | |
| 4469 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | |
| 4470 | + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | |
| 4471 | + wx.showModal({ | |
| 4472 | + title: '提示', | |
| 4473 | + content: '超出商品限购' | |
| 4474 | + }); | |
| 4494 | 4475 | |
| 4495 | - //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购--- | |
| 4496 | - // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { | |
| 4497 | - // if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | |
| 4498 | - // wx.showModal({ | |
| 4499 | - // title: '提示', | |
| 4500 | - // content: '超出商品活动限购' | |
| 4501 | - // }); | |
| 4502 | - | |
| 4503 | - // var num = th.data.prom_buy_limit - th.data.prom_buy_num; | |
| 4504 | - // if (num < 0) num = 0; | |
| 4505 | - // th.setData({ goodsInputNum: num }) | |
| 4506 | - // return false; | |
| 4507 | - // } | |
| 4508 | - // } | |
| 4476 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; | |
| 4477 | + if (num < 0) num = 0; | |
| 4478 | + th.setData({goodsInputNum: num}) | |
| 4479 | + return false; | |
| 4480 | + } | |
| 4481 | + } | |
| 4509 | 4482 | |
| 4510 | - var redis_num = 0 | |
| 4511 | - //不是普通购买的时候 | |
| 4512 | - // if (th.data.is_normal != 1) { | |
| 4513 | - // //-------判断活动是否抢光--------- | |
| 4514 | - // await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { | |
| 4515 | - // 1: 1 | |
| 4516 | - // }).then(res => { | |
| 4517 | - // redis_num = res.data.data; | |
| 4518 | - // }) | |
| 4519 | 4483 | |
| 4520 | - // if (th.data.goodsInputNum > redis_num) { | |
| 4521 | - // wx.showModal({ | |
| 4522 | - // title: '提示', | |
| 4523 | - // content: '超出商品活动库存' | |
| 4524 | - // }); | |
| 4484 | + var redis_num = 0 | |
| 4525 | 4485 | |
| 4526 | - // th.setData({ goodsInputNum: redis_num }) | |
| 4486 | + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | |
| 4487 | + th.setData({ | |
| 4488 | + sto_sele_name: "" | |
| 4489 | + }); | |
| 4527 | 4490 | |
| 4528 | - // return false; | |
| 4529 | - // } | |
| 4530 | - // } | |
| 4491 | + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | |
| 4492 | + | |
| 4493 | + //--------------此时操作的数据------------ | |
| 4494 | + var newd = { | |
| 4495 | + goods_id: o.goods_id, | |
| 4496 | + goods_num: th.data.goodsInputNum, | |
| 4497 | + pick_id: th.data.sto_sele_id, | |
| 4498 | + user_id: oo.user_id, | |
| 4499 | + store_id: th.data.stoid, | |
| 4500 | + goods_price: o.shop_price, | |
| 4501 | + goods_name: o.goods_name, | |
| 4502 | + goods_sn: o.goods_sn, | |
| 4503 | + sku: o.sku, | |
| 4504 | + }; | |
| 4531 | 4505 | |
| 4532 | - // if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | |
| 4533 | - // if (th.data.goodsInputNum > o.store_count) { | |
| 4534 | - // th.setData({ goodsInputNum: o.store_count }) | |
| 4535 | - // return s.my_warnning("超出商品库存", 0, th); | |
| 4536 | - // } | |
| 4506 | + //---是不是从收藏夹出来的--- | |
| 4507 | + if (th.data.c_guide_id) { | |
| 4508 | + newd['guide_id'] = th.data.c_guide_id; | |
| 4509 | + newd['guide_type'] = 2; | |
| 4537 | 4510 | |
| 4538 | - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | |
| 4539 | - th.setData({ | |
| 4540 | - sto_sele_name: "" | |
| 4541 | - }); | |
| 4542 | - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | |
| 4511 | + } else { | |
| 4512 | + if (getApp().globalData.guide_id) { | |
| 4513 | + newd['guide_id'] = getApp().globalData.guide_id; | |
| 4514 | + newd['guide_type'] = 0; | |
| 4543 | 4515 | |
| 4544 | - //--------------此时操作的数据------------ | |
| 4545 | - var newd = { | |
| 4546 | - goods_id: o.goods_id, | |
| 4547 | - goods_num: th.data.goodsInputNum, | |
| 4548 | - pick_id: th.data.sto_sele_id, | |
| 4549 | - user_id: oo.user_id, | |
| 4550 | - store_id: th.data.stoid, | |
| 4551 | - goods_price: o.shop_price, | |
| 4552 | - goods_name: o.goods_name, | |
| 4553 | - goods_sn: o.goods_sn, | |
| 4554 | - sku: o.sku, | |
| 4555 | - }; | |
| 4516 | + } | |
| 4517 | + } | |
| 4518 | + if (getApp().globalData.groupchat_id) { | |
| 4519 | + newd['groupchat_id'] = getApp().globalData.groupchat_id; | |
| 4520 | + } | |
| 4521 | + //让商品带上房间号 | |
| 4522 | + if (th.data.sys_switch.is_skuroom_id == 1) { | |
| 4523 | + if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | |
| 4524 | + newd.room_id = getApp().globalData.room_id; | |
| 4525 | + } | |
| 4526 | + } else { | |
| 4527 | + if (newd.goods_id == getApp().globalData.room_goods_id) { | |
| 4528 | + newd.room_id = getApp().globalData.room_id; | |
| 4529 | + } | |
| 4530 | + } | |
| 4556 | 4531 | |
| 4557 | - //---是不是从收藏夹出来的--- | |
| 4558 | - if (th.data.c_guide_id) { | |
| 4559 | - newd['guide_id'] = th.data.c_guide_id; | |
| 4560 | - newd['guide_type'] = 2; | |
| 4532 | + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | |
| 4561 | 4533 | |
| 4562 | - } else { | |
| 4563 | - if (getApp().globalData.guide_id) { | |
| 4564 | - newd['guide_id'] = getApp().globalData.guide_id; | |
| 4565 | - newd['guide_type'] = 0; | |
| 4534 | + if (th.data.is_normal == 1) { | |
| 4535 | + var conf = th.data.bconfig; | |
| 4536 | + if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { | |
| 4537 | + var s_list = JSON.parse(conf.switch_list); | |
| 4566 | 4538 | |
| 4567 | - } | |
| 4568 | - } | |
| 4569 | - if(getApp().globalData.groupchat_id){ | |
| 4570 | - newd['groupchat_id'] = getApp().globalData.groupchat_id; | |
| 4571 | - } | |
| 4572 | - //让商品带上房间号 | |
| 4573 | - if (th.data.sys_switch.is_skuroom_id == 1) { | |
| 4574 | - if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | |
| 4575 | - newd.room_id = getApp().globalData.room_id; | |
| 4576 | - } | |
| 4577 | - } else { | |
| 4578 | - if (newd.goods_id == getApp().globalData.room_goods_id) { | |
| 4579 | - newd.room_id = getApp().globalData.room_id; | |
| 4580 | - } | |
| 4581 | - } | |
| 4539 | + var now = ut.gettimestamp(); | |
| 4582 | 4540 | |
| 4583 | - //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | |
| 4541 | + var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/'); | |
| 4542 | + var end = new Date(str); | |
| 4543 | + end = Date.parse(end) / 1000; | |
| 4584 | 4544 | |
| 4585 | - if (th.data.is_normal == 1) { | |
| 4586 | - var conf = th.data.bconfig; | |
| 4587 | - if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { | |
| 4588 | - var s_list = JSON.parse(conf.switch_list); | |
| 4545 | + //如果后台有开启等级价的功能 | |
| 4546 | + if (parseInt(s_list.rank_switch) == 2 && end > now) { | |
| 4547 | + var card_price = o[getApp().globalData.userInfo['card_field']]; | |
| 4548 | + //如果会员有等级价 | |
| 4549 | + if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | |
| 4550 | + && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | |
| 4551 | + newd.goods_price = card_price; | |
| 4552 | + } | |
| 4553 | + } | |
| 4554 | + } | |
| 4589 | 4555 | |
| 4590 | - var now = ut.gettimestamp(); | |
| 4556 | + //---如果是线下门店销售的时候--- | |
| 4557 | + if (!getApp().is_virtual(th.data.sele_g) && th.data.sales_rules >= 2 && !th.data.sele_g.whsle_id) { | |
| 4558 | + var pick = th.get_pick_from_list(th.data.sto_sele_id) | |
| 4591 | 4559 | |
| 4592 | - var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/'); | |
| 4593 | - var end = new Date(str); | |
| 4594 | - end = Date.parse(end) / 1000; | |
| 4560 | + th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { | |
| 4561 | + if (CanOutQty) { | |
| 4562 | + | |
| 4563 | + if (CanOutQty < e.data.goodsInputNum) { | |
| 4564 | + wx.showToast({ | |
| 4565 | + title: '库存不足!', | |
| 4566 | + icon: 'none', | |
| 4567 | + }); | |
| 4568 | + return false; | |
| 4569 | + } | |
| 4570 | + | |
| 4571 | + th.by_next_func(newd); | |
| 4572 | + } else { | |
| 4573 | + wx.showToast({ | |
| 4574 | + title: '库存不足!', | |
| 4575 | + icon: 'none', | |
| 4576 | + }); | |
| 4577 | + return false; | |
| 4578 | + } | |
| 4579 | + }) | |
| 4580 | + | |
| 4581 | + } else { | |
| 4582 | + if (o.store_count <= 0) { | |
| 4583 | + wx.showToast({ | |
| 4584 | + title: '库存已为空!', | |
| 4585 | + icon: 'none', | |
| 4586 | + }); | |
| 4587 | + return false; | |
| 4588 | + //return s.my_warnning("库存已为空!", 0, th); | |
| 4589 | + } | |
| 4590 | + | |
| 4591 | + if (o.store_count < e.data.goodsInputNum) { | |
| 4592 | + wx.showToast({ | |
| 4593 | + title: '库存不足!', | |
| 4594 | + icon: 'none', | |
| 4595 | + }); | |
| 4596 | + return false; | |
| 4597 | + //return s.my_warnning("库存不足!", 0, th); | |
| 4598 | + } | |
| 4595 | 4599 | |
| 4596 | - //如果后台有开启等级价的功能 | |
| 4597 | - if (parseInt(s_list.rank_switch) == 2 && end > now) { | |
| 4598 | - var card_price = o[getApp().globalData.userInfo['card_field']]; | |
| 4599 | - //如果会员有等级价 | |
| 4600 | - if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | |
| 4601 | - && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | |
| 4602 | - newd.goods_price = card_price; | |
| 4600 | + | |
| 4601 | + th.by_next_func(newd); | |
| 4603 | 4602 | } |
| 4603 | + return false; | |
| 4604 | + | |
| 4605 | + | |
| 4604 | 4606 | } |
| 4605 | - } | |
| 4606 | - } | |
| 4607 | 4607 | |
| 4608 | 4608 | |
| 4609 | - //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- | |
| 4610 | - if (th.data.prom_type == 9 && th.data.is_normal != 1) { | |
| 4611 | - newd.goods_price = th.data.prom_price; | |
| 4612 | - newd.prom_type = th.data.prom_type; | |
| 4613 | - newd.prom_id = th.data.prom_id; | |
| 4614 | - //newd.kt_type = th.data.prom_act.kttype; //开团类型 | |
| 4615 | - newd.is_pt_tz = 0; | |
| 4616 | - //th.data.sto_sele_distr=1; //直接用自提的方式提交 | |
| 4617 | - if (newd.kt_type > 1) { | |
| 4618 | - newd.is_pt_tz = 1; //开团类型 | |
| 4609 | + //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- | |
| 4610 | + if (th.data.prom_type == 9 && th.data.is_normal != 1) { | |
| 4611 | + newd.goods_price = th.data.prom_price; | |
| 4612 | + newd.prom_type = th.data.prom_type; | |
| 4613 | + newd.prom_id = th.data.prom_id; | |
| 4614 | + //newd.kt_type = th.data.prom_act.kttype; //开团类型 | |
| 4615 | + newd.is_pt_tz = 0; | |
| 4616 | + //th.data.sto_sele_distr=1; //直接用自提的方式提交 | |
| 4617 | + if (newd.kt_type > 1) { | |
| 4618 | + newd.is_pt_tz = 1; //开团类型 | |
| 4619 | + } | |
| 4620 | + if (newd.kt_type == 3) { | |
| 4621 | + th.data.sto_sele_distr = 1; | |
| 4622 | + } | |
| 4623 | + | |
| 4624 | + } | |
| 4625 | + | |
| 4626 | + // else if (th.data.prom_type == 3) { | |
| 4627 | + // newd.prom_type = 0; | |
| 4628 | + // newd.prom_id = 0; | |
| 4629 | + // } | |
| 4630 | + | |
| 4631 | + th.by_next_func(newd); | |
| 4619 | 4632 | } |
| 4620 | - if (newd.kt_type == 3) { | |
| 4621 | - th.data.sto_sele_distr = 1; | |
| 4633 | + | |
| 4634 | + | |
| 4635 | + ) | |
| 4636 | + }, | |
| 4637 | + by_next_func(newd){ | |
| 4638 | + var th=this; | |
| 4639 | + newd['pick_name'] = th.data.sto_sele_name; | |
| 4640 | + newd['pick_dis'] = th.data.sto_sele_distr; | |
| 4641 | + newd['is_normal'] = th.data.is_normal; | |
| 4642 | + | |
| 4643 | + if (newd['is_normal']) { | |
| 4644 | + newd['is_pd_normal'] = 1; | |
| 4645 | + //判断一下有没有全局优惠活动 | |
| 4646 | + th.buyNow(newd); | |
| 4647 | + } | |
| 4648 | + else { | |
| 4649 | + // 点击立即参团 | |
| 4650 | + th.buyNow_pt(newd); | |
| 4651 | + } | |
| 4652 | + }, | |
| 4653 | + | |
| 4654 | + //统一一下获取线下库存的函数 | |
| 4655 | + async check_CanOutQty(goodsinfo, item, func) { | |
| 4656 | + | |
| 4657 | + var sales_rules = this.data.sales_rules; | |
| 4658 | + | |
| 4659 | + var lock_rq = { | |
| 4660 | + store_id: os.stoid, | |
| 4661 | + wareId: goodsinfo.goods_id, | |
| 4662 | + pageSize: 1000 | |
| 4663 | + }; | |
| 4664 | + | |
| 4665 | + if (sales_rules == 2) { | |
| 4666 | + lock_rq.storageId = item.pickup_id | |
| 4667 | + } else { | |
| 4668 | + lock_rq.appoint_pick_keyid = encodeURIComponent(this.data.appoint_pick_keyid) | |
| 4669 | + } | |
| 4670 | + | |
| 4671 | + var lock = 0; | |
| 4672 | + var CanOutQty = 0; | |
| 4673 | + var plist = null; | |
| 4674 | + //先读取门店的lock | |
| 4675 | + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
| 4676 | + data: lock_rq | |
| 4677 | + }).then(res => { | |
| 4678 | + if (res.data.code == 0 && res.data.data.total > 0) { | |
| 4679 | + for (var i in res.data.data.pageData) | |
| 4680 | + lock += res.data.data.pageData[i].outQty; | |
| 4622 | 4681 | } |
| 4682 | + }) | |
| 4623 | 4683 | |
| 4684 | + var sto_req = { | |
| 4685 | + wareIds: encodeURIComponent(goodsinfo.erpwareid), | |
| 4686 | + storeId: os.stoid | |
| 4687 | + } | |
| 4688 | + if (sales_rules == 2) { | |
| 4689 | + sto_req.storageNos = item.pickup_no | |
| 4690 | + } else { | |
| 4691 | + sto_req.storageIds = encodeURIComponent(this.data.appoint_pick_keyid) | |
| 4624 | 4692 | } |
| 4625 | 4693 | |
| 4626 | - // else if (th.data.prom_type == 3) { | |
| 4627 | - // newd.prom_type = 0; | |
| 4628 | - // newd.prom_id = 0; | |
| 4629 | - // } | |
| 4630 | 4694 | |
| 4631 | - newd['pick_name'] = th.data.sto_sele_name; | |
| 4632 | - newd['pick_dis'] = th.data.sto_sele_distr; | |
| 4633 | - newd['is_normal'] = th.data.is_normal; | |
| 4634 | 4695 | |
| 4635 | - if (newd['is_normal']) { | |
| 4636 | - newd['is_pd_normal'] = 1; | |
| 4637 | - //判断一下有没有全局优惠活动 | |
| 4638 | - th.buyNow(newd); | |
| 4696 | + //读取线下的门店库存 | |
| 4697 | + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
| 4698 | + data: sto_req | |
| 4699 | + }).then(res => { | |
| 4700 | + if (res.data.code == 0 && res.data.data.total > 0) { | |
| 4701 | + plist = res.data.data.pageData[0]; | |
| 4702 | + } | |
| 4703 | + }) | |
| 4704 | + | |
| 4705 | + if (plist && plist.CanOutQty - lock > 0) { | |
| 4706 | + CanOutQty = plist.CanOutQty - lock; | |
| 4639 | 4707 | } |
| 4640 | - else { | |
| 4641 | - // 点击立即参团 | |
| 4642 | - th.buyNow_pt(newd); | |
| 4643 | - }; | |
| 4644 | - }) | |
| 4645 | - }, | |
| 4708 | + | |
| 4709 | + if (func) func(CanOutQty); | |
| 4710 | + | |
| 4711 | + }, | |
| 4712 | + | |
| 4713 | + | |
| 4646 | 4714 | //----------立即购买_pt----------- |
| 4647 | 4715 | buyNow_pt: function (e) { |
| 4648 | 4716 | s.set_b_now(e); | ... | ... |
packageC/pages/presell/goodsInfo/goodsInfo.wxml
| ... | ... | @@ -194,8 +194,7 @@ |
| 194 | 194 | <view class="no_store" wx:if="{{def_pick_store && def_pick_store.is_no_dis}}"> |
| 195 | 195 | (配送不匹配2) |
| 196 | 196 | </view> |
| 197 | - <view class="no_store" wx:elif="{{def_pick_store && !def_pick_store.CanOutQty | |
| 198 | - && !filters.is_virtual_gd(sele_g.is_virtual) && sales_rules>=2 && prom_type==0}}"> | |
| 197 | + <view class="no_store" wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && !filters.is_virtual_gd(sele_g.is_virtual) && sales_rules>=2 && prom_type==0}}"> | |
| 199 | 198 | (库存不足) |
| 200 | 199 | </view> |
| 201 | 200 | </block> |
| ... | ... | @@ -631,8 +630,7 @@ |
| 631 | 630 | <view wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">(库存不足)</view> |
| 632 | 631 | <block wx:else> |
| 633 | 632 | <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配1)</view> |
| 634 | - <view wx:elif="{{def_pick_store && !def_pick_store.CanOutQty | |
| 635 | - && !filters.is_virtual_gd(sele_g.is_virtual) && sales_rules>=2 && prom_type==0}}"> | |
| 633 | + <view wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && !filters.is_virtual_gd(sele_g.is_virtual) && sales_rules>=2 && prom_type==0}}"> | |
| 636 | 634 | (库存不足) |
| 637 | 635 | </view> |
| 638 | 636 | </block> | ... | ... |
packageE/pages/cart/cart2/cart2.js
| ... | ... | @@ -3989,6 +3989,22 @@ Page({ |
| 3989 | 3989 | } |
| 3990 | 3990 | |
| 3991 | 3991 | |
| 3992 | + var mo_num=getApp().get_limit_qty(th.data.bn_goods); | |
| 3993 | + var steep=getApp().get_limit_qty(th.data.bn_goods,0,1); | |
| 3994 | + | |
| 3995 | + if ([0,3,5,7,10].indexOf(goods.prom_type)>=-1){ | |
| 3996 | + if(mo_num>goods.goods_num){ | |
| 3997 | + getApp().confirmBox(goods.goods_name + "的未到达起订数量"); | |
| 3998 | + th.data.is_summit_ing = 0; | |
| 3999 | + return false; | |
| 4000 | + } | |
| 4001 | + if(steep>1 && (goods.goods_num-mo_num)%steep!=0 ){ | |
| 4002 | + getApp().confirmBox(goods.goods_name + "的购买的数量不是起订量的倍数"); | |
| 4003 | + th.data.is_summit_ing = 0; | |
| 4004 | + return false; | |
| 4005 | + } | |
| 4006 | + } | |
| 4007 | + | |
| 3992 | 4008 | //如果不立即购买或者秒杀,如果是线下库存购买的时候 |
| 3993 | 4009 | if (goods.prom_type != 1 && goods.prom_type != 6 && goods.prom_type != 2 |
| 3994 | 4010 | && th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id && !getApp().is_virtual(th.data.bn_goods)) { |
| ... | ... | @@ -4113,7 +4129,6 @@ Page({ |
| 4113 | 4129 | |
| 4114 | 4130 | var order_prom_list_cart = th.data.order_prom_list_cart; |
| 4115 | 4131 | |
| 4116 | - | |
| 4117 | 4132 | //--组装推送数据-- |
| 4118 | 4133 | for (var i = 0; i < order_prom_list_cart.length; i++) { |
| 4119 | 4134 | var t_item = order_prom_list_cart[i]; |
| ... | ... | @@ -4336,8 +4351,26 @@ Page({ |
| 4336 | 4351 | check_map[txt] = 1; |
| 4337 | 4352 | } |
| 4338 | 4353 | |
| 4339 | - //如果不立即购买或者秒杀,如果是线下库存购买的时候 | |
| 4340 | - if (goods.prom_type == 0 && th.data.sales_rules >= 2 && !g_item.whsle_id && !getApp().is_virtual(g_item) ) { | |
| 4354 | + goods.prom_type=parseInt(goods.prom_type+''); | |
| 4355 | + var mo_num=getApp().get_limit_qty(g_item); | |
| 4356 | + var steep=getApp().get_limit_qty(g_item,0,1); | |
| 4357 | + | |
| 4358 | + if ([0,3,5,7,10].indexOf(goods.prom_type)>=-1){ | |
| 4359 | + if(mo_num>goods.goods_num){ | |
| 4360 | + getApp().confirmBox(goods.goods_name + "的未到达起订数量"); | |
| 4361 | + th.data.is_summit_ing = 0; | |
| 4362 | + return false; | |
| 4363 | + } | |
| 4364 | + if(steep>1 && (goods.goods_num-mo_num)%steep!=0 ){ | |
| 4365 | + getApp().confirmBox(goods.goods_name + "的购买的数量不是起订量的倍数"); | |
| 4366 | + th.data.is_summit_ing = 0; | |
| 4367 | + return false; | |
| 4368 | + } | |
| 4369 | + | |
| 4370 | + } | |
| 4371 | + | |
| 4372 | + //如果不立即购买或者秒杀,如果是线下库存购买的时候 | |
| 4373 | + if ([0,3,5,7,10].indexOf(goods.prom_type)>=-1 && th.data.sales_rules >= 2 && !g_item.whsle_id && !getApp().is_virtual(g_item) ) { | |
| 4341 | 4374 | var isok = 1; |
| 4342 | 4375 | await th.check_store_num(goods.goods_id, t_item.pickup_id, goods.goods_num, function (res) { |
| 4343 | 4376 | isok = res; | ... | ... |
pages/activity/pind_list/pind_list.js
| ... | ... | @@ -163,6 +163,39 @@ Page({ |
| 163 | 163 | if (plist.length <= 0) { |
| 164 | 164 | getApp().showWarning("没有更多数据"); |
| 165 | 165 | th.data.ismore = 0; |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + //没有数据切换 | |
| 170 | + if (e.data.currentPage == 1 && this.data.type == 1) { | |
| 171 | + | |
| 172 | + | |
| 173 | + e.data.currentPage=1; | |
| 174 | + i = "/api/weshop/teamlist/pageteam/0?page=" + e.data.currentPage; | |
| 175 | + await getApp().request.promiseGet(i, { | |
| 176 | + isShowLoading: 0, | |
| 177 | + data: { | |
| 178 | + store_id: os.stoid, | |
| 179 | + is_end: 0, | |
| 180 | + is_show: 1, | |
| 181 | + user_id:getApp().globalData.user_id, | |
| 182 | + } | |
| 183 | + }).then(res => { | |
| 184 | + plist = res.data.data.pageData; | |
| 185 | + }); | |
| 186 | + | |
| 187 | + if(plist){ | |
| 188 | + setTimeout(function () { | |
| 189 | + th.data.ismore = 1; | |
| 190 | + th.setData({ | |
| 191 | + type: 0 | |
| 192 | + }); | |
| 193 | + th.requestSalelist(); | |
| 194 | + }, 1000); | |
| 195 | + } | |
| 196 | + | |
| 197 | + } | |
| 198 | + | |
| 166 | 199 | } |
| 167 | 200 | //--循环读取接口--- |
| 168 | 201 | for (var i = 0; i < plist.length; i++) { | ... | ... |
pages/cart/cart/cart.js
| ... | ... | @@ -1612,9 +1612,16 @@ Page({ |
| 1612 | 1612 | } |
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | + var add_num=1; | |
| 1616 | + var mo_num=getApp().get_limit_qty(a); | |
| 1617 | + var steep=getApp().get_limit_qty(a,0,1); | |
| 1618 | + if(steep>1){ | |
| 1619 | + add_num=steep; | |
| 1620 | + } | |
| 1621 | + | |
| 1615 | 1622 | |
| 1616 | 1623 | var e = { |
| 1617 | - goods_num: a.goods_num + 1, | |
| 1624 | + goods_num: a.goods_num + add_num, | |
| 1618 | 1625 | id: a.id, |
| 1619 | 1626 | goods_id: a.goods_id, |
| 1620 | 1627 | store_id: oo.stoid |
| ... | ... | @@ -1640,16 +1647,26 @@ Page({ |
| 1640 | 1647 | } |
| 1641 | 1648 | |
| 1642 | 1649 | |
| 1650 | + var add_num=1; | |
| 1651 | + var mo_num=getApp().get_limit_qty(a); | |
| 1652 | + var steep=getApp().get_limit_qty(a,0,1); | |
| 1653 | + if(steep>1){ | |
| 1654 | + add_num=steep; | |
| 1655 | + } | |
| 1643 | 1656 | |
| 1644 | - if (1 != a.goods_num) { | |
| 1645 | - var e = { | |
| 1646 | - goods_num: a.goods_num - 1, | |
| 1647 | - id: a.id, | |
| 1648 | - goods_id: a.goods_id, | |
| 1649 | - store_id: oo.stoid | |
| 1650 | - }; | |
| 1651 | - this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); | |
| 1657 | + var e = { | |
| 1658 | + goods_num: a.goods_num - add_num, | |
| 1659 | + id: a.id, | |
| 1660 | + goods_id: a.goods_id, | |
| 1661 | + store_id: oo.stoid | |
| 1662 | + }; | |
| 1663 | + | |
| 1664 | + if(e.goods_num<=0){ | |
| 1665 | + this.data.up_dating = 0; | |
| 1666 | + return false; | |
| 1652 | 1667 | } |
| 1668 | + this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); | |
| 1669 | + | |
| 1653 | 1670 | }, |
| 1654 | 1671 | |
| 1655 | 1672 | |
| ... | ... | @@ -1668,7 +1685,10 @@ Page({ |
| 1668 | 1685 | var e = a; |
| 1669 | 1686 | var th = this; |
| 1670 | 1687 | |
| 1671 | - if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { | |
| 1688 | + | |
| 1689 | + var mo_num=getApp().get_limit_qty(e); | |
| 1690 | + | |
| 1691 | + if (a = isNaN(t.detail.value) || t.detail.value < mo_num ? mo_num : parseInt(t.detail.value)) { | |
| 1672 | 1692 | var s = { |
| 1673 | 1693 | goods_num: a, |
| 1674 | 1694 | goods_id: e.service_id, |
| ... | ... | @@ -1754,6 +1774,33 @@ Page({ |
| 1754 | 1774 | }, |
| 1755 | 1775 | |
| 1756 | 1776 | |
| 1777 | + click_set_limit(gd_info,pitems,item){ | |
| 1778 | + var th=this; | |
| 1779 | + var mo_num=getApp().get_limit_qty(gd_info); | |
| 1780 | + var steep=getApp().get_limit_qty(gd_info,0,1); | |
| 1781 | + if(gd_info.is_integral_normal || gd_info.is_pd_normal || [0,3,5,7,10].indexOf(gd_info.prom_type) > -1){ | |
| 1782 | + | |
| 1783 | + var ue = { | |
| 1784 | + goods_num: gd_info.goods_num,store_id: oo.stoid, | |
| 1785 | + id: gd_info.id,goods_id: gd_info.goods_id | |
| 1786 | + }; | |
| 1787 | + var up_num=0; | |
| 1788 | + if(mo_num>gd_info.goods_num){ | |
| 1789 | + up_num=mo_num; | |
| 1790 | + } | |
| 1791 | + if(gd_info.goods_num>mo_num && (gd_info.goods_num-mo_num)%steep!=0 && steep>1){ | |
| 1792 | + up_num=mo_num+ parseInt((gd_info.goods_num-mo_num)/steep)*steep+steep; | |
| 1793 | + } | |
| 1794 | + if(up_num){ | |
| 1795 | + ue.goods_num=up_num; | |
| 1796 | + th.update_cart(ue, pitems, item); | |
| 1797 | + var txt1 = "requestData[" + pitems + "].goods[" + item + "].goods_num"; | |
| 1798 | + th.setData({[txt1]:up_num }) | |
| 1799 | + } | |
| 1800 | + } | |
| 1801 | + }, | |
| 1802 | + | |
| 1803 | + | |
| 1757 | 1804 | //---------------全选,全选的时候要判断是否门店的匹配方式一致-------------- |
| 1758 | 1805 | checkAll: async function () { |
| 1759 | 1806 | var e = this, |
| ... | ... | @@ -1792,11 +1839,16 @@ Page({ |
| 1792 | 1839 | [txt]: 0, |
| 1793 | 1840 | }); |
| 1794 | 1841 | } |
| 1842 | + | |
| 1795 | 1843 | var fir = 0; |
| 1796 | 1844 | for (var j = 0; j < item.length; j++) { |
| 1797 | 1845 | if (item[j].is_gift) continue; |
| 1798 | - | |
| 1799 | 1846 | var obj = JSON.parse(JSON.stringify(item[j])); |
| 1847 | + //-- 判断起购数量 -- | |
| 1848 | + if(!e.data.checkAllToggle){ | |
| 1849 | + th.click_set_limit(obj,i,j); | |
| 1850 | + } | |
| 1851 | + | |
| 1800 | 1852 | //计算之前先移除组合购的计算 |
| 1801 | 1853 | if (obj.prom_type == 7) |
| 1802 | 1854 | zh_calc.remove_zhprom(dda, i, obj); |
| ... | ... | @@ -1884,7 +1936,7 @@ Page({ |
| 1884 | 1936 | |
| 1885 | 1937 | // if (!e.data.checkAllToggle) { |
| 1886 | 1938 | //多门店优惠促销次数控制 |
| 1887 | - if(dda[i].pro_off){ | |
| 1939 | + if(dda[i].pro_off || e.data.checkAllToggle){ | |
| 1888 | 1940 | var txt = "requestData[" + i + "].selected"; |
| 1889 | 1941 | e.setData({ |
| 1890 | 1942 | [txt]: 0, |
| ... | ... | @@ -2041,8 +2093,10 @@ Page({ |
| 2041 | 2093 | for (var i = 0; i < item.length; i++) { |
| 2042 | 2094 | let pro_off1=false |
| 2043 | 2095 | var txt = "requestData[" + pitems + "].goods[" + i + "].selected"; |
| 2044 | - | |
| 2045 | 2096 | var gd_info = item[i]; |
| 2097 | + | |
| 2098 | + if(!sele) th.click_set_limit(gd_info,pitems,i) | |
| 2099 | + | |
| 2046 | 2100 | 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 | 2101 | var ob = {}; |
| 2048 | 2102 | await th.check_down_line_next(gd_info, pitems, i, gd_info.erpwareid, function (res) { |
| ... | ... | @@ -2227,45 +2281,56 @@ Page({ |
| 2227 | 2281 | var gd_info = a; |
| 2228 | 2282 | |
| 2229 | 2283 | var erpwareid = gd_info.erpwareid; |
| 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 | - var ob = {}; | |
| 2232 | - await th.check_down_line_next(gd_info, pitems, item, erpwareid, function (res) { | |
| 2233 | - ob = res; | |
| 2234 | - }); | |
| 2235 | 2284 | |
| 2236 | - if (ob.code == -1) { | |
| 2237 | - | |
| 2238 | - wx.showToast({ | |
| 2239 | - title: '购买数量超出商品库存', | |
| 2240 | - icon: 'none', | |
| 2241 | - }); | |
| 2285 | + //-- 如果是选中的时候 -- | |
| 2286 | + if(!a.selected){ | |
| 2242 | 2287 | |
| 2243 | - return false; | |
| 2244 | - } else { | |
| 2245 | - if (th.data.sales_rules == 3) { | |
| 2246 | - var goods_id = gd_info.goods_id; | |
| 2247 | - var num = 0; | |
| 2288 | + //-- 专门来设置商品订购数量 -- | |
| 2289 | + th.click_set_limit(gd_info,pitems,item) | |
| 2290 | + if (!getApp().is_virtual(gd_info) && th.data.sales_rules >= 2 | |
| 2291 | + && !gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1 ) { | |
| 2248 | 2292 | |
| 2249 | - for (let i = 0; i < th.data.requestData.length; i++) { | |
| 2250 | - if (pitems == i) continue; | |
| 2251 | - var it = th.data.requestData[i].goods.find((e) => { | |
| 2252 | - return e.goods_id == goods_id; | |
| 2253 | - }) | |
| 2254 | - if (it && it.selected) num += it.goods_num | |
| 2255 | - } | |
| 2293 | + var ob = {}; | |
| 2294 | + await th.check_down_line_next(gd_info, pitems, item, erpwareid, function (res) { | |
| 2295 | + ob = res; | |
| 2296 | + }); | |
| 2297 | + if (ob.code == -1) { | |
| 2256 | 2298 | |
| 2257 | - if (num > ob.CanOutQty) { | |
| 2258 | 2299 | wx.showToast({ |
| 2259 | 2300 | title: '购买数量超出商品库存', |
| 2260 | 2301 | icon: 'none', |
| 2261 | 2302 | }); |
| 2262 | 2303 | |
| 2263 | 2304 | return false; |
| 2305 | + } else { | |
| 2306 | + if (th.data.sales_rules == 3) { | |
| 2307 | + var goods_id = gd_info.goods_id; | |
| 2308 | + var num = 0; | |
| 2309 | + | |
| 2310 | + for (let i = 0; i < th.data.requestData.length; i++) { | |
| 2311 | + if (pitems == i) continue; | |
| 2312 | + var it = th.data.requestData[i].goods.find((e) => { | |
| 2313 | + return e.goods_id == goods_id; | |
| 2314 | + }) | |
| 2315 | + if (it && it.selected) num += it.goods_num | |
| 2316 | + } | |
| 2317 | + | |
| 2318 | + if (num > ob.CanOutQty) { | |
| 2319 | + wx.showToast({ | |
| 2320 | + title: '购买数量超出商品库存', | |
| 2321 | + icon: 'none', | |
| 2322 | + }); | |
| 2323 | + | |
| 2324 | + return false; | |
| 2325 | + } | |
| 2326 | + } | |
| 2264 | 2327 | } |
| 2265 | - } | |
| 2328 | + | |
| 2266 | 2329 | } |
| 2267 | 2330 | |
| 2268 | 2331 | } |
| 2332 | + | |
| 2333 | + | |
| 2269 | 2334 | let pro_off=false |
| 2270 | 2335 | //判断多店优惠促销次数控制 |
| 2271 | 2336 | if (th.data.requestData.length>1) { |
| ... | ... | @@ -2536,6 +2601,32 @@ Page({ |
| 2536 | 2601 | user_id = getApp().globalData.user_id; |
| 2537 | 2602 | |
| 2538 | 2603 | function normal_check(store_count, goodsinfo, wareIds) { |
| 2604 | + | |
| 2605 | + | |
| 2606 | + // getApp().my_warnning('购买数量超出商品库存', 0, th); | |
| 2607 | + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2608 | + //-- 要判断是不是起订量不购 -- | |
| 2609 | + if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ | |
| 2610 | + var mo_num=getApp().get_limit_qty(goodsinfo); | |
| 2611 | + var steep=getApp().get_limit_qty(goodsinfo,0,1); | |
| 2612 | + if(mo_num>1 && t.goods_num<mo_num){ | |
| 2613 | + wx.showToast({ | |
| 2614 | + title: '购买数量小于商品的起订量', | |
| 2615 | + icon: 'none', | |
| 2616 | + }); | |
| 2617 | + t.goods_num =0; | |
| 2618 | + } | |
| 2619 | + if(steep>1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0 ){ | |
| 2620 | + | |
| 2621 | + wx.showToast({ | |
| 2622 | + title: '购买数量必须是起订量的倍数', | |
| 2623 | + icon: 'none', | |
| 2624 | + }); | |
| 2625 | + t.goods_num =mo_num+parseInt((t.goods_num-mo_num)/steep+'')*steep+steep; | |
| 2626 | + } | |
| 2627 | + } | |
| 2628 | + | |
| 2629 | + | |
| 2539 | 2630 | //--- 看一下是不是线下库存 --- |
| 2540 | 2631 | if (!getApp().is_virtual(goodsinfo) && th.data.sales_rules >= 2 && !goodsinfo.whsle_id) { |
| 2541 | 2632 | th.check_down_line(t, pitem, item, wareIds); |
| ... | ... | @@ -2545,8 +2636,6 @@ Page({ |
| 2545 | 2636 | title: '购买数量超出商品库存', |
| 2546 | 2637 | icon: 'none', |
| 2547 | 2638 | }); |
| 2548 | - // getApp().my_warnning('购买数量超出商品库存', 0, th); | |
| 2549 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2550 | 2639 | e.setData({ |
| 2551 | 2640 | [txt]: store_count |
| 2552 | 2641 | }); |
| ... | ... | @@ -2620,7 +2709,29 @@ Page({ |
| 2620 | 2709 | }); |
| 2621 | 2710 | e.doCheckAll(); |
| 2622 | 2711 | |
| 2623 | - t.goods_num = cbuy > 0 ? cbuy : limit, | |
| 2712 | + t.goods_num = cbuy > 0 ? cbuy : limit; | |
| 2713 | + | |
| 2714 | + if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ | |
| 2715 | + var mo_num=getApp().get_limit_qty(goodsinfo); | |
| 2716 | + var steep=getApp().get_limit_qty(goodsinfo,0,1); | |
| 2717 | + if(mo_num>1 && t.goods_num<mo_num){ | |
| 2718 | + wx.showToast({ | |
| 2719 | + title: '购买数量小于商品的起订量', | |
| 2720 | + icon: 'none', | |
| 2721 | + }); | |
| 2722 | + t.goods_num=0; | |
| 2723 | + | |
| 2724 | + } | |
| 2725 | + if(steep>1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0 ){ | |
| 2726 | + | |
| 2727 | + wx.showToast({ | |
| 2728 | + title: '购买数量必须是起订量的倍数', | |
| 2729 | + icon: 'none', | |
| 2730 | + }); | |
| 2731 | + | |
| 2732 | + t.goods_num=mo_num+parseInt((t.goods_num-mo_num)/steep+'')*steep | |
| 2733 | + } | |
| 2734 | + } | |
| 2624 | 2735 | // t.goods_num = cbuy > 0 ? cbuy : 0, |
| 2625 | 2736 | e.update_cart(t, pitem, item); |
| 2626 | 2737 | return false; |
| ... | ... | @@ -3370,6 +3481,38 @@ Page({ |
| 3370 | 3481 | } |
| 3371 | 3482 | glist += i_arr[j].goods_id + ","; |
| 3372 | 3483 | ab = 1; |
| 3484 | + | |
| 3485 | + //判断商品的起订数量 | |
| 3486 | + var mo_num=getApp().get_limit_qty(i_arr[j]); | |
| 3487 | + var steep=getApp().get_limit_qty(i_arr[j],0,1); | |
| 3488 | + var py_type= parseInt(i_arr[j].prom_type+''); | |
| 3489 | + | |
| 3490 | + if([0,3,5,7,10].indexOf(py_type)>-1){ | |
| 3491 | + | |
| 3492 | + if(mo_num>i_arr[j].goods_num){ | |
| 3493 | + getApp().confirmBox(i_arr[j].goods_name + "的未到达起订数量"); | |
| 3494 | + wx.hideLoading(); | |
| 3495 | + return false; | |
| 3496 | + } | |
| 3497 | + if(steep>1 && (i_arr[j].goods_num-mo_num)%steep!=0 ){ | |
| 3498 | + getApp().confirmBox(i_arr[j].goods_name + "的购买的数量不是起订量的倍数"); | |
| 3499 | + var num=mo_num+ parseInt((i_arr[j].goods_num-mo_num)/steep)*steep+steep; | |
| 3500 | + var e = { | |
| 3501 | + goods_num: num, | |
| 3502 | + id: i_arr[j].id, | |
| 3503 | + goods_id: i_arr[j].goods_id, | |
| 3504 | + store_id: oo.stoid | |
| 3505 | + }; | |
| 3506 | + | |
| 3507 | + th.postCardList(e, j, i); | |
| 3508 | + | |
| 3509 | + wx.hideLoading(); | |
| 3510 | + return false; | |
| 3511 | + } | |
| 3512 | + | |
| 3513 | + } | |
| 3514 | + | |
| 3515 | + | |
| 3373 | 3516 | |
| 3374 | 3517 | //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算,赠品不要进行调用线下库存--- |
| 3375 | 3518 | 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 || | ... | ... |
pages/cart/cart/cart.wxml
| ... | ... | @@ -42,6 +42,7 @@ |
| 42 | 42 | <!-- 门店底下的商品 --> |
| 43 | 43 | <view class="store"> |
| 44 | 44 | <view class="shmd_m"> |
| 45 | + | |
| 45 | 46 | <!-- 门店 --> |
| 46 | 47 | <icon wx:if="{{checkAllToggle||item.selected}}" class="order-raido flex-center" bindtap="check_th_all_item" data-pitems="{{pidx}}" |
| 47 | 48 | color="red" size="20" type="success"></icon> | ... | ... |
pages/goods/goodsInfo/buy_com_pop.wxml
| ... | ... | @@ -158,7 +158,7 @@ |
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | |
| 161 | - <block wx:elif="{{data.store_count<=0}}"> | |
| 161 | + <block wx:elif="{{data.store_count<(mo_num?mo_num:1)}}"> | |
| 162 | 162 | <view class="spec-cart-btn fs32" data-action="add" |
| 163 | 163 | style="background-color: #dcdcdc;color: #999">库存不足 |
| 164 | 164 | </view> | ... | ... |
pages/goods/goodsInfo/goodsInfo.js
| ... | ... | @@ -1102,6 +1102,8 @@ Page({ |
| 1102 | 1102 | }); |
| 1103 | 1103 | |
| 1104 | 1104 | |
| 1105 | + | |
| 1106 | + | |
| 1105 | 1107 | //获取统一条形码,普通商品和优惠促销的商品 |
| 1106 | 1108 | 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 | 1109 | |
| ... | ... | @@ -1109,6 +1111,7 @@ Page({ |
| 1109 | 1111 | //-- 更新默认购买的数量 --- |
| 1110 | 1112 | var mo_num=getApp().get_limit_qty(t.data.data); |
| 1111 | 1113 | ee.setData({goodsInputNum:mo_num}) |
| 1114 | + ee.setData({mo_num:mo_num}) | |
| 1112 | 1115 | |
| 1113 | 1116 | ee.get_sto(); |
| 1114 | 1117 | ee.get_sku(o.stoid, t.data.data, gid); |
| ... | ... | @@ -1194,6 +1197,7 @@ Page({ |
| 1194 | 1197 | setTimeout(()=> { |
| 1195 | 1198 | console.log('cccc'); |
| 1196 | 1199 | console.log(th.data.prom_type); |
| 1200 | + | |
| 1197 | 1201 | },500) |
| 1198 | 1202 | |
| 1199 | 1203 | |
| ... | ... | @@ -1205,11 +1209,8 @@ Page({ |
| 1205 | 1209 | console.log('aaaaaaaaaa'); |
| 1206 | 1210 | console.log(this.data.prom_type); |
| 1207 | 1211 | |
| 1208 | - this.data.enterAddressPage && (this.data.enterAddressPage = !1); | |
| 1209 | - | |
| 1210 | - | |
| 1211 | - | |
| 1212 | 1212 | |
| 1213 | + this.data.enterAddressPage && (this.data.enterAddressPage = !1); | |
| 1213 | 1214 | |
| 1214 | 1215 | |
| 1215 | 1216 | }, |
| ... | ... | @@ -1939,6 +1940,9 @@ Page({ |
| 1939 | 1940 | th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 |
| 1940 | 1941 | } |
| 1941 | 1942 | } |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1942 | 1946 | }) |
| 1943 | 1947 | }, |
| 1944 | 1948 | |
| ... | ... | @@ -2402,7 +2406,7 @@ Page({ |
| 2402 | 2406 | |
| 2403 | 2407 | var add_num=1; |
| 2404 | 2408 | var p_type=parseInt(this.data.prom_type) |
| 2405 | - if([1,2,4,6,8,9].indexOf(p_type)==-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1){ | |
| 2409 | + if([1,2,4,6,8,9].indexOf(p_type)==-1 || this.data.openSpecModal_inte_normal == 1 || this.data.is_normal == 1){ | |
| 2406 | 2410 | add_num=getApp().get_limit_qty(this.data.sele_g,0,1); |
| 2407 | 2411 | } |
| 2408 | 2412 | |
| ... | ... | @@ -2413,7 +2417,7 @@ Page({ |
| 2413 | 2417 | |
| 2414 | 2418 | var add_num=1; |
| 2415 | 2419 | var p_type=parseInt(this.data.prom_type) |
| 2416 | - if([1,2,4,6,8,9].indexOf(p_type)==-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1){ | |
| 2420 | + if([1,2,4,6,8,9].indexOf(p_type)==-1 || this.data.openSpecModal_inte_normal == 1 || this.data.is_normal == 1){ | |
| 2417 | 2421 | add_num=getApp().get_limit_qty(this.data.sele_g,0,1); |
| 2418 | 2422 | } |
| 2419 | 2423 | this.checkCartNum(this.data.goodsInputNum - add_num); |
| ... | ... | @@ -2440,6 +2444,8 @@ Page({ |
| 2440 | 2444 | //------检查数量是不是超出限购------ |
| 2441 | 2445 | checkCartNum: function (t) { |
| 2442 | 2446 | var th = this; |
| 2447 | + var mo_num=getApp().get_limit_qty(th.data.sele_g); | |
| 2448 | + var steep=getApp().get_limit_qty(th.data.sele_g,0,1); | |
| 2443 | 2449 | this.get_buy_num(this.data.sele_g, async function () { |
| 2444 | 2450 | |
| 2445 | 2451 | //--判断商品是否超出限购-- |
| ... | ... | @@ -2528,12 +2534,33 @@ Page({ |
| 2528 | 2534 | }); |
| 2529 | 2535 | // wx.showModal({title: '库存不足',}); |
| 2530 | 2536 | if (e < 0) e = 0; |
| 2537 | + | |
| 2538 | + //只有普通商品才有起购数 | |
| 2539 | + if([1,2,4,6,8,9].indexOf(p_type)==-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1){ | |
| 2540 | + if(e<mo_num) e=mo_num; | |
| 2541 | + if(e>mo_num && (e-mo_num)%steep!=0){ | |
| 2542 | + e=mo_num+ parseInt((e-mo_num)/steep)*steep; | |
| 2543 | + } | |
| 2544 | + } | |
| 2531 | 2545 | th.setData({ |
| 2532 | 2546 | goodsInputNum: e |
| 2533 | 2547 | }); |
| 2534 | 2548 | return false; |
| 2535 | 2549 | } |
| 2550 | + | |
| 2551 | + | |
| 2552 | + //var steep=getApp().get_limit_qty(th.data.sele_g,0,1); | |
| 2553 | + | |
| 2554 | + | |
| 2536 | 2555 | t > e || 0 == e ? t = e : t < 1 && (t = 1); |
| 2556 | + | |
| 2557 | + | |
| 2558 | + //只有普通商品才有起购数 | |
| 2559 | + if([1,2,4,6,8,9].indexOf(p_type)==-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1){ | |
| 2560 | + if(t<mo_num) t=mo_num; | |
| 2561 | + } | |
| 2562 | + | |
| 2563 | + | |
| 2537 | 2564 | th.setData({ |
| 2538 | 2565 | goodsInputNum: t |
| 2539 | 2566 | }); |
| ... | ... | @@ -4943,6 +4970,7 @@ Page({ |
| 4943 | 4970 | |
| 4944 | 4971 | var th = this; |
| 4945 | 4972 | var ind = parseInt(e.currentTarget.dataset.it); |
| 4973 | + var mo_num=getApp().get_limit_qty(this.data.sele_g); | |
| 4946 | 4974 | |
| 4947 | 4975 | //如果是拼单活动的普通购买 |
| 4948 | 4976 | if (ind == 1) { |
| ... | ... | @@ -4956,14 +4984,19 @@ Page({ |
| 4956 | 4984 | th.get_sto(1); |
| 4957 | 4985 | th.setData({ |
| 4958 | 4986 | is_normal: ind, |
| 4959 | - openSpecModal_pt: 1 | |
| 4987 | + openSpecModal_pt: 1, | |
| 4988 | + goodsInputNum: mo_num, | |
| 4989 | + mo_num:mo_num | |
| 4990 | + | |
| 4960 | 4991 | }); |
| 4961 | 4992 | } else { |
| 4962 | 4993 | th.get_sto(1); |
| 4963 | 4994 | th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { |
| 4964 | 4995 | th.setData({ |
| 4965 | 4996 | is_normal: ind, |
| 4966 | - openSpecModal_pt: 1 | |
| 4997 | + openSpecModal_pt: 1, | |
| 4998 | + goodsInputNum: mo_num, | |
| 4999 | + mo_num:mo_num | |
| 4967 | 5000 | }); |
| 4968 | 5001 | }); |
| 4969 | 5002 | } |
| ... | ... | @@ -4972,6 +5005,10 @@ Page({ |
| 4972 | 5005 | |
| 4973 | 5006 | if (th.data.is_normal) { |
| 4974 | 5007 | th.data.g_buy_num = new Map(); |
| 5008 | + th.setData({ | |
| 5009 | + goodsInputNum: mo_num, | |
| 5010 | + mo_num:mo_num | |
| 5011 | + }); | |
| 4975 | 5012 | } |
| 4976 | 5013 | |
| 4977 | 5014 | //拼单商品从这里进,先判断有没有买过商品, |
| ... | ... | @@ -8064,10 +8101,14 @@ Page({ |
| 8064 | 8101 | openSpecModel_Nor: function () { |
| 8065 | 8102 | this.data.g_buy_num = new Map(); |
| 8066 | 8103 | var th = this; |
| 8104 | + var mo_num=getApp().get_limit_qty(this.data.sele_g); | |
| 8105 | + | |
| 8067 | 8106 | this.setData({ |
| 8068 | 8107 | open_ind_store: 5, |
| 8069 | - goodsInputNum: 1 | |
| 8108 | + goodsInputNum: mo_num, | |
| 8109 | + mo_num:mo_num | |
| 8070 | 8110 | }); //拼团直接给4 |
| 8111 | + | |
| 8071 | 8112 | if (th.data.sku_g_pt) { |
| 8072 | 8113 | this.get_sto(1) |
| 8073 | 8114 | this.setData({ | ... | ... |
pages/goods/goodsInfo/goodsInfo.wxml
| ... | ... | @@ -1399,7 +1399,7 @@ |
| 1399 | 1399 | <block wx:else> |
| 1400 | 1400 | <!-- 如果是线下库存购买的时候,且是普通商品购买的时候 --> |
| 1401 | 1401 | <block wx:if="{{sales_rules>=2 && prom_type==0 && !sele_g.whsle_id && !filters.is_virtual_gd(sele_g.is_virtual) }}"> |
| 1402 | - <block wx:if="{{!def_pick_store.CanOutQty}}"> | |
| 1402 | + <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<mo_num }}"> | |
| 1403 | 1403 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 1404 | 1404 | 库存不足 |
| 1405 | 1405 | </view> |
| ... | ... | @@ -1415,7 +1415,7 @@ |
| 1415 | 1415 | </block> |
| 1416 | 1416 | <!-- 线上销售 --> |
| 1417 | 1417 | <block wx:else> |
| 1418 | - <block wx:if="{{sele_g.store_count<=0 && is_no_new}}"> | |
| 1418 | + <block wx:if="{{(sele_g.store_count<=0 || sele_g.store_count<mo_num ) && is_no_new}}"> | |
| 1419 | 1419 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 1420 | 1420 | 库存不足 |
| 1421 | 1421 | </view> | ... | ... |