| | |
| | | import com.dsh.competition.entity.UserCompetition; |
| | | import com.dsh.competition.feignclient.account.AppUserClient; |
| | | import com.dsh.competition.feignclient.account.model.AppUser; |
| | | import com.dsh.competition.feignclient.course.CoursePackagePaymentClient; |
| | | import com.dsh.competition.feignclient.model.*; |
| | | import com.dsh.competition.model.*; |
| | | import com.dsh.competition.service.CompetitionService; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import lombok.Synchronized; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | |
| | | @Autowired |
| | | private AppUserClient appUserClient; |
| | | |
| | | /** |
| | | * 根据门店ids 获取对应的赛事 根据赛事支付记录获取用户ids |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/getUserIds") |
| | | public List<Integer> getUserIds(@RequestBody ListQuery query){ |
| | | List<Competition> list = cttService.list(new QueryWrapper<Competition>()); |
| | | // 赛事id集合 |
| | | List<Integer> comIds = new ArrayList<>(); |
| | | |
| | | for (Integer id : query.getIds()) { |
| | | for (Competition competition : list) { |
| | | if (competition.getStoreId().contains(id.toString())){ |
| | | comIds.add(competition.getId()); |
| | | } |
| | | } |
| | | } |
| | | // 获取到赛事id集合 去重 |
| | | List<Integer> collect = comIds.stream().distinct().collect(Collectors.toList()); |
| | | // 根据赛事id 查询赛事支付记录 获取用户ids |
| | | List<PaymentCompetition> competitionId = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>() |
| | | .in("competitionId", collect)); |
| | | |
| | | // .stream().map(PaymentCompetition::getAppUserId).collect(Collectors.toList()); |
| | | |
| | | |
| | | return null; |
| | | } |
| | | /** |
| | | * 获取赛事报名记录 |
| | | */ |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/competition/getCompetitionsDetails1") |
| | | public List<PurchaseRecordVo> getStuSourseList1(@RequestBody GetStuSourseList sourseList){ |
| | | |
| | | List<PurchaseRecordVo> recordVos = new ArrayList<>(); |
| | | |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | integers.add(4); |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private CompetitionService competitionService; |
| | | @Resource |
| | | private CoursePackagePaymentClient coursePackagePaymentClient; |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/competition/paymentCompetition") |
| | | @ApiOperation(value = "赛事报名", tags = {"APP-赛事活动列表"}) |
| | |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | |
| | | }) |
| | | public ResultUtil paymentCompetition(PaymentCompetitionVo paymentCompetitionVo){ |
| | | |
| | | public synchronized ResultUtil paymentCompetition(PaymentCompetitionVo paymentCompetitionVo){ |
| | | try { |
| | | Competition byId = competitionService.getById(paymentCompetitionVo.getId()); |
| | | Date date = byId.getEndTime(); |
| | | // Assuming you have a Date object |
| | | // Check if the date is past the current time |
| | | boolean isPast = date.after(new Date()); |
| | | if (!isPast) { |
| | | return new ResultUtil(0,"已超过截至报名时间"); |
| | | } |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | if (byId.getRegisterCondition()==3){ |
| | | Integer counts = coursePackagePaymentClient.isHave(uid); |
| | | if (counts==0){ |
| | | return new ResultUtil(0,"当前赛事仅限已购课学员报名"); |
| | | } |
| | | } |
| | | if (byId.getRegisterCondition()==2){ |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | if (appUser.getIsVip()==0){ |
| | | return new ResultUtil(0,"当前赛事仅限年度会员报名"); |
| | | }else { |
| | | Date vipEndTime = appUser.getVipEndTime(); |
| | | Date currentTime = new Date(); // Current time |
| | | if (vipEndTime.before(currentTime)) { |
| | | return new ResultUtil(0,"您的年度会员已过期,请续费"); |
| | | } |
| | | } |
| | | } |
| | | return cttService.paymentCompetition(uid, paymentCompetitionVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |