From 69cf630a57ead3c517feda7ec393880ebb90b481 Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Mon, 12 Aug 2024 10:55:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=80=E8=AF=B7=E7=A0=81=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E4=B8=8E=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/readme.md | 9 +- .../user/ic/apply/UserIcApplyController.java | 72 +++++ .../apply/UserIcApplyResourceController.java | 43 +++ .../ic/apply/UserIcApplyRouteController.java | 32 +++ .../dao/user/expand/IUserExpandDao.java | 3 + .../dao/user/ic/apply/IUserIcApplyDao.java | 33 +++ .../operator/enums/ApplyStatusEnum.java | 26 ++ .../dtos/user/ic/apply/UserIcApplyDTO.java | 153 +++++++++++ .../pojo/pos/user/ic/apply/UserIcApplyPO.java | 86 ++++++ .../user/ic/apply/UserIcApplyReviewVO.java | 73 ++++++ .../user/custom/UserCustomService.java | 2 - .../user/expand/UserExpandServiceImpl.java | 35 ++- .../user/ic/apply/UserIcApplyService.java | 145 +++++++++++ .../mapper/user/expand/user-expand.xml | 18 ++ .../user/ic/apply/user-ic-apply-mapper.xml | 219 ++++++++++++++++ .../templates/user/ic/apply/list.html | 202 +++++++++++++++ .../templates/user/ic/apply/review.html | 245 ++++++++++++++++++ 17 files changed, 1391 insertions(+), 5 deletions(-) create mode 100644 src/main/java/cn/com/tenlion/operator/controller/api/user/ic/apply/UserIcApplyController.java create mode 100644 src/main/java/cn/com/tenlion/operator/controller/resource/user/ic/apply/UserIcApplyResourceController.java create mode 100644 src/main/java/cn/com/tenlion/operator/controller/route/user/ic/apply/UserIcApplyRouteController.java create mode 100644 src/main/java/cn/com/tenlion/operator/dao/user/ic/apply/IUserIcApplyDao.java create mode 100644 src/main/java/cn/com/tenlion/operator/enums/ApplyStatusEnum.java create mode 100644 src/main/java/cn/com/tenlion/operator/pojo/dtos/user/ic/apply/UserIcApplyDTO.java create mode 100644 src/main/java/cn/com/tenlion/operator/pojo/pos/user/ic/apply/UserIcApplyPO.java create mode 100644 src/main/java/cn/com/tenlion/operator/pojo/vos/user/ic/apply/UserIcApplyReviewVO.java create mode 100644 src/main/java/cn/com/tenlion/operator/service/user/ic/apply/UserIcApplyService.java create mode 100644 src/main/resources/mybatis/mapper/user/ic/apply/user-ic-apply-mapper.xml create mode 100644 src/main/resources/templates/user/ic/apply/list.html create mode 100644 src/main/resources/templates/user/ic/apply/review.html diff --git a/doc/readme.md b/doc/readme.md index 3a94b94..4471929 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -1,4 +1,4 @@ -# 邀请码 +# 邀请码(未上线) 说明 @@ -6,4 +6,9 @@ 2. 邀请码的获取有两种方式: 1. 由管理员直接生成 2. 自己发起申请,管理员审核通过后生成 -3. 生成邀请码时,必须设置金额和邀请码返利比例 \ No newline at end of file +3. 生成邀请码时,必须设置金额和邀请码返利比例 + +变更的表 + +sys_user_expand +sys_user_ic_apply \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/user/ic/apply/UserIcApplyController.java b/src/main/java/cn/com/tenlion/operator/controller/api/user/ic/apply/UserIcApplyController.java new file mode 100644 index 0000000..74bf0f4 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/controller/api/user/ic/apply/UserIcApplyController.java @@ -0,0 +1,72 @@ +package cn.com.tenlion.operator.controller.api.user.ic.apply; + +import cn.com.tenlion.operator.enums.ApplyStatusEnum; +import cn.com.tenlion.operator.pojo.dtos.user.ic.apply.UserIcApplyDTO; +import cn.com.tenlion.operator.pojo.vos.user.ic.apply.UserIcApplyReviewVO; +import cn.com.tenlion.operator.service.user.ic.apply.UserIcApplyService; +import ink.wgink.common.base.DefaultBaseController; +import ink.wgink.exceptions.ParamsException; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.result.SuccessResult; +import ink.wgink.pojo.result.SuccessResultList; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * ClassName: UserIcApplyController + * Description: 用户邀请码申请 + * Author: wanggeng + * Date: 2024/8/8 上午11:59 + * Version: 1.0 + */ +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/user/ic/apply") +public class UserIcApplyController extends DefaultBaseController { + + @Autowired + private UserIcApplyService userIcApplyService; + + @PutMapping("review/{userIcApplyId}") + public synchronized SuccessResult review(@PathVariable("userIcApplyId") String userIcApplyId, + @RequestBody UserIcApplyReviewVO userIcApplyReview) { + if (ApplyStatusEnum.PENDING.equals(userIcApplyReview.getApplyStatus())) { + throw new ParamsException("状态不能是等待"); + } + if (ApplyStatusEnum.REJECTED.equals(userIcApplyReview.getApplyStatus())) { + if (StringUtils.isBlank(userIcApplyReview.getApplyNotes())) { + throw new ParamsException("原因不能为空"); + } + } + if (ApplyStatusEnum.APPROVED.equals(userIcApplyReview.getApplyStatus())) { + if (userIcApplyReview.getPriceAll() < 0) { + throw new ParamsException("全托价格不能小于0"); + } + if (userIcApplyReview.getPriceMaterial() < 0) { + throw new ParamsException("写材料价格不能小于0"); + } + if (StringUtils.isBlank(userIcApplyReview.getIc())) { + throw new ParamsException("邀请码不能为空"); + } + if (userIcApplyReview.getIcRebateRatio() <= 0) { + throw new ParamsException("邀请码返利比率不能小于0"); + } + } + userIcApplyService.updateReview(userIcApplyId, userIcApplyReview); + return new SuccessResult(); + } + + @GetMapping("get/{userIcApplyId}") + public UserIcApplyDTO get(@PathVariable("userIcApplyId") String userIcApplyId) { + return userIcApplyService.get(userIcApplyId); + } + + @GetMapping("listpage") + public SuccessResultList> listpage(ListPage page) { + page.setParams(requestParams()); + return userIcApplyService.listpage(page); + } +} diff --git a/src/main/java/cn/com/tenlion/operator/controller/resource/user/ic/apply/UserIcApplyResourceController.java b/src/main/java/cn/com/tenlion/operator/controller/resource/user/ic/apply/UserIcApplyResourceController.java new file mode 100644 index 0000000..c843051 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/controller/resource/user/ic/apply/UserIcApplyResourceController.java @@ -0,0 +1,43 @@ +package cn.com.tenlion.operator.controller.resource.user.ic.apply; + +import cn.com.tenlion.operator.pojo.dtos.user.ic.apply.UserIcApplyDTO; +import cn.com.tenlion.operator.service.user.ic.apply.UserIcApplyService; +import com.alibaba.fastjson.JSONObject; +import ink.wgink.exceptions.ParamsException; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.pojo.result.SuccessResult; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * ClassName: UserIcApplyResourceController + * Description: + * Author: wanggeng + * Date: 2024/8/8 下午12:01 + * Version: 1.0 + */ +@RestController +@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/user/ic/apply") +public class UserIcApplyResourceController { + + @Autowired + private UserIcApplyService userIcApplyService; + + @PostMapping("apply") + public synchronized SuccessResult apply(@RequestBody JSONObject body) { + if (StringUtils.isBlank(body.getString("applier"))) { + throw new ParamsException("申请人不能为空"); + } + userIcApplyService.save(body.getString("applier")); + return new SuccessResult(); + } + + @GetMapping("get/{userId}") + public UserIcApplyDTO getByUserId(@PathVariable("userId") String userId) { + return userIcApplyService.getByUserId(userId); + } + +} diff --git a/src/main/java/cn/com/tenlion/operator/controller/route/user/ic/apply/UserIcApplyRouteController.java b/src/main/java/cn/com/tenlion/operator/controller/route/user/ic/apply/UserIcApplyRouteController.java new file mode 100644 index 0000000..3fc9f30 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/controller/route/user/ic/apply/UserIcApplyRouteController.java @@ -0,0 +1,32 @@ +package cn.com.tenlion.operator.controller.route.user.ic.apply; + +import ink.wgink.interfaces.consts.ISystemConstant; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +/** + * ClassName: UserIcRouteController + * Description: + * Author: wanggeng + * Date: 2024/8/8 下午6:04 + * Version: 1.0 + */ +@Controller +@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/user/ic/apply") +public class UserIcApplyRouteController { + + @GetMapping("list") + public ModelAndView list() { + ModelAndView modelAndView = new ModelAndView("user/ic/apply/list"); + return modelAndView; + } + + @GetMapping("review") + public ModelAndView review() { + ModelAndView modelAndView = new ModelAndView("user/ic/apply/review"); + return modelAndView; + } + +} diff --git a/src/main/java/cn/com/tenlion/operator/dao/user/expand/IUserExpandDao.java b/src/main/java/cn/com/tenlion/operator/dao/user/expand/IUserExpandDao.java index 43db1ce..469d1ba 100644 --- a/src/main/java/cn/com/tenlion/operator/dao/user/expand/IUserExpandDao.java +++ b/src/main/java/cn/com/tenlion/operator/dao/user/expand/IUserExpandDao.java @@ -21,6 +21,8 @@ public interface IUserExpandDao { void update(Map params); + void updateIc(Map params); + void updateRelationIc(Map params); void updateRelationRebateRatio(Map params); @@ -33,4 +35,5 @@ public interface IUserExpandDao { List listUserIdByRelationUserId(String userId); + } diff --git a/src/main/java/cn/com/tenlion/operator/dao/user/ic/apply/IUserIcApplyDao.java b/src/main/java/cn/com/tenlion/operator/dao/user/ic/apply/IUserIcApplyDao.java new file mode 100644 index 0000000..39ba07d --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/dao/user/ic/apply/IUserIcApplyDao.java @@ -0,0 +1,33 @@ +package cn.com.tenlion.operator.dao.user.ic.apply; + +import cn.com.tenlion.operator.pojo.dtos.user.ic.apply.UserIcApplyDTO; +import cn.com.tenlion.operator.pojo.pos.user.ic.apply.UserIcApplyPO; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: IUserIcApplyDao + * @Description: + * @Author: wanggeng + * @Date: 2024/8/8 上午11:50 + * @Version: 1.0 + */ +public interface IUserIcApplyDao { + + void save(Map params); + + void updateApplyStatus(Map params); + + UserIcApplyPO getPO(Map params); + + UserIcApplyPO getLatestPOByCreator(String creator); + + UserIcApplyDTO get(Map params); + + List listPO(Map params); + + List list(Map params); + + +} diff --git a/src/main/java/cn/com/tenlion/operator/enums/ApplyStatusEnum.java b/src/main/java/cn/com/tenlion/operator/enums/ApplyStatusEnum.java new file mode 100644 index 0000000..2febc9f --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/enums/ApplyStatusEnum.java @@ -0,0 +1,26 @@ +package cn.com.tenlion.operator.enums; + +/** + * ClassName: ApplyStatusEnum + * Description: + * Author: wanggeng + * Date: 2024/8/8 上午11:55 + * Version: 1.0 + */ +public enum ApplyStatusEnum { + + PENDING("等待中"), + APPROVED("已通过"), + REJECTED("已拒绝"); + + private final String text; + + ApplyStatusEnum(String text) { + this.text = text; + } + + public String getText() { + return text; + } + +} diff --git a/src/main/java/cn/com/tenlion/operator/pojo/dtos/user/ic/apply/UserIcApplyDTO.java b/src/main/java/cn/com/tenlion/operator/pojo/dtos/user/ic/apply/UserIcApplyDTO.java new file mode 100644 index 0000000..c3dd2c9 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/pojo/dtos/user/ic/apply/UserIcApplyDTO.java @@ -0,0 +1,153 @@ +package cn.com.tenlion.operator.pojo.dtos.user.ic.apply; + +import cn.com.tenlion.operator.enums.ApplyStatusEnum; +import cn.com.tenlion.operator.pojo.dtos.user.info.UserInfoDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * ClassName: UserIcApplyDTO + * Description: + * Author: wanggeng + * Date: 2024/8/8 下午2:30 + * Version: 1.0 + */ +@ApiModel +public class UserIcApplyDTO { + + @ApiModelProperty(name = "userIcApplyId", value = "主键") + private String userIcApplyId; + @ApiModelProperty(name = "applyStatus", value = "申请状态") + private ApplyStatusEnum applyStatus; + @ApiModelProperty(name = "applyNotes", value = "申请备注") + private String applyNotes; + @ApiModelProperty(name = "reviewer", value = "审核人") + private String reviewer; + @ApiModelProperty(name = "gmtReview", value = "审核时间") + private String gmtReview; + @ApiModelProperty(name = "gmtCreate", value = "申请时间") + private String gmtCreate; + @ApiModelProperty(name = "creator", value = "申请人") + private String creator; + @ApiModelProperty(name = "userUsername", value = "用户名") + private String userUsername; + @ApiModelProperty(name = "userName", value = "昵称") + private String userName; + private UserInfoDTO userInfo; + private Long priceAll; + private Long priceMaterial; + private String ic; + private Integer icRebateRatio; + + public String getUserIcApplyId() { + return userIcApplyId == null ? "" : userIcApplyId.trim(); + } + + public void setUserIcApplyId(String userIcApplyId) { + this.userIcApplyId = userIcApplyId; + } + + public ApplyStatusEnum getApplyStatus() { + return applyStatus; + } + + public void setApplyStatus(ApplyStatusEnum applyStatus) { + this.applyStatus = applyStatus; + } + + public String getApplyNotes() { + return applyNotes == null ? "" : applyNotes.trim(); + } + + public void setApplyNotes(String applyNotes) { + this.applyNotes = applyNotes; + } + + public String getReviewer() { + return reviewer == null ? "" : reviewer.trim(); + } + + public void setReviewer(String reviewer) { + this.reviewer = reviewer; + } + + public String getGmtReview() { + return gmtReview == null ? "" : gmtReview.trim(); + } + + public void setGmtReview(String gmtReview) { + this.gmtReview = gmtReview; + } + + public String getGmtCreate() { + return gmtCreate == null ? "" : gmtCreate.trim(); + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getCreator() { + return creator == null ? "" : creator.trim(); + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getUserUsername() { + return userUsername == null ? "" : userUsername.trim(); + } + + public void setUserUsername(String userUsername) { + this.userUsername = userUsername; + } + + public String getUserName() { + return userName == null ? "" : userName.trim(); + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public UserInfoDTO getUserInfo() { + return userInfo; + } + + public void setUserInfo(UserInfoDTO userInfo) { + this.userInfo = userInfo; + } + + public Long getPriceAll() { + return priceAll == null ? 0 : priceAll; + } + + public void setPriceAll(Long priceAll) { + this.priceAll = priceAll; + } + + public Long getPriceMaterial() { + return priceMaterial == null ? 0 : priceMaterial; + } + + public void setPriceMaterial(Long priceMaterial) { + this.priceMaterial = priceMaterial; + } + + public String getIc() { + return ic == null ? "" : ic.trim(); + } + + public void setIc(String ic) { + this.ic = ic; + } + + public Integer getIcRebateRatio() { + return icRebateRatio == null ? 0 : icRebateRatio; + } + + public void setIcRebateRatio(Integer icRebateRatio) { + this.icRebateRatio = icRebateRatio; + } +} diff --git a/src/main/java/cn/com/tenlion/operator/pojo/pos/user/ic/apply/UserIcApplyPO.java b/src/main/java/cn/com/tenlion/operator/pojo/pos/user/ic/apply/UserIcApplyPO.java new file mode 100644 index 0000000..11142f8 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/pojo/pos/user/ic/apply/UserIcApplyPO.java @@ -0,0 +1,86 @@ +package cn.com.tenlion.operator.pojo.pos.user.ic.apply; + +import cn.com.tenlion.operator.enums.ApplyStatusEnum; + +/** + * ClassName: UserIcApplyPO + * Description: + * Author: wanggeng + * Date: 2024/8/8 上午11:42 + * Version: 1.0 + */ +public class UserIcApplyPO { + + private String userIcApplyId; + private ApplyStatusEnum applyStatus; + private String applyNotes; + private String reviewer; + private String gmtReview; + private String gmtCreate; + private String creator; + private Integer isDelete; + + public String getUserIcApplyId() { + return userIcApplyId == null ? "" : userIcApplyId.trim(); + } + + public void setUserIcApplyId(String userIcApplyId) { + this.userIcApplyId = userIcApplyId; + } + + public ApplyStatusEnum getApplyStatus() { + return applyStatus; + } + + public void setApplyStatus(ApplyStatusEnum applyStatus) { + this.applyStatus = applyStatus; + } + + public String getApplyNotes() { + return applyNotes == null ? "" : applyNotes.trim(); + } + + public void setApplyNotes(String applyNotes) { + this.applyNotes = applyNotes; + } + + public String getReviewer() { + return reviewer == null ? "" : reviewer.trim(); + } + + public void setReviewer(String reviewer) { + this.reviewer = reviewer; + } + + public String getGmtReview() { + return gmtReview == null ? "" : gmtReview.trim(); + } + + public void setGmtReview(String gmtReview) { + this.gmtReview = gmtReview; + } + + public String getGmtCreate() { + return gmtCreate == null ? "" : gmtCreate.trim(); + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getCreator() { + return creator == null ? "" : creator.trim(); + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public Integer getIsDelete() { + return isDelete == null ? 0 : isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } +} diff --git a/src/main/java/cn/com/tenlion/operator/pojo/vos/user/ic/apply/UserIcApplyReviewVO.java b/src/main/java/cn/com/tenlion/operator/pojo/vos/user/ic/apply/UserIcApplyReviewVO.java new file mode 100644 index 0000000..545f9cd --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/pojo/vos/user/ic/apply/UserIcApplyReviewVO.java @@ -0,0 +1,73 @@ +package cn.com.tenlion.operator.pojo.vos.user.ic.apply; + +import cn.com.tenlion.operator.enums.ApplyStatusEnum; +import cn.com.tenlion.operator.pojo.vos.user.expand.UserExpandVO; +import ink.wgink.annotation.CheckEmptyAnnotation; +import ink.wgink.annotation.CheckNullAnnotation; +import ink.wgink.annotation.CheckNumberAnnotation; + +/** + * ClassName: UserIcApplyVO + * Description: + * Author: wanggeng + * Date: 2024/8/8 下午3:53 + * Version: 1.0 + */ +public class UserIcApplyReviewVO { + + @CheckNullAnnotation(name = "申请状态") + private ApplyStatusEnum applyStatus; + private String applyNotes; + private Double priceAll; + private Double priceMaterial; + private String ic; + private Integer icRebateRatio; + + public ApplyStatusEnum getApplyStatus() { + return applyStatus; + } + + public void setApplyStatus(ApplyStatusEnum applyStatus) { + this.applyStatus = applyStatus; + } + + public String getApplyNotes() { + return applyNotes == null ? "" : applyNotes.trim(); + } + + public void setApplyNotes(String applyNotes) { + this.applyNotes = applyNotes; + } + + public Double getPriceAll() { + return priceAll == null ? 0 : priceAll; + } + + public void setPriceAll(Double priceAll) { + this.priceAll = priceAll; + } + + public Double getPriceMaterial() { + return priceMaterial == null ? 0 : priceMaterial; + } + + public void setPriceMaterial(Double priceMaterial) { + this.priceMaterial = priceMaterial; + } + + public String getIc() { + return ic == null ? "" : ic.trim(); + } + + public void setIc(String ic) { + this.ic = ic; + } + + public Integer getIcRebateRatio() { + return icRebateRatio == null ? 0 : icRebateRatio; + } + + public void setIcRebateRatio(Integer icRebateRatio) { + this.icRebateRatio = icRebateRatio; + } +} diff --git a/src/main/java/cn/com/tenlion/operator/service/user/custom/UserCustomService.java b/src/main/java/cn/com/tenlion/operator/service/user/custom/UserCustomService.java index 5b99e57..40a96d2 100644 --- a/src/main/java/cn/com/tenlion/operator/service/user/custom/UserCustomService.java +++ b/src/main/java/cn/com/tenlion/operator/service/user/custom/UserCustomService.java @@ -44,8 +44,6 @@ public class UserCustomService extends DefaultBaseService { private IRoleUserService roleUserService; @Autowired private UserInfoService userInfoService; - @Autowired - private SystemApiPathProperties systemApiPathProperties; public SuccessResultList> listpage(ListPage page) { SuccessResultList> successResultList = userService.listPage(page); diff --git a/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java index 31fa442..0d37c23 100644 --- a/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java @@ -151,13 +151,15 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx Map params = getHashMap(2); params.put("userId", userId); + UserExpandDTO userExpandDTO = userExpandDao.get(params); + params = HashMapUtil.beanToMap(userExpandVO); params.put("userId", userId); if (StringUtils.isNotBlank(userExpandVO.getIc())) { + params.put("icAssignUserId", securityComponent.getCurrentUser().getUserId()); params.put("icWayToGet", IcWayToGetEnum.ASSIGN); params.put("icGetTime", DateUtil.getTime()); } - UserExpandDTO userExpandDTO = userExpandDao.get(params); if (userExpandDTO == null) { if (StringUtils.isNotBlank(userExpandVO.getIc()) && countIc(userExpandVO.getIc()) > 0) { throw new SearchException("邀请码已存在,请重新生成"); @@ -183,6 +185,37 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx updateBatchRelationRebateRatio(userId, userExpandDTO == null ? 0 : userExpandDTO.getIcRebateRatio(), userExpandVO.getIcRebateRatio()); } + public void saveOrUpdateWithIc(String userId, UserExpandVO userExpandVO) { + userExpandVO.setPriceAll(userExpandVO.getPriceAll() * 100); + userExpandVO.setPriceMaterial(userExpandVO.getPriceMaterial() * 100); + userExpandVO.setAvailableProjType("PRICE_ALL,PRICE_MATERIAL,PRICE_FREE"); + + Map params = getHashMap(2); + params.put("userId", userId); + UserExpandDTO userExpandDTO = userExpandDao.get(params); + + params = HashMapUtil.beanToMap(userExpandVO); + params.put("userId", userId); + params.put("icAssignUserId", securityComponent.getCurrentUser().getUserId()); + params.put("icWayToGet", IcWayToGetEnum.APPLY); + params.put("icGetTime", DateUtil.getTime()); + + if (StringUtils.isNotBlank(userExpandVO.getIc()) && countIc(userExpandVO.getIc()) > 0) { + throw new SearchException("邀请码已存在,请重新生成"); + } + if (userExpandDTO == null) { + userExpandDao.save(params); + } else { + if (StringUtils.isNotBlank(userExpandDTO.getRelationIc()) && + StringUtils.equals("ACTIVE", userExpandVO.getPostpaid())) { + throw new SearchException("已经绑定邀请码的用户不能设置为后付费用户"); + } + userExpandDao.updateIc(params); + } + updateRedis(userId); + updateBatchRelationRebateRatio(userId, userExpandDTO == null ? 0 : userExpandDTO.getIcRebateRatio(), userExpandVO.getIcRebateRatio()); + } + /** * 批量更新返利比率 * diff --git a/src/main/java/cn/com/tenlion/operator/service/user/ic/apply/UserIcApplyService.java b/src/main/java/cn/com/tenlion/operator/service/user/ic/apply/UserIcApplyService.java new file mode 100644 index 0000000..82fec2b --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/service/user/ic/apply/UserIcApplyService.java @@ -0,0 +1,145 @@ +package cn.com.tenlion.operator.service.user.ic.apply; + +import cn.com.tenlion.operator.dao.user.ic.apply.IUserIcApplyDao; +import cn.com.tenlion.operator.enums.ApplyStatusEnum; +import cn.com.tenlion.operator.pojo.dtos.user.ic.apply.UserIcApplyDTO; +import cn.com.tenlion.operator.pojo.dtos.user.info.UserInfoDTO; +import cn.com.tenlion.operator.pojo.pos.user.expand.UserExpandPO; +import cn.com.tenlion.operator.pojo.pos.user.ic.apply.UserIcApplyPO; +import cn.com.tenlion.operator.pojo.vos.user.expand.UserExpandVO; +import cn.com.tenlion.operator.pojo.vos.user.ic.apply.UserIcApplyReviewVO; +import cn.com.tenlion.operator.service.user.expand.UserExpandServiceImpl; +import cn.com.tenlion.operator.service.user.info.UserInfoService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.exceptions.SearchException; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.util.UUIDUtil; +import ink.wgink.util.date.DateUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * ClassName: UserIcApplyService + * Description: + * Author: wanggeng + * Date: 2024/8/8 上午11:58 + * Version: 1.0 + */ +@Service +public class UserIcApplyService extends DefaultBaseService { + + @Autowired + private IUserIcApplyDao userIcApplyDao; + @Autowired + private UserExpandServiceImpl userExpandService; + @Autowired + private UserInfoService userInfoService; + + public void save(String applier) { + UserIcApplyPO latestPO = userIcApplyDao.getLatestPOByCreator(applier); + if (latestPO != null) { + if (ApplyStatusEnum.PENDING.equals(latestPO.getApplyStatus())) { + throw new SearchException("正在审核"); + } + if (ApplyStatusEnum.APPROVED.equals(latestPO.getApplyStatus())) { + throw new SearchException("申请已通过,不能重复申请"); + } + } + String uuid = UUIDUtil.getUUID(); + Map params = new HashMap<>(); + params.put("userIcApplyId", uuid); + params.put("applyStatus", ApplyStatusEnum.PENDING); + params.put("creator", applier); + params.put("gmtCreate", DateUtil.getTime()); + params.put("isDelete", 0); + userIcApplyDao.save(params); + } + + public void updateReview(String userIcApplyId, UserIcApplyReviewVO userIcApplyReview) { + UserIcApplyPO po = getPO(userIcApplyId); + if (po == null) { + throw new SearchException("申请不存在"); + } + if(!ApplyStatusEnum.PENDING.equals(po.getApplyStatus())) { + throw new SearchException("不能重复审核"); + } + Map params = getHashMap(6); + params.put("receiver", securityComponent.getCurrentUser().getUserId()); + params.put("applyStatus", userIcApplyReview.getApplyStatus()); + params.put("applyNotes", userIcApplyReview.getApplyNotes()); + params.put("reviewer", securityComponent.getCurrentUser().getUserId()); + params.put("gmtReview", DateUtil.getTime()); + params.put("userIcApplyId", userIcApplyId); + userIcApplyDao.updateApplyStatus(params); + + if (ApplyStatusEnum.APPROVED.equals(userIcApplyReview.getApplyStatus())) { + UserExpandVO userExpandVO = new UserExpandVO(); + BeanUtils.copyProperties(userIcApplyReview, userExpandVO); + userExpandService.saveOrUpdateWithIc(po.getCreator(), userExpandVO); + } + } + + public UserIcApplyPO getPO(String userIcApplyId) { + Map params = getHashMap(2); + params.put("userIcApplyId", userIcApplyId); + return userIcApplyDao.getPO(params); + } + + public UserIcApplyDTO get(String userIcApplyId) { + Map params = getHashMap(2); + params.put("userIcApplyId", userIcApplyId); + UserIcApplyDTO userIcApplyDTO = userIcApplyDao.get(params); + if (userIcApplyDTO == null) { + throw new SearchException("申请不存在"); + } + UserExpandPO po = userExpandService.getPO(userIcApplyDTO.getCreator()); + if (po != null) { + userIcApplyDTO.setPriceAll(po.getPriceAll()); + userIcApplyDTO.setPriceMaterial(po.getPriceMaterial()); + userIcApplyDTO.setIc(po.getIc()); + userIcApplyDTO.setIcRebateRatio(po.getIcRebateRatio()); + } + return userIcApplyDTO; + } + + public UserIcApplyDTO getByUserId(String userId) { + Map params = getHashMap(2); + params.put("creator", userId); + return userIcApplyDao.get(params); + } + + public UserIcApplyDTO getSelf() { + return getByUserId(securityComponent.getCurrentUser().getUserId()); + } + + public SuccessResultList> listpage(ListPage page) { + PageHelper.startPage(page.getPage(), page.getRows()); + List userIcApplyDTOS = userIcApplyDao.list(page.getParams()); + PageInfo pageInfo = new PageInfo<>(userIcApplyDTOS); + setUserInfo(userIcApplyDTOS); + return new SuccessResultList<>(userIcApplyDTOS, pageInfo.getPageNum(), pageInfo.getTotal()); + } + + private void setUserInfo(List userIcApplyDTOS) { + if (userIcApplyDTOS.isEmpty()) { + return; + } + List userIds = userIcApplyDTOS.stream().map(UserIcApplyDTO::getCreator).collect(Collectors.toList()); + List userInfoDTOS = userInfoService.listByUserIds(userIds); + userIcApplyDTOS.forEach(userIcApplyDTO -> { + userInfoDTOS.stream().filter(userInfoDTO -> StringUtils.equals(userIcApplyDTO.getCreator(), userInfoDTO.getUserId())).findFirst().ifPresent(userIcApplyDTO::setUserInfo); + }); + } + + +} diff --git a/src/main/resources/mybatis/mapper/user/expand/user-expand.xml b/src/main/resources/mybatis/mapper/user/expand/user-expand.xml index 959446f..982dc06 100644 --- a/src/main/resources/mybatis/mapper/user/expand/user-expand.xml +++ b/src/main/resources/mybatis/mapper/user/expand/user-expand.xml @@ -69,6 +69,7 @@ correction_count, ic, ic_rebate_ratio, + ic_way_to_get, ic_get_time, ic_assign_user_id ) VALUES ( @@ -87,6 +88,7 @@ #{correctionCount}, #{ic}, #{icRebateRatio}, + #{icWayToGet}, #{icGetTime}, #{icAssignUserId} ) @@ -124,6 +126,22 @@ user_id = #{userId} + + UPDATE + sys_user_expand + SET + ic = #{ic}, + ic_rebate_ratio = #{icRebateRatio}, + ic_assign_user_id = #{icAssignUserId}, + ic_way_to_get = #{icWayToGet}, + ic_get_time = #{icGetTime}, + price_all = #{priceAll}, + price_material = #{priceMaterial}, + available_proj_type = #{availableProjType} + WHERE + user_id = #{userId} + + UPDATE sys_user_expand diff --git a/src/main/resources/mybatis/mapper/user/ic/apply/user-ic-apply-mapper.xml b/src/main/resources/mybatis/mapper/user/ic/apply/user-ic-apply-mapper.xml new file mode 100644 index 0000000..996082b --- /dev/null +++ b/src/main/resources/mybatis/mapper/user/ic/apply/user-ic-apply-mapper.xml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO sys_user_ic_apply ( + user_ic_apply_id, + apply_status, + apply_notes, + reviewer, + gmt_review, + gmt_create, + creator, + is_delete + ) VALUES ( + #{userIcApplyId}, + #{applyStatus}, + #{applyNotes}, + #{reviewer}, + #{gmtReview}, + #{gmtCreate}, + #{creator}, + #{isDelete} + ) + + + + UPDATE + sys_user_ic_apply + SET + apply_status = #{applyStatus}, + apply_notes = #{applyNotes}, + reviewer = #{reviewer}, + gmt_review = #{gmtReview} + WHERE + user_ic_apply_id = #{userIcApplyId} + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/user/ic/apply/list.html b/src/main/resources/templates/user/ic/apply/list.html new file mode 100644 index 0000000..c53f76c --- /dev/null +++ b/src/main/resources/templates/user/ic/apply/list.html @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/user/ic/apply/review.html b/src/main/resources/templates/user/ic/apply/review.html new file mode 100644 index 0000000..d7c36bb --- /dev/null +++ b/src/main/resources/templates/user/ic/apply/review.html @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ +
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + + + \ No newline at end of file