From 16207f06b1aae069c05657c178855388a2bcf5b2 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 26 八月 2025 18:45:09 +0800 Subject: [PATCH] 会员支付相关 --- cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TVipDetailController.java | 361 ++++++++++++++++++++++++++++---------------------- 1 files changed, 201 insertions(+), 160 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 f6db7eb..9e54a94 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,30 +1,32 @@ package com.dsh.guns.modular.system.controller.code; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +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.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.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.service.IProtocolService; -import com.dsh.guns.modular.system.service.IStoreService; -import com.dsh.guns.modular.system.service.IVipService; +import com.dsh.guns.modular.system.model.dto.VipPaymentDto; +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; @@ -44,7 +46,13 @@ private IStoreService storeService; @Autowired private AppUserClient appUserClient; - private String PREFIX = "/system/vip/"; + @Autowired + private VipPaymentClient vipPaymentClient; + @Autowired + private ITSiteService siteService; + @Autowired + private TOperatorService operatorService; + private String PREFIX = "/system/vipPayment/"; /** @@ -52,8 +60,7 @@ */ @RequestMapping("") public String index(Model model) { - - return PREFIX + "vipDetail.html"; + return PREFIX + "vip_payment.html"; } /** @@ -61,176 +68,210 @@ */ @RequestMapping(value = "/list") @ResponseBody - public List<Map<String, Object>> list(String vipName, Integer type - , Integer phone, String storeName - , Integer operatorId, Integer status - , String startTime, String endTime - , Integer useStartTime, Integer useEndTim) { - // 根据会员名查询会员ids + public List<VipPaymentListVO> list(String appUserName + , String phone, String vipName + , Integer isRefund + , String time + ) { + 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); } -// QueryByNamePhone -// appUserClient.listAll() -// Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); -// List<Map<String, Object>> maps = vipService.listOfPage(vipName, status, page); -// for (Map<String, Object> map : maps) { -// Object timeType = map.get("timeType"); -// Object time = map.get("time"); -// Integer timeTypeValue = Integer.valueOf(timeType.toString()); -// Integer timeValue = Integer.valueOf(time.toString()); -// switch (timeTypeValue) { -// case 1: -// map.put("time",timeValue+"天"); -// break; -// case 2: -// map.put("time",timeValue+"月"); -// break; -// case 3: -// map.put("time",timeValue+"年"); -// break; -// } -// } - return null; - } + if (StringUtils.hasLength(phone)){ + QueryByNamePhone queryByNamePhone = new QueryByNamePhone(); + queryByNamePhone.setPhone( phone); + List<Integer> userIds = appUserClient.queryByNamePhone(queryByNamePhone).stream().map(TAppUser::getId) + .collect(Collectors.toList()); - // APP查询所有上架的会员卡 - @ResponseBody - @PostMapping("/listAll") - public List<Vip> listAll() { - List<Vip> list = vipService.lambdaQuery().eq(Vip::getStatus, 1).list(); - List<Coupon> coupons = couponClient.queryCouponAll(); - List<CouponCity> couponCityList = couponClient.queryAllCity(); - List<CouponStore> storeList = couponClient.queryAllStore(); - List<TStore> shopList = storeService.list(); - // 封装会员权益 - for (Vip vip : list) { - List<CouponVipResp> couponVipRespList = new ArrayList<>(); - List<TicketVipResp> ticketVipRespList = new ArrayList<>(); - String couponJson = vip.getCouponJson(); - JSONArray couponJsonArray = JSONArray.parseArray(couponJson); - for (Object o : couponJsonArray) { - JSONObject couponJsonObject = (JSONObject) o; - // 优惠券id - Integer id = Integer.valueOf(couponJsonObject.getString("id")); - // 优惠券数量 - Integer value = Integer.valueOf(couponJsonObject.getString("value")); - Coupon coupon = coupons.stream().filter(e -> e.getId().equals(id)).findFirst().orElse(new Coupon()); - CouponVipResp couponVipResp = new CouponVipResp(); - couponVipResp.setId(coupon.getId()); - couponVipResp.setName(coupon.getName()); - couponVipResp.setType(coupon.getType()); - couponVipResp.setUseCondition(coupon.getUseScope()); - couponVipResp.setCount(value); - switch (coupon.getUseScope()) { + 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: - couponVipResp.setAvailable("全国通用"); + re.setVipTime(time1 + "天"); break; case 2: - couponVipResp.setAvailable("指定城市可用"); - List<CouponCity> couponId = couponCityList.stream().filter(e -> e.getCouponId().equals(id)) - .collect(Collectors.toList()); - StringBuilder stringBuilder = new StringBuilder(); - for (CouponCity couponCity : couponId) { - stringBuilder.append(couponCity.getCity()); - } - couponVipResp.setCityOrStore(String.valueOf(stringBuilder)); + re.setVipTime(time1 + "月"); break; case 3: - couponVipResp.setAvailable("指定门店可用"); - // 门店ids - List<Integer> storeIds = storeList.stream().filter(e -> e.getCouponId().equals(id)) - .map(CouponStore::getStoreId).collect(Collectors.toList()); - StringBuilder storeNames = new StringBuilder(""); - - if (!storeIds.isEmpty()) { - List<TStore> stores = shopList.stream().filter(e -> storeIds.contains(e.getId())).collect(Collectors.toList()); - for (TStore store : stores) { - storeNames.append(store.getName()).append(","); - } - // 去除最后一位 - StringBuilder res = storeNames.deleteCharAt(storeNames.length() - 1); - couponVipResp.setCityOrStore(res.toString()); - } else { - couponVipResp.setCityOrStore("无可用门店"); - } - break; - default: + re.setVipTime(time1 + "年"); break; } - couponVipResp.setInstructionsForUse(coupon.getIllustrate()); - ConponJsonRuleModel ruleModel = new ConponJsonRuleModel(); - JSONObject jsonObject = JSON.parseObject(coupon.getContent()); - switch (coupon.getType()) { + } + 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()); + } + } + 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: -// 满减券 - Double num1 = jsonObject.getDouble("conditionalAmount"); - Double num2 = jsonObject.getDouble("deductionAmount"); - ruleModel.setConditionalAmount("满" + num1 + "可用"); - ruleModel.setDeductionAmount("¥ " + num2); - ruleModel.setExperienceName(""); + re.setVipTime(time1 + "天"); break; case 2: -// 代金券 - Double jsonObjectDouble = jsonObject.getDouble("conditionalAmount"); - ruleModel.setConditionalAmount(""); - ruleModel.setDeductionAmount("¥ " + jsonObjectDouble); - ruleModel.setExperienceName(""); + re.setVipTime(time1 + "月"); break; case 3: -// 体验券 - ruleModel.setConditionalAmount(""); - ruleModel.setDeductionAmount(""); - ruleModel.setExperienceName(jsonObject.getString("experienceName")); - break; - default: + re.setVipTime(time1 + "年"); break; } - couponVipResp.setRuleModel(ruleModel); - - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - couponVipResp.setEffectiveTime(simpleDateFormat.format(coupon.getEndTime())); - couponVipRespList.add(couponVipResp); } - vip.setCouponList(couponVipRespList); - String ticketJson = vip.getTicketJson(); - JSONArray ticketJsonArray = JSONArray.parseArray(ticketJson); - for (Object o : ticketJsonArray) { - JSONObject ticketJsonObject = (JSONObject) o; - TicketVipResp ticketVipResp = new TicketVipResp(); - ticketVipResp.setName(ticketJsonObject.getString("name")); - ticketVipResp.setTime(ticketJsonObject.getInteger("time")); - ticketVipResp.setCount(ticketJsonObject.getInteger("count")); - ticketVipRespList.add(ticketVipResp); + 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()); } - vip.setTicketList(ticketVipRespList); } - return list; + + 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); + } } - @Autowired - private IProtocolService protocolService; + /** + * 退费 + */ + @RequestMapping(value = "/refund") @ResponseBody - @PostMapping("/getAgreement") - public String getAgreement() { - Protocol one = protocolService.lambdaQuery().eq(Protocol::getType, 6).one(); - if (one==null){ - Protocol protocol = new Protocol(); - protocol.setType(6); - protocol.setContent(""); - protocol.setInsertTime(new Date()); - protocolService.save( protocol); - return ""; + public Object list(@RequestBody VipRefundDto vipRefundDto) { + String code =vipPaymentClient.refund(vipRefundDto); + if (code!=null&& code.equals("200")){ + return ResultUtil.success(); }else{ - return one.getContent(); - + return ResultUtil.error("退费失败"); } } - @ResponseBody - @PostMapping("/getVipByIds") - public List<Vip> getVipByIds(@RequestBody String ids) { - List<Vip> list = vipService.lambdaQuery().in(Vip::getId, Arrays.asList(ids.split(","))).list(); - return list; - } + } -- Gitblit v1.7.1