瀏覽代碼

售后问题展示

zoujiajian 2 年之前
父節點
當前提交
e27569184c

+ 34 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonQaFrontView.java

@@ -0,0 +1,34 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: GoodsDonQaFrontView
+ * 创建者: JavaZou
+ * 创建时间:2024/5/27 11:07
+ */
+@Getter
+@Setter
+@SearchBean(tables = "goods_don_qa_relate gr inner join goods_don_qa ga on ga.id = gr.question_id",
+		where = "ga.status is true and ga.deleted is true",
+		orderBy = "ga.update_time desc")
+public class GoodsDonQaFrontView {
+	@DbField("ga.problem")
+	private String problem;
+
+	@DbField("ga.type")
+	private Integer type;
+
+	@DbField("gr.goods_id")
+	private Long goodsId;
+
+	@DbField("ga.content")
+	private String content;
+
+	@DbField("ga.url")
+	private String url;
+}

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsFrontListView.java

@@ -163,4 +163,7 @@ public class GoodsFrontListView {
 
 	@DbIgnore
 	private OrderCommentFrontView comments;
+
+	@DbIgnore
+	private List<GoodsDonQaFrontView> questions;
 }

+ 1 - 0
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -773,6 +773,7 @@ public class RedisService {
         H5_WEB_CACHE("h5_web_cache", "h5首页平台缓存", 10 * 60),
         YH_HOME_PAGHE_CACHE("yh_home_paghe_cache:", "银河首页缓存", 30 * 60),
         YH_HOME_PAGHE_CACHE_SHOP("yh_home_paghe_cache:shop:", "银河首页店铺缓存", 40 * 60),
+        YH_GOODS_QUESTIONS_DETAIL("yh_goods_questions_detail:", "平台售后问题", 60 * 60 * 24),
         REGISTER_HOME_PAGE_CACHE("register_home_page_cache:", "注册首页缓存", 10 * 60),
         CPS_BACK_LOGIN_KEY("cps_back_login:", "cps商务后台登录key", 3 * 60),
         CPS_AUTH_SUCCESS_KEY("cps_auth_success_key:%s", "cps后台微信授权", 60 * 10),

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/mange/RefreshCacheService.java

@@ -30,4 +30,6 @@ public interface RefreshCacheService {
 	 * 清除用户店铺缓存
 	 */
 	void refreshUserShopMangeCache(String customId);
+
+	void goodsQuestionCache();
 }

+ 12 - 0
netflix-service/src/main/java/com/cyksj/service/mange/impl/RefreshCacheServiceImpl.java

@@ -1,10 +1,12 @@
 package com.cyksj.service.mange.impl;
 
+import com.cyksj.model.entity.GoodsDon;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.mange.RefreshCacheService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -50,4 +52,14 @@ public class RefreshCacheServiceImpl implements RefreshCacheService {
 		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + customId + "*");
 		redisService.del(keys.toArray(String[]::new));
 	}
+
+	@Override
+	public void goodsQuestionCache() {
+		//售前
+		String goodsQuestionKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "goods_detail:*";
+		Set<String> keys = redisService.keys(goodsQuestionKey);
+		redisService.del(keys.toArray(String[]::new));
+		//售后缓存
+		redisService.del(RedisService.key.YH_GOODS_QUESTIONS_DETAIL.getEnvName() + "*");
+	}
 }

