胡锐 4 weeks ago committed by yuanye
commit 9fe5f319e1
  1. 1
      bweb/src/main/java/com/hfkj/config/AuthConfig.java
  2. 116
      bweb/src/main/java/com/hfkj/controller/cornucopia/CornucopiaController.java
  3. 153
      cweb/src/main/java/com/hfkj/controller/cornucopia/CornucopiaController.java
  4. 11
      service/src/main/java/com/hfkj/common/utils/DateUtil.java
  5. 11
      service/src/main/java/com/hfkj/dao/BsCornucopiaLotteryRecordMapper.java
  6. 33
      service/src/main/java/com/hfkj/dao/BsCornucopiaLotteryRecordMapperExt.java
  7. 14
      service/src/main/java/com/hfkj/dao/BsCornucopiaLotteryRecordSqlProvider.java
  8. 18
      service/src/main/java/com/hfkj/entity/BsCornucopiaLotteryRecord.java
  9. 60
      service/src/main/java/com/hfkj/entity/BsCornucopiaLotteryRecordExample.java
  10. 2
      service/src/main/java/com/hfkj/entity/BsCornucopiaPoolRecord.java
  11. 13
      service/src/main/java/com/hfkj/model/BsCornucopiaPoolModel.java
  12. 13
      service/src/main/java/com/hfkj/model/CornucopiaLotteryRecordModel.java
  13. 17
      service/src/main/java/com/hfkj/model/CornucopiaStatisticsModel.java
  14. 10
      service/src/main/java/com/hfkj/service/cornucopia/BsCornucopiaLotteryRecordService.java
  15. 22
      service/src/main/java/com/hfkj/service/cornucopia/BsCornucopiaPoolService.java
  16. 58
      service/src/main/java/com/hfkj/service/cornucopia/BsCornucopiaUserRecordService.java
  17. 1
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaConfigServiceImpl.java
  18. 12
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaLotteryRecordServiceImpl.java
  19. 290
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaPoolServiceImpl.java
  20. 61
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaUserRecordServiceImpl.java
  21. 6
      service/src/main/java/com/hfkj/service/order/OrderBusinessService.java

