From 06fcb5fe98d456ddd0965842bcf59d2fffb7d3d8 Mon Sep 17 00:00:00 2001 From: cun-nan <19819293608@163.com> Date: Fri, 19 Jan 2024 18:48:13 +0800 Subject: [PATCH] bug --- .../src/views/components/Service/payment.vue | 1 + .../service/impl/OilConfigServiceImpl.java | 8 +- .../service/impl/OilOrderServiceImpl.java | 105 ++++++-------- .../userManager/service/LJUserService.java | 2 + .../service/impl/LJUserServiceImpl.java | 37 +++++ .../controller/AlipayController.java | 22 +-- .../AlipayApi/service/AlipayService1.java | 4 +- .../service/impl/AlipayServiceImpl1.java | 15 +- .../src/api/cashier/preferential.js | 10 ++ .../views/cashier/NewComponents/homeindex.vue | 78 +++++++--- gasStation-uni/pagesLogin/login/login.vue | 66 +++++---- .../pagesRefuel/orderDetail/index.vue | 133 ++++++++++-------- 12 files changed, 300 insertions(+), 181 deletions(-) diff --git a/fuintAdmin_zt/src/views/components/Service/payment.vue b/fuintAdmin_zt/src/views/components/Service/payment.vue index b12eb6f52..afa47da87 100644 --- a/fuintAdmin_zt/src/views/components/Service/payment.vue +++ b/fuintAdmin_zt/src/views/components/Service/payment.vue @@ -400,6 +400,7 @@ export default { submitOilConfig(){ this.$refs["form"].validate(valid => { if (valid) { + this.form.storeId = this.merchantConfig.storeId if (this.form.id) { editOilConfig(this.form).then(response => { this.$modal.msgSuccess("修改通道成功"); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/OilConfigServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/OilConfigServiceImpl.java index 732bbad6b..886f5306b 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/OilConfigServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/OilConfigServiceImpl.java @@ -10,6 +10,7 @@ import com.fuint.api.fuyou.service.MerchantConfigService; import com.fuint.api.fuyou.service.OilConfigService; import com.fuint.api.fuyou.vo.OilConfigVo; import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.StringUtils; import com.fuint.common.util.TokenUtil; import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; @@ -119,7 +120,12 @@ public class OilConfigServiceImpl extends ServiceImpl i // 支付状态 String payStatus = "unpaid"; - if (payType.equals("CASH")){ + if (payType.equals("CASH") || map.get("allAmount").equals("0")){ payStatus = "paid"; }else { payStatus = "unpaid"; @@ -482,8 +482,9 @@ public class OilOrderServiceImpl extends ServiceImpl i */ private Map updateUserBalanceAndInsetOrder(int userId,Map map,Double oilAmount,List oilOrders,Integer storeId){ Map res = new HashMap<>(); + LJStore store = storeService.selectStoreByStoreId(storeId); // 根据userId查询用户储值卡信息 - UserBalance balance = userBalanceService.selectUserBalanceByStorId(userId,storeId); + UserBalance balance = userBalanceService.selectUserBalance(userId,store.getChainStoreId()); // 根据用户id查询用户信息 LJUserVo userVo1 = userService.selectUserById(userId,storeId); @@ -632,6 +633,44 @@ public class OilOrderServiceImpl extends ServiceImpl i }else { res.put("error","囤油卡或储值卡余额不足!"); } + }else { + Double amount = Double.valueOf(oilOrders.get(i).get("amount").toString()); + Double oilPrice = Double.valueOf(oilOrders.get(i).get("oilPrice").toString()); + flag = true; + status = "paid"; + Double oilNum = amount / oilPrice; + oilLiters += oilNum; + if (i == 0) { + order.setOrderType("主订单"); + order.setOrderAmount(amount); + order.setPayAmount(amount); + order.setOrderNo(orderNo); + } else { + order.setOrderType("子订单"); + order.setOrderAmount(amount); + order.setPayAmount(0.0); + order.setOrderNo(orderNo + "1"); + } + order.setStoreId(accountInfo.getStoreId()); + order.setUserId(userId); + order.setCommissionAmount(Double.valueOf(map.get("commissionAmount"))); + order.setStaffId(Integer.valueOf(map.get("staffId"))); + order.setTerminal(map.get("terminal")); + order.setOils((String) oilOrders.get(i).get("oilName")); + order.setOilGunNum(oilOrders.get(i).get("gunName").toString()); + order.setOilNum(oilNum); +// order.setDiscountAmount(Double.valueOf(map.get("oilDiscount"))); + order.setPayUser(userVo1.getMobile()); + order.setPayType(map.get("payType")); + order.setInvoicing("未开票"); + order.setOrderStatus("paid"); + order.setPayTime(new Date()); + + this.addOilTrack(oilOrders.get(i), accountInfo.getStoreId()); + baseMapper.insert(order); + + oilOrder = this.selectOilOrderByOrderNo(orderNo); + this.updateGrowthValue1(oilAmount,userId, Integer.valueOf(oilOrder.getOils()),0.0,storeId,orderNo); } } @@ -725,65 +764,6 @@ public class OilOrderServiceImpl extends ServiceImpl i res.put("error","储值卡余额不足!"); } } -// } else { -//// 添加油品订单信息 -// OilOrder order = new OilOrder(); -// for (int i = 0;i < oilOrders.size();i++) { -// Double amount = Double.valueOf(oilOrders.get(i).get("amount").toString()); -// Double oilPrice = Double.valueOf(oilOrders.get(i).get("oilPrice").toString()); -// Double oilNum = amount / oilPrice; -// if (i == 0) { -// order.setOrderType("主订单"); -// order.setOrderAmount(amount); -// order.setPayAmount(0.0); -// order.setOrderNo(orderNo); -// } else { -// order.setOrderType("子订单"); -// order.setOrderAmount(amount); -// order.setPayAmount(0.0); -// order.setOrderNo(orderNo + "1"); -// } -// order.setStoreId(accountInfo.getStoreId()); -// order.setUserId(userId); -// order.setCommissionAmount(Double.valueOf(map.get("commissionAmount"))); -// order.setStaffId(Integer.valueOf(map.get("staffId"))); -// order.setTerminal(map.get("terminal")); -// order.setOils((String) oilOrders.get(i).get("oilName")); -// order.setOilGunNum(oilOrders.get(i).get("gunName").toString()); -// order.setOilNum(oilNum); -//// order.setDiscountAmount(Double.valueOf(map.get("oilDiscount"))); -// order.setPayUser(userVo1.getMobile()); -// order.setPayType(map.get("payType")); -// order.setInvoicing("未开票"); -// order.setOrderStatus("paid"); -// order.setPayTime(new Date()); -// -// this.addOilTrack(oilOrders.get(i), accountInfo.getStoreId()); -// baseMapper.insert(order); -// } -// OilOrder oilOrder = this.selectOilOrderByOrderNo(orderNo); -// -//// 添加收银台订单信息 -// CashierOrder cashierOrder = new CashierOrder(); -// cashierOrder.setStaffId(Integer.valueOf(map.get("staffId"))); -// cashierOrder.setStoreId(accountInfo.getStoreId()); -// cashierOrder.setPayUser(userVo1.getMobile()); -// cashierOrder.setAmount(oilAmount); -// cashierOrder.setPayAmount(oilAmount); -// cashierOrder.setStatus("paid"); -// cashierOrder.setPayTime(new Date()); -// cashierOrder.setOrderNo(orderNo); -// cashierOrder.setOilOrderAmount(oilAmount); -//// cashierOrder.setOilDiscountAmount(Double.valueOf(map.get("oilDiscount"))); -// cashierOrder.setTerminal(map.get("terminal")); -// cashierOrder.setOilOrderId(oilOrder.getId()); -// cashierOrderService.insertCashierOrder(cashierOrder); -// this.updateGrowthValue1(oilAmount,userId, Integer.valueOf(oilOrder.getOils()),0.0,storeId); -// this.insertAllOrderInfo(orderNo,accountInfo.getStoreId(),oilAmount,map.get("payType"),userId,"PC","1","paid"); -// -// res.put("success","success"); -// } - return res; } @@ -827,7 +807,8 @@ public class OilOrderServiceImpl extends ServiceImpl i * @param refuelMoney 扣除的囤油卡升数 */ private void updateGrowthValue1(Double oilActualPay,Integer userid,Integer oilId,Double refuelMoney,Integer storeId,String orderNo){ - UserBalance balance = userBalanceService.selectUserBalanceByStorId(userid,storeId); + LJStore store = storeService.selectStoreByStoreId(storeId); + UserBalance balance = userBalanceService.selectUserBalance(userid,store.getChainStoreId()); JSONArray refuelMoneys = JSONArray.parseArray(balance.getRefuelMoney()); if (ObjectUtil.isNotEmpty(refuelMoneys)){ List list = new ArrayList<>(); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/LJUserService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/LJUserService.java index cca95a4c9..c12ff8080 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/LJUserService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/LJUserService.java @@ -111,6 +111,8 @@ public interface LJUserService extends IService { */ public int insertUser(LJUserVo user); + int addUser(LJUser user); + /** * 修改会员信息 * @param user diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/impl/LJUserServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/impl/LJUserServiceImpl.java index afe716053..2afa48bb6 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/impl/LJUserServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/impl/LJUserServiceImpl.java @@ -353,6 +353,43 @@ public class LJUserServiceImpl extends ServiceImpl impleme return row; } + @Override + public int addUser(LJUser user) { +// 生成会员号 + if (StringUtils.isEmpty(user.getUserNo())){ + Random random = new Random(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 7; i++) { + sb.append(random.nextInt(10)); + } + String digits = sb.toString(); + + int sum = 0; + for (int i = 0; i < digits.length(); i++) { + int digit = Integer.parseInt(String.valueOf(digits.charAt(i))); + if (i % 2 == 0) { + sum += digit; + } else { + sum += digit * 3; + } + } + int checksum = (10 - (sum % 10)) % 10; + + String number = digits + checksum; + user.setUserNo(number); + } + if (StringUtils.isEmpty(user.getName())){ + String before = user.getMobile().substring(0, 3); + String after = user.getMobile().substring(7); + user.setName(before+"****"+after); + }else { + user.setName(user.getName()); + } + user.setDescription("支付宝登录自动注册"); + int row = baseMapper.insert(user); + return row; + } + /** * 修改会员信息 * @param userVo diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/controller/AlipayController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/controller/AlipayController.java index 788431292..2654e4f2b 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/controller/AlipayController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/controller/AlipayController.java @@ -49,10 +49,14 @@ public class AlipayController extends BaseController { logger.info("支付宝授权登录参数:{}", map); String authCode = map.get("authCode"); String encryptedData = map.get("encryptedData"); -// alipayService.getUserMobile(encryptedData); + Map userMobile = alipayService.getUserMobile(encryptedData); + String mobile = ""; + if (userMobile.get("msg").equals("Success")){ + mobile = userMobile.get("mobile"); + } String storeId = map.get("storeId"); - if ("".equals(storeId)) return getFailureResult(0, "支付宝登录失败"); +// if ("".equals(storeId)) return getFailureResult(0, "支付宝登录失败"); // 根据storeId查找对应的连锁店id LJStore ljStore = iljStoreService.selectStoreByIdUni(Integer.parseInt(storeId)); // 获取支付宝userid @@ -63,19 +67,19 @@ public class AlipayController extends BaseController { String userId = alipayProfile.getUserId(); // 根据手机号查询用户信息 - LJUser user = userService.selectUserByMobile(map.get("phone")); + LJUser user = userService.selectUserByMobile(mobile); if (ObjectUtil.isNotEmpty(user)){ // 存在则修改用户的支付宝userid user.setUserId(userId); userService.updateById(user); }else { // 不存在则添加用户的支付宝userid - LJUserVo ljUser = new LJUserVo(); - ljUser.setMobile(map.get("phone")); + LJUser ljUser = new LJUser(); + ljUser.setMobile(mobile); ljUser.setUserId(userId); - userService.insertUser(ljUser); + userService.addUser(ljUser); } - LJUser ljUser = userService.selectUserByMobile(map.get("phone")); + LJUser ljUser = userService.selectUserByMobile(mobile); String userAgent = request.getHeader("user-agent"); AccountInfo accountInfo = new AccountInfo(); @@ -89,7 +93,9 @@ public class AlipayController extends BaseController { TokenUtil.saveAccountToken(accountInfo); LoginResponse response = new LoginResponse(); response.setLogin(true); - response.setChainStoreId(ljStore.getChainStoreId()); + if (ObjectUtil.isNotEmpty(ljStore)){ + response.setChainStoreId(ljStore.getChainStoreId()); + } response.setToken(token); response.setTokenCreatedTime(new Date()); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/service/AlipayService1.java b/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/service/AlipayService1.java index 70b2df95c..3f509b1c4 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/service/AlipayService1.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/service/AlipayService1.java @@ -3,6 +3,8 @@ package com.fuint.module.AlipayApi.service; import com.alipay.api.AlipayApiException; import com.alipay.api.response.AlipaySystemOauthTokenResponse; +import java.util.Map; + public interface AlipayService1 { /** * 获取用户支付宝userId @@ -12,5 +14,5 @@ public interface AlipayService1 { */ public AlipaySystemOauthTokenResponse getAlipayProfile(String code) throws AlipayApiException; - void getUserMobile(String encryptedData) throws Exception; + Map getUserMobile(String encryptedData) throws Exception; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/service/impl/AlipayServiceImpl1.java b/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/service/impl/AlipayServiceImpl1.java index 31e10c78d..4f4d9e132 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/service/impl/AlipayServiceImpl1.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/module/AlipayApi/service/impl/AlipayServiceImpl1.java @@ -3,6 +3,7 @@ package com.fuint.module.AlipayApi.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.parser.Feature; +import com.alibaba.fastjson2.JSONObject; import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayClient; import com.alipay.api.AlipayConfig; @@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; +import java.util.HashMap; import java.util.Map; @Service @@ -69,8 +71,8 @@ public class AlipayServiceImpl1 implements AlipayService1 { } @Override - public void getUserMobile(String encryptedData) throws Exception { - + public Map getUserMobile(String encryptedData) throws Exception { + Map res = new HashMap<>(); //1. 获取验签和解密所需要的参数 Map openapiResult = JSON.parseObject(encryptedData, new TypeReference>() {}, Feature.OrderedField); @@ -108,7 +110,7 @@ public class AlipayServiceImpl1 implements AlipayService1 { String plainData = null; if (isDataEncrypted) { try { - AlipayEncrypt.decryptContent(content, encryptType, decryptKey, charset); + plainData = AlipayEncrypt.decryptContent(content, encryptType, decryptKey, charset); } catch (AlipayApiException e) { //解密异常, 记录日志 throw new Exception("解密异常"); @@ -116,5 +118,12 @@ public class AlipayServiceImpl1 implements AlipayService1 { } else { plainData = content; } + JSONObject object = JSONObject.parseObject(plainData); + // 遍历 Map 获取 key-value 值 + for (Object key : object.keySet()) { + System.out.println("Key: " + key + ", Value: " + object.get(key)); + res.put(key.toString(),object.get(key).toString()); + } + return res; } } diff --git a/fuintCashierWeb/src/api/cashier/preferential.js b/fuintCashierWeb/src/api/cashier/preferential.js index a55103428..b559e2e0d 100644 --- a/fuintCashierWeb/src/api/cashier/preferential.js +++ b/fuintCashierWeb/src/api/cashier/preferential.js @@ -17,3 +17,13 @@ export function selectCoupon(data) { params: data }) } + +// 查询优惠券信息 +export function getPaymentActive(data) { + return request({ + url: '/business/marketingActivity/activeExchange/getPaymentActive', + method: 'get', + params: data + }) +} + diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/homeindex.vue b/fuintCashierWeb/src/views/cashier/NewComponents/homeindex.vue index 4730977cf..4ab6b56e2 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/homeindex.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/homeindex.vue @@ -89,7 +89,7 @@
-¥{{ fullReduction }}
-
+
-¥{{ oilDiscount }}
-
+
({{ item.type }}卡 - {{ item.oilType }} + 余额:{{ item.refuelMoney }}L)
- {{ consumeRefuelMoney }}L
-
+
@@ -145,7 +145,7 @@
-¥{{ consumeAmount }}
-
+
0){ - this.preferential(); - this.getCoupon(); - } } + // await this.getGrade(data.id,data.gradeId) + // if (!this.isFixingLevel){ + // this.preferentialData.storeId = this.storeId; + // this.preferentialData.userId = data.id; + // this.preferentialData.gradeId = data.gradeId; + // if (this.oilOrder.length>0){ + // this.preferential(); + // this.getCoupon(); + // } + // } + this.getOilCoupon() + }, + getOilCoupon(){ + let type = 0; + if (this.consumeAmount==0){ + type = 1; + }else { + type = 0; + } + this.paymentActive.type = type + this.paymentActive.mtUserLevel = this.member.gradeId + this.paymentActive.userId = this.member.id + let _this = this + this.oilOrder.forEach(item => { + console.log(item) + _this.paymentActive.amount = item.amount + _this.paymentActive.oilId = item.oilName + _this.paymentActive.storeId = item.storeId + + getPaymentActive(_this.paymentActive).then(res => { + console.log(res) + }) + }) }, // 调用优惠券接口 getCoupon(){ @@ -2381,12 +2413,14 @@ this.oilTotal = this.oilOrder.length; this.select = "元"; if (this.isMember){ - this.getGrade(this.member.id,this.member.gradeId) - this.changeRefuelMoney(); - if (this.oilOrder.length>0){ - this.preferential(); - this.getCoupon(); - } + // this.getGrade(this.member.id,this.member.gradeId) + // this.changeRefuelMoney(); + // if (this.oilOrder.length>0){ + // this.preferential(); + // this.getCoupon(); + // } + + this.getOilCoupon() } } }) diff --git a/gasStation-uni/pagesLogin/login/login.vue b/gasStation-uni/pagesLogin/login/login.vue index e968b87f6..328654f29 100644 --- a/gasStation-uni/pagesLogin/login/login.vue +++ b/gasStation-uni/pagesLogin/login/login.vue @@ -61,41 +61,51 @@ console.log(e) let _this = this; - my.getAuthCode({ - // my.getPhoneNumber({ + + my.getPhoneNumber({ scopes: 'auth_base', - success: res => { - const authCode = res.authCode; - let encryptedData = res.response; + success: res1 => { + let encryptedData = res1.response; // _this.setData({ // ['userInfo.phone']: "18457621459", // alertPhone: false, // }) - console.log(res) - request({ - url: "clientApi/sign/alipayLogin/getUserid", - method: 'post', - data: { - authCode: authCode, - storeId: 0, - staffId: "", - phone: "18457621459", - encryptedData:encryptedData, - }, - }).then((resp) => { - console.log(resp) - if (resp.code == 200) { - - uni.setStorageSync('App-Token', resp.data.token); - uni.setStorageSync('chainStoreId', resp.data.chainStoreId); - - uni.navigateTo({ - url: '/pages/index/index' + my.getAuthCode({ + scopes: 'auth_base', + success: res => { + const authCode = res.authCode; + console.log(res) + request({ + url: "clientApi/sign/alipayLogin/getUserid", + method: 'post', + data: { + authCode: authCode, + storeId: 0, + staffId: "", + phone: "18457621459", + encryptedData:encryptedData, + }, + }).then((resp) => { + console.log(resp) + if (resp.code == 200) { + + uni.setStorageSync('App-Token', resp.data.token); + uni.setStorageSync('chainStoreId', resp.data.chainStoreId); + + uni.navigateTo({ + url: '/pages/index/index' + }) + } + console.log("swq", uni.getStorageSync( + 'App-Token')); }) + }, + fail: err => { + console.log('my.getAuthCode 调用失败', err) } - console.log("swq", uni.getStorageSync( - 'App-Token')); - }) + }); + + }, fail: err => { console.log('my.getAuthCode 调用失败', err) diff --git a/gasStation-uni/pagesRefuel/orderDetail/index.vue b/gasStation-uni/pagesRefuel/orderDetail/index.vue index 706aa1792..7a0cf2a92 100644 --- a/gasStation-uni/pagesRefuel/orderDetail/index.vue +++ b/gasStation-uni/pagesRefuel/orderDetail/index.vue @@ -47,12 +47,6 @@ -¥{{balanceRedece}} - - - - - - @@ -67,14 +61,14 @@ - {{oilCardRedece}}L - + - + 活动优惠 @@ -91,7 +85,7 @@ - + 优惠券优惠 (优惠券) @@ -99,16 +93,11 @@ -¥{{couponRedece}} - - + 会员等级优惠 @@ -116,15 +105,10 @@ -¥{{gradeRedece}} - - 无优惠 + 已为您计算出最大优惠 注:囤油卡不参与任何优惠活动 @@ -251,11 +235,21 @@ checkFull:false, checkCoupon:false, checkGrade:false, + preferentialData:{ + activeFavorableAmount: "", + activeId: "", + activeInfo: "", + cardFavorableAmount: "", + cardFavorableId: "", + cardFavorableInfo: "", + memberFavorableAmount: "", + type: "", + }, } }, onLoad(e) { this.orderNo = e.orderNo - // this.orderNo = "234520240117095256fbd86e" + // this.orderNo = "234520240119103259511c58" }, onShow() { this.getOilOrder(); @@ -264,42 +258,15 @@ }, methods: { - // 选择储值卡 - changeBalance(val){ - console.log("balance",this.checkBalance,val); - }, // 选择囤油卡 changeOilCard(val){ - console.log("oilcard",this.checkBalance,val); + this.checkOilCard = val if (val){ - // this.payAmount = this.deductAmount - this.gradeRedece - } - }, - // 选择满减或折扣 - changeFull(val){ - console.log("balance",this.checkBalance,val); - if (val){ - this.payAmount = this.deductAmount - this.fullRedece + this.chooseRefuelMoney() }else{ - this.payAmount = this.deductAmount - } - }, - // 选择优惠券 - changeCoupon(val){ - console.log("balance",this.checkBalance,val); - if (val){ - this.payAmount = this.deductAmount - this.couponRedece - }else{ - this.payAmount = this.deductAmount - } - }, - // 选择会员等级 - changeGrade(val){ - console.log("balance",this.checkBalance,val); - if (val){ - this.payAmount = this.deductAmount - this.gradeRedece - }else{ - this.payAmount = this.deductAmount + this.payAmount = this.payAmount + (this.oilCardRedece * this.oilPrice) + this.oilCardRedece = 0 + this.getPaymentPreferential(this.user.gradeId) } }, @@ -371,6 +338,14 @@ paySign: _this.orderInfo.paySign, success: function (res) { console.log('success'); + // 支付成功后调用修改使用后的优惠券情况 + request({ + url: "business/marketingActivity/cardFavorableRecord/updateCardAndActiveById", + method: 'put', + data: {"paymentActiveVO":_this.preferentialData}, + }).then((res)=>{ + console.log(res); + }) uni.reLaunch({ url: '/pagesRefuel/orderSuccess/index' }) @@ -394,6 +369,14 @@ my.tradePay({ tradeNO: res.data.data.reservedTransactionId }, function(resp){ if(resp.resultCode == '9000'){ console.log("支付成功") + // 支付成功后调用修改使用后的优惠券情况 + request({ + url: "business/marketingActivity/cardFavorableRecord/updateCardAndActiveById", + method: 'put', + data: {"paymentActiveVO":_this.preferentialData}, + }).then((res)=>{ + console.log(res); + }) uni.reLaunch({ url: '/pagesRefuel/orderSuccess/index' }) @@ -435,6 +418,7 @@ this.oilCardRedece = this.refuelMoney[i].refuelMoney this.refuelMoneyAfter[i].refuelMoney = 0 if (falg) { + this.checkOilCard = true this.chooseCardBalance(1) } } @@ -477,7 +461,6 @@ } }else{ this.deductAmount = this.oilOrder.orderAmount - this.transferDTO.amount = this.deductAmount } }, // 查看是否有可使用的会员等级优惠 @@ -845,7 +828,45 @@ // _this.chooseGrade(res.data.userVo.id,res.data.userVo.gradeId) }) }, - // getPayment + getPaymentPreferential(gradeId){ + let type = 0; + if (this.balanceRedece==0){ + type = 1 + }else{ + type = 0 + } + let map = { + //支付类型 0:储值卡 1:囤油卡 + type: type, + //支付金额 + amount: this.oilOrder.orderAmount, + //可用油品Id + oilId: this.oilOrder.oils, + //店铺id + storeId: this.oilOrder.storeId, + //会员等级 + mtUserLevel: gradeId, + //用户id + userId: this.oilOrder.userId, + } + request({ + url: "business/marketingActivity/activeExchange/getPaymentActive", + method: 'get', + params:map, + }).then((res) => { + this.preferentialData = res.data + if (res.data.memberFavorableAmount){ + this.gradeRedece = res.data.memberFavorableAmount + } + if (res.data.cardFavorableAmount){ + this.couponRedece = res.data.cardFavorableAmount + } + if (res.data.activeFavorableAmount){ + this.fullRedece = res.data.activeFavorableAmount + } + console.log(this.gradeRedece,this.couponRedece,this.fullRedece,res.data.memberFavorableAmount,"2231"); + }) + }, // 获取油品订单 getOilOrder() { let _this = this;