+ 2 - 0
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -374,6 +374,8 @@ public class GoodsDonController {
 			Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
 					.eq(OrderDon::getGoodsId, views.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
 			views.setSold(sold + views.getSold());
+			List<GoodsDonQaFrontView> donQaFrontViews = beanSearcher.searchAll(GoodsDonQaFrontView.class, MapUtils.builder().field(GoodsDonQaFrontView::getGoodsId, id).field(GoodsDonQaFrontView::getType, 1).build());
+			views.setQuestions(donQaFrontViews);
 			redisService.setNx(goodsDetailKey, views, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 60 * RandomUtil.randomInt(10));
 			o = redisService.get(goodsDetailKey);
 		}

+ 34 - 0
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -763,4 +763,38 @@ public class GroupRelationController {
         List<RenewalView> expiryRenewals = groupRelationFrontService.getExpiryRenewalNotify(userId);
         return GatewayResponse.SUCCESS.newBuilder().toResult(expiryRenewals);
     }
+
+    /**
+     * 车票售后常见问题
+     */
+    @GetMapping("/get/questions/{goodsId}")
+    public Result<List<GoodsDonQaFrontView>> getTicketQuestions(@PathVariable Long goodsId) {
+        String key = RedisService.key.YH_GOODS_QUESTIONS_DETAIL.getEnvName() + goodsId;
+        Object o = redisService.get(key);
+        if (o == null) {
+            List<GoodsDonQaFrontView> donQaFrontViews = beanSearcher.searchAll(GoodsDonQaFrontView.class, MapUtils.builder().field(GoodsDonQaFrontView::getGoodsId, goodsId).field(GoodsDonQaFrontView::getType, 2).build());
+            if (CollUtil.isEmpty(donQaFrontViews)) {
+                return GatewayResponse.SUCCESS.newBuilder().toResult();
+            }
+            redisService.setNx(key, donQaFrontViews, RedisService.key.YH_GOODS_QUESTIONS_DETAIL.getTimeout());
+            o = redisService.get(key);
+        }
+        List<GoodsDonQaFrontView> donQaFrontViews = Jsons.parseList(o, GoodsDonQaFrontView.class);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(donQaFrontViews);
+    }
+
+    /**
+     * 车票售后常见问题
+     */
+    @GetMapping("/get/first/pay/{goodsId}")
+    public Result<Boolean> getFirstPay(@PathVariable Long goodsId) {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+        Number number = beanSearcher.searchCount(OrderDon.class, MapUtils.builder()
+                .field(OrderDon::getGoodsId, goodsId)
+                .field(OrderDon::getUserId, userIdList).op(Operator.InList)
+                .field(OrderDon::getStatus, Constant.noOrderStatus).op(Operator.NotIn)
+                .build());
+        return GatewayResponse.SUCCESS.newBuilder().toResult(number.intValue() > 0 ? true : false);
+    }
 }

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

@@ -5,7 +5,9 @@ import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.model.entity.GoodsDonQa;
 import com.cyksj.model.views.GoodsDonQaView;
+import com.cyksj.redis.RedisService;
 import com.cyksj.service.mange.GoodsDonQaService;
+import com.cyksj.service.mange.RefreshCacheService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.util.MapUtils;
@@ -32,10 +34,15 @@ public class GoodsDonQuestionController {
 
 	private final HttpServletRequest request;
 
+	private final RedisService redisService;
+
+	private final RefreshCacheService refreshCacheService;
+
 
 	@PostMapping("/post")
 	public Result<String> post(@RequestBody GoodsDonQa goodsDonQa) {
 		goodsDonQaService.saveOrdUpdateQa(goodsDonQa);
+		refreshCacheService.goodsQuestionCache();
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
@@ -46,6 +53,7 @@ public class GoodsDonQuestionController {
 		if (byId != null && byId.getDeleted()) {
 			byId.setDeleted(false);
 			goodsDonQaService.updateById(byId);
+			refreshCacheService.goodsQuestionCache();
 		}
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -53,6 +61,7 @@ public class GoodsDonQuestionController {
 	@PutMapping("/update")
 	public Result<String> update(@RequestBody GoodsDonQa goodsDonQa) {
 		goodsDonQaService.saveOrdUpdateQa(goodsDonQa);
+		refreshCacheService.goodsQuestionCache();
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
@@ -66,6 +75,7 @@ public class GoodsDonQuestionController {
 		if (byId != null) {
 			byId.setStatus(!byId.getStatus());
 			goodsDonQaService.updateById(byId);
+			refreshCacheService.goodsQuestionCache();
 		}
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -80,6 +90,7 @@ public class GoodsDonQuestionController {
 				.ne(GoodsDonQa::getStatus, status)
 				.in(GoodsDonQa::getId, ids)
 				.eq(GoodsDonQa::getDeleted, 1));
+		refreshCacheService.goodsQuestionCache();
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}