Bladeren bron

Merge remote-tracking branch 'origin/developer' into developerD

# Conflicts:
#	src/main/java/com/caimei365/user/model/vo/ClubVo.java
huangzhiguo 1 jaar geleden
bovenliggende
commit
23b98d7b41
37 gewijzigde bestanden met toevoegingen van 1539 en 74 verwijderingen
  1. 5 1
      pom.xml
  2. 14 5
      src/main/java/com/caimei365/user/components/WeChatService.java
  3. 10 0
      src/main/java/com/caimei365/user/controller/BaseApi.java
  4. 23 1
      src/main/java/com/caimei365/user/controller/LoginApi.java
  5. 72 0
      src/main/java/com/caimei365/user/controller/SellerApi.java
  6. 13 0
      src/main/java/com/caimei365/user/feign/ToolsFeign.java
  7. 1 0
      src/main/java/com/caimei365/user/mapper/BaseMapper.java
  8. 4 0
      src/main/java/com/caimei365/user/mapper/ClubMapper.java
  9. 5 0
      src/main/java/com/caimei365/user/mapper/LoginMapper.java
  10. 27 5
      src/main/java/com/caimei365/user/mapper/SellerMapper.java
  11. 8 0
      src/main/java/com/caimei365/user/model/dto/ClubRegisterDto.java
  12. 4 0
      src/main/java/com/caimei365/user/model/po/ClubPo.java
  13. 24 0
      src/main/java/com/caimei365/user/model/po/ServiceProviderPo.java
  14. 5 0
      src/main/java/com/caimei365/user/model/vo/ClubVo.java
  15. 96 0
      src/main/java/com/caimei365/user/model/vo/CmBehaviorRecordVo.java
  16. 27 1
      src/main/java/com/caimei365/user/model/vo/MessageCenter.java
  17. 3 0
      src/main/java/com/caimei365/user/model/vo/UserLoginVo.java
  18. 4 0
      src/main/java/com/caimei365/user/service/BaseService.java
  19. 3 0
      src/main/java/com/caimei365/user/service/LoginService.java
  20. 37 4
      src/main/java/com/caimei365/user/service/SellerService.java
  21. 5 0
      src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java
  22. 50 0
      src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java
  23. 52 3
      src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java
  24. 126 7
      src/main/java/com/caimei365/user/service/impl/SellerServiceImpl.java
  25. 92 2
      src/main/java/com/caimei365/user/utils/RequestUtil.java
  26. 377 0
      src/main/java/com/caimei365/user/utils/message/InsideMessage.java
  27. 43 0
      src/main/java/com/caimei365/user/utils/message/MessageModel.java
  28. 41 0
      src/main/java/com/caimei365/user/utils/message/MessageType.java
  29. 65 0
      src/main/java/com/caimei365/user/utils/message/MqInfo.java
  30. 1 1
      src/main/resources/mapper/ArticleMapper.xml
  31. 13 0
      src/main/resources/mapper/BaseMapper.xml
  32. 15 0
      src/main/resources/mapper/ClubMapper.xml
  33. 6 0
      src/main/resources/mapper/LoginMapper.xml
  34. 33 18
      src/main/resources/mapper/MessageCenter.xml
  35. 4 4
      src/main/resources/mapper/RegisterMapper.xml
  36. 208 22
      src/main/resources/mapper/SellerMapper.xml
  37. 23 0
      src/test/java/com/caimei365/user/UserApplicationTests.java

+ 5 - 1
pom.xml

@@ -154,7 +154,11 @@
             <version>3.0.0</version>
         </dependency>
 
-
+        <dependency>
+            <groupId>com.github.tobato</groupId>
+            <artifactId>fastdfs-client</artifactId>
+            <version>1.27.2</version>
+        </dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-test</artifactId>

+ 14 - 5
src/main/java/com/caimei365/user/components/WeChatService.java

@@ -4,6 +4,7 @@ import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei365.user.feign.ToolsFeign;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.utils.RequestUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -13,19 +14,21 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.crypto.Cipher;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URLDecoder;
 import java.security.AlgorithmParameters;
 import java.security.Security;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 微信 服务工具类
@@ -59,6 +62,12 @@ public class WeChatService {
     private String mcareAppId;
     @Value("${wx.mcare-app-secret}")
     private String mcareAppSecret;
+    @Value("${spring.cloud.config.profile}")
+    private String active;
+    @Value("${caimei.imageDomain}")
+    private String imageDomain;
+    @Resource
+    private ToolsFeign toolsFeign;
 
     public void setRedirectUri(String redirectUri) {
         redirectUri = redirectUri;
@@ -288,6 +297,7 @@ public class WeChatService {
         link = link.replace("APPID", crmAppId);
         link = link.replace("APPSECRET", crmAppSecret);
         String result = RequestUtil.sendGet(link);
+        log.info("微信公众号获取access_token>>>" + link);
         log.info("微信公众号获取access_token>>>" + result);
         Map<String, Object> map = JSONObject.parseObject(result, Map.class);
         return (String) map.get("access_token");
@@ -638,5 +648,4 @@ public class WeChatService {
         return ResponseJson.success(result);
     }
 
-
 }

+ 10 - 0
src/main/java/com/caimei365/user/controller/BaseApi.java

@@ -1,5 +1,6 @@
 package com.caimei365.user.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.exceptions.ClientException;
 import com.caimei365.user.components.WeChatService;
 import com.caimei365.user.idempotent.IpSave;
@@ -10,8 +11,10 @@ import com.caimei365.user.model.po.SysDict;
 import com.caimei365.user.model.vo.SysDictVO;
 import com.caimei365.user.service.BaseService;
 import com.caimei365.user.service.SysDictService;
+import com.caimei365.user.utils.RequestUtil;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
@@ -251,6 +254,7 @@ public class BaseApi {
     public ResponseJson getWechatLink(String path, String query, String env) {
         return weChatService.getOpenLink(path, query, env);
     }
+
     @ApiOperation("获取Dict")
     @GetMapping("/getDict")
     public ResponseJson getDict(String type) {
@@ -259,4 +263,10 @@ public class BaseApi {
         }
         return ResponseJson.success(sysDictService.getSysDictList(new SysDict().setType(type)));
     }
+
+    @ApiOperation("获取userId")
+    @GetMapping("/getFindUserId")
+    public ResponseJson getFindUserId(Integer userType, Integer id) {
+        return ResponseJson.success(baseService.getByUserId(userType, id));
+    }
 }

+ 23 - 1
src/main/java/com/caimei365/user/controller/LoginApi.java

@@ -182,6 +182,11 @@ public class LoginApi {
         return loginService.shopMessageCount(messageType, commonId);
     }
 
+    @ApiOperation("协销站内消息未读消息记录数")
+    @GetMapping("/auth/SpCount")
+    public ResponseJson<Map<String, Object>> SpCount(Integer messageType, Integer commonId) {
+        return loginService.SpCount(messageType, commonId);
+    }
     @ApiOperation("供应商站内消息未读消息总记录数")
     @GetMapping("/auth/ShopCount")
     public ResponseJson<Map<String, Object>> ShopCount(Integer messageType, Integer commonId) {
@@ -195,7 +200,15 @@ public class LoginApi {
 
         return loginService.ClubCount(messageType, commonId);
     }
-
+    @ApiOperation("协销站内消息列表")
+    @GetMapping("/auth/SpMessageList")
+    public ResponseJson<PageInfo<MessageCenter>> SpMessageList(Integer commonId,
+                                                               Integer messageType,
+                                                               Integer source,
+                                                               @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                               @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        return loginService.SpMessageList(commonId, messageType, source, pageNum, pageSize);
+    }
 
     @ApiOperation("机构站内消息列表")
     @GetMapping("/auth/ClubMessageList")
@@ -239,6 +252,15 @@ public class LoginApi {
         }
         return ResponseJson.success("标记已读成功", null);
     }
+    @ApiOperation("协销站内消息改为已读")
+    @GetMapping("/auth/updateSpMessageAsRead")
+    public ResponseJson<Void> updateSpMessageAsRead(Integer messageType, Integer commonId) {
+        Integer i = loginService.updateSpMessageAsRead(messageType, commonId);
+        if (i <= 0) {
+            return ResponseJson.error("没有未读消息了!", null);
+        }
+        return ResponseJson.success("标记已读成功", null);
+    }
 
     @ApiOperation("删除站内消息")
     @PostMapping("/auth/deleteMessage")

+ 72 - 0
src/main/java/com/caimei365/user/controller/SellerApi.java

@@ -6,8 +6,10 @@ import com.caimei365.user.model.dto.OnlineDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubVo;
+import com.caimei365.user.model.vo.CmBehaviorRecordVo;
 import com.caimei365.user.model.vo.ServiceProviderVo;
 import com.caimei365.user.service.SellerService;
+import com.caimei365.user.utils.MathUtil;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -17,6 +19,9 @@ import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -106,6 +111,46 @@ public class SellerApi {
         return sellerService.getClubList(spId, status, type, name, userIdentity, groupServiceId, pageNum, pageSize);
     }
 
+    /**
+     * 机构活跃分析
+     */
+    @ApiOperation("机构活跃分析比例")
+    @GetMapping("/club/livelyClub")
+    public ResponseJson<Map<String, Object>> getLivelyClub(Integer spId) {
+        if (null == spId ) {
+            return ResponseJson.error("spId  参数不全!", null);
+        }
+        return sellerService.getLivelyClub(spId);
+    }
+
+    /**
+     * 机构活跃分析
+     * 原spi的 /seller/club/list
+     *
+     * @param spId           协销Id
+     * @param status         机构状态
+     * @param type           1.我的机构2.组员机构3.待分配机构
+     * @param name           机构名字关键字(搜索用)
+     */
+    @ApiOperation("机构活跃分析列表")
+    @GetMapping("/club/livelyClubList")
+    public ResponseJson<Map<String, Object>> getLivelyClubList(Integer spId,
+                                                                         Integer status,
+                                                                         Integer type,
+                                                                         String name,
+                                                                         Integer userIdentity,
+                                                                         @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);
+        }
+        if (4 != type && 5 != type ) {
+            return ResponseJson.error("type 参数错误!", null);
+        }
+
+        return sellerService.getLivelyClubList(spId, status, type, name, userIdentity, pageNum, pageSize);
+    }
+
     @ApiOperation("组员筛选侧边栏")
     @GetMapping("/service/team")
     public ResponseJson<List<ServiceProviderVo>> getClubList(Integer spId) {
@@ -142,4 +187,31 @@ public class SellerApi {
         return sellerService.getSellerHome(userId);
     }
 
+    /**
+     * 更新协销信息
+     */
+    @GetMapping("/setHome")
+    public ResponseJson<ServiceProviderPo> setSellerHome(ServiceProviderPo serviceProviderPo) {
+        return sellerService.setSellerHome(new ServiceProviderPo()
+                .setUserId(serviceProviderPo.getUserId())
+                .setImage(serviceProviderPo.getImage())
+                .setQrCode(serviceProviderPo.getQrCode()));
+
+    }
+    /**
+     * 机构访问列表
+     */
+    @GetMapping("/getBehaviorRecordClub")
+    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer spId, String accDateTime) {
+        return sellerService.getBehaviorRecordClub( spId, accDateTime);
+
+    }
+    /**
+     * 机构访问详情
+     */
+    @GetMapping("/getBehaviorRecordClubFrom")
+    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer spId,Integer clubId,String accessTime) {
+        return sellerService.getBehaviorRecordClubFrom(spId,clubId, accessTime);
+    }
+
 }

