From c866a4237b7140578e6ba0eb90920bd66a85c9ce Mon Sep 17 00:00:00 2001 From: cun-nan <19819293608@163.com> Date: Tue, 8 Oct 2024 10:59:23 +0800 Subject: [PATCH] 10.8 --- .../impl/MerchantConfigServiceImpl.java | 2 +- .../order/service/OilOrderService.java | 2 +- .../service/impl/OilOrderServiceImpl.java | 8 +- .../service/impl/MemberServiceImpl.java | 4 +- gasStation-uni/pages/refuel/refuel.vue | 215 +++++++++++++++++- 5 files changed, 211 insertions(+), 20 deletions(-) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java index 96b3b74ef..f928dc3dc 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java @@ -59,7 +59,7 @@ public class MerchantConfigServiceImpl extends ServiceImpl(); queryWrapper.eq("is_use","1"); queryWrapper.eq("store_id",storeId); - MerchantConfig merchantConfig = baseMapper.selectOne(queryWrapper); +// MerchantConfig merchantConfig = baseMapper.selectOne(queryWrapper); // if (ObjectUtil.isNotEmpty(merchantConfig) && merchantConfig.getIsOpenRule().equals("1")){ // List list = this.selectMeChByIsOpen(storeId); // if (list.size()>0){ diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java index 9d64988bf..024ed1c69 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java @@ -123,7 +123,7 @@ public interface OilOrderService extends IService { * @param oilOrder * @return */ - public String addOilOrder(OilOrder oilOrder); + public OilOrder addOilOrder(OilOrder oilOrder); /** * 小程序订单支付 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java index d78528fbb..e1fe1dac8 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java @@ -1575,7 +1575,7 @@ public class OilOrderServiceImpl extends ServiceImpl i } @Override - public String addOilOrder(OilOrder oilOrder) { + public OilOrder addOilOrder(OilOrder oilOrder) { // AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo1(); // 根据日期生成订单信息 @@ -1614,7 +1614,7 @@ public class OilOrderServiceImpl extends ServiceImpl i } else { baseMapper.insert(oilOrder); } - return orderNo; + return oilOrder; } @Override @@ -1795,8 +1795,8 @@ public class OilOrderServiceImpl extends ServiceImpl i // 修改订单的优惠金额和支付金额 oilOrder.setDiscountAmount(Double.valueOf(discountAmount)); oilOrder.setPayAmount(payAmount); - oilOrder.setBalanceAmount(Double.valueOf(balanceAmountSale)); - oilOrder.setOilCardAmount(Double.valueOf(oilCardAmountSale)); +// oilOrder.setBalanceAmount(Double.valueOf(balanceAmountSale)); +// oilOrder.setOilCardAmount(Double.valueOf(oilCardAmountSale)); if (StringUtils.isNotEmpty(activeId)) { oilOrder.setActiveId(Integer.valueOf(activeId)); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java index 24f79dba8..fe690ae92 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java @@ -775,7 +775,7 @@ public class MemberServiceImpl extends ServiceImpl impleme mtUser.setOpenId(openId); mtUser.setMobile(mobile); - mtUser.setName("("+mobile+")微信自动注册用户"); + mtUser.setName("微信用户("+mobile+")"); mtUser.setCreateTime(new Date()); mtUser.setUpdateTime(new Date()); mtUser.setDescription("微信登录自动注册"); @@ -793,7 +793,7 @@ public class MemberServiceImpl extends ServiceImpl impleme user.setOpenId(openId); user.setMobile(mobile); - user.setName("("+mobile+")微信自动注册用户"); + user.setName("微信用户("+mobile+")"); user.setCreateTime(new Date()); user.setUpdateTime(new Date()); user.setDescription("微信登录自动注册"); diff --git a/gasStation-uni/pages/refuel/refuel.vue b/gasStation-uni/pages/refuel/refuel.vue index 18e92b353..0e39f00ca 100644 --- a/gasStation-uni/pages/refuel/refuel.vue +++ b/gasStation-uni/pages/refuel/refuel.vue @@ -33,7 +33,8 @@ - ¥ + ¥ {{oilOrder.oilNum || 0}}L @@ -260,7 +261,7 @@ - 消费应支付245.99元 + 消费应支付{{oilOrder.payAmount}}元 会员-储值卡(余额:8900.99) @@ -268,7 +269,7 @@ - 立即支付245.99元 + 立即支付{{oilOrder.payAmount}}元 @@ -282,22 +283,22 @@ 员工 - 小王 + {{staffName || '--'}} 油品单价 - 7.28元/L + {{oilPrice || 0}}元/{{oilUnit || 'L'}} 加油升数 - 约36.88L + 约{{oilOrder.oilNum}}L 加油金额 256.89元 - 商品信息 + 优惠信息 优惠券 -10.00 @@ -315,7 +316,7 @@ 合计待支付 - 568.99 + {{oilOrder.payAmount}} @@ -403,14 +404,17 @@ terminal: "applet", oils: "", oilGunNum: "", - oilNum: "", + oilNum: 0, orderAmount: 0, discountAmount: 0, payAmount: 0, payType: uni.getStorageSync("appltType"), }, // 优惠券列表 - couponList: [] + couponList: [], + // 是否登录 + ifLogin: false, + orderInfo:{}, } }, components: { @@ -478,6 +482,157 @@ }, methods: { + // 支付接口 + payment() { + this.ifLogin = this.AppToken ? true : false + let map = { + orderNo: this.oilOrder.orderNo, + payAmount: this.oilOrder.payAmount, + discountAmount: this.oilOrder.discountAmount, + oilCardAmount: '', + oilCardLiters: this.oilOrder.oilCardAmount || 0, + balanceAmount: this.oilOrder.balanceAmount || 0, + isOilStorageCard: false, + tankId: this.oilOrder.tankId, + isUseChildCard: false, + // activeId: this.preferentialData.activeId, + // cardFavorableId: this.preferentialData.cardFavorableId, + // recordId: this.preferentialData.recordId, + // type: this.preferentialData.type, + // balanceAmountSale: this.balanceRedece, + // oilCardAmountSale: this.oilCardRedece, + ifLogin: this.ifLogin, + // levelAmount: this.levelAmount, + // activeAmount: this.activeAmount + }; + let _this = this; + request({ + url: "business/oilOrder/appletPay", + method: 'post', + data: map, + }).then(res => { + let payProvider = "wxpay" + if (_this.appltType == "WECHAT") { + payProvider = "wxpay" + } else { + payProvider = "alipay" + } + if (res.data.error) { + request({ + url: "/business/allOrderInfo/orderStatus", + method: 'post', + data: { + "orderNo": _this.oilOrder.orderNo, + "status": "payFail" + }, + }).then((ress) => {}) + uni.showToast({ + title: res.data.error, + icon: "none" + }) + return; + } + if (res.data.code == "error") { + request({ + url: "/business/allOrderInfo/orderStatus", + method: 'post', + data: { + "orderNo": _this.oilOrder.orderNo, + "status": "payFail" + }, + }).then((ress) => {}) + uni.showToast({ + title: "支付失败,请联系商家", + icon: "none" + }) + return; + } + if (res.data.success == "ok") { + uni.redirectTo({ + url: '/pagesRefuel/orderSuccess/index?orderNo=' + _this.oilOrder.orderNo, + }) + return; + } + if (res.data.resultMsg == "商户订单号重复") { + uni.showToast({ + title: "商户订单号重复,请重新选择订单信息进行支付!", + icon: "none" + }) + } + if (res.data.data.reservedPayInfo) { + _this.orderInfo = JSON.parse(res.data.data.reservedPayInfo); + uni.requestPayment({ + // 微信支付provider: 'wxpay' 支付宝支付 'alipay' + provider: payProvider, + // 时间戳 + timeStamp: _this.orderInfo.timeStamp, + // 随机字符串 + nonceStr: _this.orderInfo.nonceStr, + // 固定值 + package: _this.orderInfo.package, + // 解密方式 + signType: 'MD5', + // 支付签名 + paySign: _this.orderInfo.paySign, + success: function(res) { + console.log('success'); + uni.redirectTo({ + url: '/pagesRefuel/orderSuccess/index?orderNo=' + _this.oilOrder.orderNo, + }) + }, + fail: function(err) { + request({ + url: "/business/allOrderInfo/orderStatus", + method: 'post', + data: { + "orderNo": res.data.data.orderNo, + "status": "payFail" + }, + }).then((res) => { + uni.showToast({ + title: "支付失败!", + icon: "error" + }) + }) + console.log('fail:', err); + } + }); + } + if (_this.appltType == "ALIPAY") { + my.tradePay({ + tradeNO: res.data.data.reservedTransactionId + }, function(resp) { + if (resp.resultCode == '9000') { + console.log("支付成功") + uni.redirectTo({ + url: '/pagesRefuel/orderSuccess/index?orderNo=' + _this.oilOrder.orderNo, + }) + } else { + request({ + url: "/business/allOrderInfo/orderStatus", + method: 'post', + data: { + "orderNo": res.data.data.orderNo, + "status": "payFail" + }, + }).then((res) => { + uni.showToast({ + title: "支付失败!", + icon: "error" + }) + }) + console.log('支付失败,' + resp.resultCode); + } + }); + } + }) + }, + changeAmount() { + if (this.oilOrder.orderAmount) { + this.oilOrder.payAmount = this.oilOrder.orderAmount - this.oilOrder.discountAmount + this.oilOrder.oilNum = (this.oilOrder.orderAmount / this.oilPrice).toFixed(2) + } + }, getCouponList() { request({ url: "pay/paycenter/getCoupon", @@ -510,6 +665,7 @@ this.oilPrice = data.oilPrice this.oilUnit = data.unit this.oilOrder.oils = data.oilNameId + this.oilOrder.tankId = data.oilGunList[0].tankId uni.setStorageSync("tankId", data.oilGunList[0].tankId) this.oilGunName = data.oilGunList[0].gunName } @@ -529,6 +685,7 @@ this.qhindex = index this.selectShow = false this.oilOrder.oilGunNum = data.id + this.oilOrder.tankId = data.tankId uni.setStorageSync("tankId", data.tankId) this.oilGunName = data.gunName }, @@ -538,7 +695,41 @@ }, goPayment() { // 判断一下按照什么方式支付的 - this.ConfirmPayment = true + if (this.oilOrder.orderAmount <= 0) { + uni.showToast({ + title: "请先输入加油金额", + icon: 'none' + }) + return; + } + request({ + url: "business/petrolStationManagement/oilTank/" + uni.getStorageSync('tankId'), + method: 'get', + }).then((res) => { + if (res.data.storedQuantity - this.oilOrder.oilNum < 0) { + uni.showToast({ + title: "所加油的升数大于油罐内的升数,请重新选择加油升数", + icon: "none" + }) + return; + } else { + this.ConfirmPayment = true + this.addOrder() + } + }) + + }, + // 点击支付添加油品订单信息 + addOrder() { + this.oilOrder.storeId = uni.getStorageSync('storeId') + request({ + url: "business/oilOrder/addOilOrder", + method: 'post', + data: this.oilOrder, + }).then((res) => { + console.log(res,578); + this.oilOrder = res.data + }) }, Selectclose() { this.Selectemployees = false @@ -648,6 +839,7 @@ if (res.data[0].oilGunList) { _this.oilGunList = res.data[0].oilGunList _this.oilOrder.oilGunNum = res.data[0].oilGunList[0].id + _this.oilOrder.tankId = res.data[0].oilGunList[0].tankId uni.setStorageSync("tankId", res.data[0].oilGunList[0].tankId) _this.oilGunName = res.data[0].oilGunList[0].gunName } @@ -699,7 +891,6 @@ } else { this.toPayment(id) } - }) }, // 去支付(之前的)