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-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentServiceImpl.java | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 156 insertions(+), 0 deletions(-)
diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentServiceImpl.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentServiceImpl.java
index e3501fd..4f3d5d3 100644
--- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentServiceImpl.java
+++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentServiceImpl.java
@@ -1,10 +1,39 @@
package com.dsh.communityWorldCup.service.impl;
+import com.alibaba.fastjson.JSON;
+import com.alipay.api.AlipayApiException;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dsh.communityWorldCup.entity.WorldCup;
import com.dsh.communityWorldCup.entity.WorldCupPayment;
+import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant;
+import com.dsh.communityWorldCup.entity.WorldCupStore;
+import com.dsh.communityWorldCup.feignclient.account.AppUserClient;
+import com.dsh.communityWorldCup.feignclient.account.model.AppUser;
+import com.dsh.communityWorldCup.feignclient.course.CoursePackageOrderStudentClient;
+import com.dsh.communityWorldCup.feignclient.course.model.CoursePackageOrderStudent;
+import com.dsh.communityWorldCup.feignclient.other.StoreClient;
+import com.dsh.communityWorldCup.feignclient.other.model.Store;
import com.dsh.communityWorldCup.mapper.WorldCupPaymentMapper;
+import com.dsh.communityWorldCup.model.DeductionClassHourList;
+import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService;
import com.dsh.communityWorldCup.service.IWorldCupPaymentService;
+import com.dsh.communityWorldCup.service.IWorldCupService;
+import com.dsh.communityWorldCup.service.IWorldCupStoreService;
+import com.dsh.communityWorldCup.util.PayMoneyUtil;
+import com.dsh.communityWorldCup.util.ResultUtil;
+import com.dsh.communityWorldCup.util.UUIDUtil;
+import net.bytebuddy.asm.Advice;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
/**
* @author zhibing.pu
@@ -12,4 +41,131 @@
*/
@Service
public class WorldCupPaymentServiceImpl extends ServiceImpl<WorldCupPaymentMapper, WorldCupPayment> implements IWorldCupPaymentService {
+
+ @Autowired
+ private IWorldCupPaymentParticipantService worldCupPaymentParticipantService;
+ @Autowired
+ private IWorldCupStoreService worldCupStoreService;
+
+ @Autowired
+ private IWorldCupService worldCupService;
+
+ @Autowired
+ private PayMoneyUtil payMoneyUtil;
+
+ @Resource
+ private AppUserClient appUserClient;
+ @Resource
+ private StoreClient storeClient;
+
+ @Resource
+ private CoursePackageOrderStudentClient coursePackageOrderStudentClient;
+
+
+
+
+ /**
+ * 取消已报名的世界杯
+ * @param id
+ * @return
+ */
+ @Override
+ public ResultUtil cancelMyWorldCup(Long id) throws Exception {
+ WorldCupPaymentParticipant worldCupPaymentParticipant = worldCupPaymentParticipantService.getById(id);
+ WorldCupPayment worldCupPayment = this.getById(worldCupPaymentParticipant.getWorldCupPaymentId());
+ WorldCup worldCup = worldCupService.getById(worldCupPayment.getWorldCupId());
+ //开始前一天不能取消
+ if(worldCup.getStartTime().getTime() < System.currentTimeMillis() + 86400000L){
+ return ResultUtil.error("世界杯快开始了,不能取消");
+ }
+ //开始处理退款
+ //免费
+ if(worldCupPayment.getPayType() == 0){
+ worldCupPayment.setWorldCupId(null);
+ worldCupPayment.setRefundOrderNo("");
+ worldCupPayment.setRefundTime(new Date());
+ worldCupPayment.setPayStatus(3);
+ this.updateById(worldCupPayment);
+ return ResultUtil.success();
+ }
+ List<WorldCupPaymentParticipant> list1 = worldCupPaymentParticipantService.list(new QueryWrapper<WorldCupPaymentParticipant>()
+ .eq("worldCupPaymentId", worldCupPayment.getId()).eq("alreadyEntered", 0));
+ //总排款金额(排除已经参加比赛的数据)
+ BigDecimal multiply = worldCupPayment.getUnitPrice().multiply(new BigDecimal(list1.size()));
+ //微信支付
+
+ List<WorldCupStore> list = worldCupStoreService.lambdaQuery().eq(WorldCupStore::getWorldCupId, worldCup.getId()).list();
+ Integer storeId = list.get(0).getStoreId();
+ Store store = storeClient.queryStoreById(storeId);
+ if(worldCupPayment.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, worldCupPayment.getPayOrderNo(), worldCupPayment.getAmount().toString(), "/base/worldCup/wxRefundWorldCupCallback1");
+ }else {
+ Map<String, String> map = payMoneyUtil.wxRefund(worldCupPayment.getPayOrderNo(), worldCupPayment.getCode(),
+ worldCupPayment.getAmount().toString(), multiply.toString(), "/base/worldCup/wxRefundWorldCupCallback");
+ if (!"SUCCESS".equals(map.get("return_code"))) {
+ System.err.println("-------------微信退款失败---------");
+ System.err.println(map.get("return_msg"));
+ return ResultUtil.error("微信退款失败");
+ } else {
+ worldCupPayment.setRefundAmount(multiply);
+ worldCupPayment.setWorldCupId(null);
+ this.updateById(worldCupPayment);
+ }
+ }
+ }
+ //支付宝支付
+ if(worldCupPayment.getPayType() == 2){
+ Map<String, String> map = null;
+ try {
+ map = payMoneyUtil.aliRefund(worldCupPayment.getPayOrderNo(), multiply.toString());
+ } catch (AlipayApiException e) {
+ throw new RuntimeException(e);
+ }
+ if("10000".equals(map.get("code"))){
+ String trade_no = map.get("trade_no");
+ worldCupPayment.setWorldCupId(null);
+ worldCupPayment.setRefundTime(new Date());
+ worldCupPayment.setRefundOrderNo(trade_no);
+ worldCupPayment.setPayStatus(3);
+ worldCupPayment.setRefundAmount(multiply);
+ this.updateById(worldCupPayment);
+ }
+ }
+ //玩湃币支付
+ if(worldCupPayment.getPayType() == 3){
+ Integer appUserId = worldCupPayment.getAppUserId();
+ AppUser appUser = appUserClient.getAppUser(appUserId);
+ appUser.setPlayPaiCoins(appUser.getPlayPaiCoins() + multiply.intValue());
+ appUserClient.updateAppUser(appUser);
+ worldCupPayment.setWorldCupId(null);
+ worldCupPayment.setRefundTime(new Date());
+ worldCupPayment.setRefundOrderNo("");
+ worldCupPayment.setPayStatus(3);
+ worldCupPayment.setRefundAmount(multiply);
+ this.updateById(worldCupPayment);
+ }
+ //课时支付
+ if(worldCupPayment.getPayType() == 4){
+ for (WorldCupPaymentParticipant worldCupPaymentParticipant1 : list1) {
+ String content = worldCupPaymentParticipant1.getContent();
+ DeductionClassHourList deductionClassHourList = JSON.parseObject(content, DeductionClassHourList.class);
+ coursePackageOrderStudentClient.backspaceClassHour(deductionClassHourList);
+ }
+ worldCupPayment.setWorldCupId(null);
+ worldCupPayment.setRefundTime(new Date());
+ worldCupPayment.setRefundOrderNo("");
+ worldCupPayment.setPayStatus(3);
+ worldCupPayment.setRefundAmount(multiply);
+ this.updateById(worldCupPayment);
+ }
+ return ResultUtil.success();
+ }
}
--
Gitblit v1.7.1