+ 13 - 0
src/main/java/com/caimei365/user/feign/ToolsFeign.java

@@ -1,8 +1,14 @@
 package com.caimei365.user.feign;
 
+import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.utils.message.MessageModel;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.HttpHeaders;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Description
@@ -28,4 +34,11 @@ public interface ToolsFeign {
     @PostMapping("/tools/mq/send")
     String sendCommonMessage(@RequestParam String topic, @RequestParam String content, @RequestParam String tag, @RequestParam Integer sort, @RequestParam Integer async, @RequestParam Integer oneway, @RequestParam Integer delay);
 
+    /**
+     * 请求发消息
+     */
+    @PostMapping("/tools/message/send")
+    ResponseJson sendCommonMessage(@RequestBody MessageModel messageModel);
+
+
 }

+ 1 - 0
src/main/java/com/caimei365/user/mapper/BaseMapper.java

@@ -175,4 +175,5 @@ public interface BaseMapper {
     List<String> findLabelsByLableIds(String labelIds);
 
     Integer findBankByUserId(Integer userId);
+    Integer getByUserId(@Param("userType")Integer userType,@Param("id")Integer id);
 }

+ 4 - 0
src/main/java/com/caimei365/user/mapper/ClubMapper.java

@@ -406,4 +406,8 @@ public interface ClubMapper {
     String selSpLinkMan(Integer choseServiceId);
 
     void inProvider(@Param("spId") Integer spId, @Param("clubId") Integer clubId, @Param("operator") String operator, @Param("isOneself") Integer isOneself );
+
+    Integer getSpIdRAND();
+
+    Integer getSpUserId(@Param("spId") Integer spId);
 }

+ 5 - 0
src/main/java/com/caimei365/user/mapper/LoginMapper.java

@@ -176,4 +176,9 @@ public interface LoginMapper {
      */
     Integer getClubTypeById(Integer userId);
 
+    /**
+     * 会员机构类型:1医美,2生
+     */
+    Integer getClubSpUserId(Integer clubId);
+
 }

+ 27 - 5
src/main/java/com/caimei365/user/mapper/SellerMapper.java

@@ -2,14 +2,12 @@ package com.caimei365.user.mapper;
 
 import com.caimei365.user.model.dto.ClubTemporaryDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
-import com.caimei365.user.model.vo.ClubTemporaryVo;
-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.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -36,6 +34,15 @@ public interface SellerMapper {
      */
     void updateServiceProviderByUserId(Integer userId, String openId, String unionId);
 
+    /**
+     * 更新协销信息
+     */
+    Integer setSellerHome(ServiceProviderPo serviceProviderPo);
+    /**
+     * 更新协销头像
+     */
+    Integer setSellerUserHome(@Param("userId")Integer userId, @Param("image")String image);
+
     /**
      * 查询待注册机构数据
      *
@@ -59,7 +66,16 @@ public interface SellerMapper {
      */
     void deleteTemporaryClub(Integer id);
 
-    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);
+    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);
+
+    /***
+     * 功能描述: 机构活跃分析用户登录数量
+     * @auther: Kaick
+     * @date: 2023/8/30 15:25
+     * @param spID
+     * @return [spID]
+     */
+    Map<String, Object> findSpUserLoginSum(@Param("spID") String spID);
 
     Integer findOrderNum(ClubVo club);
 
@@ -90,4 +106,10 @@ public interface SellerMapper {
     List<ServiceProviderVo> findServices(@Param("spId")Integer spId,@Param("status")Integer status);
 
     List<ServiceProviderVo> findAllServices(@Param("spId")Integer spId,@Param("status")Integer status);
+
+    String getBehaviorRecordYesterdayPageLabel(@Param("spId") Integer spId,@Param("clubId") Integer clubId,@Param("accessTime")String accessTime);
+
+    List<CmBehaviorRecordVo> getBehaviorRecordYesterdayClubFrom(@Param("spId") Integer spId, @Param("clubId") Integer clubId, @Param("accessTime")String accessTime);
+
+    List<CmBehaviorRecordVo> getBehaviorRecordYesterdayClub(@Param("spId") Integer spId,@Param("accessTime")String accessTime);
 }

+ 8 - 0
src/main/java/com/caimei365/user/model/dto/ClubRegisterDto.java

