Răsfoiți Sursa

Merge branch 'gift_card_opt_func'

# Conflicts:
#	netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java
zoujiajian 1 an în urmă
părinte
comite
29ec7c19d1

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

@@ -19,7 +19,7 @@ public class GiftCardGoodsSku extends BaseEntity{
 	private Long goodsId;
 
 	/**
-	 * 礼品卡类型 1现金卡、2虚拟卡
+	 * 礼品卡类型 1现金卡、2AI 3.流媒体
 	 */
 	private Integer gcType;
 

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

@@ -20,7 +20,7 @@ public class GiftCardUserRecord extends BaseEntity{
 	private Long orderId;
 
 	/**
-	 * 礼品卡类型
+	 * 礼品卡类型 1现金卡、2AI 3.流媒体
 	 */
 	private Integer gcType;
 

+ 1 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/HomeManagementConfig.java

@@ -84,6 +84,7 @@ public class HomeManagementConfig extends BaseEntity{
 		h5("h5首页"),
 		pcSec("pc首页副"),
 		pcDis("pc发现首页"),
+		h5Sec("h5副广告"),
 		;
 		String desc;
 

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

@@ -21,7 +21,7 @@ public class GiftCardGoodsSkuReq {
 	private Long goodsId;
 
 	/**
-	 * 礼品卡类型 1现金卡、2虚拟卡
+	 * 礼品卡类型 1现金卡、2.AI 3.流媒体
 	 */
 	private Integer gcType;
 

+ 10 - 2
netflix-dao/src/main/java/com/cyksj/model/views/GiftCardUserPayFrontView.java

@@ -18,7 +18,9 @@ import java.util.Date;
 @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")
+		" left join user u2 on u2.id = gr.to_user_id" +
+		" left join goods_don g on gr.gc_goods_id = g.id" +
+		" left join goods_don_sku sku on sku.id = gr.gc_sku_id")
 public class GiftCardUserPayFrontView {
 	@DbField("gr.id")
 	private Long id;
@@ -41,9 +43,15 @@ public class GiftCardUserPayFrontView {
 	@DbField("gr.gc_goods_id")
 	private Long gcGoodsId;
 
+	@DbField("g.title")
+	private String gcTitle;
+
 	@DbField("gr.gc_sku_id")
 	private Long gcSkuId;
 
+	@DbField("sku.spec_val")
+	private String gcSpecVal;
+
 	@DbField("gr.remain_cash")
 	private BigDecimal remainCash;
 
@@ -71,7 +79,7 @@ public class GiftCardUserPayFrontView {
 	@DbField("gr.img")
 	private String gcImg;
 
-	@DbField("if(user_id = :uid:,1,2)")
+	@DbField("if(user_id in :uid:,1,2)")
 	private Integer type;
 
 	@DbField("u2.nickname")

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

@@ -166,4 +166,10 @@ public class GoodsFrontListView {
 
 	@DbIgnore
 	private List<GoodsDonQaFrontView> questions;
+
+	/**
+	 * 是否是礼品卡平台
+	 */
+	@DbIgnore
+	private Boolean isGift = false;
 }

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

@@ -76,13 +76,12 @@ public class GiftCardGoodsSkuServiceImpl extends ServiceImpl<GiftCardGoodsSkuMap
 			if (!sku.getStatus()) {
 				throw BusinessRuntimeException.getInstance("存在下架的虚拟卡规格,请重新选择");
 			}
-			gcType = 2;
 			data.setGcGoodsId(sku.getGoodsId());
 		}
 		data.setGcType(gcType);
-		if (gcType == 2 && data.getId() == null) {
+		if (gcType != 1 && data.getId() == null) {
 			GiftCardGoodsSku one = this.getOne(Wrappers.lambdaQuery(GiftCardGoodsSku.class)
-					.eq(GiftCardGoodsSku::getGcSkuId, gcSkuId).last("limit 1"));
+					.eq(GiftCardGoodsSku::getGcSkuId, gcSkuId).eq(GiftCardGoodsSku::getDeleted, 1).last("limit 1"));
 			if (one != null) {
 				return;
 			}
@@ -98,6 +97,7 @@ public class GiftCardGoodsSkuServiceImpl extends ServiceImpl<GiftCardGoodsSkuMap
 		}
 		giftCardGoodsSkus.forEach(giftCardSku -> {
 			giftCardSku.setGoodsId(req.getGoodsId());
+			giftCardSku.setGcType(req.getGcType());
 			setOrUpdateGiftCardSku(giftCardSku);
 		});
 	}

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

@@ -947,9 +947,10 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         //礼品卡是否已使用
         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()) {
+            Integer count = giftCardUserRecordMapper.selectCount(Wrappers.lambdaQuery(GiftCardUserRecord.class)
+                    .eq(GiftCardUserRecord::getIsUsed, 1)
+                    .eq(GiftCardUserRecord::getOrderId, orderDon.getId()));
+            if (count > 0) {
                 throw BusinessRuntimeException.getInstance("该礼品卡已使用无法退款");
             }
         }
@@ -1111,6 +1112,12 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             if (gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0) {
                 giftCardOrderUseRecordService.returnGiftCardCash(orderDon.getId());
             }
+            //清除礼品卡
+            if (goodsDon.getSpecialType() != null && goodsDon.getSpecialType() == GoodsDon.SpecialType.giftCard) {
+                giftCardUserRecordMapper.update(null, Wrappers.lambdaUpdate(GiftCardUserRecord.class)
+                        .set(GiftCardUserRecord::getIsPay, 0)
+                        .eq(GiftCardUserRecord::getOrderId, orderDon.getId()));
+            }
             //是否是GPT镜像规格
             if (orderDon.getOrderType() == 1) {
                 mirrorUserCleatService.delMirrorUser(orderDon.getGoodsId(), orderDon.getRelationId());

+ 7 - 5
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -2318,12 +2318,13 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	 * 使用优惠营销 订单金额抵扣
 	 */
 	public void deductOrderMoney(OrderDon orderDon, CouponUser couponUser, BigDecimal balance, User user, BigDecimal skuMoney, Integer goodsType, BigDecimal gcCash, List<Long> gcpIds, Boolean isAcReduce, Long subsidyId) throws Exception {
-		if (gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0 && couponUser != null) {
+		if (gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0 && couponUser != null && (balance != null && balance.compareTo(BigDecimal.ZERO) > 0)) {
 			throw BusinessRuntimeException.getInstance("现金卡不能与其他优惠叠加使用");
 		}
 		BigDecimal first_money = orderDon.getMoney();
 		//礼品卡现金支付 不参与其他优惠
 		if (subsidyId == null && gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0) {
+			List<Long> userIdList = userBindRelationService.getRelationUserIdList(user.getId(), user);
 			if (CollUtil.isEmpty(gcpIds)) {
 				throw BusinessRuntimeException.getInstance("礼品卡现金支付参数异常");
 			}
@@ -2332,7 +2333,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				gcCash = money;
 			}
 			List<GiftCardUserRecord> availableGiftCards = giftCardUserRecordService.list(Wrappers.lambdaQuery(GiftCardUserRecord.class)
-					.eq(GiftCardUserRecord::getToUserId, user.getId())
+					.in(GiftCardUserRecord::getToUserId, userIdList)
 					.in(GiftCardUserRecord::getId, gcpIds)
 					.eq(GiftCardUserRecord::getIsPay, true)
 					.eq(GiftCardUserRecord::getGcType, 1)
@@ -3385,7 +3386,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	 */
 	public void setOrderDonPayTile(AtomicBoolean isGiftCardPay, GiftCardDto gcPayInfo, List<GiftCardPayReq> giftCards, OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku, List<Long> dpSkuIds) {
 		StringBuilder payTitle = new StringBuilder();
-		payTitle.append(goodsDon.getTitle());
+		if (!isGiftCardPay.get()) {
+			payTitle.append(goodsDon.getTitle());
+		}
 		if (sku != null) {
 			payTitle.append(sku.getSpecVal());
 		}
@@ -3405,7 +3408,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			if (giftCardViews.size() != giftCards.size()) {
 				throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重试");
 			}
-			payTitle.append("购买详情:");
 			BigDecimal gift_card_pay_money = BigDecimal.ZERO;
 			for (GiftCardGoodsSkuFrontView data : giftCardViews) {
 				//礼品卡数量
@@ -3416,7 +3418,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				gift_card_pay_money = gift_card_pay_money.add(data.getPrice().multiply(BigDecimal.valueOf(num)));
 
 				//礼品卡关系
-				if (!payTitle.toString().endsWith("购买详情:")) {
+				if (payTitle.length() > 0) {
 					payTitle.append(" + ");
 				}
 				String gcDetail;

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

@@ -591,7 +591,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		}
 		giftCardUserRecord.setToUserId(userId);
 		int update = giftCardUserRecordMapper.update(null, Wrappers.lambdaUpdate(GiftCardUserRecord.class)
-				.set(giftCardUserRecord.getGcType() == 2, GiftCardUserRecord::getIsUsed, true)
+				.set(giftCardUserRecord.getGcType() != 1, GiftCardUserRecord::getIsUsed, true)
 				.set(GiftCardUserRecord::getToUserId, userId)
 				.set(GiftCardUserRecord::getIsSend, true)
 				.set(GiftCardUserRecord::getReceivedTime, DateTime.now())
@@ -601,7 +601,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		if (update > 0) {
 			//虚拟卡
 			//直接发送 对应规格车票
-			if (giftCardUserRecord.getGcType() == 2) {
+			if (giftCardUserRecord.getGcType() != 1) {
 				Long gcSkuId = giftCardUserRecord.getGcSkuId();
 				log.info("用户userId:{}领取礼品卡id:{},开始发放虚拟车票skuId:{}", userId, giftCardUserRecord.getId(), gcSkuId);
 				GoodsDonSku sku = goodsDonSkuMapper.selectById(gcSkuId);
@@ -634,7 +634,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 				//是否存在对应车票
 				List<UserTicketView> ticketViews = beanSearcher.searchAll(UserTicketView.class, MapUtils.builder()
 						.field(UserTicketView::getUserId, relationUserIdList).op(Operator.InList)
-						.field(UserTicketView::getGoodsId, giftCardUserRecord.getGcGoodsId())
+						.field(UserTicketView::getSkuId, giftCardUserRecord.getGcSkuId())
 						.field(RenewalView::getStatus, List.of("validity", "outside")).op(Operator.InList)
 						.orderBy(UserTicketView::getRelationId).asc()
 						.build());

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

@@ -15,6 +15,7 @@ import com.cyksj.common.util.StringUtil;
 import com.cyksj.dto.Result;
 import com.cyksj.dto.UserSharedDto;
 import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.GiftCardGoodsSkuMapper;
 import com.cyksj.mapper.GoodsDonSkuMapper;
 import com.cyksj.mapper.OrderDonMapper;
 import com.cyksj.mapper.RegisterOrderDonMapper;
@@ -87,6 +88,8 @@ public class GoodsDonController {
 
 	private final UserBindRelationService userBindRelationService;
 
+	private final GiftCardGoodsSkuMapper giftCardGoodsSkuMapper;
+
 	/**
      * 获取平台商品分类
      */
@@ -380,6 +383,10 @@ public class GoodsDonController {
 			UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
 			dsUserId.set(userSharedDto.getSharedId());
 		}
+		views.setIsGift(giftCardGoodsSkuMapper.selectCount(Wrappers.lambdaQuery(GiftCardGoodsSku.class)
+				.eq(GiftCardGoodsSku::getGcGoodsId, views.getId())
+				.eq(GiftCardGoodsSku::getStatus, 1)
+				.eq(GiftCardGoodsSku::getDeleted, 1)) > 0);
 		views.setSkuList(views.getSkuList().stream().filter(sku -> {
 			if (StrUtil.isNotBlank(sku.getUserOwns())) {
 				if (dsUserId.get() == 0 && fUid != null && existsChannel.get()) {

+ 10 - 11
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/GiftCardController.java

@@ -1,6 +1,5 @@
 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;
@@ -86,16 +85,16 @@ public class GiftCardController {
 		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 ? "现金卡" : "虚拟卡"));
-			}
-		}
+//		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);
 		//设置对应礼品卡平台 最低价格

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

@@ -123,11 +123,12 @@ public class UserController {
     @GetMapping("/personal")
     public Result<UserPersonalView> getPersonalView(String customId) {
         long userId = StpUserUtil.getLoginIdAsLong();
-        List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
+        List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+        String userIds = userIdList.toString().replace("[", "(").replace("]", ")");
         MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
         List<RenewalView> renewalViews = beanSearcher.searchAll(RenewalView.class, builder
                 .field(RenewalView::getUserId, 0).op(Operator.GreaterThan)
-                .field(RenewalView::getUserId, userIds).op(Operator.InList)
+                .field(RenewalView::getUserId, userIdList).op(Operator.InList)
                 .field(RenewalView::getStatus, List.of("validity", "overdue", "outside")).op(Operator.InList)
                 .orderBy(RenewalView::getExpiryTime).asc()
                 .onlySelect(RenewalView::getExpiryTime)
@@ -161,7 +162,7 @@ public class UserController {
         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))
+                .put("uid", String.format("((user_id in %s and is_send = 0) or (to_user_id in %s and is_used = 0))", userIds, userIds))
                 .field(GiftCardUserRecordView::getIsPay, true)
                 .build());
         personalView.setNumOfGiftCard(numOfGiftCard.intValue());
@@ -396,10 +397,12 @@ public class UserController {
     @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()
+        List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+        String userIds = userIdList.toString().replace("[", "(").replace("]", ")");
+        String condition = String.format("and (user_id in %s or to_user_id in %s)", userIds, userIds);
+        SearchResult<GiftCardUserPayFrontView> view = beanSearcher.search(GiftCardUserPayFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
                 .put("condition", condition)
-                .put("uid", userId)
+                .put("uid", userIds)
                 .orderBy(GiftCardUserRecordView::getIsUsed).asc()
                 .orderBy(GiftCardUserPayFrontView::getId).desc().build());
         return GatewayResponse.SUCCESS.newBuilder().toResult(view);
@@ -411,10 +414,12 @@ public class UserController {
     @GetMapping("/get/available/giftCard")
     public Result<List<GiftCardUserPayFrontView>> getAvailGiftCard() {
         long userId = StpUserUtil.getLoginIdAsLong();
-        String condition = String.format("and to_user_id = %s", userId);
+        List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+        String userIds = userIdList.toString().replace("[", "(").replace("]", ")");
+        String condition = String.format("and to_user_id in %s", userIds);
         List<GiftCardUserPayFrontView> view = beanSearcher.searchAll(GiftCardUserPayFrontView.class, MapUtils.builder()
                 .put("condition", condition)
-                .put("uid", userId)
+                .put("uid", userIds)
                 //现金卡
                 .field(GiftCardUserPayFrontView::getGcType, 1)
                 .orderBy(GiftCardUserRecordView::getIsUsed).asc()