From 1d9f7b0cf4251f3058badb07dd7a2bc06b6bc09a Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 11 四月 2025 10:05:32 +0800
Subject: [PATCH] bug修改

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TFinanceController.java |  576 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 414 insertions(+), 162 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TFinanceController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TFinanceController.java
index 97b1408..f039285 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TFinanceController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TFinanceController.java
@@ -1,5 +1,7 @@
 package com.dsh.guns.modular.system.controller.code;
 import com.dsh.course.feignClient.account.*;
+import com.dsh.course.feignClient.communityWorldCup.Model.WorldCupIncomeVO;
+import com.dsh.course.feignClient.communityWorldCup.WorldCupClient;
 import com.dsh.course.feignClient.competition.model.Competition;
 import com.dsh.course.feignClient.competition.model.CompetitionQuery;
 import com.dsh.course.feignClient.competition.model.PaymentCompetition;
@@ -36,6 +38,8 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -148,6 +152,13 @@
         query.setProvince(province);
         query.setCity(city);
         query.setStoreId(storeId);
+        query.setInsertType(UserExt.getUser().getObjectType());
+        if(UserExt.getUser().getObjectType()==2){
+            List<Integer> operatorId = storeService.list(new QueryWrapper<TStore>()
+                    .eq("operatorId", UserExt.getUser().getObjectId())).stream()
+                    .map(TStore::getId).collect(Collectors.toList());
+            query.setStoresIds(operatorId);
+        }
         if(UserExt.getUser().getObjectType()==3){
             query.setStoreId(UserExt.getUser().getObjectId());
         }
@@ -230,22 +241,33 @@
         model.addAttribute("roleType",objectType);
         return PREFIX + "Income.html";
     }
+    @Autowired
+    private WorldCupClient worldCupClient;
     /**
      * 获取收入管理列表
      */
     @RequestMapping(value = "/incomeListAll")
     @ResponseBody
