Explorar el Código

修改企业微信客户关系查询

zoujiajian hace 3 años
padre
commit
1842a1efc9

+ 1 - 2
netflix-dao/src/main/java/com/cyksj/model/excel/CorpUserTagExcelData.java

@@ -1,7 +1,6 @@
 package com.cyksj.model.excel;
 
 import com.alibaba.excel.annotation.ExcelProperty;
-import com.ejlchina.searcher.bean.DbField;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -20,7 +19,7 @@ public class CorpUserTagExcelData {
 	@ExcelProperty("用户名")
 	private String nickname;
 
-	@DbField("用户头像")
+	@ExcelProperty("用户头像")
 	private String headimgurl;
 
 	@ExcelProperty("所属客服")

+ 6 - 4
netflix-dao/src/main/resources/mapper/CorpUserFollowRelationMapper.xml

@@ -14,16 +14,18 @@
     </select>
 
     <select id="selectCorpUserFollowRelationByTagIds" resultType="com.cyksj.model.dto.CorpUserFollowRelationDto">
-        select cufr.corp_user_id,any_value(cufr.follow_id) as followId,any_value(u.id) as user_id from (select
+        select cufr.corp_user_id,
+        any_value(cufr.follow_id) as follow_id,
+        any_value(cu.user_id) as user_id
+        from (select
         relation_id from `corp_user_tag`
         where tag_id in
         <foreach collection="list" item="item" open="(" separator="," close=")">
             #{item}
         </foreach>) cut left join `corp_user_follow_relation` cufr on cufr.id = cut.relation_id
         left join `corp_user_auth` ca on ca.external_userid = cufr.corp_user_id
-        left join `corp_user` cu on cu.id = ca.corp_user_id and cu.unionid != ''
-        left join `user` u on u.unionid = cu.unionid
-        where cufr.wx_corp_id = #{wxCorpId}
+        left join `corp_user` cu on cu.id = ca.corp_user_id
+        where cufr.wx_corp_id = #{wxCorpId} and cu.user_id != 0
         group by cufr.corp_user_id
     </select>
 </mapper>

+ 4 - 4
netflix-dao/src/main/resources/mapper/CorpUserTagMapper.xml

@@ -4,7 +4,7 @@
 <mapper namespace="com.cyksj.mapper.corp.CorpUserTagMapper">
 
     <select id="selectCorpUserDetailByCondition" resultType="com.cyksj.model.views.CorpUserView">
-        select cu.id,
+        select * from (select cu.id,
         cu.unionid,
         any_value(remark) as nickname,
         group_concat(ct.tag_name) as tagNames,
@@ -24,7 +24,7 @@
         left join corp_follow cf on cf.userid = cfr.follow_id
         left join corp_user_auth cua on cua.external_userid = cfr.corp_user_id
         left join corp_user cu on cu.id = cua.corp_user_id and cu.unionid != ''
-        group by cu.id, cu.unionid
+        group by cu.id, cu.unionid) s order by s.createdTime desc
     </select>
 
     <select id="exportUserTagDetail" resultType="com.cyksj.model.excel.CorpUserTagExcelData">
@@ -33,7 +33,7 @@
         any_value(remark) as nickname,
         group_concat(ct.tag_name) as tagNames,
         group_concat(cf.name) as customers,
-        any_value(ct.created_time) as createdTime,
+        any_value(ct.created_time) as tagTime,
         u.id as userId,
         u.nickname,
         u.headimgurl
@@ -58,7 +58,7 @@
         left join corp_follow cf on cf.userid = cfr.follow_id
         left join corp_user_auth cua on cua.external_userid = cfr.corp_user_id
         left join corp_user cu on cu.id = cua.corp_user_id and cu.unionid != ''
-        left join user u on u.unionid = cu.unionid
+        left join user u on u.id = cu.user_id
         group by cu.id, cu.unionid
     </select>
 </mapper>

+ 0 - 10
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpEventActionServiceImpl.java

@@ -312,16 +312,6 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 			corpUserTag.setType(tag.getType());
 			corpUserTagMapper.insert(corpUserTag);
 		});
-		CorpUserAuth corpUserAuth = corpUserAuthMapper.selectOne(Wrappers.lambdaQuery(CorpUserAuth.class)
-				.eq(CorpUserAuth::getExternalUserid, relation.getCorpUserId()).last("limit 1"));
-		if (corpUserAuth != null) {
-			CorpUser corpUser = corpUserMapper.selectById(corpUserAuth.getCorpUserId());
-			User user = userMapper.selectOne(Wrappers.lambdaQuery(User.class).eq(User::getUnionid, corpUser.getUnionid()));
-			if (user != null) {
-				corpUser.setUserId(user.getId());
-				corpUserMapper.updateById(corpUser);
-			}
-		}
 		//同步企业微信 银河用户id
 		Optional.ofNullable(corpUserMapper.setCorpUserUserId(relation.getCorpUserId()))
 				.ifPresent(corpUser -> {

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

@@ -334,12 +334,14 @@ public class CorpServiceImpl implements CorpService {
 			log.info("该客户{}不是微信用户或未关联unionId", externalUserid);
 			return new YHLXUserDetailView();
 		}
-		User user = userMapper.selectOne(Wrappers.lambdaQuery(User.class).eq(User::getUnionid, corpUser.getUnionid()).last("limit 1"));
-		if (user == null) {
-			log.info("该客户{}不是银河用户", externalUserid);
-			return new YHLXUserDetailView();
+		if (corpUser.getUserId() == 0) {
+			User user = userMapper.selectOne(Wrappers.lambdaQuery(User.class).eq(User::getUnionid, corpUser.getUnionid()).last("limit 1"));
+			if (user == null) {
+				log.info("该客户{}不是银河用户", externalUserid);
+				return new YHLXUserDetailView();
+			}
 		}
-		YHLXUserDetailView view = Optional.ofNullable(beanSearcher.searchFirst(YHLXUserDetailView.class, MapUtils.builder().field(YHLXUserDetailView::getUnionId, corpUser.getUnionid()).op(Operator.Equal).build())).orElse(new YHLXUserDetailView());
+		YHLXUserDetailView view = Optional.ofNullable(beanSearcher.searchFirst(YHLXUserDetailView.class, MapUtils.builder().field(YHLXUserDetailView::getUserId, corpUser.getUserId()).op(Operator.Equal).build())).orElse(new YHLXUserDetailView());
 		if (view.getUserId() != null) {
 			view.setAddress(addressMapper.selectOne(Wrappers.lambdaQuery(Address.class).eq(Address::getUserId, view.getUserId()).eq(Address::getIsDefault, true).last("limit 1")));
 			List<TicketView> ticketViews = beanSearcher.searchAll(TicketView.class, MapUtils.builder()

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

@@ -147,8 +147,8 @@ public class CorpTagController {
 	 * 导出标签下所有客户
 	 */
 	@GetMapping("/export")
-	public void export(String[] tagIds, String[] groupIds, HttpServletResponse response) {
-		List<CorpUserTagExcelData> list = corpTagService.exportUserTagDetail(tagIds, groupIds);
+	public void export(String[] tagId, String[] groupId, HttpServletResponse response) {
+		List<CorpUserTagExcelData> list = corpTagService.exportUserTagDetail(tagId, groupId);
 		EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, CorpUserTagExcelData.class, list, "标签下客户详情", "标签下客户详情", ExcelTypeEnum.XLSX, null);
 	}