Selaa lähdekoodia

小程序分配协销

zhijiezhao 2 vuotta sitten
vanhempi
commit
d974c782cc

+ 6 - 0
pom.xml

@@ -35,6 +35,12 @@
             <artifactId>spring-cloud-starter-openfeign</artifactId>
             <artifactId>spring-cloud-starter-openfeign</artifactId>
         </dependency>
         </dependency>
 
 
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>4.1.14</version>
+        </dependency>
+
         <dependency>
         <dependency>
 			<groupId>org.springframework.boot</groupId>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-web</artifactId>
 			<artifactId>spring-boot-starter-web</artifactId>

+ 90 - 42
src/main/java/com/caimei365/user/components/WeChatService.java

@@ -1,5 +1,7 @@
 package com.caimei365.user.components;
 package com.caimei365.user.components;
 
 
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.ResponseJson;
@@ -15,6 +17,8 @@ import org.springframework.stereotype.Component;
 import javax.crypto.Cipher;
 import javax.crypto.Cipher;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 import javax.crypto.spec.SecretKeySpec;
+import java.io.IOException;
+import java.net.URLDecoder;
 import java.security.AlgorithmParameters;
 import java.security.AlgorithmParameters;
 import java.security.Security;
 import java.security.Security;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
@@ -300,15 +304,16 @@ public class WeChatService {
 
 
     /**
     /**
      * 购买会员消息推送
      * 购买会员消息推送
+     *
      * @param accessToken 微信公众号
      * @param accessToken 微信公众号
-     * @param openid 公众号的openid
-     * @param title 标题
-     * @param name 商品名称
-     * @param money 金额
-     * @param remarkText 备注
-     * @param pagePath 跳转链接
+     * @param openid      公众号的openid
+     * @param title       标题
+     * @param name        商品名称
+     * @param money       金额
+     * @param remarkText  备注
+     * @param pagePath    跳转链接
      */
      */
-    public void sendTemplateMsgs(String accessToken, String openid, String title, String name, Double money, String date,String remarkText, String pagePath) {
+    public void sendTemplateMsgs(String accessToken, String openid, String title, String name, Double money, String date, String remarkText, String pagePath) {
         JSONObject first = new JSONObject();
         JSONObject first = new JSONObject();
         first.put("value", title);
         first.put("value", title);
         JSONObject keyword1 = new JSONObject();
         JSONObject keyword1 = new JSONObject();
@@ -332,9 +337,9 @@ public class WeChatService {
         miniProgram.put("pagepath", pagePath);
         miniProgram.put("pagepath", pagePath);
 
 
         JSONObject json = new JSONObject(new LinkedHashMap());
         JSONObject json = new JSONObject(new LinkedHashMap());
-        json.put("touser",openid);
-        json.put("template_id","Sj5QEHxYrXMOvkY0t7ptj_6LJvBE6H4O-N0TRS3l3tc");
-        json.put("url","https://www.caimei365.com/");
+        json.put("touser", openid);
+        json.put("template_id", "Sj5QEHxYrXMOvkY0t7ptj_6LJvBE6H4O-N0TRS3l3tc");
+        json.put("url", "https://www.caimei365.com/");
         json.put("miniprogram", miniProgram);
         json.put("miniprogram", miniProgram);
         json.put("data", data);
         json.put("data", data);
         // json 字符串
         // json 字符串
@@ -343,7 +348,7 @@ public class WeChatService {
         try {
         try {
             // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
             // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
 //            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
 //            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
-            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
             // 发送请求
             // 发送请求
             String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
             String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
             log.info(">>>>>>>>推送结果:" + result);
             log.info(">>>>>>>>推送结果:" + result);
@@ -354,16 +359,17 @@ public class WeChatService {
 
 
     /**
     /**
      * 续费会员消息推送
      * 续费会员消息推送
+     *
      * @param accessToken 微信公众号
      * @param accessToken 微信公众号
-     * @param openid 公众号的openid
-     * @param title 标题
-     * @param name 商品名称
-     * @param remarkText 备注
-     * @param pagePath 跳转链接
+     * @param openid      公众号的openid
+     * @param title       标题
+     * @param name        商品名称
+     * @param remarkText  备注
+     * @param pagePath    跳转链接
      */
      */
-    public void sendTemplateMsg(String accessToken, String openid,String date,String remarkText, String pagePath) {
+    public void sendTemplateMsg(String accessToken, String openid, String date, String remarkText, String pagePath) {
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        Date dat=new Date();
+        Date dat = new Date();
         JSONObject first = new JSONObject();
         JSONObject first = new JSONObject();
         first.put("value", "恭喜您成功续费采美超级会员");
         first.put("value", "恭喜您成功续费采美超级会员");
         JSONObject keyword1 = new JSONObject();
         JSONObject keyword1 = new JSONObject();
@@ -384,9 +390,9 @@ public class WeChatService {
         miniProgram.put("pagepath", pagePath);
         miniProgram.put("pagepath", pagePath);
 
 
         JSONObject json = new JSONObject(new LinkedHashMap());
         JSONObject json = new JSONObject(new LinkedHashMap());
-        json.put("touser",openid);
-        json.put("template_id","QHsM0AhlgGaX6kJ6vFm1wAKIkNjnZdWPjFGOKopLbsM");
-        json.put("url","https://www.caimei365.com/");
+        json.put("touser", openid);
+        json.put("template_id", "QHsM0AhlgGaX6kJ6vFm1wAKIkNjnZdWPjFGOKopLbsM");
+        json.put("url", "https://www.caimei365.com/");
         json.put("miniprogram", miniProgram);
         json.put("miniprogram", miniProgram);
         json.put("data", data);
         json.put("data", data);
         // json 字符串
         // json 字符串
@@ -395,7 +401,7 @@ public class WeChatService {
         try {
         try {
             // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
             // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
 //            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
 //            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
-            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
             // 发送请求
             // 发送请求
             String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
             String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
             log.info(">>>>>>>>推送结果:" + result);
             log.info(">>>>>>>>推送结果:" + result);
@@ -406,12 +412,13 @@ public class WeChatService {
 
 
     /**
     /**
      * 续费会员消息推送
      * 续费会员消息推送
+     *
      * @param accessToken 微信公众号
      * @param accessToken 微信公众号
-     * @param openid 公众号的openid
-     * @param remarkText 备注
-     * @param pagePath 跳转链接
+     * @param openid      公众号的openid
+     * @param remarkText  备注
+     * @param pagePath    跳转链接
      */
      */
-    public void sendTemplateMessg(String accessToken, String openid, String nickName,String time,String remarkText, String pagePath) {
+    public void sendTemplateMessg(String accessToken, String openid, String nickName, String time, String remarkText, String pagePath) {
         JSONObject first = new JSONObject();
         JSONObject first = new JSONObject();
         first.put("value", "绑定成功提醒");
         first.put("value", "绑定成功提醒");
         JSONObject keyword1 = new JSONObject();
         JSONObject keyword1 = new JSONObject();
@@ -435,9 +442,9 @@ public class WeChatService {
         miniProgram.put("pagepath", pagePath);
         miniProgram.put("pagepath", pagePath);
 
 
         JSONObject json = new JSONObject(new LinkedHashMap());
         JSONObject json = new JSONObject(new LinkedHashMap());
-        json.put("touser",openid);
-        json.put("template_id","ph3XjF5o2QPuANQW2XlO7PRYU7Y9t-3fAX5TSqwTftk");
-        json.put("url","https://www.caimei365.com/");
+        json.put("touser", openid);
+        json.put("template_id", "ph3XjF5o2QPuANQW2XlO7PRYU7Y9t-3fAX5TSqwTftk");
+        json.put("url", "https://www.caimei365.com/");
         json.put("miniprogram", miniProgram);
         json.put("miniprogram", miniProgram);
         json.put("data", data);
         json.put("data", data);
         // json 字符串
         // json 字符串
@@ -446,7 +453,7 @@ public class WeChatService {
         try {
         try {
             // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
             // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
 //            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
 //            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
-            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
             // 发送请求
             // 发送请求
             String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
             String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
             log.info(">>>>>>>>推送结果:" + result);
             log.info(">>>>>>>>推送结果:" + result);
@@ -458,16 +465,17 @@ public class WeChatService {
 
 
     /**
     /**
      * 上架费消息推送
      * 上架费消息推送
+     *
      * @param accessToken 微信公众号
      * @param accessToken 微信公众号
-     * @param openid 公众号的openid
-     * @param remarkText 备注
-     * @param pagePath 跳转链接
+     * @param openid      公众号的openid
+     * @param remarkText  备注
+     * @param pagePath    跳转链接
      */
      */
-    public void sendTemplate(String accessToken, String openid, String date, String newTime,String endTime,Double money,String remarkText, String pagePath) {
+    public void sendTemplate(String accessToken, String openid, String date, String newTime, String endTime, Double money, String remarkText, String pagePath) {
         JSONObject first = new JSONObject();
         JSONObject first = new JSONObject();
         first.put("value", "维护费到期提醒");
         first.put("value", "维护费到期提醒");
         JSONObject keyword1 = new JSONObject();
         JSONObject keyword1 = new JSONObject();
-        keyword1.put("value", "尊敬的采美供应商用户,您的账号维护费用"+date+"天后即将到期!");
+        keyword1.put("value", "尊敬的采美供应商用户,您的账号维护费用" + date + "天后即将到期!");
         JSONObject keyword2 = new JSONObject();
         JSONObject keyword2 = new JSONObject();
         keyword2.put("value", "维护费");
         keyword2.put("value", "维护费");
         JSONObject keyword3 = new JSONObject();
         JSONObject keyword3 = new JSONObject();
@@ -496,9 +504,9 @@ public class WeChatService {
         miniProgram.put("pagepath", pagePath);
         miniProgram.put("pagepath", pagePath);
 
 
         JSONObject json = new JSONObject(new LinkedHashMap());
         JSONObject json = new JSONObject(new LinkedHashMap());
-        json.put("touser",openid);
-        json.put("template_id","jYUIq63wP6mGFvkgNHgTOXAgF7j6h_VZKgST_-2fqCo");
-        json.put("url","https://www.caimei365.com/");
+        json.put("touser", openid);
+        json.put("template_id", "jYUIq63wP6mGFvkgNHgTOXAgF7j6h_VZKgST_-2fqCo");
+        json.put("url", "https://www.caimei365.com/");
         json.put("miniprogram", miniProgram);
         json.put("miniprogram", miniProgram);
         json.put("data", data);
         json.put("data", data);
         // json 字符串
         // json 字符串
@@ -507,7 +515,7 @@ public class WeChatService {
         try {
         try {
             // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
             // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
 //            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
 //            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
-            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
             // 发送请求
             // 发送请求
             String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
             String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
             log.info(">>>>>>>>推送结果:" + result);
             log.info(">>>>>>>>推送结果:" + result);
@@ -516,9 +524,49 @@ public class WeChatService {
         }
         }
     }
     }
 
 
-
-
-
+    /**
+     * 获取微信urlscheme
+     *
+     * @param path
+     * @param query
+     * @return
+     */
+    public ResponseJson getOpenLink(String path, String query, String env) {
+        String token = null;
+        try {
+            String link = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
+            link = link.replace("APPID", miniAppId);
+            link = link.replace("APPSECRET", miniAppSecret);
+            String result = RequestUtil.sendGet(link);
+            log.info("微信公众号获取access_token>>>" + result);
+            Map<String, Object> map = JSONObject.parseObject(result, Map.class);
+            token = (String) map.get("access_token");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        String url = "https://api.weixin.qq.com/wxa/generatescheme?access_token=" + token;
+        JSONObject jumpWxa = new JSONObject();
+        jumpWxa.put("path", path);
+        jumpWxa.put("query", query);
+        //正式版为"release",体验版为"trial",开发版为"develop"
+        jumpWxa.put("env_version", env);
+
+        JSONObject reqMap = new JSONObject();
+        reqMap.put("jump_wxa", jumpWxa);
+        String result = "";
+        try {
+            HttpRequest request = HttpUtil.createPost(url);
+            request.contentType("application/json");
+            request.body(reqMap.toJSONString());
+            result = request.execute().body();
+            result = URLDecoder.decode(result, "UTF-8");
+            log.info("微信获取getOpenLink回调报文" + result);
+            result = JSONObject.parseObject(result).getString("openlink");
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return ResponseJson.success(result);
+    }
 
 
 
 
 }
 }

+ 17 - 9
src/main/java/com/caimei365/user/controller/BaseApi.java

@@ -1,6 +1,7 @@
 package com.caimei365.user.controller;
 package com.caimei365.user.controller;
 
 
 import com.aliyuncs.exceptions.ClientException;
 import com.aliyuncs.exceptions.ClientException;
+import com.caimei365.user.components.WeChatService;
 import com.caimei365.user.idempotent.IpSave;
 import com.caimei365.user.idempotent.IpSave;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.MobileDto;
 import com.caimei365.user.model.dto.MobileDto;
@@ -28,6 +29,7 @@ import java.util.Map;
 public class BaseApi {
 public class BaseApi {
 
 
     private final BaseService baseService;
     private final BaseService baseService;
+    private final WeChatService weChatService;
     @Value(value = "${swagger.enabled}")
     @Value(value = "${swagger.enabled}")
     private Boolean swaggerEnabled;
     private Boolean swaggerEnabled;
 
 
@@ -56,7 +58,7 @@ public class BaseApi {
      */
      */
     @ApiOperation("获取图片验证码")
     @ApiOperation("获取图片验证码")
     @ApiImplicitParam(required = true, name = "platformType", value = "0:www,1:crm/h5,2:小程序")
     @ApiImplicitParam(required = true, name = "platformType", value = "0:www,1:crm/h5,2:小程序")
-    @IpSave(saveName = "获取图片验证码",saveParams = false)
+    @IpSave(saveName = "获取图片验证码", saveParams = false)
     @GetMapping("/captcha")
     @GetMapping("/captcha")
     public ResponseJson<Map<String, Object>> getCaptchaImage(Integer platformType) {
     public ResponseJson<Map<String, Object>> getCaptchaImage(Integer platformType) {
         return baseService.getCaptchaImage(platformType);
         return baseService.getCaptchaImage(platformType);
@@ -84,7 +86,7 @@ public class BaseApi {
             @ApiImplicitParam(required = false, name = "token", value = "图片token")
             @ApiImplicitParam(required = false, name = "token", value = "图片token")
 
 
     })
     })
-    @IpSave(saveName = "获取短信验证码",saveParams = true)
+    @IpSave(saveName = "获取短信验证码", saveParams = true)
     @GetMapping("/sms/code")
     @GetMapping("/sms/code")
     public ResponseJson getSmsCode(String mobile, Integer activateCodeType, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
     public ResponseJson getSmsCode(String mobile, Integer activateCodeType, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
         return baseService.getSmsCode(mobile, activateCodeType, platformType, isCheckCaptcha, imgCode, token);
         return baseService.getSmsCode(mobile, activateCodeType, platformType, isCheckCaptcha, imgCode, token);
@@ -113,7 +115,7 @@ public class BaseApi {
             @ApiImplicitParam(required = false, name = "imgCode", value = "图片验证码"),
             @ApiImplicitParam(required = false, name = "imgCode", value = "图片验证码"),
             @ApiImplicitParam(required = false, name = "token", value = "图片token")
             @ApiImplicitParam(required = false, name = "token", value = "图片token")
     })
     })
-    @IpSave(saveName = "绑定账号,发送短信验证",saveParams = true)
+    @IpSave(saveName = "绑定账号,发送短信验证", saveParams = true)
     @GetMapping("/sms/bind")
     @GetMapping("/sms/bind")
     public ResponseJson getBindSmsCode(String mobile, String bindMobile, Integer userId, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
     public ResponseJson getBindSmsCode(String mobile, String bindMobile, Integer userId, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
         return baseService.getBindSmsCode(mobile, bindMobile, userId, platformType, isCheckCaptcha, imgCode, token);
         return baseService.getBindSmsCode(mobile, bindMobile, userId, platformType, isCheckCaptcha, imgCode, token);
@@ -148,7 +150,7 @@ public class BaseApi {
      *                    }
      *                    }
      */
      */
     @ApiOperation("修改密码(旧:/user/findCompanyPwd)")
     @ApiOperation("修改密码(旧:/user/findCompanyPwd)")
-    @IpSave(saveName = "修改密码",saveParams = true)
+    @IpSave(saveName = "修改密码", saveParams = true)
     @PostMapping("/update/password")
     @PostMapping("/update/password")
     public ResponseJson updatePassword(PasswordDto passwordDto) {
     public ResponseJson updatePassword(PasswordDto passwordDto) {
         return baseService.updatePassword(passwordDto);
         return baseService.updatePassword(passwordDto);
@@ -183,19 +185,19 @@ public class BaseApi {
     }
     }
 
 
     @ApiOperation("超级会员会员中心")
     @ApiOperation("超级会员会员中心")
-    @IpSave(saveName = "超级会员中心",saveParams = true)
+    @IpSave(saveName = "超级会员中心", saveParams = true)
     @GetMapping("/super/center")
     @GetMapping("/super/center")
-    public ResponseJson<Map<String, Object>> superCenter(Integer userId,Integer source) {
+    public ResponseJson<Map<String, Object>> superCenter(Integer userId, Integer source) {
         if (null == userId) {
         if (null == userId) {
             return ResponseJson.error("参数异常:用户Id不能为空!", null);
             return ResponseJson.error("参数异常:用户Id不能为空!", null);
         }
         }
-        return baseService.superCenter(userId,source);
+        return baseService.superCenter(userId, source);
     }
     }
 
 
     @ApiOperation("超级会员套餐详情")
     @ApiOperation("超级会员套餐详情")
-    @IpSave(saveName = "超级会员套餐详情",saveParams = false)
+    @IpSave(saveName = "超级会员套餐详情", saveParams = false)
     @GetMapping("/super/package")
     @GetMapping("/super/package")
-    public ResponseJson findPackage(){
+    public ResponseJson findPackage() {
         return baseService.findPackage();
         return baseService.findPackage();
     }
     }
 
 
@@ -204,4 +206,10 @@ public class BaseApi {
     public ResponseJson<HashMap<String, String>> ossTokenGet() throws ClientException {
     public ResponseJson<HashMap<String, String>> ossTokenGet() throws ClientException {
         return baseService.ossTokenGet();
         return baseService.ossTokenGet();
     }
     }
+
+    @ApiOperation("获取微信跳转url")
+    @GetMapping("/wechat/link")
+    public ResponseJson getWechatLink(String path, String query, String env) {
+        return weChatService.getOpenLink(path, query, env);
+    }
 }
 }

+ 29 - 13
src/main/java/com/caimei365/user/controller/SellerApi.java

@@ -6,6 +6,7 @@ import com.caimei365.user.model.dto.OnlineDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubVo;
 import com.caimei365.user.model.vo.ClubVo;
+import com.caimei365.user.model.vo.ServiceProviderVo;
 import com.caimei365.user.service.SellerService;
 import com.caimei365.user.service.SellerService;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
@@ -16,6 +17,7 @@ import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -82,28 +84,42 @@ public class SellerApi {
      * 协销机构列表
      * 协销机构列表
      * 原spi的 /seller/club/list
      * 原spi的 /seller/club/list
      *
      *
-     * @param spId 协销Id
-     * @param status            机构状态
-     * @param name              机构名字关键字(搜索用)
+     * @param spId           协销Id
+     * @param status         机构状态
+     * @param type           1.我的机构2.组员机构3.待分配机构
+     * @param name           机构名字关键字(搜索用)
+     * @param groupServiceId 组员协销id(搜索用)
      */
      */
     @ApiOperation("协销机构列表")
     @ApiOperation("协销机构列表")
     @GetMapping("/club/list")
     @GetMapping("/club/list")
     public ResponseJson<PageInfo<ClubVo>> getClubList(Integer spId,
     public ResponseJson<PageInfo<ClubVo>> getClubList(Integer spId,
-                                    Integer status,
-                                    String name,
-                                    Integer userIdentity,
-                                    @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                    @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        if (null == spId || null == status) {
-            return ResponseJson.error("spId 或 status 参数不全!", null);
+                                                      Integer status,
+                                                      Integer type,
+                                                      String name,
+                                                      Integer userIdentity,
+                                                      Integer groupServiceId,
+                                                      @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                      @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        if (null == spId || null == status || null == type) {
+            return ResponseJson.error("spId 或 status 或 type 参数不全!", null);
         }
         }
-        return sellerService.getClubList(spId, status, name, userIdentity, pageNum, pageSize);
+        return sellerService.getClubList(spId, status, type, name, userIdentity, groupServiceId, pageNum, pageSize);
+    }
+
+    @ApiOperation("组员筛选侧边栏")
+    @GetMapping("/service/team")
+    public ResponseJson<List<ServiceProviderVo>> getClubList(Integer spId) {
+        if (null == spId) {
+            return ResponseJson.error("spId 不能为空!", null);
+        }
+        return sellerService.getServiceTeam(spId);
     }
     }
 
 
     /**
     /**
      * 所有的机构列表
      * 所有的机构列表
      * 原spi的 /seller/findAllClub
      * 原spi的 /seller/findAllClub
-     * @param searchWord     关键字(搜索用)
+     *
+     * @param searchWord 关键字(搜索用)
      */
      */
     @ApiOperation("所有的机构列表(搜索)")
     @ApiOperation("所有的机构列表(搜索)")
     @GetMapping("/club/all")
     @GetMapping("/club/all")
@@ -119,7 +135,7 @@ public class SellerApi {
      * @param userId 协销userId
      * @param userId 协销userId
      */
      */
     @GetMapping("/home")
     @GetMapping("/home")
-    public  ResponseJson<ServiceProviderPo> getSellerHome(Integer userId) {
+    public ResponseJson<ServiceProviderPo> getSellerHome(Integer userId) {
         if (null == userId) {
         if (null == userId) {
             return ResponseJson.error("参数异常:用户Id不能为空!", null);
             return ResponseJson.error("参数异常:用户Id不能为空!", null);
         }
         }

+ 2 - 0
src/main/java/com/caimei365/user/controller/ShopApi.java

@@ -1,5 +1,6 @@
 package com.caimei365.user.controller;
 package com.caimei365.user.controller;
 
 
+import com.caimei365.user.idempotent.IpSave;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.BaikeProductDto;
 import com.caimei365.user.model.dto.BaikeProductDto;
 import com.caimei365.user.model.dto.ShopArticleDto;
 import com.caimei365.user.model.dto.ShopArticleDto;
@@ -106,6 +107,7 @@ public class ShopApi {
     @ApiOperation("供应商首页数据(旧:/supplier/home/detail(supplierId))")
     @ApiOperation("供应商首页数据(旧:/supplier/home/detail(supplierId))")
     @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id")
     @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id")
     @GetMapping("/home/data")
     @GetMapping("/home/data")
+    @IpSave(saveName = "供应商首页数据",saveParams = true)
     public ResponseJson<ShopHomeVo> getShopHomeData(Integer shopId) {
     public ResponseJson<ShopHomeVo> getShopHomeData(Integer shopId) {
         if (null == shopId) {
         if (null == shopId) {
             return ResponseJson.error("参数异常:供应商Id不能为空!", null);
             return ResponseJson.error("参数异常:供应商Id不能为空!", null);

+ 16 - 1
src/main/java/com/caimei365/user/mapper/SellerMapper.java

@@ -4,6 +4,7 @@ import com.caimei365.user.model.dto.ClubTemporaryDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubVo;
 import com.caimei365.user.model.vo.ClubVo;
+import com.caimei365.user.model.vo.ServiceProviderVo;
 import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.model.vo.UserLoginVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
@@ -58,13 +59,15 @@ public interface SellerMapper {
      */
      */
     void deleteTemporaryClub(Integer id);
     void deleteTemporaryClub(Integer id);
 
 
-    List<ClubVo> findClubs(@Param("serviceProviderId") Integer serviceProviderId, @Param("status") Integer status, @Param("name") String name, Integer userIdentity);
+    List<ClubVo> findClubs(@Param("serviceProviderId") Integer serviceProviderId, @Param("status") Integer status, @Param("name") String name, @Param("userIdentity") Integer userIdentity,@Param("type") Integer type,@Param("serviceIds") List<Integer> serviceIds);
 
 
     Integer findOrderNum(ClubVo club);
     Integer findOrderNum(ClubVo club);
+
     /**
     /**
      * 所有的机构列表
      * 所有的机构列表
      */
      */
     List<ClubVo> getAllClubList(String searchWord);
     List<ClubVo> getAllClubList(String searchWord);
+
     /**
     /**
      * 协销信息
      * 协销信息
      */
      */
@@ -75,4 +78,16 @@ public interface SellerMapper {
     Integer findManagerByUser(Integer userId);
     Integer findManagerByUser(Integer userId);
 
 
     Integer findLeaderId(Integer userId);
     Integer findLeaderId(Integer userId);
+
+    Integer findLeaderIdByServiceId(Integer serviceProviderId);
+
+    Integer findmanagerIdByServiceId(Integer serviceProviderId);
+
+    List<Integer> findServiceIds(Integer serviceProviderId);
+
+    List<Integer> findAllServiceIds(Integer serviceProviderId);
+
+    List<ServiceProviderVo> findServices(Integer spId);
+
+    List<ServiceProviderVo> findAllServices(Integer spId);
 }
 }

+ 4 - 0
src/main/java/com/caimei365/user/model/vo/ClubVo.java

@@ -137,6 +137,10 @@ public class ClubVo implements Serializable {
      * 协销ID
      * 协销ID
      */
      */
     private Integer serviceProviderId;
     private Integer serviceProviderId;
+    /**
+     * 协销名称
+     */
+    private String serviceName;
 
 
     /**
     /**
      * 是否分配协销 0.待分配 1.已分配
      * 是否分配协销 0.待分配 1.已分配

+ 9 - 1
src/main/java/com/caimei365/user/service/SellerService.java

@@ -5,9 +5,12 @@ import com.caimei365.user.model.dto.ClubTemporaryDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubVo;
 import com.caimei365.user.model.vo.ClubVo;
+import com.caimei365.user.model.vo.ServiceProviderVo;
 import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.model.vo.UserLoginVo;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 
 
+import java.util.List;
+
 /**
 /**
  * Description
  * Description
  *
  *
@@ -24,7 +27,8 @@ public interface SellerService {
      * @param name              机构名字关键字(搜索用)
      * @param name              机构名字关键字(搜索用)
      * @return
      * @return
      */
      */
-    ResponseJson<PageInfo<ClubVo>> getClubList(Integer serviceProviderId, Integer status, String name, Integer userIdentity, Integer pageNum, Integer pageSize);
+    ResponseJson<PageInfo<ClubVo>> getClubList(Integer serviceProviderId, Integer status, Integer type, String name, Integer userIdentity, Integer groupServiceId, Integer pageNum, Integer pageSize);
+
     /**
     /**
      * 协销登录(手机号,密码)
      * 协销登录(手机号,密码)
      *
      *
@@ -64,13 +68,17 @@ public interface SellerService {
 
 
     /**
     /**
      * 所有的机构列表
      * 所有的机构列表
+     *
      * @param searchWord 搜索关键字
      * @param searchWord 搜索关键字
      */
      */
     ResponseJson<PageInfo<ClubVo>> getAllClubList(String searchWord, int pageNum, int pageSize);
     ResponseJson<PageInfo<ClubVo>> getAllClubList(String searchWord, int pageNum, int pageSize);
 
 
     /**
     /**
      * 协销个人中心
      * 协销个人中心
+     *
      * @param userId 协销用户id
      * @param userId 协销用户id
      */
      */
     ResponseJson<ServiceProviderPo> getSellerHome(Integer userId);
     ResponseJson<ServiceProviderPo> getSellerHome(Integer userId);
+
+    ResponseJson<List<ServiceProviderVo>> getServiceTeam(Integer spId);
 }
 }

+ 46 - 4
src/main/java/com/caimei365/user/service/impl/SellerServiceImpl.java

@@ -10,6 +10,7 @@ import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.po.SuperVipPo;
 import com.caimei365.user.model.po.SuperVipPo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubVo;
 import com.caimei365.user.model.vo.ClubVo;
+import com.caimei365.user.model.vo.ServiceProviderVo;
 import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.service.SellerService;
 import com.caimei365.user.service.SellerService;
 import com.caimei365.user.utils.JwtUtil;
 import com.caimei365.user.utils.JwtUtil;
@@ -21,6 +22,7 @@ import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -54,13 +56,38 @@ public class SellerServiceImpl implements SellerService {
      *                          90:已上线, 91:已冻结, 92:审查资料未通过,待补充资料, 40:已完成第一次采购
      *                          90:已上线, 91:已冻结, 92:审查资料未通过,待补充资料, 40:已完成第一次采购
      *                          66:协销下所有上线的机构----虚拟状态
      *                          66:协销下所有上线的机构----虚拟状态
      * @param name              机构名字关键字(搜索用)
      * @param name              机构名字关键字(搜索用)
+     * @param type              1.我的机构2.组员机构(组长展示全组,总管理员展示所有人)3.待分配机构
      * @return
      * @return
      */
      */
     @Override
     @Override
-    public ResponseJson<PageInfo<ClubVo>> getClubList(Integer serviceProviderId, Integer status, String name, Integer userIdentity, Integer pageNum, Integer pageSize) {
-        PageHelper.startPage(pageNum, pageSize);
+    public ResponseJson<PageInfo<ClubVo>> getClubList(Integer serviceProviderId, Integer status, Integer type, String name, Integer userIdentity, Integer groupServiceId, Integer pageNum, Integer pageSize) {
         // 获取协销用户下的机构列表
         // 获取协销用户下的机构列表
-        List<ClubVo> clubList = sellerMapper.findClubs(serviceProviderId, status, name, userIdentity);
+        List<ClubVo> clubList = new ArrayList<ClubVo>();
+        List<Integer> serviceIds = new ArrayList<Integer>();
+        if (1 == type || 3 == type) {
+            if(null != groupServiceId && groupServiceId > 0){
+                return ResponseJson.success();
+            }else{
+                PageHelper.startPage(pageNum, pageSize);
+                clubList = sellerMapper.findClubs(serviceProviderId, status, name, userIdentity, type, null);
+            }
+        } else if (2 == type) {
+            if (null != groupServiceId && groupServiceId > 0) {
+                PageHelper.startPage(pageNum, pageSize);
+                clubList = sellerMapper.findClubs(groupServiceId, status, name, userIdentity, 1, null);
+            } else {
+                Integer leaderId = sellerMapper.findLeaderIdByServiceId(serviceProviderId);
+                Integer managerId = sellerMapper.findmanagerIdByServiceId(serviceProviderId);
+                if (null != leaderId) {
+                    serviceIds = sellerMapper.findServiceIds(serviceProviderId);
+                }
+                if (null != managerId) {
+                    serviceIds = sellerMapper.findAllServiceIds(serviceProviderId);
+                }
+                PageHelper.startPage(pageNum, pageSize);
+                clubList = sellerMapper.findClubs(serviceProviderId, status, name, userIdentity, type, serviceIds);
+            }
+        }
         for (ClubVo club : clubList) {
         for (ClubVo club : clubList) {
             //未查看订单数量
             //未查看订单数量
             Integer orderNum = sellerMapper.findOrderNum(club);
             Integer orderNum = sellerMapper.findOrderNum(club);
@@ -69,7 +96,7 @@ public class SellerServiceImpl implements SellerService {
             SuperVipPo vip = vipMapper.findEndTime(club.getUserId());
             SuperVipPo vip = vipMapper.findEndTime(club.getUserId());
             if (vip != null) {
             if (vip != null) {
                 club.setVipFlag(1);
                 club.setVipFlag(1);
-            }else {
+            } else {
                 club.setVipFlag(0);
                 club.setVipFlag(0);
             }
             }
         }
         }
@@ -166,4 +193,19 @@ public class SellerServiceImpl implements SellerService {
         return ResponseJson.success(seller);
         return ResponseJson.success(seller);
     }
     }
 
 
+    @Override
+    public ResponseJson<List<ServiceProviderVo>> getServiceTeam(Integer spId) {
+        Integer leaderId = sellerMapper.findLeaderIdByServiceId(spId);
+        Integer managerId = sellerMapper.findmanagerIdByServiceId(spId);
+        List<ServiceProviderVo> serviceProviderVos = new ArrayList<>();
+        if (null != leaderId) {
+            serviceProviderVos = sellerMapper.findServices(spId);
+        }
+        if (null != managerId) {
+            serviceProviderVos = sellerMapper.findAllServices(spId);
+        }
+        //个人返回空,组长返回小组所有人
+        return ResponseJson.success(serviceProviderVos);
+    }
+
 }
 }

+ 56 - 1
src/main/resources/mapper/SellerMapper.xml

@@ -108,10 +108,29 @@
         c.firstClubType, c.secondClubType, c.department, c.medicalPracticeLicenseImg as medicalPracticeLicense,
         c.firstClubType, c.secondClubType, c.department, c.medicalPracticeLicenseImg as medicalPracticeLicense,
         c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status, c.lastCheckOrderDate,
         c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status, c.lastCheckOrderDate,
         u.userIdentity,c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount
         u.userIdentity,c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount
+        <if test="2 == type">
+        ,s.linkMan as serviceName
+        </if>
         from club c
         from club c
         left join user u on c.userID = u.userID
         left join user u on c.userID = u.userID
         LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
         LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
-        where c.spID = #{serviceProviderId}
+        <if test="2 == type">
+        left join serviceprovider s on s.serviceProviderID=c.spID
+        </if>
+        where
+        <if test="1 == type">
+            c.spID = #{serviceProviderId}
+        </if>
+        <if test="2 == type">
+            c.spID in
+            <foreach collection="serviceIds" item="id" index="index" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="3 == type">
+            r.clubId IS NOT NULL
+            AND c.spId=1342
+        </if>
         <if test="status != null and status != 66">
         <if test="status != null and status != 66">
             AND c.status = #{status}
             AND c.status = #{status}
         </if>
         </if>
@@ -167,4 +186,40 @@
         LEFT JOIN serviceprovider s ON s.serviceProviderId=csr.leaderId
         LEFT JOIN serviceprovider s ON s.serviceProviderId=csr.leaderId
         WHERE s.userId = #{userId}
         WHERE s.userId = #{userId}
     </select>
     </select>
+    <select id="findLeaderIdByServiceId" resultType="java.lang.Integer">
+        select leaderId
+        FROM cm_serviceteam_role
+        WHERE leaderId = #{serviceProviderId}
+    </select>
+    <select id="findmanagerIdByServiceId" resultType="java.lang.Integer">
+        SELECT serviceProviderId
+        FROM cm_serviceteam_manager
+        where serviceProviderId = #{serviceProviderId}
+    </select>
+    <select id="findServiceIds" resultType="java.lang.Integer">
+        SELECT csg.serviceId
+        FROM cm_serviceteam_group csg
+        LEFT JOIN  cm_serviceteam_role csr ON csr.id=csg.teamId
+        WHERE csr.leaderId = #{serviceProviderId}
+          AND csg.serviceId != #{serviceProviderId}
+    </select>
+    <select id="findAllServiceIds" resultType="java.lang.Integer">
+        SELECT csg.serviceId FROM cm_serviceteam_group csg
+        WHERE csg.serviceId != #{serviceProviderId}
+    </select>
+    <select id="findServices" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
+        SELECT csg.serviceId as serviceProviderId,s.linkMan as name
+        FROM cm_serviceteam_group csg
+        LEFT JOIN  cm_serviceteam_role csr ON csr.id=csg.teamId
+        left join serviceprovider s on csg.serviceId=s.serviceProviderID
+        WHERE csr.leaderId = #{spId}
+          AND csg.serviceId != #{spId}
+    </select>
+    <select id="findAllServices" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
+        SELECT csg.serviceId AS serviceProviderId,s.linkMan AS NAME
+        FROM cm_serviceteam_group csg
+        LEFT JOIN serviceprovider s ON csg.serviceId=s.serviceProviderID
+        WHERE csg.serviceId != #{spId}
+    </select>
+
 </mapper>
 </mapper>