-    public List<IncomeVO> incomeListAll(String time,Integer incomeType,String userName,String amount) {
+    public List<IncomeVO> incomeListAll(String time,Integer incomeType,String userName,String amount) throws ParseException {
+
         // 充值记录查询query
         RechargeRecordsQuery rechargeRecordsQuery = new RechargeRecordsQuery();
         // 报名课程查询query
         RegisterOrderQuery query = new RegisterOrderQuery();
+        query.setInsertType(UserExt.getUser().getObjectType());
+        if(UserExt.getUser().getObjectType()==2){
+            query.setStoresIds(storeService.list(new QueryWrapper<TStore>()
+                    .eq("operatorId",UserExt.getUser().getObjectId())
+            ).stream().map(TStore::getId).collect(Collectors.toList()));
+        }
         // 赛事活动查询query
         CompetitionQuery competitionQuery = new CompetitionQuery();
         // 会员支付查询query
         IncomeQuery incomeQuery = new IncomeQuery();
         // 场地预约记录查询query
         SiteBookingQuery siteBookingQuery = new SiteBookingQuery();
+        // 世界杯记录查询query
+        WorldCupQuery worldCupQuery = new WorldCupQuery();
         AppUserByNameAndPhoneDTO appUserByNameAndPhoneDTO = new AppUserByNameAndPhoneDTO();
         appUserByNameAndPhoneDTO.setUserName(userName);
         if (userName!=null){
@@ -258,6 +280,7 @@
                 query.setUserIds(collect);
                 incomeQuery.setUserIds(collect);
                 siteBookingQuery.setUserIds(collect);
+                worldCupQuery.setUserIds(collect);
             }
         }
         if (amount==null || amount.equals("")){
@@ -266,12 +289,32 @@
             rechargeRecordsQuery.setAmount(null);
             competitionQuery.setAmount(null);
             incomeQuery.setAmount(null);
+            worldCupQuery.setAmount(null);
         }else {
             siteBookingQuery.setAmount(new BigDecimal(amount));
             query.setAmount(new BigDecimal(amount));
             rechargeRecordsQuery.setAmount(new BigDecimal(amount));
             competitionQuery.setAmount(new BigDecimal(amount));
             incomeQuery.setAmount(new BigDecimal(amount));
+            worldCupQuery.setAmount(new BigDecimal(amount));
+        }
+
+        if (UserExt.getUser().getObjectType()==2){
+            // 拿到门店集合id
+            List<Integer> operatorId = storeService.list(new QueryWrapper<TStore>()
+                    .eq("operatorId", UserExt.getUser().getObjectId())).stream()
+                    .map(TStore::getId).collect(Collectors.toList());
+            query.setStoresIds(operatorId);
+            competitionQuery.setOperatorId(UserExt.getUser().getObjectId());
+            siteBookingQuery.setStoreIds(operatorId);
+        }
+        if (UserExt.getUser().getObjectType()==3){
+            // 拿到门店集合id
+            List<Integer> integers = new ArrayList<>();
+            integers.add(UserExt.getUser().getObjectId());
+            siteBookingQuery.setStoreIds(integers);
+            query.setStoresIds(integers);
+            competitionQuery.setStoreId(UserExt.getUser().getObjectId());
         }
 
         siteBookingQuery.setTime(time);
@@ -279,28 +322,37 @@
         rechargeRecordsQuery.setTime(time);
         competitionQuery.setTime(time);
         incomeQuery.setTime(time);
+        worldCupQuery.setTime(time);
         Integer roleType = UserExt.getUser().getObjectType();
-        IncomeVO incomeVO = new IncomeVO();
         List<IncomeVO> incomeVOS = new ArrayList<>();
-
-        if (roleType == 1){
             if ( incomeType==null || incomeType == 1){
             // 会员支付记录
             List<VipPayment> vipPayments = vipPaymentClient.registrationList(incomeQuery);
                 for (VipPayment vipPayment : vipPayments) {
-
+                    if (UserExt.getUser().getObjectType()!=1){
+                        break;
+                    }
                     TAppUser tAppUser = appUserClient.queryById(vipPayment.getAppUserId());
                     IncomeVO temp = new IncomeVO();
-                    temp.setId(vipPayment.getId());
-                    temp.setProvince(tAppUser.getProvince());
-                    temp.setCity(tAppUser.getCity());
+                    temp.setId(vipPayment.getId().toString());
+                    if (tAppUser!=null){
+                        if (tAppUser.getProvince()!=null){
+                            temp.setProvince(tAppUser.getProvince());
+                        }
+                        if (tAppUser.getCity()!=null){
+                            temp.setCity(tAppUser.getCity());
+                        }
+                        temp.setPayUser(tAppUser.getName());
+                        temp.setPhone(tAppUser.getPhone());
+                    }
                     temp.setStoreName("");
-                    temp.setPayUser(tAppUser.getName());
-                    temp.setPhone(tAppUser.getPhone());
                     temp.setAmount(new BigDecimal(vipPayment.getAmount().toString()));
                     temp.setIncomeType(1);
                     temp.setState(vipPayment.getState());
                     temp.setInsertTime(vipPayment.getInsertTime());
+                    if (UserExt.getUser().getObjectType()!=1){
+                        break;
+                    }
                     incomeVOS.add(temp);
                 }
             }
@@ -308,20 +360,30 @@
                 // 充值记录
                 List<RechargeRecordsVO> rechargeRecordsVOS = financeClient.rechargeList(rechargeRecordsQuery);
                 for (RechargeRecordsVO rechargeRecordsVO : rechargeRecordsVOS) {
+                    if (UserExt.getUser().getObjectType()!=1){
+                        break;
+                    }
                     TAppUser tAppUser = appUserClient.queryById(rechargeRecordsVO.getAppUserId());
                     IncomeVO temp = new IncomeVO();
-                    temp.setId(rechargeRecordsVO.getId().intValue());
-                    temp.setProvince(tAppUser.getProvince());
-                    temp.setCity(tAppUser.getCity());
+                    temp.setId(rechargeRecordsVO.getId().toString());
+                    if (tAppUser!=null){
+                        if (tAppUser.getProvince()!=null){
+                            temp.setProvince(tAppUser.getProvince());
+                        }
+                        if (tAppUser.getCity()!=null){
+                            temp.setCity(tAppUser.getCity());
+                        }
+                        temp.setPayUser(tAppUser.getName());
+                        temp.setPhone(tAppUser.getPhone());
+                    }
                     temp.setStoreName("");
-                    temp.setPayUser(tAppUser.getName());
-                    temp.setPhone(tAppUser.getPhone());
                     temp.setInsertTime(rechargeRecordsVO.getInsertTime());
                     if (rechargeRecordsVO.getAmount() != null) {
                         temp.setAmount(rechargeRecordsVO.getAmount());
                     }
                     temp.setIncomeType(2);
                     temp.setState(rechargeRecordsVO.getPayStatus());
+
                     incomeVOS.add(temp);
                 }
             }
@@ -334,22 +396,35 @@
                     }
                     TAppUser tAppUser = appUserClient.queryById(registerOrderVO.getAppUserId());
                     IncomeVO temp = new IncomeVO();
