소스 검색

用户意愿数据展示

zoujiajian 2 년 전
부모
커밋
262b831d35

+ 8 - 2
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpUserTagMapper.java

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.cyksj.model.entity.CorpUserTag;
 import com.cyksj.model.excel.CorpUserTagExcelData;
+import com.cyksj.model.views.CorpUserIntentionView;
 import com.cyksj.model.views.CorpUserView;
+import com.cyksj.model.views.UserIntentionPieView;
 import com.cyksj.model.views.UserOrderDetailView;
 import org.apache.ibatis.annotations.Param;
 
@@ -20,7 +22,11 @@ public interface CorpUserTagMapper extends BaseMapper<CorpUserTag> {
 
 	List<CorpUserTagExcelData> exportUserTagDetail(@Param("tagIds") String[] tagIds, @Param("groupIds") String[] groupIds, @Param("wxCorpId") Long wxCorpId);
 
-	UserOrderDetailView countTagUser(@Param("tagIdStr") String tagIdStr, @Param("startTime") String startTime, @Param("endTime") String endTime);
+	UserOrderDetailView countTagUser(@Param("tagIdStr") String tagIdStr, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("thisDate") String thisDate);
 
 	List<Long> getTagIdByCorpUserId(Long corpUserId);
-}
+
+	UserIntentionPieView getUserIntentionPie(@Param("tagIdStr") String tagId, @Param("thisDate") String date);
+
+	Page<CorpUserIntentionView> getCorpUserIntentionView(@Param("userId") Long userId, @Param("nickname") String nickname, @Param("tagIdStr") String tagId, @Param("thisDate") String date);
+}

+ 33 - 0
netflix-dao/src/main/java/com/cyksj/model/views/CorpUserIntentionView.java

@@ -0,0 +1,33 @@
+package com.cyksj.model.views;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: CorpUserIntentionView
+ * 创建者: JavaZou
+ * 创建时间:2024/4/3 12:09
+ */
+@Getter
+@Setter
+public class CorpUserIntentionView {
+	/**
+	 * 回传意愿id
+	 */
+	private Long intentionId;
+
+	private Long userId;
+
+	private String nickname;
+
+	/**
+	 * 意向 0无意向 1有意向 2很有意向
+	 */
+	private Integer intention;
+
+	/**
+	 * 创建时间
+	 */
+	private String createdTime;
+}

+ 22 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserIntentionPieView.java

@@ -0,0 +1,22 @@
+package com.cyksj.model.views;
+
+import com.cyksj.model.entity.BaseEntity;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: UserIntentionPieView
+ * 创建者: JavaZou
+ * 创建时间:2024/4/3 11:53
+ */
+@Getter
+@Setter
+public class UserIntentionPieView extends BaseEntity {
+	/**
+	 * 意向 0无意向 1有意向 2很有意向
+	 */
+	private Integer intention;
+
+	private Integer count;
+}

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

@@ -72,6 +72,9 @@
         </if>
         <if test="endTime != null">
             and ct.created_time &lt; #{endTime}
+        </if>
+        <if test="thisDate != null">
+            and date_format(ct.created_time,'%Y-%m-%d') = #{thisDate}
         </if>) s
         left join corp_user_follow_relation cufr on cufr.id = s.relation_id
         left join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
@@ -84,4 +87,41 @@
                  inner join corp_user_tag cut on cut.relation_id = cufr.id
                  inner join corp_tag ct on ct.tag_id = cut.tag_id
     </select>
