From 9486766c806fe1d9e082b2fd02ea1cc558f1b443 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 08 五月 2025 09:21:57 +0800
Subject: [PATCH] bug修改

---
 cloud-server-account/src/main/java/com/dsh/account/service/impl/RechargeRecordsServiceImpl.java |  308 +++++++++++++++++++++++++++------------------------
 1 files changed, 164 insertions(+), 144 deletions(-)

diff --git a/cloud-server-account/src/main/java/com/dsh/account/service/impl/RechargeRecordsServiceImpl.java b/cloud-server-account/src/main/java/com/dsh/account/service/impl/RechargeRecordsServiceImpl.java
index 7d77e6b..3113496 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/service/impl/RechargeRecordsServiceImpl.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/service/impl/RechargeRecordsServiceImpl.java
@@ -1,10 +1,14 @@
 package com.dsh.account.service.impl;
 
+import com.alipay.api.response.AlipayTradeQueryResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dsh.account.entity.RechargeRecords;
 import com.dsh.account.entity.TAppUser;
+import com.dsh.account.entity.VipPayment;
 import com.dsh.account.enums.RechargeRecordEnum;
+import com.dsh.account.feignclient.communityWorldCup.WorldCupPaymentClinet;
+import com.dsh.account.feignclient.communityWorldCup.model.GetWorldCupPayment;
 import com.dsh.account.feignclient.competition.DeductionCompetitionsClient;
 import com.dsh.account.feignclient.competition.model.PaymentCompetition;
 import com.dsh.account.feignclient.course.CoursePaymentClient;
@@ -15,6 +19,8 @@
 import com.dsh.account.feignclient.other.model.SiteBooking;
 import com.dsh.account.mapper.RechargeRecordsMapper;
 import com.dsh.account.mapper.TAppUserMapper;
+import com.dsh.account.model.IncomeQuery;
+import com.dsh.account.model.WorldCupPayment;
 import com.dsh.account.model.query.RechargeRecordsQuery;
 import com.dsh.account.model.vo.RechargeRecordsVO;
 import com.dsh.account.model.vo.userBenefitDetail.RechargeDetailsVo;
@@ -70,14 +76,17 @@
 
     @Resource
     private RechargeConfigClient reconMapper;
-    @Autowired
+    @Resource
     private RechargeRecordsMapper rechargeRecordsMapper;
+
+    @Resource
+    private WorldCupPaymentClinet worldCupPaymentClinet;
 
 
     @Override
