竞猜足球核心算法源码

需要实现的功能如下:
在这里插入图片描述

  • 仅用于学习

竞猜足球核心算法源码

package com.lotterysource.portsadmin.service;
import com.aliyun.oss.common.utils.DateUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.lotterysource.portsadmin.dbprovider.PortsAdminRepository;
import com.lotterysource.portsadmin.entity.*;
import com.lotterysource.portsadmin.messaging.ApiResult;
import com.lotterysource.portsadmin.utils.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;/*** Created by Administrator on 2024/2/1.*/
@Service
public class PortsAdminService {@AutowiredPortsAdminRepository portsAdminRepository;@Value("${footBallKey:JCZQoEN3ua7MrW8lJOGY}")private String footBallKey;private static Logger logger = LoggerFactory.getLogger(PortsAdminService.class);@AutowiredRedisStringUtil redisStringUtil;@Value("${key}")private String key;private Long userId;private String fileUrl;public void deleteLottery(Long id,Long userId) {LotteryData lotteryData = portsAdminRepository.findLotteryDataBy(id);if(lotteryData!=null){if(!Objects.equals(lotteryData.getUserId(),userId)){throw new ServiceInvokeException(-1, "该条数据是参与报名数据,不是本人没有删除权限");}List ids = new ArrayList();ids.add(lotteryData.getId());List<LotteryOrder> lotteryOrderList = portsAdminRepository.findLotteryOrderList(ids);if(lotteryOrderList!=null && lotteryOrderList.size()>0){throw new ServiceInvokeException(-1, "该条数据有人参与报名,不能删除");}portsAdminRepository.deleteLottery(id);portsAdminRepository.deleteLotteryNumber(id);}}/*** 计算方法(彩票注数)** @param n    总球数量* @param k    选择多少球组合* @param l    蓝球* @param d    胆* @param t    拖* @param x    快乐选几(1-10)* @param type 类型* @return*/public Integer getAlgorithm(Integer n,Integer k,Integer l,Integer d,Integer t,Integer x,Integer g,Integer s,Integer b,String type) {int i = 0;if (type.equals("qlcFs")) {//七彩乐复式i = comBin(n, 7);} else if (type.equals("qlcDt")) {//七彩乐胆拖i = comBin(t, 7 - d);} else if (type.equals("ssqFs")) {//双色球复式i = comBin(n, 6) * l;} else if (type.equals("ssqDt")) {//双色球胆拖i = comBin(t, 6 - d) * comBin(l, 1);} else if (type.equals("kl8Fs")) {//快乐8复式i = comBin(n, x);} else if (type.equals("kl8Dt")) {//快乐8胆拖i = comBin(t, x - d);} else if (type.equals("fc3d")) {} else if (type.equals("fc3dZx")) {//自选i = comBin(g, 1) * comBin(s, 1) * comBin(b, 1);} else if (type.equals("fc3dZ3")) {int count = 0; // 计数器for (int i1 = 0; i1 < n; i1++) {for (int j = 0; j < n; j++) {if (i1 != j) { // 确保两个数字不同count++;}}}i = count;} else if (type.equals("fc3dZ6")) {i = comBin(n, 3);} else if (type.equals("fc3dJx")) {i = n;}return i;}/*** n(总个数)和k(选择几个数作为排列组合)** @param n* @param k* @return*/public static int comBin(int n, int k) {List<List<Integer>> result = new ArrayList<>();combineHelper(n, k, 1, new ArrayList<>(), result);return result.size();}private static void combineHelper(int n, int k, int start, List<Integer> combinationSoFar, List<List<Integer>> result) {if (k == 0) {result.add(new ArrayList<>(combinationSoFar));return;}for (int i = start; i <= n; i++) {combinationSoFar.add(i);combineHelper(n, k - 1, i + 1, combinationSoFar, result);combinationSoFar.remove(combinationSoFar.size() - 1);}}public static int fc3dZu3(List<Integer> numbers) {int count = 0; // 计数器for (int i = 0; i < numbers.size(); i++) {for (int j = 0; j < numbers.size(); j++) {if (i != j) { // 确保两个数字不同//System.out.println(numbers[i] * 100 + numbers[j] * 10 + numbers[i]);System.out.println(String.valueOf(numbers.get(i))+ String.valueOf(numbers.get(j))+ String.valueOf(numbers.get(i)));count++;}}}System.out.println("Total number of 3-digit numbers: " + count);return count;}public void saveLottery(Long userId, String type, String typeTwo, Integer typeKl, String ballDsStr, List<String> numberRedStr, List<String> numberBlueStr, List<String> numberDanStr, List<String> numberTuoStr, String number3dZx, int number) {//彩票注数int zs = getZs(type, typeTwo, typeKl, ballDsStr, numberRedStr, numberBlueStr, numberDanStr, numberTuoStr, number3dZx);List<LotteryBall> lotteryBallList = new ArrayList<>();if (ballDsStr != null && ballDsStr.length() > 0) {lotteryBallList = JsonUtil.deserialize(ballDsStr, new TypeReference<List<LotteryBall>>() {});}double money = zs * 2d;if ((money * number) > 20000) {throw new ServiceInvokeException("单张限额2万");}LotteryData lotteryData = new LotteryData();Date now = new Date();if (Objects.equals(type, "ssq")) {Date ssqOpenDate = DateUtils.getSsqOpenDate(now);lotteryData.setOpenDate(ssqOpenDate);} else if (Objects.equals(type, "qlc")) {Date qlcOpenDate = DateUtils.getQlcOpenDate(now);lotteryData.setOpenDate(qlcOpenDate);} else if (Objects.equals(type, "kl8")) {Date stopTime = new Date();stopTime.setHours(21);stopTime.setMinutes(30);stopTime.setSeconds(0);if (now.getTime() > stopTime.getTime()) {Date date = DateUtils.addDays(now, 1);lotteryData.setOpenDate(date);}} else if (Objects.equals(type, "fc3d")) {Date stopTime = new Date();stopTime.setHours(21);stopTime.setMinutes(15);stopTime.setSeconds(0);if (now.getTime() > stopTime.getTime()) {Date date = DateUtils.addDays(now, 1);lotteryData.setOpenDate(date);}}lotteryData.setMoney(money);lotteryData.setType(type);lotteryData.setTypeTwo(typeTwo);lotteryData.setTypeKl(typeKl);lotteryData.setUserId(userId);lotteryData.setNumber(number);portsAdminRepository.saveLotteryData(lotteryData);saveLotteryNumber(lotteryBallList, lotteryData, numberRedStr, numberBlueStr, numberDanStr, numberTuoStr, number3dZx);}public String getNumberString(List<String> numberStr) {String str = null;if (numberStr != null && numberStr.size() > 0) {str = numberStr.stream().collect(Collectors.joining(","));}return str;}public int getZs(String type, String typeTwo, Integer typeKl, String ballDsStr, List<String> numberRedStr, List<String> numberBlueStr, List<String> numberDanStr, List<String> numberTuoStr, String number3dZx) {//彩票注数int zs = 0;if (type.equals("fc3d")) {if (typeTwo.equals("Zx")) {//自选Fc3dZx fc3dZx = JsonUtil.deserialize(number3dZx, new TypeReference<Fc3dZx>() {});List<String> g = Arrays.asList(fc3dZx.getG().split(","));List<String> s = Arrays.asList(fc3dZx.getG().split(","));List<String> b = Arrays.asList(fc3dZx.getG().split(","));zs = comBin(g.size(), 1) * comBin(s.size(), 1) * comBin(b.size(), 1);} else if (typeTwo.equals("Z3")) {List<Integer> red = new ArrayList<>();for (String s : numberRedStr) {red.add(NumberUtil.parseInteger(s));}zs = fc3dZ3(red);} else if (typeTwo.equals("Z6")) {zs = comBin(numberRedStr.size(), 3);} else if (typeTwo.equals("Jx")) {//zs = 1;List<LotteryBall> lotteryBallList = JsonUtil.deserialize(ballDsStr, new TypeReference<List<LotteryBall>>() {});zs = lotteryBallList.size();}} else {zs = getZs(type, typeTwo, typeKl, ballDsStr, numberRedStr, numberBlueStr, numberDanStr, numberTuoStr);}return zs;}public Integer getZs(String type, String typeTwo, Integer typeKl, String ballDsStr, List<String> numberRedStr, List<String> numberBlueStr, List<String> numberDanStr, List<String> numberTuoStr) {int zs = 0;if ("Ds".equals(typeTwo)) {//单式if (ballDsStr == null || ballDsStr.length() == 0) {throw new ServiceInvokeException(-1, "单式玩法参数错误");}List<LotteryBall> lotteryBallList = JsonUtil.deserialize(ballDsStr, new TypeReference<List<LotteryBall>>() {});zs = lotteryBallList.size();} else {Integer n = null;if (numberRedStr != null && numberRedStr.size() > 0) {n = numberRedStr.size();}Integer k = null;Integer l = null;if (numberBlueStr != null && numberBlueStr.size() > 0) {l = numberBlueStr.size();}Integer d = null;if (numberDanStr != null && numberDanStr.size() > 0) {d = numberDanStr.size();}Integer t = null;if (numberTuoStr != null && numberTuoStr.size() > 0) {t = numberTuoStr.size();}Integer x = null;if (typeKl != null) {x = typeKl;}String typeNew = type + typeTwo;zs = getAlgorithm(n, k, l, d, t, x, null, null, null, typeNew);}if (zs == 0) {throw new ServiceInvokeException("数据有误");}return zs;}public int fc3dZ3(List<Integer> numbers) {int count = 0; // 计数器for (int i = 0; i < numbers.size(); i++) {for (int j = 0; j < numbers.size(); j++) {if (i != j) { // 确保两个数字不同
//                    System.out.println(String.valueOf(numbers.get(i))
//                            + String.valueOf(numbers.get(j))
//                            + String.valueOf(numbers.get(i)));count++;}}}System.out.println("Total number of 3-digit numbers: " + count);return count;}public void updateLottery(Long lotteryDataId, String type, String typeTwo, Integer typeKl, String ballDsStr, List<String> numberRedStr, List<String> numberBlueStr, List<String> numberDanStr, List<String> numberTuoStr, String number3dZx, int number) {LotteryData l = portsAdminRepository.findLotteryDataBy(lotteryDataId);//if (l != null && l.getQrCode() != null) {//    throw new ServiceInvokeException(-1, "该数据已生成分享二维码,暂不支持修改");//}List ids = new ArrayList();ids.add(l.getId());List<LotteryOrder> lotteryOrderList = portsAdminRepository.findLotteryOrderList(ids);if(lotteryOrderList!=null && lotteryOrderList.size()>0){throw new ServiceInvokeException(-1, "该条数据有人参与报名,不能编辑");}List<LotteryBall> lotteryBallList = new ArrayList<>();//彩票注数int zs = getZs(type, typeTwo, typeKl, ballDsStr, numberRedStr, numberBlueStr, numberDanStr, numberTuoStr, number3dZx);double money = zs * 2d;if (ballDsStr != null && ballDsStr.length() > 0) {lotteryBallList = JsonUtil.deserialize(ballDsStr, new TypeReference<List<LotteryBall>>() {});}if ((money * number) > 20000) {throw new ServiceInvokeException("单张限额2万");}LotteryData lotteryData = new LotteryData();lotteryData.setId(lotteryDataId);lotteryData.setMoney(money);lotteryData.setNumber(number);portsAdminRepository.updateLotteryData(lotteryData);portsAdminRepository.deleteLotteryNumber(lotteryDataId);saveLotteryNumber(lotteryBallList, lotteryData, numberRedStr, numberBlueStr, numberDanStr, numberTuoStr, number3dZx);}public void saveLotteryNumber(List<LotteryBall> lotteryBallList, LotteryData lotteryData, List<String> numberRedStr, List<String> numberBlueStr, List<String> numberDanStr, List<String> numberTuoStr, String number3dZx) {List<LotteryNumber> lotteryNumberList = new ArrayList<>();if (lotteryBallList.size() > 0) {for (LotteryBall lotteryBall : lotteryBallList) {LotteryNumber lotteryNumber = new LotteryNumber();lotteryNumber.setNumberRed(lotteryBall.getRed());lotteryNumber.setNumberBlue(lotteryBall.getBlue());lotteryNumber.setLotteryDataId(lotteryData.getId());lotteryNumberList.add(lotteryNumber);}} else {LotteryNumber lotteryNumber = new LotteryNumber();String red = getNumberString(numberRedStr);String blue = getNumberString(numberBlueStr);String dan = getNumberString(numberDanStr);String tuo = getNumberString(numberTuoStr);lotteryNumber.setNumberRed(red);lotteryNumber.setNumberBlue(blue);lotteryNumber.setNumberDan(dan);lotteryNumber.setNumberTuo(tuo);lotteryNumber.setLotteryDataId(lotteryData.getId());lotteryNumber.setNumberFczx(number3dZx);lotteryNumberList.add(lotteryNumber);}if (lotteryNumberList.size() > 0) {portsAdminRepository.saveLotteryNumberList(lotteryNumberList);}}public void updateNumber(Long lotteryDataId, Integer number) {LotteryData lotteryData = portsAdminRepository.findLotteryDataBy(lotteryDataId);List<Long> ids = new ArrayList<>();ids.add(lotteryData.getId());List<LotteryOrder> orderList = portsAdminRepository.findLotteryOrderList(ids);if (orderList != null && orderList.size()>0) {throw new ServiceInvokeException(-1, "该数据已有人报名参加,暂不支持修改");}if (lotteryData != null) {if (lotteryData.getMoney() * number > 20000) {throw new ServiceInvokeException(-1, "金额不能超过2万");}portsAdminRepository.updateLotteryData(lotteryDataId, number);} else {throw new ServiceInvokeException(-1, "数据有误");}}public List<LotteryData> findLotteryData(Long userId, String type) {List<LotteryData> lotteryDataList = portsAdminRepository.findLotteryDataList(userId, type);List<Long> ids = lotteryDataList.stream().map(c -> c.getId()).collect(Collectors.toList());List<LotteryNumber> lotteryNumberList = portsAdminRepository.findLotteryNumberBy(ids);for (LotteryData lotteryData : lotteryDataList) {List<LotteryNumber> lotteryNumbers = new ArrayList<>();for (LotteryNumber lotteryNumber : lotteryNumberList) {if (Objects.equals(lotteryData.getId(), lotteryNumber.getLotteryDataId())) {lotteryNumbers.add(lotteryNumber);}}lotteryData.setLotteryNumberList(lotteryNumbers);}return lotteryDataList;}public void saveLotteryImg(Long lotteryDataId, String fileUrl) {portsAdminRepository.updateLotteryDataImg(lotteryDataId, fileUrl);}public void saveUserImg(Long userId, String fileUrl) {portsAdminRepository.saveUserImg(userId, fileUrl);}public LotteryData findLotteryDataDetail(Long lotteryId) {LotteryData lotteryData = portsAdminRepository.findLotteryDataBy(lotteryId);List<Long> ids = new ArrayList<>();ids.add(lotteryData.getId());List<LotteryNumber> lotteryNumberList = portsAdminRepository.findLotteryNumberBy(ids);lotteryData.setLotteryNumberList(lotteryNumberList);List<LotteryOrder> lotteryOrderList = portsAdminRepository.findLotteryOrderList(ids);lotteryData.setLotteryOrderList(lotteryOrderList);return lotteryData;}public void saveLotteryOrder(Long lotteryId, Long userId) {LotteryOrder lotteryOrder = portsAdminRepository.findLotteryOrderBy(lotteryId, userId);if (lotteryOrder != null) {throw new ServiceInvokeException(-1, "已报名,请勿重复报名");}portsAdminRepository.saveLotteryOrder(lotteryId, userId, 1);}public void saveFootballData(FootballDataVO footballDataVO) {calculateCost(footballDataVO);portsAdminRepository.saveFootballData(footballDataVO);for (FootballOddVO footballOddVO : footballDataVO.getFootballOddVOList()) {if (footballOddVO.getSpfOdds() != null) {footballOddVO.setSpfOddsStr(JsonUtil.serialize(footballOddVO.getSpfOdds()));}if (footballOddVO.getRqOdds() != null) {footballOddVO.setRqOddsStr(JsonUtil.serialize(footballOddVO.getRqOdds()));}if (footballOddVO.getBfOdds() != null) {footballOddVO.setBfOddsStr(JsonUtil.serialize(footballOddVO.getBfOdds()));}if (footballOddVO.getJqOdds() != null) {footballOddVO.setJqOddsStr(JsonUtil.serialize(footballOddVO.getJqOdds()));}if (footballOddVO.getBqcOdds() != null) {footballOddVO.setBqcOddsStr(JsonUtil.serialize(footballOddVO.getBqcOdds()));}if (footballOddVO.getZhu() != null && footballOddVO.getZhu().size() > 0) {footballOddVO.setZhuStr(JsonUtil.serialize(footballOddVO.getZhu()));}if (footballOddVO.getKe() != null && footballOddVO.getKe().size() > 0) {footballOddVO.setKeStr(JsonUtil.serialize(footballOddVO.getKe()));}if (footballOddVO.getQc() != null && footballOddVO.getQc().size() > 0) {footballOddVO.setQcStr(JsonUtil.serialize(footballOddVO.getQc()));}if (footballOddVO.getBc() != null && footballOddVO.getBc().size() > 0) {footballOddVO.setBcStr(JsonUtil.serialize(footballOddVO.getBc()));}}portsAdminRepository.saveFootballOddVOList(footballDataVO.getId(), footballDataVO.getFootballOddVOList());}private boolean isNullSelect(FootballOddVO obj){if(obj.getSpfOdds()!=null){if(obj.getSpfOdds().oddList().size()>0){return true;}return false;}else  if(obj.getRqOdds()!=null){if(obj.getRqOdds().oddList().size()>0){return true;}return false;}else  if(obj.getBfOdds()!=null){if(obj.getBfOdds().bfOddList().size()>0){return true;}return false;}return true;}/*** 算多少注 最高中奖金额 和最低中奖金额** @param footballDataVO* @return*/public CostVO calculateCost(FootballDataVO footballDataVO) {CostVO costVO = new CostVO();double maxMoney = 0;double minMoney = 0;Integer zhu = 0;List<FootballOddVO> newfootballOddVOList = footballDataVO.getFootballOddVOList();List<FootballOddVO> footballOddVOList = new ArrayList<FootballOddVO>();for (FootballOddVO footballOddVO0:newfootballOddVOList){if(this.isNullSelect(footballOddVO0)){footballOddVOList.add(footballOddVO0);}}String strand =footballOddVOList.size()+""; //footballDataVO.getStrand();if (Objects.equals(footballDataVO.getCategory(), "jc") || Objects.equals(footballDataVO.getCategory(), "bjdc")|| Objects.equals(footballDataVO.getCategory(), "rx")|| Objects.equals(footballDataVO.getCategory(), "sf")) {//竞猜足球算法   b北京单场算法List<List<Double>> oddList = new ArrayList<>();//每一组最高的倍率单独存起来List<Double> maxOddList = new ArrayList<>();for (FootballOddVO footballOddVO : footballOddVOList) {if (Objects.equals(footballDataVO.getType(), "mix")) {//混合过关} else if (Objects.equals(footballDataVO.getType(), "spfRq")) {if (footballOddVO.getSpfOdds() != null) {List<Double> doubleList = footballOddVO.getSpfOdds().oddList();oddList.add(doubleList);maxOddList.add(Collections.max(doubleList));}if (footballOddVO.getRqOdds() != null) {List<Double> doubleList = footballOddVO.getRqOdds().oddList();oddList.add(doubleList);maxOddList.add(Collections.max(doubleList));}} else if (Objects.equals(footballDataVO.getType(), "spf")) {if (footballOddVO.getSpfOdds() != null) {List<Double> doubleList = footballOddVO.getSpfOdds().oddList();oddList.add(doubleList);maxOddList.add(Collections.max(doubleList));}} else if (Objects.equals(footballDataVO.getType(), "bf")) {if (footballOddVO.getBfOdds() != null) {List<Double> doubleList = footballOddVO.getBfOdds().bfOddList();oddList.add(doubleList);maxOddList.add(Collections.max(doubleList));}}}if (StringUtils.isBlank(strand)) {throw new ServiceInvokeException(-1, "过关方式参数错误");}List<String> split = Arrays.asList(strand.split(","));for (String s : split) {int x = Integer.parseInt(s);if (Objects.equals(1, x)) {//单关for (List<Double> d : oddList) {zhu += d.size();if (d.size() > 2) {Double min = Collections.min(d);Double max = Collections.max(d);maxMoney += max * 2;if (minMoney == 0) {minMoney = min * 2;} else {if (minMoney > (min * 2)) {minMoney = min;}}} else {Double max = Collections.max(d);maxMoney = max * 2;}}} else {List<List<Double>> combinations = CombinationUtil.getCombinations(oddList, x, 0, new ArrayList<>(), new boolean[oddList.size()]);// 打印所有组合combinations.forEach(combination -> System.out.println(combination));System.out.println("长度:{}" + combinations.size());zhu += combinations.size();CombinationUtil.Num num2 = CombinationUtil.getNum2(combinations, 0);double min = num2.getMin();if (minMoney == 0) {minMoney = min;} else if (minMoney > min) {minMoney = min;}List<List<Double>> result = new ArrayList<>();CombinationUtil.generate(maxOddList, 0, x, new ArrayList<Double>(), result);CombinationUtil.Num num = CombinationUtil.getNum2(result, x);maxMoney += num.getMax();}}} else if (Objects.equals(footballDataVO.getCategory(), "jq") || Objects.equals(footballDataVO.getCategory(), "bqc")) {int i = 1;for (FootballOddVO footballOddVO : footballOddVOList) {List<List<Integer>> lists = new ArrayList<>();if (Objects.equals(footballDataVO.getCategory(), "jq")) {//进球 主队 客队lists.add(footballOddVO.getZhu());lists.add(footballOddVO.getKe());} else if (Objects.equals(footballDataVO.getCategory(), "bqc")) {//半全场  半场 全场lists.add(footballOddVO.getQc());lists.add(footballOddVO.getBc());}List<List<Integer>> combinations = CombinationUtil.getCombinations(lists, 2, 0, new ArrayList<>(), new boolean[lists.size()]);int size = combinations.size();i *= size;}zhu = i;}if (Objects.equals(footballDataVO.getCategory(), "bjdc")) {maxMoney = maxMoney * 0.65;minMoney = minMoney * 0.65;}DecimalFormat df = new DecimalFormat("##.##");System.out.println("最小值:"+ min);System.out.println("最小值:"+ df.format(min));//if (maxMoney == 0) {footballDataVO.setMaxMoney(0.0);costVO.setMaxMoney(0.0);} else {footballDataVO.setMaxMoney(Math.round(maxMoney * 100) / 100.0);costVO.setMaxMoney(Math.round(maxMoney * 100) / 100.0);}if (minMoney == 0) {footballDataVO.setMinMoney(0.0);costVO.setMinMoney(0.0);} else {footballDataVO.setMinMoney(Math.round(minMoney * 100) / 100.0);costVO.setMinMoney(Math.round(minMoney * 100) / 100.0);}footballDataVO.setZhu(zhu);footballDataVO.setCostMoney(zhu * 2);costVO.setZhu(zhu);costVO.setCostMoney(zhu * 2);return costVO;}public CostVO calculateFootballData(FootballDataVO footballDataVO) {CostVO costVO = calculateCost(footballDataVO);return costVO;}public List<FootballDataVO> findFootballData(String type, Long userId, String category) {List<FootballDataVO> footballDataVOList = portsAdminRepository.findFootballDataList(type, userId, category, null);List<Long> fdIds = footballDataVOList.stream().map(c -> c.getId()).collect(Collectors.toList());List<FootballOddVOTwo> footballOddVOTwoList = portsAdminRepository.findFootballOddList(fdIds);fillData(footballDataVOList, footballOddVOTwoList);return footballDataVOList;}public void fillData(List<FootballDataVO> footballDataVOList, List<FootballOddVOTwo> footballOddVOTwoList) {List<Integer> matchIds = footballOddVOTwoList.stream().map(c -> c.getMatchId()).collect(Collectors.toList());List<FootballResult> footballResultList = portsAdminRepository.findFootballJcResultBy(matchIds);if (footballResultList != null) {for (FootballOddVOTwo footballOddVOTwo : footballOddVOTwoList) {for (FootballResult footballResult : footballResultList) {if (Objects.equals(footballOddVOTwo.getMatchId(), footballResult.getMatchId())) {footballOddVOTwo.setFullTimeScore(footballOddVOTwo.getFullTimeScore());break;}}}}for (FootballDataVO footballDataVO : footballDataVOList) {List<FootballOddVOTwo> footballOddVOTwos = new ArrayList<>();fillFootballOddVOTwo(footballOddVOTwos, footballDataVO, footballOddVOTwoList);footballDataVO.setFootballOddVOTwoList(footballOddVOTwos);}}public void fillFootballOddVOTwo(List<FootballOddVOTwo> footballOddVOTwos, FootballDataVO footballDataVO, List<FootballOddVOTwo> footballOddVOTwoList) {for (FootballOddVOTwo footballOddVOTwo : footballOddVOTwoList) {if (Objects.equals(footballDataVO.getId(), footballOddVOTwo.getFootBallDataId())) {if (StringUtils.isNotEmpty(footballOddVOTwo.getSpfOdds())) {footballOddVOTwo.setSpfOddList(JsonUtil.deserialize(footballOddVOTwo.getSpfOdds(), SpfOdd.class));}if (StringUtils.isNotEmpty(footballOddVOTwo.getRqOdds())) {footballOddVOTwo.setRqOddList(JsonUtil.deserialize(footballOddVOTwo.getRqOdds(), RqOdd.class));}if (StringUtils.isNotEmpty(footballOddVOTwo.getBfOdds())) {footballOddVOTwo.setBfOddList(JsonUtil.deserialize(footballOddVOTwo.getBfOdds(), BfOdd.class));}if (StringUtils.isNotEmpty(footballOddVOTwo.getJqOdds())) {footballOddVOTwo.setJqOddList(JsonUtil.deserialize(footballOddVOTwo.getJqOdds(), JqOdd.class));}if (StringUtils.isNotEmpty(footballOddVOTwo.getBqcOdds())) {footballOddVOTwo.setBqcOddList(JsonUtil.deserialize(footballOddVOTwo.getBqcOdds(), BqcOdd.class));}footballOddVOTwos.add(footballOddVOTwo);}}}public void saveFootballDataImg(Long footballDataId, String fileUrl) {portsAdminRepository.updateFootballQrCode(footballDataId, fileUrl);}public List<FootballFixture> findFootballFixtureBy(List<Integer> matchIds) {return portsAdminRepository.findFootballFixtureBy(matchIds);}public void saveFootballOrder(Long footballDataId, Long userId) {FootballOrder footballOrder = portsAdminRepository.findFootballOrderBy(footballDataId, userId);if (footballOrder != null) {throw new ServiceInvokeException(-1, "已报名,请勿重复报名");}portsAdminRepository.saveFootballOrder(footballDataId, userId, 1);}public List<FootballDataVO> findFootballDataByOrder(String type, Long userId, String category) {List<FootballOrder> footballOrderList = portsAdminRepository.findFootballOrderList(userId);List<Long> dataIds = footballOrderList.stream().map(c -> c.getFootballDataId()).collect(Collectors.toList());List<FootballDataVO> footballDataVOList = portsAdminRepository.findFootballDataList(type, null, category, dataIds);List<Long> fdIds = footballDataVOList.stream().map(c -> c.getId()).collect(Collectors.toList());List<FootballOddVOTwo> footballOddVOTwoList = portsAdminRepository.findFootballOddList(fdIds);fillData(footballDataVOList, footballOddVOTwoList);return footballDataVOList;}public FootballDataVO findFootballDetail(Long footballDataId) {FootballDataVO footballDataVO = portsAdminRepository.findFootballDataVOBy(footballDataId);List<Long> dataIds = new ArrayList<>();dataIds.add(footballDataVO.getId());List<FootballOddVOTwo> footballOddVOTwoList = portsAdminRepository.findFootballOddList(dataIds);List<FootballOddVOTwo> footballOddVOTwos = new ArrayList<>();fillFootballOddVOTwo(footballOddVOTwos, footballDataVO, footballOddVOTwoList);footballDataVO.setFootballOddVOTwoList(footballOddVOTwos);List<FootballOrder> footballOrderList = portsAdminRepository.findFootballOrderBy(footballDataId);footballDataVO.setFootballOrderList(footballOrderList);return footballDataVO;}public void deleteFootballData(List<Long> footballDataIds,Long userId) {for (Long footballDataId : footballDataIds) {FootballDataVO footballData = portsAdminRepository.findFootballDataVOBy(footballDataId);if(footballData!=null){if(!Objects.equals(footballData.getUserId(),userId)){throw new ServiceInvokeException(-1, "选择的数据是参与报名数据,不是本人没有删除权限");}List<FootballOrder> orderList = portsAdminRepository.findFootballOrderBy(footballDataId);if(orderList!=null && orderList.size()>0){throw new ServiceInvokeException(-1, "选择的数据有人参与报名,不能删除");}}}portsAdminRepository.deleteFootballData(footballDataIds);portsAdminRepository.deleteFootballOdd(footballDataIds);portsAdminRepository.deleteFootballOrder(footballDataIds);}public List<LotteryData> findLotteryDataBy(String openDate) {List<LotteryData> lotteryDataList = portsAdminRepository.findLotteryDataBy(openDate);return lotteryDataList;}public void updateBatchLotteryData(List<LotteryData> lotteryDataList) {portsAdminRepository.updateBatchLotteryData(lotteryDataList);}public List<LotteryData> findLotteryDataByOrder(Long userId) {List<LotteryOrder> lotteryOrderList = portsAdminRepository.findLotteryDataOrderList(userId);List<Long> dataIds = lotteryOrderList.stream().map(c -> c.getLotteryDataId()).collect(Collectors.toList());List<LotteryData> lotteryDataList = portsAdminRepository.findLotteryDataByIds(dataIds);List<Long> ids = lotteryDataList.stream().map(c -> c.getId()).collect(Collectors.toList());List<LotteryNumber> lotteryNumberList = portsAdminRepository.findLotteryNumberBy(ids);for (LotteryData lotteryData : lotteryDataList) {List<LotteryNumber> lotteryNumbers = new ArrayList<>();for (LotteryNumber lotteryNumber : lotteryNumberList) {if (Objects.equals(lotteryData.getId(), lotteryNumber.getLotteryDataId())) {lotteryNumbers.add(lotteryNumber);}}lotteryData.setLotteryNumberList(lotteryNumbers);}return lotteryDataList;}public void updateFootballDataNumber(Long footballDataId, Integer number) {FootballDataVO footballData = portsAdminRepository.findFootballDataVOBy(footballDataId);List<FootballOrder> orderList = portsAdminRepository.findFootballOrderBy(footballData.getId());if (orderList != null && orderList.size()>0) {throw new ServiceInvokeException(-1, "该数据已有人报名参加,暂不支持修改");}portsAdminRepository.updateFootballDataNumber(footballDataId, number);}public AppVersion findAppVersion(String version) {AppVersion appVersion = portsAdminRepository.findAppVersion(version);return appVersion;}}

全部源码地址:
https://github.com/yangyunhai/caipiao

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/411151.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

@ohos.systemParameterEnhance系统参数接口调用:控制设备硬件(执行shell命令方式)

本文介绍如何使用应用ohos.systemParameterEnhance (系统参数)(系统接口)来控制设备硬件&#xff0c;可以通过它在系统中执行一段shell命令&#xff0c;从而实现控制设备的效果。接下来以一个实际的样例来演示如何通过它来控制设备以太网接口 开源地址&#xff1a;https://git…

链表OJ题——环形链表2

文章目录 一、题目链接二、解题思路三、解题代码 一、题目链接 环形链表2 题目描述&#xff1a;在链表有环的基础上&#xff0c;找出环的入口点。 二、解题思路 三、解题代码

超实用的8个无版权、免费、高清图片素材网站整理

不管是设计、文章配图&#xff0c;还是视频制作&#xff0c;图片都至关重要。但是图片版权一直都是困扰很多设计、自媒体以及企业的大问题。现在&#xff0c;因为图片侵权被告的案例已经是司空见惯了&#xff0c;有的公众号甚至因为图片版权问题遭受致命打击。 1. Pexels Pexe…

(经验)SVN降版本,保留版本信息和用户信息。

背景&#xff1a;由于开始公司人数规模小&#xff0c;没有关心SVN最新版本免费对于用户数量限制要求不敏感&#xff0c;随着人数越来越多&#xff0c;公司来了新员工已经添加不了SVN需要注册码了&#xff0c;不利于SVN文件管理的在公司内部的推广。看了好多资料&#xff0c;都没…

信息学奥赛初赛天天练-75-NOIP2016普及组-完善程序-二分答案、二分查找、贪心算法、贪心策略

文章PDF链接: https://pan.baidu.com/s/1SVcGU_rApvoUWrUoviPCiA?pwdht2j 提取码: ht2j 复制这段内容后打开百度网盘手机App&#xff0c;操作更方便哦 1 完善程序 (单选题 &#xff0c;每小题3分&#xff0c;共30分) 郊游活动 有 n名同学参加学校组织的郊游活动&#xff0c…

有没有比较好用的在线翻译工具?实力推荐这4款。

当我们面对外文资料时&#xff0c;可能需要翻阅厚重的词典&#xff0c;耗费大量的时间和精力。在翻译这方面&#xff0c;很多人都十分依赖翻译工具的&#xff0c;因为这些工具只需几秒钟就能给出翻译结果&#xff0c;提高了我们的学习和工作的效率。但是随着翻译工具越来阅读&a…

前后端分离项目实战-通用管理系统搭建(前端Vue3+ElementPlus,后端Springboot+Mysql+Redis)第八篇:Tab标签页的实现

天行健&#xff0c;君子以自强不息&#xff1b;地势坤&#xff0c;君子以厚德载物。 每个人都有惰性&#xff0c;但不断学习是好好生活的根本&#xff0c;共勉&#xff01; 文章均为学习整理笔记&#xff0c;分享记录为主&#xff0c;如有错误请指正&#xff0c;共同学习进步。…

使用C++封装顺序表

作业&#xff1a;使用C手动封装一个顺序表&#xff0c;包含成员数组一个&#xff0c;成员变量N个 #include <iostream>using namespace std;using datatypeint; #define MAX 20struct SeqList { private: //私有datatype *data;int size0; …

【Java】数据类型与变量(二)

目录 3.变量 3.1什么是变量&#xff08;变量的概念&#xff09; 3.2语法格式 ​编辑​编辑3.3整型变量 3.3.1整型变量如何定义 ​编辑 3.3.2长整型变量 3.3.3短整型变量 3.3.4字节型变量 3.4浮点型变量 3.4.1双精度浮点型 3.4.2单精度浮点型 3.4.3单精度浮点型与双…

Google Search Console:完整教程

Google 提供了各种工具来收集和分析网站数据&#xff0c;其中最有价值的工具之一是 Google Search Console &#xff08;GSC&#xff09;。前身为 Google Webmaster Tools&#xff0c;它为 SEO 提供了对网站性能的宝贵见解。自 2015 年推出以来&#xff0c;该平台取得了长足的发…

关机软件项目规划

一、概述 1.1 编写目的 此项目开发规划书的编写主要是为《UPS SNMP卡网络监控系统》中配套使用的关机软件做主要的规划和整合&#xff0c;在开发过程中起到引导作用&#xff0c;以及给使用者提供简要的说明。 1.2 项目背景 关机软件是UPS网络监控适配器项目监控层的组成部分…

黑神化爆火,悟空的八十一难究竟用到了什么数据库?

九九八十一难&#xff0c;第一难。猿神&#xff0c;启动…然后发现先解压缩&#xff0c;后着色编译。就这姿势&#xff0c;这就是爆火的 《黑神话&#xff1a;悟空》单机游戏&#xff0c;哪怕是在工作日&#xff0c;大家仍纷纷涌入这个游戏世界。8月20日&#xff0c;万众瞩目的…

Excel表格合并后同步修改行号,删除重复项,按合并后的列进行排序

Excel合并单元格后每个合并后的行占据多列&#xff0c;如何进行排序 1、全选后选择合并选项中的取消合并单元格 2、选择删除重复项&#xff08;可以直接选定唯一行&#xff09; 3、可以发现合并后的每行占Excel的一行 4、然后制定排序规则 5、序号列下拉重排&#xff08;鼠标放…

智谱开源 CogVideoX-5B 视频生成模型,RTX 3060 显卡可运行;曝 OpenAI 模型「草莓」今秋推出

开发者朋友们大家好&#xff1a; 这里是 「RTE 开发者日报」 &#xff0c;每天和大家一起看新闻、聊八卦。我们的社区编辑团队会整理分享 RTE&#xff08;Real-Time Engagement&#xff09; 领域内「有话题的 新闻 」、「有态度的 观点 」、「有意思的 数据 」、「有思考的 文…

Android Studio Koala下载并安装,测试helloworld.

1、下载&#xff1a; 下载 Android Studio 和应用工具 - Android 开发者 | Android Developers 2、滚动条拉到近最后&#xff0c;各个系统的下载地址&#xff1a; 3、下载完成以后&#xff0c;我们双击运行安装&#xff1a; 如果有路径要修改&#xff0c;则修改下就可以了&a…

【大模型系列篇】预训练模型:BERT GPT

2018 年&#xff0c;Google 首次推出 BERT&#xff08;Bidirectional Encoder Representations from Transformers&#xff09;。该模型是在大量文本语料库上结合无监督和监督学习进行训练的。 BERT 的目标是创建一种语言模型&#xff0c;可以理解句子中单词的上下文和含义&…

新华三H3C HCL配置IS-IS基本配置

实验目标 完成本实验,应该能够达到以下目标。 ●掌握如何在路由器进行单区域IS-IS的基本配置 ●掌握如何在路由器上查看IS-IS路由表、邻居信息 ●掌握如何在路由器上查看IS-IS的LSDB信息 实验拓扑 IP地址表 实验任务 单区域配置&#xff1a; 在本实验任务中,需要在路由器上…

Dockerfile+私有仓库

使用Dockerfile创建应用镜像 在Docker file中定义所需要执⾏的指令&#xff0c;使⽤ docker build创建镜 像&#xff0c;过程中会按照dockerfile所定义的内容进⾏打开临时性容器&#xff0c;把docker file中命令全部执⾏完成&#xff0c;就得到了⼀个容器应⽤镜像&#xff0c;每…

排序算法刷题【leetcode88题目:合并两个有序数组、leetcode21:合并两个有序链表】

一、合并两个有序数组 题目比较简单&#xff0c;使用归并排序里面的同样的操作就可以&#xff0c;代码如下所示 #include <iostream> #include <vector> using namespace std;/* leetcode88题&#xff1a;合并两个有序数组 */ class Solution { public:void merge…

代码随想录训练营 Day41打卡 动态规划 part08 121. 买卖股票的最佳时机 122. 买卖股票的最佳时机II 123. 买卖股票的最佳时机III

代码随想录训练营 Day41打卡 动态规划 part08 一、力扣121. 买卖股票的最佳时机 给定一个数组 prices &#xff0c;它的第 i 个元素 prices[i] 表示一支给定股票第 i 天的价格。 你只能选择 某一天 买入这只股票&#xff0c;并选择在 未来的某一个不同的日子 卖出该股票。设计…