From 232d3efb20f87f9c60faeda7bae4bc96e5687bd3 Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期三, 11 十月 2023 19:19:47 +0800 Subject: [PATCH] 10.12 --- cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java | 646 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 624 insertions(+), 22 deletions(-) diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java b/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java index 41ac205..b03f406 100644 --- a/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java +++ b/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java @@ -1,22 +1,38 @@ package com.dsh.competition.controller; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dsh.competition.entity.Competition; +import com.dsh.competition.entity.Participant; +import com.dsh.competition.entity.PaymentCompetition; import com.dsh.competition.entity.UserCompetition; -import com.dsh.competition.feignclient.model.GetStuSourseList; -import com.dsh.competition.feignclient.model.PurchaseRecordVo; +import com.dsh.competition.feignclient.account.AppUserClient; +import com.dsh.competition.feignclient.account.model.AppUser; +import com.dsh.competition.feignclient.model.*; +import com.dsh.competition.model.*; import com.dsh.competition.service.CompetitionService; +import com.dsh.competition.service.IParticipantService; +import com.dsh.competition.service.IPaymentCompetitionService; import com.dsh.competition.service.UserCompetitionService; +import com.dsh.competition.util.PayMoneyUtil; +import com.dsh.competition.util.ResultUtil; +import com.dsh.competition.util.TokenUtil; +import com.dsh.competition.util.ToolUtil; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import java.util.concurrent.CompletionService; import java.util.stream.Collectors; /** @@ -40,29 +56,615 @@ private final SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm"); + @Autowired + private TokenUtil tokenUtil; + + @Autowired + private PayMoneyUtil payMoneyUtil; + + @Autowired + private IPaymentCompetitionService paymentCompetitionService; + + @Autowired + private IParticipantService participantService; + + @Autowired + private AppUserClient appUserClient; + + + /** + * 获取赛事报名记录 + */ + @ResponseBody + @RequestMapping("/base/competition/listAllPayment") + public List<PaymentCompetition> listAllPayment(@RequestBody CompetitionQuery query){ + List<PaymentCompetition> paymentCompetitions = paymentCompetitionService.listAll(query); + List<PaymentCompetition> result = new ArrayList<>(); + if (query.getOperatorId()!=null){ + for (PaymentCompetition paymentCompetition : paymentCompetitions) { + Integer competitionId = paymentCompetition.getCompetitionId(); + Competition byId = cttService.getById(competitionId); + if (byId!=null){ + Integer operatorId = byId.getOperatorId(); + if (operatorId!=null){ + if (operatorId == query.getOperatorId()){ + result.add(paymentCompetition); + } + } + } + } + return result; + }else if (query.getStoreId()!=null){ + for (PaymentCompetition paymentCompetition : paymentCompetitions) { + Integer competitionId = paymentCompetition.getCompetitionId(); + Competition byId = cttService.getById(competitionId); + if (byId!=null){ + String storeId = byId.getStoreId(); + if (storeId.contains(query.getStoreId().toString())){ + result.add(paymentCompetition); + } + } + } + return result; + } + return paymentCompetitions; + } + @ResponseBody + @PostMapping("/base/competition/getPayedCompetitions") + public BillingRequestVo getAllCompetitionPayRecord(@RequestBody BillingDataRequestVo requestVo){ + BillingRequestVo billingRequestVo = new BillingRequestVo(); + List<BillingRequest> integers = new ArrayList<>(); + integers = paymentCompetitionService.queryDatas(requestVo.getAppUserId(),requestVo.getMonthStart(),requestVo.getMonthEnd()); + System.out.println(integers); + if (integers.size() > 0 ){ + billingRequestVo.setRequests(integers); + } + return billingRequestVo; + } + + @ResponseBody + @PostMapping("/base/competition/getCancelOrderOfUserPay") + public BillingRequestVo getCancelOrderOfUserPayRecord(@RequestBody BillingDataRequestVo requestVo){ + BillingRequestVo billingRequestVo = new BillingRequestVo(); + List<BillingRequest> integers = new ArrayList<>(); + integers = paymentCompetitionService.queryCancelDatas(requestVo.getAppUserId(),requestVo.getMonthStart(),requestVo.getMonthEnd()); + System.out.println(integers); + if (integers.size() > 0 ){ + billingRequestVo.setRequests(integers); + } + return billingRequestVo; + } + + + @PostMapping("/base/competition/getPlayPaiFGoldPayRecord") + public List<PaymentCompetition> getPlayPaiFGoldPayRecord(@RequestBody Integer appUserId){ + ArrayList<Integer> integers = new ArrayList<>(); + integers.add(1); + integers.add(2); + return paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>() + .in("payType",integers) + .eq("appUserId",appUserId) + .eq("payStatus",3)); + } + + + @PostMapping("/base/competition/queryByCode") + public Integer queryByCode(@RequestBody String code){ + + return paymentCompetitionService.queryByCode(code); + } + + + + @PostMapping("/base/competition/getCompetitionsDetails") public List<PurchaseRecordVo> getStuSourseList(@RequestBody GetStuSourseList sourseList){ List<PurchaseRecordVo> recordVos = new ArrayList<>(); - List<Competition> list = cttService.list(new QueryWrapper<Competition>() - .eq("payType",3 ) - .eq("auditStatus",2)); - List<Integer> comIds = list.stream().map(Competition::getId).collect(Collectors.toList()); - List<UserCompetition> userCompetitions = ucttService.queryUsersCompetetions(sourseList.getStartTime(),sourseList.getEndTime(),sourseList.getAppUserId(),comIds); - if (userCompetitions.size() > 0){ - userCompetitions.forEach(coms ->{ - PurchaseRecordVo recordVo = new PurchaseRecordVo(); - recordVo.setPurchaseType("报名赛事"); - recordVo.setPurchaseTime(dateFormat.format(coms.getInsertTime())); - Competition competition = cttService.getById(coms.getCompetitionId()); - recordVo.setPurchaseAmount("-"+competition.getPrice()); - recordVos.add(recordVo); - }); + ArrayList<Integer> integers = new ArrayList<>(); + integers.add(1); + integers.add(2); + List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>() + .in("payType",integers ) + .eq("appUserId", sourseList.getAppUserId()) + .eq("state",1)); + if (list.size() > 0){ + List<Long> comIds = list.stream().map(PaymentCompetition::getId).collect(Collectors.toList()); + List<UserCompetition> userCompetitions = ucttService.list(new QueryWrapper<UserCompetition>() + .between("insertTime", sourseList.getStartTime(),sourseList.getEndTime() ) + .eq("appUserId", sourseList.getAppUserId()) + .in("paymentCompetitionId",comIds )); + if (userCompetitions.size() > 0){ + userCompetitions.forEach(coms ->{ + PurchaseRecordVo recordVo = new PurchaseRecordVo(); + recordVo.setPurchaseType("报名赛事"); + recordVo.setPurchaseTime(dateFormat.format(coms.getInsertTime())); + PaymentCompetition paymentCompetition = paymentCompetitionService.getById(coms.getPaymentCompetitionId()); + recordVo.setPurchaseAmount("-"+paymentCompetition.getAmount()); + recordVos.add(recordVo); + }); + } } + return recordVos; } + + + + @ResponseBody + @PostMapping("/base/competition/queryCompetitionList") + @ApiOperation(value = "获取赛事列表", tags = {"APP-赛事活动列表"}) + @ApiImplicitParams({ + @ApiImplicitParam(value = "城市code", name = "cityCode", dataType = "string", required = false), + @ApiImplicitParam(value = "搜索内容", name = "content", dataType = "string", required = false), + @ApiImplicitParam(value = "报名条件(1=全部用户,2=仅限年度会员参与,3=仅限学员参与)", name = "registerCondition", dataType = "int", required = false), + @ApiImplicitParam(value = "排序(asc=正序,desc=倒序)", name = "heat", dataType = "String", required = false), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil<List<CompetitionListVo>> queryCompetitionList(String cityCode, String content, Integer registerCondition, String heat){ + try { + List<CompetitionListVo> competitionListVos = cttService.queryCompetitionList(cityCode, content, registerCondition, heat); + return ResultUtil.success(competitionListVos); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + + @ResponseBody + @PostMapping("/base/competition/queryCompetitionInfo") + @ApiOperation(value = "获取赛事详情", tags = {"APP-赛事活动列表"}) + @ApiImplicitParams({ + @ApiImplicitParam(value = "赛事id", name = "id", dataType = "int", required = true), + @ApiImplicitParam(value = "经度", name = "lon", dataType = "string", required = false), + @ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = false), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil<CompetitionInfo> queryCompetitionInfo(Integer id, String lon, String lat){ + try { + Integer uid = tokenUtil.getUserIdFormRedis(); + if(null == uid){ + return ResultUtil.tokenErr(); + } + CompetitionInfo competitionInfo = cttService.queryCompetitionInfo(uid, id, lon, lat); + return ResultUtil.success(competitionInfo); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + + @ResponseBody + @PostMapping("/api/competition/paymentCompetition") + @ApiOperation(value = "赛事报名", tags = {"APP-赛事活动列表"}) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + + }) + public ResultUtil paymentCompetition(PaymentCompetitionVo paymentCompetitionVo){ + try { + Integer uid = tokenUtil.getUserIdFormRedis(); + if(null == uid){ + return ResultUtil.tokenErr(); + } + return cttService.paymentCompetition(uid, paymentCompetitionVo); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + @ResponseBody + @PostMapping("/api/competition/paymentCompetitionCourseList") + @ApiOperation(value = "赛事报名--支付可用课时列表", tags = {"APP-赛事活动列表"}) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), + @ApiImplicitParam(value = "赛事id", name = "id", dataType = "int", required = true), + }) + public ResultUtil paymentCompetitionCourseList(Integer id){ + try { + Integer uid = tokenUtil.getUserIdFormRedis(); + if(null == uid){ + return ResultUtil.tokenErr(); + } + return cttService.paymentCompetitionCourseList(uid, id); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + /** + * 报名赛事微信支付回调 + * @param request + * @param response + */ + @ResponseBody + @PostMapping("/base/competition/weChatPaymentCompetitionCallback") + public void weChatPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response){ + try { + Map<String, String> map = payMoneyUtil.weixinpayCallback(request); + if(null != map){ + String code = map.get("out_trade_no"); + String transaction_id = map.get("transaction_id"); + String result = map.get("result"); + + PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 1)); + if(paymentCompetition.getPayStatus() == 1){ + paymentCompetition.setAppUserId(null); + paymentCompetition.setPayStatus(2); + paymentCompetition.setPayTime(new Date()); + paymentCompetition.setPayOrderNo(transaction_id); + paymentCompetitionService.updateById(paymentCompetition); + + Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); + competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); + cttService.updateById(competition); + } + + PrintWriter out = response.getWriter(); + out.write(result); + out.flush(); + out.close(); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + + + /** + * 报名赛事支付宝支付回调 + * @param request + * @param response + */ + @ResponseBody + @PostMapping("/base/competition/aliPaymentCompetitionCallback") + public void aliPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response){ + try { + Map<String, String> map = payMoneyUtil.alipayCallback(request); + if(null != map){ + String code = map.get("out_trade_no"); + String trade_no = map.get("trade_no"); + + PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 2)); + if(paymentCompetition.getPayStatus() == 1){ + paymentCompetition.setAppUserId(null); + paymentCompetition.setPayStatus(2); + paymentCompetition.setPayTime(new Date()); + paymentCompetition.setPayOrderNo(trade_no); + paymentCompetitionService.updateById(paymentCompetition); + + Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); + competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); + cttService.updateById(competition); + } + PrintWriter out = response.getWriter(); + out.write("success"); + out.flush(); + out.close(); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + + + + + @ResponseBody + @PostMapping("/api/competition/queryMyCompetitionList") + @ApiOperation(value = "获取已报名赛事列表", tags = {"APP-赛事活动列表"}) + @ApiImplicitParams({ + @ApiImplicitParam(value = "类型(0=全部,1=未开始,2=进行中,3=已结束,4=已取消)", name = "type", dataType = "int", required = true), + @ApiImplicitParam(value = "页条数", name = "pageSize", dataType = "int", required = true), + @ApiImplicitParam(value = "页码,首页1", name = "pageNo", dataType = "int", required = true), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil<List<CompetitionListVo>> queryMyCompetitionList(Integer type, Integer pageSize, Integer pageNo){ + try { + Integer uid = tokenUtil.getUserIdFormRedis(); + if(null == uid){ + return ResultUtil.tokenErr(); + } + List<CompetitionListVo> competitionListVos = paymentCompetitionService.queryMyCompetitionList(uid, type, pageSize, pageNo); + return ResultUtil.success(competitionListVos); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + + @ResponseBody + @PostMapping("/api/competition/queryMyCompetitionInfo") + @ApiOperation(value = "获取已报名赛事详情", tags = {"APP-赛事活动列表"}) + @ApiImplicitParams({ + @ApiImplicitParam(value = "赛事id", name = "id", dataType = "int", required = true), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil<CompetitionInfo> queryMyCompetitionInfo(Long id){ + try { + CompetitionInfo competitionInfo = paymentCompetitionService.queryMyCompetitionInfo(id); + return ResultUtil.success(competitionInfo); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + + @ResponseBody + @PostMapping("/api/competition/cancelMyCompetition") + @ApiOperation(value = "取消报名的赛事", tags = {"APP-赛事活动列表"}) + @ApiImplicitParams({ + @ApiImplicitParam(value = "赛事id", name = "id", dataType = "int", required = true), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil cancelMyCompetition(Long id){ + try { + ResultUtil resultUtil = paymentCompetitionService.cancelMyCompetition(id); + return resultUtil; + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + /** + * 取消已报名赛事后微信回退金额回调 + * @param request + * @param response + */ + @ResponseBody + @PostMapping("/base/competition/weChatCancelPaymentCompetitionCallback") + public void weChatCancelPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response){ + try { + Map<String, String> map = payMoneyUtil.wxRefundCallback(request); + if(null != map){ + String code = map.get("out_refund_no"); + String refund_id = map.get("refund_id"); + String result = map.get("result"); + PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 1)); + if(paymentCompetition.getPayStatus() == 1){ + paymentCompetition.setPayStatus(3); + paymentCompetition.setRefundTime(new Date()); + paymentCompetition.setRefundOrderNo(refund_id); + paymentCompetition.setAppUserId(null); + paymentCompetitionService.updateById(paymentCompetition); + + Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); + competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); + cttService.updateById(competition); + } + PrintWriter out = response.getWriter(); + out.write(result); + out.flush(); + out.close(); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + + + @PostMapping("/base/competition/queryById") + public Competition queryById(@RequestBody Integer id){ + try { + return cttService.getById(id); + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } + + + @PostMapping("/base/competition/list") + public Page<Competition> list(@RequestBody ListQuery listQuery){ + try { + Page<Competition> competitionPage = new Page<>(listQuery.getOffset(),listQuery.getLimit()); + LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<>(); + if(ToolUtil.isNotEmpty(listQuery.getProvinceCode())){ + wrapper.eq(Competition::getProvinceCode,listQuery.getProvinceCode()); + } + if(ToolUtil.isNotEmpty(listQuery.getCityCode())){ + wrapper.eq(Competition::getProvinceCode,listQuery.getCityCode()); + } + if(ToolUtil.isNotEmpty(listQuery.getEventName())){ + wrapper.like(Competition::getName,listQuery.getEventName()); + } + if(ToolUtil.isNotEmpty(listQuery.getTime())){ + wrapper.gt(Competition::getStartTime,listQuery.getTime().split(" - ")[0]+" 00:00:00"); + wrapper.lt(Competition::getEndTime,listQuery.getTime().split(" - ")[1]+" 23:59:59"); + } + if(ToolUtil.isNotEmpty(listQuery.getState())){ + wrapper.eq(Competition::getStatus,listQuery.getState()); + } + if(ToolUtil.isNotEmpty(listQuery.getRegisterCondition())){ + wrapper.eq(Competition::getRegisterCondition,listQuery.getRegisterCondition()); + } + wrapper.in(Competition::getStoreId,listQuery.getIds()); + wrapper.eq(Competition::getAuditStatus,2); + wrapper.orderByDesc(Competition::getInsertTime); + + Page<Competition> page = cttService.page(competitionPage, wrapper); + return page; + }catch (Exception e){ + e.printStackTrace(); + return new Page<Competition>(); + } + } + @PostMapping("/base/competition/listAudit") + public Page<Competition> listAudit(@RequestBody ListQuery listQuery){ + try { + Page<Competition> competitionPage = new Page<>(listQuery.getOffset(),listQuery.getLimit()); + LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<>(); + if(ToolUtil.isNotEmpty(listQuery.getProvinceCode())){ + wrapper.eq(Competition::getProvinceCode,listQuery.getProvinceCode()); + } + if(ToolUtil.isNotEmpty(listQuery.getCityCode())){ + wrapper.eq(Competition::getProvinceCode,listQuery.getCityCode()); + } + if(ToolUtil.isNotEmpty(listQuery.getEventName())){ + wrapper.like(Competition::getName,listQuery.getEventName()); + } + if(ToolUtil.isNotEmpty(listQuery.getState())){ + wrapper.eq(Competition::getAuditStatus,listQuery.getState()); + } + if(ToolUtil.isNotEmpty(listQuery.getRegisterCondition())){ + wrapper.eq(Competition::getRegisterCondition,listQuery.getRegisterCondition()); + } + wrapper.in(Competition::getStoreId,listQuery.getIds()); + ArrayList<Integer> integers = new ArrayList<>(); + integers.add(1); + integers.add(3); + wrapper.in(Competition::getAuditStatus,integers); + wrapper.orderByDesc(Competition::getInsertTime); + + Page<Competition> page = cttService.page(competitionPage, wrapper); + return page; + }catch (Exception e){ + e.printStackTrace(); + return new Page<Competition>(); + } + } + + + @PostMapping("/base/competition/add") + public void add(@RequestBody Competition competition){ + try { + competition.setInsertTime(new Date()); + cttService.save(competition); + }catch (Exception e){ + e.printStackTrace(); + } + } + + @PostMapping("/base/competition/update") + public void update(@RequestBody Competition competition){ + try { + cttService.updateById(competition); + }catch (Exception e){ + e.printStackTrace(); + } + } + + @PostMapping("/base/competition/cancel") + public void cancel(@RequestBody Integer id){ + try { + Competition byId = cttService.getById(id); + byId.setStatus(4); + cttService.updateById(byId); + }catch (Exception e){ + e.printStackTrace(); + } + } + + + @PostMapping("/base/competition/getPeopleFromId") + public Page<CompetitionUser> getPeopleFromId(@RequestBody GetPeopleQuery getPeopleQuery){ + try { + Page<UserCompetition> participantPage = new Page<>(getPeopleQuery.getOffset(),getPeopleQuery.getLimit()); + Page<CompetitionUser> page = participantService.getPeopleFromId(participantPage,getPeopleQuery.getId(),getPeopleQuery.getState()); + return page; + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } + + + + @PostMapping("/base/competition/queryFee") + public Double queryFee(@RequestBody QueryDataFee queryDataFee){ + HashMap<String, Object> map = new HashMap<>(); + String data = queryDataFee.getData(); + List<Integer> ids = queryDataFee.getIds(); + if(ids.size()==0){ + ids.add(-1); + } + LambdaQueryWrapper<PaymentCompetition> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>(); + if(ToolUtil.isNotEmpty(data)){ + String stime = data.split(" - ")[0]+" 00:00:00"; + String etime = data.split(" - ")[1]+" 23:59:59"; + vipPaymentLambdaQueryWrapper.between(PaymentCompetition::getInsertTime,stime,etime); + } + vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getAppUserId,ids); + vipPaymentLambdaQueryWrapper.eq(PaymentCompetition::getPayStatus,2); + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + objects.add(2); + vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getPayType,objects); + List<PaymentCompetition> list = paymentCompetitionService.list(vipPaymentLambdaQueryWrapper); + double sum = list.stream().mapToDouble(PaymentCompetition::getAmount).sum(); + return sum; + } + + + + @ResponseBody + @PostMapping("/base/competition/actPt") + public HashMap<String, Object> actPt(@RequestBody List<Integer> ids){ + HashMap<String, Object> map = new HashMap<>(); + if(ids.size()==0){ + ids.add(-1); + } + ArrayList<Object> integers = new ArrayList<>(); + int year = DateUtil.year(new Date()); + + for (int i = 0; i < 10; i++) { + integers.add(year-i); + } + List<Object> collect = integers.stream().sorted().collect(Collectors.toList()); + // 年 + ArrayList<Integer> years = new ArrayList<>(); + ArrayList<Integer> yearsUser = new ArrayList<>(); + for (Object o : collect) { + String s = o.toString(); + int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s)); + int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, ids).like(UserCompetition::getInsertTime,s)); + years.add(count); + yearsUser.add(count1); + } + map.put("yearData",years); + map.put("yearsUser",yearsUser); + // 月 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + ArrayList<Integer> months = new ArrayList<>(); + ArrayList<Integer> monthsUser = new ArrayList<>(); + for (int i = 1; i <= 12; i++) { + double sum=0.0; + String m=i+""; + if(i<10){ + m="0"+i; + } + String s = year + "-" + m; + int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s)); + int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, ids).like(UserCompetition::getInsertTime,s)); + months.add(count); + monthsUser.add(count1); + } + map.put("monthData",months); + map.put("monthsUser",monthsUser); + + return map; + + + + } + } -- Gitblit v1.7.1