zoujiajian 3 лет назад
Родитель
Сommit
d08805fd47
21 измененных файлов с 301 добавлено и 119 удалено
  1. 11 0
      netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpUserAuthMapper.java
  2. 11 0
      netflix-dao/src/main/java/com/cyksj/mapper/corp/WxCorpAppMapper.java
  3. 1 1
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollow.java
  4. 0 5
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpUser.java
  5. 48 0
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpUserAuth.java
  6. 5 0
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpUserFollowRelation.java
  7. 47 0
      netflix-dao/src/main/java/com/cyksj/model/entity/WxCorpApp.java
  8. 6 0
      netflix-dao/src/main/java/com/cyksj/model/request/CorpCouponSendReq.java
  9. 5 26
      netflix-dao/src/main/java/com/cyksj/model/views/CorpUserTagView.java
  10. 52 0
      netflix-service/src/main/java/com/cyksj/config/corp/WeChatCorpFactory.java
  11. 0 32
      netflix-service/src/main/java/com/cyksj/config/corp/WxCorpFactory.java
  12. 0 7
      netflix-service/src/main/java/com/cyksj/config/corp/YHLXWxCorpConfig.java
  13. 1 1
      netflix-service/src/main/java/com/cyksj/service/corp/CorpService.java
  14. 24 5
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpEventActionServiceImpl.java
  15. 31 17
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpServiceImpl.java
  16. 7 7
      netflix-service/src/main/java/com/cyksj/service/corp/impl/WxCorpOpsImpl.java
  17. 17 4
      netflix-service/src/main/java/com/cyksj/service/mange/coupon/impl/CouponCommonServiceImpl.java
  18. 16 5
      netflix-service/src/main/java/com/cyksj/task/StatisticsDataScheduler.java
  19. 2 2
      netflix-service/src/main/java/com/cyksj/util/WxCorpUtil.java
  20. 2 2
      netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/WxCorpController.java
  21. 15 5
      netflix-web/src/main/java/com/cyksj/web/controller/manage/statistics/StatisticsDataController.java

+ 11 - 0
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpUserAuthMapper.java

@@ -0,0 +1,11 @@
+package com.cyksj.mapper.corp;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.CorpUserAuth;
+
+/**
+ * @author chan
+ * @date 2022/4/8 上午11:06
+ */
+public interface CorpUserAuthMapper extends BaseMapper<CorpUserAuth> {
+}

+ 11 - 0
netflix-dao/src/main/java/com/cyksj/mapper/corp/WxCorpAppMapper.java

@@ -0,0 +1,11 @@
+package com.cyksj.mapper.corp;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.WxCorpApp;
+
+/**
+ * @author chan
+ * @date 2022/4/7 下午6:10
+ */
+public interface WxCorpAppMapper extends BaseMapper<WxCorpApp> {
+}

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollow.java

@@ -11,7 +11,7 @@ import java.io.Serializable;
 @Data
 @Data
 public class CorpFollow extends BaseEntity implements Serializable {
 public class CorpFollow extends BaseEntity implements Serializable {
 
 
-    private String corpId;
+    private Long wxCorpId;
 
 
     /**
     /**
      * 成员UserID
      * 成员UserID

+ 0 - 5
netflix-dao/src/main/java/com/cyksj/model/entity/CorpUser.java

@@ -13,11 +13,6 @@ import java.io.Serializable;
 @Data
 @Data
 public class CorpUser extends BaseEntity implements Serializable {
 public class CorpUser extends BaseEntity implements Serializable {
 
 
-	/**
-	 * 外部联系人的userid
-	 */
-	private String externalUserid;
-
 	/**
 	/**
 	 * 外部联系人的名称
 	 * 外部联系人的名称
 	 */
 	 */

+ 48 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpUserAuth.java

@@ -0,0 +1,48 @@
+package com.cyksj.model.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author chan
+ * @date 2022/4/8 上午11:06
+ */
+@Data
+public class CorpUserAuth implements Serializable {
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 企业微信客户userid
+     */
+    private String externalUserid;
+
+    /**
+     * 企业微信用户id
+     */
+    private Long corpUserId;
+
+    /**
+     *  企业id
+     */
+    private Long wxCorpId;
+
+    /**
+     * 创建时间
+     */
+    @TableField(fill = FieldFill.INSERT)
+    private Date createdTime;
+
+    /**
+     * 修改时间
+     */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
+}

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpUserFollowRelation.java

@@ -17,6 +17,11 @@ import java.util.stream.Stream;
 @Data
 @Data
 public class CorpUserFollowRelation extends BaseEntity implements Serializable {
 public class CorpUserFollowRelation extends BaseEntity implements Serializable {
 
 
+	/**
+	 * wx_corp_app_id
+	 */
+	private Long wxCorpId;
+
 	/**
 	/**
 	 * corp_user 客户id
 	 * corp_user 客户id
 	 */
 	 */

+ 47 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/WxCorpApp.java

@@ -0,0 +1,47 @@
+package com.cyksj.model.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author chan
+ * @date 2022/3/11 下午12:15
+ */
+@Getter
+@Setter
+public class WxCorpApp {
+
+    private Long id;
+
+    /**
+     * appId
+     */
+
+    @TableField(value = "corpId")
+    private String corpId;
+
+    /**
+     * appSecret
+     */
+    @TableField(value = "corpSecret")
+    private String corpSecret;
+
+    private String token;
+
+    @TableField(value = "encodingAESKey")
+    private String encodingAESKey;
+
+    private String domain;
+
+    /**
+     * 管理员
+     */
+    private String admin;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/request/CorpCouponSendReq.java

@@ -26,4 +26,10 @@ public class CorpCouponSendReq {
 	 */
 	 */
 	@NotNull
 	@NotNull
 	private Long couponId;
 	private Long couponId;
+
+	/**
+	 * 企业微信id
+	 */
+	@NotEmpty
+	private String corpId;
 }
 }

+ 5 - 26
netflix-dao/src/main/java/com/cyksj/model/views/CorpUserTagView.java

@@ -5,8 +5,6 @@ import com.ejlchina.searcher.bean.SearchBean;
 import lombok.Getter;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.Setter;
 
 
-import java.util.Date;
-
 /*
 /*
  *项目名: netflix
  *项目名: netflix
  *文件名: CorpUserTagView
  *文件名: CorpUserTagView
@@ -15,30 +13,11 @@ import java.util.Date;
  */
  */
 @Getter
 @Getter
 @Setter
 @Setter
-@SearchBean(tables = "corp_user cu left join corp_user_follow_relation cfr on cfr.corp_user_id = cu.external_userid" +
-		" left join corp_user_tag ct on ct.relation_id = cfr.id")
+@SearchBean(tables = "corp_user_follow_relation cfr left join corp_user_tag ct on ct.relation_id = cfr.id",
+where = ":tagName: and :time:",
+groupBy = "cfr.corp_user_id")
 public class CorpUserTagView {
 public class CorpUserTagView {
-	/**
-	 * 用户id
-	 */
-	@DbField("cu.id")
-	private Long corpUserId;
-
-	@DbField("cu.external_userid")
-	private String externalUserid;
-
-	@DbField("cu.unionid")
-	private String unionid;
-
-	/**
-	 * 外部联系人的类型,1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户
-	 */
-	@DbField("cu.type")
-	private int type;
-
-	@DbField("ct.tag_name")
-	private String tagName;
 
 
-	@DbField("cu.created_time")
-	private Date createdTime;
+	@DbField("cfr.corp_user_id")
+	private Long corp_user_id;
 }
 }

+ 52 - 0
netflix-service/src/main/java/com/cyksj/config/corp/WeChatCorpFactory.java

@@ -0,0 +1,52 @@
+package com.cyksj.config.corp;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.mapper.corp.WxCorpAppMapper;
+import com.cyksj.model.entity.WxCorpApp;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author chan
+ * @date 2022/4/7 4:51 下午
+ */
+@Component
+public class WeChatCorpFactory {
+
+    @Autowired
+    private WxCorpAppMapper corpAppMapper;
+
+    private static Map<String, WxCorpApp> strategyBean = new ConcurrentHashMap<>();
+
+    /**
+     * 初始化
+     *
+     * @param corpId
+     * @return
+     */
+    public static WxCorpApp getCorpConfigStrategy(String corpId) {
+        if (StrUtil.isBlank(corpId)) {
+            throw BusinessRuntimeException.getInstance("corpId is empty");
+        }
+        WxCorpApp corpApp = strategyBean.get(corpId);
+        Objects.requireNonNull(corpApp, "corp config not exist");
+        return corpApp;
+    }
+
+    @PostConstruct
+    public void init() {
+        List<WxCorpApp> wxCorpApps = corpAppMapper.selectList(Wrappers.lambdaQuery(WxCorpApp.class));
+        wxCorpApps.forEach((corpApp)->{
+            strategyBean.put(corpApp.getCorpId(), corpApp);
+        });
+    }
+
+}

+ 0 - 32
netflix-service/src/main/java/com/cyksj/config/corp/WxCorpFactory.java

@@ -1,32 +0,0 @@
-package com.cyksj.config.corp;
-
-import cn.hutool.core.util.StrUtil;
-
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-
-/*
- *项目名: netflix
- *文件名: WxCorpFactory
- *创建者: JavaZou
- *创建时间:2022/10/13 15:18
- */
-public class WxCorpFactory {
-
-	private static Map<String, BaseWxCorpConfig> wxCorpBean = new ConcurrentHashMap<>();
-
-	/**
-	 * 获取企业微信
-	 */
-	public static BaseWxCorpConfig getBaseWxCorpConfig(String corpId) {
-		if (StrUtil.isEmpty(corpId)) {
-			return null;
-		}
-		return Optional.ofNullable(wxCorpBean.get(corpId)).orElse(null);
-	}
-
-	public static void add(BaseWxCorpConfig baseWxCorpConfig) {
-		wxCorpBean.put(baseWxCorpConfig.getCorpId(), baseWxCorpConfig);
-	}
-}

+ 0 - 7
netflix-service/src/main/java/com/cyksj/config/corp/YHLXWxCorpConfig.java

@@ -3,8 +3,6 @@ package com.cyksj.config.corp;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
 
 
-import javax.annotation.PostConstruct;
-
 /*
 /*
  *项目名: netflix
  *项目名: netflix
  *文件名: A
  *文件名: A
@@ -14,9 +12,4 @@ import javax.annotation.PostConstruct;
 @Configuration
 @Configuration
 @ConfigurationProperties(prefix = "yhlx")
 @ConfigurationProperties(prefix = "yhlx")
 public class YHLXWxCorpConfig extends BaseWxCorpConfig {
 public class YHLXWxCorpConfig extends BaseWxCorpConfig {
-
-	@PostConstruct
-	public void add() {
-		WxCorpFactory.add(this);
-	}
 }
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/corp/CorpService.java

@@ -27,5 +27,5 @@ public interface CorpService {
 
 
 	String getAgentJsTicket(String corpId, String agentId) throws Exception;
 	String getAgentJsTicket(String corpId, String agentId) throws Exception;
 
 
-	YHLXUserDetailView getUserDetailView(String externalUserid) throws Exception;
+	YHLXUserDetailView getUserDetailView(String externalUserid, String corpId) throws Exception;
 }
 }

+ 24 - 5
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpEventActionServiceImpl.java

@@ -2,6 +2,7 @@ package com.cyksj.service.corp.impl;
 
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.config.corp.WeChatCorpFactory;
 import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.corp.*;
 import com.cyksj.mapper.corp.*;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.entity.*;
@@ -45,11 +46,14 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 
 
 	private final CorpTagMapper corpTagMapper;
 	private final CorpTagMapper corpTagMapper;
 
 
+	private final CorpUserAuthMapper corpUserAuthMapper;
+
 	/**
 	/**
 	 * 客户添加成员
 	 * 客户添加成员
 	 */
 	 */
 	@Override
 	@Override
 	public CorpXmlOutMessage addExternalContact(String corpId, String userId, String externalUserId, String welcomeCode, Map<String, Object> context) throws Exception {
 	public CorpXmlOutMessage addExternalContact(String corpId, String userId, String externalUserId, String welcomeCode, Map<String, Object> context) throws Exception {
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpId);
 		//1.从企业微信获取客户信息
 		//1.从企业微信获取客户信息
 		CorpExternalContactInfo externalContact = wxCorpOps.getExternalContact(corpId, externalUserId);
 		CorpExternalContactInfo externalContact = wxCorpOps.getExternalContact(corpId, externalUserId);
 		ExternalContact corpUserInfo = externalContact.getExternalContact();
 		ExternalContact corpUserInfo = externalContact.getExternalContact();
@@ -66,7 +70,6 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 		corpUser.setName(corpUserInfo.getName());
 		corpUser.setName(corpUserInfo.getName());
 		corpUser.setGender(corpUserInfo.getGender());
 		corpUser.setGender(corpUserInfo.getGender());
 		corpUser.setAvatar(corpUserInfo.getAvatar());
 		corpUser.setAvatar(corpUserInfo.getAvatar());
-		corpUser.setExternalUserid(corpUserInfo.getExternalUserId());
 		corpUser.setType(corpUserInfo.getType());
 		corpUser.setType(corpUserInfo.getType());
 
 
 		//新增修改客户信息
 		//新增修改客户信息
@@ -80,16 +83,27 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 		} else {
 		} else {
 			corpUserMapper.updateById(corpUser);
 			corpUserMapper.updateById(corpUser);
 		}
 		}
+
+		CorpUserAuth corpUserAuth = corpUserAuthMapper.selectOne(Wrappers.lambdaQuery(CorpUserAuth.class).eq(CorpUserAuth::getExternalUserid, corpUserInfo.getExternalUserId()).eq(CorpUserAuth::getWxCorpId, wxCorpApp.getId()));
+		if (corpUserAuth == null) {
+			corpUserAuth = new CorpUserAuth();
+			corpUserAuth.setWxCorpId(wxCorpApp.getId());
+			corpUserAuth.setCorpUserId(corpUser.getId());
+			corpUserAuth.setExternalUserid(corpUserInfo.getExternalUserId());
+			corpUserAuthMapper.insert(corpUserAuth);
+		}
+
 		//2.客户添加成员信息
 		//2.客户添加成员信息
 		List<FollowedUser> followedUsers = externalContact.getFollowedUsers();
 		List<FollowedUser> followedUsers = externalContact.getFollowedUsers();
 
 
 		Set<String> relationFollowUserIds = relationMapper.selectList(Wrappers.lambdaQuery(CorpUserFollowRelation.class)
 		Set<String> relationFollowUserIds = relationMapper.selectList(Wrappers.lambdaQuery(CorpUserFollowRelation.class)
 				.select(CorpUserFollowRelation::getFollowId)
 				.select(CorpUserFollowRelation::getFollowId)
+				.eq(CorpUserFollowRelation::getWxCorpId, wxCorpApp.getCorpId())
 				.eq(CorpUserFollowRelation::getCorpUserId, corpUserInfo.getExternalUserId())).stream().map(CorpUserFollowRelation::getFollowId).collect(Collectors.toSet());
 				.eq(CorpUserFollowRelation::getCorpUserId, corpUserInfo.getExternalUserId())).stream().map(CorpUserFollowRelation::getFollowId).collect(Collectors.toSet());
 
 
 		followedUsers.stream()
 		followedUsers.stream()
 				.filter((followedUser) -> !relationFollowUserIds.contains(followedUser.getUserId()))
 				.filter((followedUser) -> !relationFollowUserIds.contains(followedUser.getUserId()))
-				.forEach(followedUser -> updateUserFollowRelation(followedUser, corpUser.getExternalUserid()));
+				.forEach(followedUser -> updateUserFollowRelation(followedUser, corpUserInfo.getExternalUserId(), wxCorpApp.getId()));
 
 
 		return null;
 		return null;
 	}
 	}
@@ -99,15 +113,17 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 	 */
 	 */
 	@Override
 	@Override
 	public CorpXmlOutMessage editExternalContact(CorpXmlMessage message, Map<String, Object> context) throws Exception {
 	public CorpXmlOutMessage editExternalContact(CorpXmlMessage message, Map<String, Object> context) throws Exception {
+		String corpId = message.getToUserName();
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpId);
 		//客户id
 		//客户id
 		String externalUserId = message.getExternalUserId();
 		String externalUserId = message.getExternalUserId();
 		//成员id
 		//成员id
 		String userId = message.getUserId();
 		String userId = message.getUserId();
-		CorpExternalContactInfo externalContact = wxCorpOps.getExternalContact(message.getToUserName(), externalUserId);
+		CorpExternalContactInfo externalContact = wxCorpOps.getExternalContact(corpId, externalUserId);
 		Map<String, List<FollowedUser>> followedUserMap = externalContact.getFollowedUsers().stream().collect(Collectors.groupingBy(FollowedUser::getUserId));
 		Map<String, List<FollowedUser>> followedUserMap = externalContact.getFollowedUsers().stream().collect(Collectors.groupingBy(FollowedUser::getUserId));
 		FollowedUser followedUser = followedUserMap.get(userId).get(0);
 		FollowedUser followedUser = followedUserMap.get(userId).get(0);
 		//修改客户关系
 		//修改客户关系
-		updateUserFollowRelation(followedUser, externalUserId);
+		updateUserFollowRelation(followedUser, externalUserId, wxCorpApp.getId());
 		return null;
 		return null;
 	}
 	}
 
 
