From b27efc697f2f81e0d0f247a2708e58af52a5df9b Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 23 十月 2025 15:14:33 +0800
Subject: [PATCH] bug修改,后台新增修改用户积分
---
cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java | 96 ++++++++++++++++++++++++++++--------------------
1 files changed, 56 insertions(+), 40 deletions(-)
diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java b/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java
index 857eda0..f7914ad 100644
--- a/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java
+++ b/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java
@@ -48,6 +48,7 @@
@Resource
private StoreClient storeClient;
+
@Autowired
private UserCompetitionService userCompetitionService;
@@ -65,9 +66,9 @@
@Resource
private StudentClient studentClient;
- @Autowired
- private PaymentCompetitionMapper paymentCompetitionMapper;
+ @Resource
+ private PaymentCompetitionMapper paymentCompetitionMapper;
@Resource
@@ -75,6 +76,7 @@
/**
* 获取我的报名赛事记录
+ *
* @param uid
* @param type
* @param pageSize
@@ -85,13 +87,13 @@
@Override
public List<CompetitionListVo> queryMyCompetitionList(Integer uid, Integer type, Integer pageSize, Integer pageNo) throws Exception {
pageNo = (pageNo - 1) * pageSize;
- if(0 == type){
+ if (0 == type) {
type = null;
}
List<CompetitionListVo> competitionListVos = this.baseMapper.queryMyCompetitionList(uid, type, pageSize, pageNo);
for (CompetitionListVo competitionListVo : competitionListVos) {
- Integer counts = competitionMapper.counts(competitionListVo.getPId());
- competitionListVo.setHeat(competitionListVo.getHeat()+counts);
+ Integer counts = competitionMapper.counts(competitionListVo.getPId());
+ competitionListVo.setHeat(competitionListVo.getHeat() + counts);
}
return competitionListVos;
}
@@ -99,6 +101,7 @@
/**
* 获取我报名的赛事详情
+ *
* @param id
* @return
* @throws Exception
@@ -143,14 +146,14 @@
competitionInfo.setIntroduction(competition.getIntroduction());
competitionInfo.setRegistrationNotes(competition.getRegistrationNotes());
competitionInfo.setApply(1);
- ArrayList<Map<String,Object>> objects = new ArrayList<>();
+ ArrayList<Map<String, Object>> objects = new ArrayList<>();
- if(null != competition.getStoreId()){
+ if (null != competition.getStoreId()) {
String storeId = competition.getStoreId();
for (String s : storeId.split(",")) {
HashMap<String, Object> map = new HashMap<>();
Store store1 = storeClient.queryStoreById(Integer.valueOf(s));
- map.put("name",store1.getName());
+ map.put("name", store1.getName());
String str1 = store1.getAddress();
@@ -162,10 +165,10 @@
// 去掉第一个“区”及之前的字符串
str1 = str1.substring(str1.indexOf("区") + 1);
- map.put("address",str1);
- map.put("storeLon",store.getLon());
- map.put("storeLat",store.getLat());
- map.put("storeCoverDrawing",store.getCoverDrawing());
+ map.put("address", str1);
+ map.put("storeLon", store.getLon());
+ map.put("storeLat", store.getLat());
+ map.put("storeCoverDrawing", store.getCoverDrawing());
// if(ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)){
// Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat());
// double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
@@ -178,11 +181,10 @@
competitionInfo.setStoreInfos(objects);
-
List<ParticipantVo> participant = new ArrayList<>();
List<UserCompetition> list = userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId()));
List<Integer> collect = list.stream().map(UserCompetition::getParticipantId).collect(Collectors.toList());
- if(collect.size()==0){
+ if (collect.size() == 0) {
collect.add(-1);
}
List<Participant> participants = participantService.listByIds(collect);
@@ -201,7 +203,7 @@
for (Integer i : collect) {
TStudent tStudent = studentClient.queryById(i);
- if (tStudent!=null) {
+ if (tStudent != null) {
ParticipantVo participantVo = new ParticipantVo();
participantVo.setId(tStudent.getId());
participantVo.setName(tStudent.getName());
@@ -216,7 +218,7 @@
competitionInfo.setParticipant(participant);
competitionInfo.setStatus(competition.getStatus());
- if(paymentCompetition.getPayStatus() == 3){
+ if (paymentCompetition.getPayStatus() == 3) {
competitionInfo.setStatus(4);
}
competitionInfo.setPayMoney(paymentCompetition.getAmount());
@@ -227,6 +229,7 @@
/**
* 取消赛事报名
+ *
* @param id
* @return
* @throws Exception
@@ -234,35 +237,48 @@
@Override
public ResultUtil cancelMyCompetition(Long id) throws Exception {
PaymentCompetition paymentCompetition = this.getById(id);
- if(paymentCompetition.getPayStatus() == 3){
+ if (paymentCompetition.getPayStatus() == 3) {
return ResultUtil.error("不能重复取消");
}
String code = paymentCompetition.getCode();
Double amount = paymentCompetition.getAmount();
Competition competition = competitionService.getById(paymentCompetition.getCompetitionId());
- if(System.currentTimeMillis() >= competition.getRegisterEndTime().getTime()){
+ if (System.currentTimeMillis() >= competition.getRegisterEndTime().getTime()) {
return ResultUtil.error("赛事已结束报名,无法取消");
}
String payOrderNo = paymentCompetition.getPayOrderNo();
- if(paymentCompetition.getPayType() == 1){//微信支付
- Map<String, String> map = payMoneyUtil.wxRefund(payOrderNo, code, amount.toString(), amount.toString(), "/base/competition/weChatCancelPaymentCompetitionCallback");
- String return_code = map.get("return_code");
- if(!"SUCCESS".equals(return_code)){
- return ResultUtil.error(map.get("return_msg"));
+ Store store = storeClient.queryStoreById(Integer.valueOf(competition.getStoreId().split(",")[0]));
+
+ if (paymentCompetition.getPayType() == 1) {//微信支付
+ if (store.getOperatorId()!=null && store.getOperatorId()!=0){
+ String smidVx= storeClient.getmerchantNumberByOperatorId(store.getOperatorId());
+ if (!StringUtils.hasLength(smidVx)){
+ System.err.println("运营商未配置微信商户号,获取支付失败!");
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+ String codeRefund = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);// 退款单号
+ // 运营商退款
+ payMoneyUtil.weixinRefundV3(smidVx, codeRefund, paymentCompetition.getPayOrderNo(), paymentCompetition.getAmount().toString(), "/base/competition/weChatCancelPaymentCompetitionCallback1");
+ }else {
+ Map<String, String> map = payMoneyUtil.wxRefund(payOrderNo, code, amount.toString(), amount.toString(),
+ "/base/competition/weChatCancelPaymentCompetitionCallback");
+ String return_code = map.get("return_code");
+ if (!"SUCCESS".equals(return_code)) {
+ return ResultUtil.error(map.get("return_msg"));
+ }
+ String refund_id = map.get("refund_id");
+ paymentCompetition.setRefundOrderNo(refund_id);
+ paymentCompetition.setAppUserId(null);
+ this.updateById(paymentCompetition);
+
+ storeClient.addBackRecord(paymentCompetition.getAmount() + "_" + paymentCompetition.getAppUserId());
}
- String refund_id = map.get("refund_id");
- paymentCompetition.setRefundOrderNo(refund_id);
- this.updateById(paymentCompetition);
-
- storeClient.addBackRecord(paymentCompetition.getAmount()+"_"+paymentCompetition.getAppUserId());
-
-
}
- if(paymentCompetition.getPayType() == 2){//支付宝支付
+ if (paymentCompetition.getPayType() == 2) {//支付宝支付
Map<String, String> map = payMoneyUtil.aliRefund(payOrderNo, amount.toString());
String return_code = map.get("code");
- if(!"10000".equals(return_code)){
+ if (!"10000".equals(return_code)) {
return ResultUtil.error(map.get("msg"));
}
String refund_id = map.get("trade_no");
@@ -272,10 +288,10 @@
paymentCompetition.setAppUserId(null);
this.updateById(paymentCompetition);
- competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
+// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
competitionService.updateById(competition);
}
- if(paymentCompetition.getPayType() == 3){//玩湃币支付
+ if (paymentCompetition.getPayType() == 3) {//玩湃币支付
AppUser appUser = appUserClient.queryAppUser(paymentCompetition.getAppUserId());
appUser.setPlayPaiCoins(appUser.getPlayPaiCoins() + amount.intValue());
appUserClient.updateAppUser(appUser);
@@ -286,10 +302,10 @@
paymentCompetition.setAppUserId(null);
this.updateById(paymentCompetition);
- competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
+// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
competitionService.updateById(competition);
}
- if(paymentCompetition.getPayType() == 4){//课程支付
+ if (paymentCompetition.getPayType() == 4) {//课程支付
List<UserCompetition> list = userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId()));
for (UserCompetition userCompetition : list) {
// Participant participant = participantService.getById(userCompetition.getId());
@@ -307,7 +323,7 @@
paymentCompetition.setAppUserId(null);
this.updateById(paymentCompetition);
- competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
+// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
competitionService.updateById(competition);
}
return ResultUtil.success();
@@ -315,12 +331,12 @@
@Override
public List<BillingRequest> queryDatas(Integer appUserId, String monthStart, String monthEnd) {
- return this.baseMapper.queryDatas(appUserId,monthStart,monthEnd);
+ return this.baseMapper.queryDatas(appUserId, monthStart, monthEnd);
}
@Override
public List<BillingRequest> queryCancelDatas(Integer appUserId, String monthStart, String monthEnd) {
- return this.baseMapper.queryCancelDatas(appUserId,monthStart,monthEnd);
+ return this.baseMapper.queryCancelDatas(appUserId, monthStart, monthEnd);
}
@Override
@@ -332,7 +348,7 @@
ETime = query.getTime().split(" - ")[1] + " 23:59:59";
}
- return paymentCompetitionMapper.listAll(query,STime,ETime,query.getAmount());
+ return paymentCompetitionMapper.listAll(query, STime, ETime, query.getAmount());
}
@Override
--
Gitblit v1.7.1