licailing 3 lat temu
rodzic
commit
0d1125b4e3

+ 3 - 12
src/main/java/com/izouma/nineth/domain/Asset.java

@@ -161,14 +161,8 @@ public class Asset extends BaseEntity {
     @ApiModelProperty("持有几天")
     private Integer holdDays;
 
-//    @ApiModelProperty("展厅头部背景")
-//    private String headBg;
-//
-//    @ApiModelProperty("展厅背景")
-//    private String showroomBg;
-//
-//    @ApiModelProperty("最多可放藏品数量")
-//    private Integer maxCollection;
+//    @ApiModelProperty("vip权利")
+//    private Boolean vip;
 
     @Transient
     private boolean opened = true;
@@ -197,13 +191,10 @@ public class Asset extends BaseEntity {
                 .ownerAvatar(user.getAvatar())
                 .type(collection.getType())
                 .holdDays(collection.getHoldDays())
-//                .headBg(collection.getHeadBg())
-//                .maxCollection(collection.getMaxCollection())
-//                .showroomBg(collection.getShowroomBg())
                 .build();
     }
 
-    public static Asset create(BlindBoxItem item, User user,Integer holdDays) {
+    public static Asset create(BlindBoxItem item, User user, Integer holdDays) {
         return Asset.builder()
                 .userId(user.getId())
                 .collectionId(item.getCollectionId())

+ 3 - 1
src/main/java/com/izouma/nineth/domain/CollectionPrivilege.java

@@ -9,6 +9,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.springframework.beans.BeanUtils;
 
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Index;
 import javax.persistence.Table;
@@ -34,8 +35,9 @@ public class CollectionPrivilege extends BaseEntity {
     @ApiModelProperty("最多可放藏品数量")
     private Integer maxCollection;
 
+    @Column(columnDefinition = "bit default false")
     @ApiModelProperty("vip特权")
-    private Boolean vip;
+    private boolean vip;
 
     public CollectionPrivilege(CollectionInfoDTO info, Long collectionId) {
         BeanUtils.copyProperties(info, this);

+ 5 - 0
src/main/java/com/izouma/nineth/repo/UserRepo.java

@@ -210,4 +210,9 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
     @Transactional
     void updateShowroomToUser(Long userId);
 
+    @Modifying
+    @Transactional
+    @Query("update User set vipPurchase = ?2 where id = ?1")
+    void updateVipPurchase(Long id, int vipPurchase);
+
 }

+ 35 - 15
src/main/java/com/izouma/nineth/service/AirDropService.java

@@ -10,6 +10,7 @@ import com.izouma.nineth.repo.*;
 import com.izouma.nineth.utils.JpaUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
@@ -22,16 +23,17 @@ import java.util.List;
 @Slf4j
 public class AirDropService {
 
-    private AirDropRepo       airDropRepo;
-    private CouponRepo        couponRepo;
-    private UserCouponRepo    userCouponRepo;
-    private CollectionRepo    collectionRepo;
-    private UserRepo          userRepo;
-    private AssetService      assetService;
-    private CollectionService collectionService;
-    private ShowroomService   showroomService;
-    private TokenHistoryRepo  tokenHistoryRepo;
-    private AssetRepo         assetRepo;
+    private AirDropRepo             airDropRepo;
+    private CouponRepo              couponRepo;
+    private UserCouponRepo          userCouponRepo;
+    private CollectionRepo          collectionRepo;
+    private UserRepo                userRepo;
+    private AssetService            assetService;
+    private CollectionService       collectionService;
+    private ShowroomService         showroomService;
+    private TokenHistoryRepo        tokenHistoryRepo;
+    private AssetRepo               assetRepo;
+    private CollectionPrivilegeRepo collectionPrivilegeRepo;
 
     public Page<AirDrop> all(PageQuery pageQuery) {
         return airDropRepo.findAll(JpaUtils.toSpecification(pageQuery, AirDrop.class), JpaUtils.toPageRequest(pageQuery));
@@ -67,6 +69,14 @@ public class AirDropService {
                                     winItem.getTotal() > 1 ? collectionService.getNextNumber(winItem.getCollectionId()) : null,
                                     collection.getHoldDays());
                         } else {
+                            //查看有无vip权限
+                            CollectionPrivilege collectionPrivilege = collectionPrivilegeRepo.findByCollectionId(record.getCollectionId());
+                            if (ObjectUtils.isNotEmpty(collectionPrivilege)) {
+                                if (collectionPrivilege.isVip()) {
+                                    //更新vip信息
+                                    userRepo.updateVipPurchase(user.getId(), 1);
+                                }
+                            }
                             assetService.createAsset(winItem, user, null, null, "空投",
                                     collectionService.getNextNumber(winItem.getCollectionId()), collection.getHoldDays());
                         }
@@ -75,12 +85,22 @@ public class AirDropService {
                             assetService.createAsset(collection, user, 0L, collection.getPrice(), "出售",
                                     collection.getTotal() > 1 ? collectionService.getNextNumber(collection.getId()) : null);
                         } else {
-                            assetService.createAsset(collection, user, null, null, "空投", collectionService.getNextNumber(collection.getId()));
-                        }
-                        Asset asset = assetService.createAsset(collection, user, null, null, "空投", collectionService.getNextNumber(collection.getId()));
-                        if (collection.getType() == CollectionType.SHOWROOM) {
-                            showroomService.save(asset);
+                            //查看有无vip权限
+                            CollectionPrivilege collectionPrivilege = collectionPrivilegeRepo.findByCollectionId(record.getCollectionId());
+                            if (ObjectUtils.isNotEmpty(collectionPrivilege)) {
+                                if (collectionPrivilege.isVip()) {
+                                    //更新vip信息
+                                    userRepo.updateVipPurchase(user.getId(), 1);
+                                }
+                            }
+                            Asset asset = assetService.createAsset(collection, user, null, null, "空投", collectionService.getNextNumber(collection.getId()));
+                            //创建展厅
+                            if (collection.getType() == CollectionType.SHOWROOM) {
+                                showroomService.save(asset);
+                            }
                         }
+//                        Asset asset = assetService.createAsset(collection, user, null, null, "空投", collectionService.getNextNumber(collection.getId()));
+
                     }
                     collectionService.decreaseStock(collection.getId(), 1);
                     collectionService.increaseSale(collection.getId(), 1);

+ 22 - 11
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -44,17 +44,18 @@ import java.util.stream.Collectors;
 @Slf4j
 public class AssetService {
 
-    private AssetRepo          assetRepo;
-    private UserRepo           userRepo;
-    private CollectionRepo     collectionRepo;
-    private ApplicationContext applicationContext;
-    private OrderRepo          orderRepo;
-    private TokenHistoryRepo   tokenHistoryRepo;
-    private SysConfigService   sysConfigService;
-    private RocketMQTemplate   rocketMQTemplate;
-    private GeneralProperties  generalProperties;
-    private ShowroomRepo       showroomRepo;
-    private ShowCollectionRepo showCollectionRepo;
+    private AssetRepo               assetRepo;
+    private UserRepo                userRepo;
+    private CollectionRepo          collectionRepo;
+    private ApplicationContext      applicationContext;
+    private OrderRepo               orderRepo;
+    private TokenHistoryRepo        tokenHistoryRepo;
+    private SysConfigService        sysConfigService;
+    private RocketMQTemplate        rocketMQTemplate;
+    private GeneralProperties       generalProperties;
+    private ShowroomRepo            showroomRepo;
+    private ShowCollectionRepo      showCollectionRepo;
+    private CollectionPrivilegeRepo collectionPrivilegeRepo;
 
 
     public Page<Asset> all(PageQuery pageQuery) {
@@ -343,6 +344,16 @@ public class AssetService {
         if (orderId != null) {
             applicationContext.publishEvent(new TransferAssetEvent(this, true, newAsset));
         }
+
+        //vip权限转让
+        CollectionPrivilege collectionPrivilege = collectionPrivilegeRepo.findByCollectionId(asset.getCollectionId());
+        if (ObjectUtils.isNotEmpty(collectionPrivilege)) {
+            if (collectionPrivilege.isVip()) {
+                //更新vip信息
+                userRepo.updateVipPurchase(toUser.getId(), 1);
+                userRepo.updateVipPurchase(asset.getUserId(), 0);
+            }
+        }
     }
 
     public List<TokenHistory> tokenHistory(String tokenId, Long assetId) {

+ 22 - 0
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -93,6 +93,7 @@ public class OrderService {
     private ErrorOrderRepo                errorOrderRepo;
     private ShowCollectionRepo            showCollectionRepo;
     private ShowroomService               showroomService;
+    private CollectionPrivilegeRepo       collectionPrivilegeRepo;
 
     public Page<Order> all(PageQuery pageQuery) {
         return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
@@ -571,6 +572,7 @@ public class OrderService {
             Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
             Collection collection = collectionRepo.findById(order.getCollectionId())
                     .orElseThrow(new BusinessException("藏品不存在"));
+
             User user = userRepo.findById(order.getUserId()).orElseThrow(new BusinessException("用户不存在"));
             if (order.getStatus() == OrderStatus.NOT_PAID) {
                 order.setStatus(OrderStatus.PROCESSING);
@@ -604,9 +606,20 @@ public class OrderService {
                     log.info("抽卡成功 orderId: {}, collectionId: {}, winCollectionId: {}", orderId, collection.getId(), winItem.getCollectionId());
                     order.setWinCollectionId(winItem.getCollectionId());
                     orderRepo.save(order);
+
+                    //藏品其他信息/是否vip
+                    CollectionPrivilege collectionPrivilege = collectionPrivilegeRepo.findByCollectionId(order.getCollectionId());
+                    if (ObjectUtils.isNotEmpty(collectionPrivilege)) {
+                        if (collectionPrivilege.isVip()) {
+                            //更新vip信息
+                            userRepo.updateVipPurchase(order.getUserId(), 1);
+                        }
+                    }
                     assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售",
                             winItem.getTotal() > 1 ? collectionService.getNextNumber(winItem.getCollectionId()) : null,
                             collection.getHoldDays());
+
+
                 } else {
                     if (collection.getSource() == CollectionSource.TRANSFER) {
                         orderRepo.save(order);
@@ -623,8 +636,17 @@ public class OrderService {
 
                     } else {
                         orderRepo.save(order);
+                        //藏品其他信息/是否vip
+                        CollectionPrivilege collectionPrivilege = collectionPrivilegeRepo.findByCollectionId(order.getCollectionId());
+                        if (ObjectUtils.isNotEmpty(collectionPrivilege)) {
+                            if (collectionPrivilege.isVip()) {
+                                //更新vip信息
+                                userRepo.updateVipPurchase(order.getUserId(), 1);
+                            }
+                        }
                         Asset asset = assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
                                 collection.getTotal() > 1 ? collectionService.getNextNumber(order.getCollectionId()) : null);
+
                         if (collection.getType() == CollectionType.SHOWROOM) {
                             showroomService.save(asset);
                         }