Ver código fonte

Merge branch 'gift_card_func'

# Conflicts:
#	netflix-common/src/main/java/com/cyksj/common/constant/Constant.java
#	netflix-common/src/main/java/com/cyksj/dto/RedisKey.java
#	netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDon.java
#	netflix-dao/src/main/java/com/cyksj/model/entity/OrderDon.java
#	netflix-dao/src/main/java/com/cyksj/model/request/OrderPayRequest.java
#	netflix-dao/src/main/java/com/cyksj/model/request/TelegramBotMsgReq.java
#	netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonSkuFrontView.java
#	netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java
#	netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java
#	netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java
#	netflix-web/src/main/java/com/cyksj/web/controller/user/DistributePopularizeController.java
zoujiajian 2 anos atrás
pai
commit
46c6ce3d15
51 arquivos alterados com 1959 adições e 401 exclusões
  1. 5 0
      netflix-common/src/main/java/com/cyksj/common/constant/Constant.java
  2. 13 0
      netflix-dao/src/main/java/com/cyksj/mapper/GiftCardGoodsSkuMapper.java
  3. 13 0
      netflix-dao/src/main/java/com/cyksj/mapper/GiftCardOrderRelateMapper.java
  4. 13 0
      netflix-dao/src/main/java/com/cyksj/mapper/GiftCardOrderUseRecordMapper.java
  5. 19 0
      netflix-dao/src/main/java/com/cyksj/mapper/GiftCardUserRecordMapper.java
  6. 48 0
      netflix-dao/src/main/java/com/cyksj/model/entity/GiftCardGoodsSku.java
  7. 20 0
      netflix-dao/src/main/java/com/cyksj/model/entity/GiftCardOrderRelate.java
  8. 35 0
      netflix-dao/src/main/java/com/cyksj/model/entity/GiftCardOrderUseRecord.java
  9. 77 0
      netflix-dao/src/main/java/com/cyksj/model/entity/GiftCardUserRecord.java
  10. 4 2
      netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDon.java
  11. 4 1
      netflix-dao/src/main/java/com/cyksj/model/entity/OrderDetailView.java
  12. 16 0
      netflix-dao/src/main/java/com/cyksj/model/entity/OrderDon.java
  13. 38 0
      netflix-dao/src/main/java/com/cyksj/model/manage/dto/GiftCardDto.java
  14. 7 0
      netflix-dao/src/main/java/com/cyksj/model/manage/views/OrderDonBackView.java
  15. 4 1
      netflix-dao/src/main/java/com/cyksj/model/manage/views/OrderDonSearchView.java
  16. 1 1
      netflix-dao/src/main/java/com/cyksj/model/manage/views/OrderDonView.java
  17. 29 0
      netflix-dao/src/main/java/com/cyksj/model/request/GiftCardGoodsSkuReq.java
  18. 24 0
      netflix-dao/src/main/java/com/cyksj/model/request/GiftCardPayReq.java
  19. 24 0
      netflix-dao/src/main/java/com/cyksj/model/request/GiftCardReceiveReq.java
  20. 18 1
      netflix-dao/src/main/java/com/cyksj/model/request/OrderPayRequest.java
  21. 4 4
      netflix-dao/src/main/java/com/cyksj/model/request/TelegramBotMsgReq.java
  22. 1 1
      netflix-dao/src/main/java/com/cyksj/model/views/DistributePopularizeOrdersView.java
  23. 55 0
      netflix-dao/src/main/java/com/cyksj/model/views/GiftCardDetailFrontView.java
  24. 66 0
      netflix-dao/src/main/java/com/cyksj/model/views/GiftCardGoodsSkuFrontView.java
  25. 73 0
      netflix-dao/src/main/java/com/cyksj/model/views/GiftCardGoodsSkuView.java
  26. 79 0
      netflix-dao/src/main/java/com/cyksj/model/views/GiftCardUserPayFrontView.java
  27. 66 0
      netflix-dao/src/main/java/com/cyksj/model/views/GiftCardUserPayView.java
  28. 74 0
      netflix-dao/src/main/java/com/cyksj/model/views/GiftCardUserRecordView.java
  29. 2 0
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonSkuFrontView.java
  30. 7 0
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonViews.java
  31. 30 0
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsSkuGiftCardView.java
  32. 5 0
      netflix-dao/src/main/java/com/cyksj/model/views/UserPersonalView.java
  33. 5 0
      netflix-dao/src/main/java/com/cyksj/model/views/UserTicketView.java
  34. 20 0
      netflix-service/src/main/java/com/cyksj/service/giftcard/GiftCardGoodsSkuService.java
  35. 14 0
      netflix-service/src/main/java/com/cyksj/service/giftcard/GiftCardOrderUseRecordService.java
  36. 13 0
      netflix-service/src/main/java/com/cyksj/service/giftcard/GiftCardUserRecordService.java
  37. 128 0
      netflix-service/src/main/java/com/cyksj/service/giftcard/impl/GiftCardGoodsSkuServiceImpl.java
  38. 47 0
      netflix-service/src/main/java/com/cyksj/service/giftcard/impl/GiftCardOrderUseRecordServiceImpl.java
  39. 17 0
      netflix-service/src/main/java/com/cyksj/service/giftcard/impl/GiftCardUserRecordServiceImpl.java
  40. 31 3
      netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java
  41. 21 20
      netflix-service/src/main/java/com/cyksj/service/order/impl/OrderCommonServiceImpl.java
  42. 423 344
      netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java
  43. 5 0
      netflix-service/src/main/java/com/cyksj/service/user/UserService.java
  44. 120 2
      netflix-service/src/main/java/com/cyksj/service/user/impl/UserServiceImpl.java
  45. 20 7
      netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java
  46. 2 2
      netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java
  47. 14 1
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonController.java
  48. 120 0
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/GiftCardController.java
  49. 1 7
      netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderController.java
  50. 24 0
      netflix-web/src/main/java/com/cyksj/web/controller/user/AuthorizationController.java
  51. 60 4
      netflix-web/src/main/java/com/cyksj/web/controller/user/UserController.java

+ 5 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -162,4 +162,9 @@ public interface Constant {
 
 	//PS AI,POE会员
 	List<Long> DOWN_GOODS_PAY = List.of(33l, 35l);
+
+	/**
+	 * 人民币符号
+	 */
+	String CN_CYS = "¥";
 }

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

@@ -0,0 +1,13 @@
+package com.cyksj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.GiftCardGoodsSku;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardGoodsSkuMapper
+ *创建者: JavaZou
+ *创建时间:2023/8/28 16:35
+ */
+public interface GiftCardGoodsSkuMapper extends BaseMapper<GiftCardGoodsSku> {
+}

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

@@ -0,0 +1,13 @@
+package com.cyksj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.GiftCardOrderRelate;
+
+/*
+ *项目名: yhlxj
+ *文件名: GiftCardOrderRelateMapper
+ *创建者: JavaZou
+ *创建时间:2023/9/14 16:14
+ */
+public interface GiftCardOrderRelateMapper extends BaseMapper<GiftCardOrderRelate> {
+}

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

@@ -0,0 +1,13 @@
+package com.cyksj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.GiftCardOrderUseRecord;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardOrderUseRecordMapper
+ *创建者: JavaZou
+ *创建时间:2023/8/29 16:13
+ */
+public interface GiftCardOrderUseRecordMapper extends BaseMapper<GiftCardOrderUseRecord> {
+}

+ 19 - 0
netflix-dao/src/main/java/com/cyksj/mapper/GiftCardUserRecordMapper.java

@@ -0,0 +1,19 @@
+package com.cyksj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.GiftCardUserRecord;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
+
+import java.math.BigDecimal;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardUserRecordMapper
+ *创建者: JavaZou
+ *创建时间:2023/8/28 12:01
+ */
+public interface GiftCardUserRecordMapper extends BaseMapper<GiftCardUserRecord> {
+	@Update("update gift_card_user_record set remain_cash = remain_cash + #{addCash},is_used = 0 where id = #{gcId} and remain_cash = #{remainCash}")
+	Integer updateGiftCardRemainCash(@Param("gcId") Long gcId, @Param("addCash") BigDecimal addCash, @Param("remainCash") BigDecimal remainCash);
+}

+ 48 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GiftCardGoodsSku.java

@@ -0,0 +1,48 @@
+package com.cyksj.model.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardGoodsSku
+ *创建者: JavaZou
+ *创建时间:2023/8/28 16:34
+ */
+@Getter
+@Setter
+public class GiftCardGoodsSku extends BaseEntity{
+	private Long goodsId;
+
+	/**
+	 * 礼品卡类型 1现金卡、2虚拟卡
+	 */
+	private Integer gcType;
+
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private Long gcGoodsId;
+
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private Long gcSkuId;
+
+	/**
+	 * 现金
+	 */
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private BigDecimal cash;
+
+	/**
+	 * 对应价格
+	 */
+	private BigDecimal price;
+
+	private String logo;
+
+	private Boolean status;
+
+	private Boolean deleted;
+}

+ 20 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GiftCardOrderRelate.java

@@ -0,0 +1,20 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/*
+ *项目名: yhlxj
+ *文件名: GiftCardOrderRelate
+ *创建者: JavaZou
+ *创建时间:2023/9/14 16:14
+ */
+@Getter
+@Setter
+public class GiftCardOrderRelate extends BaseEntity{
+	private Long orderId;
+
+	private String gcPayDetail;
+
+	private Boolean isPay;
+}

+ 35 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GiftCardOrderUseRecord.java

@@ -0,0 +1,35 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardOrderUseRecord
+ *创建者: JavaZou
+ *创建时间:2023/8/29 16:12
+ */
+@Getter
+@Setter
+public class GiftCardOrderUseRecord extends BaseEntity{
+	private Long orderId;
+
+	private Long userId;
+
+	/**
+	 * 礼品卡id
+	 */
+	private Long gcId;
+
+	/**
+	 * 使用礼品卡现金数量
+	 */
+	private BigDecimal cash;
+
+	/**
+	 * 默认已使用
+	 */
+	private Boolean isUsed;
+}

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

@@ -0,0 +1,77 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardUserRecord
+ *创建者: JavaZou
+ *创建时间:2023/8/25 18:16
+ */
+@Getter
+@Setter
+public class GiftCardUserRecord extends BaseEntity{
+	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;
+
+	/**
+	 * 座位id
+	 */
+	private Long relationId;
+}

+ 4 - 2
netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDon.java

