src/main/java/cc/mrbird/febs/common/enumerates/DataDictionaryEnum.java
@@ -7,6 +7,21 @@ public enum DataDictionaryEnum { /** * 彩球 */ COLOR_BALL("COLOR_BALL","COLOR_BALL"), /** * 蓝球 */ BLUE_BALL("BLUE_BALL","BLUE_BALL"), /** * 红球 */ RED_BALL("RED_BALL","RED_BALL"), /** * 本期开奖数字 */ OPEN_PRICE("OPEN_PRICE","OPEN_PRICE"), src/main/java/cc/mrbird/febs/mall/conversion/TzInfoConversion.java
@@ -5,6 +5,8 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; import java.util.List; @Mapper public abstract class TzInfoConversion { @@ -12,4 +14,6 @@ public static final TzInfoConversion INSTANCE = Mappers.getMapper(TzInfoConversion.class); public abstract ApiTzInfoVo entityToVo(TzInfo tzInfo); public abstract List<ApiTzInfoVo> entitysToVo(List<TzInfo> daXiaos); } src/main/java/cc/mrbird/febs/mall/dto/ApiCreateItemDto.java
@@ -1,5 +1,6 @@ package cc.mrbird.febs.mall.dto; import cc.mrbird.febs.mall.entity.TzInfo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -16,4 +17,7 @@ @ApiModelProperty(value = "投注金额") private BigDecimal tzAmount;//值 @ApiModelProperty(hidden = true) private TzInfo tzInfo; } src/main/java/cc/mrbird/febs/mall/entity/CjItem.java
@@ -15,7 +15,7 @@ private Long tzId;//投注信息ID private String tzCode;//投注号码 private BigDecimal tzPercent;//获奖倍率 private Integer type;//投注类型 1-按大小 2-按单双 3-按数字 private Integer type;//投注类型 1-按大小 2-按单双 3-按数字 4- 按红蓝 5-按彩球 6-六个号码为一组 7-三个号码为一组 private BigDecimal amount;//投入金额 private String itemNum;//投注数字 private String kjNum;//中奖号码 src/main/java/cc/mrbird/febs/mall/entity/TzInfo.java
@@ -11,7 +11,7 @@ @TableName("tz_info") public class TzInfo extends BaseEntity { private Integer type;//类型 1-按大小 2-按单双 3-按数字 private Integer type;//类型 1-按大小 2-按单双 3-按数字 4- 按红蓝 5-按彩球 6-六个号码为一组 7-三个号码为一组 private String tzCode;//值 private BigDecimal tzPercent;//获奖倍率 @TableField(exist = false) src/main/java/cc/mrbird/febs/mall/mapper/CjItemMapper.java
@@ -11,7 +11,7 @@ List<CjItem> selectListByInfoId(@Param("infoId")Long id); void updateBatchById(@Param("list")ArrayList<CjItem> cjItemUpdateList); void updateBatchById(@Param("list")List<CjItem> cjItemUpdateList); List<CjItem> selectSumAmountByInfoId(@Param("list")List<Long> collect); } src/main/java/cc/mrbird/febs/mall/service/AsyncCjService.java
@@ -10,10 +10,11 @@ public interface AsyncCjService extends IService<CjInfo> { @Async(FebsConstant.ASYNC_POOL) void openPriceAsync(CjInfo cjInfo, String kjNum,String danshuang,String daXiao); void openPriceAsync(CjInfo cjInfo, String kjNum,String danshuang,String daXiao ,String hong,String lan,String caiqiu,String liugehao,String sangehao); @Async(FebsConstant.ASYNC_POOL) void create(ApiCreateDto apiCreateDto); void create(ApiCreateDto apiCreateDto,Long memberId); @Async(FebsConstant.ASYNC_POOL) void tzInfo(); src/main/java/cc/mrbird/febs/mall/service/CJService.java
@@ -36,4 +36,11 @@ LinkedHashMap<String, JSON> getTzInfo(); /** * 处理红蓝彩球 * @param num * @return */ String getKjNo(String num); } src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
@@ -541,6 +541,7 @@ if(ObjectUtil.isEmpty(tzInfo1)){ return new FebsResponse().fail().message("设置失败"); } tzInfo1.setTzCode(tzInfo.getTzCode()); tzInfo1.setTzPercent(tzInfo.getTzPercent()); tzInfoMapper.updateById(tzInfo1); src/main/java/cc/mrbird/febs/mall/service/impl/AsyncCjServiceImpl.java
@@ -27,10 +27,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.*; import java.util.stream.Collectors; @Slf4j @@ -47,25 +44,23 @@ private final IApiMallMemberService mallMemberService; @Override public void openPriceAsync(CjInfo cjInfo, String kjNum,String danshuang,String daXiao) { public void openPriceAsync(CjInfo cjInfo, String kjNum,String danshuang,String daXiao ,String hong,String lan,String caiqiu,String liugehao,String sangehao) { long l = System.currentTimeMillis(); List<CjItem> cjItems = cjItemMapper.selectListByInfoId(cjInfo.getId()); if(CollUtil.isEmpty(cjItems)){ return; } /** * 1-按大小 2-按单双 3-按数字 */ BigDecimal perkAmountTotal = BigDecimal.ZERO;//中奖总金额 ArrayList<CjItem> CjItemUpdateList = new ArrayList<>(); List<CjItem> CjItemUpdateList = new ArrayList<>(); //按大小 List<CjItem> collectDaXiao = cjItems.stream().filter(cjItem -> cjItem.getType() == 1).collect(Collectors.toList()); if(CollUtil.isNotEmpty(collectDaXiao)){ for(CjItem cjItem : collectDaXiao){ String tzCode = cjItem.getTzCode(); cjItem.setKjNum(daXiao); cjItem.setKjNum(kjNum); BigDecimal perkAmount = BigDecimal.ZERO; if(daXiao.equals(tzCode)){ perkAmount = cjItem.getAmount().multiply(cjItem.getTzPercent()).setScale(2, BigDecimal.ROUND_DOWN); @@ -82,7 +77,7 @@ if(CollUtil.isNotEmpty(collectDanShuang)){ for(CjItem cjItem : collectDanShuang){ String tzCode = cjItem.getTzCode(); cjItem.setKjNum(danshuang); cjItem.setKjNum(kjNum); BigDecimal perkAmount = BigDecimal.ZERO; if(danshuang.equals(tzCode)){ perkAmount = cjItem.getAmount().multiply(cjItem.getTzPercent()).setScale(2, BigDecimal.ROUND_DOWN); @@ -111,6 +106,92 @@ perkAmountTotal = perkAmountTotal.add(perkAmount); } } //按红 List<CjItem> collectHong = cjItems.stream().filter(cjItem -> cjItem.getType() == 4).collect(Collectors.toList()); if(CollUtil.isNotEmpty(collectHong)){ for(CjItem cjItem : collectHong){ String tzCode = cjItem.getTzCode(); cjItem.setKjNum(kjNum); BigDecimal perkAmount = BigDecimal.ZERO; if(hong.equals(tzCode)){ perkAmount = cjItem.getAmount().multiply(cjItem.getTzPercent()).setScale(2, BigDecimal.ROUND_DOWN); cjItem.setPerkAmount(perkAmount); }else{ cjItem.setPerkAmount(perkAmount); } CjItemUpdateList.add(cjItem); perkAmountTotal = perkAmountTotal.add(perkAmount); } } //按蓝 List<CjItem> collectLan = cjItems.stream().filter(cjItem -> cjItem.getType() == 8).collect(Collectors.toList()); if(CollUtil.isNotEmpty(collectLan)){ for(CjItem cjItem : collectLan){ String tzCode = cjItem.getTzCode(); cjItem.setKjNum(kjNum); BigDecimal perkAmount = BigDecimal.ZERO; if(lan.equals(tzCode)){ perkAmount = cjItem.getAmount().multiply(cjItem.getTzPercent()).setScale(2, BigDecimal.ROUND_DOWN); cjItem.setPerkAmount(perkAmount); }else{ cjItem.setPerkAmount(perkAmount); } CjItemUpdateList.add(cjItem); perkAmountTotal = perkAmountTotal.add(perkAmount); } } //按彩球 List<CjItem> collectCaiQiu = cjItems.stream().filter(cjItem -> cjItem.getType() == 5).collect(Collectors.toList()); if(CollUtil.isNotEmpty(collectCaiQiu)){ for(CjItem cjItem : collectCaiQiu){ String tzCode = cjItem.getTzCode(); cjItem.setKjNum(kjNum); BigDecimal perkAmount = BigDecimal.ZERO; if(caiqiu.equals(tzCode)){ perkAmount = cjItem.getAmount().multiply(cjItem.getTzPercent()).setScale(2, BigDecimal.ROUND_DOWN); cjItem.setPerkAmount(perkAmount); }else{ cjItem.setPerkAmount(perkAmount); } CjItemUpdateList.add(cjItem); perkAmountTotal = perkAmountTotal.add(perkAmount); } } //六个号码为一组 List<CjItem> collectLiuGeHao = cjItems.stream().filter(cjItem -> cjItem.getType() == 6).collect(Collectors.toList()); if(CollUtil.isNotEmpty(collectLiuGeHao)){ for(CjItem cjItem : collectLiuGeHao){ String tzCode = cjItem.getTzCode(); cjItem.setKjNum(kjNum); BigDecimal perkAmount = BigDecimal.ZERO; if(liugehao.equals(tzCode)){ perkAmount = cjItem.getAmount().multiply(cjItem.getTzPercent()).setScale(2, BigDecimal.ROUND_DOWN); cjItem.setPerkAmount(perkAmount); }else{ cjItem.setPerkAmount(perkAmount); } CjItemUpdateList.add(cjItem); perkAmountTotal = perkAmountTotal.add(perkAmount); } } //三个号码为一组 List<CjItem> collectSanGeHao = cjItems.stream().filter(cjItem -> cjItem.getType() == 7).collect(Collectors.toList()); if(CollUtil.isNotEmpty(collectSanGeHao)){ for(CjItem cjItem : collectSanGeHao){ String tzCode = cjItem.getTzCode(); cjItem.setKjNum(kjNum); BigDecimal perkAmount = BigDecimal.ZERO; if(sangehao.equals(tzCode)){ perkAmount = cjItem.getAmount().multiply(cjItem.getTzPercent()).setScale(2, BigDecimal.ROUND_DOWN); cjItem.setPerkAmount(perkAmount); }else{ cjItem.setPerkAmount(perkAmount); } CjItemUpdateList.add(cjItem); perkAmountTotal = perkAmountTotal.add(perkAmount); } } cjItemMapper.updateBatchById(CjItemUpdateList);//批量更新 if(perkAmountTotal.compareTo(BigDecimal.ZERO) > 0){ @@ -143,9 +224,8 @@ } @Override public void create(ApiCreateDto apiCreateDto) { public void create(ApiCreateDto apiCreateDto,Long memberId) { long l = System.currentTimeMillis(); Long memberId = 1L; //开启下注 DataDictionaryCustom noTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( DataDictionaryEnum.NO_TIME.getType(), @@ -166,6 +246,12 @@ if(BigDecimal.ZERO.compareTo(tzAmount) >= 0){ throw new FebsException("金额必须大于0"); } Long id = apiCreateItemDto.getId();//投注ID TzInfo tzInfo = tzInfoMapper.selectById(id); if(ObjectUtil.isEmpty(tzInfo)){ throw new FebsException("参数有误,请刷新页面"); } apiCreateItemDto.setTzInfo(tzInfo); totalAmount = totalAmount.add(tzAmount); } if(mallMemberWallet.getBalance().compareTo(totalAmount) < 0){ @@ -187,7 +273,7 @@ for(ApiCreateItemDto apiCreateItemDto : items){ Long id = apiCreateItemDto.getId();//投注ID TzInfo tzInfo = tzInfoMapper.selectById(id); TzInfo tzInfo = apiCreateItemDto.getTzInfo(); if(ObjectUtil.isEmpty(tzInfo)){ throw new FebsException("参数有误,请刷新页面"); } @@ -224,41 +310,31 @@ public void tzInfo() { Map<String, JSON> linkedHashMap = new LinkedHashMap<>(); ArrayList<ApiTzInfoVo> objectDaxiao = new ArrayList<>(); QueryWrapper<TzInfo> daxiaoQueryWrapper = new QueryWrapper<>(); daxiaoQueryWrapper.eq("type",1); List<TzInfo> daXiaos = tzInfoMapper.selectList(daxiaoQueryWrapper); if(CollUtil.isNotEmpty(daXiaos)){ for(TzInfo tzInfoRedis : daXiaos){ ApiTzInfoVo apiTzInfoVo = TzInfoConversion.INSTANCE.entityToVo(tzInfoRedis); objectDaxiao.add(apiTzInfoVo); } } linkedHashMap.put("daXiao", JSONUtil.parse(objectDaxiao)); ArrayList<ApiTzInfoVo> objectDanshuang = new ArrayList<>(); QueryWrapper<TzInfo> danshuangQueryWrapper = new QueryWrapper<>(); danshuangQueryWrapper.eq("type",2); List<TzInfo> danShuangs = tzInfoMapper.selectList(danshuangQueryWrapper); if(CollUtil.isNotEmpty(danShuangs)){ for(TzInfo tzInfoRedis : danShuangs){ ApiTzInfoVo apiTzInfoVo = TzInfoConversion.INSTANCE.entityToVo(tzInfoRedis); objectDanshuang.add(apiTzInfoVo); } } linkedHashMap.put("danShuang",JSONUtil.parse(objectDanshuang)); ArrayList<ApiTzInfoVo> objectShuZi = new ArrayList<>(); QueryWrapper<TzInfo> shuZiQueryWrapper = new QueryWrapper<>(); shuZiQueryWrapper.eq("type",3); List<TzInfo> shuZis = tzInfoMapper.selectList(shuZiQueryWrapper); if(CollUtil.isNotEmpty(shuZis)){ for(TzInfo tzInfoRedis : shuZis){ ApiTzInfoVo apiTzInfoVo = TzInfoConversion.INSTANCE.entityToVo(tzInfoRedis); objectShuZi.add(apiTzInfoVo); } } linkedHashMap.put("shuZi",JSONUtil.parse(objectShuZi)); List<TzInfo> tzInfos = tzInfoMapper.selectList(null); linkedHashMap.put("daXiao", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 1).collect(Collectors.toList())))); linkedHashMap.put("danShuang", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 2).collect(Collectors.toList())))); linkedHashMap.put("shuZi", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 3).collect(Collectors.toList())))); linkedHashMap.put("hong", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 4).collect(Collectors.toList())))); linkedHashMap.put("caiqiu", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 5).collect(Collectors.toList())))); linkedHashMap.put("liuHao", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 6).collect(Collectors.toList())))); linkedHashMap.put("sanHao", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 7).collect(Collectors.toList())))); linkedHashMap.put("lan", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 8).collect(Collectors.toList())))); //投注信息 String tzInfoNoExit = redisUtils.getString(AppContants.TZ_INFO); src/main/java/cc/mrbird/febs/mall/service/impl/CJServiceImpl.java
@@ -42,10 +42,8 @@ import java.text.ParseException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.*; import java.util.stream.Collectors; @Slf4j @Service @@ -67,6 +65,12 @@ public FebsResponse kjRecord(KjRecordDto kjRecordDto) { IPage<ApiKjRecordVo> page = new Page<>(kjRecordDto.getPageNum(), kjRecordDto.getPageSize()); IPage<ApiKjRecordVo> pages = kjRecordMapper.selectListInPage(page, kjRecordDto); List<ApiKjRecordVo> records = pages.getRecords(); if(CollUtil.isNotEmpty(records)){ for(ApiKjRecordVo apiKjRecordVo : records){ apiKjRecordVo.setKjNum(this.getKjNo(apiKjRecordVo.getKjNum())); } } return new FebsResponse().success().data(pages); } @@ -95,51 +99,28 @@ agentProducer.sendNoTimeDelayMsg(kjNo, (AppContants.KJ_RECORD_TIME_INTERVAL-1) * 60 * 1000L);//提一分钟停止下注 //todo 测试下注 // ApiCreateDto apiCreateDto = new ApiCreateDto(); // List<ApiCreateItemDto> items = new ArrayList<>(); // ApiCreateItemDto apiCreateItemDto = new ApiCreateItemDto(); // apiCreateItemDto.setId(1L); // apiCreateItemDto.setTzAmount(new BigDecimal("10")); // items.add(apiCreateItemDto); // // ApiCreateItemDto apiCreateItemDto2 = new ApiCreateItemDto(); // apiCreateItemDto2.setId(2L); // apiCreateItemDto2.setTzAmount(new BigDecimal("10")); // items.add(apiCreateItemDto2); // // ApiCreateItemDto apiCreateItemDto3 = new ApiCreateItemDto(); // apiCreateItemDto3.setId(3L); // apiCreateItemDto3.setTzAmount(new BigDecimal("10")); // items.add(apiCreateItemDto3); // // ApiCreateItemDto apiCreateItemDto4 = new ApiCreateItemDto(); // apiCreateItemDto4.setId(4L); // apiCreateItemDto4.setTzAmount(new BigDecimal("10")); // items.add(apiCreateItemDto4); // // ApiCreateItemDto apiCreateItemDto5 = new ApiCreateItemDto(); // int randomInt = RandomUtil.randomInt(1, 25); // apiCreateItemDto5.setId(Long.parseLong(String.valueOf(randomInt))); // apiCreateItemDto5.setTzAmount(new BigDecimal("10")); // items.add(apiCreateItemDto5); // apiCreateDto.setItems(items); // // for(int i = 0;i<=100;i++){ // asyncCjService.create(apiCreateDto); // } ApiCreateDto apiCreateDto = new ApiCreateDto(); List<ApiCreateItemDto> items = new ArrayList<>(); for(int i = 1;i<= 43;i++){ ApiCreateItemDto apiCreateItemDto6 = new ApiCreateItemDto(); apiCreateItemDto6.setId(Long.parseLong(String.valueOf(i))); apiCreateItemDto6.setTzAmount(new BigDecimal("10")); items.add(apiCreateItemDto6); } apiCreateDto.setItems(items); asyncCjService.create(apiCreateDto,1L); } @Override public FebsResponse kjInfo() { ApiKjInfoVo apiKjInfoVo = new ApiKjInfoVo(); String kjNoOld = redisUtils.getString(AppContants.KJ_RECORD_NO_OLD); String kjNumOld = redisUtils.getString(AppContants.KJ_RECORD_NUM_OLD); String kjNumOld = this.getKjNo(redisUtils.getString(AppContants.KJ_RECORD_NUM_OLD)); if(StrUtil.isBlank(kjNoOld)){ KjRecord kjRecordOld = kjRecordMapper.selectOneByLimitZero(1,1); if(ObjectUtil.isNotEmpty(kjRecordOld)){ apiKjInfoVo.setKjNoOld(kjRecordOld.getKjNo()); apiKjInfoVo.setKjNumOld(kjRecordOld.getKjNum()); apiKjInfoVo.setKjNumOld(this.getKjNo(kjRecordOld.getKjNum())); } }else{ apiKjInfoVo.setKjNoOld(kjNoOld); @@ -195,7 +176,7 @@ DataDictionaryEnum.OPEN_PRICE.getType(), DataDictionaryEnum.OPEN_PRICE.getCode() ); int randomInt = RandomUtil.randomInt(1, 25); int randomInt = RandomUtil.randomInt(1, 27); if(StrUtil.isNotEmpty(openPriceDic.getValue())){ randomInt = Integer.parseInt(openPriceDic.getValue()); openPriceDic.setValue(""); @@ -259,6 +240,12 @@ if(BigDecimal.ZERO.compareTo(tzAmount) >= 0){ throw new FebsException("金额必须大于0"); } Long id = apiCreateItemDto.getId();//投注ID TzInfo tzInfo = tzInfoMapper.selectById(id); if(ObjectUtil.isEmpty(tzInfo)){ throw new FebsException("参数有误,请刷新页面"); } apiCreateItemDto.setTzInfo(tzInfo); totalAmount = totalAmount.add(tzAmount); } if(mallMemberWallet.getBalance().compareTo(totalAmount) < 0){ @@ -280,10 +267,7 @@ for(ApiCreateItemDto apiCreateItemDto : items){ Long id = apiCreateItemDto.getId();//投注ID TzInfo tzInfo = tzInfoMapper.selectById(id); if(ObjectUtil.isEmpty(tzInfo)){ throw new FebsException("参数有误,请刷新页面"); } TzInfo tzInfo = apiCreateItemDto.getTzInfo(); BigDecimal tzAmount = apiCreateItemDto.getTzAmount().setScale(2,BigDecimal.ROUND_DOWN);//投注金额 CjItem cjItem = new CjItem(); cjItem.setInfoId(cjInfo.getId()); @@ -323,7 +307,13 @@ if(CollUtil.isNotEmpty(records)){ for(CjInfo item : records){ Long id = item.getId(); item.setKjNum(this.getKjNo(item.getKjNum())); List<CjItem> cjItems = cjItemMapper.selectListByInfoId(id); if(CollUtil.isNotEmpty(cjItems)){ for(CjItem cjItem : cjItems){ cjItem.setKjNum(this.getKjNo(cjItem.getKjNum())); } } item.setItems(cjItems); } } @@ -351,51 +341,59 @@ } String danshuang = judgeNumberOne(Integer.parseInt(kjNum)); String daXiao = judgeNumberTwo(Integer.parseInt(kjNum)); DataDictionaryCustom redBallDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( DataDictionaryEnum.RED_BALL.getType(), DataDictionaryEnum.RED_BALL.getCode() ); String hong = judgeNumberHong(kjNum, redBallDic); DataDictionaryCustom blueBallDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( DataDictionaryEnum.BLUE_BALL.getType(), DataDictionaryEnum.BLUE_BALL.getCode() ); String lan = judgeNumberLan(kjNum, blueBallDic); DataDictionaryCustom colorBallDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( DataDictionaryEnum.COLOR_BALL.getType(), DataDictionaryEnum.COLOR_BALL.getCode() ); String caiqiu = judgeNumberColor(kjNum, colorBallDic); String liugehao = getGroupNumberSix(Integer.parseInt(kjNum)); String sangehao = getGroupNumberThree(Integer.parseInt(kjNum)); for(CjInfo cjInfo : cjInfos){ asyncCjService.openPriceAsync(cjInfo,kjNum,danshuang,daXiao); asyncCjService.openPriceAsync(cjInfo,kjNum,danshuang,daXiao,hong,lan,caiqiu,liugehao,sangehao); } } @Override public LinkedHashMap<String, JSON> getTzInfo() { LinkedHashMap<String, JSON> linkedHashMap = new LinkedHashMap<>(); ArrayList<ApiTzInfoVo> objectDaxiao = new ArrayList<>(); QueryWrapper<TzInfo> daxiaoQueryWrapper = new QueryWrapper<>(); daxiaoQueryWrapper.eq("type",1); List<TzInfo> daXiaos = tzInfoMapper.selectList(daxiaoQueryWrapper); if(CollUtil.isNotEmpty(daXiaos)){ for(TzInfo tzInfoRedis : daXiaos){ ApiTzInfoVo apiTzInfoVo = TzInfoConversion.INSTANCE.entityToVo(tzInfoRedis); objectDaxiao.add(apiTzInfoVo); } } linkedHashMap.put("daXiao", JSONUtil.parse(objectDaxiao)); ArrayList<ApiTzInfoVo> objectDanshuang = new ArrayList<>(); QueryWrapper<TzInfo> danshuangQueryWrapper = new QueryWrapper<>(); danshuangQueryWrapper.eq("type",2); List<TzInfo> danShuangs = tzInfoMapper.selectList(danshuangQueryWrapper); if(CollUtil.isNotEmpty(danShuangs)){ for(TzInfo tzInfoRedis : danShuangs){ ApiTzInfoVo apiTzInfoVo = TzInfoConversion.INSTANCE.entityToVo(tzInfoRedis); objectDanshuang.add(apiTzInfoVo); } } linkedHashMap.put("danShuang",JSONUtil.parse(objectDanshuang)); ArrayList<ApiTzInfoVo> objectShuZi = new ArrayList<>(); QueryWrapper<TzInfo> shuZiQueryWrapper = new QueryWrapper<>(); shuZiQueryWrapper.eq("type",3); List<TzInfo> shuZis = tzInfoMapper.selectList(shuZiQueryWrapper); if(CollUtil.isNotEmpty(shuZis)){ for(TzInfo tzInfoRedis : shuZis){ ApiTzInfoVo apiTzInfoVo = TzInfoConversion.INSTANCE.entityToVo(tzInfoRedis); objectShuZi.add(apiTzInfoVo); } } linkedHashMap.put("shuZi",JSONUtil.parse(objectShuZi)); List<TzInfo> tzInfos = tzInfoMapper.selectList(null); linkedHashMap.put("daXiao", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 1).collect(Collectors.toList())))); linkedHashMap.put("danShuang", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 2).collect(Collectors.toList())))); linkedHashMap.put("shuZi", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 3).collect(Collectors.toList())))); linkedHashMap.put("hong", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 4).collect(Collectors.toList())))); linkedHashMap.put("caiqiu", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 5).collect(Collectors.toList())))); linkedHashMap.put("liuHao", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 6).collect(Collectors.toList())))); linkedHashMap.put("sanHao", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 7).collect(Collectors.toList())))); linkedHashMap.put("lan", JSONUtil.parse( TzInfoConversion.INSTANCE.entitysToVo( tzInfos.stream().filter(tzInfo -> tzInfo.getType() == 8).collect(Collectors.toList())))); //投注信息 String tzInfoNoExit = redisUtils.getString(AppContants.TZ_INFO); if (StrUtil.isNotBlank(tzInfoNoExit)) { @@ -406,12 +404,35 @@ return linkedHashMap; } @Override public String getKjNo(String num) { DataDictionaryCustom redBallDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( DataDictionaryEnum.RED_BALL.getType(), DataDictionaryEnum.RED_BALL.getCode() ); DataDictionaryCustom blueBallDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( DataDictionaryEnum.BLUE_BALL.getType(), DataDictionaryEnum.BLUE_BALL.getCode() ); if(redBallDic.getValue().equals(num)){ return "红"; } if(blueBallDic.getValue().equals(num)){ return "蓝"; } return num; } /** * 取模运算符%来判断该数字是否为偶数。如果余数为0,则该数字为偶数,返回"双数";否则,该数字为奇数,返回"单数" * @param num * @return 1-单数 2-双数 */ public static String judgeNumberOne(int num) { if(num > 24){ return String.valueOf(num); } if (num % 2 == 0) { return "双"; } else { @@ -425,11 +446,137 @@ * @return 1-小数 2-大数 */ public static String judgeNumberTwo(int num) { if (num <= 12) { return "小"; } else { return "大"; if(num > 24){ return String.valueOf(num); } if (num <= 12) { return "龙1-12"; } else { return "虎13-24"; } } /** * 红 * @param num */ public static String judgeNumberHong(String num,DataDictionaryCustom redBallDic) { String redBall = redBallDic.getValue(); if (redBall.equals(num)) { return "红球"; } else { return num; } } /** * 蓝 * @param num */ public static String judgeNumberLan(String num,DataDictionaryCustom blueBallDic) { String blueBall = blueBallDic.getValue(); if (blueBall.equals(num)) { return "蓝球"; } else { return num; } } /** * 彩球 * @param num */ public static String judgeNumberColor(String num,DataDictionaryCustom colorBallDic) { String colorBall = colorBallDic.getValue(); List<String> colorBallList = Arrays.asList(StrUtil.split(colorBall, ",")); if (colorBallList.contains(num)) { return "彩球"; } else { return num; } } /** * 六个号 * 判断数字属于哪一组并返回组号 * @param number 1-24之间的数字 * @return 组号(1, 2, 3, 4) */ /** * 判断一个数字属于哪个组并返回组号 * * @param num 输入的数字(1-24之间) * @return 组号(1-4之间) */ public static String getGroupNumberSix(int num) { if(num > 24){ return String.valueOf(num); } // 使用整除来确定组号 int i = (num - 1) / 6 + 1; if(1 == i){ return "1-6"; }else if(2 == i){ return "7-12"; }else if(3 == i){ return "13-18"; }else{ return "19-24"; } } /** * 六个号 * 判断数字属于哪一组并返回组号 * @param number 1-24之间的数字 * @return 组号(1, 2, 3, 4) */ /** * 判断一个数字属于哪个组并返回组号 * * @param num 输入的数字(1-24之间) * @return 组号(1-4之间) */ public static String getGroupNumberThree(int num) { if(num > 24){ return String.valueOf(num); } // 使用整除来确定组号 int i = (num - 1) / 3 + 1; if(1 == i){ return "1-3"; }else if(2 == i){ return "4-6"; }else if(3 == i){ return "7-9"; }else if(4 == i){ return "10-12"; }else if(5 == i){ return "13-15"; }else if(6 == i){ return "16-18"; }else if(7 == i){ return "19-21"; }else{ return "22-24"; } } public static void main(String[] args) { ArrayList<Integer> CjItemUpdateList = new ArrayList<>(); for(int i =1 ;i<=10000;i++){ CjItemUpdateList.add(i); } int listSize= CjItemUpdateList.size(); int toIndex = 500; for(int i = 0; i<CjItemUpdateList.size(); i+=toIndex){ if(i + toIndex > listSize){ //作用为toIndex最后没有1000条数据则剩余几条newList中就装几条 toIndex = listSize - i; } List<Integer> newList = new ArrayList<>(CjItemUpdateList.subList(i, i + toIndex)); System.out.println(newList.toString()); } } } src/main/java/cc/mrbird/febs/mall/vo/ApiTzInfoVo.java
@@ -14,8 +14,8 @@ @ApiModelProperty(value = "ID") private Long id;//类型 1-按大小 2-按单双 3-按数字 @ApiModelProperty(value = "类型 1-按大小 2-按单双 3-按数字") private Integer type;//类型 1-按大小 2-按单双 3-按数字 @ApiModelProperty(value = "类型 1-按大小 2-按单双 3-按数字 4- 按红蓝 5-按彩球 6-六个号码为一组 7-三个号码为一组") private Integer type;//类型 1-按大小 2-按单双 3-按数字 4- 按红蓝 5-按彩球 6-六个号码为一组 7-三个号码为一组 @ApiModelProperty(value = "值") private String tzCode;//值 src/main/resources/templates/febs/views/modules/goods/tzList.html
@@ -47,8 +47,20 @@ <span class="layui-badge febs-tag-green">大小</span> {{# } else if (d.type == 2) { }} <span class="layui-badge febs-tag-cyan">单双</span> {{# } else if (d.type == 3) { }} <span class="layui-badge febs-tag-blue">数字</span> {{# } else if (d.type == 4) { }} <span class="layui-badge febs-tag-red">红</span> {{# } else if (d.type == 5) { }} <span class="layui-badge febs-tag-yellow">彩</span> {{# } else if (d.type == 6) { }} <span class="layui-badge febs-tag-cyan">六个号码</span> {{# } else if (d.type == 7) { }} <span class="layui-badge febs-tag-green">三个号码</span> {{# } else if (d.type == 8) { }} <span class="layui-badge febs-tag-green">蓝</span> {{# } else { }} <span class="layui-badge febs-tag-orange">数字</span> <span class="layui-badge febs-tag-orange">-</span> {{# } }} </div> </script> src/test/java/cc/mrbird/febs/AgentTest.java
@@ -1,7 +1,17 @@ package cc.mrbird.febs; import cc.mrbird.febs.common.enumerates.AgentLevelEnum; import cc.mrbird.febs.mall.entity.AgentInfo; import cc.mrbird.febs.mall.entity.DataDictionaryCustom; import cc.mrbird.febs.mall.entity.TzInfo; import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; import cc.mrbird.febs.mall.mapper.TzInfoMapper; import lombok.extern.slf4j.Slf4j; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.math.BigDecimal; /** @@ -12,11 +22,29 @@ @SpringBootTest public class AgentTest { @Autowired private TzInfoMapper tzInfoMapper; @Test public void insertTzInfo(){ TzInfo tzInfo = new TzInfo(); tzInfo.setType(4); tzInfo.setTzCode("红"); tzInfo.setTzPercent(new BigDecimal("20")); tzInfoMapper.insert(tzInfo); TzInfo tzInfo1 = new TzInfo(); tzInfo1.setType(4); tzInfo1.setTzCode("蓝"); tzInfo1.setTzPercent(new BigDecimal("20")); tzInfoMapper.insert(tzInfo1); } // @Autowired // private AgentProducer agentProducer; // // @Autowired // private DataDictionaryCustomMapper dataDictionaryCustomMapper; @Autowired private DataDictionaryCustomMapper dataDictionaryCustomMapper; // // @Autowired // private IAgentService agentService; @@ -501,22 +529,15 @@ // System.out.println(apiMallActWinDetailsVoIPage); // } // // @Test // public void insertAgentTest() { //// AgentInfo agentInfo = new AgentInfo(); //// agentInfo.setOrderType(2); //// agentInfo.setOrderCnt(2000); //// agentInfo.setLastCnt(3); //// agentInfo.setDirectIncome(BigDecimal.valueOf(50)); //// agentInfo.setTeamIncome(BigDecimal.valueOf(15)); //// agentInfo.setTeamIncomeType(2); //// //// DataDictionaryCustom data = new DataDictionaryCustom(); //// data.setType("AGENT_LEVEL_REQUIRE"); //// data.setCode(AgentLevelEnum.FOUR_LEVEL.name()); //// data.setValue(JSONObject.toJSONString(agentInfo)); //// dataDictionaryCustomMapper.insert(data); // } @Test public void insertAgentTest() { DataDictionaryCustom data = new DataDictionaryCustom(); data.setType("AGENT_LEVEL_REQUIRE"); data.setCode(AgentLevelEnum.FOUR_LEVEL.name()); data.setValue("1"); dataDictionaryCustomMapper.insert(data); } // // @Test // public void insertData() { src/test/java/cc/mrbird/febs/ProfitTest.java
@@ -1,6 +1,12 @@ package cc.mrbird.febs; import cc.mrbird.febs.mall.entity.TzInfo; import cc.mrbird.febs.mall.mapper.TzInfoMapper; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.math.BigDecimal; /** @@ -10,6 +16,21 @@ @SpringBootTest public class ProfitTest { @Autowired private TzInfoMapper tzInfoMapper; @Test public void insertTzInfo(){ TzInfo tzInfo = new TzInfo(); tzInfo.setType(4); tzInfo.setTzCode("红"); tzInfo.setTzPercent(new BigDecimal("20")); tzInfoMapper.insert(tzInfo); TzInfo tzInfo1 = new TzInfo(); tzInfo1.setType(4); tzInfo1.setTzCode("蓝"); tzInfo1.setTzPercent(new BigDecimal("20")); tzInfoMapper.insert(tzInfo1); } }