+
+    <select id="getUserIntentionPie" resultType="com.cyksj.model.views.UserIntentionPieView">
+        select count(distinct ca.corp_user_id) as `count`, ccc.intention
+        as intention
+        from (select relation_id
+        from `corp_user_tag` ct
+        where tag_id = #{tagIdStr}
+        <if test="thisDate != null">
+            and date_format(ct.created_time,'%Y-%m-%d') = #{thisDate}
+        </if>) s
+        left join corp_user_follow_relation cufr on cufr.id = s.relation_id
+        left join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
+        inner join corp_customer_acquistion_callback ccc on ccc.corp_user_id = ca.corp_user_id
+        group by ccc.intention
+    </select>
+
+    <select id="getCorpUserIntentionView" resultType="com.cyksj.model.views.CorpUserIntentionView">
+        select cu.user_id,cu.name,cu.created_time,ccc.id as intentionId,ccc.intention
+        from (select relation_id
+        from `corp_user_tag` ct
+        where tag_id = #{tagIdStr}
+        <if test="thisDate != null">
+            and date_format(ct.created_time,'%Y-%m-%d') = #{thisDate}
+        </if>) s
+        left join corp_user_follow_relation cufr on cufr.id = s.relation_id
+        left join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
+        inner join corp_customer_acquistion_callback ccc on ccc.corp_user_id = ca.corp_user_id
+        left join corp_user cu on cu.id = ca.corp_user_id
+        <where>
+            <if test="userId != null">
+                cu.user_id = #{userId}
+            </if>
+            <if test="userId != null">
+                and cu.name like concat('%',#{userName},'%')
+            </if>
+        </where>
+    </select>
 </mapper>

+ 6 - 1
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpTagServiceImpl.java

@@ -424,12 +424,17 @@ public class CorpTagServiceImpl implements CorpTagService {
 	public UserOrderDetailView getTagUserData(Integer start, Integer limit, String tagIdStr, String startTime, String endTime) {
 		UserOrderDetailView u = orderDonMapper.getTagUserData(tagIdStr, startTime, endTime);
 
-		UserOrderDetailView u2 = corpUserTagMapper.countTagUser(tagIdStr, startTime, endTime);
+		UserOrderDetailView u2 = corpUserTagMapper.countTagUser(tagIdStr, startTime, endTime,null);
 
 		u.setNumOfUser(u2.getNumOfUser());
 		u.setDelNumOfUser(u2.getDelNumOfUser());
 		u.setOrderRate(u.getNumOfUser() == 0 ? BigDecimal.ZERO : BigDecimal.valueOf(u.getNumOfEpOrder()).divide(BigDecimal.valueOf(u.getNumOfUser()), 2, RoundingMode.HALF_DOWN));
 		Page<UserOrderDetailView> records = orderDonMapper.getTagUserDataPage(new Page<>(start, limit), tagIdStr, startTime, endTime);
+		records.getRecords().forEach(e->{
+			String date = e.getDate();
+			UserOrderDetailView userOrderDetailView = corpUserTagMapper.countTagUser(tagIdStr, null, null, date);
+			e.setNumOfUser(userOrderDetailView.getNumOfUser());
+		});
 
 		u.setRecords(records);
 		return u;

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

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.snowflake.Sequence;
 import com.cyksj.common.util.Codec;
@@ -15,8 +16,8 @@ import com.cyksj.dto.CorpJsSdkTicket;
 import com.cyksj.dto.CorpOauth2UserInfo;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
-import com.cyksj.mapper.GroupsRelationCustomerServiceFollowRecordMapper;
 import com.cyksj.mapper.GroupsRelationExpiryRecordMapper;
+import com.cyksj.mapper.corp.CorpUserTagMapper;
 import com.cyksj.model.dto.AuthRedirect;
 import com.cyksj.model.entity.CorpCustomerAcquistionCallback;
 import com.cyksj.model.entity.CorpFollow;
@@ -24,6 +25,8 @@ import com.cyksj.model.entity.CorpMsgFollowAssociation;
 import com.cyksj.model.entity.QyMsgContent;
 import com.cyksj.model.manage.views.CorpQyMsgAuditChatView;
 import com.cyksj.model.request.corp.CorpCommonReq;
+import com.cyksj.model.views.CorpUserIntentionView;
+import com.cyksj.model.views.UserIntentionPieView;
 import com.cyksj.model.views.YHLXUserDetailView;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.CorpService;
@@ -73,7 +76,7 @@ public class WxCorpController {
 
 	private final GroupsRelationExpiryRecordMapper groupsRelationExpiryRecordMapper;
 
-	private final GroupsRelationCustomerServiceFollowRecordMapper relationCustomerServiceFollowRecordMapper;
+	private final CorpUserTagMapper corpUserTagMapper;
 
 	private final static String CORP_UUID = "corp-uuid";
 
@@ -81,7 +84,7 @@ public class WxCorpController {
 	 * 企业微信 消息推送url
 	 */
 	@RequestMapping(value = "/msg/notify", method = {RequestMethod.GET, RequestMethod.POST})
-	public String msgNotify(@RequestParam(value = "msg_signature") String msgSignature, String timestamp, String nonce, @RequestParam(value = "echostr",required = false) String echoStr) throws Exception {
+	public String msgNotify(@RequestParam(value = "msg_signature") String msgSignature, String timestamp, String nonce, @RequestParam(value = "echostr", required = false) String echoStr) throws Exception {
 		if (StrUtil.hasEmpty(msgSignature, timestamp, nonce)) {
 			return StringUtil.EMPTY;
 		}
@@ -217,7 +220,7 @@ public class WxCorpController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult(jsSdkTicket);
 	}
 
-	public String getCorpUuid(){
+	public String getCorpUuid() {
 		return Optional.ofNullable(request.getHeader(CORP_UUID)).orElse(StringUtil.EMPTY);
 	}
 
@@ -277,6 +280,7 @@ public class WxCorpController {
 
 	/**
 	 * 企微会话列表
+	 *
 	 * @param externalUserid 用户 externalUserid
 	 */
 	@GetMapping("/getMsgAuditChat")
@@ -301,27 +305,29 @@ public class WxCorpController {
 	 * 获取聊天记录
 	 */
 	@GetMapping("/getMsgByFollowIdAndUserId")
-	public Result<SearchResult<QyMsgContent>> getMsgByFollowIdAndUserId(){
+	public Result<SearchResult<QyMsgContent>> getMsgByFollowIdAndUserId() {
 		SearchResult<QyMsgContent> search = beanSearcher.search(QyMsgContent.class, MapUtils.flatBuilder(request.getParameterMap()).build());
 		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
 	}
 
 	/**
 	 * 获取主动回传 回传数据
+	 *
 	 * @Param unionId 用户unionId
 	 */
 	@GetMapping("/acquistionLinkCallback")
-	public Result<CorpCustomerAcquistionCallback> getAcquistionLinkCallback(){
+	public Result<CorpCustomerAcquistionCallback> getAcquistionLinkCallback() {
 		CorpCustomerAcquistionCallback corpCustomerAcquistionCallback = beanSearcher.searchFirst(CorpCustomerAcquistionCallback.class, MapUtils.flatBuilder(request.getParameterMap()).build());
 		return GatewayResponse.SUCCESS.newBuilder().toResult(corpCustomerAcquistionCallback);
 	}
 
 	/**
 	 * 主动回传
+	 *
 	 * @param id 记录id
 	 */
 	@GetMapping("/acquistionLinkCallback/{id}")
-	public Result<String> postAcquistionLinkCallback(@PathVariable Long id){
+	public Result<String> postAcquistionLinkCallback(@PathVariable Long id) {
 		corpService.postAcquistionLinkCallback(id);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -330,12 +336,30 @@ public class WxCorpController {
 	 * 修改 意向
 	 */
 	@PutMapping("/upCallbackIntention")
-	public Result<String> upCallbackIntention(@RequestBody CorpCustomerAcquistionCallback corpCustomerAcquistionCallback){
+	public Result<String> upCallbackIntention(@RequestBody CorpCustomerAcquistionCallback corpCustomerAcquistionCallback) {
 		log.info("修改意向:{}", corpCustomerAcquistionCallback);
-		if(corpCustomerAcquistionCallback.getId() == null || corpCustomerAcquistionCallback.getId() == 0 || corpCustomerAcquistionCallback.getIntention() == null){
+		if (corpCustomerAcquistionCallback.getId() == null || corpCustomerAcquistionCallback.getId() == 0 || corpCustomerAcquistionCallback.getIntention() == null) {
 			throw BusinessRuntimeException.getInstance("缺少必填参数.");
 		}
 		corpService.upCallbackIntention(corpCustomerAcquistionCallback);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
+
+	/**
+	 * 用户意愿饼图
+	 */
+	@GetMapping("/get/user/intention/pie")
+	public Result<UserIntentionPieView> getUserIntentionPie(String tagId, String date) {
+		UserIntentionPieView userIntentionPieView = corpUserTagMapper.getUserIntentionPie(tagId, date);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(userIntentionPieView);
+	}
+
+	/**
+	 * 标签用户列表
+	 */
+	@GetMapping("/get/tag/user/list")
+	public Result<Page<CorpUserIntentionView>> getCorpUserIntentionView(Long userId, String nickname, String tagId, String date) {
+		Page<CorpUserIntentionView> page = corpUserTagMapper.getCorpUserIntentionView(userId, nickname, tagId, date);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(page);
+	}
 }