zoujiajian před 2 roky
rodič
revize
4cdd2cd575

+ 10 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GiftCardUserRecord.java

@@ -59,4 +59,14 @@ public class GiftCardUserRecord extends BaseEntity{
 	private String rc;
 
 	private Boolean isUsed;
+
+	/**
+	 * 礼品卡赠送类型
+	 */
+	private String type;
+
+	/**
+	 * 背景图
+	 */
+	private String img;
 }

+ 32 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/dto/GiftCardDto.java

@@ -0,0 +1,32 @@
+package com.cyksj.model.manage.dto;
+
+import com.cyksj.model.request.GiftCardPayReq;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/*
+ *项目名: yhlxj
+ *文件名: GiftCardDto
+ *创建者: JavaZou
+ *创建时间:2023/9/14 15:40
+ */
+@Getter
+@Setter
+public class GiftCardDto {
+	/**
+	 * 礼品类型
+	 */
+	private String gcShowType;
+
+	/**
+	 * 礼品卡赠送背景
+	 */
+	private String gcImg;
+
+	/**
+	 * 购买 礼品卡
+	 */
+	private List<GiftCardPayReq> giftCards;
+}

+ 3 - 2
netflix-dao/src/main/java/com/cyksj/model/request/OrderPayRequest.java

@@ -1,6 +1,7 @@
 package com.cyksj.model.request;
 
 import com.cyksj.model.entity.OrderDon;
+import com.cyksj.model.manage.dto.GiftCardDto;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
@@ -105,9 +106,9 @@ public class OrderPayRequest {
     private String callbackType;
 
     /**
-     * 购买 礼品卡
+     * 礼品卡购买
      */
-    private List<GiftCardPayReq> giftCards;
+    private GiftCardDto gcPayInfo;
 
     private Long goodsId;
 

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GiftCardDetailFrontView.java

@@ -37,4 +37,10 @@ public class GiftCardDetailFrontView {
 
 	@DbField("gr.rc")
 	private String code;
+
+	@DbField("gr.type")
+	private String gcShowType;
+
+	@DbField("gr.img")
+	private String gcImg;
 }

+ 18 - 8
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -53,6 +53,7 @@ import com.cyksj.mapper.market.task.UserBindDetailMapper;
 import com.cyksj.model.dto.*;
 import com.cyksj.model.entity.Address;
 import com.cyksj.model.entity.*;
+import com.cyksj.model.manage.dto.GiftCardDto;
 import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.manage.views.OrderDonView;
 import com.cyksj.model.request.GiftCardPayReq;
@@ -232,7 +233,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	public OrderDon submit(OrderPayRequest payRequest) throws Exception {
 		GoodsDonSku sku = null;
 		Long goodsId;
-		List<GiftCardPayReq> giftCards = payRequest.getGiftCards();
+		List<GiftCardPayReq> giftCards = null;
+		GiftCardDto gcPayInfo = payRequest.getGcPayInfo();
+		if (gcPayInfo != null && gcPayInfo.getGiftCards() != null) {
+			giftCards = gcPayInfo.getGiftCards();
+		}
 		AtomicBoolean isGiftCardPay = new AtomicBoolean(false);
 		if (CollUtil.isNotEmpty(giftCards)) {
 			goodsId = payRequest.getGoodsId();
@@ -462,8 +467,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		}
 		orderDon.setSpecialType(goodsDon.getSpecialType());
 		//礼品卡购买记录
-		if (CollUtil.isNotEmpty(payRequest.getGiftCards())) {
-			redisService.set(RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getName() + orderDon.getId(), payRequest.getGiftCards(), RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getTimeout());
+		if (CollUtil.isNotEmpty(giftCards)) {
+			redisService.set(RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getName() + orderDon.getId(), gcPayInfo, RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getTimeout());
 		}
 		//礼品卡现金使用记录
 		if (CollUtil.isNotEmpty(orderDon.getGcUseRecords())) {
@@ -2074,10 +2079,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				//礼品卡购买记录
 				Object giftCardPay = redisService.get(RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getName() + orderDon.getId());
 				if (giftCardPay != null) {
-					List<GiftCardPayReq> giftCardPayReqs = Jsons.parseList(giftCardPay, GiftCardPayReq.class);
-					if (CollUtil.isNotEmpty(giftCardPayReqs)) {
+					GiftCardDto giftCardDto = Jsons.parseObject(giftCardPay.toString(), GiftCardDto.class);
+					if (giftCardDto != null) {
 						log.info("记录用户userId:{}订单orderId:{}购买成功礼品卡", orderDon.getUserId(), orderDon.getId());
-						giftCardUserPayRecord(giftCardPayReqs, orderDon);
+						giftCardUserPayRecord(giftCardDto, orderDon);
 					}
 				}
 			} catch (Exception e) {
@@ -2136,17 +2141,20 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	/**
 	 * 用户购买成功礼品卡记录
 	 */
-	private void giftCardUserPayRecord(List<GiftCardPayReq> giftCards, OrderDon orderDon) {
+	private void giftCardUserPayRecord(GiftCardDto giftCardDto, OrderDon orderDon) {
 		//礼品卡规格
 		Map<Long, Integer> giftCardPayNumMap = new ConcurrentHashMap<>();
 		AtomicInteger init_size = new AtomicInteger(0);
+		List<GiftCardPayReq> giftCards = giftCardDto.getGiftCards();
+		String gcImg = giftCardDto.getGcImg();
+		String gcShowType = giftCardDto.getGcShowType();
 		giftCards.stream().forEach(data -> {
 			giftCardPayNumMap.putIfAbsent(data.getGcId(), data.getNum());
 			init_size.addAndGet(data.getNum());
 		});
 		List<GiftCardGoodsSkuFrontView> giftCardViews = beanSearcher.searchAll(GiftCardGoodsSkuFrontView.class, MapUtils.builder().field(GiftCardGoodsSkuFrontView::getId, giftCardPayNumMap.keySet()).build());
 		if (giftCardViews.size() != giftCards.size()) {
-			throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重试");
+			log.info("用户userId:{}购买orderId:{}成功后,礼品卡兑换数量错误", orderDon.getUserId(), orderDon.getId());
 		}
 		List<GiftCardUserRecord> gcUserPayRecords = new ArrayList<>(init_size.get());
 		for (GiftCardGoodsSkuFrontView data : giftCardViews) {
@@ -2168,6 +2176,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				giftCardUserRecord.setUserId(orderDon.getUserId());
 				giftCardUserRecord.setGcType(data.getGcType());
 				giftCardUserRecord.setGcDetail(gcDetail);
+				giftCardUserRecord.setType(gcShowType);
+				giftCardUserRecord.setImg(gcImg);
 				gcUserPayRecords.add(giftCardUserRecord);
 			}
 		}