-                    temp.setId(registerOrderVO.getId().intValue());
-                    temp.setProvince(tAppUser.getProvince());
-                    temp.setCity(tAppUser.getCity());
+                    temp.setId(registerOrderVO.getId().toString());
+                    if (tAppUser!=null){
+                        if (tAppUser.getProvince()!=null){
+                            temp.setProvince(tAppUser.getProvince());
+                        }
+                        if (tAppUser.getCity()!=null){
+                            temp.setCity(tAppUser.getCity());
+                        }
+                        temp.setPayUser(tAppUser.getName());
+                        temp.setPhone(tAppUser.getPhone());
+                    }
+
                     temp.setStoreName(registerOrderVO.getStoreName());
-                    temp.setPayUser(tAppUser.getName());
-                    temp.setPhone(tAppUser.getPhone());
+
                     temp.setInsertTime(registerOrderVO.getInsertTime());
                     if (registerOrderVO.getMoney() != null) {
                         temp.setAmount(registerOrderVO.getMoney());
                     }
                     temp.setIncomeType(3);
-                    temp.setState(registerOrderVO.getPayStatus());
+                    if (registerOrderVO.getPayStatus() == 1){
+                        temp.setState(2);
+                    }
+                    if (registerOrderVO.getPayStatus() == 2){
+                        temp.setState(1);
+                    }
                     incomeVOS.add(temp);
                 }
             }
-            if(roleType !=3) {
+
                 if (incomeType == null || incomeType == 4) {
                     // 报名活动
                     List<PaymentCompetition> competitions = competitionClient.listAllPayment(competitionQuery);
@@ -357,30 +432,53 @@
                         if (competition.getPayStatus() == 3) {
                             continue;
                         }
+                        IncomeVO temp = new IncomeVO();
                         TAppUser tAppUser = appUserClient.queryById(competition.getAppUserId());
                         Competition competition1 = competitionClient.queryById(competition.getCompetitionId());
+                        if(null == competition1){
+                            continue;
+                        }
                         if (!competition1.getStoreId().equals("")){
                             String[] split = competition1.getStoreId().split(",");
-                        }
-                        Store store = storeClient.getStoreById(Integer.valueOf(competition1.getStoreId()));
-                        IncomeVO temp = new IncomeVO();
-                        temp.setId(competition.getId().intValue());
-                        temp.setProvince(tAppUser.getProvince());
-                        temp.setCity(tAppUser.getCity());
-                        temp.setStoreName(store.getName());
-                        temp.setPayUser(tAppUser.getName());
-                        temp.setPhone(tAppUser.getPhone());
-                        temp.setInsertTime(competition.getInsertTime());
+                            List<Integer> list = new ArrayList<>();
+                            for (String s : split) {
+                                list.add(Integer.valueOf(s));
+                            }
+                            List<TStore> id = storeService.list(new QueryWrapper<TStore>().in("id", list));
+                            StringBuilder storeNames = new StringBuilder("");
+                            for (TStore store : id) {
+                                // 赛事举办门店 (可能会有多个门店举办 需要拼接门店名称)
+                                storeNames.append(store.getName() + ",");
+                            }
+                            String substring = storeNames.toString().substring(0, storeNames.toString().length() - 1);
 
+                            temp.setStoreName(substring);
+                        }
+                        temp.setId(competition.getId().toString());
+                        if (tAppUser!=null){
+                            if (tAppUser.getProvince()!=null){
+                                temp.setProvince(tAppUser.getProvince());
+                            }
+                            if (tAppUser.getCity()!=null){
+                                temp.setCity(tAppUser.getCity());
+                            }
+                            temp.setPayUser(tAppUser.getName());
+                            temp.setPhone(tAppUser.getPhone());
+                        }
+                        temp.setInsertTime(competition.getInsertTime());
                         if (competition.getAmount() != null) {
                             temp.setAmount(new BigDecimal(competition.getAmount().toString()));
                         }
                         temp.setIncomeType(4);
-                        temp.setState(competition.getPayStatus());
+                        if (competition.getPayStatus() == 1){
+                            temp.setState(2);
+                        }else if (competition.getPayStatus() == 2){
+                            temp.setState(1);
+                        }
                         incomeVOS.add(temp);
                     }
                 }
-            }
+
             if (incomeType == null || incomeType == 5) {
                 // 预约场地
                 List<SiteBooking> siteBookings = siteClient.listAll(siteBookingQuery);
@@ -391,15 +489,24 @@
                     } else {
                         temp.setState(2);
                     }
-                    TAppUser tAppUser = appUserClient.queryById(siteBooking.getAppUserId());
+                    TAppUser tAppUser = appUserClient.queryAppUser1(siteBooking.getAppUserId());
                     Store store = storeClient.getStoreById(siteBooking.getStoreId());
 
-                    temp.setId(siteBooking.getId());
+                    temp.setId(siteBooking.getId().toString());
                     temp.setProvince(siteBooking.getProvince());
                     temp.setCity(siteBooking.getCity());
                     temp.setStoreName(store.getName());
