From c560f1a14ae1fc468d90e50e6a32d805295875da Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期一, 01 九月 2025 15:35:59 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0' into 2.0
---
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TVipDetailController.java | 134 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 132 insertions(+), 2 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 ceecb47..fc8117d 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,10 +1,13 @@
package com.dsh.guns.modular.system.controller.code;
+import cn.hutool.core.collection.CollUtil;
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.HuiminPayQuery;
+import com.dsh.guns.config.UserExt;
import com.dsh.guns.core.base.controller.BaseController;
import com.dsh.guns.core.base.tips.SuccessTip;
import com.dsh.guns.modular.system.model.*;
@@ -12,13 +15,19 @@
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 javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.*;
import java.util.stream.Collectors;
@@ -40,6 +49,10 @@
private AppUserClient appUserClient;
@Autowired
private VipPaymentClient vipPaymentClient;
+ @Autowired
+ private IUserService userService;
+ @Autowired
+ private IRoleService roleService;
@Autowired
private ITSiteService siteService;
@Autowired
@@ -136,10 +149,120 @@
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());
+ re.setAppUserPhone(appUser.getPhone());
}
}
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);
+ }
}
/**
* 退费
@@ -147,9 +270,16 @@
@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();
+ return ResultUtil.success("操作成功");
}else{
return ResultUtil.error("退费失败");
}
--
Gitblit v1.7.1