Commit 2a85c32729f652e3f72d48f71304220b675d3ab2
1 parent
52418513
幸运购的优化
Showing
5 changed files
with
380 additions
and
166 deletions
packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | <block wx:if="{{is_normal==1}}"> |
| 26 | 26 | <view class="flex"> |
| 27 | 27 | <view class="spec-goods-stock">已售:{{sele_g.sales_sum}}</view> |
| 28 | - <block wx:if="{{sales_rules==2}}"> | |
| 28 | + <block wx:if="{{sales_rules>=2}}"> | |
| 29 | 29 | <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">可售:{{def_pick_store.CanOutQty}}</view> |
| 30 | 30 | <view class="spec-goods-stock" wx:else>可售:0</view> |
| 31 | 31 | </block> | ... | ... |
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
| ... | ... | @@ -444,7 +444,9 @@ Page({ |
| 444 | 444 | store_config: e, |
| 445 | 445 | sys_switch: json_d, |
| 446 | 446 | is_closecoupon: json_d.is_closecoupon, |
| 447 | - is_newsales_rules: json_d.is_newsales_rules | |
| 447 | + is_newsales_rules: json_d.is_newsales_rules, | |
| 448 | + appoint_pick_keyid: json_d.appoint_pick_keyid | |
| 449 | + | |
| 448 | 450 | }); |
| 449 | 451 | ee.init(gid); |
| 450 | 452 | //------几人评价------- |
| ... | ... | @@ -586,31 +588,45 @@ Page({ |
| 586 | 588 | var that = this, th = this; |
| 587 | 589 | getApp().getConfig2(function (e) { |
| 588 | 590 | var sales_rules = e.sales_rules; |
| 589 | - if (sales_rules == 2) { | |
| 591 | + if (sales_rules >= 2) { | |
| 590 | 592 | getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () { |
| 591 | 593 | var lock = 0, plist = null; |
| 592 | 594 | var gd = that.data.fir_goods; |
| 593 | 595 | //先读取门店的lock,采用链式写法,少用await |
| 594 | - getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
| 595 | - data: { store_id: os.stoid, wareId: that.data.fir_goods.goods_id, storageId: ee.pickup_id, pageSize: 1000 } | |
| 596 | - }).then(res => { | |
| 597 | - if (res.data.code == 0 && res.data.data.total > 0) { | |
| 598 | - for (var i in res.data.data.pageData) | |
| 599 | - lock += res.data.data.pageData[i].outQty | |
| 600 | - } | |
| 601 | - //---通过接口获取门店的线下库存信息-- | |
| 602 | - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
| 603 | - data: { storageNos: ee.pickup_no, wareIds: encodeURIComponent(th.data.data.erpwareid), storeId: os.stoid } | |
| 604 | - }) | |
| 605 | - }).then(res => { | |
| 606 | - if (res.data.code == 0 && res.data.data.total > 0) { | |
| 607 | - plist = res.data.data.pageData[0]; | |
| 608 | - } | |
| 609 | - if (plist && plist.CanOutQty - lock > 0) { | |
| 610 | - ee.CanOutQty = plist.CanOutQty - lock; | |
| 611 | - } else { | |
| 612 | - ee.CanOutQty = 0; | |
| 613 | - } | |
| 596 | + | |
| 597 | + // getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
| 598 | + // data: { store_id: os.stoid, wareId: that.data.fir_goods.goods_id, storageId: ee.pickup_id, pageSize: 1000 } | |
| 599 | + // }).then(res => { | |
| 600 | + // if (res.data.code == 0 && res.data.data.total > 0) { | |
| 601 | + // for (var i in res.data.data.pageData) | |
| 602 | + // lock += res.data.data.pageData[i].outQty | |
| 603 | + // } | |
| 604 | + // //---通过接口获取门店的线下库存信息-- | |
| 605 | + // return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
| 606 | + // data: { storageNos: ee.pickup_no, wareIds: encodeURIComponent(th.data.data.erpwareid), storeId: os.stoid } | |
| 607 | + // }) | |
| 608 | + // }).then(res => { | |
| 609 | + // if (res.data.code == 0 && res.data.data.total > 0) { | |
| 610 | + // plist = res.data.data.pageData[0]; | |
| 611 | + // } | |
| 612 | + // if (plist && plist.CanOutQty - lock > 0) { | |
| 613 | + // ee.CanOutQty = plist.CanOutQty - lock; | |
| 614 | + // } else { | |
| 615 | + // ee.CanOutQty = 0; | |
| 616 | + // } | |
| 617 | + // //--给门店赋值线下库存-- | |
| 618 | + // that.data.fir_def_store = ee; | |
| 619 | + // that.setData({ | |
| 620 | + // def_pick_store: ee, | |
| 621 | + // sto_sele_name: ee.pickup_name, | |
| 622 | + // sto_sele_id: ee.pickup_id, | |
| 623 | + // sto_sele_distr: ee.distr_type | |
| 624 | + // }) | |
| 625 | + // }) | |
| 626 | + | |
| 627 | + //最新的获取线下门店库存 | |
| 628 | + th.check_CanOutQty(gd, ee, function (CanOutQty) { | |
| 629 | + ee.CanOutQty = CanOutQty; | |
| 614 | 630 | //--给门店赋值线下库存-- |
| 615 | 631 | that.data.fir_def_store = ee; |
| 616 | 632 | that.setData({ |
| ... | ... | @@ -620,6 +636,8 @@ Page({ |
| 620 | 636 | sto_sele_distr: ee.distr_type |
| 621 | 637 | }) |
| 622 | 638 | }) |
| 639 | + | |
| 640 | + | |
| 623 | 641 | }) |
| 624 | 642 | } else { |
| 625 | 643 | that.data.fir_def_store = ee; |
| ... | ... | @@ -1575,45 +1593,68 @@ Page({ |
| 1575 | 1593 | return false; |
| 1576 | 1594 | } else { |
| 1577 | 1595 | //---如果是线下门店销售的时候--- |
| 1578 | - if (th.data.sales_rules == 2) { | |
| 1596 | + if (th.data.sales_rules >= 2) { | |
| 1579 | 1597 | var pick = th.get_pick_from_list(th.data.sto_sele_id) |
| 1580 | 1598 | //---通过接口获取门店的线下库存信息-- |
| 1581 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | |
| 1582 | - data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }, | |
| 1583 | - success: function (res) { | |
| 1584 | - if (res.data.code == 0) { | |
| 1585 | - if (res.data.data.pageData.length > 0) { | |
| 1586 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | |
| 1587 | - if (CanOutQty < e.data.goodsInputNum) { | |
| 1588 | - return s.my_warnning("库存不足!", 0, th); | |
| 1589 | - } | |
| 1590 | - //在调一次接口,读取商品的预出库的数量,lock | |
| 1591 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | |
| 1592 | - data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 }, | |
| 1593 | - success: function (res_data) { | |
| 1594 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | |
| 1595 | - | |
| 1596 | - var lock = 0; | |
| 1597 | - for (var i in res_data.data.data.pageData) { | |
| 1598 | - lock += res_data.data.data.pageData[i].outQty; | |
| 1599 | - } | |
| 1600 | - | |
| 1601 | - if (CanOutQty <= lock) { | |
| 1602 | - return s.my_warnning("库存不足!", 0, th); | |
| 1603 | - } | |
| 1604 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | |
| 1605 | - } else { | |
| 1606 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 1607 | - } | |
| 1608 | - } | |
| 1609 | - }) | |
| 1610 | - } else { | |
| 1611 | - return s.my_warnning("库存不足!", 0, th); | |
| 1612 | - } | |
| 1613 | - | |
| 1599 | + // getApp().request.get("/api/weshop/goods/getWareStorages", { | |
| 1600 | + // data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }, | |
| 1601 | + // success: function (res) { | |
| 1602 | + // if (res.data.code == 0) { | |
| 1603 | + // if (res.data.data.pageData.length > 0) { | |
| 1604 | + // var CanOutQty = res.data.data.pageData[0].CanOutQty; | |
| 1605 | + // if (CanOutQty < e.data.goodsInputNum) { | |
| 1606 | + // return s.my_warnning("库存不足!", 0, th); | |
| 1607 | + // } | |
| 1608 | + // //在调一次接口,读取商品的预出库的数量,lock | |
| 1609 | + // getApp().request.get("/api/weshop/order/ware/lock/page", { | |
| 1610 | + // data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 }, | |
| 1611 | + // success: function (res_data) { | |
| 1612 | + // if (res_data.data.code == 0 && res_data.data.data.total > 0) { | |
| 1613 | + // | |
| 1614 | + // var lock = 0; | |
| 1615 | + // for (var i in res_data.data.data.pageData) { | |
| 1616 | + // lock += res_data.data.data.pageData[i].outQty; | |
| 1617 | + // } | |
| 1618 | + // | |
| 1619 | + // if (CanOutQty <= lock) { | |
| 1620 | + // return s.my_warnning("库存不足!", 0, th); | |
| 1621 | + // } | |
| 1622 | + // th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | |
| 1623 | + // } else { | |
| 1624 | + // th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 1625 | + // } | |
| 1626 | + // } | |
| 1627 | + // }) | |
| 1628 | + // } else { | |
| 1629 | + // return s.my_warnning("库存不足!", 0, th); | |
| 1630 | + // } | |
| 1631 | + // | |
| 1632 | + // } | |
| 1633 | + // } | |
| 1634 | + // }) | |
| 1635 | + | |
| 1636 | + th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { | |
| 1637 | + if (CanOutQty) { | |
| 1638 | + if (CanOutQty < e.data.goodsInputNum) { | |
| 1639 | + wx.showToast({ | |
| 1640 | + title: '库存不足!', | |
| 1641 | + icon: 'none', | |
| 1642 | + }); | |
| 1643 | + return false; | |
| 1614 | 1644 | } |
| 1645 | + | |
| 1646 | + th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 1647 | + } else { | |
| 1648 | + wx.showToast({ | |
| 1649 | + title: '库存不足!', | |
| 1650 | + icon: 'none', | |
| 1651 | + }); | |
| 1652 | + return false; | |
| 1615 | 1653 | } |
| 1616 | 1654 | }) |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1617 | 1658 | } else { |
| 1618 | 1659 | if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); |
| 1619 | 1660 | if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); |
| ... | ... | @@ -1628,45 +1669,69 @@ Page({ |
| 1628 | 1669 | newd.prom_id = 0; |
| 1629 | 1670 | |
| 1630 | 1671 | //---如果是线下门店销售的时候--- |
| 1631 | - if (th.data.sales_rules == 2) { | |
| 1672 | + if (th.data.sales_rules >= 2) { | |
| 1632 | 1673 | var pick = th.get_pick_from_list(th.data.sto_sele_id) |
| 1633 | 1674 | //---通过接口获取门店的线下库存信息-- |
| 1634 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | |
| 1635 | - data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }, | |
| 1636 | - success: function (res) { | |
| 1637 | - if (res.data.code == 0) { | |
| 1638 | - if (res.data.data.pageData.length > 0) { | |
| 1639 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | |
| 1640 | - if (CanOutQty < e.data.goodsInputNum) { | |
| 1641 | - return s.my_warnning("库存不足!", 0, th); | |
| 1642 | - } | |
| 1643 | - //在调一次接口,读取商品的预出库的数量,lock | |
| 1644 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | |
| 1645 | - data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 }, | |
| 1646 | - success: function (res_data) { | |
| 1647 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | |
| 1648 | - | |
| 1649 | - var lock = 0; | |
| 1650 | - for (var i in res_data.data.data.pageData) { | |
| 1651 | - lock += res_data.data.data.pageData[i].outQty; | |
| 1652 | - } | |
| 1653 | - | |
| 1654 | - if (CanOutQty <= lock) { | |
| 1655 | - return s.my_warnning("库存不足!", 0, th); | |
| 1656 | - } | |
| 1657 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | |
| 1658 | - } else { | |
| 1659 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 1660 | - } | |
| 1661 | - } | |
| 1662 | - }) | |
| 1663 | - } else { | |
| 1664 | - return s.my_warnning("库存不足!", 0, th); | |
| 1665 | - } | |
| 1675 | + // getApp().request.get("/api/weshop/goods/getWareStorages", { | |
| 1676 | + // data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }, | |
| 1677 | + // success: function (res) { | |
| 1678 | + // if (res.data.code == 0) { | |
| 1679 | + // if (res.data.data.pageData.length > 0) { | |
| 1680 | + // var CanOutQty = res.data.data.pageData[0].CanOutQty; | |
| 1681 | + // if (CanOutQty < e.data.goodsInputNum) { | |
| 1682 | + // return s.my_warnning("库存不足!", 0, th); | |
| 1683 | + // } | |
| 1684 | + // //在调一次接口,读取商品的预出库的数量,lock | |
| 1685 | + // getApp().request.get("/api/weshop/order/ware/lock/page", { | |
| 1686 | + // data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 }, | |
| 1687 | + // success: function (res_data) { | |
| 1688 | + // if (res_data.data.code == 0 && res_data.data.data.total > 0) { | |
| 1689 | + // | |
| 1690 | + // var lock = 0; | |
| 1691 | + // for (var i in res_data.data.data.pageData) { | |
| 1692 | + // lock += res_data.data.data.pageData[i].outQty; | |
| 1693 | + // } | |
| 1694 | + // | |
| 1695 | + // if (CanOutQty <= lock) { | |
| 1696 | + // return s.my_warnning("库存不足!", 0, th); | |
| 1697 | + // } | |
| 1698 | + // th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | |
| 1699 | + // } else { | |
| 1700 | + // th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 1701 | + // } | |
| 1702 | + // } | |
| 1703 | + // }) | |
| 1704 | + // } else { | |
| 1705 | + // return s.my_warnning("库存不足!", 0, th); | |
| 1706 | + // } | |
| 1707 | + // | |
| 1708 | + // } | |
| 1709 | + // } | |
| 1710 | + // }) | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { | |
| 1714 | + if (CanOutQty) { | |
| 1666 | 1715 | |
| 1716 | + if (CanOutQty < e.data.goodsInputNum) { | |
| 1717 | + wx.showToast({ | |
| 1718 | + title: '库存不足!', | |
| 1719 | + icon: 'none', | |
| 1720 | + }); | |
| 1721 | + return false; | |
| 1667 | 1722 | } |
| 1723 | + | |
| 1724 | + th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 1725 | + } else { | |
| 1726 | + wx.showToast({ | |
| 1727 | + title: '库存不足!', | |
| 1728 | + icon: 'none', | |
| 1729 | + }); | |
| 1730 | + return false; | |
| 1668 | 1731 | } |
| 1669 | 1732 | }) |
| 1733 | + | |
| 1734 | + | |
| 1670 | 1735 | } else { |
| 1671 | 1736 | if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); |
| 1672 | 1737 | if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); |
| ... | ... | @@ -1981,7 +2046,7 @@ Page({ |
| 1981 | 2046 | } |
| 1982 | 2047 | var e = th.data.sele_g.store_count; |
| 1983 | 2048 | var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 |
| 1984 | - 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)) { | |
| 2049 | + 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)) { | |
| 1985 | 2050 | if (!th.data.def_pick_store) { |
| 1986 | 2051 | wx.showModal({ title: '请选择门店', }); |
| 1987 | 2052 | return false; |
| ... | ... | @@ -2062,7 +2127,7 @@ Page({ |
| 2062 | 2127 | |
| 2063 | 2128 | var e = th.data.sele_g.store_count; |
| 2064 | 2129 | var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 |
| 2065 | - 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)) { | |
| 2130 | + 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)) { | |
| 2066 | 2131 | if (!th.data.def_pick_store) { |
| 2067 | 2132 | wx.showModal({ title: '请选择门店', }); |
| 2068 | 2133 | return false; |
| ... | ... | @@ -2687,32 +2752,41 @@ Page({ |
| 2687 | 2752 | |
| 2688 | 2753 | |
| 2689 | 2754 | //默认门店要拿下门店库存 |
| 2690 | - if (that.data.sales_rules == 2 && that.data.def_pick_store) { | |
| 2755 | + if (that.data.sales_rules >= 2 && that.data.def_pick_store) { | |
| 2691 | 2756 | var lock = 0, plist = null; |
| 2692 | - //先读取门店的lock,采用链式写法,少用await | |
| 2693 | - getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
| 2694 | - data: { store_id: os.stoid, wareId: ee.data.sele_g.goods_id, storageId: that.data.def_pick_store.pickup_id, pageSize: 1000 } | |
| 2695 | - }).then(res => { | |
| 2696 | - if (res.data.code == 0 && res.data.data.total > 0) { | |
| 2697 | - for (var i in res.data.data.pageData) | |
| 2698 | - lock += res.data.data.pageData[i].outQty | |
| 2699 | - } | |
| 2700 | - //---通过接口获取门店的线下库存信息-- | |
| 2701 | - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
| 2702 | - data: { storageNos: that.data.def_pick_store.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid } | |
| 2703 | - }) | |
| 2704 | - }).then(res => { | |
| 2705 | - if (res.data.code == 0 && res.data.data.total > 0) { | |
| 2706 | - plist = res.data.data.pageData[0]; | |
| 2707 | - } | |
| 2708 | - if (plist && plist.CanOutQty - lock > 0) { | |
| 2709 | - that.data.def_pick_store.CanOutQty = plist.CanOutQty - lock; | |
| 2710 | - } else { | |
| 2711 | - that.data.def_pick_store.CanOutQty = 0; | |
| 2712 | - } | |
| 2757 | + // //先读取门店的lock,采用链式写法,少用await | |
| 2758 | + // getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
| 2759 | + // data: { store_id: os.stoid, wareId: ee.data.sele_g.goods_id, storageId: that.data.def_pick_store.pickup_id, pageSize: 1000 } | |
| 2760 | + // }).then(res => { | |
| 2761 | + // if (res.data.code == 0 && res.data.data.total > 0) { | |
| 2762 | + // for (var i in res.data.data.pageData) | |
| 2763 | + // lock += res.data.data.pageData[i].outQty | |
| 2764 | + // } | |
| 2765 | + // //---通过接口获取门店的线下库存信息-- | |
| 2766 | + // return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
| 2767 | + // data: { storageNos: that.data.def_pick_store.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid } | |
| 2768 | + // }) | |
| 2769 | + // }).then(res => { | |
| 2770 | + // if (res.data.code == 0 && res.data.data.total > 0) { | |
| 2771 | + // plist = res.data.data.pageData[0]; | |
| 2772 | + // } | |
| 2773 | + // if (plist && plist.CanOutQty - lock > 0) { | |
| 2774 | + // that.data.def_pick_store.CanOutQty = plist.CanOutQty - lock; | |
| 2775 | + // } else { | |
| 2776 | + // that.data.def_pick_store.CanOutQty = 0; | |
| 2777 | + // } | |
| 2778 | + // //--给门店赋值线下库存-- | |
| 2779 | + // th.setData({ def_pick_store: that.data.def_pick_store }); | |
| 2780 | + // }) | |
| 2781 | + | |
| 2782 | + that.check_CanOutQty(that.data.sele_g, that.data.def_pick_store, function (CanOutQty) { | |
| 2783 | + that.data.def_pick_store.CanOutQty = CanOutQty; | |
| 2713 | 2784 | //--给门店赋值线下库存-- |
| 2714 | - th.setData({ def_pick_store: that.data.def_pick_store }); | |
| 2785 | + that.setData({ | |
| 2786 | + def_pick_store: that.data.def_pick_store | |
| 2787 | + }); | |
| 2715 | 2788 | }) |
| 2789 | + | |
| 2716 | 2790 | } |
| 2717 | 2791 | |
| 2718 | 2792 | |
| ... | ... | @@ -2908,7 +2982,7 @@ Page({ |
| 2908 | 2982 | th.setData({ all_pick_list: e.data.data.pageData }); |
| 2909 | 2983 | |
| 2910 | 2984 | //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购-- |
| 2911 | - 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)) { | |
| 2985 | + 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)) { | |
| 2912 | 2986 | setTimeout(function () { |
| 2913 | 2987 | th.deal_pickup_dline(e); |
| 2914 | 2988 | }, 800) |
| ... | ... | @@ -3108,16 +3182,42 @@ Page({ |
| 3108 | 3182 | |
| 3109 | 3183 | var g_distr_type = th.data.sele_g.distr_type; |
| 3110 | 3184 | var lock = []; |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + var lock_rq = { | |
| 3189 | + store_id: os.stoid, | |
| 3190 | + wareId: th.data.sele_g.goods_id, | |
| 3191 | + pageSize: 1000 | |
| 3192 | + }; | |
| 3193 | + | |
| 3194 | + if (th.data.sales_rules == 3) { | |
| 3195 | + lock_rq.appoint_pick_keyid = th.data.appoint_pick_keyid; | |
| 3196 | + } | |
| 3197 | + | |
| 3111 | 3198 | //先读取门店的lock,采用链式写法,少用await |
| 3112 | 3199 | getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { |
| 3113 | - data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, pageSize: 1000 } | |
| 3200 | + data: lock_rq | |
| 3114 | 3201 | }).then(res => { |
| 3115 | 3202 | if (res.data.code == 0 && res.data.data.total > 0) { |
| 3116 | 3203 | lock = res.data.data.pageData |
| 3117 | 3204 | } |
| 3205 | + | |
| 3206 | + var sto_rq = { | |
| 3207 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | |
| 3208 | + storeId: os.stoid, | |
| 3209 | + pageSize: 2000 | |
| 3210 | + } | |
| 3211 | + | |
| 3212 | + if (th.data.sales_rules == 3) { | |
| 3213 | + sto_rq.storageIds = th.data.appoint_pick_keyid; | |
| 3214 | + } else { | |
| 3215 | + sto_rq.storageNos = pkno_str; | |
| 3216 | + } | |
| 3217 | + | |
| 3118 | 3218 | //---通过接口获取门店的线下库存信息-- |
| 3119 | 3219 | return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { |
| 3120 | - data: { storageNos: pkno_str, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid, pageSize: 2000 } | |
| 3220 | + data: sto_rq | |
| 3121 | 3221 | }) |
| 3122 | 3222 | }).then(res => { |
| 3123 | 3223 | |
| ... | ... | @@ -3126,28 +3226,64 @@ Page({ |
| 3126 | 3226 | if (res.data.data.pageData && res.data.data.pageData.length > 0) { |
| 3127 | 3227 | var plist = res.data.data.pageData; |
| 3128 | 3228 | var def_pick_store = th.data.def_pick_store; |
| 3129 | - //以原来的数组为外循环,保证距离的顺序 | |
| 3130 | - for (var kk in o_plist) { | |
| 3131 | - for (var ii in plist) { | |
| 3132 | - //线下的门店小心 | |
| 3133 | - var n_item = plist[ii]; | |
| 3134 | - if (n_item.StorageNo == o_plist[kk].pickup_no) { | |
| 3135 | - | |
| 3136 | - //拿到锁库的数量 | |
| 3137 | - var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock); | |
| 3138 | - //可出库数大于预出库库存的数量,可以判断为有库存 | |
| 3139 | - if (n_item.CanOutQty > lock_num) { | |
| 3140 | - o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num; | |
| 3141 | - new_list.push(o_plist[kk]); | |
| 3142 | - //--如果找到默认门店,同时也应该判断配送方式对不对-- | |
| 3143 | - 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)) { | |
| 3144 | - th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num; | |
| 3145 | - if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id) | |
| 3146 | - th.setData({ def_pick_store: th.data.fir_def_store }) | |
| 3147 | - is_find_def_store = 1; | |
| 3229 | + | |
| 3230 | + if (th.data.sales_rules == 3) { | |
| 3231 | + var lock_num = 0; | |
| 3232 | + var Qty = 0; | |
| 3233 | + //-- 计算锁住的库存 -- | |
| 3234 | + for (var i in lock) lock_num += lock[i].outQty; | |
| 3235 | + Qty = plist[0].CanOutQty - lock_num; | |
| 3236 | + | |
| 3237 | + if (Qty > 0) { | |
| 3238 | + for (var kk in o_plist) { | |
| 3239 | + o_plist[kk].CanOutQty = Qty; | |
| 3240 | + new_list.push(o_plist[kk]); | |
| 3241 | + } | |
| 3242 | + if (th.data.fir_def_store && | |
| 3243 | + (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))) { | |
| 3244 | + th.data.fir_def_store.Qty; | |
| 3245 | + if (def_pick_store && def_pick_store.pickup_id == th.data.fir_def_store.pickup_id) | |
| 3246 | + th.setData({ | |
| 3247 | + def_pick_store: th.data.fir_def_store | |
| 3248 | + }) | |
| 3249 | + is_find_def_store = 1; | |
| 3250 | + } | |
| 3251 | + | |
| 3252 | + } else { | |
| 3253 | + th.setData({ | |
| 3254 | + all_sto: null, | |
| 3255 | + only_pk: null, | |
| 3256 | + def_pickpu_list: null | |
| 3257 | + }); | |
| 3258 | + return false; | |
| 3259 | + } | |
| 3260 | + | |
| 3261 | + } else { | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + //以原来的数组为外循环,保证距离的顺序 | |
| 3265 | + for (var kk in o_plist) { | |
| 3266 | + for (var ii in plist) { | |
| 3267 | + //线下的门店小心 | |
| 3268 | + var n_item = plist[ii]; | |
| 3269 | + if (n_item.StorageNo == o_plist[kk].pickup_no) { | |
| 3270 | + | |
| 3271 | + //拿到锁库的数量 | |
| 3272 | + var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock); | |
| 3273 | + //可出库数大于预出库库存的数量,可以判断为有库存 | |
| 3274 | + if (n_item.CanOutQty > lock_num) { | |
| 3275 | + o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num; | |
| 3276 | + new_list.push(o_plist[kk]); | |
| 3277 | + //--如果找到默认门店,同时也应该判断配送方式对不对-- | |
| 3278 | + 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)) { | |
| 3279 | + th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num; | |
| 3280 | + if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id) | |
| 3281 | + th.setData({def_pick_store: th.data.fir_def_store}) | |
| 3282 | + is_find_def_store = 1; | |
| 3283 | + } | |
| 3148 | 3284 | } |
| 3285 | + break; | |
| 3149 | 3286 | } |
| 3150 | - break; | |
| 3151 | 3287 | } |
| 3152 | 3288 | } |
| 3153 | 3289 | } |
| ... | ... | @@ -5698,34 +5834,48 @@ Page({ |
| 5698 | 5834 | func(); return false; |
| 5699 | 5835 | } |
| 5700 | 5836 | |
| 5701 | - if (this.data.sales_rules != 2) { | |
| 5837 | + if (this.data.sales_rules < 2) { | |
| 5702 | 5838 | func(); |
| 5703 | 5839 | } else { |
| 5704 | 5840 | |
| 5705 | 5841 | //先读取门店的lock |
| 5706 | - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
| 5707 | - data: { store_id: os.stoid, wareId: goodsinfo.goods_id, storageId: item.pickup_id, pageSize: 1000 } | |
| 5708 | - }).then(res => { | |
| 5709 | - if (res.data.code == 0 && res.data.data.total > 0) { | |
| 5710 | - for (var i in res.data.data.pageData) | |
| 5711 | - lock += res.data.data.pageData[i].outQty; | |
| 5712 | - } | |
| 5713 | - }) | |
| 5714 | - //读取线下的门店库存 | |
| 5715 | - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
| 5716 | - data: { storageNos: item.pickup_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid } | |
| 5717 | - }).then(res => { | |
| 5718 | - if (res.data.code == 0 && res.data.data.total > 0) { | |
| 5719 | - plist = res.data.data.pageData[0]; | |
| 5720 | - } | |
| 5721 | - }) | |
| 5842 | + // await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
| 5843 | + // data: { store_id: os.stoid, wareId: goodsinfo.goods_id, storageId: item.pickup_id, pageSize: 1000 } | |
| 5844 | + // }).then(res => { | |
| 5845 | + // if (res.data.code == 0 && res.data.data.total > 0) { | |
| 5846 | + // for (var i in res.data.data.pageData) | |
| 5847 | + // lock += res.data.data.pageData[i].outQty; | |
| 5848 | + // } | |
| 5849 | + // }) | |
| 5850 | + // //读取线下的门店库存 | |
| 5851 | + // await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
| 5852 | + // data: { storageNos: item.pickup_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid } | |
| 5853 | + // }).then(res => { | |
| 5854 | + // if (res.data.code == 0 && res.data.data.total > 0) { | |
| 5855 | + // plist = res.data.data.pageData[0]; | |
| 5856 | + // } | |
| 5857 | + // }) | |
| 5858 | + // | |
| 5859 | + // if (plist && plist.CanOutQty - lock > 0) { | |
| 5860 | + // item.CanOutQty = plist.CanOutQty - lock; | |
| 5861 | + // func(); | |
| 5862 | + // return false; | |
| 5863 | + // } | |
| 5864 | + // getApp().my_warnning(item.pickup_name + "库存不足!", 0, th); | |
| 5722 | 5865 | |
| 5723 | - if (plist && plist.CanOutQty - lock > 0) { | |
| 5724 | - item.CanOutQty = plist.CanOutQty - lock; | |
| 5866 | + this.check_CanOutQty(goodsinfo, item, function (CanOutQty) { | |
| 5867 | + // let str = item.pickup_name + '库存不足!'; | |
| 5868 | + if (!CanOutQty) { | |
| 5869 | + wx.showToast({ | |
| 5870 | + title: item.pickup_name + '库存不足!', | |
| 5871 | + icon: 'none', | |
| 5872 | + }); | |
| 5873 | + return false; | |
| 5874 | + } | |
| 5875 | + item.CanOutQty = CanOutQty; | |
| 5725 | 5876 | func(); |
| 5726 | - return false; | |
| 5727 | - } | |
| 5728 | - getApp().my_warnning(item.pickup_name + "库存不足!", 0, th); | |
| 5877 | + | |
| 5878 | + }); | |
| 5729 | 5879 | |
| 5730 | 5880 | } |
| 5731 | 5881 | }, |
| ... | ... | @@ -6656,5 +6806,65 @@ Page({ |
| 6656 | 6806 | }); |
| 6657 | 6807 | }, |
| 6658 | 6808 | |
| 6809 | + //统一一下获取线下库存的函数 | |
| 6810 | + async check_CanOutQty(goodsinfo, item, func) { | |
| 6811 | + | |
| 6812 | + var sales_rules = this.data.sales_rules; | |
| 6813 | + | |
| 6814 | + var lock_rq = { | |
| 6815 | + store_id: os.stoid, | |
| 6816 | + wareId: goodsinfo.goods_id, | |
| 6817 | + pageSize: 1000 | |
| 6818 | + }; | |
| 6819 | + | |
| 6820 | + if (sales_rules == 2) { | |
| 6821 | + lock_rq.storageId = item.pickup_id | |
| 6822 | + } else { | |
| 6823 | + lock_rq.appoint_pick_keyid = encodeURIComponent(this.data.appoint_pick_keyid) | |
| 6824 | + } | |
| 6825 | + | |
| 6826 | + var lock = 0; | |
| 6827 | + var CanOutQty = 0; | |
| 6828 | + var plist = null; | |
| 6829 | + //先读取门店的lock | |
| 6830 | + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
| 6831 | + data: lock_rq | |
| 6832 | + }).then(res => { | |
| 6833 | + if (res.data.code == 0 && res.data.data.total > 0) { | |
| 6834 | + for (var i in res.data.data.pageData) | |
| 6835 | + lock += res.data.data.pageData[i].outQty; | |
| 6836 | + } | |
| 6837 | + }) | |
| 6838 | + | |
| 6839 | + var sto_req = { | |
| 6840 | + wareIds: encodeURIComponent(goodsinfo.erpwareid), | |
| 6841 | + storeId: os.stoid | |
| 6842 | + } | |
| 6843 | + if (sales_rules == 2) { | |
| 6844 | + sto_req.storageNos = item.pickup_no | |
| 6845 | + } else { | |
| 6846 | + sto_req.storageIds = encodeURIComponent(this.data.appoint_pick_keyid) | |
| 6847 | + } | |
| 6848 | + | |
| 6849 | + | |
| 6850 | + | |
| 6851 | + //读取线下的门店库存 | |
| 6852 | + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
| 6853 | + data: sto_req | |
| 6854 | + }).then(res => { | |
| 6855 | + if (res.data.code == 0 && res.data.data.total > 0) { | |
| 6856 | + plist = res.data.data.pageData[0]; | |
| 6857 | + } | |
| 6858 | + }) | |
| 6859 | + | |
| 6860 | + if (plist && plist.CanOutQty - lock > 0) { | |
| 6861 | + CanOutQty = plist.CanOutQty - lock; | |
| 6862 | + } | |
| 6863 | + | |
| 6864 | + if (func) func(CanOutQty); | |
| 6865 | + | |
| 6866 | + }, | |
| 6867 | + | |
| 6868 | + | |
| 6659 | 6869 | |
| 6660 | 6870 | }); | ... | ... |
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml
| ... | ... | @@ -426,7 +426,7 @@ |
| 426 | 426 | <view class="no_store" wx:if="{{def_pick_store && def_pick_store.is_no_dis}}"> |
| 427 | 427 | (配送不匹配) |
| 428 | 428 | </view> |
| 429 | - <view class="no_store" wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules==2 && prom_type==0}}"> | |
| 429 | + <view class="no_store" wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules>=2 && prom_type==0}}"> | |
| 430 | 430 | (库存不足) |
| 431 | 431 | </view> |
| 432 | 432 | </block> |
| ... | ... | @@ -1081,7 +1081,7 @@ |
| 1081 | 1081 | <block wx:if="{{prom_type == 0}}"> |
| 1082 | 1082 | <view class="flex"> |
| 1083 | 1083 | <view class="spec-goods-stock">已售:{{sele_g.sales_sum}}</view> |
| 1084 | - <block wx:if="{{sales_rules==2}}"> | |
| 1084 | + <block wx:if="{{sales_rules>=2}}"> | |
| 1085 | 1085 | <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}"> |
| 1086 | 1086 | 可售:{{def_pick_store.CanOutQty}} |
| 1087 | 1087 | </view> |
| ... | ... | @@ -1122,7 +1122,7 @@ |
| 1122 | 1122 | <view wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">(库存不足)</view> |
| 1123 | 1123 | <block wx:else> |
| 1124 | 1124 | <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配)</view> |
| 1125 | - <view wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules==2 && prom_type==0}}"> | |
| 1125 | + <view wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules>=2 && prom_type==0}}"> | |
| 1126 | 1126 | (库存不足) |
| 1127 | 1127 | </view> |
| 1128 | 1128 | </block> |
| ... | ... | @@ -1194,7 +1194,7 @@ |
| 1194 | 1194 | </block> |
| 1195 | 1195 | <block wx:else> |
| 1196 | 1196 | <!-- 如果是线下库存购买的时候,且是普通商品购买的时候 --> |
| 1197 | - <block wx:if="{{sales_rules==2 && prom_type==0}}"> | |
| 1197 | + <block wx:if="{{sales_rules>=2 && prom_type==0}}"> | |
| 1198 | 1198 | <block wx:if="{{!def_pick_store.CanOutQty}}"> |
| 1199 | 1199 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 1200 | 1200 | 库存不足 | ... | ... |
pages/goods/goodsInfo/goodsInfo.js
| ... | ... | @@ -3063,7 +3063,7 @@ Page({ |
| 3063 | 3063 | |
| 3064 | 3064 | //默认门店要拿下门店库存 |
| 3065 | 3065 | if (that.data.sales_rules >= 2 && that.data.def_pick_store && !that.data.sele_g.whsle_id) { |
| 3066 | - var lock = 0, | |
| 3066 | + var lock = 0, | |
| 3067 | 3067 | plist = null; |
| 3068 | 3068 | //先读取门店的lock,采用链式写法,少用await |
| 3069 | 3069 | // getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ... | ... |
pages/user/order_detail/order_detail.js
| ... | ... | @@ -975,6 +975,7 @@ Page({ |
| 975 | 975 | sto_rq.storageIds=this.data.appoint_pick_keyid; |
| 976 | 976 | delete sto_rq.storageNos |
| 977 | 977 | } |
| 978 | + | |
| 978 | 979 | |
| 979 | 980 | //读取线下的门店库存 |
| 980 | 981 | await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ |
| ... | ... | @@ -1115,6 +1116,7 @@ Page({ |
| 1115 | 1116 | } |
| 1116 | 1117 | |
| 1117 | 1118 | var prom=null; |
| 1119 | + let user_id = getApp().globalData.userInfo.user_id; | |
| 1118 | 1120 | |
| 1119 | 1121 | b_item.goods_id=g_item.goods_id; |
| 1120 | 1122 | b_item.goods_name=g_item.goods_name; |
| ... | ... | @@ -1210,7 +1212,7 @@ Page({ |
| 1210 | 1212 | }) |
| 1211 | 1213 | break; |
| 1212 | 1214 | case 10: |
| 1213 | - let user_id = getApp().globalData.userInfo.user_id; | |
| 1215 | + | |
| 1214 | 1216 | var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`; |
| 1215 | 1217 | await getApp().request.promiseGet(url, {}).then(res => { |
| 1216 | 1218 | if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) { |
| ... | ... | @@ -1314,6 +1316,8 @@ Page({ |
| 1314 | 1316 | delete sto_rq.storageNos; |
| 1315 | 1317 | } |
| 1316 | 1318 | |
| 1319 | + | |
| 1320 | + | |
| 1317 | 1321 | //---通过接口获取门店的线下库存信息-- |
| 1318 | 1322 | await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { |
| 1319 | 1323 | data: sto_rq | ... | ... |