Commit 1d10de0e80897f76936376c1e3db1e449725fb99

Authored by yvan.ni
1 parent bd026007

1. 订单重新支付, 线下取价的功能关闭后的判断

pages/cart/cart/cart.js
@@ -65,7 +65,29 @@ Page({ @@ -65,7 +65,29 @@ Page({
65 this.setData({requestData:null,is_load:0}); 65 this.setData({requestData:null,is_load:0});
66 //调用底部导航 66 //调用底部导航
67 //t.editTabBar(th,getApp().globalData.setting.stoid,getApp().globalData.url); 67 //t.editTabBar(th,getApp().globalData.setting.stoid,getApp().globalData.url);
68 - this.getCardList(); 68 + //----获取系统参数-----
  69 + getApp().getConfig2(function(e) {
  70 + var json_d = JSON.parse(e.switch_list);
  71 + var is_open_offline=json_d.is_pricing_open;
  72 + th.setData({
  73 + bconfig: e,sales_rules:e.sales_rules
  74 + });
  75 +
  76 + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
  77 + //未购买
  78 + if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){
  79 + is_open_offline=0;
  80 + }
  81 + //已经过期
  82 + var item=res.data.data.pageData[0];
  83 + if(item.end_time<ut.gettimestamp()){
  84 + is_open_offline=0;
  85 + }
  86 + th.data.is_open_offline=0;
  87 + th.getCardList();
  88 + });
  89 +
  90 + },1)
69 91
70 //--获取是否又秒杀活动-- 92 //--获取是否又秒杀活动--
71 getApp().request.promiseGet("/api/ms/flash_sale/spikepage", { 93 getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {
@@ -292,12 +314,14 @@ Page({ @@ -292,12 +314,14 @@ Page({
292 }, 800) 314 }, 800)
293 } 315 }
294 316
295 - //-- 此时要实时更新线下取价价格 --  
296 - for(var i=0;i<arr.length;i++){  
297 - //每个门店都去看下线下取价  
298 - var list=arr[i];  
299 - await th.set_offline(list);  
300 - } 317 + if(th.data.is_open_offline && th.data.is_open_offline>0){
  318 + //-- 此时要实时更新线下取价价格 --
  319 + for(var i=0;i<arr.length;i++){
  320 + //每个门店都去看下线下取价
  321 + var list=arr[i];
  322 + await th.set_offline(list);
  323 + }
  324 + }
301 325
302 th.setData({ 326 th.setData({
303 requestData: arr, 327 requestData: arr,
pages/goods/goodsInfo/goodsInfo.js
@@ -652,6 +652,7 @@ Page({ @@ -652,6 +652,7 @@ Page({
652 getApp().getConfig2(function(e) { 652 getApp().getConfig2(function(e) {
653 var json_d = JSON.parse(e.switch_list); 653 var json_d = JSON.parse(e.switch_list);
654 th.setData({is_closecoupon: json_d.is_closecoupon}) 654 th.setData({is_closecoupon: json_d.is_closecoupon})
  655 + th.setData({is_open_offline: json_d.is_pricing_open})
655 },1) 656 },1)
656 657
657 658
@@ -1663,6 +1664,9 @@ Page({ @@ -1663,6 +1664,9 @@ Page({
1663 openSpecModal_ind: ind, 1664 openSpecModal_ind: ind,
1664 }); 1665 });
1665 1666
  1667 + var is_open=th.data.config
  1668 +
  1669 +
1666 this.get_off_price(); 1670 this.get_off_price();
1667 1671
1668 }, 1672 },
@@ -1670,32 +1674,50 @@ Page({ @@ -1670,32 +1674,50 @@ Page({
1670 //----获取线下价格------- 1674 //----获取线下价格-------
1671 get_off_price(){ 1675 get_off_price(){
1672 var th=this; 1676 var th=this;
1673 - var cur_goods=this.data.sele_g;  
1674 - var user_info = getApp().globalData.userInfo;  
1675 - //获取一下接口,判断是不是有线下接口,必须是普通商品,全局优惠活动也是不行  
1676 - if(cur_goods.prom_type==0 && !this.data.prom_goods){  
1677 - cur_goods.offline_price=null;  
1678 - //如果没有门店,不用计算线下价格  
1679 - var def_pick_store=this.data.def_pick_store;  
1680 - if(!def_pick_store) return false;  
1681 - getApp().request.get("/api/weshop/goods/listWarePrice", {  
1682 - data:{VIPId:encodeURIComponent(user_info.erpvipid),  
1683 - store_id:os.stoid,  
1684 - PickupId:def_pick_store.pickup_id,  
1685 - WareIds:encodeURIComponent(cur_goods.erpwareid)},  
1686 - success:function(res){  
1687 - if(res.data.code==0 && res.data.data && res.data.data.length>0){  
1688 - var datalist=res.data.data;  
1689 - if(datalist[0].WarePrice<cur_goods.shop_price){  
1690 - cur_goods.offline_price=datalist[0].WarePrice; //存储线下活动的价格  
1691 - cur_goods.pricing_type=datalist[0].PriceType; //存储线下活动的类型  
1692 - }  
1693 - }  
1694 - th.setData({sele_g:cur_goods});  
1695 - }  
1696 -  
1697 - })  
1698 - } 1677 + //没有开启就返回
  1678 + if(!th.data.is_open_offline) return false;
  1679 + //先看下购买的功能有没有到期
  1680 + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
  1681 + //未购买
  1682 + if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){
  1683 + return false;
  1684 + }
  1685 + //已经过期
  1686 + var item=res.data.data.pageData[0];
  1687 + if(item.end_time<ut.gettimestamp()){
  1688 + return false;
  1689 + }
  1690 +
  1691 + var cur_goods=this.data.sele_g;
  1692 + var user_info = getApp().globalData.userInfo;
  1693 + //获取一下接口,判断是不是有线下接口,必须是普通商品,全局优惠活动也是不行
  1694 + if(cur_goods.prom_type==0 && !this.data.prom_goods){
  1695 + cur_goods.offline_price=null;
  1696 + //如果没有门店,不用计算线下价格
  1697 + var def_pick_store=this.data.def_pick_store;
  1698 + if(!def_pick_store) return false;
  1699 + getApp().request.get("/api/weshop/goods/listWarePrice", {
  1700 + data:{VIPId:encodeURIComponent(user_info.erpvipid),
  1701 + store_id:os.stoid,
  1702 + PickupId:def_pick_store.pickup_id,
  1703 + WareIds:encodeURIComponent(cur_goods.erpwareid)},
  1704 + success:function(res){
  1705 + if(res.data.code==0 && res.data.data && res.data.data.length>0){
  1706 + var datalist=res.data.data;
  1707 + if(datalist[0].WarePrice<cur_goods.shop_price){
  1708 + cur_goods.offline_price=datalist[0].WarePrice; //存储线下活动的价格
  1709 + cur_goods.pricing_type=datalist[0].PriceType; //存储线下活动的类型
  1710 + }
  1711 + }
  1712 + th.setData({sele_g:cur_goods});
  1713 + }
  1714 +
  1715 + })
  1716 + }
  1717 +
  1718 + })
  1719 +
  1720 +
1699 }, 1721 },
1700 1722
1701 1723
pages/user/order_detail/order_detail.js
@@ -18,10 +18,12 @@ Page({ @@ -18,10 +18,12 @@ Page({
18 var r = void 0 !== e.isGoup && e.isGoup; 18 var r = void 0 !== e.isGoup && e.isGoup;
19 19
20 getApp().getConfig2(function (e) { 20 getApp().getConfig2(function (e) {
  21 +
21 th.setData({conf: e,sales_rules:e.sales_rules }); 22 th.setData({conf: e,sales_rules:e.sales_rules });
22 //--- 看后台是不是有开通等级卡 --- 23 //--- 看后台是不是有开通等级卡 ---
23 if(e.switch_list){ 24 if(e.switch_list){
24 var s_list=JSON.parse(e.switch_list); 25 var s_list=JSON.parse(e.switch_list);
  26 + var is_open_offline=s_list.is_pricing_open;
25 var user=getApp().globalData.userInfo; 27 var user=getApp().globalData.userInfo;
26 //如果后台有开启等级价的功能 28 //如果后台有开启等级价的功能
27 if(parseInt(s_list.rank_switch)==2 && user['card_expiredate']){ 29 if(parseInt(s_list.rank_switch)==2 && user['card_expiredate']){
@@ -34,8 +36,22 @@ Page({ @@ -34,8 +36,22 @@ Page({
34 th.setData({card_field:user.card_field}) 36 th.setData({card_field:user.card_field})
35 } 37 }
36 } 38 }
  39 + //-- 判断有没有过期 --
  40 + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
  41 + //未购买
  42 + if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){
  43 + is_open_offline=0;
  44 + }
  45 + //已经过期
  46 + var item=res.data.data.pageData[0];
  47 + if(item.end_time<ut.gettimestamp()){
  48 + is_open_offline=0;
  49 + }
  50 + th.data.is_open_offline=is_open_offline;
  51 + })
  52 +
37 } 53 }
38 - }) 54 + },1)
39 55
40 this.setData({ 56 this.setData({
41 optionIsGoup: r 57 optionIsGoup: r
@@ -303,7 +319,15 @@ Page({ @@ -303,7 +319,15 @@ Page({
303 319
304 var wlist=""; 320 var wlist="";
305 for(var i in order_goods){ 321 for(var i in order_goods){
306 - var good=order_goods[i]; 322 + var good=order_goods[i];
  323 + //线下取价功能已经关闭或者过期
  324 + if(!th.data.is_open_offline && good.offline_cut>0){
  325 + wx.showModal({
  326 + title: '提示',
  327 + content: '线下取价功能已经关闭或者过期!'
  328 + });
  329 + return false;
  330 + }
307 //如果不是小程序有的功能,直接提示要去3.0处理 331 //如果不是小程序有的功能,直接提示要去3.0处理
308 if(good.prom_type==2 ){ 332 if(good.prom_type==2 ){
309 wx.showModal({ 333 wx.showModal({
@@ -558,7 +582,7 @@ Page({ @@ -558,7 +582,7 @@ Page({
558 } 582 }
559 583
560 //-- 要判断一下线下取价价格是不是发生改变 -- 584 //-- 要判断一下线下取价价格是不是发生改变 --
561 - if(wlist!=""){ 585 + if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){
562 wlist=ut.sub_last(wlist); 586 wlist=ut.sub_last(wlist);
563 var keyid=order.pickup_id; 587 var keyid=order.pickup_id;
564 var user_info=getApp().globalData.userInfo; 588 var user_info=getApp().globalData.userInfo;
@@ -747,11 +771,16 @@ Page({ @@ -747,11 +771,16 @@ Page({
747 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ 771 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
748 data:{storageNos:pick_no,wareIds:encodeURIComponent(gg.erpwareid),storeId:os.stoid} 772 data:{storageNos:pick_no,wareIds:encodeURIComponent(gg.erpwareid),storeId:os.stoid}
749 }).then(res=>{ 773 }).then(res=>{
750 - if(res.data.code==0){ 774 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){
751 plist=res.data.data.pageData[0]; 775 plist=res.data.data.pageData[0];
752 } 776 }
753 }) 777 })
754 var ob={}; ob.code=1; 778 var ob={}; ob.code=1;
  779 + if(!plist){
  780 + ob.code=-1; ob.CanOutQty=0;
  781 + func(ob);return false;
  782 + }
  783 +
755 if(num>plist.CanOutQty-lock){ 784 if(num>plist.CanOutQty-lock){
756 ob.code=-1; 785 ob.code=-1;
757 ob.CanOutQty=plist.CanOutQty-lock 786 ob.CanOutQty=plist.CanOutQty-lock
pages/user/order_list/order_list.js
@@ -81,15 +81,19 @@ Page({ @@ -81,15 +81,19 @@ Page({
81 if (t.type != undefined) this.setData({ 81 if (t.type != undefined) this.setData({
82 activeCategoryId: t.type 82 activeCategoryId: t.type
83 }); 83 });
84 - s.init(this, "", "orderList"); 84 + s.init(this, "", "orderList");
  85 + },
  86 + onShow: function() {
  87 + var th=this;
85 //---查看会员的等级价--- 88 //---查看会员的等级价---
86 - getApp().getConfig2(function(e) { 89 + getApp().getConfig2(function(e) {
87 th.setData({conf: e,sales_rules:e.sales_rules }); 90 th.setData({conf: e,sales_rules:e.sales_rules });
88 //--- 看后台是不是有开通等级卡 --- 91 //--- 看后台是不是有开通等级卡 ---
89 if(e.switch_list){ 92 if(e.switch_list){
90 - var s_list=JSON.parse(e.switch_list);  
91 - var user=getApp().globalData.userInfo;  
92 - //如果后台有开启等级价的功能 93 + var s_list=JSON.parse(e.switch_list);
  94 + var user=getApp().globalData.userInfo;
  95 + var is_open_offline=s_list.is_pricing_open;
  96 + //-- 如果后台有开启等级价的功能 --
93 if(parseInt(s_list.rank_switch)==2 && user['card_expiredate']){ 97 if(parseInt(s_list.rank_switch)==2 && user['card_expiredate']){
94 var str = user['card_expiredate'].replace(/-/g, '/'); 98 var str = user['card_expiredate'].replace(/-/g, '/');
95 var end = new Date(str); 99 var end = new Date(str);
@@ -99,12 +103,25 @@ Page({ @@ -99,12 +103,25 @@ Page({
99 if(user.card_field && now<end){ 103 if(user.card_field && now<end){
100 th.setData({card_field:user.card_field}) 104 th.setData({card_field:user.card_field})
101 } 105 }
102 - }  
103 - }  
104 - })  
105 - },  
106 - onShow: function() { 106 + }
  107 + //-- 判断有没有过期 --
  108 + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
  109 + //未购买
  110 + if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){
  111 + is_open_offline=0;
  112 + }
  113 + //已经过期
  114 + var item=res.data.data.pageData[0];
  115 + if(item.end_time<ut.gettimestamp()){
  116 + is_open_offline=0;
  117 + }
  118 + th.data.is_open_offline=is_open_offline;
  119 + })
  120 + }
  121 + },1)
  122 +
107 this.resetData(), this.requestOrderList(this.data.activeCategoryId); 123 this.resetData(), this.requestOrderList(this.data.activeCategoryId);
  124 +
108 }, 125 },
109 changeTab: function(t) { 126 changeTab: function(t) {
110 if (this.data.activeCategoryId == t.currentTarget.id) return false; 127 if (this.data.activeCategoryId == t.currentTarget.id) return false;
@@ -424,6 +441,14 @@ Page({ @@ -424,6 +441,14 @@ Page({
424 var wlist=""; 441 var wlist="";
425 for(var i in order_goods){ 442 for(var i in order_goods){
426 var good=order_goods[i]; 443 var good=order_goods[i];
  444 + //线下取价功能已经关闭或者过期
  445 + if(!th.data.is_open_offline && good.offline_cut>0){
  446 + wx.showModal({
  447 + title: '提示',
  448 + content: '线下取价功能已经关闭或者过期!'
  449 + });
  450 + return false;
  451 + }
427 //如果不是小程序有的功能,直接提示要去3.0处理 452 //如果不是小程序有的功能,直接提示要去3.0处理
428 if(good.prom_type==2 ){ 453 if(good.prom_type==2 ){
429 wx.showModal({ 454 wx.showModal({
@@ -568,6 +593,7 @@ Page({ @@ -568,6 +593,7 @@ Page({
568 //赠品和搭配购不判断商品金额 593 //赠品和搭配购不判断商品金额
569 var isok=1; 594 var isok=1;
570 var card_field=th.data.card_field; 595 var card_field=th.data.card_field;
  596 +
571 //-- 如果会员是等级会员,商品有等级价,且不是活动商品,同时线下取价的要放在最后来判断 -- 597 //-- 如果会员是等级会员,商品有等级价,且不是活动商品,同时线下取价的要放在最后来判断 --
572 if(!good.is_gift && !good.is_collocation) { 598 if(!good.is_gift && !good.is_collocation) {
573 if (card_field && gg[card_field] > 0) { 599 if (card_field && gg[card_field] > 0) {
@@ -689,12 +715,11 @@ Page({ @@ -689,12 +715,11 @@ Page({
689 } 715 }
690 } 716 }
691 717
692 - }  
693 - 718 + }
694 } 719 }
695 720
696 //-- 要判断一下线下取价价格是不是发生改变 -- 721 //-- 要判断一下线下取价价格是不是发生改变 --
697 - if(wlist!=""){ 722 + if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){
698 wlist=ut.sub_last(wlist); 723 wlist=ut.sub_last(wlist);
699 var keyid=order.pickup_id; 724 var keyid=order.pickup_id;
700 var user_info=getApp().globalData.userInfo; 725 var user_info=getApp().globalData.userInfo;
@@ -790,11 +815,17 @@ Page({ @@ -790,11 +815,17 @@ Page({
790 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ 815 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
791 data:{storageNos:pick_no,wareIds:encodeURIComponent(gg.erpwareid),storeId:os.stoid} 816 data:{storageNos:pick_no,wareIds:encodeURIComponent(gg.erpwareid),storeId:os.stoid}
792 }).then(res=>{ 817 }).then(res=>{
793 - if(res.data.code==0){ 818 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){
794 plist=res.data.data.pageData[0]; 819 plist=res.data.data.pageData[0];
795 } 820 }
796 - })  
797 - var ob={}; ob.code=1; 821 + })
  822 +
  823 + var ob={}; ob.code=1;
  824 + if(!plist){
  825 + ob.code=-1; ob.CanOutQty=0;
  826 + func(ob);return false;
  827 + }
  828 +
798 if(num>plist.CanOutQty-lock){ 829 if(num>plist.CanOutQty-lock){
799 ob.code=-1; 830 ob.code=-1;
800 ob.CanOutQty=plist.CanOutQty-lock 831 ob.CanOutQty=plist.CanOutQty-lock