master
parent
87fb375349
commit
16811aca02
@ -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,91 @@ |
||||
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() , 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,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,90 @@ |
||||
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 create(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 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 , 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,157 @@ |
||||
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.user.UserAccountRecordTypeEnum; |
||||
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.Collections; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
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 create(BsCornucopiaPool cornucopiaPool) { |
||||
bsCornucopiaPoolMapper.insert(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 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, 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) { |
||||
|
||||
} |
||||
|
||||
|
||||
} 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 ,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); |
||||
} |
||||
} |
Loading…
Reference in new issue