@@ -173,9 +189,10 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 	 * 修改客户成员关系,客户标签
 	 * 修改客户成员关系,客户标签
 	 */
 	 */
 	@Transactional(rollbackFor = Throwable.class)
 	@Transactional(rollbackFor = Throwable.class)
-	public void updateUserFollowRelation(FollowedUser followedUser, String externalUserid) {
+	public void updateUserFollowRelation(FollowedUser followedUser, String externalUserid, Long wxCorpId) {
 		CorpUserFollowRelation relation = Optional.ofNullable(relationMapper
 		CorpUserFollowRelation relation = Optional.ofNullable(relationMapper
 				.selectOne(Wrappers.lambdaQuery(CorpUserFollowRelation.class)
 				.selectOne(Wrappers.lambdaQuery(CorpUserFollowRelation.class)
+						.eq(CorpUserFollowRelation::getWxCorpId, wxCorpId)
 						.eq(CorpUserFollowRelation::getCorpUserId, externalUserid)
 						.eq(CorpUserFollowRelation::getCorpUserId, externalUserid)
 						.eq(CorpUserFollowRelation::getFollowId, followedUser.getUserId())
 						.eq(CorpUserFollowRelation::getFollowId, followedUser.getUserId())
 						.last("limit 1"))).orElse(new CorpUserFollowRelation().setFollowId(followedUser.getUserId()).setCorpUserId(externalUserid));
 						.last("limit 1"))).orElse(new CorpUserFollowRelation().setFollowId(followedUser.getUserId()).setCorpUserId(externalUserid));
@@ -186,6 +203,8 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 		relation.setRemarkMobiles(Arrays.toString(followedUser.getRemarkMobiles()));
 		relation.setRemarkMobiles(Arrays.toString(followedUser.getRemarkMobiles()));
 		relation.setAddWay(CorpUserFollowRelation.Way.getDesc(followedUser.getAddWay()));
 		relation.setAddWay(CorpUserFollowRelation.Way.getDesc(followedUser.getAddWay()));
 		relation.setOperUserid(followedUser.getOperatorUserId());
 		relation.setOperUserid(followedUser.getOperatorUserId());
+		relation.setStatus(1);
+		relation.setWxCorpId(wxCorpId);
 		if (relation.getId() == null) relationMapper.insert(relation);
 		if (relation.getId() == null) relationMapper.insert(relation);
 		else relationMapper.updateById(relation);
 		else relationMapper.updateById(relation);
 		corpUserTagMapper.delete(Wrappers.lambdaQuery(CorpUserTag.class).eq(CorpUserTag::getRelationId, relation.getId()));
 		corpUserTagMapper.delete(Wrappers.lambdaQuery(CorpUserTag.class).eq(CorpUserTag::getRelationId, relation.getId()));

+ 31 - 17
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpServiceImpl.java

@@ -3,24 +3,22 @@ package com.cyksj.service.corp.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
 import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
 import com.cyksj.common.util.ListsUtil;
 import com.cyksj.common.util.ListsUtil;
 import com.cyksj.common.util.Xmls;
 import com.cyksj.common.util.Xmls;
 import com.cyksj.common.util.corp.WxCryptUtil;
 import com.cyksj.common.util.corp.WxCryptUtil;
-import com.cyksj.config.corp.BaseWxCorpConfig;
-import com.cyksj.config.corp.WxCorpFactory;
+import com.cyksj.config.corp.WeChatCorpFactory;
 import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.dto.CorpOauth2UserInfo;
 import com.cyksj.dto.CorpOauth2UserInfo;
 import com.cyksj.mapper.AddressMapper;
 import com.cyksj.mapper.AddressMapper;
 import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.corp.CorpFollowMapper;
 import com.cyksj.mapper.corp.CorpFollowMapper;
+import com.cyksj.mapper.corp.CorpUserAuthMapper;
 import com.cyksj.mapper.corp.CorpUserMapper;
 import com.cyksj.mapper.corp.CorpUserMapper;
 import com.cyksj.model.dto.WxCorpEncryptDto;
 import com.cyksj.model.dto.WxCorpEncryptDto;
-import com.cyksj.model.entity.Address;
-import com.cyksj.model.entity.CorpFollow;
-import com.cyksj.model.entity.CorpUser;
-import com.cyksj.model.entity.User;
+import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.views.OrderDonView;
 import com.cyksj.model.manage.views.OrderDonView;
 import com.cyksj.model.request.corp.CorpXmlMessage;
 import com.cyksj.model.request.corp.CorpXmlMessage;
 import com.cyksj.model.request.corp.CorpXmlOutMessage;
 import com.cyksj.model.request.corp.CorpXmlOutMessage;
@@ -89,6 +87,9 @@ public class CorpServiceImpl implements CorpService {
 	@Autowired
 	@Autowired
 	private AddressMapper addressMapper;
 	private AddressMapper addressMapper;
 
 
+	@Autowired
+	private CorpUserAuthMapper corpUserAuthMapper;
+
 	@PostConstruct
 	@PostConstruct
 	private void init() {
 	private void init() {
 		corpMessageRouter = new CorpMessageRouter(this)
 		corpMessageRouter = new CorpMessageRouter(this)
@@ -176,9 +177,9 @@ public class CorpServiceImpl implements CorpService {
 	@Override
 	@Override
 	public String corpMsg(String msgSignature, String timestamp, String nonce, String content) throws Exception {
 	public String corpMsg(String msgSignature, String timestamp, String nonce, String content) throws Exception {
 		WxCorpEncryptDto corpEncryptDto = Xmls.parseObject(content, WxCorpEncryptDto.class);
 		WxCorpEncryptDto corpEncryptDto = Xmls.parseObject(content, WxCorpEncryptDto.class);
-		BaseWxCorpConfig corpConfig = WxCorpFactory.getBaseWxCorpConfig(corpEncryptDto.getToUserName());
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpEncryptDto.getToUserName());
 
 
-		WxCorpUtil wxCorpUtil = new WxCorpUtil(corpConfig.getToken(), corpConfig.getEncodingAESKey(), corpConfig.getCorpId());
+		WxCorpUtil wxCorpUtil = new WxCorpUtil(wxCorpApp.getToken(), wxCorpApp.getEncodingAESKey(), wxCorpApp.getCorpId());
 
 
 		String msg = wxCorpUtil.DecryptMsg(msgSignature, timestamp, nonce, corpEncryptDto);
 		String msg = wxCorpUtil.DecryptMsg(msgSignature, timestamp, nonce, corpEncryptDto);
 		log.info("企业微信 解密 msg:\n{}", msg);
 		log.info("企业微信 解密 msg:\n{}", msg);
@@ -198,6 +199,8 @@ public class CorpServiceImpl implements CorpService {
 	public String dataInitByCorpId(String corpId) throws Exception {
 	public String dataInitByCorpId(String corpId) throws Exception {
 		//获取成员列表
 		//获取成员列表
 		List<String> followUserList = wxCorpOps.getFollowUserList(corpId);
 		List<String> followUserList = wxCorpOps.getFollowUserList(corpId);
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpId);
+		Long wxCorpId = wxCorpApp.getId();
 		for (String userId : followUserList) {
 		for (String userId : followUserList) {
 			THREAD_POOL.execute(() -> {
 			THREAD_POOL.execute(() -> {
 				CorpUserInfo userInfo = null;
 				CorpUserInfo userInfo = null;
@@ -209,9 +212,9 @@ public class CorpServiceImpl implements CorpService {
 				}
 				}
 				CorpFollow corpFollow = new CorpFollow();
 				CorpFollow corpFollow = new CorpFollow();
 				BeanUtil.copyProperties(userInfo, corpFollow);
 				BeanUtil.copyProperties(userInfo, corpFollow);
-				CorpFollow follow = corpFollowMapper.selectOne(Wrappers.lambdaQuery(CorpFollow.class).eq(CorpFollow::getUserid, corpFollow.getUserid()).eq(CorpFollow::getCorpId, corpId));
+				CorpFollow follow = corpFollowMapper.selectOne(Wrappers.lambdaQuery(CorpFollow.class).eq(CorpFollow::getUserid, corpFollow.getUserid()).eq(CorpFollow::getWxCorpId, wxCorpId));
 				if (follow == null) {
 				if (follow == null) {
-					corpFollow.setCorpId(corpId);
+					corpFollow.setWxCorpId(wxCorpId);
 					corpFollowMapper.insert(corpFollow);
 					corpFollowMapper.insert(corpFollow);
 				} else {
 				} else {
 					corpFollow.setId(follow.getId());
 					corpFollow.setId(follow.getId());
@@ -265,12 +268,14 @@ public class CorpServiceImpl implements CorpService {
 	@Override
 	@Override
 	@Transactional(rollbackFor = Throwable.class)
 	@Transactional(rollbackFor = Throwable.class)
 	public CorpFollow saveFollowUser(String corpId, CorpOauth2UserInfo corpOauth2UserInfo) throws Exception {
 	public CorpFollow saveFollowUser(String corpId, CorpOauth2UserInfo corpOauth2UserInfo) throws Exception {
-		CorpFollow corpFollow = corpFollowMapper.selectOne(Wrappers.lambdaQuery(CorpFollow.class).eq(CorpFollow::getCorpId, corpId).eq(CorpFollow::getUserid, corpOauth2UserInfo.getUserId()));
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpId);
+		Long wxCorpId = wxCorpApp.getId();
+		CorpFollow corpFollow = corpFollowMapper.selectOne(Wrappers.lambdaQuery(CorpFollow.class).eq(CorpFollow::getWxCorpId, wxCorpId).eq(CorpFollow::getUserid, corpOauth2UserInfo.getUserId()));
 		if (corpFollow == null) {
 		if (corpFollow == null) {
 			CorpUserInfo userInfo = wxCorpOps.getFollowUser(corpId, corpOauth2UserInfo.getUserId());
 			CorpUserInfo userInfo = wxCorpOps.getFollowUser(corpId, corpOauth2UserInfo.getUserId());
 			corpFollow = new CorpFollow();
 			corpFollow = new CorpFollow();
 			BeanUtil.copyProperties(userInfo, corpFollow);
 			BeanUtil.copyProperties(userInfo, corpFollow);
-			corpFollow.setCorpId(corpId);
+			corpFollow.setWxCorpId(wxCorpId);
 			corpFollowMapper.insert(corpFollow);
 			corpFollowMapper.insert(corpFollow);
 		}
 		}
 
 
@@ -288,12 +293,21 @@ public class CorpServiceImpl implements CorpService {
 	}
 	}
 
 
 	@Override
 	@Override
-	public YHLXUserDetailView getUserDetailView(String externalUserid) throws Exception {
-		CorpUser corpUser = corpUserMapper.selectOne(Wrappers.lambdaQuery(CorpUser.class).eq(CorpUser::getExternalUserid, externalUserid).last("limit 1"));
-		if (corpUser == null) {
+	public YHLXUserDetailView getUserDetailView(String externalUserid, String corpId) throws Exception {
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpId);
+
+		LambdaQueryWrapper<CorpUserAuth> corpUserAuthWrapper = Wrappers.lambdaQuery(CorpUserAuth.class)
+				.eq(CorpUserAuth::getExternalUserid, externalUserid)
+				.eq(CorpUserAuth::getWxCorpId, wxCorpApp.getId()).last("limit 1");
+		CorpUserAuth corpUserAuth = corpUserAuthMapper.selectOne(corpUserAuthWrapper);
+		CorpUser corpUser = null;
+		if (corpUserAuth == null) {
 			//尝试添加客户
 			//尝试添加客户
-			corpEventActionService.addExternalContact(yhlXWxCorpConfig.getCorpId(), null, externalUserid, null, null);
-			corpUser = corpUserMapper.selectOne(Wrappers.lambdaQuery(CorpUser.class).eq(CorpUser::getExternalUserid, externalUserid).last("limit 1"));
+			corpEventActionService.addExternalContact(corpId, null, externalUserid, null, null);
+			corpUserAuth = corpUserAuthMapper.selectOne(corpUserAuthWrapper);
+			if (corpUserAuth != null) {
+				corpUser = corpUserMapper.selectOne(Wrappers.lambdaQuery(CorpUser.class).eq(CorpUser::getId, corpUserAuth.getCorpUserId()).last("limit 1"));
+			}
 		}
 		}
 		if (corpUser == null) {
 		if (corpUser == null) {
 			log.info("该客户{}不存在", externalUserid);
 			log.info("该客户{}不存在", externalUserid);

+ 7 - 7
netflix-service/src/main/java/com/cyksj/service/corp/impl/WxCorpOpsImpl.java

@@ -6,11 +6,11 @@ import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.IoKit;
 import com.cyksj.common.util.IoKit;
 import com.cyksj.common.util.J11HttpC;
 import com.cyksj.common.util.J11HttpC;
 import com.cyksj.common.util.Jsons;
 import com.cyksj.common.util.Jsons;
-import com.cyksj.config.corp.BaseWxCorpConfig;
-import com.cyksj.config.corp.WxCorpFactory;
+import com.cyksj.config.corp.WeChatCorpFactory;
 import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.dto.CorpOauth2UserInfo;
 import com.cyksj.dto.CorpOauth2UserInfo;
 import com.cyksj.dto.RedisKey;
 import com.cyksj.dto.RedisKey;
+import com.cyksj.model.entity.WxCorpApp;
 import com.cyksj.model.response.*;
 import com.cyksj.model.response.*;
 import com.cyksj.redis.RedisService;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.WxCorpOps;
 import com.cyksj.service.corp.WxCorpOps;
@@ -136,10 +136,10 @@ public class WxCorpOpsImpl implements WxCorpOps {
 
 
 	@Override
 	@Override
 	public String createUrl(String corpId, String state) {
 	public String createUrl(String corpId, String state) {
-		BaseWxCorpConfig wxCorpConfig = WxCorpFactory.getBaseWxCorpConfig(corpId);
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpId);
 		return "https://open.weixin.qq.com/connect/oauth2/authorize" +
 		return "https://open.weixin.qq.com/connect/oauth2/authorize" +
-				"?appid=" + wxCorpConfig.getCorpId() +
-				"&redirect_uri=" + URLEncoder.encode(wxCorpConfig.getDomain() + "/manage/corp/redirect", IoKit.Charsets.UTF_8.getCharset()) +
+				"?appid=" + wxCorpApp.getCorpId() +
+				"&redirect_uri=" + URLEncoder.encode(wxCorpApp.getDomain() + "/manage/corp/redirect", IoKit.Charsets.UTF_8.getCharset()) +
 				"&response_type=code" +
 				"&response_type=code" +
 				"&scope=snsapi_base" +
 				"&scope=snsapi_base" +
 				"&state=" + state +
 				"&state=" + state +
@@ -186,11 +186,11 @@ public class WxCorpOpsImpl implements WxCorpOps {
 	}
 	}
 
 
 	public String access_token(String corpId) throws Exception {
 	public String access_token(String corpId) throws Exception {
-		BaseWxCorpConfig corpConfig = WxCorpFactory.getBaseWxCorpConfig(corpId);
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpId);
 		if (corpId == null) {
 		if (corpId == null) {
 			throw BusinessRuntimeException.getInstance("{0}企业微信不存在", corpId);
 			throw BusinessRuntimeException.getInstance("{0}企业微信不存在", corpId);
 		}
 		}
-		String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s", corpConfig.getCorpId(), corpConfig.getCorpSecret());
+		String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s", wxCorpApp.getCorpId(), wxCorpApp.getCorpSecret());
 		HttpResponse<byte[]> res =
 		HttpResponse<byte[]> res =
 				J11HttpC.custom()
 				J11HttpC.custom()
 						.ofGet()
 						.ofGet()

+ 17 - 4
netflix-service/src/main/java/com/cyksj/service/mange/coupon/impl/CouponCommonServiceImpl.java

@@ -1,13 +1,16 @@
 package com.cyksj.service.mange.coupon.impl;
 package com.cyksj.service.mange.coupon.impl;
 
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;
 import com.cyksj.common.util.Jsons;
+import com.cyksj.config.corp.WeChatCorpFactory;
 import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.mapper.GoodsDonSkuMapper;
 import com.cyksj.mapper.GoodsDonSkuMapper;
 import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.UserMapper;
+import com.cyksj.mapper.corp.CorpUserAuthMapper;
 import com.cyksj.mapper.corp.CorpUserMapper;
 import com.cyksj.mapper.corp.CorpUserMapper;
 import com.cyksj.mapper.manage.coupon.*;
 import com.cyksj.mapper.manage.coupon.*;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.entity.*;
@@ -63,6 +66,8 @@ public class CouponCommonServiceImpl implements CouponCommonService {
 
 
 	private final CouponFontService couponFontService;
 	private final CouponFontService couponFontService;
 
 
+	private final CorpUserAuthMapper corpUserAuthMapper;
+
 	@Override
 	@Override
 	@Transactional(rollbackFor = Throwable.class)
 	@Transactional(rollbackFor = Throwable.class)
 	public void saveCoupon(Coupon coupon) throws Exception {
 	public void saveCoupon(Coupon coupon) throws Exception {
@@ -160,12 +165,20 @@ public class CouponCommonServiceImpl implements CouponCommonService {
 
 
 	@Override
 	@Override
 	public void corpSendCoupon(CorpCouponSendReq corpCouponSendReq) throws Exception {
 	public void corpSendCoupon(CorpCouponSendReq corpCouponSendReq) throws Exception {
+		WxCorpApp wxCorpApp = WeChatCorpFactory.getCorpConfigStrategy(corpCouponSendReq.getCorpId());
 		String externalUserId = corpCouponSendReq.getExternalUserId();
 		String externalUserId = corpCouponSendReq.getExternalUserId();
-		CorpUser corpUser = corpUserMapper.selectOne(Wrappers.lambdaQuery(CorpUser.class).eq(CorpUser::getExternalUserid, externalUserId).last("limit 1"));
-		if (corpUser == null) {
+		LambdaQueryWrapper<CorpUserAuth> corpUserAuthWrapper = Wrappers.lambdaQuery(CorpUserAuth.class)
+				.eq(CorpUserAuth::getExternalUserid, externalUserId)
+				.eq(CorpUserAuth::getWxCorpId, wxCorpApp.getId()).last("limit 1");
+		CorpUserAuth corpUserAuth = corpUserAuthMapper.selectOne(corpUserAuthWrapper);
+		CorpUser corpUser = null;
+		if (corpUserAuth == null) {
 			//尝试添加客户
 			//尝试添加客户
-			corpEventActionService.addExternalContact(yhlXWxCorpConfig.getCorpId(), null, externalUserId, null, null);
-			corpUser = corpUserMapper.selectOne(Wrappers.lambdaQuery(CorpUser.class).eq(CorpUser::getExternalUserid, externalUserId).last("limit 1"));
+			corpEventActionService.addExternalContact(wxCorpApp.getCorpId(), null, externalUserId, null, null);
+			corpUserAuth = corpUserAuthMapper.selectOne(corpUserAuthWrapper);
+			if (corpUserAuth != null) {
+				corpUser = corpUserMapper.selectOne(Wrappers.lambdaQuery(CorpUser.class).eq(CorpUser::getId, corpUserAuth.getCorpUserId()).last("limit 1"));
+			}
 		}
 		}
 		if (corpUser == null) {
 		if (corpUser == null) {
 			log.info("该客户{}不存在", externalUserId);
 			log.info("该客户{}不存在", externalUserId);

+ 16 - 5
netflix-service/src/main/java/com/cyksj/task/StatisticsDataScheduler.java

@@ -9,6 +9,7 @@ import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.mapper.RegisterAccountDataMapper;
 import com.cyksj.mapper.RegisterAccountDataMapper;
 import com.cyksj.mapper.RegisterOrderDonMapper;
 import com.cyksj.mapper.RegisterOrderDonMapper;
+import com.cyksj.mapper.corp.CorpUserAuthMapper;
 import com.cyksj.mapper.manage.statistics.AppleOneDataMapper;
 import com.cyksj.mapper.manage.statistics.AppleOneDataMapper;
 import com.cyksj.mapper.manage.statistics.RealGoodsDataMapper;
 import com.cyksj.mapper.manage.statistics.RealGoodsDataMapper;
 import com.cyksj.mapper.manage.statistics.StatisticsUserDataMapper;
 import com.cyksj.mapper.manage.statistics.StatisticsUserDataMapper;
@@ -19,7 +20,7 @@ import com.cyksj.service.mange.CmsAccountService;
 import com.cyksj.service.mange.CmsGoodsDonSkuService;
 import com.cyksj.service.mange.CmsGoodsDonSkuService;
 import com.cyksj.service.order.OrderDonService;
 import com.cyksj.service.order.OrderDonService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.BeanSearcher;
-import com.ejlchina.searcher.param.Operator;
+import com.ejlchina.searcher.util.MapBuilder;
 import com.ejlchina.searcher.util.MapUtils;
 import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
@@ -71,6 +72,8 @@ public class StatisticsDataScheduler {
 
 
 	private final BeanSearcher beanSearcher;
 	private final BeanSearcher beanSearcher;
 
 
+	private final CorpUserAuthMapper corpUserAuthMapper;
+
 	/**
 	/**
 	 * 后台数据统计 定时器
 	 * 后台数据统计 定时器
 	 */
 	 */
@@ -104,10 +107,18 @@ public class StatisticsDataScheduler {
 		statisticsUserData.setNumOfUser(yesNumOfUser + statisticsUserData.getNumOfNewUser());
 		statisticsUserData.setNumOfUser(yesNumOfUser + statisticsUserData.getNumOfNewUser());
 
 
 		statisticsUserData.setNumOfDistributeUser(statisticsUserDataMapper.getNumOfDistributeUserToday(yesZeroDate, thisZeroDate));
 		statisticsUserData.setNumOfDistributeUser(statisticsUserDataMapper.getNumOfDistributeUserToday(yesZeroDate, thisZeroDate));
-		List<CorpUserTagView> corpUserLists = Optional.ofNullable(beanSearcher.searchAll(CorpUserTagView.class, MapUtils.builder().field(CorpUserTagView::getCreatedTime, yesZeroDate, thisZeroDate).op(Operator.Between).build())).orElse(new ArrayList<>());
-		statisticsUserData.setNumOfCorpUser(corpUserLists.size());
-		statisticsUserData.setNumOfCorpEquipmentUser(corpUserLists.stream().filter(data -> "设备".equals(data.getTagName())).collect(Collectors.toList()).size());
-		statisticsUserData.setNumOfCorpAccountUser(corpUserLists.stream().filter(data -> "账号".equals(data.getTagName())).collect(Collectors.toList()).size());
+
+		Integer numOfCorpUser = corpUserAuthMapper.selectCount(Wrappers.lambdaQuery(CorpUserAuth.class)
+				.between(CorpUserAuth::getCreatedTime, yesZeroDate, thisZeroDate)
+				.groupBy(CorpUserAuth::getExternalUserid));
+		statisticsUserData.setNumOfCorpUser(numOfCorpUser);
+		MapBuilder builder = MapUtils.builder()
+				.put("time", String.format("ct.created_time between '%s' and '%s'", yesZeroDate, thisZeroDate))
+				.group("cfr.corp_user_id");
+		Number equipments = beanSearcher.searchCount(CorpUserTagView.class, builder.put("tagName", "ct.tag_name = '设备'").build());
+		statisticsUserData.setNumOfCorpEquipmentUser(equipments.intValue());
+		Number accounts = beanSearcher.searchCount(CorpUserTagView.class, builder.put("tagName", "ct.tag_name = '账号'").build());
+		statisticsUserData.setNumOfCorpAccountUser(accounts.intValue());
 
 
 		statisticsUserData.setPcNumOfNewUser(statisticsUserDataMapper.getPcNumOfNewUser(yesZeroDate, thisZeroDate));
 		statisticsUserData.setPcNumOfNewUser(statisticsUserDataMapper.getPcNumOfNewUser(yesZeroDate, thisZeroDate));
 		statisticsUserData.setPcNumOfActiveUser(statisticsUserDataMapper.getPcNumOfActiveUser(yesZeroDate, thisZeroDate));
 		statisticsUserData.setPcNumOfActiveUser(statisticsUserDataMapper.getPcNumOfActiveUser(yesZeroDate, thisZeroDate));

+ 2 - 2
netflix-service/src/main/java/com/cyksj/util/WxCorpUtil.java

@@ -4,7 +4,7 @@ import com.cyksj.common.exception.AesException;
 import com.cyksj.common.util.Codec;
 import com.cyksj.common.util.Codec;
 import com.cyksj.common.util.corp.PKCS7Encoder;
 import com.cyksj.common.util.corp.PKCS7Encoder;
 import com.cyksj.common.util.corp.SHA1;
 import com.cyksj.common.util.corp.SHA1;
-import com.cyksj.config.corp.WxCorpFactory;
+import com.cyksj.config.corp.WeChatCorpFactory;
 import com.cyksj.model.dto.WxCorpEncryptDto;
 import com.cyksj.model.dto.WxCorpEncryptDto;
 
 
 import javax.crypto.Cipher;
 import javax.crypto.Cipher;
@@ -135,7 +135,7 @@ public class WxCorpUtil {
 		}
 		}
 
 
 		// receiveid不相同的情况
 		// receiveid不相同的情况
-		if (WxCorpFactory.getBaseWxCorpConfig(from_receiveid) == null) {
+		if (WeChatCorpFactory.getCorpConfigStrategy(from_receiveid) == null) {
 			throw new AesException(AesException.ValidateCorpidError);
 			throw new AesException(AesException.ValidateCorpidError);
 		}
 		}
 		return xmlContent;
 		return xmlContent;

+ 2 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/WxCorpController.java

@@ -202,8 +202,8 @@ public class WxCorpController {
 	 * 企业微信客户银河录像详情
 	 * 企业微信客户银河录像详情
 	 */
 	 */
 	@GetMapping("/user/detail")
 	@GetMapping("/user/detail")
-	public Result<YHLXUserDetailView> getYHLXUserDetailView(String externalUserid) throws Exception {
-		YHLXUserDetailView detailView = corpService.getUserDetailView(externalUserid);
+	public Result<YHLXUserDetailView> getYHLXUserDetailView(String externalUserid, String corpId) throws Exception {
+		YHLXUserDetailView detailView = corpService.getUserDetailView(externalUserid, corpId);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(detailView);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(detailView);
 	}
 	}
 
 

+ 15 - 5
netflix-web/src/main/java/com/cyksj/web/controller/manage/statistics/StatisticsDataController.java

@@ -13,6 +13,7 @@ import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.CustomerServiceRenewOrderRecordMapper;
 import com.cyksj.mapper.CustomerServiceRenewOrderRecordMapper;
 import com.cyksj.mapper.GroupsRelationMapper;
 import com.cyksj.mapper.GroupsRelationMapper;
 import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.UserMapper;
+import com.cyksj.mapper.corp.CorpUserAuthMapper;
 import com.cyksj.mapper.manage.CustomerServiceEveryMonthDetailMapper;
 import com.cyksj.mapper.manage.CustomerServiceEveryMonthDetailMapper;
 import com.cyksj.mapper.manage.RealGoodsOrderHandleMapper;
 import com.cyksj.mapper.manage.RealGoodsOrderHandleMapper;
 import com.cyksj.mapper.manage.statistics.IncrExpiryTimeRecordMapper;
 import com.cyksj.mapper.manage.statistics.IncrExpiryTimeRecordMapper;
@@ -42,7 +43,6 @@ import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
-import java.util.Optional;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /*
 /*
@@ -77,6 +77,8 @@ public class StatisticsDataController {
 
 
 	private final CustomerServiceRenewOrderRecordMapper customerServiceRenewOrderRecordMapper;
 	private final CustomerServiceRenewOrderRecordMapper customerServiceRenewOrderRecordMapper;
 
 
+	private final CorpUserAuthMapper corpUserAuthMapper;
+
 	/**
 	/**
 	 * 查询统计数据
 	 * 查询统计数据
 	 */
 	 */
@@ -182,10 +184,18 @@ public class StatisticsDataController {
 		statisticsUserDataView.setPcNumOfActiveUser(statisticsUserDataMapper.getPcNumOfActiveUser(thisZero, thisEnd));
 		statisticsUserDataView.setPcNumOfActiveUser(statisticsUserDataMapper.getPcNumOfActiveUser(thisZero, thisEnd));
 
 
 		statisticsUserDataView.setNumOfDistributeUser(statisticsUserDataMapper.getNumOfDistributeUserToday(thisZero, thisEnd));
 		statisticsUserDataView.setNumOfDistributeUser(statisticsUserDataMapper.getNumOfDistributeUserToday(thisZero, thisEnd));
-		List<CorpUserTagView> corpUserLists = Optional.ofNullable(beanSearcher.searchAll(CorpUserTagView.class, MapUtils.builder().field(CorpUserTagView::getCreatedTime, thisZero, thisEnd).op(Operator.Between).build())).orElse(new ArrayList<>());
-		statisticsUserDataView.setNumOfCorpUser(corpUserLists.size());
-		statisticsUserDataView.setNumOfCorpEquipmentUser(corpUserLists.stream().filter(data -> "设备".equals(data.getTagName())).collect(Collectors.toList()).size());
-		statisticsUserDataView.setNumOfCorpAccountUser(corpUserLists.stream().filter(data -> "账号".equals(data.getTagName())).collect(Collectors.toList()).size());
+
+		Integer numOfCorpUser = corpUserAuthMapper.selectCount(Wrappers.lambdaQuery(CorpUserAuth.class)
+				.between(CorpUserAuth::getCreatedTime, thisZero, thisEnd)
+				.groupBy(CorpUserAuth::getExternalUserid));
+		statisticsUserDataView.setNumOfCorpUser(numOfCorpUser);
+		MapBuilder builder = MapUtils.builder()
+				.put("time", String.format("ct.created_time between '%s' and '%s'", thisZero, thisEnd))
+				.group("cfr.corp_user_id");
+		Number equipments = beanSearcher.searchCount(CorpUserTagView.class, builder.put("tagName", "ct.tag_name = '设备'").build());
+		statisticsUserDataView.setNumOfCorpEquipmentUser(equipments.intValue());
+		Number accounts = beanSearcher.searchCount(CorpUserTagView.class, builder.put("tagName", "ct.tag_name = '账号'").build());
+		statisticsUserDataView.setNumOfCorpAccountUser(accounts.intValue());
 
 
 		statisticsUserDataView.setUserData(beanSearcher.search(StatisticsUserData.class, MapUtils.flatBuilder(request.getParameterMap()).build()));
 		statisticsUserDataView.setUserData(beanSearcher.search(StatisticsUserData.class, MapUtils.flatBuilder(request.getParameterMap()).build()));
 		return GatewayResponse.SUCCESS.newBuilder().toResult(statisticsUserDataView);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(statisticsUserDataView);