Browse Source

Merge branch 'dev'

# Conflicts:
#	src/main/resources/static/download_raex_space.html
xiongzhu 3 years ago
parent
commit
28665b330e

+ 11 - 0
src/main/java/com/izouma/nineth/domain/Collection.java

@@ -290,4 +290,15 @@ public class Collection extends CollectionBaseEntity {
     @ApiModelProperty("bit 0: 蚂蚁链, bit 1: 华储链")
     @Column(columnDefinition = "int default 3 not null")
     private int chainFlag;
+
+    @ApiModelProperty("新闻id")
+    private Long newsId;
+
+    @ApiModelProperty("新闻标题")
+    private String newsTitle;
+
+    @ApiModelProperty("新闻图片")
+    private String newsPic;
+
+    private LocalDateTime newsCreatedTime;
 }

+ 2 - 0
src/main/java/com/izouma/nineth/domain/PhotoAsset.java

@@ -42,5 +42,7 @@ public class PhotoAsset extends BaseEntity {
 
     private Long createAssetId;
 
+    private Long ownerId;
+
     private boolean gifted;
 }

+ 9 - 5
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -609,17 +609,21 @@ public class AssetService {
         newAsset.setOasisId(asset.getOasisId());
         newAsset.setFromAssetId(asset.getId());
         newAsset.setType(CollectionType.DEFAULT);
+
+        newAsset.setSource(TransferReason.GIFT == reason ? AssetSource.GIFT : AssetSource.TRANSFER);
+        newAsset.setTags(new HashSet<>(asset.getTags()));
+        newAsset.setSafeFlag(safeFlag);
+        newAsset.setHoldDays(asset.getOldHoldDays());
+        Long savedId = assetRepo.saveAndFlush(newAsset).getId();
+
         if (asset.getType().equals(CollectionType.PICTURE)) {
             newAsset.setType(CollectionType.PICTURE);
             PhotoAsset photoAsset = photoAssetRepo.findFirstByCreateAssetId(asset.getId());
             photoAsset.setGifted(true);
+            photoAsset.setOwnerId(toUser.getId());
+            photoAsset.setCreateAssetId(savedId);
             photoAssetRepo.save(photoAsset);
         }
-        newAsset.setSource(TransferReason.GIFT == reason ? AssetSource.GIFT : AssetSource.TRANSFER);
-        newAsset.setTags(new HashSet<>(asset.getTags()));
-        newAsset.setSafeFlag(safeFlag);
-        newAsset.setHoldDays(asset.getOldHoldDays());
-        assetRepo.saveAndFlush(newAsset);
 
         TokenHistory tokenHistory = TokenHistory.builder()
                 .tokenId(asset.getTokenId())

+ 43 - 18
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -71,6 +71,7 @@ public class CollectionService {
     private TagRepo                       tagRepo;
     private UserBalanceService            userBalanceService;
     private SysConfigService              sysConfigService;
+    private NewsRepo                      newsRepo;
 
     private final Map<Long, ScheduledFuture<?>> tasks = new HashMap<>();
 
@@ -79,7 +80,8 @@ public class CollectionService {
         if (Arrays.asList(env.getActiveProfiles()).contains("dev")) {
             return;
         }
-        List<Collection> collections = collectionRepo.findByScheduleSaleTrueAndOnShelfFalseAndStartTimeBeforeAndDelFalse(LocalDateTime.now());
+        List<Collection> collections = collectionRepo
+                .findByScheduleSaleTrueAndOnShelfFalseAndStartTimeBeforeAndDelFalse(LocalDateTime.now());
         for (Collection collection : collections) {
             onShelfTask(collection);
         }
@@ -101,11 +103,12 @@ public class CollectionService {
             BigDecimal minPrice = Convert.toBigDecimal(query.get("minPrice"));
             query.remove("minPrice");
             if (minPrice.compareTo(BigDecimal.ZERO) > 0) {
-                specification = specification.and((Specification<Collection>) (root, criteriaQuery, criteriaBuilder) -> {
-                    List<Predicate> and = new ArrayList<>();
-                    and.add(criteriaBuilder.greaterThanOrEqualTo(root.get("price"), minPrice));
-                    return criteriaBuilder.and(and.toArray(new Predicate[0]));
-                });
+                specification = specification
+                        .and((Specification<Collection>) (root, criteriaQuery, criteriaBuilder) -> {
+                            List<Predicate> and = new ArrayList<>();
+                            and.add(criteriaBuilder.greaterThanOrEqualTo(root.get("price"), minPrice));
+                            return criteriaBuilder.and(and.toArray(new Predicate[0]));
+                        });
             }
         }
 
@@ -128,12 +131,13 @@ public class CollectionService {
                 }
                 String finalNotLike = not;
                 String finalLike = "%" + rarityLabel + " #%";
-                specification = specification.and((Specification<Collection>) (root, criteriaQuery, criteriaBuilder) -> {
-                    List<Predicate> and = new ArrayList<>();
-                    and.add(criteriaBuilder.like(root.get("name"), finalLike));
-                    and.add(criteriaBuilder.notLike(root.get("name"), finalNotLike));
-                    return criteriaBuilder.and(and.toArray(new Predicate[0]));
-                });
+                specification = specification
+                        .and((Specification<Collection>) (root, criteriaQuery, criteriaBuilder) -> {
+                            List<Predicate> and = new ArrayList<>();
+                            and.add(criteriaBuilder.like(root.get("name"), finalLike));
+                            and.add(criteriaBuilder.notLike(root.get("name"), finalNotLike));
+                            return criteriaBuilder.and(and.toArray(new Predicate[0]));
+                        });
             }
         }
 
@@ -190,7 +194,15 @@ public class CollectionService {
             if (!userBalanceService.checkBalance(record.getCompanyId(), totalPrice)) {
                 throw new BusinessException("余额不足");
             }
-            userBalanceService.modifyBalance(record.getCompanyId(), totalPrice.negate(), BalanceType.PAY, null, false, null);
+            userBalanceService
+                    .modifyBalance(record.getCompanyId(), totalPrice.negate(), BalanceType.PAY, null, false, null);
+        }
+        if (record.getNewsId() != null) {
+            News news = newsRepo.findById(record.getNewsId()).orElseThrow(new BusinessException("未找到"));
+            record.setNewsId(news.getId());
+            record.setNewsPic(news.getPic());
+            record.setNewsTitle(news.getTitle());
+            record.setNewsCreatedTime(news.getCreatedAt());
         }
         record.setMinter(minter.getNickname());
         record.setMinterId(minter.getId());
@@ -265,6 +277,13 @@ public class CollectionService {
             collection.setTags(new HashSet<>(tagRepo.findAllById(record.getTags().stream().map(Tag::getId)
                     .collect(Collectors.toList()))));
         }
+        if (record.getNewsId() != null) {
+            News news = newsRepo.findById(record.getNewsId()).orElseThrow(new BusinessException("未找到新闻"));
+            collection.setNewsId(news.getId());
+            collection.setNewsTitle(news.getTitle());
+            collection.setNewsPic(news.getPic());
+            collection.setNewsCreatedTime(news.getCreatedAt());
+        }
         collection = collectionRepo.save(collection);
 
         onShelfTask(collection);
@@ -309,7 +328,9 @@ public class CollectionService {
                     collectionDTO.setAppointment(appointmentRepo.findFirstByBlindBoxId(collection.getId()).isPresent());
                 }
                 if (showVip && collection.getAssignment() > 0 && user.getVipPurchase() > 0) {
-                    int purchase = orderRepo.countByUserIdAndCollectionIdAndVipTrueAndStatusIn(user.getId(), collection.getId(), Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
+                    int purchase = orderRepo
+                            .countByUserIdAndCollectionIdAndVipTrueAndStatusIn(user.getId(), collection.getId(), Arrays
+                                    .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
                     collectionDTO.setVipSurplus(user.getVipPurchase() - purchase);
                 }
             }
@@ -454,14 +475,16 @@ public class CollectionService {
     public BlindBoxItem draw(Long userId, Long collectionId) {
         log.info("blindBoxDraw, userId={}, collectionId={}", userId, collectionId);
         List<BlindBoxItem> items = blindBoxItemRepo.findByBlindBoxId(collectionId);
-        BoundHashOperations<String, Object, Object> operations = redisTemplate.boundHashOps(RedisKeys.DRAW_BLIND_BOX + collectionId);
+        BoundHashOperations<String, Object, Object> operations = redisTemplate
+                .boundHashOps(RedisKeys.DRAW_BLIND_BOX + collectionId);
         Map<Object, Object> entries = operations.entries();
 
         Map<BlindBoxItem, Range<Integer>> randomRange = new HashMap<>();
         int c = 0, sum = 0;
         for (BlindBoxItem item : items) {
             if (item.getStock() > 0) {
-                int stock = Optional.ofNullable(entries.get(item.getCollectionId() + "")).map(i -> (int) i).orElse(item.getStock());
+                int stock = Optional.ofNullable(entries.get(item.getCollectionId() + "")).map(i -> (int) i)
+                        .orElse(item.getStock());
                 randomRange.put(item, Range.between(c, c + item.getStock()));
                 c += stock;
                 sum += stock;
@@ -473,7 +496,8 @@ public class CollectionService {
         while (winItem == null) {
             retry++;
             if (userId == 3453161L || userId == 7194L || userId == 134613L) {
-                winItem = items.stream().filter(i -> i.getName().contains("SSR") && i.getStock() > 0).findFirst().orElse(null);
+                winItem = items.stream().filter(i -> i.getName().contains("SSR") && i.getStock() > 0).findFirst()
+                        .orElse(null);
             }
             if (winItem == null) {
                 int rand = RandomUtils.nextInt(0, sum + 1);
@@ -529,7 +553,8 @@ public class CollectionService {
     }
 
     public synchronized Integer getNextNumber(Long collectionId) {
-        BoundValueOperations<String, Object> opt = redisTemplate.boundValueOps(RedisKeys.COLLECTION_NUMBER + collectionId);
+        BoundValueOperations<String, Object> opt = redisTemplate
+                .boundValueOps(RedisKeys.COLLECTION_NUMBER + collectionId);
         opt.setIfAbsent(collectionRepo.getCurrentNumber(collectionId).orElse(0));
         int num = Math.toIntExact(Optional.ofNullable(opt.increment()).orElse(1L));
         collectionRepo.setNumber(collectionId, num);

+ 2 - 0
src/main/java/com/izouma/nineth/service/PhotoAssetService.java

@@ -54,6 +54,7 @@ public class PhotoAssetService {
         record.setUserAvatar(asset.getOwnerAvatar());
         record.setUserName(asset.getOwner());
         record.setDestroyAssetName(asset.getName());
+        record.setOwnerId(record.getOwnerId());
         record.setGifted(false);
         if (asset.getNumber() != null) {
             record.setDestroyAssetNumber(asset.getNumber().toString());
@@ -69,6 +70,7 @@ public class PhotoAssetService {
                 .orElseThrow(new BusinessException("无用户记录")), null, BigDecimal.ZERO, "星图", null, false).getId();
         photoAsset.setStatus(CollectionStatus.SUCCESS);
         photoAsset.setCreateAssetId(createId);
+        photoAsset.setOwnerId(photoAsset.getUserId());
         photoAssetRepo.save(photoAsset);
     }
 

+ 10 - 0
src/main/java/com/izouma/nineth/web/AgreementController.java

@@ -2,6 +2,7 @@ package com.izouma.nineth.web;
 
 import com.izouma.nineth.config.GeneralProperties;
 import lombok.AllArgsConstructor;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -19,6 +20,15 @@ public class AgreementController {
         return  "Privacy";
     }
 
+    @GetMapping("/privacy1.html")
+    public String privacy1(Model model) {
+        GeneralProperties p = new GeneralProperties();
+        BeanUtils.copyProperties(generalProperties, p);
+        p.setName("RAEX绿洲");
+        model.addAttribute("properties", generalProperties);
+        return  "Privacy";
+    }
+
     @GetMapping("/service.html")
     public String service(Model model) {
         model.addAttribute("properties", generalProperties);

+ 2 - 2
src/main/resources/static/download_raex_space.html

@@ -125,8 +125,8 @@
         <span>PC版下载</span>
       </a>
       <a id="androidUrlPhone" class="btn">
-        <img src="img/icon_Android.png" alt="" />
-        <span>Android版下载</span>
+        <img src="img/icon_pc.png" alt="" />
+        <span>PC版下载</span>
       </a>
       <div id="androidUrl" class="btn">
         <img src="img/icon_Android.png" alt="" />

+ 24 - 1
src/main/vue/src/views/CollectionEdit.vue

@@ -336,7 +336,23 @@
                     <el-form-item label="活动规则" v-if="formData.assignment > 0">
                         <rich-text style="width:500px" onlyText v-model="formData.rule"></rich-text>
                     </el-form-item>
-
+                    <el-form-item prop="newsId" label="新闻">
+                        <el-select v-model="formData.newsId" placeholder="请选择">
+                        <el-option
+                            v-for="item in newsOptions"
+                            :key="item.id"
+                            :label="item.title"
+                            :value="item.id"
+                            class="minter-item"
+                        >
+<!--                            <el-image :src="item.pic" fit="cover" class="avatar"></el-image>-->
+                            <div class="content">
+                                <div class="name">{{ item.title }}</div>
+                                <div class="id">#{{ item.subTitle }}</div>
+                            </div>
+                        </el-option>
+                        </el-select>
+                    </el-form-item>
                     <el-form-item class="form-submit">
                         <el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
                         <!-- <el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id">
@@ -419,6 +435,12 @@ export default {
                 }
                 return resolve();
             }),
+            this.$http
+                .post('/news/all', { size: 10000, query: { del: false } }, { body: 'json' })
+                .then(res => {
+                    this.newsOptions = res.content;
+                    return Promise.resolve();
+                }),
             this.$http
                 .post('/privilegeOption/all', { size: 10000, query: { del: false } }, { body: 'json' })
                 .then(res => {
@@ -447,6 +469,7 @@ export default {
                 onShelf: false,
                 salable: false,
                 properties: [],
+                newsOptions: [],
                 type: 'DEFAULT',
                 source: 'OFFICIAL',
                 pic: [],