@@ -17,7 +17,8 @@ import java.util.List;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don")
+@SearchBean(tables = "goods_don",
+		where = ":condition:")
 public class GoodsDon extends BaseEntity {
 
 
@@ -187,7 +188,8 @@ public class GoodsDon extends BaseEntity {
     @Getter
     public enum SpecialType {
         recharge("代充"),
-        courseware("课件")
+        courseware("课程"),
+        giftCard("礼品卡")
         ;
 
         private String desc;

+ 4 - 1
netflix-dao/src/main/java/com/cyksj/model/entity/OrderDetailView.java

@@ -17,7 +17,7 @@ import java.math.BigDecimal;
 @Getter
 @Setter
 @SearchBean(tables = "order_don o left join goods_don_sku sku on o.sku_id = sku.id " +
-		"left join goods_don g on g.id = sku.goods_id ")
+		"left join goods_don g on g.id = o.goods_id ")
 public class OrderDetailView {
 	/**
 	 * 订单id
@@ -62,6 +62,9 @@ public class OrderDetailView {
 	@DbField("o.num")
 	private Integer num;
 
+	@DbField("o.pay_title")
+	private String payTitle;
+
 	@DbIgnore
 	private OrderDonWaybill waybill;
 

+ 16 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/OrderDon.java

@@ -2,6 +2,8 @@ package com.cyksj.model.entity;
 
 import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.Setter;
@@ -10,6 +12,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @author chan
@@ -71,6 +74,11 @@ public class OrderDon extends BaseEntity implements Serializable {
      */
     private BigDecimal refundBalance;
 
+    /**
+     * 礼品卡现金支付金额
+     */
+    private BigDecimal gcCash;
+
     /**
      * 退款原因
      */
@@ -231,6 +239,14 @@ public class OrderDon extends BaseEntity implements Serializable {
      */
     private Boolean isOt;
 
+    /**
+     * 礼品卡现金使用记录
+     */
+    @DbIgnore
+    @TableField(exist = false)
+    @JsonIgnore
+    private List<GiftCardOrderUseRecord> gcUseRecords;
+
     public enum Status {
         /**
          * 订单状态

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

@@ -0,0 +1,38 @@
+package com.cyksj.model.manage.dto;
+
+import com.cyksj.model.request.GiftCardPayReq;
+import com.cyksj.model.views.GiftCardGoodsSkuFrontView;
+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;
+
+	/**
+	 * 购买信息
+	 */
+	private List<GiftCardGoodsSkuFrontView> gcPayDetail;
+}

+ 7 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/OrderDonBackView.java

@@ -1,5 +1,6 @@
 package com.cyksj.model.manage.views;
 
+import com.cyksj.model.entity.GoodsDon;
 import com.cyksj.model.entity.OrderDon;
 import com.cyksj.model.entity.OrderDonTransport;
 import com.cyksj.model.entity.OrderDonWaybill;
@@ -69,6 +70,9 @@ public class OrderDonBackView {
 	@DbField("g.title")
 	private String title;
 
+	@DbField("g.special_type")
+	private GoodsDon.SpecialType goodsSpecialType;
+
 	@DbField("o.sku_id")
 	private Long skuId;
 
@@ -105,6 +109,9 @@ public class OrderDonBackView {
 	@DbField("o.balance")
 	private BigDecimal balance;
 
+	@DbField("o.gc_cash")
+	private BigDecimal gcCash;
+
 	@DbField("o.refund_money")
 	private BigDecimal refundMoney;
 

+ 4 - 1
netflix-dao/src/main/java/com/cyksj/model/manage/views/OrderDonSearchView.java

@@ -24,7 +24,7 @@ import java.util.List;
 @Getter
 @Setter
 @SearchBean(tables = "(select * from order_don :orderId:) o left join goods_don_sku sku on o.sku_id = sku.id " +
-		"left join goods_don g on g.id = sku.goods_id " +
+		"left join goods_don g on g.id = o.goods_id " +
 		"left join order_don_transport odt on odt.order_id = o.id")
 public class OrderDonSearchView {
 	@DbField("o.id")
@@ -153,6 +153,9 @@ public class OrderDonSearchView {
 	@DbIgnore
 	private List<GoodsDonSkuView> benefitsViews;
 
+	@DbField("o.pay_title")
+	private String payTitle;
+
 	/**
 	 * 关联兑换码
 	 */

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/manage/views/OrderDonView.java

@@ -22,7 +22,7 @@ import java.util.List;
 @Getter
 @Setter
 @SearchBean(tables = "order_don o left join goods_don_sku sku on o.sku_id = sku.id " +
-        "left join goods_don g on g.id = sku.goods_id " +
+        "left join goods_don g on g.id = o.goods_id " +
         "left join order_don_transport odt on odt.order_id = o.id")
 public class OrderDonView {
 

+ 29 - 0
netflix-dao/src/main/java/com/cyksj/model/request/GiftCardGoodsSkuReq.java

@@ -0,0 +1,29 @@
+package com.cyksj.model.request;
+
+import com.cyksj.model.entity.GiftCardGoodsSku;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/*
+ *项目名: yhlxj
+ *文件名: GiftCardGoodsSkuReq
+ *创建者: JavaZou
+ *创建时间:2023/9/13 17:16
+ */
+@Getter
+@Setter
+public class GiftCardGoodsSkuReq {
+	/**
+	 * 礼品卡平台
+	 */
+	private Long goodsId;
+
+	/**
+	 * 礼品卡类型 1现金卡、2虚拟卡
+	 */
+	private Integer gcType;
+
+	private List<GiftCardGoodsSku> configs;
+}

+ 24 - 0
netflix-dao/src/main/java/com/cyksj/model/request/GiftCardPayReq.java

@@ -0,0 +1,24 @@
+package com.cyksj.model.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardPayReq
+ *创建者: JavaZou
+ *创建时间:2023/8/30 11:02
+ */
+@Getter
+@Setter
+public class GiftCardPayReq {
+	/**
+	 * 礼品卡id
+	 */
+	private Long gcId;
+
+	/**
+	 * 礼品卡购买数量
+	 */
+	private Integer num;
+}

+ 24 - 0
netflix-dao/src/main/java/com/cyksj/model/request/GiftCardReceiveReq.java

@@ -0,0 +1,24 @@
+package com.cyksj.model.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotEmpty;
+
+/*
+ *项目名: yhlxj
+ *文件名: GiftCardReceiveReq
+ *创建者: JavaZou
+ *创建时间:2023/9/19 15:01
+ */
+@Getter
+@Setter
+public class GiftCardReceiveReq {
+
+	@NotEmpty
+	private String code;
+
+	private Long userId;
+
+	private Long relationId;
+}

+ 18 - 1
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;
@@ -22,7 +23,6 @@ public class OrderPayRequest {
     /**
      * 商品id
      */
-    @NotNull(message = "缺少必填参数")
     private Long skuId;
 
     /**
@@ -109,4 +109,21 @@ public class OrderPayRequest {
      * 是否是特定价格
      */
     private Boolean isSpecificPrice;
+
+    /**
+     * 礼品卡购买
+     */
+    private GiftCardDto gcPayInfo;
+
+    private Long goodsId;
+
+    /**
+     * 礼品卡现金支付
+     */
+    private BigDecimal gcCash;
+
+    /**
+     * 礼品卡现金支付所拥有id
+     */
+    private List<Long> gcpIds;
 }

+ 4 - 4
netflix-dao/src/main/java/com/cyksj/model/request/TelegramBotMsgReq.java

@@ -9,11 +9,11 @@ import lombok.Data;
 @Data
 public class TelegramBotMsgReq {
 
-    private String name;
+	private String name;
 
-    private String goodsName;
+	private String goodsName;
 
-    private Integer number;
+	private Integer number;
 
-    private Long day;
+	private Long day;
 }

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/views/DistributePopularizeOrdersView.java

@@ -59,7 +59,7 @@ public class DistributePopularizeOrdersView {
 	@DbField("od.status")
 	private OrderDon.Status orderStatus;
 
-	@DbIgnore
+	@DbField("od.pay_title")
 	private String specVal;
 
 	@DbField("od.created_time")

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

@@ -0,0 +1,55 @@
+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.math.BigDecimal;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardDetailFrontView
+ *创建者: JavaZou
+ *创建时间:2023/8/29 17:58
+ */
+@Getter
+@Setter
+@SearchBean(tables = "gift_card_user_record gr left join user u on u.id = gr.user_id")
+public class GiftCardDetailFrontView {
+	@DbField("gr.id")
+	private Long id;
+
+	@DbField("u.headimgurl")
+	private String headimgurl;
+
+	@DbField("u.nickname")
+	private String nickname;
+
+	@DbField("gr.gc_detail")
+	private String gcDetail;
+
+	@DbField("gr.cash")
+	private BigDecimal cash;
+
+	@DbField("gr.gc_goods_id")
+	private Long gcGoodsId;
+
+	@DbField("gr.gc_sku_id")
+	private Long gcSkuId;
+
+	@DbField("gr.remain_cash")
+	private BigDecimal remainCash;
+
+	@DbField("gr.rc")
+	private String code;
+
+	@DbField("gr.gc_type")
+	private Integer gcType;
+
+	@DbField("gr.type")
+	private String gcShowType;
+
+	@DbField("gr.img")
+	private String gcImg;
+}

+ 66 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GiftCardGoodsSkuFrontView.java

@@ -0,0 +1,66 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardGoodsSkuFrontView
+ *创建者: JavaZou
+ *创建时间:2023/8/28 16:36
+ */
+@Getter
+@Setter
+@SearchBean(tables = "gift_card_goods_sku gc left join goods_don g on g.id = gc.gc_goods_id" +
+		" left join goods_don_sku sku on sku.id = gc.gc_sku_id",
+		where = "gc.status is true and gc.deleted is true")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class GiftCardGoodsSkuFrontView {
+	@DbField("gc.id")
+	private Long id;
+
+	@DbField("gc.goods_id")
+	private Long goodsId;
+
+	@DbField("gc.gc_type")
+	private Integer gcType;
+
+	@DbField("gc.price")
+	private BigDecimal price;
+
+	@DbField("sku.price")
+	private BigDecimal sPrice;
+
+	@DbField("gc.gc_goods_id")
+	private Long gcGoodsId;
+
+	@DbField("gc.gc_sku_id")
+	private Long gcSkuId;
+
+	@DbField("g.title")
+	private String gcGoodsTitle;
+
+	@DbField("sku.spec_val")
+	private String gcSpecVal;
+
+	@DbField("gc.cash")
+	private BigDecimal cash;
+
+	@DbField("gc.logo")
+	private String logo;
+
+	@DbIgnore
+	private Integer gcNum;
+
+	@DbIgnore
+	private String gcShowType;
+
+	@DbIgnore
+	private String gcImg;
+}

+ 73 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GiftCardGoodsSkuView.java

@@ -0,0 +1,73 @@
+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.math.BigDecimal;
+import java.util.Date;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardGoodsSkuView
+ *创建者: JavaZou
+ *创建时间:2023/8/30 10:28
+ */
+@Getter
+@Setter
+@SearchBean(tables = "gift_card_goods_sku gc left join goods_don g on g.id = gc.gc_goods_id" +
+		" left join goods_don_sku sku on sku.id = gc.gc_sku_id",
+		where = "gc.deleted is true")
+public class GiftCardGoodsSkuView {
+	@DbField("gc.id")
+	private Long id;
+
+	@DbField("gc.goods_id")
+	private Long goodsId;
+
+	/**
+	 * 礼品卡类型 1现金卡、2虚拟卡
+	 */
+	@DbField("gc.gc_type")
+	private Integer gcType;
+
+	@DbField("gc.gc_goods_id")
+	private Long gcGoodsId;
+
+	@DbField("g.title")
+	private String gcGoodsTitle;
+
+	@DbField("gc.gc_sku_id")
+	private Long gcSkuId;
+
+	@DbField("sku.spec_val")
+	private String gcSpecVal;
+
+	/**
+	 * 现金
+	 */
+	@DbField("gc.cash")
+	private BigDecimal cash;
+
+	/**
+	 * 对应价格
+	 */
+	@DbField("gc.price")
+	private BigDecimal price;
+
+	@DbField("sku.price")
+	private BigDecimal sPrice;
+
+	@DbField("gc.logo")
+	private String logo;
+
+	@DbField("gc.status")
+	private Boolean status;
+
+	@DbField("gc.created_time")
+	private Date createdTime;
+
+	@DbField("gc.update_time")
+	private Date updateTime;
+}

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

@@ -0,0 +1,79 @@
+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.math.BigDecimal;
+import java.util.Date;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardUserPayFrontView
+ *创建者: JavaZou
+ *创建时间:2023/8/29 17:33
+ * 购买的礼品卡
+ */
+@Getter
+@Setter
+@SearchBean(tables = "(select * from gift_card_user_record where is_pay is true :condition:) gr left join user u on u.id = gr.user_id" +
+		" left join user u2 on u2.id = gr.to_user_id")
+public class GiftCardUserPayFrontView {
+	@DbField("gr.id")
+	private Long id;
+
+	@DbField("gr.gc_type")
+	private Integer gcType;
+
+	@DbField("gr.gc_detail")
+	private String gcDetail;
+
+	/**
+	 * 赠送人
+	 */
+	@DbField("u.nickname")
+	private String donor;
+
+	@DbField("gr.cash")
+	private BigDecimal cash;
+
+	@DbField("gr.gc_goods_id")
+	private Long gcGoodsId;
+
+	@DbField("gr.gc_sku_id")
+	private Long gcSkuId;
+
+	@DbField("gr.remain_cash")
+	private BigDecimal remainCash;
+
+	@DbField("gr.is_send")
+	private Boolean isSend;
+
+	@DbField("gr.rc")
+	private String code;
+
+	@DbField("gr.pay_time")
+	private Date payTime;
+
+	@DbField("gr.received_time")
+	private Date receivedTime;
+
+	/**
+	 * 默认未使用
+	 */
+	@DbField("gr.is_used")
+	private Boolean isUsed;
+
+	@DbField("gr.type")
+	private String gcShowType;
+
+	@DbField("gr.img")
+	private String gcImg;
+
+	@DbField("if(user_id = :uid:,1,2)")
+	private Integer type;
+
+	@DbField("u2.nickname")
+	private String toNickname;
+}

+ 66 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GiftCardUserPayView.java

@@ -0,0 +1,66 @@
+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.math.BigDecimal;
+import java.util.Date;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardUserPayView
+ *创建者: JavaZou
+ *创建时间:2023/8/29 18:24
+ */
+@Getter
+@Setter
+@SearchBean(tables = "gift_card_user_record gr left join user u on u.id = gr.user_id" +
+		" left join user u2 on u2.id = gr.to_user_id")
+public class GiftCardUserPayView {
+	@DbField("gr.id")
+	private Long id;
+
+	@DbField("gr.gc_type")
+	private Integer gcType;
+
+	@DbField("gr.gc_detail")
+	private String gcDetail;
+
+	@DbField("gr.user_id")
+	private Long userId;
+
+	/**
+	 * 赠送人
+	 */
+	@DbField("u.nickname")
+	private String donor;
+
+	@DbField("gr.cash")
+	private BigDecimal cash;
+
+	@DbField("gr.remain_cash")
+	private BigDecimal remainCash;
+
+	@DbField("gr.is_send")
+	private Boolean isSend;
+
+	@DbField("gr.is_pay")
+	private Boolean isPay;
+
+	@DbField("gr.to_user_id")
+	private Long toUserId;
+
+	@DbField("u2.nickname")
+	private String toNickname;
+
+	@DbField("gr.rc")
+	private String code;
+
+	@DbField("gr.pay_time")
+	private Date payTime;
+
+	@DbField("gr.received_time")
+	private Date receivedTime;
+}

+ 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;
+}

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonSkuFrontView.java

@@ -4,6 +4,7 @@ import com.ejlchina.searcher.bean.DbField;
 import com.ejlchina.searcher.bean.DbIgnore;
 import com.ejlchina.searcher.bean.SearchBean;
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -19,6 +20,7 @@ import java.util.List;
 @Getter
 @Setter
 @SearchBean(tables = "goods_don_sku")
+@JsonInclude(JsonInclude.Include.NON_NULL)
 public class GoodsDonSkuFrontView {
 
 	private Long id;

+ 7 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonViews.java

@@ -129,4 +129,11 @@ public class GoodsDonViews {
 
     @DbIgnore
     private GoodsDonSpecFrontView specs;
+
+    private String giftCards;
+
+    @DbIgnore
+    private List<GoodsSkuGiftCardView> giftCardsView;
+
+    private BigDecimal giftCardCash;
 }

+ 30 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsSkuGiftCardView.java

@@ -0,0 +1,30 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+/*
+ *项目名: netflix
+ *文件名: GoodsSkuGiftCardView
+ *创建者: JavaZou
+ *创建时间:2023/8/28 14:23
+ */
+@Getter
+@Setter
+@SearchBean(tables = "goods_don g left join goods_don_sku sku on sku.id = g.goods_id",
+		where = "g.deleted is true and g.status is true and sku.true is true")
+public class GoodsSkuGiftCardView {
+	@DbField("g.id")
+	private Long goodsId;
+
+	@DbField("g.sku_id")
+	private Long skuId;
+
+	@DbField("g.title")
+	private String title;
+
+	@DbField("sku.spec_val")
+	private String specVal;
+}

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserPersonalView.java

@@ -44,5 +44,10 @@ public class UserPersonalView {
 	 */
 	private Boolean isNoPayment;
 
+	/**
+	 * 礼品卡可用数量
+	 */
+	private Integer numOfGiftCard;
+
 	private String phone;
 }

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserTicketView.java

@@ -6,6 +6,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.Date;
+
 /*
  *项目名: netflix
  *文件名: UserTicketView
@@ -35,6 +37,9 @@ public class UserTicketView {
 	@DbField("gdk.spec_val")
 	private String specVal;
 
+	@DbField("gr.expiry_time")
+	private Date expiryTime;
+
 	@DbField("gr.status")
 	@JsonIgnore
 	private String status;

+ 20 - 0
netflix-service/src/main/java/com/cyksj/service/giftcard/GiftCardGoodsSkuService.java

@@ -0,0 +1,20 @@
+package com.cyksj.service.giftcard;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.cyksj.model.entity.GiftCardGoodsSku;
+import com.cyksj.model.entity.GoodsDon;
+import com.cyksj.model.request.GiftCardGoodsSkuReq;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardGoodsSkuService
+ *创建者: JavaZou
+ *创建时间:2023/8/29 18:19
+ */
+public interface GiftCardGoodsSkuService extends IService<GiftCardGoodsSku> {
+	void setOrUpdateGiftCardSku(GiftCardGoodsSku giftCardSku);
+
+	void setGiftCardSku(GiftCardGoodsSkuReq req);
+
+	void setGiftCardGoodsStat(GoodsDon goodsDon);
+}

+ 14 - 0
netflix-service/src/main/java/com/cyksj/service/giftcard/GiftCardOrderUseRecordService.java

@@ -0,0 +1,14 @@
+package com.cyksj.service.giftcard;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.cyksj.model.entity.GiftCardOrderUseRecord;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardOrderUseRecordService
+ *创建者: JavaZou
+ *创建时间:2023/8/29 16:44
+ */
+public interface GiftCardOrderUseRecordService extends IService<GiftCardOrderUseRecord> {
+	void returnGiftCardCash(Long orderId);
+}

+ 13 - 0
netflix-service/src/main/java/com/cyksj/service/giftcard/GiftCardUserRecordService.java

@@ -0,0 +1,13 @@
+package com.cyksj.service.giftcard;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.cyksj.model.entity.GiftCardUserRecord;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardUserRecordService
+ *创建者: JavaZou
+ *创建时间:2023/8/30 10:54
+ */
+public interface GiftCardUserRecordService extends IService<GiftCardUserRecord> {
+}

+ 128 - 0
netflix-service/src/main/java/com/cyksj/service/giftcard/impl/GiftCardGoodsSkuServiceImpl.java

@@ -0,0 +1,128 @@
+package com.cyksj.service.giftcard.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.mapper.GiftCardGoodsSkuMapper;
+import com.cyksj.mapper.GoodsDonMapper;
+import com.cyksj.mapper.GoodsDonSkuMapper;
+import com.cyksj.model.entity.GiftCardGoodsSku;
+import com.cyksj.model.entity.GoodsDon;
+import com.cyksj.model.entity.GoodsDonSku;
+import com.cyksj.model.request.GiftCardGoodsSkuReq;
+import com.cyksj.redis.RedisService;
+import com.cyksj.service.giftcard.GiftCardGoodsSkuService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Set;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardGoodsSkuServiceImpl
+ *创建者: JavaZou
+ *创建时间:2023/8/29 18:19
+ */
+@Service
+@RequiredArgsConstructor
+public class GiftCardGoodsSkuServiceImpl extends ServiceImpl<GiftCardGoodsSkuMapper, GiftCardGoodsSku> implements GiftCardGoodsSkuService {
+	private final GoodsDonSkuMapper goodsDonSkuMapper;
+
+	private final GoodsDonMapper goodsDonMapper;
+
+	private final RedisService redisService;
+
+	@Override
+	public void setOrUpdateGiftCardSku(GiftCardGoodsSku data) {
+		if (data.getGoodsId() == null) {
+			throw BusinessRuntimeException.getInstance("请选择对应的礼品卡平台");
+		}
+		GoodsDon goodsDon = goodsDonMapper.selectById(data.getGoodsId());
+		if (goodsDon == null) {
+			throw BusinessRuntimeException.getInstance("请选择对应的礼品卡平台");
+		}
+		if (goodsDon.getSpecialType() == null || goodsDon.getSpecialType() != GoodsDon.SpecialType.giftCard) {
+			throw BusinessRuntimeException.getInstance("该{0}平台不是礼品卡特殊类型", goodsDon.getTitle());
+		}
+		BigDecimal cash = data.getCash();
+		Integer gcType = data.getGcType();
+		BigDecimal price = data.getPrice();
+		if (price == null || price.compareTo(BigDecimal.ZERO) <= 0) {
+			throw BusinessRuntimeException.getInstance("请输入正确的礼品卡价格");
+		}
+		Long gcSkuId = data.getGcSkuId();
+		if (gcSkuId == null && cash == null) {
+			throw BusinessRuntimeException.getInstance("请选择对应的礼品卡类型");
+		}
+
+		if (gcSkuId != null && cash != null) {
+			throw BusinessRuntimeException.getInstance("只能选择一种礼品卡类型");
+		}
+		if (cash != null) {
+			if (cash.compareTo(BigDecimal.ZERO) <= 0) {
+				throw BusinessRuntimeException.getInstance("请输入正确的礼品卡价格");
+			}
+			gcType = 1;
+		}
+		//虚拟卡
+		if (gcSkuId != null) {
+			GoodsDonSku sku = goodsDonSkuMapper.selectById(gcSkuId);
+			if (sku == null) {
+				throw BusinessRuntimeException.getInstance("存在未有的虚拟卡规格,请重新选择");
+			}
+			if (!sku.getStatus()) {
+				throw BusinessRuntimeException.getInstance("存在下架的虚拟卡规格,请重新选择");
+			}
+			gcType = 2;
+			data.setGcGoodsId(sku.getGoodsId());
+		}
+		data.setGcType(gcType);
+		if (gcType == 2 && data.getId() == null) {
+			GiftCardGoodsSku one = this.getOne(Wrappers.lambdaQuery(GiftCardGoodsSku.class)
+					.eq(GiftCardGoodsSku::getGcSkuId, gcSkuId).last("limit 1"));
+			if (one != null) {
+				return;
+			}
+		}
+		this.saveOrUpdate(data);
+		//设置对应礼品卡平台 最低价格
+		setGiftCardGoodsStat(goodsDon);
+	}
+
+	@Override
+	public void setGiftCardSku(GiftCardGoodsSkuReq req) {
+		List<GiftCardGoodsSku> giftCardGoodsSkus = req.getConfigs();
+		if (CollUtil.isEmpty(giftCardGoodsSkus)) {
+			throw BusinessRuntimeException.getInstance("请输入对应数据");
+		}
+		giftCardGoodsSkus.forEach(giftCardSku -> {
+			giftCardSku.setGoodsId(req.getGoodsId());
+			setOrUpdateGiftCardSku(giftCardSku);
+		});
+	}
+
+	/**
+	 * 设置对应礼品卡平台 最低价格
+	 */
+	@Override
+	public void setGiftCardGoodsStat(GoodsDon goodsDon) {
+		//设置对应礼品卡平台 最低价格
+		BigDecimal minPrice = goodsDon.getMinPrice();
+		GiftCardGoodsSku min = this.getOne(Wrappers.lambdaQuery(GiftCardGoodsSku.class)
+				.eq(GiftCardGoodsSku::getGoodsId, goodsDon.getId())
+				.eq(GiftCardGoodsSku::getStatus, true)
+				.eq(GiftCardGoodsSku::getDeleted, true)
+				.orderByAsc(GiftCardGoodsSku::getPrice).last("limit 1"));
+		if (min != null) {
+			if (minPrice == null || minPrice.compareTo(min.getPrice()) > 0) {
+				goodsDon.setMinPrice(min.getPrice());
+				goodsDonMapper.updateById(goodsDon);
+				Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+				redisService.del(keys.toArray(String[]::new));
+			}
+		}
+	}
+}

+ 47 - 0
netflix-service/src/main/java/com/cyksj/service/giftcard/impl/GiftCardOrderUseRecordServiceImpl.java

@@ -0,0 +1,47 @@
+package com.cyksj.service.giftcard.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cyksj.mapper.GiftCardOrderUseRecordMapper;
+import com.cyksj.mapper.GiftCardUserRecordMapper;
+import com.cyksj.model.entity.GiftCardOrderUseRecord;
+import com.cyksj.model.entity.GiftCardUserRecord;
+import com.cyksj.service.giftcard.GiftCardOrderUseRecordService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardOrderUseRecordServiceImpl
+ *创建者: JavaZou
+ *创建时间:2023/8/29 16:44
+ */
+@Service
+@RequiredArgsConstructor
+public class GiftCardOrderUseRecordServiceImpl extends ServiceImpl<GiftCardOrderUseRecordMapper, GiftCardOrderUseRecord> implements GiftCardOrderUseRecordService {
+	private final GiftCardUserRecordMapper giftCardUserRecordMapper;
+
+	@Override
+	public void returnGiftCardCash(Long orderId) {
+		List<GiftCardOrderUseRecord> useRecords = this.list(Wrappers.lambdaQuery(GiftCardOrderUseRecord.class)
+				.eq(GiftCardOrderUseRecord::getOrderId, orderId));
+		if (CollUtil.isNotEmpty(useRecords)) {
+			useRecords.forEach(data -> {
+				while (true) {
+					Long gcId = data.getGcId();
+					BigDecimal addCash = data.getCash();
+					GiftCardUserRecord giftCardUserRecord = giftCardUserRecordMapper.selectById(gcId);
+					BigDecimal remainCash = giftCardUserRecord.getRemainCash();
+					Integer update = giftCardUserRecordMapper.updateGiftCardRemainCash(gcId, addCash, remainCash);
+					if (update > 0) {
+						break;
+					}
+				}
+			});
+		}
+	}
+}

+ 17 - 0
netflix-service/src/main/java/com/cyksj/service/giftcard/impl/GiftCardUserRecordServiceImpl.java

@@ -0,0 +1,17 @@
+package com.cyksj.service.giftcard.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cyksj.mapper.GiftCardUserRecordMapper;
+import com.cyksj.model.entity.GiftCardUserRecord;
+import com.cyksj.service.giftcard.GiftCardUserRecordService;
+import org.springframework.stereotype.Service;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardUserRecordServiceImpl
+ *创建者: JavaZou
+ *创建时间:2023/8/30 10:55
+ */
+@Service
+public class GiftCardUserRecordServiceImpl extends ServiceImpl<GiftCardUserRecordMapper, GiftCardUserRecord> implements GiftCardUserRecordService {
+}

+ 31 - 3
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -43,6 +43,7 @@ import com.cyksj.model.request.OrderRefundReq;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.coupon.CouponFontService;
 import com.cyksj.service.distribute.equipment.EquipmentDistributeService;
+import com.cyksj.service.giftcard.GiftCardOrderUseRecordService;
 import com.cyksj.service.mange.CmsOrderDonService;
 import com.cyksj.service.mange.stock.GoodsDonStockService;
 import com.cyksj.service.market.MarketFrontService;
@@ -148,6 +149,10 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
 
     private final GroupsRelationExpiryRecordService groupsRelationExpiryRecordService;
 
+    private final GiftCardOrderUseRecordService giftCardOrderUseRecordService;
+
+    private final GiftCardUserRecordMapper giftCardUserRecordMapper;
+
     private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
 
     @Override
@@ -283,8 +288,11 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
     @Transactional(rollbackFor = Throwable.class)
     public void unifiedRefund(OrderRefundReq refundReq) throws Exception {
         OrderDon orderDon = orderDonMapper.selectById(refundReq.getOrderId());
-        GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
-        GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
+        GoodsDonSku sku = null;
+        if (orderDon.getSkuId() != null) {
+            sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
+        }
+        GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
         if (StrUtil.isEmpty(refundReq.getRefundType())) {
             refundReq.setRefundType("money");
         }
@@ -595,7 +603,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         if (OrderDon.Status.noPayment == orderDon.getStatus() || OrderDon.Status.close == orderDon.getStatus()) {
             throw BusinessRuntimeException.getInstance("订单{0}状态不支持退款", orderDon.getStatus());
         }
-        if (goodsDon.getType() == 1) {
+        if (goodsDon.getType() == 1 && sku != null) {
             //虚拟原订单是否已过期
             Integer months = sku.getMonths();
             Integer days = sku.getDays();
@@ -645,9 +653,23 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             }
             orderDon.setRefundMoney(refundMoney);
         }
+        //礼品卡是否已使用
+        GiftCardUserRecord giftCardUserRecord = null;
+        if (goodsDon.getSpecialType() != null && goodsDon.getSpecialType() == GoodsDon.SpecialType.giftCard) {
+            giftCardUserRecord = giftCardUserRecordMapper.selectOne(Wrappers.lambdaQuery(GiftCardUserRecord.class)
+                    .eq(GiftCardUserRecord::getOrderId, orderDon.getId()).last("limit 1"));
+            if (giftCardUserRecord != null && giftCardUserRecord.getIsUsed()) {
+                throw BusinessRuntimeException.getInstance("该礼品卡已使用无法退款");
+            }
+        }
         if (!redisService.setNx(String.format("%s", refundReq.getOrderId()), refundReq.getOrderId(), 10l)) {
             throw BusinessRuntimeException.getInstance("请勿重复点击,正在退款中..");
         }
+        //礼品卡购买状态
+        if (giftCardUserRecord != null) {
+            giftCardUserRecord.setIsPay(false);
+            giftCardUserRecordMapper.updateById(giftCardUserRecord);
+        }
     }
 
     /**
@@ -760,6 +782,12 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
                     groupsRelationExpiryRecordService.saveOrUpdate(groupsRelationExpiryRecord);
                 }
             });
+
+            //是否是礼品卡 现金支付订单
+            BigDecimal gcCash = orderDon.getGcCash();
+            if (gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0) {
+                giftCardOrderUseRecordService.returnGiftCardCash(orderDon.getId());
+            }
         });
     }
 

+ 21 - 20
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderCommonServiceImpl.java

@@ -44,7 +44,7 @@ public class OrderCommonServiceImpl implements OrderCommonService {
 
 	@Override
 	public void clearUnrealGoodsDetail(OrderDon orderDon, Integer goodsType, GoodsDonSku sku) {
-		if (goodsType == 1) {
+		if (goodsType == 1 && sku != null) {
 			//清出车队,车位变为已过期
 			Long relationId = orderDon.getRelationId();
 			//更换车票前后的座位id集合
@@ -70,34 +70,35 @@ public class OrderCommonServiceImpl implements OrderCommonService {
 			if (relation != null) {
 				Boolean isFlag = true;
 				Date expiryTime = relation.getExpiryTime();
+				OrderDon otherOrder = null;
 				if (orderDon.getOrderType() == 2 || relationIds.size() > 1) {
 					//是否有其他付款订单是否过期
-					OrderDon otherOrder = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
+					otherOrder = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
 							.in(OrderDon::getRelationId, relationIds)
 							.eq(OrderDon::getUserId, orderDon.getUserId())
 							.ne(OrderDon::getId, orderDon.getId())
 							.notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
 							.orderByDesc(OrderDon::getId)
 							.last("limit 1"));
-					if (otherOrder != null) {
-						Long otherSkuId = otherOrder.getSkuId();
-						GoodsDonSku otherGoodsSku = goodsDonSkuMapper.selectById(otherSkuId);
-						DateTime endTime = DateUtil.offsetMonth(otherOrder.getCreatedTime(), otherGoodsSku.getMonths() * num);
-						if (now.isBefore(endTime)) {
-							isFlag = false;
+				}
+				if (otherOrder != null) {
+					Long otherSkuId = otherOrder.getSkuId();
+					GoodsDonSku otherGoodsSku = goodsDonSkuMapper.selectById(otherSkuId);
+					DateTime endTime = DateUtil.offsetMonth(otherOrder.getCreatedTime(), otherGoodsSku.getMonths() * num);
+					if (now.isBefore(endTime)) {
+						isFlag = false;
+					}
+				} else {
+					//座位 过期时间
+					if (expiryTime != null) {
+						DateTime refundExpiryTime;
+						if (sku.getDays() != null && sku.getDays() > 0) {
+							refundExpiryTime = DateUtil.offsetDay(expiryTime, -sku.getDays() * num);
+						} else {
+							refundExpiryTime = DateUtil.offsetMonth(expiryTime, -sku.getMonths() * num);
 						}
-					} else {
-						//续费更换后的座位 过期时间
-						if (expiryTime != null) {
-							DateTime refundExpiryTime;
-							if (sku.getDays() != null && sku.getDays() > 0) {
-								refundExpiryTime = DateUtil.offsetDay(expiryTime, -sku.getDays() * num);
-							} else {
-								refundExpiryTime = DateUtil.offsetMonth(expiryTime, -sku.getMonths() * num);
-							}
-							if (now.isBefore(refundExpiryTime)) {
-								isFlag = false;
-							}
+						if (now.isBefore(refundExpiryTime)) {
+							isFlag = false;
 						}
 					}
 				}

Diferenças do arquivo suprimidas por serem muito extensas
+ 423 - 344
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java


+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/user/UserService.java

@@ -46,4 +46,9 @@ public interface UserService extends IService<User> {
 	User webLogin(LoginReq loginReq) throws Exception;
 
 	String bindWxAccountRedirect(String code, String state) throws Exception;
+
+	/**
+	 * 领取礼品卡
+	 */
+	void receiveGiftCardByRc(Long userId, String code, Long relationId);
 }

+ 120 - 2
netflix-service/src/main/java/com/cyksj/service/user/impl/UserServiceImpl.java

@@ -1,6 +1,7 @@
 package com.cyksj.service.user.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.RandomUtil;
@@ -15,26 +16,33 @@ import com.cyksj.common.util.Codec;
 import com.cyksj.common.util.Jsons;
 import com.cyksj.common.util.StringUtil;
 import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
-import com.cyksj.mapper.PhoneCodeMapper;
-import com.cyksj.mapper.UserMapper;
+import com.cyksj.mapper.*;
 import com.cyksj.mapper.channel.ChannelPopularizeMapper;
 import com.cyksj.mapper.manage.cps.UserDistributePopularizeMapper;
 import com.cyksj.mapper.market.task.UserBindDetailMapper;
 import com.cyksj.model.dto.*;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.request.LoginReq;
+import com.cyksj.model.views.RenewalView;
+import com.cyksj.model.views.UserTicketView;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.distribute.DistributeService;
 import com.cyksj.service.distribute.equipment.EquipmentDistributeService;
+import com.cyksj.service.exchange.ExchangeCodeService;
 import com.cyksj.service.mange.coupon.CouponCommonService;
 import com.cyksj.service.market.task.BindTaskService;
 import com.cyksj.service.sys.SysConfigService;
+import com.cyksj.service.user.UserBindRelationService;
 import com.cyksj.service.user.UserService;
 import com.cyksj.service.wechat.WeChatService;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.param.Operator;
+import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
 
 import java.util.ArrayList;
@@ -76,6 +84,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 
 	private final WxOpenPlatYHLXLoginConfig wxOpenPlatYHLXLoginConfig;
 
+	private final GiftCardUserRecordMapper giftCardUserRecordMapper;
+
+	private final ExchangeCodeService exchangeCodeService;
+
+	private final GoodsDonSkuMapper goodsDonSkuMapper;
+
+	private final GroupsRelationMapper groupsRelationMapper;
+
+	private final BeanSearcher beanSearcher;
+
+	private final UserBindRelationService userBindRelationService;
+
 	private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
 
 	@Override
@@ -514,6 +534,104 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		return redisService.getStr(re.getMappingId().toString());
 	}
 
+	@Override
+	@Transactional(rollbackFor = Throwable.class)
+	public void receiveGiftCardByRc(Long userId, String code, Long relationId) {
+		GiftCardUserRecord giftCardUserRecord = giftCardUserRecordMapper.selectOne(Wrappers.lambdaQuery(GiftCardUserRecord.class)
+				.eq(GiftCardUserRecord::getRc, code).last("limit 1"));
+		if (giftCardUserRecord == null) {
+			throw BusinessRuntimeException.getInstance("好友赠送礼品卡不存在");
+		}
+		if (!giftCardUserRecord.getIsPay()) {
+			throw BusinessRuntimeException.getInstance("无效礼品卡,好友未购买");
+		}
+		List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
+		if (relationUserIdList.contains(giftCardUserRecord.getUserId())) {
+			throw BusinessRuntimeException.getInstance("无法领取自己购买的礼品卡");
+		}
+		if (giftCardUserRecord.getToUserId() != 0 && !giftCardUserRecord.getToUserId().equals(userId)) {
+			throw BusinessRuntimeException.getInstance("好友赠送礼品卡已被领取");
+		}
+		if (giftCardUserRecord.getToUserId().equals(userId)) {
+			throw BusinessRuntimeException.getInstance("您已领取该礼品卡");
+		}
+		giftCardUserRecord.setToUserId(userId);
+		int update = giftCardUserRecordMapper.update(null, Wrappers.lambdaUpdate(GiftCardUserRecord.class)
+				.set(giftCardUserRecord.getGcType() == 2, GiftCardUserRecord::getIsUsed, true)
+				.set(GiftCardUserRecord::getToUserId, userId)
+				.set(GiftCardUserRecord::getIsSend, true)
+				.set(GiftCardUserRecord::getReceivedTime, DateTime.now())
+				.eq(GiftCardUserRecord::getId, giftCardUserRecord.getId())
+				.eq(GiftCardUserRecord::getIsPay, true)
+				.eq(GiftCardUserRecord::getToUserId, 0));
+		if (update > 0) {
+			//虚拟卡
+			//直接发送 对应规格车票
+			if (giftCardUserRecord.getGcType() == 2) {
+				Long gcSkuId = giftCardUserRecord.getGcSkuId();
+				log.info("用户userId:{}领取礼品卡id:{},开始发放虚拟车票skuId:{}", userId, giftCardUserRecord.getId(), gcSkuId);
+				GoodsDonSku sku = goodsDonSkuMapper.selectById(gcSkuId);
+				if (sku == null) {
+					log.info("礼品卡id:{}虚拟车票skuId:{}不存在", giftCardUserRecord.getId(), gcSkuId);
+					throw BusinessRuntimeException.getInstance("该礼品卡对应的虚拟卡不存在,请联系客服");
+				}
+				if (relationId != null) {
+					GroupsRelation groupsRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
+							.in(GroupsRelation::getUserId, relationUserIdList)
+							.eq(GroupsRelation::getId, relationId)
+							.in(GroupsRelation::getStatus, List.of(GroupsRelation.Status.validity, GroupsRelation.Status.outside)).last("limit 1"));
+					if (groupsRelation == null) {
+						throw BusinessRuntimeException.getInstance("您选择的车票不存在");
+					}
+					Date expiryTime = groupsRelation.getExpiryTime();
+					if (expiryTime == null) {
+						throw BusinessRuntimeException.getInstance("请等您该类型下的车票配置账号后再增加对应时长");
+					}
+					if (sku.getDays() != null && sku.getDays() > 0) {
+						expiryTime = DateUtil.offsetDay(expiryTime, sku.getDays());
+					} else {
+						expiryTime = DateUtil.offsetMonth(expiryTime, sku.getMonths());
+					}
+					log.info("userId:{}领取虚拟卡skuId:{},增加车票时长至:{}", userId, sku.getId(), expiryTime.toString());
+					groupsRelation.setExpiryTime(expiryTime);
+					groupsRelationMapper.updateById(groupsRelation);
+					return;
+				}
+				//是否存在对应车票
+				List<UserTicketView> ticketViews = beanSearcher.searchAll(UserTicketView.class, MapUtils.builder()
+						.field(UserTicketView::getUserId, relationUserIdList).op(Operator.InList)
+						.field(UserTicketView::getGoodsId, giftCardUserRecord.getGcGoodsId())
+						.field(RenewalView::getStatus, List.of("validity", "outside")).op(Operator.InList)
+						.orderBy(UserTicketView::getRelationId).asc()
+						.build());
+				if (CollUtil.isEmpty(ticketViews)) {
+					GroupsRelation relationNoOrder = exchangeCodeService.getRelationNoOrder(sku, userId);
+					giftCardUserRecordMapper.update(null, Wrappers.lambdaUpdate(GiftCardUserRecord.class)
+							.set(GiftCardUserRecord::getRelationId, relationNoOrder.getId())
+							.eq(GiftCardUserRecord::getId, giftCardUserRecord.getId()));
+					log.info("用户未有该规格:{}车票,发送至用户userId:{}礼品卡虚拟车票结束", gcSkuId, userId);
+					return;
+				}
+				if (ticketViews.size() > 1) {
+					throw BusinessRuntimeException.getInstance("您有多张该类型的车票,请选择一张增加时长");
+				}
+				UserTicketView userTicketView = ticketViews.get(0);
+				Date expiryTime = userTicketView.getExpiryTime();
+				if (expiryTime == null) {
+					throw BusinessRuntimeException.getInstance("请等您该类型下的车票配置账号后再增加对应时长");
+				}
+				if (sku.getDays() != null && sku.getDays() > 0) {
+					expiryTime = DateUtil.offsetDay(expiryTime, sku.getDays());
+				} else {
+					expiryTime = DateUtil.offsetMonth(expiryTime, sku.getMonths());
+				}
+				groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
+						.set(GroupsRelation::getExpiryTime, expiryTime)
+						.eq(GroupsRelation::getId, userTicketView.getRelationId()));
+			}
+		}
+	}
+
 	/**
 	 * 发放新用户福利
 	 */

+ 20 - 7
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -31,8 +31,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.math.BigDecimal;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * @author chan
@@ -76,7 +79,7 @@ public class GoodsDonController {
                     .orderByAsc(GoodsDonSku::getPrice)
                     .last("limit 1")
                     .select(GoodsDonSku::getPrice));
-            Optional.ofNullable(goodsDonSku).ifPresent(sku->{
+            Optional.ofNullable(goodsDonSku).ifPresent(sku -> {
                 goods.setPrice(goodsDonSku.getPrice());
                 goods.setSoldNum(goods.getVirtualSold() + orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
                         .eq(OrderDon::getGoodsId, goods.getId())
@@ -266,12 +269,12 @@ public class GoodsDonController {
         }
         MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
         List<RegisterGoodsDonView> dataList = beanSearcher.searchAll(RegisterGoodsDonView.class, builder.build());
-	    DateTime now = DateTime.now();
-	    dataList.forEach(data->{
+        DateTime now = DateTime.now();
+        dataList.forEach(data -> {
             Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
                     .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
             data.setSold(sold + data.getVirtualSold());
-		    data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2));
+            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2));
         });
         redisService.setNx(registerCacheKey, dataList, RedisService.key.REGISTER_HOME_PAGE_CACHE.getTimeout());
         return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
@@ -282,7 +285,7 @@ public class GoodsDonController {
      * 获取商品详情
      */
     @GetMapping("/get/{id}")
-    public Result<GoodsDonViews> getDetail(@PathVariable Long id) {
+    public Result<GoodsDonViews> getDetail(@PathVariable Long id) throws Exception {
         Long fUid = StpUserUtil.getUserIdAfterLogin();
         GoodsDonViews views = beanSearcher.searchFirst(GoodsDonViews.class, MapUtils.builder().field(GoodsDonViews::getId, id).build());
 
@@ -377,6 +380,16 @@ public class GoodsDonController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(search);
     }
 
+    /**
+     * 获取礼品卡平台性情
+     */
+    @GetMapping("/get/card/{id}")
+    public Result<Map<Integer, List<GiftCardGoodsSkuFrontView>>> getGiftCardDetail(@PathVariable Long id) {
+        List<GiftCardGoodsSkuFrontView> giftCardGoodsSkuFrontViews = beanSearcher.searchAll(GiftCardGoodsSkuFrontView.class, MapUtils.builder().field(GiftCardGoodsSkuFrontView::getGoodsId, id).build());
+        Map<Integer, List<GiftCardGoodsSkuFrontView>> map = giftCardGoodsSkuFrontViews.stream().collect(Collectors.groupingBy(GiftCardGoodsSkuFrontView::getGcType));
+        return GatewayResponse.SUCCESS.newBuilder().toResult(map);
+    }
+
     public List<Long> getFilterGoodsIds() {
         //过滤杭州Ai ChatGPT平台
         //获取当前ip地址

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

@@ -170,9 +170,9 @@ public class GroupRelationController {
     public Result<List<UserTicketView>> getUserTicketView() {
         long userId = StpUserUtil.getLoginIdAsLong();
         List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
-        List<UserTicketView> ticketViews = beanSearcher.searchAll(UserTicketView.class, MapUtils.builder()
+        List<UserTicketView> ticketViews = beanSearcher.searchAll(UserTicketView.class, MapUtils.flatBuilder(request.getParameterMap())
                 .field(UserTicketView::getUserId, userIds).op(Operator.InList)
-                .field(RenewalView::getStatus, List.of("validity", "overdue", "outside")).op(Operator.InList)
+                .field(RenewalView::getStatus, List.of("validity", "outside")).op(Operator.InList)
                 .orderBy(UserTicketView::getRelationId).asc()
                 .build());
         return GatewayResponse.SUCCESS.newBuilder().toResult(ticketViews);

+ 14 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonController.java

@@ -52,6 +52,7 @@ public class CmsGoodsDonController {
     public Result<SearchResult<GoodsDon>> get(){
         SearchResult<GoodsDon> search = beanSearcher.search(GoodsDon.class, MapUtils.flatBuilder(request.getParameterMap())
                 .field(GoodsDon::getDeleted,true)
+                .put("condition", "(special_type is null or special_type != 'giftCard')")
                 .build());
         return GatewayResponse.SUCCESS.newBuilder().toResult(search);
     }
@@ -179,8 +180,20 @@ public class CmsGoodsDonController {
     @GetMapping("/get/all")
     public Result<List<GoodsDon>> getAllGoodsList() {
         List<GoodsDon> goodsDons = beanSearcher.searchAll(GoodsDon.class, MapUtils.flatBuilder(request.getParameterMap())
-                .field(GoodsDon::getDeleted,true)
+                .field(GoodsDon::getDeleted, true)
+                .put("condition", "(special_type is null or special_type != 'giftCard')")
                 .onlySelect(GoodsDon::getId, GoodsDon::getCategory, GoodsDon::getType, GoodsDon::getTitle).build());
         return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDons);
     }
+
+    /**
+     * 获取礼品卡平台
+     */
+    @GetMapping("/get/giftCard")
+    public Result<GoodsDon> getGiftCard() {
+        GoodsDon goodsDon = beanSearcher.searchFirst(GoodsDon.class, MapUtils.builder()
+                .field(GoodsDon::getSpecialType, GoodsDon.SpecialType.giftCard.name())
+                .build());
+        return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDon);
+    }
 }

+ 120 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/GiftCardController.java

@@ -0,0 +1,120 @@
+package com.cyksj.web.controller.manage.goods;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.dto.Result;
+import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.GoodsDonMapper;
+import com.cyksj.model.entity.GiftCardGoodsSku;
+import com.cyksj.model.request.GiftCardGoodsSkuReq;
+import com.cyksj.model.views.GiftCardGoodsSkuView;
+import com.cyksj.model.views.GiftCardUserPayView;
+import com.cyksj.service.giftcard.GiftCardGoodsSkuService;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.SearchResult;
+import com.ejlchina.searcher.util.MapUtils;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+/*
+ *项目名: netflix
+ *文件名: GiftCardController
+ *创建者: JavaZou
+ *创建时间:2023/8/29 18:15
+ */
+@RequestMapping("/manage/giftCard")
+@RestController
+@RequiredArgsConstructor
+public class GiftCardController {
+	private final GiftCardGoodsSkuService giftCardGoodsSkuService;
+
+	private final BeanSearcher beanSearcher;
+
+	private final HttpServletRequest request;
+
+	private final GoodsDonMapper goodsDonMapper;
+
+	/**
+	 * 设置礼品卡 规格
+	 */
+	@PostMapping("/set")
+	public Result<String> setGiftCardSku(@RequestBody GiftCardGoodsSkuReq req) {
+		giftCardGoodsSkuService.setGiftCardSku(req);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 修改礼品卡 规格
+	 */
+	@PutMapping("/put")
+	public Result<String> updateGiftCardSku(@RequestBody GiftCardGoodsSku giftCardSku) {
+		if (giftCardSku.getId() == null) {
+			throw BusinessRuntimeException.getInstance("请指定要修改的礼品卡");
+		}
+		giftCardGoodsSkuService.setOrUpdateGiftCardSku(giftCardSku);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 获取礼品卡规格 配置
+	 */
+	@GetMapping("/get")
+	public Result<SearchResult<GiftCardGoodsSkuView>> getGiftCardGoodsSku() {
+		SearchResult<GiftCardGoodsSkuView> list = beanSearcher.search(GiftCardGoodsSkuView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(list);
+	}
+
+	/**
+	 * 礼品卡用户购买成功 记录
+	 */
+	@GetMapping("/get/pay")
+	public Result<SearchResult<GiftCardUserPayView>> getGiftCardPayRecord() {
+		SearchResult<GiftCardUserPayView> search = beanSearcher.search(GiftCardUserPayView.class, MapUtils.flatBuilder(request.getParameterMap())
+				.field(GiftCardUserPayView::getIsPay, true)
+				.build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+	}
+
+	/**
+	 * 礼品卡上下架
+	 */
+	@PutMapping("/update/status/{id}")
+	public Result<String> updateStatusById(@PathVariable Long id) {
+		GiftCardGoodsSku byId = giftCardGoodsSkuService.getById(id);
+		if (byId == null) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
+		}
+		if (!byId.getStatus()) {
+			//校验礼品卡已上架多少个 最多上架三个
+			int count = giftCardGoodsSkuService.count(Wrappers.lambdaQuery(GiftCardGoodsSku.class)
+					.eq(GiftCardGoodsSku::getStatus, true)
+					.eq(GiftCardGoodsSku::getDeleted, true)
+					.eq(GiftCardGoodsSku::getGcType, byId.getGcType()));
+			if (count > 2) {
+				throw BusinessRuntimeException.getInstance(String.format("%s最多上架三个", byId.getGcType() == 1 ? "现金卡" : "虚拟卡"));
+			}
+		}
+		byId.setStatus(!byId.getStatus());
+		giftCardGoodsSkuService.updateById(byId);
+		//设置对应礼品卡平台 最低价格
+		giftCardGoodsSkuService.setGiftCardGoodsStat(goodsDonMapper.selectById(byId.getGoodsId()));
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 删除礼品卡
+	 */
+	@DeleteMapping("/del/{id}")
+	public Result<String> delById(@PathVariable Long id) {
+		GiftCardGoodsSku byId = giftCardGoodsSkuService.getById(id);
+		if (byId == null) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
+		}
+		byId.setDeleted(false);
+		giftCardGoodsSkuService.updateById(byId);
+		giftCardGoodsSkuService.setGiftCardGoodsStat(goodsDonMapper.selectById(byId.getGoodsId()));
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+}

+ 1 - 7
netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderController.java

@@ -15,7 +15,6 @@ import com.cyksj.config.zfb.ZfbProductCode;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayApiCode;
 import com.cyksj.enums.GatewayResponse;
-import com.cyksj.mapper.OrderDonMapper;
 import com.cyksj.mapper.OrderDonWaybillMapper;
 import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.channel.UserPayEquipmentAvailableBenefitsMapper;
@@ -87,9 +86,6 @@ public class OrderController {
     @Resource
     private HttpServletResponse response;
 
-    @Autowired
-    private OrderDonMapper orderDonMapper;
-
     @Autowired
     private UserBindDetailMapper userBindDetailMapper;
 
@@ -128,9 +124,7 @@ public class OrderController {
     @PostMapping("/post/submit")
     public Result<OrderDon> submit(@Validated @RequestBody OrderPayRequest payRequest) throws Exception {
         final String methodName = "吊起微信支付";
-        if (payRequest.getIsNoLogin() == null || !payRequest.getIsNoLogin()) {
-            payRequest.setUserId(StpUserUtil.getLoginIdAsLong());
-        }
+        payRequest.setUserId(StpUserUtil.getUserIdAfterLogin());
         log.info("{}[start] params:{}",methodName,payRequest);
 
         OrderDon orderDon = orderDonService.submit(payRequest);

+ 24 - 0
netflix-web/src/main/java/com/cyksj/web/controller/user/AuthorizationController.java

@@ -218,6 +218,30 @@ public class AuthorizationController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(wxAuthUrl);
     }
 
+    /**
+     * 不同域名跳转 微信授权登录
+     */
+    @GetMapping("/do/wx/authLogin/")
+    public Result<String> doWxAuthorize(Long sharedId, Integer dsType, Long popularizeId, String dsCode, String type, String loginUrl, String callbackType, String callback) throws Exception {
+        Long mappingId = SEQUENCE.nextId();
+        if (StrUtil.isEmpty(loginUrl)) {
+            loginUrl = wxOpenPlatYHLXLoginConfig.getLoginUrl();
+        }
+        if (StrUtil.isNotBlank(type)) {
+            loginUrl = String.format("https://nf.video/%s/web", type);
+        }
+        redisService.set(mappingId.toString(), loginUrl, 60 * 60 * 24L);
+        if (StrUtil.isNotBlank(dsCode)) {
+            dsCode = dsCode.trim();
+        }
+        AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setDsCode(dsCode)
+                .setCk(callback)
+                .setCt(callbackType);
+        String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
+        String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getRedirectUri());
+        return GatewayResponse.SUCCESS.newBuilder().toResult(wxAuthUrl);
+    }
+
     /**
      * 网页微信授权后跳转
      */

+ 60 - 4
netflix-web/src/main/java/com/cyksj/web/controller/user/UserController.java

@@ -13,10 +13,7 @@ import com.cyksj.mapper.manage.coupon.CouponUserMapper;
 import com.cyksj.model.dto.UserWhoami;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.views.GroupsRelationView;
-import com.cyksj.model.request.ExchangeCodeTicket;
-import com.cyksj.model.request.ReceiveBenefitsReq;
-import com.cyksj.model.request.UserReq;
-import com.cyksj.model.request.WorkOrderReq;
+import com.cyksj.model.request.*;
 import com.cyksj.model.response.UserAuthLoginResp;
 import com.cyksj.model.views.*;
 import com.cyksj.service.corp.CropChatService;
@@ -118,6 +115,12 @@ public class UserController {
                 .eq(OrderDon::getUserId, userId)
                 .eq(OrderDon::getStatus, OrderDon.Status.noPayment).last("limit 1"));
         personalView.setIsNoPayment(orderDon != null ? true : false);
+        //礼品卡可用数量
+        Number numOfGiftCard = beanSearcher.searchCount(GiftCardUserRecordView.class, MapUtils.builder()
+                .put("uid", String.format("((user_id = %s and is_send = 0) or (to_user_id = %s and is_used = 0))", userId, userId))
+                .field(GiftCardUserRecordView::getIsPay, true)
+                .build());
+        personalView.setNumOfGiftCard(numOfGiftCard.intValue());
         return GatewayResponse.SUCCESS.newBuilder().toResult(personalView);
     }
 
@@ -338,4 +341,57 @@ public class UserController {
         UserAuthLoginResp loginPhoneRep = new UserAuthLoginResp(StpUserUtil.getTokenValue(), switch_user.getShowId(), switch_user.getNickname(), switch_user.getHeadimgurl());
         return GatewayResponse.SUCCESS.newBuilder().toResult(loginPhoneRep);
     }
+
+    /**
+     * 个人礼品卡列表
+     * @return
+     */
+    @GetMapping("/get/giftCard")
+    public Result<SearchResult<GiftCardUserPayFrontView>> getGiftCard() {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        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);
+    }
+
+    /**
+     * 可用现金礼品卡列表
+     */
+    @GetMapping("/get/available/giftCard")
+    public Result<List<GiftCardUserPayFrontView>> getAvailGiftCard() {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        String condition = String.format("and to_user_id = %s", userId);
+        List<GiftCardUserPayFrontView> view = beanSearcher.searchAll(GiftCardUserPayFrontView.class, MapUtils.builder()
+                .put("condition", condition)
+                .put("uid", userId)
+                //现金卡
+                .field(GiftCardUserPayFrontView::getGcType, 1)
+                .orderBy(GiftCardUserRecordView::getIsUsed).asc()
+                .orderBy(GiftCardUserPayFrontView::getId).desc().build());
+        return GatewayResponse.SUCCESS.newBuilder().toResult(view);
+    }
+
+    /**
+     * 礼品卡分享详情
+     */
+    @GetMapping("/get/giftCard/detail/{code}")
+    public Result<GiftCardDetailFrontView> getGiftCardDetailByCode(@PathVariable String code) {
+        GiftCardDetailFrontView detail = beanSearcher.searchFirst(GiftCardDetailFrontView.class, MapUtils.builder().field(GiftCardDetailFrontView::getCode, code).build());
+        return GatewayResponse.SUCCESS.newBuilder().toResult(detail);
+    }
+
+    /**
+     * 领取他人礼品卡
+     */
+    @PostMapping("/receive/giftCard")
+    public Result<String> receiveGiftCardByRc(@RequestBody GiftCardReceiveReq req) {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        Long relationId = req.getRelationId();
+        userService.receiveGiftCardByRc(userId, req.getCode(), relationId);
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
 }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff