From dec64d47a9a3a3cc133afdf5141744d90fcb49b4 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 01 九月 2025 15:46:42 +0800
Subject: [PATCH] Merge branch '2.0' of http://120.76.84.145:10101/gitblit/r/java/PlayPai into 2.0

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TVipDetailController.java |  213 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 197 insertions(+), 16 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TVipDetailController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TVipDetailController.java
index aa90268..bd3eb5b 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TVipDetailController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TVipDetailController.java
@@ -1,35 +1,34 @@
 package com.dsh.guns.modular.system.controller.code;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dsh.course.feignClient.account.AppUserClient;
+import com.dsh.course.feignClient.account.VipPaymentClient;
 import com.dsh.course.feignClient.account.model.QueryByNamePhone;
 import com.dsh.course.feignClient.account.model.TAppUser;
 import com.dsh.course.feignClient.activity.CouponClient;
-import com.dsh.course.feignClient.activity.model.Coupon;
-import com.dsh.course.feignClient.activity.model.CouponCity;
-import com.dsh.course.feignClient.activity.model.TicketDetailVO;
+import com.dsh.course.feignClient.activity.model.HuiminPayQuery;
 import com.dsh.guns.config.UserExt;
 import com.dsh.guns.core.base.controller.BaseController;
-import com.dsh.guns.core.common.constant.factory.PageFactory;
+import com.dsh.guns.core.base.tips.SuccessTip;
 import com.dsh.guns.modular.system.model.*;
-import com.dsh.guns.modular.system.model.dto.VipDetailDto;
 import com.dsh.guns.modular.system.model.dto.VipPaymentDto;
-import com.dsh.guns.modular.system.model.vo.VipDetailVO;
-import com.dsh.guns.modular.system.model.vo.VipPaymentVO;
+import com.dsh.guns.modular.system.model.dto.VipRefundDto;
+import com.dsh.guns.modular.system.model.vo.VipPaymentListVO;
 import com.dsh.guns.modular.system.service.*;
+import com.dsh.guns.modular.system.util.DateUtil;
+import com.dsh.guns.modular.system.util.ExcelUtil;
 import com.dsh.guns.modular.system.util.ResultUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -46,9 +45,15 @@
     @Autowired
     private CouponClient couponClient;
     @Autowired
-    private IStoreService storeService;
+    private IRelationService relationService;
     @Autowired
     private AppUserClient appUserClient;
+    @Autowired
+    private VipPaymentClient vipPaymentClient;
+    @Autowired
+    private IUserService userService;
+    @Autowired
+    private IRoleService roleService;
     @Autowired
     private ITSiteService siteService;
     @Autowired
@@ -69,11 +74,14 @@
      */
     @RequestMapping(value = "/list")
     @ResponseBody
-    public List<VipPaymentVO> list(String appUserName
+    public List<VipPaymentListVO> list(String appUserName
             , String phone, String vipName
             , Integer isRefund
             , String time
             ) {
+        // 判断当前是否有权限
+        String roleid = UserExt.getUser().getRoleid();
+        int count = relationService.count(new LambdaQueryWrapper<Relation>().eq(Relation::getRoleid, roleid).eq(Relation::getMenuid, 646));
         VipPaymentDto vipPaymentDto = new VipPaymentDto();
         if (StringUtils.hasLength(vipName)){
             List<Integer> vipIds = vipService.lambdaQuery().like(Vip::getVipName, vipName)
@@ -110,7 +118,180 @@
                 vipPaymentDto.setUserIds(userIds);
             }
         }
-        return null;
+        vipPaymentDto.setIsRefund(isRefund);
+        if (StringUtils.hasLength(time)){
+            String stareTime = null;
+            String endTime = null;
+            stareTime = time.split(" - ")[0] + " 00:00:00";
+            endTime = time.split(" - ")[1] + " 23:59:59";
+            vipPaymentDto.setStartTime(stareTime);
+            vipPaymentDto.setEndTime(endTime);
+        }
+        QueryByNamePhone queryByNamePhone = new QueryByNamePhone();
+        List<TAppUser> tAppUsers = appUserClient.queryByNamePhone(queryByNamePhone);
+        List<Vip> vipList = vipService.list();
+        List<VipPaymentListVO> res =vipPaymentClient.vipPayment(vipPaymentDto);
+        for (VipPaymentListVO re : res) {
+            Vip vip = vipList.stream().filter(e -> e.getId().equals(re.getVipId())).findFirst().orElse(null);
+            if (vip!=null){
+                re.setVipName(vip.getVipName());
+                Integer timeType = vip.getTimeType();
+                Integer time1 = vip.getTime();
+                switch (timeType){
+                    case 1:
+                        re.setVipTime(time1 + "天");
+                        break;
+                    case 2:
+                        re.setVipTime(time1 + "月");
+                        break;
+                    case 3:
+                        re.setVipTime(time1 + "年");
+                        break;
+                }
+            }
+            re.setAmountValue("¥"+re.getAmount().toString());
+            TAppUser appUser = tAppUsers.stream().filter(e -> e.getId().equals(re.getAppUserId())).findFirst().orElse(null);
+            if (appUser!=null){
+                re.setAppUserName(appUser.getName());
+                re.setAppUserPhone(appUser.getPhone());
+            }
+            if (count>0){
+                re.setMenuShow(1);
+            }
+
+        }
+
+        return res;
+    }
+    /**
+     * 导出会员卡订单
+     * @param
+     */
+    @GetMapping("/export")
+    public void exportData(String appUserName
+            , String phone, String vipName
+            , Integer isRefund
+            , String time, HttpServletResponse response) {
+        VipPaymentDto vipPaymentDto = new VipPaymentDto();
+        if (StringUtils.hasLength(vipName)){
+            List<Integer> vipIds = vipService.lambdaQuery().like(Vip::getVipName, vipName)
+                    .list().stream().map(Vip::getId).collect(Collectors.toList());
+            if (vipIds.isEmpty()){
+                vipIds.add(-1);
+            }
+            vipPaymentDto.setVipIds(vipIds);
+        }
+        if (StringUtils.hasLength(phone)){
+            QueryByNamePhone queryByNamePhone = new QueryByNamePhone();
+            queryByNamePhone.setPhone( phone);
+            List<Integer> userIds = appUserClient.queryByNamePhone(queryByNamePhone).stream().map(TAppUser::getId)
+                    .collect(Collectors.toList());
+
+            vipPaymentDto.setUserIds(userIds);
+        }
+        if (StringUtils.hasLength(appUserName)){
+            QueryByNamePhone queryByNamePhone = new QueryByNamePhone();
+            queryByNamePhone.setName( appUserName);
+            List<Integer> userIds = appUserClient.queryByNamePhone(queryByNamePhone).stream().map(TAppUser::getId)
+                    .collect(Collectors.toList());
+            if (vipPaymentDto.getUserIds()!=null){
+                // 取交集
+                vipPaymentDto.setUserIds(vipPaymentDto.getUserIds().stream().filter(userIds::contains).collect(Collectors.toList()));
+            }else{
+                vipPaymentDto.setUserIds(userIds);
+            }
+        }
+        if (StringUtils.hasLength(appUserName)|| StringUtils.hasLength(phone)){
+            if (vipPaymentDto.getUserIds().isEmpty()){
+                List<Integer> userIds = vipPaymentDto.getUserIds();
+                userIds.add(-1);
+                vipPaymentDto.setUserIds(userIds);
+            }
+        }
+        vipPaymentDto.setIsRefund(isRefund);
+        if (StringUtils.hasLength(time)){
+            String stareTime = null;
+            String endTime = null;
+            stareTime = time.split(" - ")[0] + " 00:00:00";
+            endTime = time.split(" - ")[1] + " 23:59:59";
+            vipPaymentDto.setStartTime(stareTime);
+            vipPaymentDto.setEndTime(endTime);
+        }
+        QueryByNamePhone queryByNamePhone = new QueryByNamePhone();
+        List<TAppUser> tAppUsers = appUserClient.queryByNamePhone(queryByNamePhone);
+        List<Vip> vipList = vipService.list();
+        List<VipPaymentListVO> res =vipPaymentClient.vipPayment(vipPaymentDto);
+        for (VipPaymentListVO re : res) {
+            Vip vip = vipList.stream().filter(e -> e.getId().equals(re.getVipId())).findFirst().orElse(null);
+            if (vip!=null){
+                re.setVipName(vip.getVipName());
+                Integer timeType = vip.getTimeType();
+                Integer time1 = vip.getTime();
+                switch (timeType){
+                    case 1:
+                        re.setVipTime(time1 + "天");
+                        break;
+                    case 2:
+                        re.setVipTime(time1 + "月");
+                        break;
+                    case 3:
+                        re.setVipTime(time1 + "年");
+                        break;
+                }
+            }
+            re.setAmountValue("¥"+re.getAmount().toString());
+            TAppUser appUser = tAppUsers.stream().filter(e -> e.getId().equals(re.getAppUserId())).findFirst().orElse(null);
+            if (appUser!=null){
+                re.setAppUserName(appUser.getName());
+                re.setAppUserPhone(appUser.getName());
+            }
+        }
+
+        String[] titleArr = {"订单编号", "用户姓名", "联系电话", "会员卡名称", "时长", "金额", "下单时间", "是否退费", "备注"};
+        String[][] values = new String[res.size()][];
+        for (int i = 0; i < res.size(); i++) {
+            VipPaymentListVO vipPaymentListVO = res.get(i);
+            values[i] = new String[titleArr.length];
+            values[i][0] = vipPaymentListVO.getCode();
+            values[i][1] = vipPaymentListVO.getAppUserName();
+            values[i][2] = vipPaymentListVO.getAppUserPhone();
+            values[i][3] = vipPaymentListVO.getVipName();
+            values[i][4] = vipPaymentListVO.getVipTime();
+            values[i][5] = vipPaymentListVO.getAmountValue();
+            values[i][6] = DateUtil.format(vipPaymentListVO.getInsertTime(), "yyyy-MM-dd HH:mm:ss");
+            values[i][7] = vipPaymentListVO.getIsRefund() == 1 ? "是" : "否";
+            values[i][8] = vipPaymentListVO.getRemark().toString();
+        }
+        try {
+            HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("会员卡订单", titleArr, values, null);
+            ExcelUtil.setResponseHeader(response, "会员卡订单.xls");
+            OutputStream os = response.getOutputStream();
+            wb.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    /**
+     * 退费
+     */
+    @RequestMapping(value = "/refund")
+    @ResponseBody
+    public Object list(@RequestBody VipRefundDto vipRefundDto) {
+        Integer objectId = UserExt.getUser().getObjectId();
+        User user = userService.getById(UserExt.getUser().getId());
+        String roleid = user.getRoleid();
+        Role role = roleService.getById(roleid);
+        if (!role.getName().contains("财务")){
+            return ResultUtil.error("权限不足");
+        }
+        String code =vipPaymentClient.refund(vipRefundDto);
+        if (code!=null&& code.equals("200")){
+            return ResultUtil.success("操作成功");
+        }else{
+            return ResultUtil.error("退费失败");
+        }
     }
 
 

--
Gitblit v1.7.1