浏览代码

产生微信客服会话前记录用户咨询问题

zoujiajian 1 年之前
父节点
当前提交
6addc16556

+ 13 - 0
netflix-dao/src/main/java/com/cyksj/mapper/CustomerConsultationRecordMapper.java

@@ -0,0 +1,13 @@
+package com.cyksj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.CustomerConsultationRecord;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: CustomerConsultationRecordMapper
+ * 创建者: JavaZou
+ * 创建时间:2025/2/7 11:59
+ */
+public interface CustomerConsultationRecordMapper extends BaseMapper<CustomerConsultationRecord> {
+}

+ 27 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CustomerConsultationRecord.java

@@ -0,0 +1,27 @@
+package com.cyksj.model.entity;
+
+
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.NotEmpty;
+
+@Getter
+@Setter
+public class CustomerConsultationRecord extends BaseEntity{
+	private Long userId;
+
+	@NonNull
+	private Integer type;
+
+	@NonNull
+	private Long goodsId;
+
+	@NotEmpty
+	@Max(value = 1000)
+	private String content;
+
+	private String imgs;
+}

+ 54 - 0
netflix-dao/src/main/java/com/cyksj/model/views/CustomerConsultationRecordView.java

@@ -0,0 +1,54 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: CustomerConsultationRecordView
+ * 创建者: JavaZou
+ * 创建时间:2025/2/7 15:07
+ */
+@Getter
+@Setter
+@SearchBean(tables = "customer_consultation_record ccr left join goods_don g on g.id = ccr.goods_id" +
+		" left join user u on u.id = ccr.user_id")
+public class CustomerConsultationRecordView {
+
+	@DbField("ccr.user_id")
+	private Long userId;
+
+	@DbField("u.nickname")
+	private String nickname;
+
+	@DbField("g.title")
+	private String tittle;
+
+	@DbField("g.id")
+	private Long goodsId;
+
+	@DbField("ccr.type")
+	private Integer type;
+
+	/**
+	 * 分类名
+	 */
+	@DbField("ccr.category_name")
+	private String categoryName;
+
+	@DbField("ccr.content")
+	private String content;
+
+	@DbField("ccr.imgs")
+	private String imgs;
+
+	@DbField("ccr.created_time")
+	private Date createdTime;
+
+	@DbField("ccr.update_time")
+	private Date updateTime;
+}

+ 27 - 0
netflix-dao/src/main/java/com/cyksj/model/views/CustomerConsultationStatisticsDataView.java

@@ -0,0 +1,27 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: CustomerConsultationStatisticsDataView
+ * 创建者: JavaZou
+ * 创建时间:2025/2/7 15:17
+ */
+@Getter
+@Setter
+@SearchBean(tables = "customer_consultation_record ccr left join goods_don g on g.id = ccr.goods_id",
+		groupBy = "ccr.type,ccr.category_name,g.title")
+public class CustomerConsultationStatisticsDataView {
+	@DbField("ccr.type")
+	private Integer type;
+
+	@DbField("ccr.category_name")
+	private String categoryName;
+
+	@DbField("ccr.title")
+	private String title;
+}

+ 56 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsQaShowView.java

@@ -0,0 +1,56 @@
+package com.cyksj.model.views;
+
+import com.cyksj.model.entity.GoodsDon;
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: GoodsQaShowView
+ * 创建者: JavaZou
+ * 创建时间:2025/2/7 12:04
+ */
+@Getter
+@Setter
+@SearchBean(tables = "goods_don_qa_relate gr inner join goods_don_qa ga on ga.id = gr.question_id" +
+		" inner join goods_don g on g.id = gr.goods_id" +
+		" left join goods_don_category_relate gcr on gcr.goods_id = g.id" +
+		" left join goods_don_category gc on gc.id = gcr.category",
+		where = "ga.status is true and ga.deleted is true and g.status is true")
+public class GoodsQaShowView {
+	/**
+	 * 1.售前,2.售后
+	 */
+	@DbField("ga.type")
+	private Integer type;
+
+	@DbField("g.id")
+	private Long goodsId;
+
+	@DbField("g.title")
+	private String title;
+
+	/**
+	 * 分类
+	 */
+	@DbField("gc.name")
+	private String categoryName;
+
+	@DbIgnore
+	private List<QaGoodsType> children;
+
+	@Getter
+	@Setter
+	public static class QaGoodsType {
+		private Long category;
+
+		private String name;
+
+		private List<GoodsDon> children;
+	}
+}

+ 25 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/GoodsDonQuestionController.java

@@ -6,6 +6,8 @@ import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.GoodsDonQaRelateMapper;
 import com.cyksj.model.entity.GoodsDonQa;
 import com.cyksj.model.entity.GoodsDonQaRelate;
