diff --git a/bweb/src/main/java/com/hfkj/controller/BsMessageController.java b/bweb/src/main/java/com/hfkj/controller/BsMessageController.java new file mode 100644 index 0000000..de0ba52 --- /dev/null +++ b/bweb/src/main/java/com/hfkj/controller/BsMessageController.java @@ -0,0 +1,135 @@ +package com.hfkj.controller; + +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.utils.ResponseMsgUtil; +import com.hfkj.entity.BsMessage; +import com.hfkj.model.ResponseData; +import com.hfkj.service.message.BsMessageService; +import com.hfkj.sysenum.message.MessageStatusEnum; +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 java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/msg") +@Api(value = "消息") +public class BsMessageController { + private static Logger log = LoggerFactory.getLogger(BsMessageController.class); + @Resource + private BsMessageService messageService; + + @RequestMapping(value="/edit",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "编辑消息") + public ResponseData edit(@RequestBody BsMessage body) { + try { + if (body == null + || body.getType() == null + || StringUtils.isBlank(body.getTitle()) + || StringUtils.isBlank(body.getContent()) + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + BsMessage message; + if (null != body.getId()) { + // 查询消息 + message = messageService.getDetail(body.getId()); + if (message == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + } else { + message = new BsMessage(); + message.setStatus(MessageStatusEnum.status1.getStatus()); + } + message.setType(body.getType()); + message.setTitle(body.getTitle()); + message.setContent(body.getContent()); + messageService.editData(message); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/release",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "发布消息") + public ResponseData release(@RequestBody JSONObject body) { + try { + if (body == null || body.getLong("id") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 查询消息 + BsMessage message = messageService.getDetail(body.getLong("id")); + if (message == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + message.setStatus(MessageStatusEnum.status2.getStatus()); + messageService.editData(message); + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/del",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "删除消息") + public ResponseData del(@RequestBody JSONObject body) { + try { + if (body == null || body.getLong("id") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 查询消息 + BsMessage message = messageService.getDetail(body.getLong("id")); + if (message == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + message.setStatus(MessageStatusEnum.status0.getStatus()); + messageService.editData(message); + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/queryList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询消息列表") + public ResponseData queryList(@RequestParam(name = "type", required = true) Integer type, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + + Map param = new HashMap<>(); + param.put("type", type); + param.put("status", status); + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(messageService.getList(param))); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/bweb/src/main/java/com/hfkj/controller/BsUserController.java b/bweb/src/main/java/com/hfkj/controller/BsUserController.java index 1ff31ba..4c32d50 100644 --- a/bweb/src/main/java/com/hfkj/controller/BsUserController.java +++ b/bweb/src/main/java/com/hfkj/controller/BsUserController.java @@ -148,7 +148,7 @@ public class BsUserController { // 团长或渠道 if (userParentRel != null) { if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) { - contribute.add(userService.getUser(userParentRel.getUserId())); + contribute.add(userService.getUser(userParentRel.getParentUserId())); // 递归判断找到渠道 userParentRel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); if (userParentRel != null) { @@ -168,7 +168,7 @@ public class BsUserController { // 递归判断找到渠道 BsUserParentRel userParentRel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4),parentRel.getParentUserId()); if (userParentRel != null) { - contribute.add(userService.getUser(userParentRel.getUserId())); + contribute.add(userService.getUser(userParentRel.getParentUserId())); // 递归判断找到渠道 BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); @@ -189,7 +189,7 @@ public class BsUserController { if (userParentRel != null) { // 团长 if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) { - contribute.add(userService.getUser(userParentRel.getUserId())); + contribute.add(userService.getUser(userParentRel.getParentUserId())); // 递归判断找到渠道 BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); @@ -199,7 +199,7 @@ public class BsUserController { // 渠道 } else if (UserGradeEnum.grade4.getCode().equals(userParentRel.getParentUserGrade())) { - contribute.add(userService.getUser(userParentRel.getUserId())); + contribute.add(userService.getUser(userParentRel.getParentUserId())); // 递归判断渠道 BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); @@ -219,15 +219,15 @@ public class BsUserController { if (userParentRel != null) { // 团长 if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) { - contribute.add(userService.getUser(userParentRel.getUserId())); + contribute.add(userService.getUser(userParentRel.getParentUserId())); // 递归判断找到渠道 BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); if (channel != null) { contribute.add(userService.getUser(channel.getParentUserId())); } // 渠道 - } else if (UserGradeEnum.grade4.getCode().equals(userParentRel.getParentUserGrade())) { - contribute.add(userService.getUser(userParentRel.getUserId())); + } else if (UserGradeEnum.grade4.getCode().equals(userParentRel.getParentUserGrade())) { + contribute.add(userService.getUser(userParentRel.getParentUserId())); // 递归判断找到渠道 BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); if (channel != null) { diff --git a/service/src/main/java/com/hfkj/service/message/impl/BsMessageServiceImpl.java b/service/src/main/java/com/hfkj/service/message/impl/BsMessageServiceImpl.java index 059c96f..a357083 100644 --- a/service/src/main/java/com/hfkj/service/message/impl/BsMessageServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/message/impl/BsMessageServiceImpl.java @@ -6,6 +6,8 @@ import com.hfkj.entity.BsMessageExample; import com.hfkj.service.message.BsMessageService; import com.hfkj.sysenum.message.MessageStatusEnum; import com.hfkj.sysenum.message.MessageTypeEnum; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -42,9 +44,15 @@ public class BsMessageServiceImpl implements BsMessageService { @Override public List getList(Map param) { BsMessageExample example = new BsMessageExample(); - example.createCriteria().andStatusNotEqualTo(MessageStatusEnum.status0.getStatus()); + BsMessageExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(MessageStatusEnum.status0.getStatus()); + if (MapUtils.getInteger(param, "type") != null) { + criteria.andTypeEqualTo(MapUtils.getInteger(param, "type")); + } + if (MapUtils.getInteger(param, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(param, "status")); + } example.setOrderByClause("create_time desc"); return messageMapper.selectByExample(example); diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserContributeServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserContributeServiceImpl.java index 2198b62..c3c17a4 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserContributeServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserContributeServiceImpl.java @@ -150,7 +150,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { directlyContributeRate = new BigDecimal("9"); // 合伙人权益加成 partnerIncomePer = new BigDecimal("0"); - BsUser channelUserId = userService.getUser(parentRel.getParentUserId()); + BsUser channelUserId = userService.getUser(channel.getParentUserId()); if (channelUserId != null) { partnerIncomePer = channelUserId.getPartnerIncomePer()!=null?channelUserId.getPartnerIncomePer():new BigDecimal("0"); } @@ -221,7 +221,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { directlyContributeRate = new BigDecimal("10"); // 合伙人权益加成 partnerIncomePer = new BigDecimal("0"); - parentUserId = userService.getUser(userParentRel.getUserId()); + parentUserId = userService.getUser(userParentRel.getParentUserId()); if (parentUserId != null) { partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0"); } @@ -235,7 +235,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); parentUserParam.put("sourceContent", "直属团长团队贡献"); // 团长账户 - userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); + userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); // 递归判断找到渠道 userParentRel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); @@ -289,7 +289,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { directlyContributeRate = new BigDecimal("9"); // 合伙人权益加成 partnerIncomePer = new BigDecimal("0"); - parentUserId = userService.getUser(userParentRel.getParentUserId()); + parentUserId = userService.getUser(channel.getParentUserId()); if (parentUserId != null) { partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0"); } @@ -305,37 +305,6 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { // 渠道账户 userAccountService.recharge(channel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); } - /* // 递归找到团长 - BsUserParentRel teamLeader = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade3), parentRel.getParentUserId()); - if (teamLeader != null) { - // 贡献比例 2 3% - directlyContributeRate = new BigDecimal("23"); - // 贡献 = (返利金额 * 元宝汇率) * 直属贡献 - goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) - .multiply(directlyContributeRate.divide(new BigDecimal("100"))) - .setScale(6, BigDecimal.ROUND_HALF_DOWN); - // 贡献 - parentUserParam.clear(); - parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); - parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); - parentUserParam.put("sourceContent", "直属团长团队贡献"); - // 团长账户 - userAccountService.recharge(teamLeader.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); - - // 贡献比例 9% - directlyContributeRate = new BigDecimal("9"); - // 贡献 = (返利金额 * 元宝汇率) * 直属贡献 - goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) - .multiply(directlyContributeRate.divide(new BigDecimal("100"))) - .setScale(6, BigDecimal.ROUND_HALF_DOWN); - // 贡献 - parentUserParam.clear(); - parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); - parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); - parentUserParam.put("sourceContent", "直属渠道团队贡献"); - // 渠道账户 - userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); - }*/ } } } @@ -449,7 +418,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { } // 合伙人权益加成 partnerIncomePer = new BigDecimal("0"); - parentUserId = userService.getUser(userParentRel.getUserId()); + parentUserId = userService.getUser(userParentRel.getParentUserId()); if (parentUserId != null) { partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0"); } @@ -458,7 +427,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { .multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100"))) .setScale(6, BigDecimal.ROUND_HALF_DOWN); // 团长账户 - userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); + userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); // 递归判断找到渠道 BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); @@ -617,7 +586,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { } // 合伙人权益加成 partnerIncomePer = new BigDecimal("0"); - parentUserId = userService.getUser(parentRel.getParentUserId()); + parentUserId = userService.getUser(userParentRel.getParentUserId()); if (parentUserId != null) { partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0"); } @@ -626,7 +595,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { .multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100"))) .setScale(6, BigDecimal.ROUND_HALF_DOWN); // 团长账户 - userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); + userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); // 递归判断找到渠道 BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); @@ -698,7 +667,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); // 递归判断渠道 - BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); + BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); if (channel != null) { // 贡献比例 9% directlyContributeRate = new BigDecimal("9");