更新9.30

This commit is contained in:
许允枞 2024-09-30 15:05:34 +08:00
parent 888a6709e2
commit 976ca57b71
4 changed files with 110 additions and 23 deletions

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.fleet.entity.FleetInfo; import com.fuint.business.fleet.entity.FleetInfo;
import com.fuint.business.fleet.vo.FleetInfoUniVo; import com.fuint.business.fleet.vo.FleetInfoUniVo;
import com.fuint.business.fleet.vo.FleetInfoVo; import com.fuint.business.fleet.vo.FleetInfoVo;
import com.fuint.framework.web.ResponseObject;
import java.util.List; import java.util.List;
@ -98,4 +99,10 @@ public interface FleetInfoService {
* @return * @return
*/ */
int ifFleetAdmin(Integer fleetId); int ifFleetAdmin(Integer fleetId);
/**
* 车队卡支付
* @param orderId
*/
int payFleet(String orderId, Double money);
} }

View File

@ -2,6 +2,7 @@ package com.fuint.business.fleet.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.FleetInfo;
import com.fuint.business.fleet.entity.FleetMember; 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.FleetInfoMapper;
import com.fuint.business.fleet.mapper.FleetMemberMapper; import com.fuint.business.fleet.mapper.FleetMemberMapper;
import com.fuint.business.fleet.service.FleetInfoService; 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.fleet.vo.FleetInfoVo;
import com.fuint.business.member.entity.LJStaff; import com.fuint.business.member.entity.LJStaff;
import com.fuint.business.member.service.ILJStaffService; 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.store.mapper.MtStoreMapper;
import com.fuint.business.storeInformation.entity.LJStore; import com.fuint.business.storeInformation.entity.LJStore;
import com.fuint.business.storeInformation.service.ILJStoreService; import com.fuint.business.storeInformation.service.ILJStoreService;
@ -76,6 +81,12 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
@Resource @Resource
private ILJStoreService iljStoreService; private ILJStoreService iljStoreService;
@Autowired
private AllOrderInfoMapper allOrderInfoMapper;
@Autowired
private FleetConsumeRecordMapper fleetConsumeRecordMapper;
@Override @Override
public IPage<FleetInfoVo> queryPage(Page page, FleetInfoVo fleetInfo) { public IPage<FleetInfoVo> queryPage(Page page, FleetInfoVo fleetInfo) {
@ -395,6 +406,64 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
return 0; return 0;
} }
/**
* 车队卡支付
*
* @param orderId
*/
@Override
public int payFleet(String orderId, Double money) {
AllOrderInfo allOrderInfo = allOrderInfoMapper.selectOne(new LambdaQueryWrapper<AllOrderInfo>()
.eq(AllOrderInfo::getId, orderId));
if (ObjectUtil.isEmpty(allOrderInfo)) {
throw new RuntimeException("订单不存在");
}
//获取车队订单表的订单信息
FleetConsumeRecord fleetConsumeRecord = fleetConsumeRecordMapper.selectOne(new LambdaQueryWrapper<FleetConsumeRecord>()
.eq(FleetConsumeRecord::getOrderNo, allOrderInfo.getOrderNo()));
if (ObjectUtil.isEmpty(fleetConsumeRecord)) {
throw new RuntimeException("车队订单不存在");
}
// 获取当前车队卡
FleetInfo fleetInfo = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>()
.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);
}
/** /**
* 创建用户的基础信息 * 创建用户的基础信息

View File

@ -27,7 +27,8 @@
</view> </view>
</view> </view>
<view class="but-sub" @click="show=!show">兑换</view> <!-- <view class="but-sub" @click="show=!show">兑换</view> -->
<view class="but-sub" @click="goExchange">兑换</view>
<u-modal :show="show" :title="title" :content='content' :showCancelButton='true' @confirm="confirm" <u-modal :show="show" :title="title" :content='content' :showCancelButton='true' @confirm="confirm"
@cancel="cancel" confirmColor="#FA6400"></u-modal> @cancel="cancel" confirmColor="#FA6400"></u-modal>
@ -87,7 +88,12 @@
}).then(res => { }).then(res => {
console.log(res, 89) console.log(res, 89)
if (res.code == 200) { if (res.code == 200) {
this.content = '礼品卡已兑换成功,请在礼品卡兑换记录中查看!' if(res.data.id){
this.content = '礼品卡已兑换成功,请在礼品卡兑换记录中查看!'
}else {
this.content = '礼品卡兑换失败。'
}
} else { } else {
this.content = '礼品卡兑换失败。' this.content = '礼品卡兑换失败。'
} }

View File

@ -25,7 +25,11 @@
<view style="width: 85%;"> <view style="width: 85%;">
<view class="right-box"> <view class="right-box">
<view class="l-text">{{item.fromType}}</view> <view class="l-text">{{item.fromType}}</view>
<view class="r-text">{{item.cardPaymentAmount}}</view> <view class="r-text">
<span v-if="item.change_type == 1">+</span>
<span v-else>-</span>
{{item.cardPaymentAmount}}
</view>
</view> </view>
<view class="right-box"> <view class="right-box">
<view class="">{{item.cardType}}</view> <view class="">{{item.cardType}}</view>
@ -39,7 +43,8 @@
</view> </view>
<u-datetime-picker :show="show" v-model="value1" mode="year-month" @cancel="cancel1" <u-datetime-picker :show="show" v-model="value1" mode="year-month" @cancel="cancel1"
@confirm="confirm1"></u-datetime-picker> @confirm="confirm1"></u-datetime-picker>
<u-picker :show="show1" :columns="columnsBalance" keyName="label" @cancel="cancel" @confirm="confirmBalance"></u-picker> <u-picker :show="show1" :columns="columnsBalance" keyName="label" @cancel="cancel"
@confirm="confirmBalance"></u-picker>
</view> </view>
<view v-if="type==1"> <view v-if="type==1">
<view class="tab-bs"> <view class="tab-bs">
@ -105,7 +110,7 @@
show: false, show: false,
show1: false, show1: false,
value1: Number(new Date()), value1: Number(new Date()),
fleetBalance:0, fleetBalance: 0,
columns: [ columns: [
[{ [{
label: '全部类型', label: '全部类型',
@ -120,17 +125,17 @@
], ],
columnsBalance: [ columnsBalance: [
[{ [{
label:'全部类型', label: '全部类型',
type:null type: null
}, { }, {
label:'油品', label: '油品',
type:'油品' type: '油品'
}, { }, {
label:'积分兑换', label: '积分兑换',
type:"积分兑换" type: "积分兑换"
}, { }, {
label:"会员充值", label: "会员充值",
type:'会员充值' type: '会员充值'
}] }]
], ],
queryParams: { queryParams: {
@ -152,7 +157,7 @@
this.queryParams.fleetId = e.fleetId this.queryParams.fleetId = e.fleetId
// console.log('this.fleetId', this.fleetId); // console.log('this.fleetId', this.fleetId);
this.storeId = uni.getStorageSync("storeId"), this.storeId = uni.getStorageSync("storeId"),
this.getFleetBalance() this.getFleetBalance()
}, },
onShow() { onShow() {
this.query.chainStoreId = uni.getStorageSync('chainStoreId'); this.query.chainStoreId = uni.getStorageSync('chainStoreId');
@ -169,7 +174,7 @@
storeId: uni.getStorageSync("storeId"), storeId: uni.getStorageSync("storeId"),
changeReason: "", changeReason: "",
startTime: "", startTime: "",
fromType:null fromType: null
} }
this.getList() this.getList()
}, },
@ -183,7 +188,7 @@
methods: { methods: {
getindex(index) { getindex(index) {
this.type = index this.type = index
this.queryParams.startTime= null this.queryParams.startTime = null
this.value1 = Number(new Date()) this.value1 = Number(new Date())
if (index == 1) { if (index == 1) {
this.getFleetLinesChange() this.getFleetLinesChange()
@ -204,8 +209,8 @@
}) })
}, },
// //
getFleetBalance(){ getFleetBalance() {
request({ request({
url: '/fleetInfo/' + this.queryParams.fleetId, url: '/fleetInfo/' + this.queryParams.fleetId,
method: 'get', method: 'get',
@ -253,7 +258,7 @@
this.getFleetLinesChange() this.getFleetLinesChange()
this.show1 = false this.show1 = false
}, },
confirmBalance(e) { confirmBalance(e) {
this.queryParams.pageNo = 1 this.queryParams.pageNo = 1
console.log("获取的e:", e); console.log("获取的e:", e);
@ -262,7 +267,7 @@
} else { } else {
this.queryParams.fromType = e.value[0].type this.queryParams.fromType = e.value[0].type
} }
console.log('this.queryParams:',this.queryParams); console.log('this.queryParams:', this.queryParams);
this.getList() this.getList()
this.show1 = false this.show1 = false
}, },
@ -281,12 +286,12 @@
confirm1(e) { confirm1(e) {
this.queryParams.startTime = this.timestampToString(e.value) this.queryParams.startTime = this.timestampToString(e.value)
this.queryParams.pageNo = 1 this.queryParams.pageNo = 1
if(this.type == 1) { if (this.type == 1) {
this.getFleetLinesChange() this.getFleetLinesChange()
}else{ } else {
this.getList() this.getList()
} }
this.show = false this.show = false
}, },
cancel1() { cancel1() {