+import com.cyksj.model.views.CustomerConsultationRecordView;
+import com.cyksj.model.views.CustomerConsultationStatisticsDataView;
 import com.cyksj.model.views.GoodsDonQaView;
 import com.cyksj.service.mange.GoodsDonQaService;
 import com.cyksj.service.mange.RefreshCacheService;
@@ -142,4 +144,27 @@ public class GoodsDonQuestionController {
 		}
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
+
+
+	/**
+	 * 客户咨询问题记录列表
+	 */
+	@GetMapping("/get/consultation/record")
+	public Result<SearchResult<CustomerConsultationRecordView>> getConsultationRecord() {
+		SearchResult<CustomerConsultationRecordView> search = beanSearcher.search(CustomerConsultationRecordView.class, MapUtils.flatBuilder(request.getParameterMap())
+				.orderBy(CustomerConsultationRecordView::getUpdateTime).desc()
+				.build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+	}
+
+
+	/**
+	 * 客户咨询问题记录列表 数据统计
+	 */
+	@GetMapping("/get/consultation/statistics/data")
+	public Result<List<CustomerConsultationStatisticsDataView>> getConsultationStatisticsData() {
+		List<CustomerConsultationStatisticsDataView> customerConsultationStatisticsDataViews = beanSearcher.searchAll(CustomerConsultationStatisticsDataView.class, MapUtils.flatBuilder(request.getParameterMap())
+				.build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(customerConsultationStatisticsDataViews);
+	}
 }

+ 91 - 0
netflix-web/src/main/java/com/cyksj/web/controller/qa/CorpKfQaController.java

@@ -0,0 +1,91 @@
+package com.cyksj.web.controller.qa;
+
+import cn.dev33.satoken.stp.StpUtil;
+import com.cyksj.dto.Result;
+import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.CustomerConsultationRecordMapper;
+import com.cyksj.model.entity.CustomerConsultationRecord;
+import com.cyksj.model.entity.GoodsDon;
+import com.cyksj.model.views.GoodsQaShowView;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.util.MapUtils;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: CorpKfQaController
+ * 创建者: JavaZou
+ * 创建时间:2025/2/7 12:02
+ */
+@RestController
+@RequestMapping("/applet/qa")
+@RequiredArgsConstructor
+public class CorpKfQaController {
+	private final BeanSearcher beanSearcher;
+
+	private final HttpServletRequest request;
+
+	private final CustomerConsultationRecordMapper customerConsultationRecordMapper;
+
+	/**
+	 * 咨询问题级联
+	 */
+	@GetMapping("/get/cascade")
+	public Result<List<GoodsQaShowView>> getCascade() {
+		List<GoodsQaShowView> goodsQaShowViews = beanSearcher.searchAll(GoodsQaShowView.class, MapUtils.builder().build());
+		// 按type分组
+		Map<Integer, List<GoodsQaShowView>> byType = goodsQaShowViews.stream()
+				.collect(Collectors.groupingBy(GoodsQaShowView::getType));
+		List<GoodsQaShowView> result = new ArrayList<>();
+		byType.forEach((type, typeViews) -> {
+			GoodsQaShowView typeGroup = new GoodsQaShowView();
+			typeGroup.setType(type);
+
+			// 按categoryName分组并转换为QaGoodsType
+			Map<String, List<GoodsQaShowView>> byCategory = typeViews.stream()
+					.collect(Collectors.groupingBy(GoodsQaShowView::getCategoryName));
+
+			List<GoodsQaShowView.QaGoodsType> qaGoodsTypes = new ArrayList<>();
+			byCategory.forEach((categoryName, categoryViews) -> {
+				GoodsQaShowView.QaGoodsType qaType = new GoodsQaShowView.QaGoodsType();
+				qaType.setName(categoryName);
+				// 假设需要将GoodsQaShowView转换为GoodsDon,此处需要具体逻辑
+				List<GoodsDon> goodsDons = categoryViews.stream()
+						.map(view -> convertToGoodsDon(view)) // 自定义转换方法
+						.collect(Collectors.toList());
+				qaType.setChildren(goodsDons);
+				qaGoodsTypes.add(qaType);
+			});
+			typeGroup.setChildren(qaGoodsTypes);
+			result.add(typeGroup);
+		});
+		return GatewayResponse.SUCCESS.newBuilder().toResult(result);
+	}
+
+
+	/**
+	 * 咨询问题记录
+	 */
+	@PostMapping("/consultation/question/record")
+	public Result<String> recordConsultationQuestion(@RequestBody @Validated CustomerConsultationRecord customerConsultationRecord) {
+		long userId = StpUtil.getLoginIdAsLong();
+		customerConsultationRecord.setUserId(userId);
+		customerConsultationRecordMapper.insert(customerConsultationRecord);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	private GoodsDon convertToGoodsDon(GoodsQaShowView view) {
+		GoodsDon don = new GoodsDon();
+		don.setTitle(view.getTitle());
+		don.setId(view.getGoodsId());
+		return don;
+	}
+}