-                    temp.setPayUser(tAppUser.getName());
-                    temp.setPhone(tAppUser.getPhone());
+                    if (tAppUser!=null){
+                        if (tAppUser.getProvince()!=null){
+                            temp.setProvince(tAppUser.getProvince());
+                        }
+                        if (tAppUser.getCity()!=null){
+                            temp.setCity(tAppUser.getCity());
+                        }
+                        temp.setPayUser(tAppUser.getName());
+                        temp.setPhone(tAppUser.getPhone());
+                    }
+
                     temp.setInsertTime(siteBooking.getInsertTime());
                     if (siteBooking.getPayMoney() != null) {
                         temp.setAmount(new BigDecimal(siteBooking.getPayMoney().toString()));
@@ -408,7 +515,25 @@
                     incomeVOS.add(temp);
                 }
             }
-        }
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        if (roleType == 1 && (incomeType == null || incomeType == 6)){
+                List<WorldCupIncomeVO> worldCupIncome = worldCupClient.getWorldCupIncome(worldCupQuery);
+                for (WorldCupIncomeVO worldCupIncomeVO : worldCupIncome) {
+                    IncomeVO temp = new IncomeVO();
+                    temp.setId(worldCupIncomeVO.getId());
+                    temp.setProvince(worldCupIncomeVO.getProvince());
+                    temp.setCity(worldCupIncomeVO.getCity());
+                    temp.setStoreName(worldCupIncomeVO.getStoreName());
+                    temp.setPayUser(worldCupIncomeVO.getUserName());
+                    temp.setPhone(worldCupIncomeVO.getPhone());
+                    temp.setAmount(new BigDecimal(worldCupIncomeVO.getAmount()));
+                    temp.setIncomeType(6);
+                    temp.setState(1);
+                    temp.setInsertTime(simpleDateFormat.parse(worldCupIncomeVO.getPayTime()));
+                    incomeVOS.add(temp);
+                }
+            }
         return incomeVOS;
     }
 
@@ -417,17 +542,23 @@
      */
     @RequestMapping(value = "/getIncomeData")
     @ResponseBody