-    public List<RechargesDetail> getAppUserRechargeRecord(String yearMonth, Integer recordId, Integer appUserId,Integer pageNum,Integer pageSize) {
+    public List<RechargesDetail> getAppUserRechargeRecord(String yearMonth, Integer recordId, Integer appUserId, Integer pageNum, Integer pageSize) {
         List<RechargesDetail> details = new ArrayList<>();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm");
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
 
         Date monthStart = null;
         Date monthEnd = null;
@@ -91,22 +100,42 @@
 
 //            1.赛事报名
         List<PaymentCompetition> playPaiFGoldPayRecord = deducClient.getPlayPaiFGoldPayRecord(appUserId);
-        if (playPaiFGoldPayRecord.size() > 0 ){
+        if (playPaiFGoldPayRecord.size() > 0) {
             for (PaymentCompetition competition : playPaiFGoldPayRecord) {
-                RechargesDetail consumeDetail = new RechargesDetail();
-                consumeDetail.setConsumeName(RechargeRecordEnum.EVENT_REGISTRATION.getMsg() );
-                consumeDetail.setConsumeTime(simpleDateFormat.format(competition.getInsertTime()));
-                consumeDetail.setConsumeAmount("-" + competition.getAmount());
-                consumeDetail.setRecordId(2);
-                details.add(consumeDetail);
+                if (competition.getPayStatus() == 2) {
+                    RechargesDetail consumeDetail = new RechargesDetail();
+                    consumeDetail.setConsumeName(RechargeRecordEnum.EVENT_REGISTRATION.getMsg());
+                    consumeDetail.setConsumeTime(simpleDateFormat.format(competition.getInsertTime()));
+                    consumeDetail.setConsumeAmount("-" + competition.getAmount());
+                    consumeDetail.setRecordId(2);
+                    details.add(consumeDetail);
+                } else {
+
+
+                    RechargesDetail consumeDetail1 = new RechargesDetail();
+                    consumeDetail1.setConsumeName(RechargeRecordEnum.CANCEL_EVENT_REGISTRATION.getMsg());
+                    consumeDetail1.setConsumeTime(simpleDateFormat.format(competition.getRefundTime()));
+                    consumeDetail1.setConsumeAmount("+" + competition.getAmount());
+                    consumeDetail1.setRecordId(1);
+                    details.add(consumeDetail1);
+
+                    RechargesDetail consumeDetail = new RechargesDetail();
+                    consumeDetail.setConsumeName(RechargeRecordEnum.EVENT_REGISTRATION.getMsg());
+                    consumeDetail.setConsumeTime(simpleDateFormat.format(competition.getInsertTime()));
+                    consumeDetail.setConsumeAmount("-" + competition.getAmount());
+                    consumeDetail.setRecordId(2);
+                    details.add(consumeDetail);
+
+
+                }
             }
         }
 //            2.课包购买
         List<CouponPaymentVo> appuserCourseList = cpClient.getAppuserCourseList(appUserId);
-        if (appuserCourseList.size() > 0){
+        if (appuserCourseList.size() > 0) {
             for (CouponPaymentVo tCoursePackagePayment : appuserCourseList) {
                 RechargesDetail consumeDetail = new RechargesDetail();
-                consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg() );
+                consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg());
                 consumeDetail.setConsumeTime(tCoursePackagePayment.getTime());
                 consumeDetail.setConsumeAmount("-" + tCoursePackagePayment.getAmount());
                 consumeDetail.setRecordId(2);
@@ -115,19 +144,49 @@
         }
 //            3.场地预约
         List<SiteBooking> siteBookings = stClient.wanpaiGoldSiteBookingList(appUserId);
-        if (siteBookings.size() > 0 ){
+        if (siteBookings.size() > 0) {
             for (SiteBooking booking : siteBookings) {
+                if (booking.getStatus() != 5) {
+                    RechargesDetail consumeDetail = new RechargesDetail();
+                    consumeDetail.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.getMsg());
+                    consumeDetail.setConsumeTime(simpleDateFormat.format(booking.getInsertTime()));
+                    consumeDetail.setConsumeAmount("-" + booking.getPayMoney());
+                    consumeDetail.setRecordId(2);
+                    details.add(consumeDetail);
+                } else {
+                    RechargesDetail consumeDetail1 = new RechargesDetail();
+                    consumeDetail1.setConsumeName(RechargeRecordEnum.CANCEL_VENUE_RESERVATION.getMsg());
+                    consumeDetail1.setConsumeTime(simpleDateFormat.format(booking.getCancelTime()));
+                    consumeDetail1.setConsumeAmount("+" + booking.getPayMoney());
+                    consumeDetail1.setRecordId(1);
+                    details.add(consumeDetail1);
+
+                    RechargesDetail consumeDetail = new RechargesDetail();
+                    consumeDetail.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.getMsg());
+                    consumeDetail.setConsumeTime(simpleDateFormat.format(booking.getInsertTime()));
+                    consumeDetail.setConsumeAmount("-" + booking.getPayMoney());
+                    consumeDetail.setRecordId(2);
+                    details.add(consumeDetail);
+
+
+                }
+            }
+        }
+        //    4.智慧球场
+        List<Map<String, Object>> list = stClient.game(appUserId);
+        if (list.size() > 0) {
+            for (Map<String, Object> booking : list) {
                 RechargesDetail consumeDetail = new RechargesDetail();
-                consumeDetail.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.name());
-                consumeDetail.setConsumeTime(simpleDateFormat.format(booking.getInsertTime()));
-                consumeDetail.setConsumeAmount("-" + booking.getPayMoney());
+                consumeDetail.setConsumeName("激战游戏");
+                consumeDetail.setConsumeTime(simpleDateFormat.format(new Date(Long.valueOf(booking.get("time").toString()))));
+                consumeDetail.setConsumeAmount("-" + String.valueOf(booking.get("money")));
                 consumeDetail.setRecordId(2);
                 details.add(consumeDetail);
             }
         }
-//            4.智慧球场
 
-//            5.充值
+
+        //  5.充值
         List<RechargeRecords> rechargeRecords = this.baseMapper.selectList(new QueryWrapper<RechargeRecords>()
                 .eq("payStatus", 2)
                 .eq("appUserId", appUserId)
@@ -135,19 +194,53 @@
         if (rechargeRecords.size() > 0) {
             for (RechargeRecords rechargeRecord : rechargeRecords) {
                 RechargesDetail consumeDetail = new RechargesDetail();
-                consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.name() + ":" + rechargeRecord.getPlayPaiCoins());
+                consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.getMsg() + ":¥" + rechargeRecord.getAmount());
                 consumeDetail.setConsumeTime(simpleDateFormat.format(rechargeRecord.getInsertTime()));
-                consumeDetail.setConsumeAmount("+" + rechargeRecord.getAmount());
+                consumeDetail.setConsumeAmount("+" + rechargeRecord.getPlayPaiCoins());
                 consumeDetail.setRecordId(1);
                 details.add(consumeDetail);
             }
         }
