From 6bf7b9f105b9b91a71f06af88ebbc0cc5d441532 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Mon, 10 Jul 2023 00:38:39 +0800 Subject: [PATCH] 1、拼团自定义的优化 2、 订单列表的待支付的问题优化 --- components/diy_pingd_buy/diy_pingd_buy.js | 7 +++++-- packageA/pages/details_serviceCard/details_serviceCard.js | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- pages/goods/goodsInfo/goodsInfo.wxss | 4 ++-- pages/user/order_list/order_list.js | 238 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------ pages/user/order_list/order_list.wxml | 6 +++++- 5 files changed, 351 insertions(+), 147 deletions(-) diff --git a/components/diy_pingd_buy/diy_pingd_buy.js b/components/diy_pingd_buy/diy_pingd_buy.js index 1b5e23d..837b4e1 100644 --- a/components/diy_pingd_buy/diy_pingd_buy.js +++ b/components/diy_pingd_buy/diy_pingd_buy.js @@ -49,12 +49,15 @@ Component({ clearInterval(this.data.timer); } }, - - + ready: function() { console.log("ready"); var g_id = this.data.object.data; + var data_type = this.data.object.data_type; console.log(g_id); + if(data_type!=2){ + g_id=null; + } this.init(g_id); }, detached() { diff --git a/packageA/pages/details_serviceCard/details_serviceCard.js b/packageA/pages/details_serviceCard/details_serviceCard.js index 9bc5db1..e52c5e9 100644 --- a/packageA/pages/details_serviceCard/details_serviceCard.js +++ b/packageA/pages/details_serviceCard/details_serviceCard.js @@ -4,6 +4,7 @@ const app = getApp(); const os = app.globalData.setting; let self = null; var util = require('../../../utils/util.js'); +const ut = require("../../../utils/util.js"); Page({ @@ -513,7 +514,7 @@ Page({ // 立即支付 - pay() { + async pay() { if(this.data.is_summit_ing) return false; this.data.is_summit_ing=1; @@ -522,51 +523,201 @@ Page({ let order_sn = this.data.details.order_sn; let order_id = this.data.details.order_id; let store_id = app.globalData.setting.stoid; - t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); - t_pay.pay({ - parentSn: order_sn, - store_id: store_id - }, function () { - app.showWarning('支付成功'); - setTimeout(function() { - wx.reLaunch({ - url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, - }) - }, 1000) - - }, function (e) { - th.data.is_summit_ing=0; - wx.showToast({ - title: e, - icon: 'none', - duration: 2000 - }); - }) - // app.request.post('/api/weshop/order/pay/createRechargeOrder', { - // data: { - // parentSn: order_sn, - // store_id: store_id, - // }, - // - // success: function(res) { - // var n = res.data.data; - // self.weixinPay(n, function() { - // app.showWarning('支付成功'); - // // setTimeout(function() { - // // wx.reLaunch({ - // // url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, - // // }) - // // }, 1000) - // }, function() { - // app.showWarning('支付失败'); - // // setTimeout(function() { - // // wx.reLaunch({ - // // url: '/packageA/pages/cardList/cardList', - // // }) - // // }, 1000) - // }); - // } - // }) + let user_id = os.user_id; + + let flag = true; + // 如果是普通购买或单独购买,不用判断 + // 如果是秒杀购买:1、判断活动是否变化;2、是否超出限购 + let list = this.data.details.list; + var pt_act=null; //-- 拼团活动的优化 -- + + //秒杀活动和拼团活动要重新计算一下 + for (const it of list) { + if (it.prom_type == 1) { + let act_details = null; + let redis_num = 0; + let promcardbuynum = 0; + let qty = it.qty; + + + await getApp().request.promiseGet('/api/ms/flash_sale/getNew/' + store_id + '/' + user_id + '/' + it.prom_id, {}).then(res => { + console.log('11111111====>>>'); + if (res.data.code == 0) { + console.log('当前的秒杀活动信息:', res.data.data); + act_details = res.data.data; + if (act_details.is_end == 1) { + wx.showModal({ + title: '提示', + content: '活动已结束,无法支付,请取消订单!', + showCancel: false, + }); + flag = false; + return false; + }; + if (act_details.id != it.prom_id) { + wx.showModal({ + title: '提示', + content: '活动发生了变化,无法支付,请取消订单,重新购买!', + showCancel: false, + }); + flag = false; + return false; + }; + + + var t_now = ut.gettimestamp(); + if (act_details.is_end == 0 && act_details.start_time < t_now && act_details.end_time > t_now) { + wx.showModal({ + title: '提示', + content: '活动发生了变化,无法支付,请取消订单,重新购买!', + showCancel: false, + }); + flag = false; + return false; + } + + }; + }); + + if(act_details.buy_limit>0 && flag){ + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { + data: { + store_id: store_id, + user_id: user_id, + card_id: it.card_id, + prom_type: it.prom_type, + prom_id: it.prom_id, + } + }).then(res => { + + if (res.data.code == 0) { + promcardbuynum = res.data.data.promcardbuynum; + let canBuyNum = act_details.buy_limit - promcardbuynum; // 自己还可购买的数量c + + if (canBuyNum < qty) { + wx.showModal({ + title: '提示', + content: '您已超出活动限购数量,无法支付,请取消订单!', + showCancel: false, + }); + flag = false; + } + } + }) + } + + }; + + if (it.prom_type == 6) { + let act_details = null; + let redis_num = 0; + let promcardbuynum = 0; + let qty = it.qty; + + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + store_id + "/" + it.prom_id, {}).then(res => { + + if (res.data.code == 0) { + + act_details = res.data.data; + + if (act_details.is_end == 1) { + wx.showModal({ + title: '提示', + content: '活动已结束,无法支付,请取消订单!', + showCancel: false, + }); + flag = false; + return false; + } + + if (act_details.id != it.prom_id) { + wx.showModal({ + title: '提示', + content: '活动发生了变化,无法支付,请取消订单,重新购买!', + showCancel: false, + }); + flag = false; + return false; + } + + var t_now = ut.gettimestamp(); + if (act_details.is_end == 1 || act_details.start_time > t_now || act_details.end_time < t_now) { + wx.showModal({ + title: '提示', + content: '活动发生了变化,无法支付,请取消订单,重新购买!', + showCancel: false, + }); + flag = false; + return false; + } + + }; + }); + + if(act_details.buy_limit>0){ + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { + data: { + store_id: store_id, + user_id: user_id, + card_id: it.card_id, + prom_type: it.prom_type, + prom_id: it.prom_id, + } + }).then(res => { + if (res.data.code == 0) { + console.log('已经购买的数量:', res.data.data); + promcardbuynum = res.data.data.promcardbuynum; + } + }) + let limited = act_details.buy_limit; // 限购数量a + let canBuyNum = limited - promcardbuynum; // 自己还可购买的数量c + + if (canBuyNum < qty ) { + wx.showModal({ + title: '提示', + content: '您已超出活动限购数量,无法支付,请取消订单!', + showCancel: false, + }); + flag = false; + } + } + pt_act=act_details; + } + } + + if (flag) { + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); + t_pay.pay({ + parentSn: order_sn, + store_id: store_id + }, function () { + app.showWarning('支付成功'); + + if(pt_act.is_zsorder==2){ + //--如果商家团的时候--- + getApp().request.promisePost("/api/weshop/order/pay/vipAutoTuan", { + data: {orderSn:order_sn,storeId:os.stoid } + }) + } + + setTimeout(function () { + wx.reLaunch({ + url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, + }) + }, 1000) + + }, function (e) { + th.data.is_summit_ing = 0; + wx.showToast({ + title: e, + icon: 'none', + duration: 2000 + }); + }) + }else{ + this.data.is_summit_ing=0; + } + }, //-- 支付尾款 -- diff --git a/pages/goods/goodsInfo/goodsInfo.wxss b/pages/goods/goodsInfo/goodsInfo.wxss index b283a5c..026a232 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxss +++ b/pages/goods/goodsInfo/goodsInfo.wxss @@ -3134,8 +3134,8 @@ xc-ensure-div { } .xc-qt-price .xc-qtunit-price { - margin-left: 6rpx; - margin-top: -4rpx; + /*margin-left: 6rpx;*/ + /*margin-top: -4rpx;*/ } .xc-nanber { diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index 48fb99c..c4526d9 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -1217,7 +1217,8 @@ Page({ success: function (t) { th.setData({ paying: 0 }); if (t.data.code == 0) { - th.onload(); + th.data.orderList.splice(o_index, 1); + th.setData({ orderList: th.data.orderList }); } else { getApp().confirmBox(t.data.msg + "请您取消该订单"); } @@ -1239,6 +1240,15 @@ Page({ wx.showToast({ title: '支付成功' }) th.data.orderList.splice(o_index, 1); th.setData({ orderList: th.data.orderList }); + + //商家团支付成功后,要让他的团能够建立或者参与 + if(e.is_zsorder==2){ + //--如果商家团的时候--- + getApp().request.promisePost("/api/weshop/order/pay/vipAutoTuan", { + data: {orderSn:e.order_sn,storeId:os.stoid } + }) + } + }, function () { th.setData({ paying: 0 }); }, os.stoid, 1); @@ -2470,19 +2480,23 @@ Page({ // 卡项订单 - 立即支付 pay: async function (e) { let th=this; + + if(th.data.ser_paying) return false; + th.data.ser_paying=1; + let index = e.currentTarget.dataset.index; let item = this.data.cardList[index]; let order_sn = item.order_sn; let order_id = item.order_id; let store_id = app.globalData.setting.stoid; let user_id = oo.user_id; - let flag = true; - + let flag = true; // 如果是普通购买或单独购买,不用判断 // 如果是秒杀购买:1、判断活动是否变化;2、是否超出限购 - let list = item.list; + var pt_act=null; //-- 拼团活动的优化 -- + for (const it of list) { if (it.prom_type == 1) { let act_details = null; @@ -2492,9 +2506,8 @@ Page({ await getApp().request.promiseGet('/api/ms/flash_sale/getNew/' + store_id + '/' + user_id + '/' + it.prom_id, {}).then(res => { - console.log('11111111====>>>'); + if (res.data.code == 0) { - console.log('当前的秒杀活动信息:', res.data.data); act_details = res.data.data; if (act_details.is_end == 1) { wx.showModal({ @@ -2514,108 +2527,127 @@ Page({ flag = false; return false; }; - }; - }); - await getApp().request.promiseGet('/api/weshop/activitylist/getActLen/' + store_id + '/' + it.prom_type + '/' + it.prom_id, { - 1: 1 - }).then(res => { - console.log('222222222====>>>'); - if (res.data.code == 0) { - // 当前可以购买的数量 - console.log('redis当前可以购买的数量:', res.data.data); - redis_num = res.data.data; - // if(redis_num <=0) { - // wx.showModal({ - // title: '提示', - // content: '活动库存不足,无法支付,请取消订单!', - // showCancel: false, - // }); - // // flag = false; - // return true; - // }; - }; - }); - await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { - data: { - store_id: store_id, - user_id: user_id, - card_id: it.card_id, - prom_type: it.prom_type, - prom_id: it.prom_id, + var t_now = ut.gettimestamp(); + if (act_details.is_end == 1 || act_details.start_time > t_now || act_details.end_time < t_now) { + wx.showModal({ + title: '提示', + content: '活动发生了变化,无法支付,请取消订单,重新购买!', + showCancel: false, + }); + flag = false; + return false; + } + } - }).then(res => { - console.log('333333333====>>>'); - if (res.data.code == 0) { - console.log('已经购买的数量:', res.data.data); - promcardbuynum = res.data.data.promcardbuynum; + }); + if(act_details.buy_limit>0 && flag){ + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { + data: { + store_id: store_id, + user_id: user_id, + card_id: it.card_id, + prom_type: it.prom_type, + prom_id: it.prom_id, + } + }).then(res => { + if (res.data.code == 0) { + promcardbuynum = res.data.data.promcardbuynum; + let canBuyNum = act_details.buy_limit - promcardbuynum; // 自己还可购买的数量c + + if (canBuyNum < qty) { + wx.showModal({ + title: '提示', + content: '您已超出活动限购数量,无法支付,请取消订单!', + showCancel: false, + }); + flag = false; + } + } + }) + } - let limited = act_details.buy_limit; // 限购数量a - let buyedNum = promcardbuynum; // 自己已经购买的数量b - let canBuyNum = limited - buyedNum; // 自己还可购买的数量c + }; + if (it.prom_type == 6) { + let act_details = null; + let redis_num = 0; + let promcardbuynum = 0; + let qty = it.qty; + + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + store_id + "/" + it.prom_id, {}).then(res => { + + if (res.data.code == 0) { + + act_details = res.data.data; - if (canBuyNum <= 0) { + if (act_details.is_end == 1) { wx.showModal({ title: '提示', - content: '您已超出活动限购数量,无法支付,请取消订单!', + content: '活动已结束,无法支付,请取消订单!', showCancel: false, }); flag = false; return false; - }; - - if (limited > redis_num) { - if (canBuyNum <= redis_num) { - if (qty > canBuyNum) { - wx.showModal({ - title: '提示', - content: '您已超出活动限购数量,无法支付,请取消订单!', - showCancel: false, - }); - flag = false; - return false; - }; - - }; - - if (canBuyNum > redis_num) { - if (qty > redis_num) { - wx.showModal({ - title: '提示', - content: '活动库存不足,无法支付,请取消订单!', - showCancel: false, - }); - flag = false; - return false; - }; + } - }; - }; + if (act_details.id != it.prom_id) { + wx.showModal({ + title: '提示', + content: '活动发生了变化,无法支付,请取消订单,重新购买!', + showCancel: false, + }); + flag = false; + return false; + } - if (limited <= redis_num) { - if (qty > canBuyNum) { - wx.showModal({ - title: '提示', - content: '您已超出活动限购数量,无法支付,请取消订单!', - showCancel: false, - }); - flag = false; - return false; - }; - }; - }; + var t_now = ut.gettimestamp(); + if (act_details.is_end == 1 || act_details.start_time > t_now || act_details.end_time < t_now) { + wx.showModal({ + title: '提示', + content: '活动发生了变化,无法支付,请取消订单,重新购买!', + showCancel: false, + }); + flag = false; + return false; + } + } }); - }; - - }; + if(act_details.buy_limit>0 && flag){ + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { + data: { + store_id: store_id, + user_id: user_id, + card_id: it.card_id, + prom_type: it.prom_type, + prom_id: it.prom_id, + } + }).then(res => { + if (res.data.code == 0) { + console.log('已经购买的数量:', res.data.data); + promcardbuynum = res.data.data.promcardbuynum; + } + }) + let limited = act_details.buy_limit; // 限购数量a + let canBuyNum = limited - promcardbuynum; // 自己还可购买的数量c + + if (canBuyNum < qty ) { + wx.showModal({ + title: '提示', + content: '您已超出活动限购数量,无法支付,请取消订单!', + showCancel: false, + }); + flag = false; + } + } + pt_act=act_details; - if(th.data.ser_paying) return false; - th.data.ser_paying=1; + } + } if (flag) { @@ -2624,12 +2656,24 @@ Page({ parentSn: order_sn, store_id: store_id }, function () { - th.data.ser_paying=0; - wx.showToast({ - title: '支付成功', - icon:'success', - duration: 2000 - }); + th.data.ser_paying=0; + wx.showToast({ + title: '支付成功', + icon:'success', + duration: 2000 + }); + + if(pt_act.is_zsorder==2){ + //--如果商家团的时候--- + getApp().request.promisePost("/api/weshop/order/pay/vipAutoTuan", { + data: {orderSn:order_sn,storeId:os.stoid } + }) + } + + th.data.cardList.splice(index, 1); + th.setData({ orderList: th.data.cardList }); + + }, function (e) { th.data.ser_paying=0; wx.showToast({ @@ -2660,7 +2704,9 @@ Page({ // }); // // } // }); - }; + }else { + th.data.ser_paying=0; + } }, diff --git a/pages/user/order_list/order_list.wxml b/pages/user/order_list/order_list.wxml index 259b154..0e8e518 100644 --- a/pages/user/order_list/order_list.wxml +++ b/pages/user/order_list/order_list.wxml @@ -334,12 +334,16 @@ - 已取消 + + + + 已取消 已作废 + 支付尾款失败 -- libgit2 0.21.4