zq-erp/src/main/java/com/matrix/biz/service/BizUserService.java
@@ -79,4 +79,10 @@ * 保存用户信息 */ public int saveUserInfo(BizUser bizUser); /** * 设置为推广员 * @param invitationId */ public int setToBeAnSalesman(String openId,String invitationId); } zq-erp/src/main/java/com/matrix/biz/service/impl/BizUserServiceImpl.java
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; import java.util.Map; @@ -152,7 +153,17 @@ return bizUserDao.updateByModel(bizUser); } /** * 设置成为推广员 * @param invitationId */ @Override public int setToBeAnSalesman(String openId,String invitationId) { BizUser bizUser=bizUserDao.findByOpenId(openId); bizUser.setIsSales(BizUser.IS_SALES); bizUser.setParentOpenId(invitationId); bizUser.setBindingParentTime(new Date()); return bizUserDao.updateByModel(bizUser); } } zq-erp/src/main/java/com/matrix/component/redis/RedisUserLoginUtils.java
@@ -7,7 +7,6 @@ import com.matrix.core.tools.StringUtils; import com.matrix.core.tools.UUIDUtil; import com.matrix.core.tools.WebUtil; import com.matrix.system.hive.plugin.message.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -120,10 +119,14 @@ * @date:2018年1月19日下午3:17:14 */ public void loginOut() { String toke = getUserToken(); redisClient.removeObject(toke); String token = getUserToken(); redisClient.removeObject(token); } public void updateUserInfo(Object obj) { String token = getUserToken(); redisClient.saveValue(token, obj); LogUtil.debug("更新redis用户"); } } zq-erp/src/main/java/com/matrix/system/fenxiao/constant/FenxiaoSettingConstant.java
@@ -14,7 +14,7 @@ */ public final static String FX_APPLY_WAY = "FX_APPLY_WAY"; /** * 审核方式 * 审核方式 1系统自动审核,2人工审核 */ public final static String FX_AUDIT_METHOD = "FX_AUDIT_METHOD"; /** @@ -26,4 +26,5 @@ */ public final static String FX_TG_PLAN = "FX_TG_PLAN"; public static final String FX_TG_POSTER ="FX_TG_POSTER"; } zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
@@ -1,9 +1,22 @@ package com.matrix.system.fenxiao.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.matrix.biz.bean.BizUser; import com.matrix.biz.dao.BizUserDao; import com.matrix.biz.service.BizUserService; import com.matrix.core.exception.GlobleException; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.interceptor.HostInterceptor; import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; import com.matrix.system.fenxiao.dao.ShopSalesmanApplyDao; import com.matrix.system.fenxiao.entity.ShopSalesmanApply; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; /** * @description 推广员申请记录 @@ -14,7 +27,67 @@ public class ShopSalesmanApplyService extends ServiceImpl<ShopSalesmanApplyDao, ShopSalesmanApply>{ @Autowired BusParameterSettingsDao busParameterSettingsDao; @Autowired ShopSalesmanApplyDao salesmanApplyDao; @Autowired private BizUserDao bizUserDao; @Autowired BizUserService bizUserService; /** * 申请成为推广员 * @param openId * @param invitationId * @return */ public ShopSalesmanApply applyToBeAnSalesman(String openId, String invitationId) { BizUser loginUser=bizUserDao.findByOpenId(openId); //校验审核状态,和是否重复发起 QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id",loginUser.getOpenId()); 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()); shopSalesmanApply.setApplyWay(ShopSalesmanApply.APPLY_WAY_SELF); shopSalesmanApply.setCompanyId(loginUser.getCompanyId()); shopSalesmanApply.setUpdateBy(loginUser.getNickName()); Date date = new Date(); shopSalesmanApply.setCreateTime(date); shopSalesmanApply.setUpdateTime(date); if(StringUtils.isNotBlank(invitationId)){ shopSalesmanApply.setParentUserId(invitationId); }else if(StringUtils.isNotBlank(loginUser.getParentOpenId())){ //如果曾经是被邀请进来的则自动绑定为之前邀请人的下级 shopSalesmanApply.setParentUserId(loginUser.getParentOpenId()); } BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_AUDIT_METHOD, HostInterceptor.getCompanyId()); if(busParameterSettings!=null &&busParameterSettings.getParamValue().equals("1")){ //自动审核 shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_TG); bizUserService.setToBeAnSalesman(loginUser.getOpenId(),invitationId); }else{ shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_DSH); } salesmanApplyDao.insert(shopSalesmanApply); return shopSalesmanApply; }else{ throw new GlobleException("不能重复申请"); } } } zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
@@ -17,14 +17,19 @@ import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; import com.matrix.system.fenxiao.dao.ShopSalesmanApplyDao; import com.matrix.system.fenxiao.entity.ShopSalesmanApply; import com.matrix.system.fenxiao.service.ShopSalesmanApplyService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.Date; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.util.HashMap; import java.util.Map; @@ -44,10 +49,14 @@ ShopSalesmanApplyDao salesmanApplyDao; @Autowired ShopSalesmanApplyService shopSalesmanApplyService; @Autowired private RedisUserLoginUtils redisUserLoginUtils; @Autowired private BizUserDao bizUserDao; @ApiOperation(value = "查询推广计划", notes = "") @GetMapping(value = "/getTgPlan") @@ -61,46 +70,21 @@ @ApiOperation(value = "申请成为推广员", notes = "传入参数invitationId 邀请人openId ,非必填 例: {invitationId:openId}") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = Map.class) @ApiResponse(code = 200, message = "ok", response = ShopSalesmanApply.class) }) @PostMapping(value = "/applyToBeAnSalesman") @Transactional public AjaxResult applyToBeAnSalesman(@RequestBody Map<String,String> param) { BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); String invitationId = param.get("invitationId"); ShopSalesmanApply shopSalesmanApply= shopSalesmanApplyService.applyToBeAnSalesman(loginUser.getOpenId(),invitationId); loginUser=bizUserDao.selectById(loginUser.getUserId()); //校验审核状态,和是否重复发起 QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id",loginUser.getOpenId()); 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()); shopSalesmanApply.setApplyWay(ShopSalesmanApply.APPLY_WAY_SELF); shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_DSH); shopSalesmanApply.setCompanyId(loginUser.getCompanyId()); shopSalesmanApply.setUpdateBy(loginUser.getNickName()); Date date = new Date(); shopSalesmanApply.setCreateTime(date); shopSalesmanApply.setUpdateTime(date); 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("不能重复申请"); } redisUserLoginUtils.updateUserInfo(loginUser); return AjaxResult.buildSuccessInstance(shopSalesmanApply); } @ApiOperation(value = "查询推广员审核进度", notes = "") @ApiOperation(value = " ", notes = "") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = ShopSalesmanApply.class) }) @@ -150,6 +134,22 @@ try { BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); String qrcodeSavePath = WxacodeUtil.getWxacode(loginUser.getOpenId() + "", "pages/index/index", MD5Util.strToMD5(loginUser.getOpenId() + "")); //获取海报 BusParameterSettings posterSetting = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_POSTER, HostInterceptor.getCompanyId()); String posterSavePath = posterSetting.getParamValue1(); BufferedImage productImgBuf = ImageIO.read(new File(qrcodeSavePath)); BufferedImage qrcordImgBuf = ImageIO.read(new File(posterSavePath)); BufferedImage backgroundImgBuf = new BufferedImage(750, 900, BufferedImage.TYPE_4BYTE_ABGR); //绘制背景+产品 Graphics2D g = backgroundImgBuf.createGraphics(); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1)); LogUtil.debug("qrcodeSavePath={}", qrcodeSavePath); // 图片保存目录路径 String baseSavePath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH);