| | |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.poi.excel.ExcelUtil; |
| | | import cn.mb.cloud.common.core.exception.BusinessException; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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.UserCompetition; |
| | | import com.dsh.competition.feignclient.account.AppUserClient; |
| | | import com.dsh.competition.feignclient.account.StudentClient; |
| | | import com.dsh.competition.feignclient.account.StudentHonorClient; |
| | | import com.dsh.competition.feignclient.account.model.AppUser; |
| | | import com.dsh.competition.feignclient.account.model.StudentHonor; |
| | | import com.dsh.competition.feignclient.account.model.TStudent; |
| | | import com.dsh.competition.feignclient.course.CoursePackagePaymentClient; |
| | | import com.dsh.competition.feignclient.course.model.PaymentDeductionClassHour; |
| | | import com.dsh.competition.feignclient.model.*; |
| | | import com.dsh.competition.feignclient.other.StoreClient; |
| | | import com.dsh.competition.feignclient.other.model.Store; |
| | | 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 com.dsh.competition.util.*; |
| | | import com.dsh.competition.util.wx.WxV3PayConfig; |
| | | import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import lombok.Synchronized; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | @Autowired |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private StudentHonorClient studentHonorClient; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据门店ids 获取对应的赛事 根据赛事支付记录获取用户ids |
| | | */ |
| | |
| | | // 获取到赛事id集合 去重 |
| | | List<Integer> collect = comIds.stream().distinct().collect(Collectors.toList()); |
| | | // 根据赛事id 查询赛事支付记录 获取用户ids |
| | | if (collect.size() == 0) { |
| | | if (collect.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } else { |
| | | List<Integer> userIds = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>() |
| | | .in("competitionId", collect)).stream() |
| | | .in("competitionId", collect) |
| | | .eq("payStatus",2)).stream() |
| | | .map(PaymentCompetition::getAppUserId).collect(Collectors.toList()); |
| | | return userIds; |
| | | } |
| | |
| | | } |
| | | 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; |
| | | } |
| | | return paymentCompetitions; |
| | | } |
| | |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | |
| | | }) |
| | | |
| | | 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, "已超过截至报名时间"); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 报名赛事微信支付回调 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/weChatPaymentCompetitionCallback1") |
| | | public void weChatPaymentCompetitionCallback1(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.err.println("微信回调"); |
| | | System.err.println("请求" + request); |
| | | BufferedReader reader = request.getReader(); |
| | | String string1 = reader.toString(); |
| | | System.err.println("请求reader" + string1); |
| | | StringBuilder requestBody = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | requestBody.append(line); |
| | | } |
| | | System.err.println("全部请求体" + requestBody); |
| | | JSONObject jsonObject = JSONObject.parseObject(requestBody.toString()); |
| | | JSONObject resource = jsonObject.getJSONObject("resource"); |
| | | |
| | | AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8)); |
| | | String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8), |
| | | resource.getString("ciphertext")); |
| | | System.err.println("微信解密的字符串信息" + decryptedData); |
| | | JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData); |
| | | String code = jsonInfo.getString("out_trade_no"); |
| | | String transaction_id = jsonInfo.getString("transaction_id"); |
| | | String trade_state = jsonInfo.getString("trade_state"); |
| | | if (trade_state.equals("SUCCESS")) { |
| | | 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("SUCCESS"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | /** |
| | | * 报名赛事微信支付回调 |
| | | * |
| | |
| | | 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 paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>() |
| | | .eq("code", code).eq("payType", 1)); |
| | | if (paymentCompetition.getPayStatus() == 2) { |
| | | paymentCompetition.setPayStatus(3); |
| | | paymentCompetition.setRefundTime(new Date()); |
| | | paymentCompetition.setRefundOrderNo(refund_id); |
| | |
| | | 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(); |
| | | } |
| | | } |
| | | /** |
| | | * 取消已报名赛事后微信回退金额回调微信V3服务商版本 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/weChatCancelPaymentCompetitionCallback1") |
| | | public void weChatCancelPaymentCompetitionCallback1(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.err.println("微信回调"); |
| | | System.err.println("请求" + request); |
| | | BufferedReader reader = request.getReader(); |
| | | String string1 = reader.toString(); |
| | | System.err.println("请求reader" + string1); |
| | | StringBuilder requestBody = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | requestBody.append(line); |
| | | } |
| | | System.err.println("全部请求体" + requestBody); |
| | | JSONObject jsonObject = JSONObject.parseObject(requestBody.toString()); |
| | | JSONObject resource = jsonObject.getJSONObject("resource"); |
| | | |
| | | AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8)); |
| | | String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8), |
| | | resource.getString("ciphertext")); |
| | | System.err.println("微信解密的字符串信息" + decryptedData); |
| | | JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData); |
| | | String code = jsonInfo.getString("out_trade_no"); |
| | | String transaction_id = jsonInfo.getString("transaction_id"); |
| | | String refund_status = jsonInfo.getString("refund_status"); |
| | | String out_refund_no = jsonInfo.getString("out_refund_no"); |
| | | if (refund_status.equals("SUCCESS")) { |
| | | PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>() |
| | | .eq("code", code).eq("payType", 1)); |
| | | if (paymentCompetition.getPayStatus() == 2) { |
| | | paymentCompetition.setPayStatus(3); |
| | | paymentCompetition.setRefundTime(new Date()); |
| | | paymentCompetition.setRefundOrderNo(out_refund_no); |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | |
| | | Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); |
| | | competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); |
| | | cttService.updateById(competition); |
| | | storeClient.addBackRecord(paymentCompetition.getAmount() + "_" + paymentCompetition.getAppUserId()); |
| | | |
| | | } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.write("SUCCESS"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | |
| | | wrapper.ne(Competition::getAuditStatus,2); |
| | | } |
| | | wrapper.in(Competition::getStoreId,listQuery.getIds()); |
| | | wrapper.orderByDesc(Competition::getInsertTime); |
| | | wrapper.orderByDesc(Competition::getInsertTime) |
| | | .orderByDesc(Competition::getId); |
| | | Page<Competition> page = cttService.page(competitionPage, wrapper); |
| | | for (Competition record : page.getRecords()) { |
| | | // 查询当前赛事有多少人报名了 |
| | |
| | | integers.add(1); |
| | | integers.add(3); |
| | | wrapper.in(Competition::getAuditStatus, integers); |
| | | wrapper.orderByDesc(Competition::getInsertTime); |
| | | wrapper.orderByDesc(Competition::getInsertTime) |
| | | .orderByDesc(Competition::getId); |
| | | |
| | | Page<Competition> page = cttService.page(competitionPage, wrapper); |
| | | return page; |
| | |
| | | } else { |
| | | competition.setStatus(3); |
| | | } |
| | | |
| | | if(competition.getStatus() == 2){ |
| | | //添加勋章数据 |
| | | List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>() |
| | | .eq("competitionId", competition.getId()).eq("payStatus", 2).eq("state", 1)); |
| | | Set<Integer> collect = list.stream().map(PaymentCompetition::getAppUserId).collect(Collectors.toSet()); |
| | | for (Integer integer : collect) { |
| | | int count = paymentCompetitionService.count(new QueryWrapper<PaymentCompetition>() |
| | | .eq("appUserId", integer).eq("payStatus", 2).eq("state", 1)); |
| | | StudentHonor studentHonor = new StudentHonor(); |
| | | studentHonor.setAppUserId(integer); |
| | | studentHonor.setHonorType(2); |
| | | studentHonor.setNumber(count); |
| | | studentHonorClient.saveStudentHonor(studentHonor); |
| | | } |
| | | } |
| | | } |
| | | competition.setInsertTime(new Date()); |
| | | cttService.save(competition); |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新活动配置。 |
| | | * |
| | | * @param competition 管理端提交的活动信息 |
| | | */ |
| | | @PostMapping("/base/competition/update") |
| | | public void update(@RequestBody Competition competition) { |
| | | try { |
| | | if (competition.getStartTime().after(new Date())) { |
| | | competition.setStatus(1); |
| | | } |
| | | if (competition.getStartTime().before(new Date())) { |
| | | if (competition.getEndTime().after(new Date())) { |
| | | competition.setStatus(2); |
| | | } else { |
| | | competition.setStatus(3); |
| | | } |
| | | } |
| | | cttService.updateById(competition); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | public void update(@RequestBody Competition competition) throws BusinessException { |
| | | cttService.updateCompetition(competition); |
| | | } |
| | | |
| | | @Resource |
| | |
| | | String code = paymentCompetition.getCode(); |
| | | Double amount = paymentCompetition.getAmount(); |
| | | Competition competition = competitionService.getById(paymentCompetition.getCompetitionId()); |
| | | |
| | | |
| | | Store store = storeClient.queryStoreById(Integer.valueOf(competition.getStoreId().split(",")[0])); |
| | | String payOrderNo = paymentCompetition.getPayOrderNo(); |
| | | if (paymentCompetition.getPayType() == 1) {//微信支付 |
| | | Map<String, String> map = payMoneyUtil.wxRefund(payOrderNo, code, amount.toString(), amount.toString(), "/base/competition/weChatCancelPaymentCompetitionCallback"); |
| | | String return_code = map.get("return_code"); |
| | | if (!"SUCCESS".equals(return_code)) { |
| | | if (store.getOperatorId()!=null && store.getOperatorId()!=0){ |
| | | String smidVx= storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | if (!StringUtils.hasLength(smidVx)){ |
| | | System.err.println("运营商未配置微信商户号,获取支付失败!"); |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String codeRefund = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);// 退款单号 |
| | | // 运营商退款 |
| | | payMoneyUtil.weixinRefundV3(smidVx, codeRefund, pay.getPayOrderNo(), pay.getAmount().toString(), "/base/competition/weChatCancelPaymentCompetitionCallback1"); |
| | | }else { |
| | | Map<String, String> map = payMoneyUtil.wxRefund(payOrderNo, code, amount.toString(), amount.toString(), |
| | | "/base/competition/weChatCancelPaymentCompetitionCallback"); |
| | | String return_code = map.get("return_code"); |
| | | if (!"SUCCESS".equals(return_code)) { |
| | | // return ResultUtil.error(map.get("return_msg")); |
| | | continue; |
| | | continue; |
| | | } |
| | | String refund_id = map.get("refund_id"); |
| | | paymentCompetition.setRefundOrderNo(refund_id); |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | storeClient.addBackRecord(paymentCompetition.getAmount() + "_" + paymentCompetition.getAppUserId()); |
| | | } |
| | | String refund_id = map.get("refund_id"); |
| | | paymentCompetition.setRefundOrderNo(refund_id); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | storeClient.addBackRecord(paymentCompetition.getAmount() + "_" + paymentCompetition.getAppUserId()); |
| | | |
| | | } |
| | | if (paymentCompetition.getPayType() == 2) {//支付宝支付 |
| | | Map<String, String> map = payMoneyUtil.aliRefund(payOrderNo, amount.toString()); |
| | |
| | | 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.between(PaymentCompetition::getPayTime, stime, etime); |
| | | } |
| | | vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getCompetitionId, ids); |
| | | vipPaymentLambdaQueryWrapper.eq(PaymentCompetition::getPayStatus, 2); |
| | | vipPaymentLambdaQueryWrapper.eq(PaymentCompetition::getState, 1); |
| | | ArrayList<Integer> objects = new ArrayList<>(); |
| | | objects.add(1); |
| | | objects.add(2); |
| | |
| | | // 年 |
| | | ArrayList<Integer> years = new ArrayList<>(); |
| | | ArrayList<Integer> yearsUser = new ArrayList<>(); |
| | | Integer operatorId = vo.getOperatorId(); |
| | | List<Integer> operatorId1 = cttService.list(new QueryWrapper<Competition>().eq("operatorId", operatorId)) |
| | | .stream().map(Competition::getId).collect(Collectors.toList()); |
| | | for (Object o : collect) { |
| | | String s = o.toString(); |
| | | int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s).eq(Competition::getOperatorId, vo.getOperatorId())); |
| | | int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, vo.getIds()).like(UserCompetition::getInsertTime, s)); |
| | | List<Integer> competitionIds = listCompetitionIds(vo, s); |
| | | int count = competitionIds.size(); |
| | | int count1 = countUserCompetitions(vo, s, competitionIds); |
| | | years.add(count); |
| | | yearsUser.add(count1); |
| | | } |
| | |
| | | m = "0" + i; |
| | | } |
| | | String s = year + "-" + m; |
| | | int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s).eq(Competition::getOperatorId, operatorId)); |
| | | int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, vo.getIds()).like(UserCompetition::getInsertTime, s)); |
| | | List<Integer> competitionIds = listCompetitionIds(vo, s); |
| | | int count = competitionIds.size(); |
| | | int count1 = countUserCompetitions(vo, s, competitionIds); |
| | | months.add(count); |
| | | monthsUser.add(count1); |
| | | } |
| | |
| | | return map; |
| | | } |
| | | |
| | | /** 门店活动统计:仅统计指定门店的赛事及其报名记录。 */ |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/actStore") |
| | | public HashMap<String, Object> actStore(@RequestBody CompetionVO vo) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | if (vo.getStoreIds() == null || vo.getStoreIds().isEmpty()) { |
| | | vo.setStoreIds(Collections.singletonList(-1)); |
| | | } |
| | | ArrayList<Integer> years = new ArrayList<>(); |
| | | ArrayList<Integer> yearsUser = new ArrayList<>(); |
| | | int year = DateUtil.year(new Date()); |
| | | for (int statisticYear = year - 9; statisticYear <= year; statisticYear++) { |
| | | String dateText = String.valueOf(statisticYear); |
| | | List<Integer> competitionIds = listStoreCompetitionIds(vo, dateText); |
| | | years.add(competitionIds.size()); |
| | | yearsUser.add(countStoreUserCompetitions(dateText, competitionIds)); |
| | | } |
| | | map.put("yearData", years); |
| | | map.put("yearsUser", yearsUser); |
| | | |
| | | ArrayList<Integer> months = new ArrayList<>(); |
| | | ArrayList<Integer> monthsUser = new ArrayList<>(); |
| | | for (int month = 1; month <= 12; month++) { |
| | | String dateText = String.format("%d-%02d", year, month); |
| | | List<Integer> competitionIds = listStoreCompetitionIds(vo, dateText); |
| | | months.add(competitionIds.size()); |
| | | monthsUser.add(countStoreUserCompetitions(dateText, competitionIds)); |
| | | } |
| | | map.put("monthData", months); |
| | | map.put("monthsUser", monthsUser); |
| | | return map; |
| | | } |
| | | |
| | | private List<Integer> listCompetitionIds(CompetionVO vo, String dateText) { |
| | | return cttService.list(buildCompetitionCountWrapper(vo, dateText)) |
| | | .stream() |
| | | .map(Competition::getId) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private List<Integer> listStoreCompetitionIds(CompetionVO vo, String dateText) { |
| | | Set<String> storeIds = vo.getStoreIds().stream() |
| | | .filter(Objects::nonNull) |
| | | .map(String::valueOf) |
| | | .collect(Collectors.toSet()); |
| | | return cttService.list(new LambdaQueryWrapper<Competition>() |
| | | .like(Competition::getInsertTime, dateText)) |
| | | .stream() |
| | | .filter(competition -> containsStoreId(competition.getStoreId(), storeIds)) |
| | | .map(Competition::getId) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private boolean containsStoreId(String competitionStoreIds, Set<String> storeIds) { |
| | | if (competitionStoreIds == null || competitionStoreIds.trim().isEmpty()) { |
| | | return false; |
| | | } |
| | | return Arrays.stream(competitionStoreIds.split(",")) |
| | | .map(String::trim) |
| | | .anyMatch(storeIds::contains); |
| | | } |
| | | |
| | | private int countStoreUserCompetitions(String dateText, List<Integer> competitionIds) { |
| | | if (competitionIds.isEmpty()) { |
| | | return 0; |
| | | } |
| | | return ucttService.count(new LambdaQueryWrapper<UserCompetition>() |
| | | .in(UserCompetition::getCompetitionId, competitionIds) |
| | | .like(UserCompetition::getInsertTime, dateText)); |
| | | } |
| | | |
| | | private int countUserCompetitions(CompetionVO vo, String dateText, List<Integer> competitionIds) { |
| | | if (competitionIds.isEmpty()) { |
| | | return 0; |
| | | } |
| | | return ucttService.count(new LambdaQueryWrapper<UserCompetition>() |
| | | .in(UserCompetition::getAppUserId, vo.getIds()) |
| | | .in(UserCompetition::getCompetitionId, competitionIds) |
| | | .like(UserCompetition::getInsertTime, dateText)); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<Competition> buildCompetitionCountWrapper(CompetionVO vo, String dateText) { |
| | | LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<Competition>() |
| | | .like(Competition::getInsertTime, dateText); |
| | | // 平台统计由平台门店范围决定,历史平台赛事的 operatorId 可能为空或为 0。 |
| | | if (vo.getOperatorId() != null && !Integer.valueOf(0).equals(vo.getOperatorId())) { |
| | | wrapper.eq(Competition::getOperatorId, vo.getOperatorId()); |
| | | } |
| | | appendStoreIdFilter(wrapper, vo.getStoreIds()); |
| | | return wrapper; |
| | | } |
| | | |
| | | private void appendStoreIdFilter(LambdaQueryWrapper<Competition> wrapper, List<Integer> storeIds) { |
| | | if (storeIds == null || storeIds.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | List<Integer> validStoreIds = storeIds.stream() |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | if (validStoreIds.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | wrapper.and(item -> { |
| | | item.apply("FIND_IN_SET({0}, storeId)", validStoreIds.get(0)); |
| | | for (int i = 1; i < validStoreIds.size(); i++) { |
| | | item.or().apply("FIND_IN_SET({0}, storeId)", validStoreIds.get(i)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/queryAppUserId") |
| | | public List<Integer> queryAppUserId(@RequestBody List<Integer> storeIds){ |
| | | List<Competition> list = competitionService.list(new QueryWrapper<Competition>().in("storeId", storeIds).eq("auditStatus", 2).eq("state", 1)); |
| | | if (storeIds == null || storeIds.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<Competition>() |
| | | .eq(Competition::getAuditStatus, 2).eq(Competition::getState, 1); |
| | | appendStoreIdFilter(wrapper, storeIds); |
| | | List<Competition> list = competitionService.list(wrapper); |
| | | List<Integer> collect = list.stream().map(Competition::getId).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return new ArrayList<>(); |
| | |
| | | return list1.stream().map(PaymentCompetition::getAppUserId).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | |