Merge branch 'master' of http://gitea.dctpay.com/hurui/youtao
commit
d0e9329ccb
@ -0,0 +1,101 @@ |
||||
package com.hfkj.controller.cornucopia; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
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.utils.ResponseMsgUtil; |
||||
import com.hfkj.controller.order.BsOrderController; |
||||
import com.hfkj.entity.BsCornucopiaConfig; |
||||
import com.hfkj.entity.BsCornucopiaPool; |
||||
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 io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
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; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/cornucopia") |
||||
@Api(value="聚宝盆管理") |
||||
public class CornucopiaController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CornucopiaController.class); |
||||
|
||||
@Resource |
||||
private BsCornucopiaConfigService cornucopiaConfigService; |
||||
|
||||
@Resource |
||||
private BsCornucopiaPoolService cornucopiaPoolService; |
||||
|
||||
@Resource |
||||
private BsCornucopiaLotteryRecordService cornucopiaLotteryRecordService; |
||||
|
||||
@RequestMapping(value="/editCornucopiaConfig",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "编辑聚宝盆开奖配置内容") |
||||
public ResponseData editCornucopiaConfig(@RequestBody BsCornucopiaConfig body, HttpServletRequest request) { |
||||
|
||||
try { |
||||
|
||||
if (body == null |
||||
|| body.getType() == null |
||||
|| body.getName() == null |
||||
|| body.getProportion() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询是否存在当前开奖内容
|
||||
BsCornucopiaConfig cornucopiaConfig = cornucopiaConfigService.queryDetail(body.getType()); |
||||
|
||||
if (cornucopiaConfig == null) { |
||||
cornucopiaConfig = new BsCornucopiaConfig(); |
||||
cornucopiaConfig.setStatus(1); |
||||
cornucopiaConfig.setCreateTime(new Date()); |
||||
} |
||||
|
||||
cornucopiaConfig.setUpdateTime(new Date()); |
||||
cornucopiaConfig.setType(body.getType()); |
||||
cornucopiaConfig.setName(body.getName()); |
||||
cornucopiaConfig.setProportion(body.getProportion()); |
||||
|
||||
cornucopiaConfigService.edit(cornucopiaConfig); |
||||
|
||||
return ResponseMsgUtil.success(cornucopiaConfig); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
|
||||
} |
||||
|
||||
@RequestMapping(value="/getCornucopiaConfig",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询聚宝盆配置参数列表") |
||||
public ResponseData getCornucopiaConfig() { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(cornucopiaConfigService.queryAllList(new HashMap<>())); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,69 @@ |
||||
package com.hfkj.controller.order; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.security.SessionObject; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.service.order.BsOrderService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/order") |
||||
@Api(value="订单管理") |
||||
public class BsOrderController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BsOrderController.class); |
||||
|
||||
@Resource |
||||
private BsOrderService orderService; |
||||
|
||||
@RequestMapping(value="/getOrderList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询列表") |
||||
public ResponseData getOrderList(@RequestParam(value = "orderNo" , required = false) String orderNo, |
||||
@RequestParam(value = "type" , required = false) Integer type, |
||||
@RequestParam(value = "status" , required = false) Integer status, |
||||
@RequestParam(value = "userPhone" , required = false) String userPhone, |
||||
@RequestParam(value = "goodsName" , required = false) String goodsName, |
||||
@RequestParam(value = "createTimeS" , required = false) Long createTimeS, |
||||
@RequestParam(value = "createTimeE" , required = false) Long createTimeE, |
||||
@RequestParam(value = "pageNum" , required = true) Integer pageNum, |
||||
@RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { |
||||
try { |
||||
|
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("orderNo", orderNo); |
||||
map.put("userPhone", userPhone); |
||||
map.put("type", type); |
||||
map.put("status", status); |
||||
map.put("goodsName", goodsName); |
||||
map.put("createTimeS", createTimeS); |
||||
map.put("createTimeE", createTimeE); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderList(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,116 @@ |
||||
package com.hfkj.controller.cornucopia; |
||||
|
||||
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.ResponseMsgUtil; |
||||
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 io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
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 javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.HashMap; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/cornucopia") |
||||
@Api(value="聚宝盆管理") |
||||
public class CornucopiaController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CornucopiaController.class); |
||||
|
||||
@Resource |
||||
private BsCornucopiaConfigService cornucopiaConfigService; |
||||
|
||||
@Resource |
||||
private BsCornucopiaPoolService cornucopiaPoolService; |
||||
|
||||
@Resource |
||||
private BsCornucopiaLotteryRecordService cornucopiaLotteryRecordService; |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
|
||||
@RequestMapping(value="/getCornucopiaConfig",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询聚宝盆配置参数列表") |
||||
public ResponseData getCornucopiaConfig() { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(cornucopiaConfigService.queryAllList(new HashMap<>())); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/investmentCornucopia",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "投入聚宝盆") |
||||
public ResponseData investmentCornucopia(@RequestBody JSONObject body, HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
|
||||
if (body == null|| |
||||
body.getInteger("type") == null || |
||||
body.getBigDecimal("goldCoin") == null |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
cornucopiaPoolService.investmentCornucopia(body.getInteger("type") , userModel.getAccount().getId() , userModel.getAccount().getUserName() , body.getBigDecimal("goldCoin")); |
||||
|
||||
return ResponseMsgUtil.success("投入成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/recoveryGoldCoin",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "回收元宝") |
||||
public ResponseData recoveryCornucopia(@RequestBody JSONObject body, HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
|
||||
if (body == null|| |
||||
body.getInteger("type") == null || |
||||
body.getBigDecimal("goldCoin") == null |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
cornucopiaPoolService.investmentCornucopia(body.getInteger("type") , userModel.getAccount().getId() , userModel.getAccount().getUserName() , body.getBigDecimal("goldCoin")); |
||||
|
||||
return ResponseMsgUtil.success("投入成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,106 @@ |
||||
package com.hfkj.controller.order; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
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.ResponseMsgUtil; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.model.UserSessionObject; |
||||
import com.hfkj.service.order.BsOrderService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/order") |
||||
@Api(value="订单管理") |
||||
public class BsOrderController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BsOrderController.class); |
||||
|
||||
@Resource |
||||
private BsOrderService orderService; |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private BsOrderService bsOrderService; |
||||
|
||||
@RequestMapping(value="/getOrderList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询列表") |
||||
public ResponseData getOrderList(@RequestParam(value = "orderNo" , required = false) String orderNo, |
||||
@RequestParam(value = "type" , required = false) Integer type, |
||||
@RequestParam(value = "status" , required = false) Integer status, |
||||
@RequestParam(value = "userPhone" , required = false) String userPhone, |
||||
@RequestParam(value = "goodsName" , required = false) String goodsName, |
||||
@RequestParam(value = "createTimeS" , required = false) Long createTimeS, |
||||
@RequestParam(value = "createTimeE" , required = false) Long createTimeE, |
||||
@RequestParam(value = "pageNum" , required = true) Integer pageNum, |
||||
@RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
|
||||
|
||||
|
||||
map.put("orderNo", orderNo); |
||||
map.put("userPhone", userPhone); |
||||
map.put("type", type); |
||||
map.put("userId", userModel.getAccount().getId()); |
||||
map.put("status", status); |
||||
map.put("goodsName", goodsName); |
||||
map.put("createTimeS", createTimeS); |
||||
map.put("createTimeE", createTimeE); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderList(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/create",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "创建订单") |
||||
public ResponseData create(@RequestBody JSONObject jsonObject) { |
||||
try { |
||||
|
||||
// 用户session
|
||||
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
||||
if (userSession == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); |
||||
} |
||||
|
||||
jsonObject.put("userId", userSession.getUser().getId()); |
||||
jsonObject.put("userPhone", userSession.getUser().getPhone()); |
||||
|
||||
return ResponseMsgUtil.success(bsOrderService.create(jsonObject)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,113 @@ |
||||
package com.hfkj.schedule; |
||||
|
||||
import com.hfkj.common.security.SessionObject; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.ListUtil; |
||||
import com.hfkj.entity.BsUser; |
||||
import com.hfkj.model.UserSessionObject; |
||||
import com.hfkj.service.user.BsUserGradeService; |
||||
import com.hfkj.service.user.BsUserService; |
||||
import com.hfkj.service.user.impl.BsUserServiceImpl; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.concurrent.ArrayBlockingQueue; |
||||
import java.util.concurrent.CountDownLatch; |
||||
import java.util.concurrent.ThreadPoolExecutor; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
/** |
||||
* @className: UserGradeSchedule |
||||
* @author: HuRui |
||||
* @date: 2024/9/27 |
||||
**/ |
||||
@Component |
||||
public class UserGradeSchedule { |
||||
@Resource |
||||
private BsUserService userService; |
||||
@Resource |
||||
private BsUserGradeService userGradeService; |
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Scheduled(cron = "0 0 5 * * ?") // 每日凌晨05:00:00 执行一次
|
||||
public void promote() { |
||||
try { |
||||
// 用户数据
|
||||
List<BsUser> userList = userService.getList(new HashMap<>()); |
||||
|
||||
// 设备核心数目
|
||||
int processorsNum = Runtime.getRuntime().availableProcessors(); |
||||
|
||||
Long startTime = System.currentTimeMillis(); |
||||
System.out.println("本次更新任务开始"); |
||||
// 初始化线程池
|
||||
ThreadPoolExecutor threadPool = new ThreadPoolExecutor( |
||||
processorsNum * 2, |
||||
processorsNum * 2, |
||||
4, |
||||
TimeUnit.SECONDS, |
||||
new ArrayBlockingQueue(processorsNum * 2 * 10), |
||||
new ThreadPoolExecutor.DiscardPolicy()); |
||||
|
||||
// 大集合拆分成N个小集合,然后用多线程去处理数据,确保不会因为数据量过大导致执行过慢
|
||||
List<List<BsUser>> splitNList = ListUtil.splitList(userList, 200); |
||||
// 记录单个任务的执行次数
|
||||
CountDownLatch countDownLatch = new CountDownLatch(splitNList.size()); |
||||
// 对拆分的集合进行批量处理, 先拆分的集合, 再多线程执行
|
||||
for (List<BsUser> singleList : splitNList) { |
||||
// 线程池执行
|
||||
threadPool.execute(new Thread(new Runnable(){ |
||||
@Override |
||||
public void run() { |
||||
//模拟执行时间
|
||||
System.out.println("当前线程:"+Thread.currentThread().getName()); |
||||
try { |
||||
for (BsUser user : singleList) { |
||||
try { |
||||
// 等级晋升
|
||||
userGradeService.promote(user.getId()); |
||||
|
||||
// 更新session
|
||||
UserSessionObject session = new UserSessionObject(); |
||||
session.setUser(userService.getUser(user.getId())); |
||||
SessionObject sessionObject = new SessionObject(BsUserServiceImpl.userToken(user.getId()), session); |
||||
userCenter.save(sessionObject); |
||||
|
||||
} catch (Exception e) { |
||||
System.out.println("更新油站失败"); |
||||
} |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
System.out.println("更新油站出现异常"); |
||||
System.out.println(e.getMessage()); |
||||
} finally { |
||||
// 任务个数 - 1, 直至为0时唤醒await()
|
||||
countDownLatch.countDown(); |
||||
} |
||||
} |
||||
})); |
||||
} |
||||
try { |
||||
// 让当前线程处于阻塞状态,直到锁存器计数为零
|
||||
countDownLatch.await(); |
||||
} catch (Exception e) { |
||||
System.out.println("系统出现异常"); |
||||
} |
||||
Long endTime = System.currentTimeMillis(); |
||||
Long useTime = endTime - startTime; |
||||
System.out.println("本次更新任务结束,共计用时"+useTime+"毫秒"); |
||||
|
||||
} catch (Exception e) { |
||||
System.out.println("更新价格失败!!!"); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,56 @@ |
||||
package com.hfkj.common.utils; |
||||
|
||||
import com.alibaba.excel.util.CollectionUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 集合工具类 |
||||
* @className: ListUtil |
||||
* @author: HuRui |
||||
* @date: 2024/9/27 |
||||
**/ |
||||
public class ListUtil { |
||||
|
||||
/** |
||||
* 拆分集合 |
||||
* |
||||
* @param <T> 泛型对象 |
||||
* @param resList 需要拆分的集合 |
||||
* @param subListLength 每个子集合的元素个数 |
||||
* @return 返回拆分后的各个集合组成的列表 |
||||
**/ |
||||
public static <T> List<List<T>> splitList(List<T> resList, int subListLength) { |
||||
if (CollectionUtils.isEmpty(resList) || subListLength <= 0) { |
||||
return new ArrayList<>(); |
||||
} |
||||
List<List<T>> ret = new ArrayList<>(); |
||||
int size = resList.size(); |
||||
if (size <= subListLength) { |
||||
// 数据量不足 subListLength 指定的大小
|
||||
ret.add(resList); |
||||
} else { |
||||
int pre = size / subListLength; |
||||
int last = size % subListLength; |
||||
// 前面pre个集合,每个大小都是 subListLength 个元素
|
||||
for (int i = 0; i < pre; i++) { |
||||
List<T> itemList = new ArrayList<>(subListLength); |
||||
for (int j = 0; j < subListLength; j++) { |
||||
itemList.add(resList.get(i * subListLength + j)); |
||||
} |
||||
ret.add(itemList); |
||||
} |
||||
|
||||
// last的进行处理
|
||||
if (last > 0) { |
||||
List<T> itemList = new ArrayList<>(last); |
||||
for (int i = 0; i < last; i++) { |
||||
itemList.add(resList.get(pre * subListLength + i)); |
||||
} |
||||
ret.add(itemList); |
||||
} |
||||
} |
||||
return ret; |
||||
} |
||||
} |
@ -0,0 +1,68 @@ |
||||
package com.hfkj.service.cornucopia; |
||||
|
||||
import com.hfkj.entity.BsCornucopiaConfig; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface BsCornucopiaConfigService { |
||||
|
||||
/** |
||||
* @MethodName create |
||||
* @Description: 创建 |
||||
* @param cornucopiaConfig |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
void create(BsCornucopiaConfig cornucopiaConfig); |
||||
|
||||
/** |
||||
* @MethodName update |
||||
* @Description: 更新 |
||||
* @param cornucopiaConfig |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
void edit(BsCornucopiaConfig cornucopiaConfig); |
||||
|
||||
/** |
||||
* @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.BsCornucopiaConfig |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
BsCornucopiaConfig queryDetail(Long id); |
||||
|
||||
/** |
||||
* @MethodName queryDetail |
||||
* @Description: |
||||
* @param type |
||||
* @return: com.hfkj.entity.BsCornucopiaConfig |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/27 下午2:28 |
||||
*/ |
||||
BsCornucopiaConfig queryDetail(Integer type); |
||||
|
||||
/** |
||||
* @MethodName queryAllList |
||||
* @Description: map |
||||
* @param |
||||
* @return: java.util.List<com.hfkj.entity.BsCornucopiaConfig> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/27 上午11:42 |
||||
*/ |
||||
List<BsCornucopiaConfig> queryAllList(Map<String , Object> map); |
||||
|
||||
} |
@ -0,0 +1,57 @@ |
||||
package com.hfkj.service.cornucopia; |
||||
|
||||
import com.hfkj.entity.BsCornucopiaLotteryRecord; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface BsCornucopiaLotteryRecordService { |
||||
|
||||
/** |
||||
* @MethodName create |
||||
* @Description: 创建 |
||||
* @param cornucopiaLotteryRecord |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
void create(BsCornucopiaLotteryRecord cornucopiaLotteryRecord); |
||||
|
||||
/** |
||||
* @MethodName update |
||||
* @Description: 更新 |
||||
* @param cornucopiaLotteryRecord |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
void update(BsCornucopiaLotteryRecord cornucopiaLotteryRecord); |
||||
|
||||
/** |
||||
* @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.BsCornucopiaLotteryRecord |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
BsCornucopiaLotteryRecord queryDetail(Long id); |
||||
|
||||
/** |
||||
* @MethodName queryAllList |
||||
* @Description: map |
||||
* @param |
||||
* @return: java.util.List<com.hfkj.entity.BsCornucopiaLotteryRecord> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/27 上午11:42 |
||||
*/ |
||||
List<BsCornucopiaLotteryRecord> queryAllList(Map<String , Object> map); |
||||
} |
@ -0,0 +1,101 @@ |
||||
package com.hfkj.service.cornucopia; |
||||
|
||||
import com.hfkj.entity.BsCornucopiaLotteryRecord; |
||||
import com.hfkj.entity.BsCornucopiaPool; |
||||
import com.hfkj.entity.BsCornucopiaPoolRecord; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface BsCornucopiaPoolService { |
||||
|
||||
/** |
||||
* @MethodName create |
||||
* @Description: 创建 |
||||
* @param cornucopiaPool |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
void edit(BsCornucopiaPool cornucopiaPool); |
||||
|
||||
/** |
||||
* @MethodName update |
||||
* @Description: 更新 |
||||
* @param cornucopiaPool |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
void update(BsCornucopiaPool cornucopiaPool); |
||||
|
||||
/** |
||||
* @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.BsCornucopiaPool |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
BsCornucopiaPool queryDetail(Long id); |
||||
|
||||
/** |
||||
* @MethodName queryDetail |
||||
* @Description: |
||||
* @param userId |
||||
* @param type |
||||
* @return: com.hfkj.entity.BsCornucopiaPool |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/27 下午4:02 |
||||
*/ |
||||
BsCornucopiaPool queryDetail(Long userId , Integer type); |
||||
|
||||
/** |
||||
* @MethodName queryAllList |
||||
* @Description: map |
||||
* @param |
||||
* @return: java.util.List<com.hfkj.entity.BsCornucopiaPool> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/27 上午11:42 |
||||
*/ |
||||
List<BsCornucopiaPool> queryAllList(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @MethodName investmentCornucopia |
||||
* @Description: 投入聚宝盆 |
||||
* @param type |
||||
* @param userId |
||||
* @param goldCoin |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/27 下午2:50 |
||||
*/ |
||||
void investmentCornucopia(Integer type , Long userId , String userName , BigDecimal goldCoin) throws Exception; |
||||
|
||||
/** |
||||
* @MethodName create |
||||
* @Description: 创建 |
||||
* @param cornucopiaPoolRecord |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/7/4 下午2:30 |
||||
*/ |
||||
void create(BsCornucopiaPoolRecord cornucopiaPoolRecord); |
||||
|
||||
/** |
||||
* @MethodName queryAllList |
||||
* @Description: map |
||||
* @param |
||||
* @return: java.util.List<com.hfkj.entity.BsCornucopiaPool> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/27 上午11:42 |
||||
*/ |
||||
List<BsCornucopiaPoolRecord> queryAllListRecord(Map<String , Object> map); |
||||
} |
@ -0,0 +1,84 @@ |
||||
package com.hfkj.service.cornucopia.Impl; |
||||
|
||||
import com.hfkj.dao.BsCornucopiaConfigMapper; |
||||
import com.hfkj.entity.BsCornucopiaConfig; |
||||
import com.hfkj.entity.BsCornucopiaConfigExample; |
||||
import com.hfkj.service.cornucopia.BsCornucopiaConfigService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Collections; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("bsCornucopiaConfigService") |
||||
public class BsCornucopiaConfigServiceImpl implements BsCornucopiaConfigService { |
||||
|
||||
@Resource |
||||
private BsCornucopiaConfigMapper bsCornucopiaConfigMapper; |
||||
|
||||
@Override |
||||
public void create(BsCornucopiaConfig cornucopiaConfig) { |
||||
bsCornucopiaConfigMapper.insert(cornucopiaConfig); |
||||
} |
||||
|
||||
@Override |
||||
public void edit(BsCornucopiaConfig cornucopiaConfig) { |
||||
|
||||
if (cornucopiaConfig.getId() == null) { |
||||
bsCornucopiaConfigMapper.insert(cornucopiaConfig); |
||||
} else { |
||||
bsCornucopiaConfigMapper.updateByPrimaryKey(cornucopiaConfig); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void delete(Long id, Boolean fullDelete) { |
||||
if (fullDelete) { |
||||
bsCornucopiaConfigMapper.deleteByPrimaryKey(id); |
||||
} else { |
||||
BsCornucopiaConfig cornucopiaConfig = queryDetail(id); |
||||
cornucopiaConfig.setStatus(0); |
||||
cornucopiaConfig.setUpdateTime(new Date()); |
||||
bsCornucopiaConfigMapper.updateByPrimaryKey(cornucopiaConfig); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public BsCornucopiaConfig queryDetail(Long id) { |
||||
return bsCornucopiaConfigMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public BsCornucopiaConfig queryDetail(Integer type) { |
||||
BsCornucopiaConfigExample example = new BsCornucopiaConfigExample(); |
||||
BsCornucopiaConfigExample.Criteria criteria = example.createCriteria(); |
||||
criteria.andTypeEqualTo(type); |
||||
|
||||
List<BsCornucopiaConfig> list = bsCornucopiaConfigMapper.selectByExample(example); |
||||
|
||||
if (!list.isEmpty()) { |
||||
return list.get(0); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public List<BsCornucopiaConfig> queryAllList(Map<String, Object> map) { |
||||
BsCornucopiaConfigExample example = new BsCornucopiaConfigExample(); |
||||
BsCornucopiaConfigExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getInteger(map, "type") != null) { |
||||
criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); |
||||
} |
||||
|
||||
if (MapUtils.getString(map, "name") != null) { |
||||
criteria.andNameLike("%" + MapUtils.getString(map, "name") + "%"); |
||||
} |
||||
|
||||
return bsCornucopiaConfigMapper.selectByExample(example); |
||||
} |
||||
} |
@ -0,0 +1,67 @@ |
||||
package com.hfkj.service.cornucopia.Impl; |
||||
|
||||
import com.hfkj.dao.BsCornucopiaLotteryRecordMapper; |
||||
import com.hfkj.entity.BsCornucopiaConfig; |
||||
import com.hfkj.entity.BsCornucopiaLotteryRecord; |
||||
import com.hfkj.entity.BsCornucopiaLotteryRecordExample; |
||||
import com.hfkj.service.cornucopia.BsCornucopiaLotteryRecordService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Collections; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("bsCornucopiaLotteryRecordService") |
||||
public class BsCornucopiaLotteryRecordServiceImpl implements BsCornucopiaLotteryRecordService { |
||||
|
||||
|
||||
@Resource |
||||
private BsCornucopiaLotteryRecordMapper bsCornucopiaLotteryRecordMapper; |
||||
|
||||
@Override |
||||
public void create(BsCornucopiaLotteryRecord cornucopiaLotteryRecord) { |
||||
bsCornucopiaLotteryRecordMapper.insert(cornucopiaLotteryRecord); |
||||
} |
||||
|
||||
@Override |
||||
public void update(BsCornucopiaLotteryRecord cornucopiaLotteryRecord) { |
||||
bsCornucopiaLotteryRecordMapper.updateByPrimaryKeySelective(cornucopiaLotteryRecord); |
||||
} |
||||
|
||||
@Override |
||||
public void delete(Long id, Boolean fullDelete) { |
||||
if (fullDelete) { |
||||
bsCornucopiaLotteryRecordMapper.deleteByPrimaryKey(id); |
||||
} else { |
||||
BsCornucopiaLotteryRecord cornucopiaLotteryRecord = queryDetail(id); |
||||
cornucopiaLotteryRecord.setStatus(0); |
||||
cornucopiaLotteryRecord.setUpdateTime(new Date()); |
||||
update(cornucopiaLotteryRecord); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public BsCornucopiaLotteryRecord queryDetail(Long id) { |
||||
return bsCornucopiaLotteryRecordMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<BsCornucopiaLotteryRecord> queryAllList(Map<String, Object> map) { |
||||
BsCornucopiaLotteryRecordExample example = new BsCornucopiaLotteryRecordExample(); |
||||
BsCornucopiaLotteryRecordExample.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") + "%"); |
||||
} |
||||
|
||||
|
||||
return bsCornucopiaLotteryRecordMapper.selectByExample(example); |
||||
} |
||||
} |
@ -0,0 +1,212 @@ |
||||
package com.hfkj.service.cornucopia.Impl; |
||||
|
||||
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.dao.BsCornucopiaPoolMapper; |
||||
import com.hfkj.dao.BsCornucopiaPoolRecordMapper; |
||||
import com.hfkj.entity.*; |
||||
import com.hfkj.service.cornucopia.BsCornucopiaPoolService; |
||||
import com.hfkj.service.user.BsUserAccountService; |
||||
import com.hfkj.sysenum.cornucopia.CornucopiaEnum; |
||||
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; |
||||
import com.hfkj.sysenum.user.UserAccountRecordTypeEnum; |
||||
import com.hfkj.sysenum.user.UserGradeEnum; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.util.*; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
@Service("bsCornucopiaPoolService") |
||||
public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService { |
||||
|
||||
|
||||
@Resource |
||||
private BsCornucopiaPoolMapper bsCornucopiaPoolMapper; |
||||
|
||||
@Resource |
||||
private BsCornucopiaPoolRecordMapper cornucopiaPoolRecordMapper; |
||||
|
||||
@Resource |
||||
private BsUserAccountService userAccountService; |
||||
|
||||
@Resource |
||||
private RedisTemplate<String,Object> redisTemplate; |
||||
private final String LOCK_KEY = "POOL_TRADE_LOCK_"; |
||||
|
||||
@Override |
||||
public void edit(BsCornucopiaPool cornucopiaPool) { |
||||
if (cornucopiaPool.getId() == null) { |
||||
bsCornucopiaPoolMapper.insert(cornucopiaPool); |
||||
} else { |
||||
bsCornucopiaPoolMapper.updateByPrimaryKeySelective(cornucopiaPool); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void update(BsCornucopiaPool cornucopiaPool) { |
||||
bsCornucopiaPoolMapper.updateByPrimaryKeySelective(cornucopiaPool); |
||||
} |
||||
|
||||
@Override |
||||
public void delete(Long id, Boolean fullDelete) { |
||||
if (fullDelete) { |
||||
bsCornucopiaPoolMapper.deleteByPrimaryKey(id); |
||||
} else { |
||||
BsCornucopiaPool cornucopiaPool = queryDetail(id); |
||||
cornucopiaPool.setStatus(0); |
||||
cornucopiaPool.setUpdateTime(new Date()); |
||||
update(cornucopiaPool); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public BsCornucopiaPool queryDetail(Long id) { |
||||
return bsCornucopiaPoolMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public BsCornucopiaPool queryDetail(Long userId, Integer type) { |
||||
BsCornucopiaPoolExample example = new BsCornucopiaPoolExample(); |
||||
BsCornucopiaPoolExample.Criteria criteria = example.createCriteria(); |
||||
criteria.andUserIdEqualTo(userId).andTypeEqualTo(type); |
||||
|
||||
List<BsCornucopiaPool> list = bsCornucopiaPoolMapper.selectByExample(example); |
||||
|
||||
if (!list.isEmpty()) { |
||||
return list.get(0); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public List<BsCornucopiaPool> queryAllList(Map<String, Object> map) { |
||||
|
||||
BsCornucopiaPoolExample example = new BsCornucopiaPoolExample(); |
||||
BsCornucopiaPoolExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getInteger(map, "type") != null) { |
||||
criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); |
||||
} |
||||
|
||||
if (MapUtils.getString(map, "userName") != null) { |
||||
criteria.andUserNameLike("%" + MapUtils.getString(map, "userName") + "%"); |
||||
} |
||||
if (MapUtils.getLong(map, "userId") != null) { |
||||
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); |
||||
} |
||||
if (MapUtils.getInteger(map, "status") != null) { |
||||
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
||||
} |
||||
|
||||
return bsCornucopiaPoolMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class}) |
||||
public void investmentCornucopia(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); |
||||
// 查询账户
|
||||
BsUserAccount userAccount = userAccountService.getAccount(userId); |
||||
// 判断当前账户余额是否足够投入 true 不够 false 够
|
||||
Boolean isMeet = userAccount.getGoldCoin().compareTo(goldCoin) < 0; |
||||
|
||||
// 判断是否充足
|
||||
if (isMeet) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "元宝还差那么一点点哦!"); |
||||
} |
||||
// 插入投入记录
|
||||
BsCornucopiaPoolRecord record = new BsCornucopiaPoolRecord(); |
||||
record.setUserId(userId); |
||||
record.setType(type); |
||||
record.setGoldCoin(goldCoin); |
||||
record.setStatus(1); |
||||
record.setCreateTime(new Date()); |
||||
record.setUpdateTime(new Date()); |
||||
record.setUserName(userName); |
||||
create(record); |
||||
|
||||
// 查询是否第一次投入
|
||||
BsCornucopiaPool cornucopiaPool = queryDetail(userId , type); |
||||
|
||||
// 判断是否存在
|
||||
if (cornucopiaPool != null) { |
||||
cornucopiaPool.setGoldCoin(cornucopiaPool.getGoldCoin().add(goldCoin)); |
||||
} else { |
||||
// 插入用户投入金额
|
||||
cornucopiaPool = new BsCornucopiaPool(); |
||||
cornucopiaPool.setUserId(userId); |
||||
cornucopiaPool.setType(type); |
||||
cornucopiaPool.setGoldCoin(goldCoin); |
||||
cornucopiaPool.setStatus(1); |
||||
cornucopiaPool.setCreateTime(new Date()); |
||||
cornucopiaPool.setUpdateTime(new Date()); |
||||
cornucopiaPool.setUserName(userName); |
||||
} |
||||
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.consume(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); |
||||
investmentCornucopia(type , userId , userName ,goldCoin); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void create(BsCornucopiaPoolRecord cornucopiaPoolRecord) { |
||||
cornucopiaPoolRecordMapper.insert(cornucopiaPoolRecord); |
||||
} |
||||
|
||||
@Override |
||||
public List<BsCornucopiaPoolRecord> queryAllListRecord(Map<String, Object> map) { |
||||
|
||||
BsCornucopiaPoolRecordExample example = new BsCornucopiaPoolRecordExample(); |
||||
BsCornucopiaPoolRecordExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getInteger(map, "type") != null) { |
||||
criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); |
||||
} |
||||
if (MapUtils.getString(map, "userName") != null) { |
||||
criteria.andUserNameLike("%" + MapUtils.getString(map, "userName") + "%"); |
||||
} |
||||
if (MapUtils.getLong(map, "userId") != null) { |
||||
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); |
||||
} |
||||
if (MapUtils.getInteger(map, "status") != null) { |
||||
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
||||
} |
||||
return cornucopiaPoolRecordMapper.selectByExample(example); |
||||
} |
||||
} |
@ -0,0 +1,46 @@ |
||||
package com.hfkj.sysenum.cornucopia; |
||||
|
||||
import com.hfkj.sysenum.user.UserGradeEnum; |
||||
import lombok.Getter; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @className: UserStatusEnum |
||||
* @author: HuRui |
||||
* @date: 2024/5/6 |
||||
**/ |
||||
@Getter |
||||
public enum CornucopiaEnum { |
||||
/** |
||||
* 删除 |
||||
*/ |
||||
type1(1, "金聚宝盆"), |
||||
|
||||
/** |
||||
* 正常 |
||||
*/ |
||||
type2(2, "玉聚宝盆"); |
||||
|
||||
private int code; |
||||
|
||||
private String name; |
||||
|
||||
|
||||
CornucopiaEnum(int code, String name) { |
||||
this.code = code; |
||||
this.name = name; |
||||
} |
||||
|
||||
/** |
||||
* 查询数据 |
||||
* @param code |
||||
* @return |
||||
*/ |
||||
public static CornucopiaEnum getDataByType(Integer code) { |
||||
for (CornucopiaEnum ele : values()) { |
||||
if (Objects.equals(code,ele.getCode())) return ele; |
||||
} |
||||
return null; |
||||
} |
||||
} |
Loading…
Reference in new issue