zq-erp/src/main/java/com/matrix/core/pojo/AjaxResult.java
@@ -4,7 +4,6 @@ import com.matrix.core.tools.InternationaUtil; import com.matrix.core.tools.MdcUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.hive.plugin.message.StringUtil; import java.io.Serializable; import java.util.HashMap; @@ -44,7 +43,14 @@ * info会被国际化工具先处理,找不到国际化资源则显示原始信息 **/ private String info; /** * 单个对象返回参数 */ private Object data; private Map<Object, Object> mapInfo = new HashMap<>(); private List<?> rows; /** * 总记录数 @@ -53,8 +59,17 @@ private String requestId; public static AjaxResult buildSuccessInstance(Object data) { AjaxResult result= new AjaxResult(STATUS_SUCCESS,""); result.data=data; return result; } public static AjaxResult buildSuccessInstance(Object data, String info) { AjaxResult result= new AjaxResult(STATUS_SUCCESS,info); result.data=data; return result; } public static AjaxResult buildSuccessInstance(String info) { @@ -93,8 +108,6 @@ * 设置简单信息,这是一个便捷的方法 * * @param status * @param page * @param info */ public AjaxResult(String status, List<?> rows) { this.status = status; @@ -168,6 +181,14 @@ this.requestId = requestId; } public Object getData() { return data; } public void setData(Object data) { this.data = data; } /** * 在map对象中放置信息 * zq-erp/src/main/java/com/matrix/system/fenxiao/entity/ShopSalesmanApply.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.matrix.system.score.entity.BaseEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** @@ -45,46 +46,27 @@ /** * 申请方式1、自主申请,2、自动添加,3上级邀请,4、手动添加 */ @ApiModelProperty(value = "申请方式1、自主申请,2、自动添加,3上级邀请,4、手动添加") private Integer applyWay; /** * 申请用户id */ @ApiModelProperty(value = "申请用户id") private String userId; /** * 邀请用户ID */ @ApiModelProperty(value = "邀请用户ID") private String parentUserId; /** * 申请状态1、待审核,2通过,3未通过 */ @ApiModelProperty(value = "申请状态1、待审核,2通过,3未通过") private Integer applyStatus; /** * 备注 */ @ApiModelProperty(value = "备注") private String remark; /** * 公司ID */ @ApiModelProperty(hidden = true) private Long companyId; zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
@@ -1,6 +1,8 @@ package com.matrix.system.shopXcx.api.action; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.matrix.biz.bean.BizUser; import com.matrix.biz.dao.BizUserDao; import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.tools.StringUtils; @@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.HashMap; import java.util.Map; /** @@ -38,23 +41,34 @@ @Autowired private RedisUserLoginUtils redisUserLoginUtils; @Autowired private BizUserDao bizUserDao; @ApiOperation(value = "查询推广计划", notes = "") @GetMapping(value = "/getTgPlan") public AjaxResult getTgPlan() { BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_PLAN, HostInterceptor.getCompanyId()); AjaxResult ajaxResult = AjaxResult.buildSuccessInstance(""); ajaxResult.putInMap("tgjh",busParameterSettings.getParamValue3()); ajaxResult.putInMap("data",busParameterSettings.getParamValue3()); return ajaxResult; } @ApiOperation(value = "申请成为推广员", notes = "传入参数invitationId 邀请人openId 如: {invitationId:openId}") @ApiOperation(value = "申请成为推广员", notes = "传入参数invitationId 邀请人openId ,非必填 例: {invitationId:openId}") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = Map.class) }) @PostMapping(value = "/applyToBeAnSalesman") public AjaxResult applyToBeAnSalesman(@RequestBody Map<String,String> param) { BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); loginUser=bizUserDao.selectById(loginUser.getUserId()); //校验审核状态,和是否重复发起 QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id",loginUser.getUserId()); ShopSalesmanApply checkApply = salesmanApplyDao.selectOne(queryWrapper); if(checkApply==null|| checkApply.getApplyStatus()==ShopSalesmanApply.APPLY_STATUS_WTG){ ShopSalesmanApply shopSalesmanApply=new ShopSalesmanApply(); shopSalesmanApply.setUserId(loginUser.getUserId()); shopSalesmanApply.setCreateBy(loginUser.getNickName()); @@ -68,12 +82,64 @@ String invitationId = param.get("invitationId"); if(StringUtils.isNotBlank(invitationId)){ shopSalesmanApply.setParentUserId(invitationId); }else if(StringUtils.isNotBlank(loginUser.getParentOpenId())){ //如果曾经是被邀请进来的则自动绑定为之前邀请人的下级 shopSalesmanApply.setParentUserId(loginUser.getParentOpenId()); } salesmanApplyDao.insert(shopSalesmanApply); return AjaxResult.buildSuccessInstance("申请成功"); }else{ return AjaxResult.buildFailInstance("不能重复申请"); } } @ApiOperation(value = "查询推广员审核进度", notes = "") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = ShopSalesmanApply.class) }) @GetMapping(value = "/queryApplyProgress") public AjaxResult queryApplyProgress() { BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id",loginUser.getUserId()); ShopSalesmanApply shopSalesmanApply = salesmanApplyDao.selectOne(queryWrapper); return AjaxResult.buildSuccessInstance(shopSalesmanApply); } @ApiOperation(value = "绑定下级客户,当客户点击分销员分销的产品时调用", notes = "传入参数invitationId 必须 分销员openId 例: {invitationId:openId}") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = Map.class) }) @PostMapping(value = "/bindingParentSalesman") public AjaxResult bindingParentSalesman(@RequestBody Map<String,String> param) { String invitationId = param.get("invitationId"); if (StringUtils.isBlank(invitationId)) { return AjaxResult.buildFailInstance("请求参数错误"); } BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); loginUser = bizUserDao.selectById(loginUser.getUserId()); if (loginUser.getIsSales() == null || loginUser.getIsSales() == BizUser.NOT_SALES) { if (StringUtils.isBlank(loginUser.getParentOpenId())) { Map<String, Object> updateParam = new HashMap<>(); updateParam.put("userId", loginUser.getUserId()); updateParam.put("parentOpenId", invitationId); bizUserDao.updateByMap(updateParam); return AjaxResult.buildSuccessInstance("绑定成功"); } else { return AjaxResult.buildSuccessInstance("已经存在上级"); } } else { return AjaxResult.buildSuccessInstance("分销员不能被绑定"); } } zq-erp/src/main/resources/mybatis/mapper/xcxShop/BizUserDao.xml
@@ -36,6 +36,7 @@ <result property="isSales" column="is_sales" /> <result property="withdrawalCash" column="withdrawal_cash" /> <result property="salesmanGrade" column="salesman_grade" /> <result property="parentOpenId" column="parent_open_id" /> </resultMap> @@ -72,6 +73,7 @@ <result property="isSales" column="is_sales" /> <result property="withdrawalCash" column="withdrawal_cash" /> <result property="salesmanGrade" column="salesman_grade" /> <result property="parentOpenId" column="parent_open_id" /> </resultMap> <!-- 字段sql --> @@ -106,7 +108,8 @@ company_id, is_sales, withdrawal_cash, salesman_grade salesman_grade, parent_open_id </sql> @@ -142,7 +145,9 @@ #{item.companyId}, #{item.isSales}, #{item.withdrawalCash}, #{item.salesmanGrade} #{item.salesmanGrade}, #{item.parentOpenId} </sql> @@ -238,7 +243,9 @@ <if test="record.salesmanGrade != null and record.salesmanGrade !='' "> and salesman_grade = #{record.salesmanGrade} </if> <if test="record.parentOpenId != null and record.parentOpenId !='' "> and parent_open_id = #{record.parentOpenId} </if> <if test="(record.startTime!=null and record.startTime!='') or (record.startTime!='' and record.startTime==0) "> and date_format(create_time,'%Y-%m-%d') >= #{record.startTime} @@ -361,6 +368,9 @@ <if test="_parameter.containsKey('salesmanGrade')"> salesman_grade = #{salesmanGrade}, </if> <if test="_parameter.containsKey('parentOpenId')"> parent_open_id = #{parentOpenId}, </if> @@ -448,7 +458,9 @@ <if test="record.salesmanGrade != null "> salesman_grade = #{record.salesmanGrade}, </if> <if test="record.parentOpenId != null "> parent_open_id = #{record.parentOpenId}, </if> </set> WHERE user_id=#{record.userId}