-    public Object getIncomeData(String time,Integer incomeType,String userName,String amount) {
+    public Object getIncomeData(String time,Integer incomeType,String userName,String amount) throws ParseException {
         // 充值记录查询query
         RechargeRecordsQuery rechargeRecordsQuery = new RechargeRecordsQuery();
         // 报名课程查询query
         RegisterOrderQuery query = new RegisterOrderQuery();
+        query.setInsertType(UserExt.getUser().getObjectType());
+        query.setStoresIds(storeService.list(new QueryWrapper<TStore>()
+                .eq("operatorId",UserExt.getUser().getObjectId()))
+        .stream().map(TStore::getId).collect(Collectors.toList()));
         // 赛事活动查询query
         CompetitionQuery competitionQuery = new CompetitionQuery();
         // 会员支付查询query
         IncomeQuery incomeQuery = new IncomeQuery();
         // 场地预约记录查询query
         SiteBookingQuery siteBookingQuery = new SiteBookingQuery();
+        // 世界杯查询query
+        WorldCupQuery worldCupQuery = new WorldCupQuery();
         AppUserByNameAndPhoneDTO appUserByNameAndPhoneDTO = new AppUserByNameAndPhoneDTO();
         appUserByNameAndPhoneDTO.setUserName(userName);
         if (userName!=null){
@@ -440,6 +571,7 @@
                 query.setUserIds(collect);
                 incomeQuery.setUserIds(collect);
                 siteBookingQuery.setUserIds(collect);
+                worldCupQuery.setUserIds(collect);
             }
         }
         if (amount==null || amount.equals("")){
@@ -448,151 +580,256 @@
             rechargeRecordsQuery.setAmount(null);
             competitionQuery.setAmount(null);
             incomeQuery.setAmount(null);
+            worldCupQuery.setAmount(null);
         }else {
             siteBookingQuery.setAmount(new BigDecimal(amount));
             query.setAmount(new BigDecimal(amount));
             rechargeRecordsQuery.setAmount(new BigDecimal(amount));
             competitionQuery.setAmount(new BigDecimal(amount));
             incomeQuery.setAmount(new BigDecimal(amount));
+            worldCupQuery.setAmount(new BigDecimal(amount));
         }
-
+        if (UserExt.getUser().getObjectType()==2){
+            // 拿到门店集合id
+            List<Integer> operatorId = storeService.list(new QueryWrapper<TStore>()
+                    .eq("operatorId", UserExt.getUser().getObjectId())).stream()
+                    .map(TStore::getId).collect(Collectors.toList());
+            query.setStoresIds(operatorId);
+            competitionQuery.setOperatorId(UserExt.getUser().getObjectId());
+            siteBookingQuery.setStoreIds(operatorId);
+        }
+        if (UserExt.getUser().getObjectType()==3){
+            // 拿到门店集合id
+            List<Integer> integers = new ArrayList<>();
+            integers.add(UserExt.getUser().getObjectId());
+            siteBookingQuery.setStoreIds(integers);
+            query.setStoresIds(integers);
+            competitionQuery.setStoreId(UserExt.getUser().getObjectId());
+        }
         siteBookingQuery.setTime(time);
         query.setRegisterTime(time);
         rechargeRecordsQuery.setTime(time);
         competitionQuery.setTime(time);
         incomeQuery.setTime(time);
+        worldCupQuery.setTime(time);
         Integer roleType = UserExt.getUser().getObjectType();
-        IncomeVO incomeVO = new IncomeVO();
         List<IncomeVO> incomeVOS = new ArrayList<>();
-
-        if (roleType == 1){
-            if ( incomeType==null || incomeType == 1){
-                // 会员支付记录
-                List<VipPayment> vipPayments = vipPaymentClient.registrationList(incomeQuery);
-                for (VipPayment vipPayment : vipPayments) {
-
-                    TAppUser tAppUser = appUserClient.queryById(vipPayment.getAppUserId());
-                    IncomeVO temp = new IncomeVO();
-                    temp.setId(vipPayment.getId());
-                    temp.setProvince(tAppUser.getProvince());
-                    temp.setCity(tAppUser.getCity());
-                    temp.setStoreName("");
-                    temp.setPayUser(tAppUser.getName());
-                    temp.setPhone(tAppUser.getPhone());
-                    temp.setAmount(new BigDecimal(vipPayment.getAmount().toString()));
-                    temp.setIncomeType(1);
-                    temp.setState(vipPayment.getState());
-                    temp.setInsertTime(vipPayment.getInsertTime());
-                    incomeVOS.add(temp);
+        if ( incomeType==null || incomeType == 1){
+            // 会员支付记录
+            List<VipPayment> vipPayments = vipPaymentClient.registrationList(incomeQuery);
+            for (VipPayment vipPayment : vipPayments) {
+                if (UserExt.getUser().getObjectType()!=1){
+                    break;
                 }
-            }
-            if ( incomeType==null || incomeType == 2) {
-                // 充值记录
-                List<RechargeRecordsVO> rechargeRecordsVOS = financeClient.rechargeList(rechargeRecordsQuery);
-                for (RechargeRecordsVO rechargeRecordsVO : rechargeRecordsVOS) {
-                    TAppUser tAppUser = appUserClient.queryById(rechargeRecordsVO.getAppUserId());
-                    IncomeVO temp = new IncomeVO();
-                    temp.setId(rechargeRecordsVO.getId().intValue());
-                    temp.setProvince(tAppUser.getProvince());
-                    temp.setCity(tAppUser.getCity());
-                    temp.setStoreName("");
-                    temp.setPayUser(tAppUser.getName());
-                    temp.setPhone(tAppUser.getPhone());
-                    temp.setInsertTime(rechargeRecordsVO.getInsertTime());
-                    if (rechargeRecordsVO.getAmount() != null) {
-                        temp.setAmount(rechargeRecordsVO.getAmount());
-                    }
-                    temp.setIncomeType(2);
-                    temp.setState(rechargeRecordsVO.getState());
-                    incomeVOS.add(temp);
-                }
-            }
-            if ( incomeType==null || incomeType == 3) {
-                // 报名课程记录
-                List<RegisterOrderVO> registerOrderVOS = coursePackagePaymentClient.listAllRegister(query);
-                for (RegisterOrderVO registerOrderVO : registerOrderVOS) {
-                    if (registerOrderVO.getMoney() == null) {
-                        continue;
-                    }
-                    TAppUser tAppUser = appUserClient.queryById(registerOrderVO.getAppUserId());
-                    IncomeVO temp = new IncomeVO();
-                    temp.setId(registerOrderVO.getId().intValue());
-                    temp.setProvince(tAppUser.getProvince());
-                    temp.setCity(tAppUser.getCity());
-                    temp.setStoreName(registerOrderVO.getStoreName());
-                    temp.setPayUser(tAppUser.getName());
-                    temp.setPhone(tAppUser.getPhone());
-                    temp.setInsertTime(registerOrderVO.getInsertTime());
-                    if (registerOrderVO.getMoney() != null) {
-                        temp.setAmount(registerOrderVO.getMoney());
-                    }
-                    temp.setIncomeType(3);
-                    temp.setState(registerOrderVO.getPayStatus());
-                    incomeVOS.add(temp);
-                }
-            }
-            if(roleType !=3) {
-                if (incomeType == null || incomeType == 4) {
-                    // 报名活动
-                    List<PaymentCompetition> competitions = competitionClient.listAllPayment(competitionQuery);
-                    for (PaymentCompetition competition : competitions) {
-                        if (competition.getPayStatus() == 3) {
-                            continue;
-                        }
-                        TAppUser tAppUser = appUserClient.queryById(competition.getAppUserId());
-                        Competition competition1 = competitionClient.queryById(competition.getCompetitionId());
-                        Store store = storeClient.getStoreById(Integer.valueOf(competition1.getStoreId().split(",")[0]));
-                        IncomeVO temp = new IncomeVO();
-                        temp.setId(competition.getId().intValue());
+                TAppUser tAppUser = appUserClient.queryById(vipPayment.getAppUserId());
+                IncomeVO temp = new IncomeVO();
+                temp.setId(vipPayment.getId().toString());
+                if (tAppUser!=null){
+                    if (tAppUser.getProvince()!=null){
                         temp.setProvince(tAppUser.getProvince());
+                    }
+                    if (tAppUser.getCity()!=null){
                         temp.setCity(tAppUser.getCity());
-                        temp.setStoreName(store.getName());
-                        temp.setPayUser(tAppUser.getName());
-                        temp.setPhone(tAppUser.getPhone());
-                        temp.setInsertTime(competition.getInsertTime());
-
-                        if (competition.getAmount() != null) {
-                            temp.setAmount(new BigDecimal(competition.getAmount().toString()));
-                        }
-                        temp.setIncomeType(4);
-                        temp.setState(competition.getPayStatus());
-                        incomeVOS.add(temp);
                     }
-                }
-            }
-            if (incomeType == null || incomeType == 5) {
-                // 预约场地
-                List<SiteBooking> siteBookings = siteClient.listAll(siteBookingQuery);
-                for (SiteBooking siteBooking : siteBookings) {
-                    IncomeVO temp = new IncomeVO();
-                    if (siteBooking.getStatus() == 0 || siteBooking.getStatus() == 5 || siteBooking.getStatus() == 4) {
-                        temp.setState(1);
-                    } else {
-                        temp.setState(2);
-                    }
-                    TAppUser tAppUser = appUserClient.queryById(siteBooking.getAppUserId());
-                    Store store = storeClient.getStoreById(siteBooking.getStoreId());
-
-                    temp.setId(siteBooking.getId());
-                    temp.setProvince(siteBooking.getProvince());
-                    temp.setCity(siteBooking.getCity());
-                    temp.setStoreName(store.getName());
                     temp.setPayUser(tAppUser.getName());
                     temp.setPhone(tAppUser.getPhone());
-                    temp.setInsertTime(siteBooking.getInsertTime());
-                    if (siteBooking.getPayMoney() != null) {
-                        temp.setAmount(new BigDecimal(siteBooking.getPayMoney().toString()));
-                    }
-                    temp.setIncomeType(5);
-                    incomeVOS.add(temp);
                 }
+                temp.setStoreName("");
+                temp.setAmount(new BigDecimal(vipPayment.getAmount().toString()));
+                temp.setIncomeType(1);
+                temp.setState(vipPayment.getState());
+                temp.setInsertTime(vipPayment.getInsertTime());
+                if (UserExt.getUser().getObjectType()!=1){
+                    break;
+                }
+                incomeVOS.add(temp);
             }
         }
-        BigDecimal totalAmount = BigDecimal.ZERO; // 初始化累加变量为0
+        if ( incomeType==null || incomeType == 2) {
+            // 充值记录
+            List<RechargeRecordsVO> rechargeRecordsVOS = financeClient.rechargeList(rechargeRecordsQuery);
+            for (RechargeRecordsVO rechargeRecordsVO : rechargeRecordsVOS) {
+                if (UserExt.getUser().getObjectType()!=1){
+                    break;
+                }
+                TAppUser tAppUser = appUserClient.queryById(rechargeRecordsVO.getAppUserId());
+                IncomeVO temp = new IncomeVO();
+                temp.setId(rechargeRecordsVO.getId().toString());
+                if (tAppUser!=null){
+                    if (tAppUser.getProvince()!=null){
+                        temp.setProvince(tAppUser.getProvince());
+                    }
+                    if (tAppUser.getCity()!=null){
+                        temp.setCity(tAppUser.getCity());
+                    }
+                    temp.setPayUser(tAppUser.getName());
+                    temp.setPhone(tAppUser.getPhone());
+                }
+                temp.setStoreName("");
+                temp.setInsertTime(rechargeRecordsVO.getInsertTime());
+                if (rechargeRecordsVO.getAmount() != null) {
+                    temp.setAmount(rechargeRecordsVO.getAmount());
+                }
+                temp.setIncomeType(2);
+                temp.setState(rechargeRecordsVO.getPayStatus());
 
+                incomeVOS.add(temp);
+            }
+        }
+        if ( incomeType==null || incomeType == 3) {
+            // 报名课程记录
+            List<RegisterOrderVO> registerOrderVOS = coursePackagePaymentClient.listAllRegister(query);
+            for (RegisterOrderVO registerOrderVO : registerOrderVOS) {
+                if (registerOrderVO.getMoney() == null) {
+                    continue;
+                }
+                TAppUser tAppUser = appUserClient.queryById(registerOrderVO.getAppUserId());
+                IncomeVO temp = new IncomeVO();
+                temp.setId(registerOrderVO.getId().toString());
+                if (registerOrderVO.getPayStatus()==2) {
+                    temp.setState(2);
+                } else {
+                    temp.setState(1);
+                }
+                if (tAppUser!=null){
+                    if (tAppUser.getProvince()!=null){
+                        temp.setProvince(tAppUser.getProvince());
+                    }
+                    if (tAppUser.getCity()!=null){
+                        temp.setCity(tAppUser.getCity());
+                    }
+                    temp.setPayUser(tAppUser.getName());
+                    temp.setPhone(tAppUser.getPhone());
+                }
+
+                temp.setStoreName(registerOrderVO.getStoreName());
+
+                temp.setInsertTime(registerOrderVO.getInsertTime());
+                if (registerOrderVO.getMoney() != null) {
+                    temp.setAmount(registerOrderVO.getMoney());
+                }
+                temp.setIncomeType(3);
+                temp.setState(registerOrderVO.getPayStatus());
+                incomeVOS.add(temp);
+            }
+        }
+            if (incomeType == null || incomeType == 4) {
+                // 报名活动
+                List<PaymentCompetition> competitions = competitionClient.listAllPayment(competitionQuery);
+                for (PaymentCompetition competition : competitions) {
+                    if (competition.getPayStatus() == 3) {
+                        continue;
+                    }
+                    IncomeVO temp = new IncomeVO();
+                    TAppUser tAppUser = appUserClient.queryById(competition.getAppUserId());
+                    Competition competition1 = competitionClient.queryById(competition.getCompetitionId());
+                    if(null == competition1){
+                        continue;
+                    }
+                    if (!competition1.getStoreId().equals("")){
+                        String[] split = competition1.getStoreId().split(",");
+                        List<Integer> list = new ArrayList<>();
+                        for (String s : split) {
+                            list.add(Integer.valueOf(s));
+                        }
+                        List<TStore> id = storeService.list(new QueryWrapper<TStore>().in("id", list));
+                        StringBuilder storeNames = new StringBuilder("");
+                        for (TStore store : id) {
+                            // 赛事举办门店 (可能会有多个门店举办 需要拼接门店名称)
+                            storeNames.append(store.getName() + ",");
+                        }
+                        String substring = storeNames.toString().substring(0, storeNames.toString().length() - 1);
+
+                        temp.setStoreName(substring);
+                    }
+                    if (competition.getPayStatus()==2) {
+                        temp.setState(2);
+                    } else {
+                        temp.setState(1);
+                    }
+                    temp.setId(competition.getId().toString());
+                    if (tAppUser!=null){
+                        if (tAppUser.getProvince()!=null){
+                            temp.setProvince(tAppUser.getProvince());
+                        }
+                        if (tAppUser.getCity()!=null){
+                            temp.setCity(tAppUser.getCity());
+                        }
+                        temp.setPayUser(tAppUser.getName());
+                        temp.setPhone(tAppUser.getPhone());
+                    }
+                    temp.setInsertTime(competition.getInsertTime());
+                    if (competition.getAmount() != null) {
+                        temp.setAmount(new BigDecimal(competition.getAmount().toString()));
+                    }
+                    temp.setIncomeType(4);
+                    temp.setState(competition.getPayStatus());
+                    incomeVOS.add(temp);
+                }
+            }
+        if (incomeType == null || incomeType == 5) {
+            // 预约场地
+            List<SiteBooking> siteBookings = siteClient.listAll(siteBookingQuery);
+            for (SiteBooking siteBooking : siteBookings) {
+                IncomeVO temp = new IncomeVO();
+                if (siteBooking.getStatus() == 0 || siteBooking.getStatus() == 5 || siteBooking.getStatus() == 4) {
+                    temp.setState(1);
+                } else {
+                    temp.setState(2);
+                }
+                TAppUser tAppUser = appUserClient.queryAppUser1(siteBooking.getAppUserId());
+                Store store = storeClient.getStoreById(siteBooking.getStoreId());
+
+                temp.setId(siteBooking.getId().toString());
+                temp.setProvince(siteBooking.getProvince());
+                temp.setCity(siteBooking.getCity());
+                temp.setStoreName(store.getName());
+                if (tAppUser!=null){
+                    if (tAppUser.getProvince()!=null){
+                        temp.setProvince(tAppUser.getProvince());
+                    }
+                    if (tAppUser.getCity()!=null){
+                        temp.setCity(tAppUser.getCity());
+                    }
+                    temp.setPayUser(tAppUser.getName());
+                    temp.setPhone(tAppUser.getPhone());
+                }
+
+                temp.setInsertTime(siteBooking.getInsertTime());
+                if (siteBooking.getPayMoney() != null) {
+                    temp.setAmount(new BigDecimal(siteBooking.getPayMoney().toString()));
+                }
+                temp.setIncomeType(5);
+                incomeVOS.add(temp);
+            }
+        }
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        if (roleType == 1 && (incomeType == null || incomeType == 6)){
+            List<WorldCupIncomeVO> worldCupIncome = worldCupClient.getWorldCupIncome(worldCupQuery);
+            for (WorldCupIncomeVO worldCupIncomeVO : worldCupIncome) {
+                IncomeVO temp = new IncomeVO();
+                temp.setId(worldCupIncomeVO.getId());
+                temp.setProvince(worldCupIncomeVO.getProvince());
+                temp.setCity(worldCupIncomeVO.getCity());
+                temp.setStoreName(worldCupIncomeVO.getStoreName());
+                temp.setPayUser(worldCupIncomeVO.getUserName());
+                temp.setPhone(worldCupIncomeVO.getPhone());
+                temp.setAmount(new BigDecimal(worldCupIncomeVO.getAmount()));
+                temp.setIncomeType(6);
+                temp.setState(1);
+                temp.setInsertTime(simpleDateFormat.parse(worldCupIncomeVO.getPayTime()));
+                incomeVOS.add(temp);
+            }
+        }
+         BigDecimal totalAmount = BigDecimal.ZERO; // 初始化累加变量为0
         for (IncomeVO vo : incomeVOS) {
-            BigDecimal totalMoney = vo.getAmount();
-            totalAmount = totalAmount.add(totalMoney); // 累加每个IncomeVO对象的amount
+            if (vo.getAmount() == null ){
+                BigDecimal temp = BigDecimal.ZERO;
+                totalAmount = totalAmount.add(temp);
+            }else{
+                BigDecimal totalMoney = vo.getAmount();
+                totalAmount = totalAmount.add(totalMoney); // 累加每个IncomeVO对象的amount
+            }
         }
         return totalAmount;
     }
@@ -610,11 +847,20 @@
         if(UserExt.getUser().getObjectType()==3){
             coachQuery.setStoreId(UserExt.getUser().getObjectId());
         }
+        if(UserExt.getUser().getObjectType()==2){
+            // 运营商门店ids
+            List<Integer> storeIds = storeService
+                    .list(new QueryWrapper<TStore>().eq("operatorId", UserExt.getUser().getObjectId()))
+                    .stream().map(TStore::getId).collect(Collectors.toList());
+            coachQuery.setStoreIds(storeIds);
+        }
         return cancelledClassesClient.listAll(coachQuery);
     }
     /**
      * 获取报名订单记录
      */
+    @Autowired
+    private IStoreService storeService;
     @RequestMapping(value = "/registerListAll")
     @ResponseBody
     public List<RegisterOrderVO> registerListAll(String province,String city,Integer storeId,String registerTime
@@ -623,6 +869,12 @@
         query.setProvince(province);
         query.setCity(city);
         query.setStoreId(storeId);
+        query.setInsertType(UserExt.getUser().getObjectType());
+        if(UserExt.getUser().getObjectType()==2){
+            query.setStoresIds(storeService.list(new QueryWrapper<TStore>()
+                    .eq("operatorId",UserExt.getUser().getObjectId())
+                    ).stream().map(TStore::getId).collect(Collectors.toList()));
+        }
         if(UserExt.getUser().getObjectType()==3){
             query.setStoreId(UserExt.getUser().getObjectId());
         }
@@ -647,9 +899,9 @@
         if (userIds.size()==0){
             return new ArrayList<>();
         }
-        List<RegisterOrderVO> registerOrderVOS = coursePackagePaymentClient.listAllRegister(query);
 
-        return registerOrderVOS;
+
+        return coursePackagePaymentClient.listAllRegister(query);
     }
 
 

--
Gitblit v1.7.1