袁野 1 month ago
commit d0e9329ccb
  1. 101
      bweb/src/main/java/com/hfkj/controller/cornucopia/CornucopiaController.java
  2. 69
      bweb/src/main/java/com/hfkj/controller/order/BsOrderController.java
  3. 26
      cweb/src/main/java/com/hfkj/controller/ClientController.java
  4. 35
      cweb/src/main/java/com/hfkj/controller/GoodsController.java
  5. 190
      cweb/src/main/java/com/hfkj/controller/UserGradeController.java
  6. 29
      cweb/src/main/java/com/hfkj/controller/UserTeamController.java
  7. 116
      cweb/src/main/java/com/hfkj/controller/cornucopia/CornucopiaController.java
  8. 106
      cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java
  9. 113
      schedule/src/main/java/com/hfkj/schedule/UserGradeSchedule.java
  10. 56
      service/src/main/java/com/hfkj/common/utils/ListUtil.java
  11. 68
      service/src/main/java/com/hfkj/service/cornucopia/BsCornucopiaConfigService.java
  12. 57
      service/src/main/java/com/hfkj/service/cornucopia/BsCornucopiaLotteryRecordService.java
  13. 101
      service/src/main/java/com/hfkj/service/cornucopia/BsCornucopiaPoolService.java
  14. 84
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaConfigServiceImpl.java
  15. 67
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaLotteryRecordServiceImpl.java
  16. 212
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaPoolServiceImpl.java
  17. 9
      service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java
  18. 13
      service/src/main/java/com/hfkj/service/order/BsOrderService.java
  19. 46
      service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java
  20. 19
      service/src/main/java/com/hfkj/service/order/OrderBusinessService.java
  21. 7
      service/src/main/java/com/hfkj/service/pdd/PddService.java
  22. 30
      service/src/main/java/com/hfkj/service/user/BsUserGradeService.java
  23. 7
      service/src/main/java/com/hfkj/service/user/BsUserService.java
  24. 7
      service/src/main/java/com/hfkj/service/user/impl/BsUserAccountServiceImpl.java
  25. 124
      service/src/main/java/com/hfkj/service/user/impl/BsUserGradeServiceImpl.java
  26. 13
      service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java
  27. 46
      service/src/main/java/com/hfkj/sysenum/cornucopia/CornucopiaEnum.java
  28. 4
      service/src/main/java/com/hfkj/sysenum/user/UserAccountRecordSourceTypeEnum.java

@ -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);
}
}
}

@ -17,10 +17,7 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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;
@ -81,6 +78,27 @@ public class ClientController {
}
}
@RequestMapping(value = "/smsLogin", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "登录并注册")
public ResponseData smsLogin(@RequestParam(value = "phone" , required = true) String phone) {
try {
// 校验手机号格式
if (!MemberValidateUtil.validatePhone(phone)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
}
return ResponseMsgUtil.success(userService.login(phone, UserLoginType.SMS, new HashMap<>(), null));
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/loginOut",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "退出登录")

@ -38,8 +38,7 @@ public class GoodsController {
@Autowired
private UserCenter userCenter;
@Resource
private BsOrderService bsOrderService;
@RequestMapping(value="/goodsList",method = RequestMethod.GET)
@ResponseBody
@ -63,11 +62,16 @@ public class GoodsController {
goodsList = goodsDataService.goodsModelTaoBaoList(jsonObject);
} else if (type == 2) {
JSONObject object = PddService.authority();
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
Map<String , Object> mapUser = new HashMap<>();
mapUser.put("uid", userSession.getUser().getId());
JSONObject object = PddService.authority(mapUser.toString());
boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
if (generateAuthorityUrl && title != null) {
goodsList = new ArrayList<>();
JSONObject jsonObject = PddService.promotion();
JSONObject jsonObject = PddService.promotion(mapUser.toString());
JSONObject promotion = jsonObject.getJSONObject("rpPromotionUrlGenerateResponse").getJSONArray("urlList").getJSONObject(0);
GoodsModel goodsModel = new GoodsModel();
goodsModel.setPddUrl(promotion);
@ -77,7 +81,7 @@ public class GoodsController {
if (pageSize < 10) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "pageSize的取值范围是10-100!");
}
JSONObject jsonObject = PddService.syncInvoke(title , pageNo , pageSize);
JSONObject jsonObject = PddService.syncInvoke(title , pageNo , pageSize , mapUser.toString());
goodsList = goodsDataService.goodsModelPddList(jsonObject);
}
@ -93,28 +97,7 @@ public class GoodsController {
}
}
@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);
}
}
@RequestMapping(value="/createCommand",method = RequestMethod.GET)
@ResponseBody

