From 616f788090c83156ac5cc0d4cd38b9de344ee3b7 Mon Sep 17 00:00:00 2001
From: lisy <linlangsur163@163.com>
Date: 星期五, 18 八月 2023 10:18:29 +0800
Subject: [PATCH] 管理后台:完善核销功能
---
cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java b/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
index 617d841..74c35c7 100644
--- a/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
+++ b/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
@@ -124,8 +124,9 @@
competitionInfo.setProvince(competition.getEntryProvince());
competitionInfo.setCity(competition.getEntryCity());
competitionInfo.setAddress(competition.getEntryAddress());
- competitionInfo.setPayType(competition.getPayType());
- competitionInfo.setPrice(competition.getPrice().doubleValue());
+ competitionInfo.setCashPrice(competition.getCashPrice());
+ competitionInfo.setPlayPaiCoin(competition.getPlayPaiCoin());
+ competitionInfo.setClassPrice(competition.getClassPrice());
competitionInfo.setIntroduction(competition.getIntroduction());
competitionInfo.setRegistrationNotes(competition.getRegistrationNotes());
competitionInfo.setApply(0);
@@ -168,13 +169,18 @@
AppUser appUser = appUserClient.queryAppUser(uid);
String[] split = paymentCompetitionVo.getIds().split(";");
Competition competition = this.getById(paymentCompetitionVo.getId());
- BigDecimal money = competition.getPrice().multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN);
+ BigDecimal money = null;
+ if(paymentCompetitionVo.getPayType() == 1 || paymentCompetitionVo.getPayType() == 2){
+ money = new BigDecimal(competition.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN);
+ }
if(paymentCompetitionVo.getPayType() == 3){//玩湃币
+ money = new BigDecimal(competition.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN);
if(money.compareTo(new BigDecimal(appUser.getPlayPaiCoins())) > 0){
return ResultUtil.error("报名失败,玩湃币不足,请充值");
}
}
if(paymentCompetitionVo.getPayType() == 4){//课程
+ money = new BigDecimal(competition.getClassPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN);
for (String s : split) {
Participant participant = participantService.getById(s);
Student student = studentClient.queryStudentByPhone(participant.getPhone());
@@ -182,7 +188,7 @@
return ResultUtil.error(participant.getName() + "不是学员,无法使用课时支付。");
}
Integer integer = coursePackagePaymentClient.queryResidueClassHour(student.getId());
- if(new BigDecimal(integer).compareTo(competition.getPrice()) < 0){
+ if(new BigDecimal(integer).compareTo(new BigDecimal(competition.getClassPrice())) < 0){
return ResultUtil.error(participant.getName() + "剩余课时不足,无法完成支付。");
}
}
@@ -195,8 +201,9 @@
paymentCompetition.setCompetitionId(paymentCompetitionVo.getId());
paymentCompetition.setAppUserId(uid);
paymentCompetition.setPayType(paymentCompetitionVo.getPayType());
- paymentCompetition.setAmount(competition.getPrice().multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
+ paymentCompetition.setAmount(money.doubleValue());
paymentCompetition.setPayStatus(1);
+ paymentCompetition.setState(1);
paymentCompetition.setInsertTime(new Date());
paymentCompetitionService.save(paymentCompetition);
@@ -220,6 +227,8 @@
appUser.setPlayPaiCoins(appUser.getPlayPaiCoins() - money.intValue());
appUserClient.updateAppUser(appUser);
+ paymentCompetition = paymentCompetitionService.getById(paymentCompetition.getId());
+ paymentCompetition.setAppUserId(null);
paymentCompetition.setPayStatus(2);
paymentCompetition.setPayTime(new Date());
paymentCompetition.setPayOrderNo("");
@@ -234,10 +243,12 @@
Student student = studentClient.queryStudentByPhone(participant.getPhone());
PaymentDeductionClassHour paymentDeductionClassHour = new PaymentDeductionClassHour();
paymentDeductionClassHour.setId(student.getId());
- paymentDeductionClassHour.setClassHour(competition.getPrice().intValue());
+ paymentDeductionClassHour.setClassHour(competition.getClassPrice());
paymentDeductionClassHour.setCode(code);
coursePackagePaymentClient.paymentDeductionClassHour(paymentDeductionClassHour);
}
+ paymentCompetition = paymentCompetitionService.getById(paymentCompetition.getId());
+ paymentCompetition.setAppUserId(null);
paymentCompetition.setPayStatus(2);
paymentCompetition.setPayTime(new Date());
paymentCompetition.setPayOrderNo("");
@@ -289,11 +300,13 @@
String s = data1.get("trade_state");
String transaction_id = data1.get("transaction_id");
if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){
+ paymentCompetition.setAppUserId(null);
paymentCompetition.setState(3);
userCompetitionService.remove(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId()));
break;
}
if("SUCCESS".equals(s)){
+ paymentCompetition.setAppUserId(null);
paymentCompetition.setPayStatus(2);
paymentCompetition.setPayTime(new Date());
paymentCompetition.setPayOrderNo(transaction_id);
@@ -351,11 +364,13 @@
String s = data1.get("tradeStatus");
String tradeNo = data1.get("tradeNo");
if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){
+ paymentCompetition.setAppUserId(null);
paymentCompetition.setState(3);
userCompetitionService.remove(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId()));
break;
}
if("TRADE_SUCCESS".equals(s)){
+ paymentCompetition.setAppUserId(null);
paymentCompetition.setPayStatus(2);
paymentCompetition.setPayTime(new Date());
paymentCompetition.setPayOrderNo(tradeNo);
--
Gitblit v1.7.1