From 11e9536bf17e452f947faf14bdce99b5f9d31094 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 15 Mar 2021 21:38:07 +0800
Subject: [PATCH] 分销员后台0315
---
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java | 140 ++++++++++++++++++++++++++++++++--------------
1 files changed, 97 insertions(+), 43 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
index a9256e3..e94b42d 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
@@ -1,11 +1,15 @@
package com.matrix.system.shopXcx.api.action;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.biz.bean.BizUser;
import com.matrix.biz.dao.BizUserDao;
import com.matrix.component.redis.RedisUserLoginUtils;
+import com.matrix.component.tools.ImageUtil;
import com.matrix.component.tools.WxacodeUtil;
import com.matrix.core.pojo.AjaxResult;
+import com.matrix.core.pojo.BasePageQueryDto;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.MD5Util;
import com.matrix.core.tools.PropertiesUtil;
@@ -17,14 +21,22 @@
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 com.matrix.system.shopXcx.api.WeChatApiTools;
+import com.matrix.system.shopXcx.vo.SalesmanCenterInfo;
+import com.matrix.system.shopXcx.vo.SalesmanVo;
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;
@@ -43,64 +55,45 @@
@Autowired
ShopSalesmanApplyDao salesmanApplyDao;
+
+ @Autowired
+ ShopSalesmanApplyService shopSalesmanApplyService;
+
@Autowired
private RedisUserLoginUtils redisUserLoginUtils;
@Autowired
private BizUserDao bizUserDao;
+ @Autowired
+ WeChatApiTools weChatApiTools;
@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("data",busParameterSettings.getParamValue3());
+ ajaxResult.setData(busParameterSettings.getParamValue3());
return ajaxResult;
}
@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,ShopSalesmanApply.APPLY_WAY_SELF);
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)
})
@@ -149,26 +142,87 @@
AjaxResult getInvitationPoster() {
try {
BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
- String qrcodeSavePath = WxacodeUtil.getWxacode(loginUser.getOpenId() + "", "pages/index/index", MD5Util.strToMD5(loginUser.getOpenId() + ""));
- LogUtil.debug("qrcodeSavePath={}", qrcodeSavePath);
- // 图片保存目录路径
+
String baseSavePath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH);
// 图片访问URL
String baseSaveUrl = PropertiesUtil.getString(AppConstance.NGINX_URL);
- String qrcodeImgUrl = qrcodeSavePath.replace(baseSavePath, baseSaveUrl);
- return AjaxResult.buildSuccessInstance(qrcodeImgUrl);
+ //目标海报物理存储路径
+ String targetImg=MD5Util.strToMD5(loginUser.getOpenId()) +"haibao.png";
+ String targetImgPath=baseSavePath+"wxacode" + File.separatorChar+targetImg ;
+
+ String urlPath = baseSaveUrl + "/" + "wxacode" + "/" + targetImg;
+
+ String qrcodeSavePath = WxacodeUtil.getWxacode(loginUser.getOpenId() + "", "pages/distributorCenter/applyFor/applyFor", MD5Util.strToMD5(loginUser.getOpenId())+"qrcode"
+ ,weChatApiTools.getAppid(loginUser.getCompanyId()),weChatApiTools.getSecret(loginUser.getCompanyId()));
+
+ BufferedImage qrcordImgBuf = ImageIO.read(new File(qrcodeSavePath));
+
+ //获取海报
+ BusParameterSettings posterSetting = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_POSTER, loginUser.getCompanyId());
+ String posterPath=baseSavePath+"wxacode" + File.separatorChar+MD5Util.strToMD5(loginUser.getOpenId())+"poster.png";
+ ImageUtil.downloadPicture(posterSetting.getParamValue(),posterPath);
+ BufferedImage posterImgBuf = ImageIO.read(new File(posterPath));
+
+ //获取用户头像
+ String userPhotoPath=baseSavePath+"wxacode" + File.separatorChar+MD5Util.strToMD5(loginUser.getOpenId())+"userPhoto.png";
+ ImageUtil.downloadPicture(loginUser.getAvatarUrl(),userPhotoPath);
+ BufferedImage userPhotoImgBuf = ImageIO.read(new File(userPhotoPath));
+
+
+ BufferedImage backgroundImgBuf = new BufferedImage(700, 900, BufferedImage.TYPE_4BYTE_ABGR);
+ //绘制背景+产品
+ Graphics2D g = backgroundImgBuf.createGraphics();
+ g.setColor(Color.WHITE);
+ g.fillRect(0,0,700,900);
+ g.drawImage(posterImgBuf,0,0,700, 700,null);
+
+ g.drawImage(userPhotoImgBuf,20,720,80,80,null);
+
+ g.drawImage(qrcordImgBuf,500,720,150,150,null);
+
+ g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
+
+ g.setFont(new Font("WenQuanYi Micro Hei", Font.BOLD, 24));
+ g.setColor(Color.BLACK);
+ g.drawString(loginUser.getNickName()+"邀请你一起推广赚佣金",120,750);
+
+ g.dispose();
+ ImageIO.write(backgroundImgBuf, "png", new File(targetImgPath));
+
+ return AjaxResult.buildSuccessInstance(urlPath);
} catch (Exception e) {
- LogUtil.error("门店生成二维码错误:{}", e, "");
+ LogUtil.error("推广二维码生成错误:{}", e, "");
+ return AjaxResult.buildFailInstance("二维码生成失败");
}
- return AjaxResult.buildFailInstance("二维码生成失败");
+
}
+ @ApiOperation(value = "获取下级列表", notes = "keywords=1 表示下级,keywords=2表示顾客")
+ @PostMapping(value = "/getInvitationuserList")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "ok", response = SalesmanVo.class)
+ })
+ AjaxResult getInvitationuserList(@RequestBody BasePageQueryDto pageDto) {
+ BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
+ Page<SalesmanVo> page=new Page<>(pageDto.getPageNum(),pageDto.getPageSize());
+ IPage<SalesmanVo> shopSalesmanApplyIPage = salesmanApplyDao.selectInvitationuserInPage(page, loginUser.getOpenId(),pageDto.getKeywords());
+ AjaxResult result=AjaxResult.buildSuccessInstance(shopSalesmanApplyIPage.getRecords());
+ return result;
+ }
-
-
+ @ApiOperation(value = "查询分销员中心信息", notes = "")
+ @PostMapping(value = "/getSalesmanCenterInfo")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "ok", response = SalesmanCenterInfo.class)
+ })
+ AjaxResult getSalesmanCenterInfo() {
+ BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
+ SalesmanCenterInfo salesmanCenterInfo= salesmanApplyDao.selectSalesmanCenterInfo(loginUser.getOpenId());
+ return AjaxResult.buildSuccessInstance(salesmanCenterInfo);
+ }
--
Gitblit v1.9.1