@@ -61,6 +61,13 @@ public class ClubRegisterDto implements Serializable {
     @NotNull
     @ApiModelProperty("是否同意勾选同意协议,1是,其他否")
     private Integer isAgreed;
+
+    @NotNull
+    @ApiModelProperty("是否接受匹配客户经理,1是,其他否")
+    private Integer isSp;
+
+    @ApiModelProperty("协销ID")
+    private Integer spId;
     /**
      * 微信unionId
      */
@@ -76,4 +83,5 @@ public class ClubRegisterDto implements Serializable {
      */
     @ApiModelProperty("微信头像(headimgurl)")
     private String avatarUrl;
+
 }

+ 4 - 0
src/main/java/com/caimei365/user/model/po/ClubPo.java

@@ -121,5 +121,9 @@ public class ClubPo implements Serializable {
      * 状态:90:已上线,91:已冻结,92:审查资料未通过,待补充资料,1:待审查资料,2:电话预约,3:已预约,20:待确认,21:待拜访,30:待员工推荐,40:已完成第一次采购
      */
     private Integer status;
+    /**
+     * 新分配机构状态 0.否,1.是
+     */
+    private Integer newDeal;
 }
 

+ 24 - 0
src/main/java/com/caimei365/user/model/po/ServiceProviderPo.java

@@ -1,8 +1,20 @@
 package com.caimei365.user.model.po;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.aliyuncs.http.HttpRequest;
+import com.caimei365.user.utils.RequestUtil;
+import com.caimei365.user.utils.message.InsideMessage;
+import com.caimei365.user.utils.message.MessageModel;
+import com.caimei365.user.utils.message.MessageType;
+import com.caimei365.user.utils.message.MqInfo;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 协销
@@ -10,6 +22,7 @@ import java.io.Serializable;
  * @author : Aslee
  * @date : 2021/3/18
  */
+@Accessors(chain  = true )
 @Data
 public class ServiceProviderPo implements Serializable {
     private static final long serialVersionUID = 1L;
@@ -72,6 +85,16 @@ public class ServiceProviderPo implements Serializable {
      */
     private String validFlag;
 
+    /**
+     * 头像
+     */
+    private String image;
+
+    /**
+     * 协销二维码
+     */
+    private String qrCode;
+
     /**
      * 创建时间
      */
@@ -80,4 +103,5 @@ public class ServiceProviderPo implements Serializable {
      * 创客经理Id
      */
     private Integer mainServiceProviderId;
+
 }

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

@@ -200,6 +200,11 @@ public class ClubVo implements Serializable {
      */
     private String ipAddress;
 
+    /***
+     * 分配时间:
+     */
+    private Date providerTime;
+
     /**
      * 沟通情况
      */

+ 96 - 0
src/main/java/com/caimei365/user/model/vo/CmBehaviorRecordVo.java

@@ -0,0 +1,96 @@
+package com.caimei365.user.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 用户行为记录对象 cm_behavior_record
+ *
+ * @author Kaick
+ * @date 2023-09-06
+ */
+@Accessors(chain  = true )
+@Data
+@Alias("CmBehaviorRecordVo")
+public class CmBehaviorRecordVo implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private String recordID;
+
+    /** 访问人IP地址 */
+    private String IP;
+
+    /** 用户id、0为游客 */
+    private Integer userID;
+
+    /** 页面路径 */
+    private String pagePath;
+
+    /** 页面类型 */
+    private String pageType;
+
+    /** 页面标签 */
+    private String pageLabel;
+
+    /** 用户行为类型1:用户行为记录、2:ROOS页面统计 */
+    private String behaviorType;
+
+    /** 商品ID */
+    private Integer productID;
+
+    /** 访问时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date accessTime;
+
+    /** 访问时长 */
+    private String accessDuration;
+
+    /** 访问日期 */
+    private String accessDate;
+
+    /** 浏览器链接 */
+    private String referer;
+
+    /** 0直接访问 1百度搜索 2360搜索 3谷歌搜索 4神马搜索 5头条搜索 6搜狗搜索 7小程序 */
+    private String accessSource;
+
+    /** 访问客户端  0:网站 1:小程序 */
+    private String accessClient;
+
+    /** 是否计算访问时长 0未计算 1已计算 */
+    private String isReckon;
+
+    /** ip所属地 */
+    private String region;
+
+    /** 请求头 userAgent */
+    private String userAgent;
+
+    /** 图片 */
+    private String image;
+
+    /** 标题Id */
+    private Integer titleId;
+    /** 标题 */
+    private String title;
+    /** 标题图片 */
+    private String titleImage;
+    /** 内容 */
+    private String content;
+    /** 机构Id */
+    private Integer clubId;
+    /** 名称 */
+    private String name;
+    /** 联系人 */
+    private String linkMan;
+    /** 手机号 */
+    private String contractMobile;
+
+}

+ 27 - 1
src/main/java/com/caimei365/user/model/vo/MessageCenter.java

@@ -70,7 +70,7 @@ public class MessageCenter implements Serializable {
      */
     private Integer shopMessType;
     /**
-     * 供应商服务消息类型 1.上架费
+     * 服务消息类型 1.上架费,2.机构重新分配通知,3.机构转移分配通知,4.机构分配通知,5.客户经理分配通知,6.客户经理重新分配通知,7.机构访问通知,8机构回收通知
      */
     private Integer shopTieredType;
     /**
@@ -111,4 +111,30 @@ public class MessageCenter implements Serializable {
      * 失败原因
      */
     private String reasonContent;
+
+
+    /** 手机号 */
+    private String mobile;
+
+    /** 名称 */
+    private String name;
+
+    /**
+     * 用户名称
+     */
+    private String userName;
+
+    /**
+     * 前用户名称
+     */
+    private String superUserName;
+
+    /**
+     * 当前id
+     */
+    private Integer thisId;
+    /**
+     * 数量
+     */
+    private Integer sum;
 }

+ 3 - 0
src/main/java/com/caimei365/user/model/vo/UserLoginVo.java

@@ -19,6 +19,9 @@ public class UserLoginVo implements Serializable {
      */
     @ApiModelProperty("用户Id")
     private Integer userId;
+
+    @ApiModelProperty("协销用户Id")
+    private Integer spUserId;
     /**
      * 组织Id
      */

+ 4 - 0
src/main/java/com/caimei365/user/service/BaseService.java

@@ -4,6 +4,7 @@ import com.aliyuncs.exceptions.ClientException;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.MobileDto;
 import com.caimei365.user.model.dto.PasswordDto;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -130,4 +131,7 @@ public interface BaseService {
     ResponseJson findPackage();
 
     ResponseJson<HashMap<String, String>> ossTokenGet() throws ClientException;
+
+    ResponseJson<Integer>  getByUserId(Integer userType, Integer userId);
+
 }

+ 3 - 0
src/main/java/com/caimei365/user/service/LoginService.java

@@ -86,6 +86,7 @@ public interface LoginService {
      */
     ResponseJson<UserLoginVo> appletsOrganizeAuthorization(String code, String encryptedData, String iv, HttpHeaders headers) throws ParseException;
 
+    ResponseJson<PageInfo<MessageCenter>> SpMessageList(Integer commonId,Integer messageType,Integer source, int pageNum, int pageSize);
     ResponseJson<PageInfo<MessageCenter>> ClubMessageList(Integer commonId,Integer messageType,Integer source, int pageNum, int pageSize);
 
     ResponseJson<PageInfo<MessageCenter>> shopMessageList(Integer commonId,Integer messageType,Integer source, int pageNum, int pageSize);
@@ -94,6 +95,7 @@ public interface LoginService {
 
     ResponseJson<Map<String, Object>> shopMessageCount(Integer messageType,Integer commonId);
 
+    ResponseJson<Map<String, Object>> SpCount(Integer messageType,Integer commonId);
     ResponseJson<Map<String, Object>> ShopCount(Integer messageType,Integer commonId);
 
     ResponseJson<Map<String, Object>> ClubCount(Integer messageType,Integer commonId);
@@ -101,6 +103,7 @@ public interface LoginService {
      Integer updateMessageAsRead(Integer messageType,Integer commonId);
 
     Integer updateShopMessageAsRead(Integer messageType,Integer commonId);
+    Integer updateSpMessageAsRead(Integer messageType,Integer commonId);
 
      Integer updateRead(Integer userType,String Id);
 

+ 37 - 4
src/main/java/com/caimei365/user/service/SellerService.java

@@ -4,13 +4,11 @@ import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubTemporaryDto;
 import com.caimei365.user.model.dto.LoginCodeDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
-import com.caimei365.user.model.vo.ClubTemporaryVo;
-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.*;
 import com.github.pagehelper.PageInfo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -29,7 +27,30 @@ public interface SellerService {
      * @return
      */
     ResponseJson<PageInfo<ClubVo>> getClubList(Integer serviceProviderId, Integer status, Integer type, String name, Integer userIdentity, Integer groupServiceId, Integer pageNum, Integer pageSize);
+/**
+ * 功能描述: 机构活跃分析
+ * @auther: Kaick
+ * @date: 2023/8/30 16:54
+ * @param serviceProviderId
+ * @param status
+ * @param type
+ * @param name
+ * @param userIdentity
+ * @param pageNum
+ * @param pageSize
+ * @return [serviceProviderId, status, type, name, userIdentity, pageNum, pageSize]
+ */
+
+    ResponseJson<Map<String, Object>> getLivelyClubList(Integer serviceProviderId, Integer status, Integer type, String name, Integer userIdentity, Integer pageNum, Integer pageSize);
+    /**
+     * 功能描述: 机构活跃分析比例
+     * @auther: Kaick
+     * @date: 2023/9/4 9:48
+     * @param
+     * @return []
+     */
 
+    ResponseJson<Map<String, Object>> getLivelyClub(Integer serviceProviderId);
     /**
      * 协销登录(手机号,密码)
      *
@@ -86,6 +107,18 @@ public interface SellerService {
      * @param userId 协销用户id
      */
     ResponseJson<ServiceProviderPo> getSellerHome(Integer userId);
+    /**
+     * 功能描述: 更新协销信息
+     * @auther: Kaick
+     * @date: 2023/9/4 10:02
+     * @param serviceProviderPo
+     * @return [serviceProviderPo]
+     */
+
+    ResponseJson setSellerHome(ServiceProviderPo serviceProviderPo);
+
+    ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer spId,String accessTime);
+    ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer spId, Integer clubId, String accessTime);
 
     ResponseJson<List<ServiceProviderVo>> getServiceTeam(Integer spId,Integer status);
 }

+ 5 - 0
src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java

@@ -800,4 +800,9 @@ public class BaseServiceImpl implements BaseService {
         }
         return superVipDto;
     }
+
+    @Override
+    public ResponseJson<Integer> getByUserId(Integer userType, Integer id) {
+        return ResponseJson.success(baseMapper.getByUserId(userType, id));
+    }
 }

+ 50 - 0
src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java

@@ -553,6 +553,21 @@ public class LoginServiceImpl implements LoginService {
         return ResponseJson.success(map);
     }
 
+    @Override
+    public ResponseJson<Map<String, Object>> SpCount(Integer messageType, Integer commonId) {
+        Integer count = messageCenterMapper.Count(3, commonId);
+        Integer tradeCount = messageCenterMapper.MessageCount(3, 1, commonId);
+        Integer accountCount = messageCenterMapper.MessageCount(3, 2, commonId);
+        Integer notificationCount = messageCenterMapper.MessageCount(3, 3, commonId);
+        Integer promotionCount = messageCenterMapper.MessageCount(3, 4, commonId);
+        Map<String, Object> map = new HashMap(10);
+        map.put("count", count);
+        map.put("tradeCount", tradeCount);
+        map.put("accountCount", accountCount);
+        map.put("notificationCount", notificationCount);
+        map.put("promotionCount", promotionCount);
+        return ResponseJson.success(map);
+    }
     @Override
     public ResponseJson<Map<String, Object>> ShopCount(Integer messageType, Integer commonId) {
         Integer count = messageCenterMapper.Count(2, commonId);
@@ -579,6 +594,10 @@ public class LoginServiceImpl implements LoginService {
     public Integer updateShopMessageAsRead(Integer messageType, Integer commonId) {
         return messageCenterMapper.updateMessageAsRead(2, messageType, commonId);
     }
+    @Override
+    public Integer updateSpMessageAsRead(Integer messageType, Integer commonId) {
+        return messageCenterMapper.updateMessageAsRead(3, messageType, commonId);
+    }
 
     @Override
     public Integer deleteMessage(String id) {
@@ -601,6 +620,34 @@ public class LoginServiceImpl implements LoginService {
     }
 
 
+    @Override
+    public ResponseJson<PageInfo<MessageCenter>> SpMessageList(Integer commonId, Integer messageType, Integer source, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<MessageCenter> list = messageCenterMapper.MessageList(3, messageType, commonId);
+        list.forEach(mess -> {
+            if (null != mess.getClubId()) {
+                MessageCenter messageCenter = messageCenterMapper.MainImage(3, commonId, mess.getOrderId());
+                Integer productCount=messageCenterMapper.productCount(mess.getOrderId());
+                if (null != messageCenter) {
+                    mess.setMainImage(messageCenter.getMainImage());
+                    mess.setOnlinePayFlag(messageCenter.getOnlinePayFlag());
+                    if (messageCenter.getProductName().length() > 10) {
+                        mess.setProductName(StringUtils.strip(messageCenter.getProductName().substring(0, 11)));
+                    } else {
+                        mess.setProductName(messageCenter.getProductName());
+                    }
+                    mess.setProductCount(productCount);
+                    mess.setRefundType(messageCenter.getRefundType());
+                    mess.setStatus(messageCenter.getStatus());
+                }
+            }
+        });
+        if (source == 2) {
+            messageCenterMapper.updateMessageAsRead(3, messageType, commonId);
+        }
+        PageInfo<MessageCenter> pageData = new PageInfo<>(list);
+        return ResponseJson.success(pageData);
+    }
     @Override
     public ResponseJson<PageInfo<MessageCenter>> ClubMessageList(Integer commonId, Integer messageType, Integer source, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
@@ -836,6 +883,9 @@ public class LoginServiceImpl implements LoginService {
 //        }
 
         if (loginUser.getUserId() != null) {
+            if(loginUser.getClubId() != null&&loginUser.getClubId()!=1342){
+                loginUser.setSpUserId(loginMapper.getClubSpUserId(loginUser.getClubId()));
+            }
             Integer shopID = messageCenterMapper.shopID(loginUser.getUserId());
             Integer newReceiptType = messageCenterMapper.newReceiptType(shopID);
             Integer listingFeeCount= messageCenterMapper.listingFee(shopID);

+ 52 - 3
src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java

@@ -12,6 +12,10 @@ import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.RegisterService;
 import com.caimei365.user.service.RemoteCallService;
 import com.caimei365.user.utils.*;
+import com.caimei365.user.utils.message.InsideMessage;
+import com.caimei365.user.utils.message.MessageModel;
+import com.caimei365.user.utils.message.MessageType;
+import com.caimei365.user.utils.message.MqInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -154,6 +158,11 @@ public class RegisterServiceImpl implements RegisterService {
         if (passResult != null) {
             return ResponseJson.error(passResult);
         }
+        // 协销Id,默认采美官方
+        Integer spId =1342;
+        if (null !=clubRegisterDto.getIsSp()&&1 ==clubRegisterDto.getIsSp()) {
+            spId =null!= clubRegisterDto.getSpId()?clubRegisterDto.getSpId():clubMapper.getSpIdRAND();
+        }
         // 获取ip所在地
         String ipAddress = "";
         Integer provinceId = null;
@@ -212,7 +221,7 @@ public class RegisterServiceImpl implements RegisterService {
         // 用户状态,1正常,0冻结
         user.setValidFlag(1);
         // 协销Id,默认采美官方
-        user.setServiceProviderId(1342);
+        user.setServiceProviderId(spId);
         // 协销状态,已上线
         user.setServiceProviderStatus(90);
         //采美豆
@@ -246,7 +255,7 @@ public class RegisterServiceImpl implements RegisterService {
         // 用户Id
         club.setUserId(user.getUserId());
         // 协销Id(spId)
-        club.setServiceProviderId(1342);
+        club.setServiceProviderId(spId);
         // 注册时间
         club.setAddTime(current);
         // 状态设置上线
@@ -272,7 +281,46 @@ public class RegisterServiceImpl implements RegisterService {
         registerMapper.updateUserClubId(user.getUserId(), club.getClubId());
         // 添加机构协销记录
         if (StringUtils.isNotBlank(club.getLinkMan())) {
-            clubMapper.inProvider(1342, club.getClubId(), club.getLinkMan(), 0);
+            clubMapper.inProvider(spId, club.getClubId(), spId!=1342?"系统自动分配":club.getLinkMan(), 0);
+            if(spId!=1342) {
+                log.info("注册普通机构,开始站内信推送");
+                String selSpName = clubMapper.selSpName(spId);
+                String spMessage = "【采美365】系统已为你分配机构客户,请及时跟进。机构名称【" + user.getUserName() + "】,联系人【" + user.getUserName() + "】,手机号【" + user.getBindMobile() + "】。";
+                String mobile = vipMapper.findMobile(clubMapper.getSpUserId(spId));
+                String clubMessage = "【采美365】采美平台已为您提供专属客户经理,为您提供专业服务。客户经理【" + selSpName + "】,手机号【" + mobile + "】。";
+                if (mobile != null && mobile != "") {
+                    log.info("注册普通机构,发送站内信推送");
+                    //站内信
+                    MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+                    insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                            .mqInfo(new MqInfo().topic("MessageLine").delay(1).async(0))
+                            .info(new InsideMessage()
+                                    .userType(3)
+                                    .messageType(3)
+                                    .shopTieredType(4)
+                                    .name(user.getUserName())
+                                    .userName(user.getUserName())
+                                    .mobile(user.getBindMobile())
+                                    .thisId(spId)
+                                    .clubId(club.getClubId())
+                            );
+                    smsFeign.sendCommonMessage(insideMessageMessageModel);
+
+                    insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                            .info(new InsideMessage()
+                                    .userType(1)
+                                    .messageType(3)
+                                    .shopTieredType(5)
+                                    .userName(selSpName)
+                                    .mobile(mobile)
+                                    .clubId(club.getClubId())
+                            );
+                    smsFeign.sendCommonMessage(insideMessageMessageModel);
+                    //短信
+                    remoteCallService.remoteSendSms(25, 1, mobile, spMessage);
+                    remoteCallService.remoteSendSms(25, 1, user.getBindMobile(), clubMessage);
+                }
+            }
         }
         //推送信息中心-账户通知
         MessageCenter messageCenter = new MessageCenter();
@@ -911,6 +959,7 @@ public class RegisterServiceImpl implements RegisterService {
         club.setServiceProviderId(serviceProvider.getServiceProviderId());
         // 待扫描
         club.setScanFlag(0);
+
         // 注册时间
         club.setAddTime(current);
         // 会员机构,填写升级资料

+ 126 - 7
src/main/java/com/caimei365/user/service/impl/SellerServiceImpl.java

@@ -2,9 +2,7 @@ package com.caimei365.user.service.impl;
 
 import com.caimei365.user.components.RedisService;
 import com.caimei365.user.components.WeChatService;
-import com.caimei365.user.mapper.LoginMapper;
-import com.caimei365.user.mapper.SellerMapper;
-import com.caimei365.user.mapper.SuperVipMapper;
+import com.caimei365.user.mapper.*;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubTemporaryDto;
 import com.caimei365.user.model.dto.LoginCodeDto;
@@ -13,16 +11,25 @@ import com.caimei365.user.model.po.SuperVipPo;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.SellerService;
 import com.caimei365.user.utils.JwtUtil;
+import com.caimei365.user.utils.MathUtil;
 import com.caimei365.user.utils.Md5Util;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * Description
@@ -41,6 +48,10 @@ public class SellerServiceImpl implements SellerService {
     @Resource
     private SellerMapper sellerMapper;
     @Resource
+    private ShopMapper shopMapper;
+    @Resource
+    private ArticleMapper articleMapper;
+    @Resource
     private SuperVipMapper vipMapper;
     @Resource
     private LoginMapper loginMapper;
@@ -63,7 +74,7 @@ public class SellerServiceImpl implements SellerService {
         // 获取协销用户下的机构列表
         List<ClubVo> clubList = new ArrayList<ClubVo>();
         List<Integer> serviceIds = new ArrayList<Integer>();
-        if (1 == type || 3 == type) {
+        if (1 == type || 3 == type|| 6 == type) {
             if(null != groupServiceId && groupServiceId > 0){
                 return ResponseJson.success();
             }else{
@@ -112,6 +123,49 @@ public class SellerServiceImpl implements SellerService {
         return ResponseJson.success(pageData);
     }
 
+    /**
+     * 机构活跃分析
+     *
+     * @param serviceProviderId 协销Id
+     * @param status            机构状态:
+     *                          1:待审查资料, 2:电话预约, 3:已预约
+     *                          20:待确认, 21:待拜访, 30:待员工推荐
+     *                          90:已上线, 91:已冻结, 92:审查资料未通过,待补充资料, 40:已完成第一次采购
+     *                          66:协销下所有上线的机构----虚拟状态
+     * @param name              机构名字关键字(搜索用)
+     * @param type              1.我的机构2.组员机构(组长展示全组,总管理员展示所有人)3.待分配机构
+     * @return
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getLivelyClubList(Integer serviceProviderId, Integer status, Integer type, String name, Integer userIdentity, Integer pageNum, Integer pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        Map<String, Object> map = new HashMap<>();
+        map.put("clubList", new PageInfo<>(sellerMapper.findClubs(serviceProviderId, status, name, userIdentity, type, null)));
+        return ResponseJson.success(map);
+    }
+    /**
+     * 功能描述: 机构活跃分析比例
+     * @auther: Kaick
+     * @date: 2023/9/4 9:48
+     * @param
+     * @return []
+     */
+
+    @Override
+    public ResponseJson<Map<String, Object>> getLivelyClub(Integer serviceProviderId) {
+        Map<String, Object> map = new HashMap<>();
+        Map<String, Object> spUserLoginSum = sellerMapper.findSpUserLoginSum(serviceProviderId.toString());
+        Integer loginSum = Integer.valueOf(spUserLoginSum.get("loginSum").toString());
+        Integer not_loginSum = Integer.valueOf(spUserLoginSum.get("not_loginSum").toString());
+//        机构活跃与不活跃占比计算方法,例如:机构活跃数/机构活跃数+机构不活跃数(60/(60+30)=0.666...),保留小数点后2位,四舍五入,0.67;
+        BigDecimal livelyClubProportion = new BigDecimal((loginSum + not_loginSum) != 0 ?(double) loginSum / (loginSum + not_loginSum) * 100 : 0).setScale(2, RoundingMode.UP);
+        map.put("livelyClub", loginSum);
+        map.put("noLivelyClub", not_loginSum);
+        map.put("livelyClubProportion", livelyClubProportion);
+        map.put("noLivelyClubProportion", MathUtil.sub(100, livelyClubProportion).setScale(2));
+        return ResponseJson.success(map);
+    }
+
     /**
      * 协销登录(手机号,密码)
      *
@@ -289,16 +343,81 @@ public class SellerServiceImpl implements SellerService {
         return ResponseJson.success(seller);
     }
 
+
+    @Override
+    public ResponseJson setSellerHome(ServiceProviderPo serviceProviderPo) {
+        // 协销用户
+        if (StringUtils.isNotBlank(serviceProviderPo.getImage())) {
+            sellerMapper.setSellerUserHome(serviceProviderPo.getUserId(), serviceProviderPo.getImage());
+        }
+        if (StringUtils.isNotBlank(serviceProviderPo.getQrCode())) {
+            sellerMapper.setSellerHome(serviceProviderPo);
+        }
+        return ResponseJson.success("");
+    }
+
+    @Override
+    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer spId, String accessTime) {
+       // 设置日期格式
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate date = LocalDate.parse(accessTime, formatter);
+        // 获取前一天的日期
+        LocalDate dayBeforeYesterday = date.minusDays(1);
+        // 格式化日期
+        accessTime= dayBeforeYesterday.format(formatter);
+        List<CmBehaviorRecordVo> behaviorRecordYesterdayClub = sellerMapper.getBehaviorRecordYesterdayClub(spId, accessTime);
+        for (CmBehaviorRecordVo cmBehaviorRecordVo : behaviorRecordYesterdayClub) {
+            String pageLabel = sellerMapper.getBehaviorRecordYesterdayPageLabel(spId, cmBehaviorRecordVo.getClubId(), accessTime);
+            cmBehaviorRecordVo.setPageLabel(pageLabel);
+        }
+        return ResponseJson.success(behaviorRecordYesterdayClub);
+    }
+
+    @Override
+    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer spId, Integer clubId, String accessTime) {
+        // 设置日期格式
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate date = LocalDate.parse(accessTime, formatter);
+        // 获取前一天的日期
+        LocalDate dayBeforeYesterday = date.minusDays(1);
+        // 格式化日期
+        accessTime= dayBeforeYesterday.format(formatter);
+        List<CmBehaviorRecordVo> behaviorRecordYesterdayClubFrom = sellerMapper.getBehaviorRecordYesterdayClubFrom(spId, clubId, accessTime);
+        for (CmBehaviorRecordVo cmBehaviorRecordVo : behaviorRecordYesterdayClubFrom) {
+            String pageLabel = sellerMapper.getBehaviorRecordYesterdayPageLabel(spId, cmBehaviorRecordVo.getClubId(), accessTime);
+            cmBehaviorRecordVo.setPageLabel(pageLabel);
+            if (cmBehaviorRecordVo.getProductID() != 0 && cmBehaviorRecordVo.getPageType().equals("6") ) {
+                ProductItemVo productShown = shopMapper.getProductShown(cmBehaviorRecordVo.getProductID());
+                cmBehaviorRecordVo.setTitleId(cmBehaviorRecordVo.getProductID());
+                cmBehaviorRecordVo.setTitle(productShown.getName());
+                cmBehaviorRecordVo.setTitleImage(productShown.getImage());
+            }else if ( cmBehaviorRecordVo.getPageType().equals("11") ) {
+                //获取文章id
+                Integer id = null;
+                Pattern pattern = Pattern.compile("info/detail-(.*?)-");
+                Matcher matcher = pattern.matcher(cmBehaviorRecordVo.getPagePath());
+                if (matcher.find()) {
+                    id= Integer.valueOf(matcher.group(1));
+                }
+                ShopArticleVo info = articleMapper.getShopArticleById(id);
+                cmBehaviorRecordVo.setTitleId(id);
+                cmBehaviorRecordVo.setTitle(info.getTitle());
+                cmBehaviorRecordVo.setTitleImage(info.getGuidanceImage());
+            }
+        }
+        return ResponseJson.success(behaviorRecordYesterdayClubFrom);
+    }
+
     @Override
-    public ResponseJson<List<ServiceProviderVo>> getServiceTeam(Integer spId,Integer status) {
+    public ResponseJson<List<ServiceProviderVo>> getServiceTeam(Integer spId, Integer status) {
         Integer leaderId = sellerMapper.findLeaderIdByServiceId(spId);
         Integer managerId = sellerMapper.findmanagerIdByServiceId(spId);
         List<ServiceProviderVo> serviceProviderVos = new ArrayList<>();
         if (null != leaderId) {
-            serviceProviderVos = sellerMapper.findServices(spId,status);
+            serviceProviderVos = sellerMapper.findServices(spId, status);
         }
         if (null != managerId) {
-            serviceProviderVos = sellerMapper.findAllServices(spId,status);
+            serviceProviderVos = sellerMapper.findAllServices(spId, status);
         }
         //个人返回空,组长返回小组所有人
         return ResponseJson.success(serviceProviderVos);

+ 92 - 2
src/main/java/com/caimei365/user/utils/RequestUtil.java

@@ -1,5 +1,12 @@
 package com.caimei365.user.utils;
 
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.protocol.HttpContext;
 import org.springframework.util.StringUtils;
 
 import javax.net.ssl.HttpsURLConnection;
@@ -7,8 +14,7 @@ import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 import java.io.*;
-import java.net.URL;
-import java.net.URLConnection;
+import java.net.*;
 import java.nio.charset.StandardCharsets;
 import java.security.cert.X509Certificate;
 import java.util.List;
@@ -117,7 +123,31 @@ public class RequestUtil {
         }
         return result.toString();
     }
+    public static ByteArrayInputStream sendPost(String url, String params) throws URISyntaxException, IOException {
+        CloseableHttpClient client = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost();
+        httpPost.addHeader("Content-type","application/json;charset=UTF-8");
+        httpPost.setHeader("Accept","application/json");
+        URI uri = new URI(url);
+        httpPost.setURI(uri);
+        StringEntity entity = new StringEntity(params, "UTF-8");
+        httpPost.setEntity(entity);
+        CloseableHttpResponse response = client.execute(httpPost, (HttpContext) null);
+        HttpEntity responseEntity = response.getEntity();
+        InputStream inputStream = responseEntity.getContent();
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        byte[] buffer = new byte[1024];
+        int len = 0;
+        while ((len = inputStream.read(buffer)) != -1) {
+            outputStream.write(buffer, 0, len);
+        }
+        inputStream.close();
+        ByteArrayInputStream byteInputStream = new ByteArrayInputStream(outputStream.toByteArray());
+        outputStream.flush();
+        outputStream.close();
+        return byteInputStream;
 
+    }
     /**
      * 向指定 URL 发送请求
      * @param requestUrl 发送请求的 URL
@@ -184,4 +214,64 @@ public class RequestUtil {
         } catch (Exception ignored) {}
         return null;
     }
+
+    public static String sendPost(String url, String param, String contentType) {
+        OutputStreamWriter out = null;
+        BufferedReader in = null;
+        String result = "";
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
+            // 设置通用的请求属性
+            conn.setRequestProperty("accept", "*/*");
+            conn.setRequestProperty("connection", "Keep-Alive");
+            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+            conn.setRequestProperty("Content-Type", contentType);
+            // 发送POST请求必须设置如下两行
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+
+            /*************************************************************************/
+            // 获取URLConnection对象对应的输出流
+            // out = new PrintWriter(conn.getOutputStream());
+            out = new OutputStreamWriter(conn.getOutputStream(), "utf-8"); // 8859_1
+            /*************************************************************************/
+
+            out.write(param); // post的关键所在
+            // 发送请求参数
+            // out.print(param);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应
+            int code = conn.getResponseCode();
+            if(code == 200) {
+                in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+            }else{
+                in = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
+            }
+            String line;
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+        } catch (Exception e) {
+            System.out.println("发送 POST 请求出现异常!" + e);
+            e.printStackTrace();
+        }
+        // 使用finally块来关闭输出流、输入流
+        finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return result;
+    }
+
 }

+ 377 - 0
src/main/java/com/caimei365/user/utils/message/InsideMessage.java

@@ -0,0 +1,377 @@
+package com.caimei365.user.utils.message;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author Administrator
+ * 站内信model
+ */
+@Data
+@Accessors(fluent = true)
+public class InsideMessage implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 消息id
+     */
+    private Integer id;
+    /**
+     * 供应商id
+     */
+    private Integer shopId;
+    /**
+     * 机构id
+     */
+    private Integer clubId;
+    /**
+     * 订单ID
+     */
+    private Integer orderId;
+    /**
+     * 用户类型1.机构2.供应商
+     */
+    private Integer userType;
+    /**
+     * 消息类型1.交易物流2.账户通知3.服务通知4.优惠促销
+     */
+    private Integer messageType;
+    /**
+     * 消息内容
+     */
+    private String content;
+
+    /**
+     * 失败原因
+     */
+    private String reasonContent;
+    /**
+     * 操作完成时间
+     */
+    private String time;
+    /**
+     * 账户通知类型 1.注册成功通知 2.购买超级会员成功 3.超级会员到期提醒 4.超级会员到期提醒 5.升级资质机构成功 6.升级资质机构失败 7.成为机构运营人员通知
+     */
+    private Integer accountType;
+    /**
+     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     */
+    private Integer couponType;
+    /**
+     * 优惠券金额
+     */
+    private Double couponFee;
+    /**
+     * 主图
+     */
+    private String mainImage;
+    /**
+     * 是否能走线上支付 0可以 1不可以 只能线下
+     */
+    private Integer onlinePayFlag;
+    /**
+     * 商品名称
+     */
+    private String productName;
+    /**
+     * 供应商消息类型 1,账号审核通知,2.成为公司运营人员通知,3.商品上架审核通知,4.新品展示审核通知,5.上架费到期通知 6.商品资质到期通知
+     */
+    private Integer shopMessType;
+    /**
+     * 供应商服务消息类型 1.上架费
+     */
+    private Integer shopTieredType;
+    /**
+     * 交易物流1.下单成功通知  2.订单支付完成 3.退款/货成功通知 4.订单取消通知 5.订单发货通知 6.自动收货通知
+     */
+    private Integer orderMessageType;
+    /**
+     * 0.未读 , 1.已读
+     */
+    private Integer saved;
+    /**
+     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     */
+    private Integer couponMessageType;
+    /**
+     * 商品记录数
+     */
+    private Integer productCount;
+    /**
+     * 退货退款类型:1部分退、2全部退
+     */
+    private Integer refundType;
+
+    /**
+     * 订单状态
+     */
+    private Integer status;
+    /**
+     * 商品ID
+     */
+    private Integer productId;
+
+    /** 手机号 */
+    private String mobile;
+
+    /** 名称 */
+    private String name;
+
+    /** 用户名称 */
+    private String userName;
+
+    /** 前用户名称 */
+    private String superUserName;
+
+    /** 当前id */
+    private Integer thisId;
+
+    /**
+     * 供应商公司名称
+     */
+
+    private String shopName;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public Integer getClubId() {
+        return clubId;
+    }
+
+    public void setClubId(Integer clubId) {
+        this.clubId = clubId;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getUserType() {
+        return userType;
+    }
+
+    public void setUserType(Integer userType) {
+        this.userType = userType;
+    }
+
+    public Integer getMessageType() {
+        return messageType;
+    }
+
+    public void setMessageType(Integer messageType) {
+        this.messageType = messageType;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getReasonContent() {
+        return reasonContent;
+    }
+
+    public void setReasonContent(String reasonContent) {
+        this.reasonContent = reasonContent;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public Integer getAccountType() {
+        return accountType;
+    }
+
+    public void setAccountType(Integer accountType) {
+        this.accountType = accountType;
+    }
+
+    public Integer getCouponType() {
+        return couponType;
+    }
+
+    public void setCouponType(Integer couponType) {
+        this.couponType = couponType;
+    }
+
+    public Double getCouponFee() {
+        return couponFee;
+    }
+
+    public void setCouponFee(Double couponFee) {
+        this.couponFee = couponFee;
+    }
+
+    public String getMainImage() {
+        return mainImage;
+    }
+
+    public void setMainImage(String mainImage) {
+        this.mainImage = mainImage;
+    }
+
+    public Integer getOnlinePayFlag() {
+        return onlinePayFlag;
+    }
+
+    public void setOnlinePayFlag(Integer onlinePayFlag) {
+        this.onlinePayFlag = onlinePayFlag;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public Integer getShopMessType() {
+        return shopMessType;
+    }
+
+    public void setShopMessType(Integer shopMessType) {
+        this.shopMessType = shopMessType;
+    }
+
+    public Integer getShopTieredType() {
+        return shopTieredType;
+    }
+
+    public void setShopTieredType(Integer shopTieredType) {
+        this.shopTieredType = shopTieredType;
+    }
+
+    public Integer getOrderMessageType() {
+        return orderMessageType;
+    }
+
+    public void setOrderMessageType(Integer orderMessageType) {
+        this.orderMessageType = orderMessageType;
+    }
+
+    public Integer getSaved() {
+        return saved;
+    }
+
+    public void setSaved(Integer saved) {
+        this.saved = saved;
+    }
+
+    public Integer getCouponMessageType() {
+        return couponMessageType;
+    }
+
+    public void setCouponMessageType(Integer couponMessageType) {
+        this.couponMessageType = couponMessageType;
+    }
+
+    public Integer getProductCount() {
+        return productCount;
+    }
+
+    public void setProductCount(Integer productCount) {
+        this.productCount = productCount;
+    }
+
+    public Integer getRefundType() {
+        return refundType;
+    }
+
+    public void setRefundType(Integer refundType) {
+        this.refundType = refundType;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getSuperUserName() {
+        return superUserName;
+    }
+
+    public void setSuperUserName(String superUserName) {
+        this.superUserName = superUserName;
+    }
+
+    public Integer getThisId() {
+        return thisId;
+    }
+
+    public void setThisId(Integer thisId) {
+        this.thisId = thisId;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+}

+ 43 - 0
src/main/java/com/caimei365/user/utils/message/MessageModel.java

@@ -0,0 +1,43 @@
+package com.caimei365.user.utils.message;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * @author Administrator
+ */
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+public class MessageModel<T> {
+    private MessageType code;
+
+    private MqInfo mqInfo;
+
+    private T info;
+
+    public MessageType getCode() {
+        return code;
+    }
+
+    public void setCode(MessageType code) {
+        this.code = code;
+    }
+
+    public MqInfo getMqInfo() {
+        return mqInfo;
+    }
+
+    public void setMqInfo(MqInfo mqInfo) {
+        this.mqInfo = mqInfo;
+    }
+
+    public T getInfo() {
+        return info;
+    }
+
+    public void setInfo(T info) {
+        this.info = info;
+    }
+}

+ 41 - 0
src/main/java/com/caimei365/user/utils/message/MessageType.java

@@ -0,0 +1,41 @@
+package com.caimei365.user.utils.message;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+
+/**
+ * @author Administrator
+ */
+
+@ToString
+@AllArgsConstructor
+public enum MessageType {
+    /**
+     * 1.微信模板消息
+     * 2.站内消息
+     * 3.邮件
+     * 4.短信
+     */
+    WECHAT_TEMPLATE_MESSAGE(1, "微信模板消息"),
+    WEB_INSIDE_MESSAGE(2, "站内消息"),
+    EMAILS(3, "邮件"),
+    SYS_MESSAGE(4, "短信");
+    private Integer code;
+    private String description;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}

+ 65 - 0
src/main/java/com/caimei365/user/utils/message/MqInfo.java

@@ -0,0 +1,65 @@
+package com.caimei365.user.utils.message;
+
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Range;
+
+
+@Data
+@Accessors(fluent = true)
+public class MqInfo {
+    /**
+     * 异步消息(可选):1是,0否
+     */
+    @Range(min = 0, max = 1)
+    private Integer async;
+
+    /**
+     * 1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
+     */
+    @Range(min = 0, max = 18)
+    private Integer delay;
+
+    /**
+     * 消息主题
+     */
+    private String topic;
+
+    /**
+     * 消息标签(可选)
+     */
+    private String tag;
+
+    public Integer getAsync() {
+        return async;
+    }
+
+    public void setAsync(Integer async) {
+        this.async = async;
+    }
+
+    public Integer getDelay() {
+        return delay;
+    }
+
+    public void setDelay(Integer delay) {
+        this.delay = delay;
+    }
+
+    public String getTopic() {
+        return topic;
+    }
+
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+}

+ 1 - 1
src/main/resources/mapper/ArticleMapper.xml

@@ -19,7 +19,7 @@
                guidanceImage,
                enabledStatus as status,
                labelIds
-        from info
+            from info
         where id = #{articleId}
     </select>
     <select id="getArticleTypeList" resultType="com.caimei365.user.model.vo.ArticleTypeVo">

+ 13 - 0
src/main/resources/mapper/BaseMapper.xml

@@ -203,4 +203,17 @@
         WHERE userId = #{userId}
           and delflag = 0
     </select>
+    <select id="getByUserId" resultType="java.lang.Integer">
+        <if test="userType != null">
+            <if test="userType == 1">
+            SELECT userID from  club   WHERE  clubId = #{id}
+            </if>
+            <if test="userType == 2">
+            SELECT userID from  shop   WHERE  shopId = #{id}
+            </if>
+            <if test="userType == 3">
+            SELECT userID from  serviceprovider  WHERE  serviceProviderID = #{id}
+            </if>
+        </if>
+    </select>
 </mapper>

+ 15 - 0
src/main/resources/mapper/ClubMapper.xml

@@ -1187,6 +1187,21 @@
     <select id="selSpLinkMan" resultType="java.lang.String">
         SELECT linkMan FROM serviceprovider WHERE serviceProviderID = #{choseServiceId}
     </select>
+    <select id="getSpIdRAND" resultType="java.lang.Integer">
+        SELECT sp.serviceProviderID FROM serviceprovider sp
+        WHERE sp.organizeID = 0
+          and sp.status=90
+          and sp.serviceProviderID != 1342 and linkMan not LIKE '%测试%'
+        ORDER BY RAND()
+        LIMIT 0,1;
+    </select>
+    <select id="getSpUserId" resultType="java.lang.Integer">
+        SELECT sp.userId FROM serviceprovider sp
+        WHERE sp.organizeID = 0
+          and sp.status=90
+          and sp.serviceProviderID=#{spId}
+        LIMIT 0,1;
+    </select>
     <insert id="inProvider">
         insert into cm_provider_record (spId, clubId, operator, isOneself, createTime)
         values (#{spId}, #{clubId}, #{operator}, #{isOneself}, now())

+ 6 - 0
src/main/resources/mapper/LoginMapper.xml

@@ -473,4 +473,10 @@
         WHERE userID = #{userId}
         limit 1
     </select>
+    <select id="getClubSpUserId" resultType="java.lang.Integer">
+        SELECT s.userID from  serviceprovider s
+        left join club c on c.spId=s.serviceProviderID
+        WHERE  c.clubId = #{clubId}
+        limit 1
+    </select>
 </mapper>

+ 33 - 18
src/main/resources/mapper/MessageCenter.xml

@@ -65,6 +65,9 @@
             <if test="userType == 2">
                 and  shopID=#{commonId}
             </if>
+            <if test="userType == 3">
+                and  thisId=#{commonId}
+            </if>
             AND messageType=#{messageType}
             and userType=#{userType}
             AND saved=0
@@ -80,6 +83,9 @@
             <if test="userType == 2">
                 and  shopID=#{commonId}
             </if>
+            <if test="userType == 3">
+                and  thisId=#{commonId}
+            </if>
             and userType=#{userType}
             AND saved=0
         </where>
@@ -102,15 +108,18 @@
         SELECT * FROM `message_center`
         <where>
             <if test="messageType !=null">
-            AND messageType=#{messageType}
-           </if>
+                AND messageType=#{messageType}
+            </if>
             <if test="userType == 1">
-                and  clubID=#{commonId}
+                and clubID=#{commonId}
             </if>
             <if test="userType == 2">
-                and  shopID=#{commonId}
+                and shopID=#{commonId}
+            </if>
+            <if test="userType == 3">
+                and thisId=#{commonId}
             </if>
-           and userType=#{userType}
+            and userType=#{userType}
         </where>
         ORDER BY id DESC
     </select>
@@ -154,12 +163,15 @@
         <where>
 
             <if test="userType == 1">
-              and  c.clubID=#{commonId}
+                and c.clubID=#{commonId}
             </if>
             <if test="userType == 2">
-              and  p.shopID=#{commonId}
+                and p.shopID=#{commonId}
+            </if>
+            <if test="userType == 3">
+                and sp.serviceProviderID=#{commonId}
             </if>
-        and co.orderID=#{orderID}
+            and co.orderID=#{orderID}
         </where>
         LIMIT 1
     </select>
@@ -216,16 +228,19 @@
     <update id="updateMessageAsRead">
         UPDATE message_center SET saved = 1
         <where>
-      <if test="userType == 1">
-          and  clubID=#{commonId}
-      </if>
-      <if test="userType == 2">
-          and  shopID=#{commonId}
-      </if>
-        <if test="messageType !=null">
-           and messageType = #{messageType}
-        </if>
-          and userType=#{userType}
+            <if test="userType == 1">
+                and clubID=#{commonId}
+            </if>
+            <if test="userType == 2">
+                and shopID=#{commonId}
+            </if>
+            <if test="userType == 3">
+                and thisId=#{commonId}
+            </if>
+            <if test="messageType !=null">
+                and messageType = #{messageType}
+            </if>
+            and userType=#{userType}
         </where>
     </update>
 

+ 4 - 4
src/main/resources/mapper/RegisterMapper.xml

@@ -14,12 +14,12 @@
             values(#{userID},"新增用户","一般挽留客户",0,1)
     </insert>
     <insert id="insertClub" parameterType="com.caimei365.user.model.po.ClubPo" keyProperty="clubId" useGeneratedKeys="true">
-        insert into club(`name`, `sname`, `contractMobile`, `linkMan`, `userID`, `addTime`, `status`, `spID`, `scanFlag`, provinceID, cityID, townID, address, headpic, businessLicenseImage, medicalPracticeLicenseImg, socialCreditCode)
-                  values(#{name},#{shortName},#{contractMobile},#{linkMan},#{userId},#{addTime},#{status}, #{serviceProviderId}, #{scanFlag}, #{provinceId}, #{cityId}, #{townId}, #{address}, #{shopPhoto}, #{businessLicense},#{medicalPracticeLicense}, #{socialCreditCode})
+        insert into club(`name`, `sname`, `contractMobile`, `linkMan`, `userID`, `addTime`, `status`, `spID`, `scanFlag`, provinceID, cityID, townID, address, headpic, businessLicenseImage, medicalPracticeLicenseImg, socialCreditCode,newDeal)
+                  values(#{name},#{shortName},#{contractMobile},#{linkMan},#{userId},#{addTime},#{status}, #{serviceProviderId}, #{scanFlag}, #{provinceId}, #{cityId}, #{townId}, #{address}, #{shopPhoto}, #{businessLicense},#{medicalPracticeLicense}, #{socialCreditCode},1)
     </insert>
     <insert id="insertUpgradeClub" parameterType="com.caimei365.user.model.po.ClubPo" keyProperty="clubId" useGeneratedKeys="true">
-        insert into club(`name`, `sname`,     `contractMobile`, `userID`, `addTime`, `status`, `spID`,              `scanFlag`,`contractEmail`,`linkMan`, `provinceID`, `cityID`,`townID`, `address`, `headpic`, `businessLicenseImage`,`socialCreditCode`,`firstClubType`,`secondClubType`,`department`,`medicalPracticeLicenseImg`,`mainpro`)
-                  values(#{name},#{shortName},#{contractMobile},#{userId},#{addTime},#{status},#{serviceProviderId},#{scanFlag},#{contractEmail},#{linkMan},#{provinceId},#{cityId},#{townId},#{address},#{shopPhoto},#{businessLicense},#{socialCreditCode},#{firstClubType},#{secondClubType},#{department},#{medicalPracticeLicense},#{mainProduct})
+        insert into club(`name`, `sname`,     `contractMobile`, `userID`, `addTime`, `status`, `spID`,              `scanFlag`,`contractEmail`,`linkMan`, `provinceID`, `cityID`,`townID`, `address`, `headpic`, `businessLicenseImage`,`socialCreditCode`,`firstClubType`,`secondClubType`,`department`,`medicalPracticeLicenseImg`,`mainpro`,newDeal)
+                  values(#{name},#{shortName},#{contractMobile},#{userId},#{addTime},#{status},#{serviceProviderId},#{scanFlag},#{contractEmail},#{linkMan},#{provinceId},#{cityId},#{townId},#{address},#{shopPhoto},#{businessLicense},#{socialCreditCode},#{firstClubType},#{secondClubType},#{department},#{medicalPracticeLicense},#{mainProduct},1)
     </insert>
     <insert id="insertOperation" parameterType="com.caimei365.user.model.po.OperationPo" keyProperty="id" useGeneratedKeys="true">
         insert into cm_mall_operation_user(`userID`, `clubID`, `shopID`, `userOrganizeID`,`linkName`,`nickName`,`headimgurl`,`userType`,`mobile`,`status`, `unionId`, `openid`,`pcOpenid`, `addTime`, `updateTime`, `bindTime`, `delFlag`)

+ 208 - 22
src/main/resources/mapper/SellerMapper.xml

@@ -28,6 +28,20 @@
             unionId = #{unionId}
         where userID = #{userId}
     </update>
+    <update id="setSellerHome" parameterType="com.caimei365.user.model.po.ServiceProviderPo">
+        update serviceprovider
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="qrCode != null and qrCode != ''">qrCode = #{qrCode},</if>
+        </trim>
+        where userID = #{userId}
+    </update>
+    <update id="setSellerUserHome" >
+        update user
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="image != null and image != ''">image = #{image},</if>
+        </trim>
+        where userId = #{userId}
+    </update>
 
     <select id="findClubTemporary" resultType="com.caimei365.user.model.vo.ClubTemporaryVo">
         SELECT
@@ -106,7 +120,7 @@
     </select>
 
     <select id="findClubs" resultType="com.caimei365.user.model.vo.ClubVo">
-        select DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
+        select  c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
         c.contractEmail as contractEmail,
         c.contractPhone, c.linkMan, c.provinceID as proviceId, c.cityID as cityId, c.townID as townId,
         c.address, c.headpic as shopPhoto, c.businessLicenseImage as businessLicense, c.socialCreditCode,
@@ -116,12 +130,14 @@
         u.userIdentity,c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount,
         sp.name AS serviceName,
         covs.activeState AS activeState,
-        covs.customerValue AS customerValue
+        covs.customerValue AS customerValue,
+        cpr.createTime AS providerTime
         from club c
         left join user u on c.userID = u.userID
         LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
         LEFT JOIN cm_organ_value_system covs ON covs.userID = u.userID
         LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
+        LEFT JOIN cm_provider_record cpr ON cpr.spID = sp.serviceProviderID and cpr.clubId = c.clubId
         where
         <if test="1 == type">
             c.spID = #{serviceProviderId}
@@ -136,6 +152,64 @@
             r.clubId IS NOT NULL
             AND c.spId=1342
         </if>
+        <if test="4 == type">
+            c.spID = #{serviceProviderId}
+            AND sp.status = 90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
+            AND (u.loginTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) OR c.clubId= (select a.clubId
+            FROM ((
+            select
+            c.clubId,ccr.addTime AS time,c.spID
+            FROM club c
+            LEFT JOIN user u ON u.userID = c.userID
+            LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
+            LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+            where c.status=90 and sp.status=90
+            and  ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
+            GROUP BY c.clubId
+            )UNION(
+            select c.clubId,cr.orderTime AS time,c.spID
+            FROM club c
+            LEFT JOIN user u ON u.userID = c.userID
+            LEFT JOIN cm_order cr ON cr.clubId = c.clubId
+            LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+            where c.status=90 and sp.status=90
+            and  cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
+            GROUP BY c.clubId
+            )) a where a.time is not null
+            and  a.spID=#{serviceProviderId}
+            GROUP BY a.clubId))
+        </if>
+        <if test="5 == type">
+            c.spID = #{serviceProviderId}
+            AND sp.status = 90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
+            AND (u.loginTime <![CDATA[ < ]]> DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) or u.loginTime is null)and c.clubId not in (select a.clubId
+            FROM ((
+            select
+            c.clubId,ccr.addTime AS time,c.spID
+            FROM club c
+            LEFT JOIN user u ON u.userID = c.userID
+            LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
+            LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+            where c.status=90 and sp.status=90
+            and  ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
+            GROUP BY c.clubId
+            )UNION(
+            select c.clubId,cr.orderTime AS time,c.spID
+            FROM club c
+            LEFT JOIN user u ON u.userID = c.userID
+            LEFT JOIN cm_order cr ON cr.clubId = c.clubId
+            LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+            where c.status=90 and sp.status=90
+            and  cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
+            GROUP BY c.clubId
+            )) a where a.time is not null
+            and  a.spID=#{serviceProviderId}
+            GROUP BY a.clubId )
+        </if>
+        <if test="6 == type">
+            c.spID = #{serviceProviderId}
+            AND c.newDeal =1
+        </if>
         <if test="status != null and status != 66">
             AND c.status = #{status}
         </if>
@@ -149,7 +223,54 @@
             AND u.userIdentity = #{userIdentity}
         </if>
         AND covs.stage = 0 AND covs.delType = 1
-        order by c.clubID desc
+        group by c.clubID
+        order by cpr.createTime desc
+    </select>
+
+    <select id="findSpUserLoginSum" resultType="java.util.HashMap" parameterType="string">
+        select
+        COUNT(  CASE WHEN a.time=1 THEN 1 END) AS loginSum,
+        ((SELECT count(1) from club
+        WHERE  status=90
+        <if test="spID != null">
+            and  spID=#{spID}
+        </if>
+        )-COUNT(  CASE WHEN a.time=1 THEN 1 END)) AS not_loginSum
+        FROM (select a.*
+        FROM ((
+        select
+        c.clubId,1 AS time,c.spID
+        FROM club c
+        LEFT JOIN user u ON u.userID = c.userID
+        LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+        where c.status=90 and sp.status=90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
+        and u.loginTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
+        GROUP BY c.clubId
+        )UNION(
+        select
+        c.clubId,1 AS time,c.spID
+        FROM club c
+        LEFT JOIN user u ON u.userID = c.userID
+        LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
+        LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+        where c.status=90 and sp.status=90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
+        and  ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
+        GROUP BY c.clubId
+        )UNION(
+        select c.clubId,1 AS time,c.spID
+        FROM club c
+        LEFT JOIN user u ON u.userID = c.userID
+        LEFT JOIN cm_order cr ON cr.clubId = c.clubId
+        LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+        where c.status=90 and sp.status=90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
+        and  cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
+        GROUP BY c.clubId
+        )
+        ) a where  1=1
+        <if test="spID != null">
+            and  a.spID=#{spID}
+        </if>
+        GROUP BY a.clubId ) a
     </select>
     <select id="getAllClubList" resultType="com.caimei365.user.model.vo.ClubVo">
         SELECT DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
@@ -172,24 +293,27 @@
         </if>
     </select>
     <select id="getSellerByUserId" resultType="com.caimei365.user.model.po.ServiceProviderPo">
-        select serviceProviderID     AS serviceProviderId,
-               status,
-               userID                AS userId,
-               openid,
-               unionId,
-               name,
-               contractMobile,
-               linkMan,
-               duty,
-               contractEmail,
-               auditStatus,
-               auditTime,
-               auditNote,
-               validFlag,
-               addTime,
-               mainServiceProviderID AS mainServiceProviderId
-        from serviceprovider
-        where userID = #{userId}
+        select s.serviceProviderID     AS serviceProviderId,
+               s.status,
+               s.userID                AS userId,
+               s.openid,
+               s.unionId,
+               s.name,
+               s.contractMobile,
+               s.linkMan,
+               s.duty,
+               s.contractEmail,
+               s.auditStatus,
+               s.auditTime,
+               s.auditNote,
+               s.validFlag,
+               s.addTime,
+               s.qrCode,
+               u.image,
+               s.mainServiceProviderID AS mainServiceProviderId
+        from serviceprovider s
+        LEFT JOIN USER u ON s.userId = u.userId
+        where s.userID = #{userId}
     </select>
     <select id="findManager" resultType="java.lang.Integer">
         SELECT IF(csm.serviceProviderId IS NULL, 2, 1) AS manager
@@ -254,5 +378,67 @@
             </if>
         </where>
     </select>
-
+    <select id="getBehaviorRecordYesterdayPageLabel" resultType="string">
+        SELECT GROUP_CONCAT(a.pageLabel)
+        FROM (SELECT b.pageLabel
+        FROM cm_behavior_record b
+        LEFT JOIN club c ON b.userID = c.userID
+        WHERE b.userId !=0
+        and c.spId=#{spId}
+        <if test="clubId != null">
+            AND c.clubId =#{clubId}
+        </if>
+        and b.pageType in(6,8,11)
+        and  DATE(b.accessTime) = DATE(#{accessTime})
+        GROUP BY b.pageLabel LIMIT 10) as a
+    </select>
+    <select id="getBehaviorRecordYesterdayClubFrom" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
+        SELECT
+            b.recordID,
+            b.userID,
+            b.pagePath,
+            b.pageType,
+            b.pageLabel,
+            b.productID,
+            b.accessTime,
+            b.accessDuration,
+            b.accessDate,
+            b.referer,
+            b.accessClient,
+            b.isReckon,
+            b.region,
+            c.name,c.linkMan,c.contractMobile,c.clubId,u.image
+        FROM cm_behavior_record b
+        LEFT JOIN club c ON b.userID = c.userID
+        LEFT JOIN user u ON u.userID = c.userID
+        WHERE b.userId !=0
+        and c.spId=#{spId}
+        and c.clubId=#{clubId}
+        and b.pageType in(6,8,11)
+        and  DATE(b.accessTime) = DATE(#{accessTime})
+    </select>
+    <select id="getBehaviorRecordYesterdayClub" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
+        SELECT b.recordID,
+               b.userID,
+               b.pagePath,
+               b.pageType,
+               b.pageLabel,
+               b.productID,
+               b.accessTime,
+               b.accessDuration,
+               b.accessDate,
+               b.referer,
+               b.accessClient,
+               b.isReckon,
+               b.region,
+               c.name,c.linkMan,c.contractMobile,c.clubId,u.image
+        FROM cm_behavior_record b
+                 LEFT JOIN club c ON b.userID = c.userID
+                 LEFT JOIN user u ON u.userID = c.userID
+        WHERE b.userId !=0
+        and c.spId=#{spId}
+          and b.pageType in(6,8,11)
+          and  DATE(b.accessTime) = DATE(#{accessTime})
+        GROUP BY c.clubId
+    </select>
 </mapper>

+ 23 - 0
src/test/java/com/caimei365/user/UserApplicationTests.java

@@ -8,6 +8,10 @@ import com.caimei365.user.service.LoginService;
 import com.caimei365.user.utils.AliyunSmsUtil;
 import com.caimei365.user.utils.CodeUtil;
 import com.caimei365.user.utils.ValidateUtil;
+import com.caimei365.user.utils.message.InsideMessage;
+import com.caimei365.user.utils.message.MessageModel;
+import com.caimei365.user.utils.message.MessageType;
+import com.caimei365.user.utils.message.MqInfo;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -15,16 +19,35 @@ import org.springframework.boot.test.context.SpringBootTest;
 import javax.annotation.Resource;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
 @SpringBootTest
 class UserApplicationTests {
+    @Resource
+    private ToolsFeign smsFeign;
     @Resource
     LoginService loginService;
     @Test
     void contextLoads() {
+
+//        //站内信
+//        MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+//        insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+//                .mqInfo(new MqInfo().topic("MessageLine").delay(1).async(0))
+//                .info(new InsideMessage()
+//                        .userType(3)
+//                        .messageType(3)
+//                        .shopTieredType(4)
+//                        .name("user.getUserName()")
+//                        .userName("user.getUserName()")
+//                        .mobile("164848989")
+//                        .thisId(4648)
+//                        .clubId(448)
+//                );
+//        smsFeign.sendCommonMessage(insideMessageMessageModel);
         /*List<Integer> listShopId = loginService.getMessageCenterListDay(1);
         System.out.println("-------->listShopId == "+listShopId.toString()+" <--------------");*/
 //        boolean b = ValidateUtil.validateEmail("182126@qq.com");