Browse Source

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

 Conflicts:
	src/main/vue/src/router.js
sunkean 3 years ago
parent
commit
a6c7916af0

+ 3 - 0
src/main/java/com/izouma/nineth/config/CacheConfig.java

@@ -156,6 +156,9 @@ public class CacheConfig {
         cacheNamesConfigurationMap.put("transactionTopTen", RedisCacheConfiguration.defaultCacheConfig()
                 .entryTtl(Duration.ofDays(1))
                 .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(redisTemplate.getValueSerializer())));
+        cacheNamesConfigurationMap.put("userTopTen", RedisCacheConfiguration.defaultCacheConfig()
+                .entryTtl(Duration.ofHours(3))
+                .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(redisTemplate.getValueSerializer())));
         RedisCacheManager redisCacheManager = RedisCacheManager.builder()
                 .cacheWriter(RedisCacheWriter.nonLockingRedisCacheWriter(redisTemplate.getConnectionFactory()))
                 .withInitialCacheConfigurations(cacheNamesConfigurationMap)

+ 2 - 0
src/main/java/com/izouma/nineth/config/RedisKeys.java

@@ -9,6 +9,8 @@ public class RedisKeys {
 
     public static final String COLLECTION_SALE = "collectionSale::";
 
+    public static final String DOMAIN_COUNT = "LimitDomainCount::";
+
     public static final String AUCTION_STOCK = "auctionStock::";
 
     public static final String AUCTION_SALE = "auctionSale::";

+ 40 - 0
src/main/java/com/izouma/nineth/domain/MetaConfig.java

@@ -0,0 +1,40 @@
+package com.izouma.nineth.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Data
+@Entity
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class MetaConfig extends AuditedEntity {
+
+    @Id
+    @Column(length = 25, unique = true)
+    @ApiModelProperty(value = "名称", name = "name")
+    private String name;
+
+    @Column(name = "description")
+    @ApiModelProperty(value = "描述", name = "desc")
+    private String desc;
+
+    @ApiModelProperty(value = "值", name = "value")
+    @Column(columnDefinition = "TEXT")
+    private String value;
+
+    @Enumerated(EnumType.STRING)
+    private SysConfig.ValueType type;
+
+    private String options;
+
+    public enum ValueType {
+        STRING
+    }
+}
+

+ 17 - 0
src/main/java/com/izouma/nineth/dto/TouristDTO.java

@@ -0,0 +1,17 @@
+package com.izouma.nineth.dto;
+
+import lombok.Data;
+import org.apache.commons.lang3.RandomStringUtils;
+
+@Data
+public class TouristDTO {
+
+    private String nickName;
+
+    private Long userId;
+
+    public TouristDTO() {
+        this.nickName = "游客-" + RandomStringUtils.randomAlphabetic(8);
+        this.userId = 999999L;
+    }
+}

+ 1 - 1
src/main/java/com/izouma/nineth/listener/RegisterListener.java

@@ -40,7 +40,7 @@ public class RegisterListener implements RocketMQListener<RegisterEvent> {
             User user = userService.phoneRegister(registerEvent.getPhone(), registerEvent.getCode(),
                     registerEvent.getPassword(), registerEvent.getInviteCode(),
                     registerEvent.getInvitor(), registerEvent.getCollectionId(),
-                    registerEvent.getShowroomId(), InviteType.NORMAL);
+                    registerEvent.getShowroomId(), InviteType.NORMAL, null);
             map.put("status", "success");
             map.put("data", user);
             map.put("token", jwtTokenUtil.generateToken(JwtUserFactory.create(user)));

+ 2 - 0
src/main/java/com/izouma/nineth/repo/AssetRepo.java

@@ -32,6 +32,8 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
 
     List<Asset> findAllByCollectionIdInAndStatusIn(List<Long> collectionId, Iterable<AssetStatus> statuses);
 
+    List<Asset> findAllByCollectionIdAndStatusInAndUserId(Long collectionId, Iterable<AssetStatus> statuses,Long userId);
+
     List<Asset> findByCreatedAtBefore(LocalDateTime localDateTime);
 
     List<Asset> findByConsignmentTrue();

+ 16 - 0
src/main/java/com/izouma/nineth/repo/MetaConfigRepo.java

@@ -0,0 +1,16 @@
+package com.izouma.nineth.repo;
+
+import com.izouma.nineth.domain.MetaConfig;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import javax.transaction.Transactional;
+
+public interface MetaConfigRepo extends JpaRepository<MetaConfig, Long>, JpaSpecificationExecutor<MetaConfig> {
+    @Query("update MetaConfig t set t.del = true where t.id = ?1")
+    @Modifying
+    @Transactional
+    void softDelete(Long id);
+}

+ 98 - 17
src/main/java/com/izouma/nineth/service/DomainOrderService.java

@@ -1,15 +1,21 @@
 package com.izouma.nineth.service;
 
 import com.alibaba.excel.util.StringUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.google.zxing.WriterException;
+import com.izouma.nineth.config.RedisKeys;
+import com.izouma.nineth.domain.Asset;
 import com.izouma.nineth.domain.DomainOrder;
 import com.izouma.nineth.domain.FileObject;
 import com.izouma.nineth.domain.User;
 import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.enums.AssetStatus;
 import com.izouma.nineth.enums.CollectionStatus;
 import com.izouma.nineth.enums.OrderStatus;
 import com.izouma.nineth.enums.PayMethod;
 import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.AssetRepo;
 import com.izouma.nineth.repo.DomainOrderRepo;
 import com.izouma.nineth.repo.UserRepo;
 import com.izouma.nineth.service.storage.StorageService;
@@ -17,12 +23,15 @@ import com.izouma.nineth.utils.ImageUtils;
 import com.izouma.nineth.utils.JpaUtils;
 import com.izouma.nineth.utils.SecurityUtils;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.data.annotation.Transient;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.domain.Sort;
+import org.springframework.data.redis.core.BoundValueOperations;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
 import javax.imageio.ImageIO;
@@ -37,19 +46,25 @@ import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 @Service
 @AllArgsConstructor
+@Slf4j
 public class DomainOrderService {
 
-    private DomainOrderRepo     domainOrderRepo;
-    private ContentAuditService contentAuditService;
-    private UserRepo            userRepo;
-    private AssetService        assetService;
-    private SysConfigService    sysConfigService;
-    private StorageService      storageService;
+    private DomainOrderRepo               domainOrderRepo;
+    private ContentAuditService           contentAuditService;
+    private UserRepo                      userRepo;
+    private AssetService                  assetService;
+    private SysConfigService              sysConfigService;
+    private StorageService                storageService;
+    private RockRecordService             rockRecordService;
+    private AssetRepo                     assetRepo;
+    private RedisTemplate<String, Object> redisTemplate;
 
     public Page<DomainOrder> all(PageQuery pageQuery) {
         return domainOrderRepo
@@ -70,6 +85,7 @@ public class DomainOrderService {
     }
 
     public DomainOrder create(Long userId, String domain, BigDecimal price, Long year) {
+        AtomicBoolean checkPoint = checkPoint(userId);
         List<DomainOrder> notPaidOrders = domainOrderRepo.findAllByUserIdAndOrderStatus(userId, OrderStatus.NOT_PAID);
         Long superUserId = Long.valueOf(sysConfigService.getString("domain_superUserId"));
         if (notPaidOrders.size() > 0) {
@@ -82,8 +98,14 @@ public class DomainOrderService {
             if (isContainChinese(domain)) {
                 throw new BusinessException("禁止注册中文域名");
             }
-            if (domain.length() < 9) {
-                throw new BusinessException("四位及以下域名只能官方创建。");
+            if (!checkPoint.get()) {
+                if (domain.length() < 9 || domain.length() > 20) {
+                    throw new BusinessException("四位及以下域名只能官方创建。");
+                }
+            } else {
+                if (domain.length() < 8 || domain.length() > 20) {
+                    throw new BusinessException("四位及以下域名只能官方创建。");
+                }
             }
         }
         String realName;
@@ -121,10 +143,57 @@ public class DomainOrderService {
         domainOrder.setUserId(user.getId());
         domainOrder.setUserAvatar(user.getAvatar());
         domainOrder.setUserName(user.getNickname());
+        if (checkPoint.get()) {
+            if (realName.length() < 5) {
+                increaseCount(userId, 1);
+            }
+        }
         return domainOrderRepo.save(domainOrder);
     }
 
+    public void increaseCount(Long userId, Integer count) {
+        BoundValueOperations<String, Object> ops = redisTemplate.boundValueOps(RedisKeys.DOMAIN_COUNT + userId);
+        if (ops.get() == null) {
+            Boolean success = ops.setIfAbsent(0);
+            log.info("创建redis域名统计:{}", success);
+        }
+        ops.increment(count);
+    }
+
+    public void decreaseCount(Long userId) {
+        increaseCount(userId, -1);
+    }
+
+    public AtomicBoolean checkPoint(Long userId) {
+        Map<Long, Long> collections = JSONObject.parseObject(sysConfigService
+                .getString("domain_collection"), new TypeReference<HashMap<Long, Long>>() {
+        });
+        if (collections.size() == 0) {
+            return new AtomicBoolean(false);
+        }
+        List<AssetStatus> statuses = new ArrayList<>();
+        statuses.add(AssetStatus.NORMAL);
+        statuses.add(AssetStatus.AUCTIONING);
+        AtomicBoolean vipPoint = new AtomicBoolean(false);
+        collections.forEach((k, v) -> {
+            List<Asset> assets = assetRepo.findAllByCollectionIdAndStatusInAndUserId(k, statuses, userId);
+            if (assets.size() > 0) {
+                BoundValueOperations<String, Object> ops = redisTemplate.boundValueOps(RedisKeys.DOMAIN_COUNT + userId);
+                Integer count = (Integer) ops.get();
+                if (count != null) {
+                    if (count < v) {
+                        vipPoint.set(true);
+                    }
+                } else {
+                    vipPoint.set(true);
+                }
+            }
+        });
+        return vipPoint;
+    }
+
     public Map<String, Object> check(String domain) {
+        AtomicBoolean checkPoint = checkPoint(SecurityUtils.getAuthenticatedUser().getId());
         Map<String, Object> result = new HashMap<>();
         Long superUserId = Long.valueOf(sysConfigService.getString("domain_superUserId"));
         String visibleDomain = domain;
@@ -143,10 +212,18 @@ public class DomainOrderService {
                 result.put("reason", "包含敏感关键字");
                 return result;
             }
-            if (visibleDomain.length() < 9 || visibleDomain.length() > 20) {
-                result.put("result", false);
-                result.put("reason", "域名长度不合规");
-                return result;
+            if (!checkPoint.get()) {
+                if (visibleDomain.length() < 9 || visibleDomain.length() > 20) {
+                    result.put("result", false);
+                    result.put("reason", "域名长度不合规");
+                    return result;
+                }
+            } else {
+                if (visibleDomain.length() < 8 || visibleDomain.length() > 20) {
+                    result.put("result", false);
+                    result.put("reason", "域名长度不合规");
+                    return result;
+                }
             }
             if (!contentAuditService.auditText(domain)) {
                 result.put("result", false);
@@ -172,7 +249,8 @@ public class DomainOrderService {
             domain = domain.substring(0, dotIndex);
         }
         Pageable pageable = PageRequest.of(0, 10, Sort.by("createdAt").descending());
-        List<DomainOrder> used = domainOrderRepo.searchUsedDomain("%" + domain + "%", OrderStatus.CANCELLED,pageable).getContent();
+        List<DomainOrder> used = domainOrderRepo.searchUsedDomain("%" + domain + "%", OrderStatus.CANCELLED, pageable)
+                .getContent();
 
         String n = domain.substring(domain.length() - 1);
         List<Map<String, Object>> recommend = new ArrayList<>();
@@ -198,12 +276,10 @@ public class DomainOrderService {
             Map<String, Object> sold = new HashMap<>();
             if (!domainOrder.getDomainName().contains(".uni")) {
                 sold.put("domain", domainOrder.getDomainName().toLowerCase());
+                sold.put("endTime", domainOrder.getEndTime());
                 sold.put("sold", true);
                 result.add(sold);
             }
-            if (result.size() > 9) {
-
-            }
         });
         return result;
     }
@@ -233,17 +309,22 @@ public class DomainOrderService {
         domainOrder.setCreateAssetId(createAsset(domainOrder));
         domainOrder.setEndTime(LocalDateTime.now().plusYears(domainOrder.getYears()));
         domainOrderRepo.save(domainOrder);
+
+        rockRecordService.addRock(domainOrder.getUserId(), domainOrder.getPrice(), "购买");
     }
 
     public void cancel(DomainOrder domainOrder) {
         domainOrder.setOrderStatus(OrderStatus.CANCELLED);
         domainOrder.setStatus(CollectionStatus.FAIL);
+        if (domainOrder.getPicName().length() < 5) {
+            decreaseCount(domainOrder.getUserId());
+        }
         domainOrderRepo.save(domainOrder);
     }
 
     public Long createAsset(DomainOrder domainOrder) {
         return assetService.createAsset(domainOrder, userRepo.findById(domainOrder.getUserId())
-                .orElseThrow(new BusinessException("无用户记录")), null, BigDecimal.ZERO, "域名", null, false).getId();
+                .orElseThrow(new BusinessException("无用户记录")), null, domainOrder.getPrice(), "域名", null, false).getId();
     }
 
     public BufferedImage domainImg(String domain) throws IOException, FontFormatException, WriterException {

+ 20 - 0
src/main/java/com/izouma/nineth/service/MetaConfigService.java

@@ -0,0 +1,20 @@
+package com.izouma.nineth.service;
+
+import com.izouma.nineth.domain.MetaConfig;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.repo.MetaConfigRepo;
+import com.izouma.nineth.utils.JpaUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+
+@Service
+@AllArgsConstructor
+public class MetaConfigService {
+
+    private MetaConfigRepo metaConfigRepo;
+
+    public Page<MetaConfig> all(PageQuery pageQuery) {
+        return metaConfigRepo.findAll(JpaUtils.toSpecification(pageQuery, MetaConfig.class), JpaUtils.toPageRequest(pageQuery));
+    }
+}

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

@@ -720,7 +720,7 @@ public class SandPayService {
             System.out.println("verify sign success");
 
             JSONObject respJson = JSONObject.parseObject(respData);
-            return respJson.getBigDecimal("balance").divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
+            return respJson.getBigDecimal("creditAmt").divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
 
         } catch (Exception e) {
 

+ 21 - 21
src/main/java/com/izouma/nineth/service/TradeAuctionOrderService.java

@@ -305,27 +305,27 @@ public class TradeAuctionOrderService {
 //        releaseOrderLock(order.getId());
     }
 
-    @Scheduled(fixedRate = 30000)
-    public void batchAirdrop() {
-        List<TradeAuctionOrder> tradeAuctionOrders = tradeAuctionOrderRepo
-                .findByStatusAndDelFalse(AuctionOrderStatus.AIR_DROP);
-        tradeAuctionOrders.parallelStream().forEach(o -> {
-            try {
-                TradeAuctionOrder order = tradeAuctionOrderRepo.findById(o.getId())
-                        .orElseThrow(new BusinessException("订单不存在"));
-                TradeAuction tradeAuction = tradeAuctionRepo.findById(order.getTradeAuctionId())
-                        .orElseThrow(new BusinessException("未找到易拍活动"));
-                User owner = userRepo.findById(order.getUserId())
-                        .orElseThrow(new BusinessException("暂无用户"));
-                assetService.createAsset(tradeAuction, owner, order.getId(), tradeAuction
-                        .getCurrentPrice(), "空投", 1, false);
-                order.setStatus(AuctionOrderStatus.FINISH);
-                tradeAuctionOrderRepo.save(order);
-            } catch (Exception e) {
-                log.error("取消易拍订单错误 " + o.getId(), e);
-            }
-        });
-    }
+//    @Scheduled(fixedRate = 30000)
+//    public void batchAirdrop() {
+//        List<TradeAuctionOrder> tradeAuctionOrders = tradeAuctionOrderRepo
+//                .findByStatusAndDelFalse(AuctionOrderStatus.AIR_DROP);
+//        tradeAuctionOrders.parallelStream().forEach(o -> {
+//            try {
+//                TradeAuctionOrder order = tradeAuctionOrderRepo.findById(o.getId())
+//                        .orElseThrow(new BusinessException("订单不存在"));
+//                TradeAuction tradeAuction = tradeAuctionRepo.findById(order.getTradeAuctionId())
+//                        .orElseThrow(new BusinessException("未找到易拍活动"));
+//                User owner = userRepo.findById(order.getUserId())
+//                        .orElseThrow(new BusinessException("暂无用户"));
+//                assetService.createAsset(tradeAuction, owner, order.getId(), tradeAuction
+//                        .getCurrentPrice(), "空投", 1, false);
+//                order.setStatus(AuctionOrderStatus.FINISH);
+//                tradeAuctionOrderRepo.save(order);
+//            } catch (Exception e) {
+//                log.error("取消易拍订单错误 " + o.getId(), e);
+//            }
+//        });
+//    }
 
     @Scheduled(fixedRate = 30000)
     public void batchPayEarning() {

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

@@ -268,8 +268,10 @@ public class UserService {
     }
 
     public User phoneRegister(String phone, String code, String password, String inviteCode, Long invitor,
-                              Long collectionId, Long showroomId, InviteType inviteType) {
-        String name = "0x" + RandomStringUtils.randomAlphabetic(8);
+                              Long collectionId, Long showroomId, InviteType inviteType, String name) {
+        if (StringUtils.isBlank(name)) {
+            name = "0x" + RandomStringUtils.randomAlphabetic(8);
+        }
         Invite invite = null;
         if (StringUtils.isNotBlank(inviteCode)) {
             invite = inviteRepo.findFirstByCode(inviteCode).orElse(null);

+ 9 - 3
src/main/java/com/izouma/nineth/service/netease/NeteaseMessageService.java

@@ -8,6 +8,7 @@ import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.netease.NeteaseMessageRepo;
 import com.izouma.nineth.repo.UserRepo;
+import com.izouma.nineth.service.ContentAuditService;
 import com.izouma.nineth.utils.JpaUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.data.domain.Page;
@@ -20,9 +21,10 @@ import java.util.Map;
 @AllArgsConstructor
 public class NeteaseMessageService {
 
-    private NeteaseMessageRepo neteaseMessageRepo;
-    private NeteaseUserService neteaseUserService;
-    private UserRepo           userRepo;
+    private NeteaseMessageRepo  neteaseMessageRepo;
+    private NeteaseUserService  neteaseUserService;
+    private UserRepo            userRepo;
+    private ContentAuditService contentAuditService;
 
     public Page<NeteaseMessage> all(PageQuery pageQuery) {
         return neteaseMessageRepo
@@ -30,6 +32,10 @@ public class NeteaseMessageService {
     }
 
     public NeteaseMessage sendMessage(NeteaseMessage msg) {
+        boolean result1 = contentAuditService.auditText(msg.getBody());
+        if (!result1) {
+            throw new BusinessException("包含敏感词!");
+        }
         User from = userRepo.findById(Long.valueOf(msg.getFromId())).orElseThrow(new BusinessException("未找到用户"));
 //        User to = userRepo.findById(Long.valueOf(msg.getToId())).orElseThrow(new BusinessException("未找到用户"));
         msg.setFromAvatar(from.getAvatar());

+ 16 - 1
src/main/java/com/izouma/nineth/web/AuthenticationController.java

@@ -3,6 +3,7 @@ package com.izouma.nineth.web;
 import com.izouma.nineth.domain.User;
 import com.izouma.nineth.dto.MetaRestResult;
 import com.izouma.nineth.dto.MetaUserDTO;
+import com.izouma.nineth.dto.TouristDTO;
 import com.izouma.nineth.enums.AuthorityName;
 import com.izouma.nineth.enums.InviteType;
 import com.izouma.nineth.exception.AuthenticationException;
@@ -121,7 +122,16 @@ public class AuthenticationController {
     public String phonePwdLogin(String phone, String code, String password, String inviteCode, Long invitor,
                                 Long collectionId, Long showroomId, InviteType inviteType) {
         User user = userService
-                .phoneRegister(phone, code, password, inviteCode, invitor, collectionId, showroomId, inviteType);
+                .phoneRegister(phone, code, password, inviteCode, invitor, collectionId, showroomId, inviteType, null);
+        return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
+    }
+
+    @PostMapping("/meta/phoneRegister")
+    @ApiOperation(value = "元宇宙手机号密码注册")
+    public String metaPhonePwdLogin(String phone, String code, String password, String inviteCode, Long invitor,
+                                Long collectionId, Long showroomId, InviteType inviteType, String name) {
+        User user = userService
+                .phoneRegister(phone, code, password, inviteCode, invitor, collectionId, showroomId, inviteType, name);
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }
 
@@ -182,4 +192,9 @@ public class AuthenticationController {
         User user = userService.oneKeyLogin(umengKey, token);
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }
+
+    @GetMapping("/touristLogin")
+    public TouristDTO touristLogin() {
+        return new TouristDTO();
+    }
 }

+ 57 - 0
src/main/java/com/izouma/nineth/web/MetaConfigController.java

@@ -0,0 +1,57 @@
+package com.izouma.nineth.web;
+import com.alibaba.fastjson.JSONObject;
+import com.izouma.nineth.config.EventNames;
+import com.izouma.nineth.config.GeneralProperties;
+import com.izouma.nineth.domain.MetaConfig;
+import com.izouma.nineth.service.CacheService;
+import com.izouma.nineth.service.MetaConfigService;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.MetaConfigRepo;
+import com.izouma.nineth.utils.ObjUtils;
+import com.izouma.nineth.utils.excel.ExcelUtils;
+import lombok.AllArgsConstructor;
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
+import org.springframework.data.domain.Page;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+@RestController
+@RequestMapping("/metaConfig")
+@AllArgsConstructor
+public class MetaConfigController extends BaseController {
+    private MetaConfigService metaConfigService;
+    private MetaConfigRepo metaConfigRepo;
+    private RocketMQTemplate rocketMQTemplate;
+    private GeneralProperties generalProperties;
+    private CacheService cacheService;
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/save")
+    public MetaConfig save(@RequestBody MetaConfig record) {
+        record = metaConfigRepo.save(record);
+        cacheService.clearSysConfigGet();
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("name", EventNames.CONFIG_CHANGE);
+        JSONObject data = new JSONObject();
+        data.put("name", record.getName());
+        data.put("value", record.getValue());
+        jsonObject.put("data", data);
+        rocketMQTemplate.convertAndSend(generalProperties.getBroadcastEventTopic(), jsonObject);
+
+        return record;
+    }
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<MetaConfig> all(@RequestBody PageQuery pageQuery) {
+        return metaConfigService.all(pageQuery);
+    }
+
+}
+

+ 2 - 0
src/main/java/com/izouma/nineth/web/UserController.java

@@ -26,6 +26,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -431,6 +432,7 @@ public class UserController extends BaseController {
     }
 
     @GetMapping("/topTen")
+    @Cacheable(value = "userTopTen")
     public List<User> topTen() {
 
         LocalDateTime time = LocalDateTime.now().plusDays(-7);

+ 17 - 1
src/main/vue/src/router.js

@@ -1726,6 +1726,22 @@ const router = new Router({
                        title: '抽奖活动管理',
                     },
                },
+                {
+                    path: '/metaConfigEdit',
+                    name: 'MetaConfigEdit',
+                    component: () => import(/* webpackChunkName: "metaConfigEdit" */ '@/views/MetaConfigEdit.vue'),
+                    meta: {
+                        title: '元宇宙配置编辑',
+                    },
+                },
+                {
+                    path: '/metaConfigList',
+                    name: 'MetaConfigList',
+                    component: () => import(/* webpackChunkName: "metaConfigList" */ '@/views/MetaConfigList.vue'),
+                    meta: {
+                        title: '元宇宙配置',
+                    },
+                },
                 {
                     path: '/metaLuckyDrawAwardReceiveRecordList',
                     name: 'MetaLuckyDrawAwardReceiveRecordList',
@@ -1825,4 +1841,4 @@ router.beforeEach((to, from, next) => {
     }
 });
 
-export default router;
+export default router;

+ 120 - 0
src/main/vue/src/views/MetaConfigEdit.vue

@@ -0,0 +1,120 @@
+<template>
+    <div class="edit-view">
+        <page-title>
+            <el-button @click="$router.go(-1)" :disabled="saving">取消</el-button>
+            <el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id">
+                删除
+            </el-button>
+            <el-button @click="onSave" :loading="saving" type="primary">保存</el-button>
+        </page-title>
+        <div class="edit-view__content-wrapper">
+            <div class="edit-view__content-section">
+                <el-form :model="formData" :rules="rules" ref="form" label-width="74px" label-position="right"
+                         size="small"
+                         style="max-width: 500px;">
+                        <el-form-item prop="name" label="名称">
+                                    <el-input v-model="formData.name"></el-input>
+                        </el-form-item>
+                        <el-form-item prop="desc" label="描述">
+                                    <el-input v-model="formData.desc"></el-input>
+                        </el-form-item>
+                        <el-form-item prop="value" label="值">
+                                    <el-input v-model="formData.value"></el-input>
+                        </el-form-item>
+                        <el-form-item prop="type" label="type">
+                                    <el-select v-model="formData.type" clearable filterable placeholder="请选择">
+                                        <el-option
+                                                v-for="item in typeOptions"
+                                                :key="item.value"
+                                                :label="item.label"
+                                                :value="item.value">
+                                        </el-option>
+                                    </el-select>
+                        </el-form-item>
+                        <el-form-item prop="options" label="options">
+                                    <el-input v-model="formData.options"></el-input>
+                        </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">
+                            删除
+                        </el-button>
+                        <el-button @click="$router.go(-1)" :disabled="saving">取消</el-button>
+                    </el-form-item>
+                </el-form>
+            </div>
+        </div>
+    </div>
+</template>
+<script>
+    export default {
+        name: 'MetaConfigEdit',
+        created() {
+            if (this.$route.query.id) {
+                this.$http
+                    .get('metaConfig/get/' + this.$route.query.id)
+                    .then(res => {
+                        this.formData = res;
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.$message.error(e.error);
+                    });
+            }
+        },
+        data() {
+            return {
+                saving: false,
+                formData: {
+                },
+                rules: {
+                },
+                typeOptions: [{"label":"STRING","value":"STRING"},{"label":"TIME","value":"TIME"},{"label":"DATE","value":"DATE"},{"label":"DATETIME","value":"DATETIME"},{"label":"BOOLEAN","value":"BOOLEAN"},{"label":"NUMBER","value":"NUMBER"},{"label":"FILE","value":"FILE"},{"label":"SELECT","value":"SELECT"}],
+            }
+        },
+        methods: {
+            onSave() {
+                this.$refs.form.validate((valid) => {
+                    if (valid) {
+                        this.submit();
+                    } else {
+                        return false;
+                    }
+                });
+            },
+            submit() {
+                let data = {...this.formData};
+
+                this.saving = true;
+                this.$http
+                    .post('/metaConfig/save', data, {body: 'json'})
+                    .then(res => {
+                        this.saving = false;
+                        this.$message.success('成功');
+                        this.$router.go(-1);
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.saving = false;
+                        this.$message.error(e.error);
+                    });
+            },
+            onDelete() {
+                this.$confirm('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
+                    return this.$http.post(`/metaConfig/del/${this.formData.id}`)
+                }).then(() => {
+                    this.$message.success('删除成功');
+                    this.$router.go(-1);
+                }).catch(e => {
+                    if (e !== 'cancel') {
+                        console.log(e);
+                        this.$message.error((e || {}).error || '删除失败');
+                    }
+                })
+            },
+        }
+    }
+</script>
+<style lang="less" scoped></style>

+ 402 - 0
src/main/vue/src/views/MetaConfigList.vue

@@ -0,0 +1,402 @@
+<template>
+    <div class="list-view">
+        <div class="filters-container">
+            <el-button @click="editRow()" type="primary" icon="el-icon-plus" class="filter-item">添加 </el-button>
+        </div>
+        <el-table
+            :data="filterList"
+            row-key="id"
+            ref="table"
+            header-row-class-name="table-header-row"
+            header-cell-class-name="table-header-cell"
+            row-class-name="table-row"
+            cell-class-name="table-cell"
+            :height="tableHeight"
+        >
+            <el-table-column prop="name" label="名称"> </el-table-column>
+            <el-table-column prop="desc" label="描述"> </el-table-column>
+            <el-table-column prop="type" label="类型" :formatter="typeFormatter"></el-table-column>
+            <el-table-column prop="value" label="值" show-overflow-tooltip> </el-table-column>
+            <el-table-column label="操作" align="center" fixed="right" width="150">
+                <template slot-scope="{ row }">
+                    <el-button @click="editRow(row, true)" type="primary" size="mini" plain>编辑</el-button>
+                </template>
+            </el-table-column>
+        </el-table>
+        <div class="pagination-wrapper"></div>
+
+        <el-dialog :visible.sync="showDialog" width="500px" title="编辑设置" :close-on-click-modal="false">
+            <el-form :model="formData" :rules="rules" ref="form" label-width="52px" label-position="right" size="small">
+                <el-form-item prop="name" label="名称">
+                    <el-input v-model="formData.name" :disabled="edit === true"></el-input>
+                </el-form-item>
+                <el-form-item prop="desc" label="描述">
+                    <el-input v-model="formData.desc"></el-input>
+                </el-form-item>
+                <el-form-item prop="type" label="类型">
+                    <el-select v-model="formData.type" placeholder="请选择" :disabled="edit === true">
+                        <el-option
+                            v-for="item in valueTypes"
+                            :label="item.label"
+                            :value="item.value"
+                            :key="item.value"
+                        ></el-option>
+                    </el-select>
+                </el-form-item>
+                <el-form-item prop="value" label="值">
+                    <el-input v-model="formData.value" v-if="formData.type === 'STRING'"></el-input>
+                    <!-- <el-date-picker
+                        v-model="formData.value"
+                        v-if="formData.type === 'DATETIME'"
+                        type="datetime"
+                        value-format="yyyy-MM-dd HH:mm:ss"
+                        placeholder="请选择日期时间"
+                    ></el-date-picker>
+                    <el-date-picker
+                        v-model="formData.value"
+                        v-if="formData.type === 'DATE'"
+                        type="date"
+                        value-format="yyyy-MM-dd"
+                        placeholder="请选择日期"
+                    ></el-date-picker>
+                    <el-time-picker
+                        v-model="formData.value"
+                        v-if="formData.type === 'TIME'"
+                        value-format="HH:mm"
+                        placeholder="请选择时间"
+                        arrow-control
+                    ></el-time-picker> -->
+                    <!-- <el-switch
+                        v-model="formData.value"
+                        v-if="formData.type === 'BOOLEAN'"
+                        active-text="是"
+                        inactive-text="否"
+                        active-value="1"
+                        inactive-value="0"
+                    ></el-switch>
+                    <el-select v-if="formData.type === 'SELECT'" v-model="formData.value">
+                        <el-option
+                            v-for="item in formData.options.split(',')"
+                            :key="item"
+                            :label="item"
+                            :value="item"
+                        ></el-option>
+                    </el-select> -->
+                    <el-input-number v-model="formData.value" v-if="formData.type === 'NUMBER'"></el-input-number>
+                    <file-upload v-model="formData.value" v-if="formData.type === 'FILE'" :limit="1"></file-upload>
+                </el-form-item>
+            </el-form>
+            <span slot="footer">
+                <el-button type="primary" size="mini" @click="save" :loading="saving">保存</el-button>
+            </span>
+        </el-dialog>
+
+        <el-dialog title="支付选项" :visible.sync="showPayConfigDialog" width="800px">
+            <div class="pay-config-item-list">
+                <div class="pay-config-item head">
+                    <div class="key">KEY</div>
+                    <div class="name">名称</div>
+                    <div class="icon">图标</div>
+                    <div class="show">显示</div>
+                    <div class="enabled">可用</div>
+                    <div class="sort">排序</div>
+                </div>
+                <div class="pay-config-item" v-for="item in payConfig">
+                    <div class="key">
+                        <el-input v-model="item.key" size="mini"></el-input>
+                    </div>
+                    <div class="name">
+                        <el-input v-model="item.name" size="mini"></el-input>
+                    </div>
+                    <div class="icon">
+                        <el-image
+                            @click="addIcon(item)"
+                            :src="item.icon"
+                            v-if="item.icon"
+                            fit="contain"
+                            style="width: 26px; height: 26px"
+                        ></el-image>
+                        <el-button v-else type="text" @click="addIcon(item)">上传</el-button>
+                    </div>
+                    <div class="show">
+                        <el-checkbox v-model="item.show"></el-checkbox>
+                    </div>
+                    <div class="enabled">
+                        <el-checkbox v-model="item.enabled"></el-checkbox>
+                    </div>
+                    <div class="sort">
+                        <el-input-number v-model="item.sort" :controls="false"></el-input-number>
+                    </div>
+                </div>
+            </div>
+            <el-button @click="addPayConfig" size="mini">添加 </el-button>
+            <div slot="footer">
+                <el-button @click="showPayConfigDialog = false" size="mini">取消</el-button>
+                <el-button @click="savePayConfig" size="mini" type="primary" :loading="saving">保存</el-button>
+            </div>
+        </el-dialog>
+    </div>
+</template>
+<script>
+import { mapState } from 'vuex';
+import pageableTable from '@/mixins/pageableTable';
+
+export default {
+    name: 'MetaConfigList',
+    mixins: [pageableTable],
+    data() {
+        return {
+            multipleMode: false,
+            search: '',
+            url: '/metaConfig/all',
+            downloading: false,
+            formData: {
+                name: '',
+                desc: '',
+                value: '',
+                type: 'STRING'
+            },
+            rules: {
+                name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
+                desc: [{ required: true, message: '请输入描述', trigger: 'blur' }],
+                type: [{ required: true, message: '请选择类型', trigger: 'blur' }],
+                value: [{ required: true, message: '请输入值', trigger: 'blur' }]
+            },
+            showDialog: false,
+            saving: false,
+            edit: false,
+            sortStr: 'createdAt,desc',
+            valueTypes: [
+                {
+                    label: '字符串',
+                    value: 'STRING'
+                }
+                // {
+                //     label: '日期时间',
+                //     value: 'DATETIME'
+                // },
+                // {
+                //     label: '日期',
+                //     value: 'DATE'
+                // },
+                // {
+                //     label: '时间',
+                //     value: 'TIME'
+                // },
+                // {
+                //     label: '开关',
+                //     value: 'BOOLEAN'
+                // },
+                // {
+                //     label: '数字',
+                //     value: 'NUMBER'
+                // },
+                // {
+                //     label: '文件',
+                //     value: 'FILE'
+                // },
+                // {
+                //     label: '选择',
+                //     value: 'SELECT'
+                // }
+            ],
+            htmlContents: [''],
+            showPayConfigDialog: false,
+            payConfig: []
+        };
+    },
+    computed: {
+        selection() {
+            return this.$refs.table.selection.map(i => i.id);
+        },
+        filterList() {
+            if (this.search) {
+                return this.tableData.filter(i => i.name.indexOf(this.search) > -1 || i.desc.indexOf(this.search) > -1);
+            } else {
+                return this.tableData;
+            }
+        }
+    },
+    methods: {
+        beforeGetData() {
+            return { sort: 'createdAt,desc', size: 10000 };
+        },
+        toggleMultipleMode(multipleMode) {
+            this.multipleMode = multipleMode;
+            if (!multipleMode) {
+                this.$refs.table.clearSelection();
+            }
+        },
+        addRow() {
+            this.$router.push({
+                path: '/metaConfigEdit',
+                query: {
+                    ...this.$route.query
+                }
+            });
+        },
+        editRow(row, edit) {
+            if (row && row.name === 'pay_config') {
+                if (row.value) {
+                    this.payConfig = JSON.parse(row.value).sort((a, b) => {
+                        return a.sort - b.sort;
+                    });
+                }
+                this.formData = { ...row };
+                this.showPayConfigDialog = true;
+                return;
+            }
+            this.edit = edit;
+            if (!row) {
+                row = {
+                    name: '',
+                    desc: '',
+                    value: '',
+                    type: null
+                };
+            }
+            this.formData = { ...row };
+            this.showDialog = true;
+        },
+        // download() {
+        //     this.downloading = true;
+        //     this.$axios
+        //         .get('/metaConfig/excel', {
+        //             responseType: 'blob',
+        //             params: { size: 10000 }
+        //         })
+        //         .then(res => {
+        //             console.log(res);
+        //             this.downloading = false;
+        //             const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+        //             const link = document.createElement('a');
+        //             link.href = downloadUrl;
+        //             link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+        //             document.body.appendChild(link);
+        //             link.click();
+        //             link.remove();
+        //         })
+        //         .catch(e => {
+        //             console.log(e);
+        //             this.downloading = false;
+        //             this.$message.error(e.error);
+        //         });
+        // },
+        save() {
+            this.$refs.form.validate(valid => {
+                if (valid) {
+                    let data = { ...this.formData };
+                    this.saving = true;
+                    this.$http
+                        .post('/metaConfig/save', data, { body: 'json' })
+                        .then(res => {
+                            this.saving = false;
+                            this.$message.success('成功');
+                            this.showDialog = false;
+                            this.getData();
+                        })
+                        .catch(e => {
+                            console.log(e);
+                            this.saving = false;
+                            this.showDialog = false;
+                            this.$message.error(e.error);
+                        });
+                } else {
+                    return false;
+                }
+            });
+        },
+        typeFormatter(row, cell, cellValue) {
+            let item = this.valueTypes.find(i => i.value === cellValue);
+            return item ? item.label : '';
+        },
+        addPayConfig() {
+            this.payConfig.push({
+                name: '',
+                icon: '',
+                show: false,
+                enabled: false,
+                description: '',
+                sort: 0
+            });
+        },
+        savePayConfig() {
+            let data = { ...this.formData, value: JSON.stringify(this.payConfig) };
+            this.saving = true;
+            this.$http
+                .post('/metaConfig/save', data, { body: 'json' })
+                .then(res => {
+                    this.saving = false;
+                    this.$message.success('成功');
+                    this.showPayConfigDialog = false;
+                    this.getData();
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.saving = false;
+                    this.showPayConfigDialog = false;
+                    this.$message.error(e.error);
+                });
+        },
+        addIcon(item) {
+            const input = document.createElement('input');
+            input.type = 'file';
+            input.accept = 'image/*';
+            input.onchange = e => {
+                console.log(input.files[0]);
+                let form = new FormData();
+                form.append('file', input.files[0]);
+                this.$axios.post('/upload/file', form).then(res => {
+                    this.$set(item, 'icon', res.data);
+                });
+            };
+            input.click();
+        }
+    }
+};
+</script>
+<style lang="less" scoped>
+.pay-config-item-list {
+    .pay-config-item {
+        margin-bottom: 6px;
+        .flex();
+        font-size: 14px;
+        .key {
+            width: 150px;
+        }
+        .name {
+            margin-left: 20px;
+            width: 150px;
+        }
+        .icon {
+            width: 50px;
+            margin-left: 10px;
+            font-size: 0;
+            text-align: center;
+        }
+        .show {
+            width: 50px;
+            margin-left: 10px;
+            text-align: center;
+        }
+        .enabled {
+            width: 50px;
+            margin-left: 10px;
+            text-align: center;
+        }
+        .sort {
+            width: 80px;
+            margin-left: 10px;
+            text-align: center;
+            .el-input-number {
+                width: 60px;
+            }
+        }
+        &.head {
+            .icon {
+                font-size: 14px;
+            }
+        }
+    }
+}
+</style>

+ 1 - 1
src/test/java/com/izouma/nineth/service/UserServiceTest.java

@@ -150,7 +150,7 @@ public class UserServiceTest extends ApplicationTests {
     @Test
     public void phoneRegister() {
         userService.phoneRegister("18100004444", "1234", "123456", null, 9972L,
-                206925L, null, InviteType.NORMAL);
+                206925L, null, InviteType.NORMAL, null);
     }
 
     @Test