From cf148cae4937f807347e56d94b2dc96c9f258c59 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Wed, 14 Jul 2021 15:04:48 +0800 Subject: [PATCH] Merge branch 'score-shop' of http://120.27.238.55:7000/r/xzx into score-shop --- gc-core/src/main/resources/application.properties | 2 gc-user/src/main/java/com/xzx/gc/user/vo/UserIdentityVo.java | 17 +++ gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml | 19 +++ gc-user/src/main/java/com/xzx/gc/user/controller/UserController.java | 6 + gc-user/src/main/java/com/xzx/gc/user/mapper/UserShareInfoMapper.java | 3 gc-core/src/main/java/com/xzx/gc/entity/AccountInfo.java | 7 + gc-user/src/main/java/com/xzx/gc/user/service/UserService.java | 10 ++ gc-user/src/main/java/com/xzx/gc/user/vo/HeadInfoVo.java | 29 +++++ gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java | 13 ++ gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java | 76 +++++++++++++++ gc-user/src/main/resources/mapper/user/UserShareInfoMapper.xml | 8 + gc-user/src/main/java/com/xzx/gc/user/dto/DistribJoinDto.java | 17 +++ gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java | 42 ++++++++ 13 files changed, 247 insertions(+), 2 deletions(-) diff --git a/gc-core/src/main/java/com/xzx/gc/entity/AccountInfo.java b/gc-core/src/main/java/com/xzx/gc/entity/AccountInfo.java index 0bc5177..a7abe64 100644 --- a/gc-core/src/main/java/com/xzx/gc/entity/AccountInfo.java +++ b/gc-core/src/main/java/com/xzx/gc/entity/AccountInfo.java @@ -42,6 +42,8 @@ private Short adjustFlag; private String isProhibit; + public static final String IS_PROHIBIT_Y = "1"; + public static final String IS_PROHIBIT_N = "0"; private String createTime; private String updateTime; @@ -70,5 +72,10 @@ // @ApiModelProperty("用户所在区域ID") // private transient String townId; + private Integer isHead; + public static final Integer IS_HEAD_Y = 1; + public static final Integer IS_HEAD_N = 2; + + } diff --git a/gc-core/src/main/resources/application.properties b/gc-core/src/main/resources/application.properties index 832738b..b09f250 100644 --- a/gc-core/src/main/resources/application.properties +++ b/gc-core/src/main/resources/application.properties @@ -11,7 +11,7 @@ #log -project.log.path=/xzx/logs +project.log.path=xzx/logs logstash.server.url=localhost:4560 #spring diff --git a/gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java b/gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java new file mode 100644 index 0000000..405159a --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java @@ -0,0 +1,42 @@ +package com.xzx.gc.user.controller; + +import com.xzx.gc.common.request.BaseController; +import com.xzx.gc.model.JsonResult; +import com.xzx.gc.user.dto.DistribJoinDto; +import com.xzx.gc.user.service.DistribService; +import com.xzx.gc.user.vo.HeadInfoVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author wzy + * @date 2021-07-14 + **/ +@Api(tags = "分销-小程序") +@Slf4j +@RestController +public class ApiDistribController extends BaseController { + + @Autowired + private DistribService distribService; + + @ApiOperation("加入团队") + @PostMapping(value = "/distrib/join") + public JsonResult<String> join(DistribJoinDto distribJoinDto, HttpServletRequest request) { + distribService.join(distribJoinDto.getHeadId(), getUserId(request)); + return JsonResult.success(); + } + + + @ApiOperation("获取团长信息") + @PostMapping(value = "/distrib/headInfo") + public JsonResult<HeadInfoVo> headInfo(HttpServletRequest request) { + return JsonResult.success(distribService.findHeadInfo(getUserId(request))); + } +} diff --git a/gc-user/src/main/java/com/xzx/gc/user/controller/UserController.java b/gc-user/src/main/java/com/xzx/gc/user/controller/UserController.java index 45fbe44..e6cc4ca 100644 --- a/gc-user/src/main/java/com/xzx/gc/user/controller/UserController.java +++ b/gc-user/src/main/java/com/xzx/gc/user/controller/UserController.java @@ -31,6 +31,7 @@ import com.xzx.gc.user.dto.*; import com.xzx.gc.user.mapper.*; import com.xzx.gc.user.service.*; +import com.xzx.gc.user.vo.UserIdentityVo; import com.xzx.gc.util.DoubleUtil; import com.xzx.gc.util.SessionUtil; import io.swagger.annotations.*; @@ -204,6 +205,11 @@ return result; } + @ApiOperation(value = "获取用户身份状态") + @PostMapping("/user/query/userIdentity") + public JsonResult<UserIdentityVo> userIdentity(HttpServletRequest request) { + return JsonResult.success(userService.userIdentity(getUserId(request))); + } /** * 验证支付密码 diff --git a/gc-user/src/main/java/com/xzx/gc/user/dto/DistribJoinDto.java b/gc-user/src/main/java/com/xzx/gc/user/dto/DistribJoinDto.java new file mode 100644 index 0000000..67fa424 --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/dto/DistribJoinDto.java @@ -0,0 +1,17 @@ +package com.xzx.gc.user.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author wzy + * @date 2021-07-14 + **/ +@Data +@ApiModel(value = "DistribJoinDto", description = "加入团长参数接收类") +public class DistribJoinDto { + + @ApiModelProperty(value = "团长ID") + private String headId; +} diff --git a/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java b/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java new file mode 100644 index 0000000..25015d6 --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java @@ -0,0 +1,13 @@ +package com.xzx.gc.user.mapper; + +import com.xzx.gc.entity.UserHeadRelate; +import com.xzx.gc.user.vo.HeadInfoVo; +import com.xzx.gc.util.GcMapper; +import org.apache.ibatis.annotations.Param; + +public interface UserHeadRelateMapper extends GcMapper<UserHeadRelate> { + + UserHeadRelate selectMemberByUserId(@Param("userId") String userId); + + HeadInfoVo selectHeadStatisticsData(@Param("userId") String userId); +} diff --git a/gc-user/src/main/java/com/xzx/gc/user/mapper/UserShareInfoMapper.java b/gc-user/src/main/java/com/xzx/gc/user/mapper/UserShareInfoMapper.java index f56f1f2..176c879 100644 --- a/gc-user/src/main/java/com/xzx/gc/user/mapper/UserShareInfoMapper.java +++ b/gc-user/src/main/java/com/xzx/gc/user/mapper/UserShareInfoMapper.java @@ -2,12 +2,13 @@ import com.xzx.gc.entity.UserShareInfo; import com.xzx.gc.util.GcMapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @Repository public interface UserShareInfoMapper extends GcMapper<UserShareInfo> { - + UserShareInfo selectByRegistPhone(@Param("registPhone") String registPhone); } diff --git a/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java b/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java index ee9cedf..9eca3ab 100644 --- a/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java +++ b/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java @@ -1,5 +1,17 @@ package com.xzx.gc.user.service; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import com.xzx.gc.common.exception.RestException; +import com.xzx.gc.entity.AccountInfo; +import com.xzx.gc.entity.SysMessage; +import com.xzx.gc.entity.UserHeadRelate; +import com.xzx.gc.entity.UserShareInfo; +import com.xzx.gc.user.mapper.AccountMapper; +import com.xzx.gc.user.mapper.SysMessageMapper; +import com.xzx.gc.user.mapper.UserHeadRelateMapper; +import com.xzx.gc.user.mapper.UserShareInfoMapper; +import com.xzx.gc.user.vo.HeadInfoVo; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.xzx.gc.entity.RedPaperRule; @@ -7,6 +19,7 @@ import com.xzx.gc.user.dto.UpdateSettingDto; import com.xzx.gc.user.mapper.RedPaperRuleMapper; import com.xzx.gc.user.vo.ViewSettingVo; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -14,12 +27,24 @@ import java.math.BigDecimal; import java.util.List; +import java.math.BigDecimal; +import java.util.Date; + @Service @Transactional public class DistribService { @Resource private RedPaperRuleMapper redPaperRuleMapper; + @Autowired + private UserHeadRelateMapper userHeadRelateMapper; + + @Autowired + private AccountMapper accountMapper; + @Autowired + private UserShareInfoMapper userShareInfoMapper; + @Autowired + private SysMessageMapper sysMessageMapper; public ViewSettingVo viewSetting(String ruleStr) { ViewSettingVo viewSettingVo = new ViewSettingVo(); @@ -60,6 +85,57 @@ return viewSettingVo; } + + public void join(String headId, String userId) { + AccountInfo headInfo = accountMapper.selectOneByUserId(headId); + if (AccountInfo.IS_HEAD_N.equals(headInfo.getIsHead())) { + throw new RestException(-3, "不是团长"); + } + + if (AccountInfo.IS_PROHIBIT_Y.equals(headInfo.getIsProhibit())) { + throw new RestException(-3, "该用户被冻结"); + } + + UserHeadRelate existHeadRelate = userHeadRelateMapper.selectMemberByUserId(userId); + if (existHeadRelate != null) { + throw new RestException(-3, "已加入其他团队"); + } + + AccountInfo accountInfo = accountMapper.selectOneByUserId(userId); + UserShareInfo userShareInfo = userShareInfoMapper.selectByRegistPhone(accountInfo.getAccountName()); + if (userShareInfo != null) { + throw new RestException(-3, "您已与推广员绑定, 无法加入"); + } + + UserHeadRelate userHeadRelate = new UserHeadRelate(); + userHeadRelate.setHeadUserId(headId); + userHeadRelate.setUserId(userId); + userHeadRelate.setScore(BigDecimal.ZERO); + userHeadRelate.setAmount(BigDecimal.ZERO); + userHeadRelateMapper.insert(userHeadRelate); + + SysMessage sysMessage = new SysMessage(); + sysMessage.setCreateTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + sysMessage.setCreateUserId(userId); + sysMessage.setMobilePhone(accountInfo.getAccountName()); + sysMessage.setMessageType("4"); + sysMessage.setMessage("手机号:" + accountInfo.getAccountName() + "的用户, 成功加入您的团队"); + sysMessage.setFlag("2"); + sysMessageMapper.insert(sysMessage); + } + + public HeadInfoVo findHeadInfo(String userId) { + AccountInfo accountInfo = accountMapper.selectOneByUserId(userId); + + HeadInfoVo headInfoVo = userHeadRelateMapper.selectHeadStatisticsData(userId); + if (headInfoVo == null) { + headInfoVo = new HeadInfoVo(); + } + + headInfoVo.setIsHead(accountInfo.getIsHead()); + return headInfoVo; + } + public void addSetting(UpdateSettingDto model) { RedPaperRule redPaperRule = new RedPaperRule(); StringBuffer stringBuffer = new StringBuffer(); diff --git a/gc-user/src/main/java/com/xzx/gc/user/service/UserService.java b/gc-user/src/main/java/com/xzx/gc/user/service/UserService.java index b783a35..ce6eb09 100644 --- a/gc-user/src/main/java/com/xzx/gc/user/service/UserService.java +++ b/gc-user/src/main/java/com/xzx/gc/user/service/UserService.java @@ -25,6 +25,7 @@ import com.xzx.gc.user.dto.RayaltyDto; import com.xzx.gc.user.mapper.*; import com.xzx.gc.user.vo.CategaryVo; +import com.xzx.gc.user.vo.UserIdentityVo; import com.xzx.gc.util.DoubleUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; @@ -109,6 +110,15 @@ return userInfo1; } + public UserIdentityVo userIdentity(String userId) { + AccountInfo accountInfo = accountService.findByUserIdForbidden(userId); + + UserIdentityVo userIdentityVo = new UserIdentityVo(); + userIdentityVo.setIsHead(accountInfo.getIsHead()); + + return userIdentityVo; + } + public List<AccountVo> queryMyMoney(AccountReq accountReq) { Map map = new HashMap(); diff --git a/gc-user/src/main/java/com/xzx/gc/user/vo/HeadInfoVo.java b/gc-user/src/main/java/com/xzx/gc/user/vo/HeadInfoVo.java new file mode 100644 index 0000000..a4e976d --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/vo/HeadInfoVo.java @@ -0,0 +1,29 @@ +package com.xzx.gc.user.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.models.auth.In; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author wzy + * @date 2021-07-14 + **/ +@Data +@ApiModel(value = "HeadInfoVo", description = "团长信息接口返回参数类") +public class HeadInfoVo { + + @ApiModelProperty(value = "是否团长 1-是 2-否") + private Integer isHead; + + @ApiModelProperty(value = "环保币") + private BigDecimal amount; + + @ApiModelProperty(value = "积分") + private BigDecimal score; + + @ApiModelProperty(value = "团队") + private Integer cnt; +} diff --git a/gc-user/src/main/java/com/xzx/gc/user/vo/UserIdentityVo.java b/gc-user/src/main/java/com/xzx/gc/user/vo/UserIdentityVo.java new file mode 100644 index 0000000..9765040 --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/vo/UserIdentityVo.java @@ -0,0 +1,17 @@ +package com.xzx.gc.user.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author wzy + * @date 2021-07-14 + **/ +@Data +@ApiModel(value = "UserIdentityVo", description = "获取用户身份类型返回参数类") +public class UserIdentityVo { + + @ApiModelProperty(value = "是否团长 1-是 2-否") + private Integer isHead; +} diff --git a/gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml b/gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml new file mode 100644 index 0000000..0b0db58 --- /dev/null +++ b/gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.xzx.gc.user.mapper.UserHeadRelateMapper"> + + <select id="selectMemberByUserId" resultType="com.xzx.gc.entity.UserHeadRelate"> + select * from xzx_user_head_relate where user_id=#{userId} + </select> + + + <select id="selectHeadStatisticsData" resultType="com.xzx.gc.user.vo.HeadInfoVo"> + select + IFNULL(sum(a.score), 0) score, + IFNULL(sum(a.amount), 0) amount, + IFNULL(count(1), 0) cnt + from xzx_user_head_relate a + where a.head_user_id=#{userId} + group by a.head_user_id + </select> +</mapper> \ No newline at end of file diff --git a/gc-user/src/main/resources/mapper/user/UserShareInfoMapper.xml b/gc-user/src/main/resources/mapper/user/UserShareInfoMapper.xml new file mode 100644 index 0000000..591e275 --- /dev/null +++ b/gc-user/src/main/resources/mapper/user/UserShareInfoMapper.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.xzx.gc.user.mapper.UserShareInfoMapper"> + + <select id="selectByRegistPhone" resultType="com.xzx.gc.entity.UserShareInfo"> + select * from xzx_user_share_info where register_mobile_phone=#{registPhone} + </select> +</mapper> \ No newline at end of file -- Gitblit v1.9.1