Forráskód Böngészése

Merge branch 'dev' of http://git.izouma.com/xiongzhu/raex_back into dev

panhui 4 éve
szülő
commit
ad2ede1abd

+ 8 - 0
src/main/java/com/izouma/nineth/event/CreateOrderEvent.java

@@ -1,5 +1,7 @@
 package com.izouma.nineth.event;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -10,12 +12,18 @@ import java.io.Serializable;
 @AllArgsConstructor
 @NoArgsConstructor
 public class CreateOrderEvent implements Serializable {
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long    id;
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long    userId;
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long    collectionId;
     private int     qty;
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long    addressId;
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long    userCouponId;
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long    invitor;
     private boolean vip;
     private int     vipPurchase;

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

@@ -384,7 +384,7 @@ public class CollectionService {
     public synchronized Long increaseSale(Long id, int number) {
         BoundValueOperations<String, Object> ops = redisTemplate.boundValueOps(RedisKeys.COLLECTION_SALE + id);
         if (ops.get() == null) {
-            Boolean success = ops.setIfAbsent(Optional.ofNullable(collectionRepo.getStock(id))
+            Boolean success = ops.setIfAbsent(Optional.ofNullable(collectionRepo.getSale(id))
                     .orElse(0), 7, TimeUnit.DAYS);
             log.info("创建redis销量:{}", success);
         }
@@ -394,7 +394,7 @@ public class CollectionService {
     }
 
     public synchronized Long decreaseSale(Long id, int number) {
-        return increaseStock(id, -number);
+        return increaseSale(id, -number);
     }
 
     @Debounce(key = "#id", delay = 500)

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

@@ -32,6 +32,7 @@ import com.izouma.nineth.security.Authority;
 import com.izouma.nineth.service.sms.SmsService;
 import com.izouma.nineth.utils.AESEncryptUtil;
 import com.izouma.nineth.utils.JpaUtils;
+import com.izouma.nineth.utils.SecurityUtils;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -241,6 +242,7 @@ public class OrderService {
                 } else {
                     order.setTotalPrice(BigDecimal.ZERO);
                 }
+                userCouponRepo.save(coupon);
             }
 
             if (collection.getSource() == CollectionSource.TRANSFER) {
@@ -357,12 +359,18 @@ public class OrderService {
 
     @Cacheable(value = "adapay", key = "#id+'_'+#payChannel")
     public Object payAdapay(Long id, String payChannel, String openId) throws BaseAdaPayException {
+
         List<String> aliChannels = Arrays.asList("alipay", "alipay_qr", "alipay_wap");
         List<String> wxChannels = Arrays.asList("wx_pub", "wx_lite");
         if (!aliChannels.contains(payChannel) && !wxChannels.contains(payChannel)) {
             throw new BusinessException("不支持此渠道");
         }
         Order order = orderRepo.findByIdAndDelFalse(id).orElseThrow(new BusinessException("订单不存在"));
+        if (SecurityUtils.getAuthenticatedUser() != null
+                && !SecurityUtils.getAuthenticatedUser().getId().equals(order.getUserId())) {
+            log.error("payAdapay userId错误 requestUserId={} orderUserId={}",
+                    SecurityUtils.getAuthenticatedUser().getId(), order.getUserId());
+        }
         Collection collection = collectionRepo.findById(order.getCollectionId())
                 .orElseThrow(new BusinessException("藏品不存在"));
         User invitor = null;
@@ -768,7 +776,20 @@ public class OrderService {
     }
 
     public Object queryCreateOrder(String id) {
-        return redisTemplate.opsForValue().get(RedisKeys.CREATE_ORDER + id);
+        Object res = redisTemplate.opsForValue().get(RedisKeys.CREATE_ORDER + id);
+        if (res != null) {
+            if (res instanceof Map) {
+                if (MapUtils.getBooleanValue((Map) res, "success", false)) {
+                    Order order = (Order) MapUtils.getObject((Map) res, "data");
+                    if (!SecurityUtils.getAuthenticatedUser().getId().equals(order.getUserId())) {
+                        log.error("queryCreateOrder userId错误 requestUserId={} orderUserId={}",
+                                SecurityUtils.getAuthenticatedUser().getId(), order.getUserId());
+                        return null;
+                    }
+                }
+            }
+        }
+        return res;
     }
 
     // 获取订单锁,有效时间1小时

+ 5 - 3
src/main/vue/src/views/BannerEdit.vue

@@ -53,7 +53,8 @@
                         </el-select>
                     </el-form-item>
                     <el-form-item prop="linkContent" label="跳转内容" v-if="formData.link">
-                        <el-input v-model="formData.linkContent" placeholder="输入ID"></el-input>
+                        <el-input v-if="formData.linkType === 'collections'" v-model="formData.linkContent" placeholder="输入藏品名称"></el-input>
+                        <el-input v-else v-model="formData.linkContent" placeholder="输入ID"></el-input>
                     </el-form-item>
                     <el-form-item class="form-submit">
                         <el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
@@ -132,14 +133,15 @@ export default {
                 { label: '首页', value: 'HOME' },
                 { label: '发现页', value: 'DISCOVER' },
                 { label: '铸造者', value: 'MINTER' },
-                { label: '市场', value: 'MARKET' },
+                { label: '二手市场', value: 'MARKET' },
                 { label: 'PC官方活动', value: 'PC_ACT' },
                 { label: 'PC首页大图', value: 'PC_TITLE' }
             ],
             linkTypeOptions: [
                 { label: '藏品/盲盒', value: 'collection' },
                 { label: '铸造者', value: 'user' },
-                { label: '活动', value: 'activity' }
+                { label: '活动', value: 'activity' },
+                { label: '多个藏品', value: 'collections' }
             ]
         };
     },

+ 3 - 2
src/main/vue/src/views/BannerList.vue

@@ -111,7 +111,7 @@ export default {
                 { label: '首页', value: 'HOME' },
                 { label: '发现页', value: 'DISCOVER' },
                 { label: '铸造者', value: 'MINTER' },
-                { label: '市场', value: 'MARKET' },
+                { label: '二手市场', value: 'MARKET' },
                 { label: 'PC官方活动', value: 'PC_ACT' },
                 { label: 'PC首页大图', value: 'PC_TITLE' }
             ],
@@ -119,7 +119,8 @@ export default {
             linkTypeOptions: [
                 { label: '藏品/盲盒', value: 'collection' },
                 { label: '铸造者', value: 'user' },
-                { label: '活动', value: 'activity' }
+                { label: '活动', value: 'activity' },
+                { label: '多个藏品', value: 'collections' }
             ]
         };
     },

+ 14 - 13
src/test/java/com/izouma/nineth/service/CollectionServiceTest.java

@@ -52,23 +52,23 @@ class CollectionServiceTest extends ApplicationTests {
 
     @Test
     public void batchUpload() throws IOException {
-        AtomicInteger num = new AtomicInteger(4001);
+        AtomicInteger num = new AtomicInteger(2501);
         List<BlindBoxItem> items = new ArrayList<>();
-        String jsonStr = FileUtils.readFileToString(new File("/Users/drew/Downloads/003.json"), "UTF-8");
-        Arrays.stream(new File("/Users/drew/Downloads/s5-1000").listFiles())
+        String jsonStr = FileUtils.readFileToString(new File("/Users/qiufangchao/Desktop/evo.json"), "UTF-8");
+        Arrays.stream(new File("/Users/qiufangchao/Desktop/evo3").listFiles())
                 .filter(f -> Pattern.matches("^BJ.*\\.png$", f.getName()))
                 .parallel().forEach(file -> {
                     try {
                         Collection collection = JSON.parseObject(jsonStr, Collection.class);
                         collection.setId(null);
-                        collection.setName(String.format("MAYBEMAN #%05d", num.getAndIncrement()));
+                        collection.setName(String.format("OASISPUNK.EVO #%04d", num.getAndIncrement()));
                         collection.setStock(1);
                         collection.setTotal(1);
                         collection.setSale(0);
-                        collection.setMinterId(8666L);
+                        collection.setMinterId(7150L);
                         collection.setOnShelf(false);
                         collection.setSalable(false);
-                        collection.setPic(Collections.singletonList(new FileObject("", "https://raex-meta.oss-cn-shenzhen.aliyuncs.com/image/s5/" + file.getName(), null, "png")));
+                        collection.setPic(Collections.singletonList(new FileObject("", "https://raex-meta.oss-cn-shenzhen.aliyuncs.com/image/evos3/" + file.getName(), null, "png")));
 
                         collectionRepo.save(collection);
                         System.out.println("保存成功" + collection.getId());
@@ -89,20 +89,21 @@ class CollectionServiceTest extends ApplicationTests {
 
     @Test
     public void createBlindBox() throws IOException {
-        List<Collection> items = collectionRepo.findByNameLike("MAYBEMAN #%").stream().filter(i -> {
-            int num = Integer.parseInt(i.getName().substring("MAYBEMAN #".length()));
-            return num > 4000 && num <= 5000;
+        List<Collection> items = collectionRepo.findByNameLike("OASISPUNK.EVO #%").stream().filter(i -> {
+            int num = Integer.parseInt(i.getName().substring("OASISPUNK.EVO #".length()));
+            return num > 2500 && num <= 3000;
         }).collect(Collectors.toList());
 
-        String jsonStr = FileUtils.readFileToString(new File("/Users/drew/Downloads/003.json"), "UTF-8");
+        String jsonStr = FileUtils.readFileToString(new File("/Users/qiufangchao/Desktop/evo.json"), "UTF-8");
         Collection blindBox = JSON.parseObject(jsonStr, Collection.class);
         blindBox.setType(CollectionType.BLIND_BOX);
         blindBox.setId(null);
         blindBox.setOnShelf(false);
         blindBox.setSalable(false);
-        blindBox.setMinterId(8666L);
-        blindBox.setName("MAYBEMAN潮流艺术限定盲盒S5");
-        blindBox.setPic(Arrays.asList(new FileObject(null, "https://raex-meta.oss-cn-shenzhen.aliyuncs.com/nft/2022-01-07-10-08-30DpIYYBOv.jpg", null, null)));
+        blindBox.setMinterId(7150L);
+        blindBox.setNoSoldOut(true);
+        blindBox.setName("OASISPUNK.EVO绿洲朋克进化版限定盲盒S3");
+        blindBox.setPic(Arrays.asList(new FileObject(null, "https://raex-meta.oss-cn-shenzhen.aliyuncs.com/image/evos3/fm.jpg", null, null)));
         collectionService.createBlindBox(new CreateBlindBox(blindBox, items.stream().map(i -> {
             BlindBoxItem item = new BlindBoxItem();
             item.setCollectionId(i.getId());