-        if (ToolUtil.isNotEmpty(recordId)){
+
+        //世界杯
+        GetWorldCupPayment getWorldCupPayment = new GetWorldCupPayment();
+        getWorldCupPayment.setAppUserId(appUserId);
+        getWorldCupPayment.setPayType("3");
+        getWorldCupPayment.setStartTime(monthStart);
+        getWorldCupPayment.setEndTime(monthEnd);
+        List<WorldCupPayment> worldCupPayment = worldCupPaymentClinet.getWorldCupPayment(getWorldCupPayment);
+        for (WorldCupPayment cupPayment : worldCupPayment) {
+            RechargesDetail consumeDetail = new RechargesDetail();
+            if(cupPayment.getPayStatus() != 3){
+                consumeDetail.setConsumeName(RechargeRecordEnum.WORLD_CIP_PAYMENT.getMsg());
+                consumeDetail.setConsumeTime(simpleDateFormat.format(cupPayment.getPayTime()));
+                consumeDetail.setConsumeAmount("-" + cupPayment.getAmount());
+                consumeDetail.setRecordId(2);
+                details.add(consumeDetail);
+            }else{
+                consumeDetail = new RechargesDetail();
+                consumeDetail.setConsumeName(RechargeRecordEnum.WORLD_CIP_PAYMENT.getMsg());
+                consumeDetail.setConsumeTime(simpleDateFormat.format(cupPayment.getPayTime()));
+                consumeDetail.setConsumeAmount("-" + cupPayment.getAmount());
+                consumeDetail.setRecordId(2);
+                details.add(consumeDetail);
+
+                consumeDetail = new RechargesDetail();
+                consumeDetail.setConsumeName(RechargeRecordEnum.CANCEL_WORLD_CIP_PAYMENT.getMsg());
+                consumeDetail.setConsumeTime(simpleDateFormat.format(cupPayment.getRefundTime()));
+                consumeDetail.setConsumeAmount("+" + cupPayment.getRefundAmount());
+                consumeDetail.setRecordId(1);
+                details.add(consumeDetail);
+            }
+        }
+
+
+        if (ToolUtil.isNotEmpty(recordId)) {
             details = details.stream()
                     .filter(record -> record.getRecordId().equals(recordId))
                     .collect(Collectors.toList());
         }
-        if (details.size() > 0 ){
+        if (details.size() > 0) {
             Collections.sort(details, new Comparator<RechargesDetail>() {
                 @Override
                 public int compare(RechargesDetail o1, RechargesDetail o2) {
@@ -167,11 +260,28 @@
         //一页五条
         int size = pageSize;
 
+
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        List<RechargesDetail> filteredList = new ArrayList<>();
+        for (RechargesDetail detail : details) {
+            try {
+                Date consumeTime = dateFormat.parse(detail.getConsumeTime());
+                if (consumeTime.after(monthStart) && consumeTime.before(monthEnd)) {
+                    String substring = detail.getConsumeTime().substring(5);
+                    detail.setConsumeTime(substring);
+                    filteredList.add(detail);
+                }
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+
+
         //分页
-        details = details.stream().skip((pageNo - 1) * size).limit(size).
+        filteredList = filteredList.stream().skip((pageNo - 1) * size).limit(size).
                 collect(Collectors.toList());
 
-        return details;
+        return filteredList;
     }
 
     @Override
@@ -185,7 +295,7 @@
 
         List<Map<String, Object>> rechargeConfig = reconMapper.getRechargeConfig();
         BigDecimal amount = BigDecimal.ZERO;
-        if (rechargeConfig.size() > 0){
+        if (rechargeConfig.size() > 0) {
             for (Map<String, Object> stringObjectMap : rechargeConfig) {
                 double o = (double) stringObjectMap.get("money");
                 if (BigDecimal.valueOf(o).compareTo(request.getAmount()) == 0) {
@@ -204,133 +314,30 @@
         rechargeRecords.setInsertTime(new Date());
         this.baseMapper.insert(rechargeRecords);
         try {
-            switch (request.getPayType()){
+            switch (request.getPayType()) {
                 case 1:
-                    return WeChatPayment(code,amount);
+                    return WeChatPayment(code, amount);
                 case 2:
-                    return AlipayPayment(code,amount);
+                    return AlipayPayment(code, amount);
                 default:
                     break;
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             ResultUtil.runErr();
         }
         return ResultUtil.success();
     }
 
-
-
-    private ResultUtil AlipayPayment(String code,BigDecimal amount) {
-        ResultUtil alipay = payMoneyUtil.alipay("玩湃币充值", "玩湃币充值", "", code, amount.toString(),
+    private String smid = "2088330203191220";//平台支付宝商户号
+    private ResultUtil AlipayPayment(String code, BigDecimal amount) {
+        ResultUtil alipay = payMoneyUtil.alipay(smid,"玩湃币充值", "玩湃币充值", "", code, amount.toString(),
                 "/base/recharge/alipayRechargeCallback");
-        if(alipay.getCode() == 200){
-            new Thread(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        int num = 1;
-                        int wait = 0;
-                        while (num <= 10){
-                            int min = 5000;
-                            wait += (min * num);
-                            Thread.sleep(wait);
-
-                            RechargeRecords records = rereMapper.selectOne(new QueryWrapper<RechargeRecords>()
-                                    .eq("code",code));
-                            if(records.getPayStatus() == 2){
-                                break;
-                            }
-                            ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code);
-                            if(resultUtil.getCode() == 200 && records.getPayStatus() == 1){
-                                /**
-                                 * WAIT_BUYER_PAY(交易创建,等待买家付款)、
-                                 * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、
-                                 * TRADE_SUCCESS(交易支付成功)、
-                                 * TRADE_FINISHED(交易结束,不可退款)
-                                 */
-                                Map<String, String> data1 = resultUtil.getData();
-                                String s = data1.get("tradeStatus");
-                                String tradeNo = data1.get("tradeNo");
-                                if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){
-                                    records.setState(3);
-                                    rereMapper.deleteById(records.getId());
-                                    break;
-                                }
-                                if("TRADE_SUCCESS".equals(s)){
-                                    records.setPayStatus(2);
-                                    records.setOrderNumber(tradeNo);
-                                    rereMapper.updateById(records);
-                                    break;
-                                }
-                                if("WAIT_BUYER_PAY".equals(s)){
-                                    num++;
-                                }
-                            }
-                        }
-                    }catch (Exception e){
-                        e.printStackTrace();
-                    }
-                }
-            }).start();
-        }
         return alipay;
     }
 
-    private ResultUtil WeChatPayment(String code,BigDecimal amount) throws Exception {
+    private ResultUtil WeChatPayment(String code, BigDecimal amount) throws Exception {
         ResultUtil weixinpay = payMoneyUtil.weixinpay("玩湃币充值", "", code, amount.toString(),
                 "/base/recharge/wechatRechargeCallback", "APP", "");
-        if(weixinpay.getCode() == 200){
-            new Thread(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        int num = 1;
-                        int wait = 0;
-                        while (num <= 10){
-                            int min = 5000;
-                            wait += (min * num);
-                            Thread.sleep(wait);
-                            RechargeRecords records = rereMapper.selectOne(new QueryWrapper<RechargeRecords>()
-                                    .eq("code",code));
-                            if(records.getPayStatus() == 2){
-                                break;
-                            }
-                            ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(code, "");
-                            if(resultUtil.getCode() == 200 && records.getPayStatus() == 1){
-                                /**
-                                 * SUCCESS—支付成功,
-                                 * REFUND—转入退款,
-                                 * NOTPAY—未支付,
-                                 * CLOSED—已关闭,
-                                 * REVOKED—已撤销(刷卡支付),
-                                 * USERPAYING--用户支付中,
-                                 * PAYERROR--支付失败(其他原因,如银行返回失败)
-                                 */
-                                Map<String, String> data1 = resultUtil.getData();
-                                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){
-                                    records.setState(3);
-                                    rereMapper.deleteById(records.getId());
-                                    break;
-                                }
-                                if("SUCCESS".equals(s)){
-                                    records.setPayStatus(2);
-                                    records.setOrderNumber(transaction_id);
-                                    rereMapper.updateById(records);
-                                    break;
-                                }
-                                if("USERPAYING".equals(s)){
-                                    num++;
-                                }
-                            }
-                        }
-                    }catch (Exception e){
-                        e.printStackTrace();
-                    }
-                }
-            }).start();
-        }
         return weixinpay;
 
     }
@@ -339,18 +346,20 @@
     public ResultUtil addRechargeCallbackPay(String code, String orderNumber) {
         RechargeRecords rechargeRecords = this.baseMapper.selectOne(new QueryWrapper<RechargeRecords>()
                 .eq("code", code));
-        if (rechargeRecords.getPayStatus() == 2){
-            return  ResultUtil.success();
+        if (null == rechargeRecords || rechargeRecords.getPayStatus() == 2) {
+            return ResultUtil.success();
         }
+
+        TAppUser tAppUser = tappMapper.selectById(rechargeRecords.getAppUserId());
+        tAppUser.setPlayPaiCoins(null == tAppUser.getPlayPaiCoins() ? rechargeRecords.getPlayPaiCoins() : tAppUser.getPlayPaiCoins() + rechargeRecords.getPlayPaiCoins());
+        tappMapper.updateById(tAppUser);
+
+        rechargeRecords.setAppUserId(null);
         rechargeRecords.setPayStatus(2);
         rechargeRecords.setPayTime(new Date());
         rechargeRecords.setOrderNumber(orderNumber);
         this.baseMapper.updateById(rechargeRecords);
-
-        TAppUser tAppUser = tappMapper.selectById(rechargeRecords.getAppUserId());
-        tAppUser.setPlayPaiCoins(null == tAppUser.getPlayPaiCoins()? rechargeRecords.getPlayPaiCoins(): tAppUser.getPlayPaiCoins() +rechargeRecords.getPlayPaiCoins() );
-        tappMapper.updateById(tAppUser);
-        return null;
+        return ResultUtil.success();
     }
 
     @Override
@@ -362,10 +371,21 @@
             ETime = query.getTime().split(" - ")[1] + " 23:59:59";
         }
 
-        return  rechargeRecordsMapper.rechargeList(query,STime,ETime);
+        return rechargeRecordsMapper.rechargeList(query, STime, ETime);
 
     }
 
+    @Override
+    public List<VipPayment> listAll(IncomeQuery query) {
+        String STime = null;
+        String ETime = null;
+        if (StringUtils.hasLength(query.getTime())) {
+            STime = query.getTime().split(" - ")[0] + " 00:00:00";
+            ETime = query.getTime().split(" - ")[1] + " 23:59:59";
+        }
+        return rechargeRecordsMapper.listAll(query, STime, ETime, query.getAmount(), query.getInsertType());
+    }
+
     public static <T> List<T> pageList(List<T> list, int pageNum, int pageSize) {
         //计算总页数
         int page = list.size() % pageSize == 0 ? list.size() / pageSize : list.size() / pageSize + 1;

--
Gitblit v1.7.1