zoujiajian 2 жил өмнө
parent
commit
0f4fa02040

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

@@ -65,6 +65,9 @@ public class GiftCardUserPayFrontView {
 	@DbField("gr.img")
 	private String gcImg;
 
+	@DbField("if(user_id = :uid:,1,2)")
+	private Integer type;
+
 	@DbField("u2.nickname")
 	private String toNickname;
 }

+ 74 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GiftCardUserRecordView.java

@@ -0,0 +1,74 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/*
+ *项目名: yhlxj
+ *文件名: GiftCardUserRecordView
+ *创建者: JavaZou
+ *创建时间:2023/9/18 11:48
+ */
+@Getter
+@Setter
+@SearchBean(tables = "gift_card_user_record", where = ":uid:")
+public class GiftCardUserRecordView {
+	private Long userId;
+
+	private Long orderId;
+
+	/**
+	 * 礼品卡类型
+	 */
+	private Integer gcType;
+
+	/**
+	 * 礼品卡明细
+	 */
+	private String gcDetail;
+
+	private Long gcGoodsId;
+
+	private Long gcSkuId;
+
+	private BigDecimal cash;
+
+	private BigDecimal remainCash;
+
+	private Long toUserId;
+
+	private Boolean isSend;
+
+	/**
+	 * 领取时间
+	 */
+	private Date receivedTime;
+
+	private Date payTime;
+
+	/**
+	 * 是否已购买
+	 */
+	private Boolean isPay;
+
+	/**
+	 * 礼品卡兑换随机码
+	 */
+	private String rc;
+
+	private Boolean isUsed;
+
+	/**
+	 * 礼品卡赠送类型
+	 */
+	private String type;
+
+	/**
+	 * 背景图
+	 */
+	private String img;
+}

+ 8 - 12
netflix-web/src/main/java/com/cyksj/web/controller/user/UserController.java

@@ -119,10 +119,10 @@ public class UserController {
                 .eq(OrderDon::getStatus, OrderDon.Status.noPayment).last("limit 1"));
         personalView.setIsNoPayment(orderDon != null ? true : false);
         //礼品卡可用数量
-        Number numOfGiftCard = beanSearcher.searchCount(GiftCardUserRecord.class, MapUtils.builder()
-                .field(GiftCardUserRecord::getToUserId, userId)
-                .field(GiftCardUserRecord::getIsPay, true)
-                .field(GiftCardUserRecord::getIsUsed, false)
+        Number numOfGiftCard = beanSearcher.searchCount(GiftCardUserRecordView.class, MapUtils.builder()
+                .put("uid", String.format("(user_id = %s or to_user_id = %s)", userId, userId))
+                .field(GiftCardUserRecordView::getIsPay, true)
+                .field(GiftCardUserRecordView::getIsUsed, false)
                 .build());
         personalView.setNumOfGiftCard(numOfGiftCard.intValue());
         return GatewayResponse.SUCCESS.newBuilder().toResult(personalView);
@@ -348,20 +348,16 @@ public class UserController {
 
     /**
      * 个人礼品卡列表
-     * @param type 1自购,2、获赠
      * @return
      */
     @GetMapping("/get/giftCard")
-    public Result<SearchResult<GiftCardUserPayFrontView>> getGiftCard(@RequestParam(defaultValue = "1") Integer type) {
+    public Result<SearchResult<GiftCardUserPayFrontView>> getGiftCard() {
         long userId = StpUserUtil.getLoginIdAsLong();
-        String condition = StrUtil.EMPTY;
-        if (type == 1) {
-            condition += String.format("and user_id = %s", userId);
-        } else {
-            condition += String.format("and to_user_id = %s", userId);
-        }
+        String condition = String.format("and (user_id = %s or to_user_id = %s)", userId, userId);
         SearchResult<GiftCardUserPayFrontView> view = beanSearcher.search(GiftCardUserPayFrontView.class, MapUtils.builder()
                 .put("condition", condition)
+                .put("uid", userId)
+                .orderBy(GiftCardUserRecordView::getIsUsed).asc()
                 .orderBy(GiftCardUserPayFrontView::getId).desc().build());
         return GatewayResponse.SUCCESS.newBuilder().toResult(view);
     }