@ -88,6 +88,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/common/*")
.excludePathPatterns("/secUser/*")
.excludePathPatterns("/cornucopia/*")
;
}

@ -9,14 +9,19 @@ import com.hfkj.common.security.SessionObject;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.controller.order.BsOrderController;
import com.hfkj.entity.BsCornucopiaConfig;
import com.hfkj.entity.BsCornucopiaLotteryRecord;
import com.hfkj.entity.BsCornucopiaPool;
import com.hfkj.model.CornucopiaStatisticsModel;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.service.cornucopia.BsCornucopiaConfigService;
import com.hfkj.service.cornucopia.BsCornucopiaLotteryRecordService;
import com.hfkj.service.cornucopia.BsCornucopiaPoolService;
import com.hfkj.service.cornucopia.BsCornucopiaUserRecordService;
import com.hfkj.sysenum.cornucopia.CornucopiaEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -25,9 +30,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@RequestMapping(value="/cornucopia")
@ -45,6 +50,9 @@ public class CornucopiaController {
@Resource
private BsCornucopiaLotteryRecordService cornucopiaLotteryRecordService;
@Resource
private BsCornucopiaUserRecordService cornucopiaUserRecordService;
@RequestMapping(value="/editCornucopiaConfig",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "编辑聚宝盆开奖配置内容")
@ -98,4 +106,106 @@ public class CornucopiaController {
}
}
@RequestMapping(value="/cornucopiaLottery",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "聚宝盆开奖")
public ResponseData cornucopiaLottery() {
try {
cornucopiaPoolService.cornucopiaLottery();
return ResponseMsgUtil.success("");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/lotteryRecordList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询开奖记录")
public ResponseData lotteryRecordList(
@RequestParam(value = "type" , required = false) Integer type,
@RequestParam(value = "lotteryNo" , required = false) String lotteryNo,
@RequestParam(value = "pageNum" , required = true) Integer pageNum,
@RequestParam(value = "pageSize" , required = true) Integer pageSize) {
try {
Map<String , Object> map = new HashMap<>();
map.put("type", type);
map.put("lotteryNo", lotteryNo);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(cornucopiaLotteryRecordService.queryAllList(map)));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryUserRecordList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询用户收益记录")
public ResponseData queryUserRecordList(
@RequestParam(value = "type" , required = false) Integer type,
@RequestParam(value = "lotteryNo" , required = false) String lotteryNo,
@RequestParam(value = "userName" , required = false) String userName,
@RequestParam(value = "pageNum" , required = true) Integer pageNum,
@RequestParam(value = "pageSize" , required = true) Integer pageSize) {
try {
Map<String , Object> map = new HashMap<>();
map.put("type", type);
map.put("lotteryNo", lotteryNo);
map.put("userName", userName);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(cornucopiaUserRecordService.queryAllList(map)));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/cornucopiaStatistics",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "统计")
public ResponseData cornucopiaStatistics(
@RequestParam(value = "createTimeS" , required = false) Long createTimeS,
@RequestParam(value = "createTimeE" , required = false) Long createTimeE
) {
try {
Map<String , Object> map = new HashMap<>();
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
// 查询开奖记录
List<BsCornucopiaLotteryRecord> list = cornucopiaLotteryRecordService.queryAllList(map);
CornucopiaStatisticsModel model = new CornucopiaStatisticsModel();
model.setJadeCornucopia(new BigDecimal(0));
model.setGoldCornucopia(new BigDecimal(0));
model.setUserGoldNum(0L);
model.setUserJadeNum(0L);
for (BsCornucopiaLotteryRecord record : list) {
if (record.getType().equals(CornucopiaEnum.type1.getCode())) {
model.setUserGoldNum(model.getUserGoldNum() + record.getUserNum());
model.setGoldCornucopia(model.getGoldCornucopia().add(record.getGoldCoin()));
}
if (record.getType().equals(CornucopiaEnum.type2.getCode())) {
model.setUserJadeNum(model.getUserJadeNum() + record.getUserNum());
model.setJadeCornucopia(model.getJadeCornucopia().add(record.getGoldCoin()));
}
}
return ResponseMsgUtil.success(model);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -4,27 +4,35 @@ import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsCornucopiaConfig;
import com.hfkj.entity.BsCornucopiaLotteryRecord;
import com.hfkj.entity.BsCornucopiaPool;
import com.hfkj.entity.BsCornucopiaUserRecord;
import com.hfkj.model.BsCornucopiaPoolModel;
import com.hfkj.model.CornucopiaLotteryRecordModel;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.cornucopia.BsCornucopiaConfigService;
import com.hfkj.service.cornucopia.BsCornucopiaLotteryRecordService;
import com.hfkj.service.cornucopia.BsCornucopiaPoolService;
import com.hfkj.service.cornucopia.BsCornucopiaUserRecordService;
import com.hfkj.sysenum.cornucopia.CornucopiaEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Controller
@RequestMapping(value="/cornucopia")
@ -42,6 +50,9 @@ public class CornucopiaController {
@Resource
private BsCornucopiaLotteryRecordService cornucopiaLotteryRecordService;
@Resource
private BsCornucopiaUserRecordService cornucopiaUserRecordService;
@Resource
private UserCenter userCenter;
@ -63,12 +74,14 @@ public class CornucopiaController {
@RequestMapping(value="/investmentCornucopia",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "投入聚宝盆")
public ResponseData investmentCornucopia(@RequestBody JSONObject body, HttpServletRequest request) {
public ResponseData investmentCornucopia(@RequestBody JSONObject body) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject();
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
if (body == null||
body.getInteger("type") == null ||
body.getBigDecimal("goldCoin") == null
@ -76,7 +89,7 @@ public class CornucopiaController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
cornucopiaPoolService.investmentCornucopia(body.getInteger("type") , userModel.getAccount().getId() , userModel.getAccount().getUserName() , body.getBigDecimal("goldCoin"));
cornucopiaPoolService.investmentCornucopia(body.getInteger("type") , userSession.getUser().getId() , userSession.getUser().getName() , body.getBigDecimal("goldCoin"));
return ResponseMsgUtil.success("投入成功");
@ -89,12 +102,14 @@ public class CornucopiaController {
@RequestMapping(value="/recoveryGoldCoin",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "回收元宝")
public ResponseData recoveryCornucopia(@RequestBody JSONObject body, HttpServletRequest request) {
public ResponseData recoveryGoldCoin(@RequestBody JSONObject body) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject();
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
if (body == null||
body.getInteger("type") == null ||
body.getBigDecimal("goldCoin") == null
@ -102,9 +117,62 @@ public class CornucopiaController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
cornucopiaPoolService.investmentCornucopia(body.getInteger("type") , userModel.getAccount().getId() , userModel.getAccount().getUserName() , body.getBigDecimal("goldCoin"));
if (body.getBigDecimal("goldCoin").compareTo(new BigDecimal(0)) < 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "元宝不能为0!");
}
return ResponseMsgUtil.success("投入成功");
cornucopiaPoolService.recoveryCornucopia(body.getInteger("type") , userSession.getUser().getId() , userSession.getUser().getName() , body.getBigDecimal("goldCoin"));
return ResponseMsgUtil.success("回收成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/userInvestmentMsg",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "用户投入元宝信息")
public ResponseData userInvestmentMsg(@RequestParam(value = "type" , required = false) Integer type) {
try {
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
Map<String , Object> map = new HashMap<>();
map.put("userId" , userSession.getUser().getId());
map.put("type" , type);
List<BsCornucopiaPool> list = cornucopiaPoolService.queryAllList(map);
// 查询聚宝盆配置内容
List<BsCornucopiaConfig> configs = cornucopiaConfigService.queryAllList(new HashMap<>());
configs.stream().sorted(Comparator.comparing(BsCornucopiaConfig::getType)).collect(Collectors.toList());
List<BsCornucopiaPoolModel> poolModels = new ArrayList<>();
for (BsCornucopiaConfig config : configs) {
BsCornucopiaPoolModel poolModel = new BsCornucopiaPoolModel();
poolModel.setCornucopiaName(CornucopiaEnum.getDataByType(config.getType()).getName());
poolModel.setLotteryNo(DateUtil.date2String(new Date() , DateUtil.YMD));
List<BsCornucopiaPool> cornucopiaPoolList = list.stream().filter(s-> s.getType().equals(config.getType())).collect(Collectors.toList());
if (!cornucopiaPoolList.isEmpty()) {
poolModel.setEnterGoldCoin(cornucopiaPoolList.get(0).getGoldCoin());
} else {
poolModel.setEnterGoldCoin(new BigDecimal(0));
}
poolModels.add(poolModel);
}
return ResponseMsgUtil.success(poolModels);
} catch (Exception e) {
log.error("error!",e);
@ -113,4 +181,51 @@ public class CornucopiaController {
}
@RequestMapping(value="/cornucopiaRecord",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "聚宝记录")
public ResponseData cornucopiaRecord() {
try {
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
// 查询用户开奖记录
List<BsCornucopiaUserRecord> userRecords = cornucopiaUserRecordService.queryAllList(new HashMap<>());
// 查询开奖记录
List<BsCornucopiaLotteryRecord> lotteryRecords = cornucopiaLotteryRecordService.queryAllList(new HashMap<>());
List<CornucopiaLotteryRecordModel> modelList = new ArrayList<>();
CornucopiaLotteryRecordModel model;
for (BsCornucopiaLotteryRecord lotteryRecord : lotteryRecords) {
model = new CornucopiaLotteryRecordModel();
BeanUtils.copyProperties(model, lotteryRecord);
List<BsCornucopiaUserRecord> lotteryRecordList = userRecords.stream().filter(s-> s.getLotteryNo().equals(lotteryRecord.getLotteryNo())).filter(s-> s.getType().equals(lotteryRecord.getType())).collect(Collectors.toList());
model.setUserGoldCoin(lotteryRecordList.get(0).getGoldCoin());
modelList.add(model);
}
Map<String, List<CornucopiaLotteryRecordModel>> collect = modelList.stream().collect(Collectors.groupingBy(CornucopiaLotteryRecordModel::getLotteryNo));
AtomicReference<Integer> i = new AtomicReference<>(1);
List<JSONObject> countRecords = collect.keySet().stream().map(key -> {
JSONObject goodObject = new JSONObject(true);
goodObject.put("name",key.toUpperCase());
goodObject.put("id",i.getAndSet(i.get() + 1));
goodObject.put("list",collect.get(key));
return goodObject;
}).collect(Collectors.toList());
return ResponseMsgUtil.success(countRecords);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -39,6 +39,17 @@ public class DateUtil {
Calendar calendar = Calendar.getInstance();
return calendar.get(Calendar.YEAR);
}
public static Integer getThisMonth(){
Calendar calendar = Calendar.getInstance();
return calendar.get(Calendar.MONTH);
}
public static Integer getThisDay(){
Calendar calendar = Calendar.getInstance();
return calendar.get(Calendar.DATE);
}
public static String date2String(Date date,String format) throws Exception{
String str = null;
SimpleDateFormat sdf = new SimpleDateFormat(format);

@ -40,13 +40,13 @@ public interface BsCornucopiaLotteryRecordMapper extends BsCornucopiaLotteryReco
@Insert({
"insert into bs_cornucopia_lottery_record (lottery_no, lottery_time, ",
"`type`, proportion, ",
"`type`, user_num, proportion, ",
"gold_coin, type_name, ",
"config_msg, create_time, ",
"update_time, `status`, ",
"ext_1, ext_2, ext_3)",
"values (#{lotteryNo,jdbcType=VARCHAR}, #{lotteryTime,jdbcType=TIMESTAMP}, ",
"#{type,jdbcType=INTEGER}, #{proportion,jdbcType=DECIMAL}, ",
"#{type,jdbcType=INTEGER}, #{userNum,jdbcType=INTEGER}, #{proportion,jdbcType=DECIMAL}, ",
"#{goldCoin,jdbcType=DECIMAL}, #{typeName,jdbcType=VARCHAR}, ",
"#{configMsg,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
@ -65,6 +65,7 @@ public interface BsCornucopiaLotteryRecordMapper extends BsCornucopiaLotteryReco
@Result(column="lottery_no", property="lotteryNo", jdbcType=JdbcType.VARCHAR),
@Result(column="lottery_time", property="lotteryTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="user_num", property="userNum", jdbcType=JdbcType.INTEGER),
@Result(column="proportion", property="proportion", jdbcType=JdbcType.DECIMAL),
@Result(column="gold_coin", property="goldCoin", jdbcType=JdbcType.DECIMAL),
@Result(column="type_name", property="typeName", jdbcType=JdbcType.VARCHAR),
@ -80,8 +81,8 @@ public interface BsCornucopiaLotteryRecordMapper extends BsCornucopiaLotteryReco
@Select({
"select",
"id, lottery_no, lottery_time, `type`, proportion, gold_coin, type_name, config_msg, ",
"create_time, update_time, `status`, ext_1, ext_2, ext_3",
"id, lottery_no, lottery_time, `type`, user_num, proportion, gold_coin, type_name, ",
"config_msg, create_time, update_time, `status`, ext_1, ext_2, ext_3",
"from bs_cornucopia_lottery_record",
"where id = #{id,jdbcType=BIGINT}"
})
@ -90,6 +91,7 @@ public interface BsCornucopiaLotteryRecordMapper extends BsCornucopiaLotteryReco
@Result(column="lottery_no", property="lotteryNo", jdbcType=JdbcType.VARCHAR),
@Result(column="lottery_time", property="lotteryTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="user_num", property="userNum", jdbcType=JdbcType.INTEGER),
@Result(column="proportion", property="proportion", jdbcType=JdbcType.DECIMAL),
@Result(column="gold_coin", property="goldCoin", jdbcType=JdbcType.DECIMAL),
@Result(column="type_name", property="typeName", jdbcType=JdbcType.VARCHAR),
@ -117,6 +119,7 @@ public interface BsCornucopiaLotteryRecordMapper extends BsCornucopiaLotteryReco
"set lottery_no = #{lotteryNo,jdbcType=VARCHAR},",
"lottery_time = #{lotteryTime,jdbcType=TIMESTAMP},",
"`type` = #{type,jdbcType=INTEGER},",
"user_num = #{userNum,jdbcType=INTEGER},",
"proportion = #{proportion,jdbcType=DECIMAL},",
"gold_coin = #{goldCoin,jdbcType=DECIMAL},",
"type_name = #{typeName,jdbcType=VARCHAR},",

@ -1,7 +1,40 @@
package com.hfkj.dao;
import com.hfkj.entity.BsCornucopiaLotteryRecord;
import com.hfkj.entity.BsCornucopiaLotteryRecordExample;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
/**
* mapper扩展类
*/
public interface BsCornucopiaLotteryRecordMapperExt {
@Select(value = {
"<script>",
"select * from bs_cornucopia_lottery_record ",
"where ",
"DATE_FORMAT(create_time,'%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d') and status = 1 " ,
"</script>"
})
@Results({
@Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
@Result(column="lottery_no", property="lotteryNo", jdbcType=JdbcType.VARCHAR),
@Result(column="lottery_time", property="lotteryTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="type_name", property="typeName", jdbcType=JdbcType.VARCHAR),
@Result(column="config_msg", property="configMsg", jdbcType=JdbcType.VARCHAR),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<BsCornucopiaLotteryRecord> cornucopiaLottery();
}

@ -40,6 +40,10 @@ public class BsCornucopiaLotteryRecordSqlProvider {
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}");
}
if (record.getUserNum() != null) {
sql.VALUES("user_num", "#{userNum,jdbcType=INTEGER}");
}
if (record.getProportion() != null) {
sql.VALUES("proportion", "#{proportion,jdbcType=DECIMAL}");
}
@ -93,6 +97,7 @@ public class BsCornucopiaLotteryRecordSqlProvider {
sql.SELECT("lottery_no");
sql.SELECT("lottery_time");
sql.SELECT("`type`");
sql.SELECT("user_num");
sql.SELECT("proportion");
sql.SELECT("gold_coin");
sql.SELECT("type_name");
@ -136,6 +141,10 @@ public class BsCornucopiaLotteryRecordSqlProvider {
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
}
if (record.getUserNum() != null) {
sql.SET("user_num = #{record.userNum,jdbcType=INTEGER}");
}
if (record.getProportion() != null) {
sql.SET("proportion = #{record.proportion,jdbcType=DECIMAL}");
}
@ -188,6 +197,7 @@ public class BsCornucopiaLotteryRecordSqlProvider {
sql.SET("lottery_no = #{record.lotteryNo,jdbcType=VARCHAR}");
sql.SET("lottery_time = #{record.lotteryTime,jdbcType=TIMESTAMP}");
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
sql.SET("user_num = #{record.userNum,jdbcType=INTEGER}");
sql.SET("proportion = #{record.proportion,jdbcType=DECIMAL}");
sql.SET("gold_coin = #{record.goldCoin,jdbcType=DECIMAL}");
sql.SET("type_name = #{record.typeName,jdbcType=VARCHAR}");
@ -220,6 +230,10 @@ public class BsCornucopiaLotteryRecordSqlProvider {
sql.SET("`type` = #{type,jdbcType=INTEGER}");
}
if (record.getUserNum() != null) {
sql.SET("user_num = #{userNum,jdbcType=INTEGER}");
}
if (record.getProportion() != null) {
sql.SET("proportion = #{proportion,jdbcType=DECIMAL}");
}

@ -13,7 +13,7 @@ import java.util.Date;
* 代码由工具生成
*
**/
public class BsCornucopiaLotteryRecord implements Serializable {
public class BsCornucopiaLotteryRecord implements Serializable {
/**
* 主键
*/
@ -34,6 +34,11 @@ public class BsCornucopiaLotteryRecord implements Serializable {
*/
private Integer type;
/**
* 参与用户数量
*/
private Integer userNum;
/**
* 比例
*/
@ -118,6 +123,14 @@ public class BsCornucopiaLotteryRecord implements Serializable {
this.type = type;
}
public Integer getUserNum() {
return userNum;
}
public void setUserNum(Integer userNum) {
this.userNum = userNum;
}
public BigDecimal getProportion() {
return proportion;
}
@ -214,6 +227,7 @@ public class BsCornucopiaLotteryRecord implements Serializable {
&& (this.getLotteryNo() == null ? other.getLotteryNo() == null : this.getLotteryNo().equals(other.getLotteryNo()))
&& (this.getLotteryTime() == null ? other.getLotteryTime() == null : this.getLotteryTime().equals(other.getLotteryTime()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getUserNum() == null ? other.getUserNum() == null : this.getUserNum().equals(other.getUserNum()))
&& (this.getProportion() == null ? other.getProportion() == null : this.getProportion().equals(other.getProportion()))
&& (this.getGoldCoin() == null ? other.getGoldCoin() == null : this.getGoldCoin().equals(other.getGoldCoin()))
&& (this.getTypeName() == null ? other.getTypeName() == null : this.getTypeName().equals(other.getTypeName()))
@ -234,6 +248,7 @@ public class BsCornucopiaLotteryRecord implements Serializable {
result = prime * result + ((getLotteryNo() == null) ? 0 : getLotteryNo().hashCode());
result = prime * result + ((getLotteryTime() == null) ? 0 : getLotteryTime().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getUserNum() == null) ? 0 : getUserNum().hashCode());
result = prime * result + ((getProportion() == null) ? 0 : getProportion().hashCode());
result = prime * result + ((getGoldCoin() == null) ? 0 : getGoldCoin().hashCode());
result = prime * result + ((getTypeName() == null) ? 0 : getTypeName().hashCode());
@ -257,6 +272,7 @@ public class BsCornucopiaLotteryRecord implements Serializable {
sb.append(", lotteryNo=").append(lotteryNo);
sb.append(", lotteryTime=").append(lotteryTime);
sb.append(", type=").append(type);
sb.append(", userNum=").append(userNum);
sb.append(", proportion=").append(proportion);
sb.append(", goldCoin=").append(goldCoin);
sb.append(", typeName=").append(typeName);

@ -376,6 +376,66 @@ public class BsCornucopiaLotteryRecordExample {
return (Criteria) this;
}
public Criteria andUserNumIsNull() {
addCriterion("user_num is null");
return (Criteria) this;
}
public Criteria andUserNumIsNotNull() {
addCriterion("user_num is not null");
return (Criteria) this;
}
public Criteria andUserNumEqualTo(Integer value) {
addCriterion("user_num =", value, "userNum");
return (Criteria) this;
}
public Criteria andUserNumNotEqualTo(Integer value) {
addCriterion("user_num <>", value, "userNum");
return (Criteria) this;
}
public Criteria andUserNumGreaterThan(Integer value) {
addCriterion("user_num >", value, "userNum");
return (Criteria) this;
}
public Criteria andUserNumGreaterThanOrEqualTo(Integer value) {
addCriterion("user_num >=", value, "userNum");
return (Criteria) this;
}
public Criteria andUserNumLessThan(Integer value) {
addCriterion("user_num <", value, "userNum");
return (Criteria) this;
}
public Criteria andUserNumLessThanOrEqualTo(Integer value) {
addCriterion("user_num <=", value, "userNum");
return (Criteria) this;
}
public Criteria andUserNumIn(List<Integer> values) {
addCriterion("user_num in", values, "userNum");
return (Criteria) this;
}
public Criteria andUserNumNotIn(List<Integer> values) {
addCriterion("user_num not in", values, "userNum");
return (Criteria) this;
}
public Criteria andUserNumBetween(Integer value1, Integer value2) {
addCriterion("user_num between", value1, value2, "userNum");
return (Criteria) this;
}
public Criteria andUserNumNotBetween(Integer value1, Integer value2) {
addCriterion("user_num not between", value1, value2, "userNum");
return (Criteria) this;
}
public Criteria andProportionIsNull() {
addCriterion("proportion is null");
return (Criteria) this;

@ -50,7 +50,7 @@ public class BsCornucopiaPoolRecord implements Serializable {
private Date updateTime;
/**
* 状态 1:投入 0:取出
* 状态 1:投入 2:取出
*/
private Integer status;

@ -0,0 +1,13 @@
package com.hfkj.model;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class BsCornucopiaPoolModel {
String cornucopiaName;
BigDecimal enterGoldCoin;
String lotteryNo;
String img;
}

@ -0,0 +1,13 @@
package com.hfkj.model;
import com.hfkj.entity.BsCornucopiaLotteryRecord;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class CornucopiaLotteryRecordModel extends BsCornucopiaLotteryRecord {
// 用户元宝
BigDecimal userGoldCoin;
}

@ -0,0 +1,17 @@
package com.hfkj.model;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class CornucopiaStatisticsModel {
// 用户数量
Long userGoldNum;
// 玉聚宝盆用户数量
Long userJadeNum;
// 金聚宝盆投入数量
BigDecimal goldCornucopia;
// 玉聚宝盆投入数量
BigDecimal jadeCornucopia;
}

@ -54,4 +54,14 @@ public interface BsCornucopiaLotteryRecordService {
* @Date: 2024/9/27 上午11:42
*/
List<BsCornucopiaLotteryRecord> queryAllList(Map<String , Object> map);
/**
* @MethodName cornucopiaLottery
* @Description:
* @param
* @return: java.util.List<com.hfkj.entity.BsCornucopiaLotteryRecord>
* @Author: Sum1Dream
* @Date: 2024/10/8 下午2:35
*/
List<BsCornucopiaLotteryRecord> cornucopiaLottery();
}

@ -80,6 +80,17 @@ public interface BsCornucopiaPoolService {
*/
void investmentCornucopia(Integer type , Long userId , String userName , BigDecimal goldCoin) throws Exception;
/**
* @MethodName recoveryCornucopia
* @Description: 回收元宝
* @param type
* @param userId
* @param userName
* @param goldCoin
* @Author: Sum1Dream
* @Date: 2024/9/27 下午4:46
*/
void recoveryCornucopia(Integer type , Long userId , String userName , BigDecimal goldCoin) throws Exception;
/**
* @MethodName create
* @Description: 创建
@ -98,4 +109,15 @@ public interface BsCornucopiaPoolService {
* @Date: 2024/9/27 上午11:42
*/
List<BsCornucopiaPoolRecord> queryAllListRecord(Map<String , Object> map);
/**
* @MethodName cornucopiaLottery
* @Description: 聚宝盆开奖
* @param
* @Author: Sum1Dream
* @Date: 2024/10/8 下午2:16
*/
void cornucopiaLottery() throws Exception;
}

@ -0,0 +1,58 @@
package com.hfkj.service.cornucopia;
import com.hfkj.entity.BsCornucopiaUserRecord;
import java.util.List;
import java.util.Map;
public interface BsCornucopiaUserRecordService {
/**
* @MethodName create
* @Description: 创建
* @param cornucopiaUserRecord
* @Author: Sum1Dream
* @Date: 2024/7/4 下午2:30
*/
void create(BsCornucopiaUserRecord cornucopiaUserRecord);
/**
* @MethodName delete
* @Description: 删除
* @param id
* @param fullDelete
* @Author: Sum1Dream
* @Date: 2024/7/4 下午2:30
*/
void delete(Long id , Boolean fullDelete);
/**
* @MethodName queryDetail
* @Description:查询详情
* @param id
* @return: com.hfkj.entity.BsCornucopiaUserRecord
* @Author: Sum1Dream
* @Date: 2024/7/4 下午2:30
*/
BsCornucopiaUserRecord queryDetail(Long id);
/**
* @MethodName queryDetail
* @Description:
* @param type
* @return: com.hfkj.entity.BsCornucopiaUserRecord
* @Author: Sum1Dream
* @Date: 2024/9/27 下午2:28
*/
BsCornucopiaUserRecord queryDetail(Integer type);
/**
* @MethodName queryAllList
* @Description: map
* @param
* @return: java.util.List<com.hfkj.entity.BsCornucopiaUserRecord>
* @Author: Sum1Dream
* @Date: 2024/9/27 上午11:42
*/
List<BsCornucopiaUserRecord> queryAllList(Map<String , Object> map);
}

@ -78,6 +78,7 @@ public class BsCornucopiaConfigServiceImpl implements BsCornucopiaConfigService
if (MapUtils.getString(map, "name") != null) {
criteria.andNameLike("%" + MapUtils.getString(map, "name") + "%");
}
criteria.andStatusNotEqualTo(0);
return bsCornucopiaConfigMapper.selectByExample(example);
}

@ -56,7 +56,12 @@ public class BsCornucopiaLotteryRecordServiceImpl implements BsCornucopiaLottery
if (MapUtils.getInteger(map, "type") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map, "type"));
}
if (MapUtils.getLong(map, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS")));
}
if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
}
if (MapUtils.getString(map, "lotteryNo") != null) {
criteria.andLotteryNoLike("%" + MapUtils.getString(map, "lotteryNo") + "%");
}
@ -64,4 +69,9 @@ public class BsCornucopiaLotteryRecordServiceImpl implements BsCornucopiaLottery
return bsCornucopiaLotteryRecordMapper.selectByExample(example);
}
@Override
public List<BsCornucopiaLotteryRecord> cornucopiaLottery() {
return bsCornucopiaLotteryRecordMapper.cornucopiaLottery();
}
}

@ -4,10 +4,14 @@ import com.hfkj.common.exception.BaseException;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.dao.BsCornucopiaPoolMapper;
import com.hfkj.dao.BsCornucopiaPoolRecordMapper;
import com.hfkj.entity.*;
import com.hfkj.service.cornucopia.BsCornucopiaConfigService;
import com.hfkj.service.cornucopia.BsCornucopiaLotteryRecordService;
import com.hfkj.service.cornucopia.BsCornucopiaPoolService;
import com.hfkj.service.cornucopia.BsCornucopiaUserRecordService;
import com.hfkj.service.user.BsUserAccountService;
import com.hfkj.sysenum.cornucopia.CornucopiaEnum;
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum;
@ -23,6 +27,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service("bsCornucopiaPoolService")
public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService {
@ -37,6 +42,15 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService {
@Resource
private BsUserAccountService userAccountService;
@Resource
private BsCornucopiaConfigService cornucopiaConfigService;
@Resource
private BsCornucopiaLotteryRecordService cornucopiaLotteryRecordService;
@Resource
private BsCornucopiaUserRecordService cornucopiaUserRecordService;
@Resource
private RedisTemplate<String,Object> redisTemplate;
private final String LOCK_KEY = "POOL_TRADE_LOCK_";
@ -103,6 +117,12 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService {
if (MapUtils.getLong(map, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
}
if (MapUtils.getLong(map, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS")));
}
if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
}
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
@ -184,6 +204,68 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService {
}
}
@Override
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class})
public void recoveryCornucopia(Integer type, Long userId, String userName, BigDecimal goldCoin) throws Exception {
// 锁编号
String lockKey = LOCK_KEY+userId;
// 获取锁
Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, "");
if (Boolean.TRUE.equals(lock)) {
try {
// 获取锁成功
// 锁超时时间 10秒
redisTemplate.expire(lockKey, 10, TimeUnit.SECONDS);
// 插入投入记录
BsCornucopiaPoolRecord record = new BsCornucopiaPoolRecord();
record.setUserId(userId);
record.setType(type);
record.setGoldCoin(goldCoin);
record.setStatus(2);
record.setCreateTime(new Date());
record.setUpdateTime(new Date());
record.setUserName(userName);
create(record);
// 查询投入
BsCornucopiaPool cornucopiaPool = queryDetail(userId , type);
if (cornucopiaPool == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "您还没有参加活动哟!");
}
if (cornucopiaPool.getGoldCoin().compareTo(goldCoin) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "元宝不够哟!");
}
// 扣除
cornucopiaPool.setGoldCoin(cornucopiaPool.getGoldCoin().subtract(goldCoin));
cornucopiaPool.setUpdateTime(new Date());
edit(cornucopiaPool);
// 充值记录
Map<String, Object> userRechargeParam = new HashMap<>();
userRechargeParam.put("sourceId", record.getId());
userRechargeParam.put("sourceOrderNo", "");
userRechargeParam.put("sourceContent", userName + "回收" + CornucopiaEnum.getDataByType(type).getName() + goldCoin);
// 用户账户充值
userAccountService.recharge(userId,goldCoin, UserAccountRecordSourceTypeEnum.type3, userRechargeParam);
} catch (BaseException e) {
// 释放锁
redisTemplate.delete(lockKey);
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, e.getErrorMsg());
} catch (Exception e) {
// 释放锁
redisTemplate.delete(lockKey);
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "啊偶~交易出现未知问题!请稍后重试");
}
} else {
Thread.sleep(100);
recoveryCornucopia(type , userId , userName ,goldCoin);
}
}
@Override
public void create(BsCornucopiaPoolRecord cornucopiaPoolRecord) {
cornucopiaPoolRecordMapper.insert(cornucopiaPoolRecord);
@ -204,9 +286,217 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService {
if (MapUtils.getLong(map, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
}
if (MapUtils.getLong(map, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS")));
}
if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
}
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
} else {
criteria.andStatusNotEqualTo(0);
}
return cornucopiaPoolRecordMapper.selectByExample(example);
}
@Override
public void cornucopiaLottery() throws Exception {
// 查询聚宝盆配置参数
List<BsCornucopiaConfig> cornucopiaConfigList = cornucopiaConfigService.queryAllList(new HashMap<>());
if (cornucopiaConfigList.isEmpty()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "啊偶~没有配置参数!");
}
// 判断是否当天已经开奖
List<BsCornucopiaLotteryRecord> lotteryRecord = cornucopiaLotteryRecordService.cornucopiaLottery();
if (!lotteryRecord.isEmpty()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当期已开奖!");
}
String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD);
Date LotteryTime = new Date();
// 查询投入玩家
List<BsCornucopiaPool> cornucopiaPoolList = queryAllList(new HashMap<>());
if (lotteryRecord.isEmpty()) {
// 获取时间
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) -1);
calendar.set(Calendar.HOUR_OF_DAY, 7);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
Long time = calendar.getTime().getTime();
// 查询用户开奖周期元宝记录
Map<String , Object> map = new HashMap<>();
map.put("createTimeE" , time);
List<BsCornucopiaPoolRecord> beforePoolRecordList = queryAllListRecord(map);
// 查询用户开奖周期之后的元宝记录
Map<String , Object> mapS = new HashMap<>();
mapS.put("createTimeS" , time);
List<BsCornucopiaPoolRecord> afterPoolRecordList = queryAllListRecord(mapS);
// 定义开奖期数记录
BsCornucopiaLotteryRecord cornucopiaLotteryRecord;
// 定义用户元宝收益记录
BsCornucopiaUserRecord userRecord;
// 记录金玉聚宝盆总投入
BigDecimal goldIncomeAll = BigDecimal.ZERO;
BigDecimal jadeIncomeAll = BigDecimal.ZERO;
Integer userGoldNum = 0;
Integer userJadeNum = 0;
if (!beforePoolRecordList.isEmpty()) {
for (BsCornucopiaPool cornucopiaPool : cornucopiaPoolList) {
// 查询用户开奖周期内金聚宝盆投入元宝
BigDecimal enterBeforeGoldPrice = beforePoolRecordList.stream()
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId()))
.filter(s->s.getStatus().equals(1))
.filter(s->s.getType().equals(1))
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
// 查询用户开奖周期内金聚宝盆投出元宝
BigDecimal outBeforeGoldPrice = beforePoolRecordList.stream()
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId()))
.filter(s->s.getStatus().equals(2))
.filter(s->s.getType().equals(1))
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
// 查询用户开奖周期后金聚宝盆投入元宝
BigDecimal enterAfterGoldPrice = afterPoolRecordList.stream()
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId()))
.filter(s->s.getStatus().equals(1))
.filter(s->s.getType().equals(1))
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
// 查询用户开奖周期后金聚宝盆投出元宝
BigDecimal outAfterGoldPrice = afterPoolRecordList.stream()
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId()))
.filter(s->s.getStatus().equals(2))
.filter(s->s.getType().equals(1))
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
// 查询用户开奖周期内玉聚宝盆投入元宝
BigDecimal enterBeforeJadePrice = beforePoolRecordList.stream()
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId()))
.filter(s->s.getStatus().equals(1))
.filter(s->s.getType().equals(2))
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
// 查询用户开奖周期内玉聚宝盆投出元宝
BigDecimal outBeforeJadePrice = beforePoolRecordList.stream()
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId()))
.filter(s->s.getStatus().equals(2))
.filter(s->s.getType().equals(2))
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
// 查询用户开奖周期后玉聚宝盆投入元宝
BigDecimal enterAfterJadePrice = afterPoolRecordList.stream()
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId()))
.filter(s->s.getStatus().equals(1))
.filter(s->s.getType().equals(2))
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
// 查询用户开奖周期后玉聚宝盆投出元宝
BigDecimal outAfterJadePrice = afterPoolRecordList.stream()
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId()))
.filter(s->s.getStatus().equals(2))
.filter(s->s.getType().equals(2))
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
// 计算金聚宝盆实际收益
// 计算金聚宝盆开奖周期内的剩余元宝
BigDecimal gold = enterBeforeGoldPrice.subtract(outBeforeGoldPrice);
// 计算金聚宝盆开奖周期之后的剩余元宝
BigDecimal goldAfter = enterAfterGoldPrice.subtract(outAfterGoldPrice);
if (goldAfter.compareTo(new BigDecimal(0)) < 1) {
gold = gold.add(goldAfter);
}
// 计算玉聚宝盆实际收益
// 计算玉聚宝盆开奖周期内的剩余元宝
BigDecimal jade = enterBeforeJadePrice.subtract(outBeforeJadePrice);
// 计算玉聚宝盆开奖周期之后的剩余元宝
BigDecimal jadeAfter = enterAfterJadePrice.subtract(outAfterJadePrice);
if (jadeAfter.compareTo(new BigDecimal(0)) < 1) {
jade = jade.add(jadeAfter);
}
List<BsCornucopiaConfig> list = cornucopiaConfigList.stream().filter(s->s.getType().equals(cornucopiaPool.getType())).collect(Collectors.toList());
BigDecimal goldCoin = BigDecimal.ZERO;
// 计算金聚宝盆收益
if (cornucopiaPool.getType().equals(1)) {
if (gold.compareTo(new BigDecimal(0)) > 0) {
userGoldNum++;
// 计算总投入
goldIncomeAll = goldIncomeAll.add(gold);
// 实际收益
goldCoin = gold.multiply(list.get(0).getProportion());
}
}
//计算玉聚宝盆收益
if (cornucopiaPool.getType().equals(2)) {
if (jade.compareTo(new BigDecimal(0)) > 0) {
userJadeNum++;
jadeIncomeAll = jadeIncomeAll.add(jade);
goldCoin = jade.multiply(list.get(0).getProportion());
}
}
// 赠送用户收益
userRecord = new BsCornucopiaUserRecord();
userRecord.setCreateTime(new Date());
userRecord.setUpdateTime(new Date());
userRecord.setLotteryTime(LotteryTime);
userRecord.setUserId(cornucopiaPool.getUserId());
userRecord.setUserName(cornucopiaPool.getUserName());
userRecord.setStatus(1);
userRecord.setLotteryNo(lotteryNo);
userRecord.setType(cornucopiaPool.getType());
userRecord.setGoldCoin(goldCoin);
userRecord.setProportion(list.get(0).getProportion());
cornucopiaUserRecordService.create(userRecord);
// 充值记录
Map<String, Object> userRechargeParam = new HashMap<>();
userRechargeParam.put("sourceId", userRecord.getId());
userRechargeParam.put("sourceOrderNo", "");
userRechargeParam.put("sourceContent", cornucopiaPool.getUserName() + CornucopiaEnum.getDataByType(cornucopiaPool.getType()).getName() + "收益" + goldCoin);
// 用户账户充值
userAccountService.recharge(cornucopiaPool.getUserId(),goldCoin, UserAccountRecordSourceTypeEnum.type3, userRechargeParam);
}
for (BsCornucopiaConfig cornucopiaConfig : cornucopiaConfigList) {
cornucopiaLotteryRecord = new BsCornucopiaLotteryRecord();
// 金聚宝盆
if (cornucopiaConfig.getType().equals(1)) {
cornucopiaLotteryRecord.setUserNum(userGoldNum);
cornucopiaLotteryRecord.setGoldCoin(goldIncomeAll);
}
//计算玉聚宝盆收益
if (cornucopiaConfig.getType().equals(2)) {
cornucopiaLotteryRecord.setUserNum(userJadeNum);
cornucopiaLotteryRecord.setGoldCoin(jadeIncomeAll);
}
// 开奖记录
cornucopiaLotteryRecord.setCreateTime(new Date());
cornucopiaLotteryRecord.setUpdateTime(new Date());
cornucopiaLotteryRecord.setLotteryTime(LotteryTime);
cornucopiaLotteryRecord.setLotteryNo(lotteryNo);
cornucopiaLotteryRecord.setType(cornucopiaConfig.getType());
cornucopiaLotteryRecord.setStatus(1);
cornucopiaLotteryRecord.setConfigMsg(cornucopiaConfig.toString());
cornucopiaLotteryRecord.setProportion(cornucopiaConfig.getProportion());
cornucopiaLotteryRecord.setTypeName(CornucopiaEnum.getDataByType(cornucopiaConfig.getType()).getName());
cornucopiaLotteryRecordService.create(cornucopiaLotteryRecord);
}
}
}
}
}

@ -0,0 +1,61 @@
package com.hfkj.service.cornucopia.Impl;
import com.hfkj.dao.BsCornucopiaUserRecordMapper;
import com.hfkj.entity.BsCornucopiaUserRecord;
import com.hfkj.entity.BsCornucopiaUserRecordExample;
import com.hfkj.service.cornucopia.BsCornucopiaUserRecordService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@Service("bsCornucopiaUserRecordService")
public class BsCornucopiaUserRecordServiceImpl implements BsCornucopiaUserRecordService {
@Resource
private BsCornucopiaUserRecordMapper userRecordMapper;
@Override
public void create(BsCornucopiaUserRecord cornucopiaUserRecord) {
userRecordMapper.insert(cornucopiaUserRecord);
}
@Override
public void delete(Long id, Boolean fullDelete) {
}
@Override
public BsCornucopiaUserRecord queryDetail(Long id) {
return null;
}
@Override
public BsCornucopiaUserRecord queryDetail(Integer type) {
return null;
}
@Override
public List<BsCornucopiaUserRecord> queryAllList(Map<String, Object> map) {
BsCornucopiaUserRecordExample example = new BsCornucopiaUserRecordExample();
BsCornucopiaUserRecordExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map, "type") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map, "type"));
}
if (MapUtils.getString(map, "lotteryNo") != null) {
criteria.andLotteryNoLike("%" + MapUtils.getString(map, "lotteryNo") + "%");
}
if (MapUtils.getString(map, "userName") != null) {
criteria.andUserNameLike("%" + MapUtils.getString(map, "userName") + "%");
}
if (MapUtils.getLong(map, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
}
return userRecordMapper.selectByExample(example);
}
}

@ -32,10 +32,10 @@ public class OrderBusinessService {
public JSONObject taobaoUrl(BsOrder bsOrder) throws Exception{
JSONObject jsonObject = JSONObject.parseObject(bsOrder.getCustomparameters());
JSONObject object = TaoBaoService.createCommand(jsonObject.getString("url"));
if (!jsonObject.getBoolean("success")) {
if (!object.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
return object;
return object.getJSONObject("data");
}
@ -55,12 +55,10 @@ public class OrderBusinessService {
Map<String , Object> mapUser = new HashMap<>();
mapUser.put("uid", bsOrder.getUserId());
mapUser.put("orderNo", bsOrder.getOrderNo());
// 判断是否需要授权
JSONObject object = PddService.authority(mapUser.toString());
boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
JSONObject o = PddService.promotion(searchId , goodsSign , generateAuthorityUrl , mapUser.toString());
return o.getJSONObject("goodsPromotionUrlGenerateResponse").getJSONArray("goodsPromotionUrlList").getJSONObject(0);

Loading…
Cancel
Save