Commit 366aa639bb8296ffba8379eefd00a92d0f56db35

Authored by yvan.ni
1 parent ed232222

预售的服务卡项的优化

packageA/pages/details_serviceCard/details_serviceCard.js
... ... @@ -454,6 +454,13 @@ Page({
454 454 return false;
455 455 }
456 456  
  457 + if(prom_type==8){
  458 + wx.showModal({
  459 + title: details.list[i].service_name +"预售商品不加入购物车\n"
  460 + });
  461 + return false;
  462 + }
  463 +
457 464 //----先看会员在购物车中是否加入了该商品-----
458 465 app.request.get("/api/weshop/cartService/page", {
459 466 data: {
... ... @@ -794,6 +801,104 @@ Page({
794 801 }
795 802 pt_act=act_details;
796 803 }
  804 + //-- 预售 --
  805 + if (it.prom_type == 8) {
  806 +
  807 + let act_details = null;
  808 + let promcardbuynum = 0;
  809 + let qty = it.qty;
  810 + let presell_id=0;
  811 +
  812 + var url = "/api/weshop/marketing/marketingPresellList/list"
  813 + var rd = {
  814 + store_id: os.stoid,
  815 + presell_id: it.prom_id,
  816 + goods_id: it.card_id
  817 + }
  818 + console.log('获取预售从表')
  819 + //------获取预售从表----------
  820 + await getApp().request.promiseGet(url, {
  821 + data: rd
  822 + }).then(res => {
  823 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  824 + act_details = res.data.data[0];
  825 + presell_id = act_details.presell_id;
  826 + }
  827 + })
  828 +
  829 + //------获取预售主表----------
  830 + await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}).then(res => {
  831 + if (res.data.code == 0 && res.data.data) {
  832 + var act_data = res.data.data;
  833 + if (act_data.is_end) {
  834 + wx.showToast({ title: "活动已经结束", icon: 'none', duration: 3000 });
  835 + flag = 0;
  836 + return false;
  837 + }
  838 + if (act_data.isuse == 0) {
  839 + wx.showToast({ title: "活动未启用", icon: 'none', duration: 3000 });
  840 + flag = 0;
  841 + return false;
  842 + }
  843 +
  844 + var err_txt = "活动定金时间已经结束";
  845 + var end_time = act_data.end_time;
  846 + if (act_data.presell_type == 1) {
  847 + err_txt = "活动时间已经结束";
  848 + }
  849 + if (end_time < ut.gettimestamp()) {
  850 + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 });
  851 + flag = 0;
  852 + return false;
  853 + }
  854 +
  855 + if (act_data.presell_type == 0) {
  856 + end_time = act_data.pay_enddate;
  857 + err_txt = "活动尾款时间已经结束";
  858 + }
  859 + if (end_time < ut.gettimestamp()) {
  860 + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 });
  861 + flag = 0;
  862 + return false;
  863 + }
  864 + }
  865 + })
  866 +
  867 + if(!flag) {
  868 + th.data.ser_paying=0;
  869 + return false;
  870 + }
  871 +
  872 + //-- 判断一下限购的计算 --
  873 + if(act_details.vip_butyqty>0){
  874 + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
  875 + data: {
  876 + store_id: store_id,
  877 + user_id: user_id,
  878 + card_id: it.card_id,
  879 + prom_type: it.prom_type,
  880 + prom_id: it.prom_id,
  881 + ispay:1
  882 + }
  883 + }).then(res => {
  884 + if (res.data.code == 0) {
  885 + console.log('已经购买的数量:', res.data.data);
  886 + promcardbuynum = res.data.data.promcardbuynum;
  887 + }
  888 + })
  889 + let limited = act_details.buy_limit; // 限购数量a
  890 + let canBuyNum = limited - promcardbuynum; // 自己还可购买的数量c
  891 +
  892 + if (canBuyNum < qty ) {
  893 + wx.showModal({
  894 + title: '提示',
  895 + content: '您已超出活动限购数量,无法支付,请取消订单!',
  896 + showCancel: false,
  897 + });
  898 + flag = false;
  899 + }
  900 + }
  901 + }