@ -4,13 +4,21 @@ 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.MemberValidateUtil;
import com.hfkj.common.utils.RedisUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsUser;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.user.BsUserAccountRecordService;
import com.hfkj.service.user.BsUserAccountService;
import com.hfkj.service.user.BsUserGradeService;
import com.hfkj.service.user.BsUserService;
import com.hfkj.service.user.impl.BsUserServiceImpl;
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum;
import com.hfkj.sysenum.user.UserGradeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -22,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
@ -34,39 +43,29 @@ import java.util.Map;
@RequestMapping(value="/userGrade")
@Api(value="客户端业务")
public class UserGradeController {
@Autowired
private UserCenter userCenter;
@Resource
private BsUserService userService;
@Resource
private RedisUtil redisUtil;
@Autowired
private UserCenter userCenter;
private BsUserGradeService userGradeService;
@RequestMapping(value = "/getUser", method = RequestMethod.GET)
@RequestMapping(value = "/promote", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询用户信息")
public ResponseData getUser() {
@ApiOperation(value = "等级晋升")
public ResponseData promote() {
try {
Map<String,Object> param = new HashMap<>();
// 用户信息
param.put("user", userCenter.getSessionModel(UserSessionObject.class));
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
return ResponseMsgUtil.success(param);
// 等级晋升
userGradeService.promote(userSession.getUser().getId());
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
// 更新session
UserSessionObject session = new UserSessionObject();
session.setUser(userService.getUser(userSession.getUser().getId()));
SessionObject sessionObject = new SessionObject(BsUserServiceImpl.userToken(userSession.getUser().getId()), session);
userCenter.save(sessionObject);
@RequestMapping(value = "/updateWechat", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改用户微信号")
public ResponseData updateWechat(@RequestBody JSONObject body) {
try {
if (body == null || StringUtils.isBlank(body.getString("wechatNum"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
userService.updateWechatNum(userSession.getUser().getId(), body.getString("wechatNum"));
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
@ -74,145 +73,60 @@ public class UserGradeController {
}
}
@RequestMapping(value = "/bindPhone", method = RequestMethod.POST)
@RequestMapping(value = "/payGrade2", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "绑定手机号")
public ResponseData bindPhone(@RequestBody JSONObject body) {
@ApiOperation(value = "购买【优淘会员】等级")
public ResponseData payGrade2() {
try {
if (body == null
|| StringUtils.isBlank(body.getString("phone"))
|| StringUtils.isBlank(body.getString("smsCode"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (StringUtils.isNotBlank(userSession.getUser().getPhone())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已绑定");
}
String phone = body.getString("phone");
// 校验手机号格式
if (!MemberValidateUtil.validatePhone(phone)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
}
if (StringUtils.isBlank(body.getString("smsCode"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码");
}
if (userService.getUser(phone) != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已被绑定");
}
// 手机号的验证码
Object phoneCodeObject = redisUtil.get("SMS_BIND_PHONE_CODE:" + phone);
if (phoneCodeObject == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误");
}
if (!body.getString("smsCode").equals(phoneCodeObject.toString())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误");
}
redisUtil.del("SMS_BIND_PHONE_CODE:" + phone);
// 更新手机号
userService.updatePhone(userSession.getUser().getId(), body.getString("phone"));
// 购买
userGradeService.payGrade2(userSession.getUser().getId());
// 更新session
UserSessionObject session = new UserSessionObject();
session.setUser(userService.getUser(userSession.getUser().getId()));
SessionObject sessionObject = new SessionObject(BsUserServiceImpl.userToken(userSession.getUser().getId()), session);
userCenter.save(sessionObject);
return ResponseMsgUtil.success(userCenter.getSessionModel(UserSessionObject.class));
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/bindInviteUser", method = RequestMethod.POST)
@RequestMapping(value = "/queryProgress", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "绑定邀请人Id")
public ResponseData bindInviteUser(@RequestBody JSONObject body) {
@ApiOperation(value = "查询升级条件进度")
public ResponseData queryProgress() {
try {
if (body == null || body.getLong("inviteUseId") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
// 绑定邀请人
userService.bindInviteUser(userSession.getUser().getId(), body.getLong("inviteUseId"));
// 查询用户
BsUser user = userService.getUser(userSession.getUser().getId());
return ResponseMsgUtil.success(userCenter.getSessionModel(UserSessionObject.class));
Map<String,Object> map = new HashMap<>();
if (UserGradeEnum.grade1.getCode().equals(user.getGrade())) {
// 晋升优淘会员
map = userGradeService.promoteGrade2Progress(user.getId());
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
} else if (UserGradeEnum.grade2.getCode().equals(user.getGrade())) {
// 晋升团长渠道
map = userGradeService.promoteGrade3Progress(user.getId());
@RequestMapping(value = "/verifyUpdPhoneSmsCode", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "验证修改手机号验证码")
public ResponseData verifyUpdPhoneSmsCode(@RequestBody JSONObject body) {
try {
if (body == null
|| StringUtils.isBlank(body.getString("phone"))
|| StringUtils.isBlank(body.getString("smsCode"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
String phone = body.getString("phone");
// 手机号的验证码
Object phoneCodeObject = redisUtil.get("SMS_UPDATE_PHONE_CODE:" + phone);
if (phoneCodeObject == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误或已失效");
}
if (!body.getString("smsCode").equals(phoneCodeObject.toString())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误或已失效");
} else if (UserGradeEnum.grade3.getCode().equals(user.getGrade())) {
// 晋升渠道进度
map = userGradeService.promoteGrade4Progress(user.getId());
}
redisUtil.del("SMS_UPDATE_PHONE_CODE:" + phone);
return ResponseMsgUtil.success(true);
map.put("currentUserGrade", user.getGrade());
return ResponseMsgUtil.success(map);
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/updatePhone", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改手机号")
public ResponseData updatePhone(@RequestBody JSONObject body) {
try {
if (body == null
|| StringUtils.isBlank(body.getString("newPhone"))
|| StringUtils.isBlank(body.getString("smsCode"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (StringUtils.isBlank(userSession.getUser().getPhone())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户未绑定手机号");
}
String phone = body.getString("newPhone");
if (userSession.getUser().getPhone().equals(phone)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "新手机号与现绑定手机号相同");
}
if (userService.getUser(phone) != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已被绑定");
}
// 校验手机号格式
if (!MemberValidateUtil.validatePhone(phone)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
}
if (StringUtils.isBlank(body.getString("smsCode"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码");
}
// 手机号的验证码
Object phoneCodeObject = redisUtil.get("SMS_UPDATE_PHONE_CODE:" + phone);
if (phoneCodeObject == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误或已失效");
}
if (!body.getString("smsCode").equals(phoneCodeObject.toString())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误或已失效");
}
redisUtil.del("SMS_UPDATE_PHONE_CODE:" + phone);
// 更新手机号
userService.updatePhone(userSession.getUser().getId(), body.getString("newPhone"));
return ResponseMsgUtil.success(userCenter.getSessionModel(UserSessionObject.class));
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
}

@ -59,32 +59,45 @@ public class UserTeamController {
// 团队好友
map.put("teamFriend", subList.stream().filter(o -> o.getRelType().equals(2)).count());
// 活跃情况
Map<String,Object> active = new HashMap<>();
// 今日
Map<String,Object> today = new HashMap<>();
today.put("newFriend", "");
today.put("activeFriend", "");
today.put("newFriend", "0");
today.put("activeFriend", "0");
active.put("today", today);
// 昨日
Map<String,Object> yesterday = new HashMap<>();
yesterday.put("newFriend", "");
yesterday.put("activeFriend", "");
yesterday.put("newFriend", "0");
yesterday.put("activeFriend", "0");
active.put("yesterday", yesterday);
// 本月
Map<String,Object> thisMonth = new HashMap<>();
thisMonth.put("newFriend", "");
thisMonth.put("activeFriend", "");
thisMonth.put("newFriend", "0");
thisMonth.put("activeFriend", "0");
active.put("thisMonth", thisMonth);
// 上月
Map<String,Object> lastMonth = new HashMap<>();
lastMonth.put("newFriend", "");
lastMonth.put("activeFriend", "");
lastMonth.put("newFriend", "0");
lastMonth.put("activeFriend", "0");
active.put("lastMonth", lastMonth);
map.put("active", active);
// 邀请人
if (userSession.getUser().getInviteUserId() != null) {
// 邀请人数据
BsUser inviteUser = userService.getUser(userSession.getUser().getInviteUserId());
if (inviteUser != null) {
inviteUser.setPhone(null);
}
map.put("inviteUser", inviteUser);
} else {
map.put("inviteUser", null);
}
return ResponseMsgUtil.success(map);
} catch (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);
}
}

@ -58,7 +58,7 @@ public class GoodsDataServiceImpl implements GoodsDataService {
// 商品佣金信息
incomeInfoModel = new IncomeInfoModel();
publishInfoModel = new PublishInfoModel();
publishInfoModel.setClickUrl(publish_info.getString("click_url"));
publishInfoModel.setClickUrl("https:" + publish_info.getString("click_url"));
if (publish_info.getString("coupon_share_url") != null) {
publishInfoModel.setCouponShareUrl("https:" + publish_info.getString("coupon_share_url"));
}
@ -182,9 +182,10 @@ public class GoodsDataServiceImpl implements GoodsDataService {
// 价格促销信息
pricePromotionInfoModel = new PricePromotionInfoModel();
pricePromotionInfoModel.setReservePrice(goods.getBigDecimal("minNormalPrice").divide(new BigDecimal(100) , 2 , RoundingMode.DOWN));
pricePromotionInfoModel.setZkFinalPrice(goods.getBigDecimal("minGroupPrice").divide(new BigDecimal(100) , 2 , RoundingMode.DOWN));
pricePromotionInfoModel.setFinalPromotionPrice(pricePromotionInfoModel.getZkFinalPrice());
pricePromotionInfoModel.setFinalPromotionPrice(goods.getBigDecimal("minNormalPrice").divide(new BigDecimal(100) , 2 , RoundingMode.DOWN));
pricePromotionInfoModel.setZkFinalPrice(pricePromotionInfoModel.getFinalPromotionPrice().add(morePromotionModel.getPromotionFee()));
pricePromotionInfoModel.setReservePrice(pricePromotionInfoModel.getZkFinalPrice());
// 插入更多活动优惠
pricePromotionInfoModel.setMorePromotionList(morePromotionModels);

@ -3,6 +3,9 @@ package com.hfkj.service.order;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.entity.BsOrder;
import java.util.List;
import java.util.Map;
/**
* @className: BsOrderService
@ -48,6 +51,16 @@ public interface BsOrderService {
* @Date: 2024/9/24 下午3:08
*/
BsOrder findByOrderNo(String orderNo);
/**
* @MethodName getOrderList
* @Description:
* @param map
* @return: java.util.List<com.hfkj.entity.BsOrder>
* @Author: Sum1Dream
* @Date: 2024/9/26 上午11:31
*/
List<BsOrder> getOrderList(Map<String , Object> map);
}

@ -8,15 +8,13 @@ import com.hfkj.entity.BsOrder;
import com.hfkj.entity.BsOrderExample;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.OrderBusinessService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.OrderUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service("bsOrderService")
public class BsOrderServiceImpl implements BsOrderService {
@ -68,12 +66,13 @@ public class BsOrderServiceImpl implements BsOrderService {
order.setUserPhone(body.getString("phone"));
order.setUserId(body.getLong("userId"));
Map<String , Object> map = new HashMap<>();
JSONObject map = new JSONObject();
map.put("orderNo", order.getOrderNo());
map.put("uid", order.getUserId());
map.put("searchId", body.getString("searchId"));
map.put("goodsSign", body.getString("goodsSign"));
order.setCustomparameters(map.toString());
map.put("url", body.getString("url"));
order.setCustomparameters(map.toJSONString());
order.setGoodsName(body.getString("goodsName"));
order.setType(body.getInteger("type"));
order.setImg(body.getString("img"));
@ -82,7 +81,7 @@ public class BsOrderServiceImpl implements BsOrderService {
// 淘宝订单业务
if (body.getInteger("type") == 1) {
return orderBusinessService.taobaoUrl(order);
}
// 拼多多订单业务
if (body.getInteger("type") == 2) {
@ -114,4 +113,37 @@ public class BsOrderServiceImpl implements BsOrderService {
return (BsOrder) o;
}
@Override
public List<BsOrder> getOrderList(Map<String, Object> map) {
BsOrderExample example = new BsOrderExample();
BsOrderExample.Criteria criteria = example.createCriteria();
if (MapUtils.getString(map , "orderNo") != null) {
criteria.andOrderNoEqualTo(MapUtils.getString(map , "orderNo"));
}
if (MapUtils.getInteger(map , "type") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map , "type"));
}
if (MapUtils.getString(map , "userPhone") != null) {
criteria.andUserPhoneEqualTo(MapUtils.getString(map , "userPhone"));
}
if (MapUtils.getString(map , "goodsName") != null) {
criteria.andGoodsNameLike("%" + MapUtils.getString(map , "goodsName") + "%");
}
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.andTypeEqualTo(MapUtils.getInteger(map , "status"));
}
if (MapUtils.getLong(map , "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId"));
}
return bsOrderMapper.selectByExample(example);
}
}

@ -4,9 +4,11 @@ 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.utils.ResponseMsgUtil;
import com.hfkj.dao.BsOrderMapper;
import com.hfkj.entity.BsOrder;
import com.hfkj.service.pdd.PddService;
import com.hfkj.service.taobao.TaoBaoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@ -27,8 +29,13 @@ public class OrderBusinessService {
// 淘口令生成业务
public JSONObject taobaoUrl(BsOrder bsOrder) {
return null;
public JSONObject taobaoUrl(BsOrder bsOrder) throws Exception{
JSONObject jsonObject = JSONObject.parseObject(bsOrder.getCustomparameters());
JSONObject object = TaoBaoService.createCommand(jsonObject.getString("url"));
if (!jsonObject.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
return object;
}
@ -46,11 +53,15 @@ public class OrderBusinessService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少goodsSign!");
}
Map<String , Object> mapUser = new HashMap<>();
mapUser.put("uid", bsOrder.getUserId());
mapUser.put("orderNo", bsOrder.getOrderNo());
// 判断是否需要授权
JSONObject object = PddService.authority(bsOrder.getCustomparameters());
JSONObject object = PddService.authority(mapUser.toString());
boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
JSONObject o = PddService.promotion(searchId , goodsSign , generateAuthorityUrl , bsOrder.getCustomparameters());
JSONObject o = PddService.promotion(searchId , goodsSign , generateAuthorityUrl , mapUser.toString());
return o.getJSONObject("goodsPromotionUrlGenerateResponse").getJSONArray("goodsPromotionUrlList").getJSONObject(0);

@ -25,7 +25,7 @@ public class PddService {
private static Logger log = LoggerFactory.getLogger(PddService.class);
public static JSONObject syncInvoke(String title , Long pageNo , Long pageSize) throws Exception {
public static JSONObject syncInvoke(String title , Long pageNo , Long pageSize , String customParameters) throws Exception {
log.info("============ 拼多多请求-START =============");
String clientId = "71a050c5d93d4169a237539af44c7c33";
@ -38,8 +38,10 @@ public class PddService {
request.setPage(pageNo.intValue());
request.setPageSize(pageSize.intValue());
request.setSortType(0);
request.setPid("41483885_294044603");
request.setUseCustomized(true);
request.setWithCoupon(true);
request.setCustomParameters(customParameters);
PddDdkGoodsSearchResponse response = client.syncInvoke(request);
log.info("请求接口:" + "syncInvoke");
@ -93,7 +95,7 @@ public class PddService {
* @Author: Sum1Dream
* @Date: 2024/9/20 下午3:57
*/
public static JSONObject promotion() throws Exception {
public static JSONObject promotion(String customParameters) throws Exception {
log.info("============ 拼多多请求-START =============");
String clientId = "71a050c5d93d4169a237539af44c7c33";
@ -105,6 +107,7 @@ public class PddService {
pIdList.add("41483885_294044603");
request.setPIdList(pIdList);
request.setChannelType(10);
request.setCustomParameters(customParameters);
PddDdkRpPromUrlGenerateResponse response = client.syncInvoke(request);
log.info("请求接口:" + "promotion");

@ -1,5 +1,7 @@
package com.hfkj.service.user;
import java.util.Map;
/**
* @className: BsUserService
* @author: HuRui
@ -13,4 +15,32 @@ public interface BsUserGradeService {
*/
void promote(Long userId);
/**
* 购买优淘会员
* @param userId
*/
void payGrade2(Long userId) throws Exception;
/**
* 晋升优淘会员进度
* @param userId
* @return
*/
Map<String,Object> promoteGrade2Progress(Long userId);
/**
* 晋升团长进度
* @param userId
* @return
*/
Map<String,Object> promoteGrade3Progress(Long userId);
/**
* 晋升渠道进度
* @param userId
* @return
*/
Map<String,Object> promoteGrade4Progress(Long userId);
}

@ -4,6 +4,7 @@ import com.hfkj.common.security.SessionObject;
import com.hfkj.entity.BsUser;
import com.hfkj.sysenum.user.UserLoginType;
import java.util.List;
import java.util.Map;
/**
@ -54,6 +55,12 @@ public interface BsUserService {
*/
BsUser getUser(String userPhone);
/**
* 查询列表
* @param param
* @return
*/
List<BsUser> getList(Map<String,Object> param);
/**
* 用户注册
* @param phone 手机号

@ -111,9 +111,6 @@ public class BsUserAccountServiceImpl implements BsUserAccountService {
record.setSourceContent(MapUtils.getString(otherParam, "sourceContent"));
userAccountRecordService.create(record);
// 是否达到升级条件
userGradeService.promote(userId);
// 释放锁
redisTemplate.delete(lockKey);
@ -146,6 +143,10 @@ public class BsUserAccountServiceImpl implements BsUserAccountService {
// 查询账户
BsUserAccount userAccount = getAccount(userId);
// 余额 是否小于 消费余额
if (userAccount.getGoldCoin().compareTo(amount) == -1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "元宝不足");
}
// 变更前金额
BigDecimal beforeAmount = userAccount.getGoldCoin();
// 计算金额

@ -5,12 +5,10 @@ import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.entity.BsUser;
import com.hfkj.model.UserTeamModel;
import com.hfkj.service.user.BsUserGradeService;
import com.hfkj.service.user.BsUserAccountRecordService;
import com.hfkj.service.user.BsUserParentRelService;
import com.hfkj.service.user.BsUserService;
import com.hfkj.service.user.*;
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum;
import com.hfkj.sysenum.user.UserGradeEnum;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@ -31,6 +29,8 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
@Resource
private BsUserService userService;
@Resource
private BsUserAccountService userAccountService;
@Resource
private BsUserAccountRecordService userAccountRecordService;
@Resource
private BsUserParentRelService userParentRelService;
@ -72,6 +72,83 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
}
}
@Override
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class})
public void payGrade2(Long userId) throws Exception {
// 查询用户
BsUser user = userService.getUser(userId);
if (!UserGradeEnum.grade1.getCode().equals(user.getGrade())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "只有“见习会员”才能进行购买");
}
Map<String,Object> otherParam = new HashMap<>();
otherParam.put("sourceContent", "升级优淘会员");
// 支付3元宝
userAccountService.consume(user.getId(),new BigDecimal("3"), UserAccountRecordSourceTypeEnum.type2, otherParam);
}
@Override
public Map<String, Object> promoteGrade2Progress(Long userId) {
Map<String,Object> map = new HashMap<>();
map.put("condition1", false);
// 条件一(支付3元宝)
Map<String,Object> accountRecordParam = new HashMap<>();
accountRecordParam.put("userId", userId);
accountRecordParam.put("sourceType", UserAccountRecordSourceTypeEnum.type2.getType());
if (!userAccountRecordService.getList(accountRecordParam).isEmpty()) {
map.put("condition1", true);
}
// 条件二(元宝收益达到5元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId);
map.put("condition2", profit);
return map;
}
@Override
public Map<String, Object> promoteGrade3Progress(Long userId) {
Map<String,Object> map = new HashMap<>();
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", userId);
List<UserTeamModel> subData = userParentRelService.getTeamSubList(param);
// 条件一(直属正式会员达到30人)
map.put("condition1", subData.stream().filter(o -> o.getRelType().equals(1)).count());
// 条件二(非直属正式会员达到100人)
map.put("condition2", subData.stream().filter(o -> o.getRelType().equals(2)).count());
// 条件三(累计元宝收益达到100元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId);
map.put("condition3", profit);
return map;
}
@Override
public Map<String, Object> promoteGrade4Progress(Long userId) {
Map<String,Object> map = new HashMap<>();
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", userId);
param.put("userType", 4);
List<UserTeamModel> directlyUnderData = userParentRelService.getTeamSubList(param);
// 条件一(直属团长达到100人)
map.put("condition1", directlyUnderData.stream().filter(o -> o.getRelType().equals(1)).count());
// 条件二(非直属团长达到300人)
map.put("condition2", directlyUnderData.stream().filter(o -> o.getRelType().equals(2)).count());
// 条件三(累计元宝收益达到10000元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId);
map.put("condition3", profit);
return map;
}
/**
* 晋升条件优淘会员
* @param user
@ -82,17 +159,16 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
boolean payCondition = false;
boolean profitCondition = false;
// 完成进度
Map<String, Object> map = promoteGrade2Progress(user.getId());
// 条件一(支付3元宝)
Map<String,Object> accountRecordParam = new HashMap<>();
accountRecordParam.put("userId", "");
accountRecordParam.put("sourceType", UserAccountRecordSourceTypeEnum.type2.getType());
if (!userAccountRecordService.getList(accountRecordParam).isEmpty()) {
if (MapUtils.getBoolean(map, "condition1")) {
payCondition = true;
}
// 条件二(元宝收益达到5元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(user.getId());
if (profit.compareTo(new BigDecimal("5")) >= 1) {
if (new BigDecimal(MapUtils.getString(map, "condition2")).compareTo(new BigDecimal("5")) >= 1) {
profitCondition = true;
}
// 满足其中条件一项
@ -110,24 +186,21 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
boolean nonDirect = false; // 非直属
boolean profitCondition = false; // 元宝收益
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", user.getId());
List<UserTeamModel> subData = userParentRelService.getTeamSubList(param);
// 完成进度
Map<String, Object> map = promoteGrade3Progress(user.getId());
// 条件一(直属正式会员达到30人)
if (subData.stream().filter(o -> o.getRelType().equals(1)).count() >= 30) {
if (MapUtils.getInteger(map, "condition1") >= 30) {
directlyUnder = true;
}
// 条件二(非直属正式会员达到100人)
if (subData.stream().filter(o -> o.getRelType().equals(2)).count() >= 100) {
if (MapUtils.getInteger(map, "condition2") >= 100) {
nonDirect = true;
}
// 条件三(累计元宝收益达到100元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(user.getId());
if (profit.compareTo(new BigDecimal("100")) >= 1) {
if (new BigDecimal(MapUtils.getString(map, "condition3")).compareTo(new BigDecimal("100")) >= 1) {
profitCondition = true;
}
// 满足全部条件
return (directlyUnder && nonDirect && profitCondition);
}
@ -143,24 +216,19 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
boolean nonDirect = false; // 非直属
boolean profitCondition = false; // 元宝收益
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", user.getId());
param.put("userType", 4);
List<UserTeamModel> directlyUnderData = userParentRelService.getTeamSubList(param);
// 完成进度
Map<String, Object> map = promoteGrade3Progress(user.getId());
// 条件一(直属团长达到100人)
if (directlyUnderData.stream().filter(o -> o.getRelType().equals(1)).count() >= 100) {
if (MapUtils.getInteger(map, "condition1") >= 100) {
directlyUnder = true;
}
// 条件二(非直属团长达到300人)
if (directlyUnderData.stream().filter(o -> o.getRelType().equals(2)).count() >= 300) {
if (MapUtils.getInteger(map, "condition2") >= 300) {
nonDirect = true;
}
// 条件三(累计元宝收益达到10000元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(user.getId());
if (profit.compareTo(new BigDecimal("10000")) >= 1) {
if (new BigDecimal(MapUtils.getString(map, "condition3")).compareTo(new BigDecimal("10000")) >= 1) {
profitCondition = true;
}
return (directlyUnder && nonDirect && profitCondition);

@ -144,9 +144,6 @@ public class BsUserServiceImpl implements BsUserService {
userParentRel.setUserId(userId);
userParentRelService.editData(userParentRel);
// 检查上级等级晋升
userGradeService.promote(userParentRel.getParentUserId());
// 更新session
UserSessionObject session = new UserSessionObject();
session.setUser(user);
@ -178,6 +175,16 @@ public class BsUserServiceImpl implements BsUserService {
return null;
}
@Override
public List<BsUser> getList(Map<String, Object> param) {
BsUserExample example = new BsUserExample();
example.createCriteria().andStatusNotEqualTo(0);
example.setOrderByClause("create_time desc");
return userMapper.selectByExample(example);
}
@Override
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class})
public BsUser register(String phone, Map<String, Object> other, Long inviteUseId) {

@ -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;
}
}

@ -16,6 +16,10 @@ public enum UserAccountRecordSourceTypeEnum {
* 自购元宝升级优淘会员等级
*/
type2(2 , "升级优淘会员"),
/**
* 聚宝盆
*/
type3(3 , "聚宝盆"),
;
private Integer type;

Loading…
Cancel
Save