diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java index 26fb6ec84..9cc5a0b99 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.fleet.entity.FleetInfo; import com.fuint.business.fleet.vo.FleetInfoUniVo; import com.fuint.business.fleet.vo.FleetInfoVo; +import com.fuint.framework.web.ResponseObject; import java.util.List; @@ -98,4 +99,10 @@ public interface FleetInfoService { * @return */ int ifFleetAdmin(Integer fleetId); + + /** + * 车队卡支付 + * @param orderId + */ + int payFleet(String orderId, Double money); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java index 890f7d11d..583bcf42e 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java @@ -2,6 +2,7 @@ package com.fuint.business.fleet.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -9,8 +10,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.business.fleet.entity.FleetConsumeRecord; import com.fuint.business.fleet.entity.FleetInfo; import com.fuint.business.fleet.entity.FleetMember; +import com.fuint.business.fleet.mapper.FleetConsumeRecordMapper; import com.fuint.business.fleet.mapper.FleetInfoMapper; import com.fuint.business.fleet.mapper.FleetMemberMapper; import com.fuint.business.fleet.service.FleetInfoService; @@ -18,6 +21,8 @@ import com.fuint.business.fleet.vo.FleetInfoUniVo; import com.fuint.business.fleet.vo.FleetInfoVo; import com.fuint.business.member.entity.LJStaff; import com.fuint.business.member.service.ILJStaffService; +import com.fuint.business.order.entity.AllOrderInfo; +import com.fuint.business.order.mapper.AllOrderInfoMapper; import com.fuint.business.store.mapper.MtStoreMapper; import com.fuint.business.storeInformation.entity.LJStore; import com.fuint.business.storeInformation.service.ILJStoreService; @@ -76,6 +81,12 @@ public class FleetInfoServiceImpl extends ServiceImpl queryPage(Page page, FleetInfoVo fleetInfo) { @@ -395,6 +406,64 @@ public class FleetInfoServiceImpl extends ServiceImpl() + .eq(AllOrderInfo::getId, orderId)); + if (ObjectUtil.isEmpty(allOrderInfo)) { + throw new RuntimeException("订单不存在"); + } + //获取车队订单表的订单信息 + FleetConsumeRecord fleetConsumeRecord = fleetConsumeRecordMapper.selectOne(new LambdaQueryWrapper() + .eq(FleetConsumeRecord::getOrderNo, allOrderInfo.getOrderNo())); + if (ObjectUtil.isEmpty(fleetConsumeRecord)) { + throw new RuntimeException("车队订单不存在"); + } + // 获取当前车队卡 + FleetInfo fleetInfo = baseMapper.selectOne(new LambdaQueryWrapper() + .eq(FleetInfo::getId, fleetConsumeRecord.getFleetId())); + //判断支付金额是否超过当前余额 + if (money > fleetInfo.getTotalBalance()){ + throw new RuntimeException("支付金额超过当前余额"); + } + + //更新时间 + DateTime now = DateUtil.date(); + + //计算车队的赠送金额与充值金额比例 + double recharge = fleetInfo.getRechargeAmount() / fleetInfo.getTotalBalance(); + double give = fleetInfo.getGiveAmount() / fleetInfo.getTotalBalance(); + //更新当前余额 + fleetInfo.setTotalBalance(fleetInfo.getTotalBalance() - money); + //更新赠送金额与充值金额 + fleetInfo.setRechargeAmount(fleetInfo.getRechargeAmount() - (money * recharge)); + fleetInfo.setGiveAmount(fleetInfo.getGiveAmount() - (money * give)); + fleetInfo.setUpdateTime(now); + //更新车队卡余额 + baseMapper.updateById(fleetInfo); + + //更新订单状态 + allOrderInfo.setStatus("paid"); + allOrderInfo.setPayTime(now); + allOrderInfo.setUpdateTime(now); + + allOrderInfoMapper.updateById(allOrderInfo); + + //更新车队订单表 + fleetConsumeRecord.setOrderStatus("paid"); + fleetConsumeRecord.setPaymentTime(now); + fleetConsumeRecord.setUpdateTime(now); + //计算扣完款后的余额 + fleetConsumeRecord.setAfterTheChange(fleetInfo.getTotalBalance()); + + return fleetConsumeRecordMapper.updateById(fleetConsumeRecord); + } + /** * 创建用户的基础信息 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java index aefabbfa1..a2a90d355 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java @@ -307,10 +307,12 @@ public class FleetMemberServiceImpl extends ServiceImpl - 兑换 + + 兑换 @@ -87,7 +88,12 @@ }).then(res => { console.log(res, 89) if (res.code == 200) { - this.content = '礼品卡已兑换成功,请在礼品卡兑换记录中查看!' + if(res.data.id){ + this.content = '礼品卡已兑换成功,请在礼品卡兑换记录中查看!' + }else { + this.content = '礼品卡兑换失败。' + } + } else { this.content = '礼品卡兑换失败。' } diff --git a/gasStation-uni/pagesMy/fleetInfo/fund.vue b/gasStation-uni/pagesMy/fleetInfo/fund.vue index 4498cc200..7a8798a3d 100644 --- a/gasStation-uni/pagesMy/fleetInfo/fund.vue +++ b/gasStation-uni/pagesMy/fleetInfo/fund.vue @@ -25,7 +25,11 @@ {{item.fromType}} - {{item.cardPaymentAmount}} + + + + - + {{item.cardPaymentAmount}} + {{item.cardType}} @@ -39,7 +43,8 @@ - + @@ -105,7 +110,7 @@ show: false, show1: false, value1: Number(new Date()), - fleetBalance:0, + fleetBalance: 0, columns: [ [{ label: '全部类型', @@ -120,17 +125,17 @@ ], columnsBalance: [ [{ - label:'全部类型', - type:null + label: '全部类型', + type: null }, { - label:'油品', - type:'油品' + label: '油品', + type: '油品' }, { - label:'积分兑换', - type:"积分兑换" + label: '积分兑换', + type: "积分兑换" }, { - label:"会员充值", - type:'会员充值' + label: "会员充值", + type: '会员充值' }] ], queryParams: { @@ -152,7 +157,7 @@ this.queryParams.fleetId = e.fleetId // console.log('this.fleetId', this.fleetId); this.storeId = uni.getStorageSync("storeId"), - this.getFleetBalance() + this.getFleetBalance() }, onShow() { this.query.chainStoreId = uni.getStorageSync('chainStoreId'); @@ -169,7 +174,7 @@ storeId: uni.getStorageSync("storeId"), changeReason: "", startTime: "", - fromType:null + fromType: null } this.getList() }, @@ -183,7 +188,7 @@ methods: { getindex(index) { this.type = index - this.queryParams.startTime= null + this.queryParams.startTime = null this.value1 = Number(new Date()) if (index == 1) { this.getFleetLinesChange() @@ -204,8 +209,8 @@ }) }, //获取车队金额 - getFleetBalance(){ - + getFleetBalance() { + request({ url: '/fleetInfo/' + this.queryParams.fleetId, method: 'get', @@ -253,7 +258,7 @@ this.getFleetLinesChange() this.show1 = false }, - + confirmBalance(e) { this.queryParams.pageNo = 1 console.log("获取的e:", e); @@ -262,7 +267,7 @@ } else { this.queryParams.fromType = e.value[0].type } - console.log('this.queryParams:',this.queryParams); + console.log('this.queryParams:', this.queryParams); this.getList() this.show1 = false }, @@ -281,12 +286,12 @@ confirm1(e) { this.queryParams.startTime = this.timestampToString(e.value) this.queryParams.pageNo = 1 - if(this.type == 1) { + if (this.type == 1) { this.getFleetLinesChange() - }else{ + } else { this.getList() } - + this.show = false }, cancel1() { diff --git a/gasStation-uni/pagesMy/fleetLimit/index.vue b/gasStation-uni/pagesMy/fleetLimit/index.vue index 3c1898924..5f42fd9a8 100644 --- a/gasStation-uni/pagesMy/fleetLimit/index.vue +++ b/gasStation-uni/pagesMy/fleetLimit/index.vue @@ -42,7 +42,7 @@ 确认 - + @@ -62,7 +62,13 @@ value1: true, show: false, columns: [ - ['增加', '扣除'] + [{ + label:'增加', + value: 0 + }, { + label:'扣除', + value: 1 + }] ], memberInfo: {}, memberId: '' @@ -91,52 +97,52 @@ }, methods: { - submitFrom(){ - if (this.memberInfo.adjustType!=''){ + submitFrom() { + if (this.memberInfo.adjustType == '') { uni.showToast({ - title:'请选择调整类型', - icon:'none' + title: '请选择调整类型', + icon: 'none' }) return } - if (!this.memberInfo.adjustLimit){ + if (!this.memberInfo.adjustLimit) { uni.showToast({ - title:'请输入调整额度', - icon:'none' + title: '请输入调整额度', + icon: 'none' }) return } request({ url: 'fleetMember/editLimitPC', method: 'put', - data:this.memberInfo + data: this.memberInfo }).then(res => { - if (res.data==1){ + if (res.data == 1) { uni.navigateBack() - }else if (res.data==2){ + } else if (res.data == 2) { uni.showToast({ - title:'共享副卡-不限额,暂不支持修改', - icon:'none' + title: '共享副卡-不限额,暂不支持修改', + icon: 'none' }) - }else if (res.data==3){ + } else if (res.data == 3) { uni.showToast({ - title:'当前车队卡剩余额度不足,无法扣除', - icon:'none' + title: '当前车队卡剩余额度不足,无法扣除', + icon: 'none' }) - }else if (res.data==4){ + } else if (res.data == 4) { uni.showToast({ - title:'当前车队卡剩余额度不足,无法扣除', - icon:'none' + title: '当前车队卡剩余额度不足,无法扣除', + icon: 'none' }) - }else if (res.data==5){ + } else if (res.data == 5) { uni.showToast({ - title:'当前副卡剩余额度不足,无法扣除', - icon:'none' + title: '当前副卡剩余额度不足,无法扣除', + icon: 'none' }) - }else{ + } else { uni.showToast({ - title:'修改失败,请联系管理员', - icon:'none' + title: '修改失败,请联系管理员', + icon: 'none' }) } }) @@ -153,8 +159,10 @@ this.show = false }, confirm(e) { - this.memberInfo.adjustType = e.indexs[0] - console.log(this.memberInfo.adjustType,e.indexs[0],e,130); + // this.memberInfo.adjustType = e.indexs[0] + this.memberInfo.adjustType = e.value[0].value + console.log("this.memberInfo.adjustType",this.memberInfo.adjustType); + console.log(this.memberInfo.adjustType, e.indexs[0], e, 130); this.show = false }, goback() {