797 902 }
798 903  
799 904 if (flag) {
... ...
packageC/pages/presell/cardInfo/goodsInfo.js
... ... @@ -2445,7 +2445,7 @@ Page({
2445 2445 },
2446 2446  
2447 2447  
2448   - //--跳转到商品详情页面--
  2448 + //--跳转到商品详情页面 --
2449 2449 go_goods: function(e) {
2450 2450 var gid = e.currentTarget.dataset.gid;
2451 2451 var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid;
... ... @@ -3434,6 +3434,21 @@ Page({
3434 3434 // "function" == typeof func && func();
3435 3435 // return false;
3436 3436 // }
  3437 +
  3438 +
  3439 + getApp().request.get("/api/weshop/order/orderPresell/countBuyGoodsSum", {
  3440 + data: { store_id: os.stoid, user_id: user_id, goods_id: gd.goods_id, prom_id: t_prom_id },
  3441 + success: function (e) {
  3442 + if (e.data.code == 0) {
  3443 + th.setData({ prom_buy_num: e.data.data.sumgoodsnum })
  3444 + "function" == typeof func && func();
  3445 + } else {
  3446 + th.setData({ prom_buy_num: 0, })
  3447 + "function" == typeof func && func();
  3448 + }
  3449 +
  3450 + }
  3451 + });
3437 3452  
3438 3453  
3439 3454 //----获取商品购买数----
... ...
pages/user/order_list/order_list.js
... ... @@ -2997,7 +2997,7 @@ Page({
2997 2997 }
2998 2998  
2999 2999 };
3000   - //拼团
  3000 + //-- 拼团 --
3001 3001 if (it.prom_type == 6) {
3002 3002 let act_details = null;
3003 3003 let redis_num = 0;
... ... @@ -3054,7 +3054,6 @@ Page({
3054 3054 }
3055 3055 }
3056 3056  
3057   -
3058 3057 }
3059 3058 });
3060 3059  
... ... @@ -3089,68 +3088,76 @@ Page({
3089 3088 pt_act=act_details;
3090 3089  
3091 3090 }
3092   - //预售
  3091 + //-- 预售 --
3093 3092 if (it.prom_type == 8) {
  3093 +
3094 3094 let act_details = null;
3095   - let redis_num = 0;
3096 3095 let promcardbuynum = 0;
3097 3096 let qty = it.qty;
  3097 + let presell_id=0;
3098 3098  
3099   - await getApp().request.promiseGet("/api/weshop/teamlist/get/" + store_id + "/" + it.prom_id, {}).then(res => {
3100   -
3101   - if (res.data.code == 0) {
3102   -
3103   - act_details = res.data.data;
  3099 + var url = "/api/weshop/marketing/marketingPresellList/list"
  3100 + var rd = {
  3101 + store_id: os.stoid,
  3102 + presell_id: it.prom_id,
  3103 + goods_id: it.card_id
  3104 + }
  3105 + console.log('获取预售从表')
  3106 + //------获取预售从表----------
  3107 + await getApp().request.promiseGet(url, {
  3108 + data: rd
  3109 + }).then(res => {
  3110 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  3111 + act_details = res.data.data[0];
  3112 + presell_id = act_details.presell_id;
  3113 + }
  3114 + })
3104 3115  
3105   - if (act_details.is_end == 1) {
3106   - wx.showModal({
3107   - title: '提示',
3108   - content: '活动已结束,无法支付,请取消订单!',
3109   - showCancel: false,
3110   - });
3111   - flag = false;
  3116 + //------获取预售主表----------
  3117 + await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}).then(res => {
  3118 + if (res.data.code == 0 && res.data.data) {
  3119 + var act_data = res.data.data;
  3120 + if (act_data.is_end) {
  3121 + wx.showToast({ title: "活动已经结束", icon: 'none', duration: 3000 });
  3122 + flag = 0;
3112 3123 return false;
3113 3124 }
3114   -
3115   - if (act_details.id != it.prom_id) {
3116   - wx.showModal({
3117   - title: '提示',
3118   - content: '活动发生了变化,无法支付,请取消订单,重新购买!',
3119   - showCancel: false,
3120   - });
3121   - flag = false;
  3125 + if (act_data.isuse == 0) {
  3126 + wx.showToast({ title: "活动未启用", icon: 'none', duration: 3000 });
  3127 + flag = 0;
3122 3128 return false;
3123 3129 }
3124 3130  
3125   - var t_now = ut.gettimestamp();
3126   - if (act_details.is_end == 1 || act_details.start_time > t_now || act_details.end_time < t_now) {
3127   - wx.showModal({
3128   - title: '提示',
3129   - content: '活动发生了变化,无法支付,请取消订单,重新购买!',
3130   - showCancel: false,
3131   - });
3132   - flag = false;
  3131 + var err_txt = "活动定金时间已经结束";
  3132 + var end_time = act_data.end_time;
  3133 + if (act_data.presell_type == 1) {
  3134 + err_txt = "活动时间已经结束";
  3135 + }
  3136 + if (end_time < ut.gettimestamp()) {
  3137 + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 });
  3138 + flag = 0;
3133 3139 return false;
3134 3140 }
3135 3141  
3136   - //指定门店的控制
3137   - if (act_details.pick_up_lists) {
3138   - var idx0=act_details.pick_up_lists.findIndex(function (e){
3139   - return e.pickup_id==it.pickup_id;
3140   - })
3141   - if(idx0<0){
3142   - getApp().confirmBox(it.service_name + "拼团活动的门店不可售");
3143   - th.setData({ paying: 0 });
3144   - flag = false;
3145   - return false;
3146   - }
  3142 + if (act_data.presell_type == 0) {
  3143 + end_time = act_data.pay_enddate;
  3144 + err_txt = "活动尾款时间已经结束";
  3145 + }
  3146 + if (end_time < ut.gettimestamp()) {
  3147 + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 });
  3148 + flag = 0;
  3149 + return false;
3147 3150 }
3148   -
3149   -
3150 3151 }
3151   - });
  3152 + })
3152 3153  
3153   - if(act_details.buy_limit>0 && flag){
  3154 + if(!flag) {
  3155 + th.data.ser_paying=0;
  3156 + return false;
  3157 + }
  3158 +
  3159 + //-- 判断一下限购的计算 --
  3160 + if(act_details.vip_butyqty>0){
3154 3161 await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
3155 3162 data: {
3156 3163 store_id: store_id,
... ... @@ -3162,8 +3169,8 @@ Page({
3162 3169 }
3163 3170 }).then(res => {
3164 3171 if (res.data.code == 0) {
3165   - console.log('已经购买的数量:', res.data.data);
3166   - promcardbuynum = res.data.data.promcardbuynum;
  3172 + console.log('已经购买的数量:', res.data.data);
  3173 + promcardbuynum = res.data.data.promcardbuynum;
3167 3174 }
3168 3175 })
3169 3176 let limited = act_details.buy_limit; // 限购数量a
... ... @@ -3178,8 +3185,6 @@ Page({
3178 3185 flag = false;
3179 3186 }
3180 3187 }
3181   - pt_act=act_details;
3182   -
3183 3188 }
3184 3189  
3185 3190 }
... ...