| | |
| | | package com.dsh.competition.controller; |
| | | |
| | | |
| | | 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.CompetitionInfo; |
| | | import com.dsh.competition.model.CompetitionListVo; |
| | | import com.dsh.competition.model.PaymentCompetitionVo; |
| | | 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; |
| | |
| | | @Autowired |
| | | private IPaymentCompetitionService paymentCompetitionService; |
| | | |
| | | @Autowired |
| | | private IParticipantService participantService; |
| | | |
| | | @Autowired |
| | | private AppUserClient appUserClient; |
| | | |
| | | |
| | | @PostMapping("/base/competition/getPayedCompetitions") |
| | | public List<PaymentCompetition> getAllCompetitionPayRecord(@RequestBody Integer appUserId){ |
| | | public List<PaymentCompetition> getAllCompetitionPayRecord(@RequestBody BillingDataRequestVo requestVo){ |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(1); |
| | | integers.add(2); |
| | | return paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>() |
| | | .in("payType",integers) |
| | | .eq("appUserId",appUserId) |
| | | .eq("payStatus",2)); |
| | | .eq("appUserId",requestVo.getAppUserId()) |
| | | .eq("payStatus",2) |
| | | .between("payTime",requestVo.getMonthStart(),requestVo.getMonthEnd())); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/competition/getCancelOrderOfUserPay") |
| | | public List<PaymentCompetition> getCancelOrderOfUserPayRecord(@RequestBody Integer appUserId){ |
| | | public List<PaymentCompetition> getCancelOrderOfUserPayRecord(@RequestBody BillingDataRequestVo requestVo){ |
| | | List<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)); |
| | | .eq("appUserId",requestVo.getAppUserId()) |
| | | .eq("payStatus",3) |
| | | .between("refundTime",requestVo.getMonthStart(),requestVo.getMonthEnd())); |
| | | } |
| | | |
| | | |
| | | @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>() |
| | | .eq("payType",3) |
| | | .in("payType",integers) |
| | | .eq("appUserId",appUserId) |
| | | .eq("payStatus",3)); |
| | | } |
| | |
| | | |
| | | 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.list(new QueryWrapper<UserCompetition>() |
| | | .between("insertTime", sourseList.getStartTime(),sourseList.getEndTime() ) |
| | | .eq("userId", sourseList.getAppUserId()) |
| | | .in("competitionId",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; |
| | | } |
| | | |
| | |
| | | |
| | | 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); |
| | |
| | | |
| | | 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); |
| | |
| | | @PostMapping("/api/competition/queryMyCompetitionList") |
| | | @ApiOperation(value = "获取已报名赛事列表", tags = {"APP-赛事活动列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "类型(1=未开始,2=进行中,3=已结束,4=已取消)", name = "type", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageSize", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "页条数", name = "pageNo", dataType = "int", required = true), |
| | | @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){ |
| | |
| | | paymentCompetition.setPayStatus(3); |
| | | paymentCompetition.setRefundTime(new Date()); |
| | | paymentCompetition.setRefundOrderNo(refund_id); |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | |
| | | Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); |
| | |
| | | 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/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; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |