|
@@ -774,29 +774,32 @@ public class AssetService {
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 0 0/1 * * ?")
|
|
@Scheduled(cron = "0 0 0/1 * * ?")
|
|
|
public void offTheShelfAll() {
|
|
public void offTheShelfAll() {
|
|
|
- LocalDateTime lastTime = LocalDateTime.now().minusHours(240);
|
|
|
|
|
|
|
+ LocalDateTime lastTime = LocalDateTime.now().minusDays(10);
|
|
|
Set<Long> assetIds = collectionRepo
|
|
Set<Long> assetIds = collectionRepo
|
|
|
- .findResaleCollectionPriceOver20K(BigDecimal
|
|
|
|
|
- .valueOf(0L), CollectionSource.TRANSFER, lastTime, true);
|
|
|
|
|
|
|
+ .findResaleCollectionOverTime(lastTime);
|
|
|
assetIds.forEach(this::cancelConsignmentBySystem);
|
|
assetIds.forEach(this::cancelConsignmentBySystem);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
public void cancelConsignmentBySystem(Long id) {
|
|
public void cancelConsignmentBySystem(Long id) {
|
|
|
- Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
|
|
- if (asset.getPublicCollectionId() != null) {
|
|
|
|
|
- List<Order> orders = orderRepo.findByCollectionId(asset.getPublicCollectionId());
|
|
|
|
|
- if (orders.stream().anyMatch(o -> o.getStatus() != OrderStatus.CANCELLED)) {
|
|
|
|
|
- throw new BusinessException("已有订单不可取消");
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
|
|
+ if (asset.getPublicCollectionId() != null) {
|
|
|
|
|
+ List<Order> orders = orderRepo.findByCollectionId(asset.getPublicCollectionId());
|
|
|
|
|
+ if (orders.stream().anyMatch(o -> o.getStatus() != OrderStatus.CANCELLED)) {
|
|
|
|
|
+ throw new BusinessException("已有订单不可取消");
|
|
|
|
|
+ }
|
|
|
|
|
+ collectionRepo.findById(asset.getPublicCollectionId())
|
|
|
|
|
+ .ifPresent(collection -> {
|
|
|
|
|
+ collection.setSalable(false);
|
|
|
|
|
+ collectionRepo.save(collection);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- collectionRepo.findById(asset.getPublicCollectionId())
|
|
|
|
|
- .ifPresent(collection -> {
|
|
|
|
|
- collection.setSalable(false);
|
|
|
|
|
- collectionRepo.save(collection);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ asset.setConsignment(false);
|
|
|
|
|
+ assetRepo.saveAndFlush(asset);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.info("自动下架报错,assetId:" + id);
|
|
|
}
|
|
}
|
|
|
- asset.setConsignment(false);
|
|
|
|
|
- assetRepo.saveAndFlush(asset);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// @Cacheable(cacheNames = "fmaa", key = "#userId+'#'+#mintActivityId+'#'+#pageable.hashCode()")
|
|
// @Cacheable(cacheNames = "fmaa", key = "#userId+'#'+#mintActivityId+'#'+#pageable.hashCode()")
|
|
@@ -813,16 +816,16 @@ public class AssetService {
|
|
|
if (tags.isEmpty()) return new PageImpl<>(Collections.emptyList());
|
|
if (tags.isEmpty()) return new PageImpl<>(Collections.emptyList());
|
|
|
return assetRepo.findAll((Specification<Asset>) (root, query, criteriaBuilder) ->
|
|
return assetRepo.findAll((Specification<Asset>) (root, query, criteriaBuilder) ->
|
|
|
query.distinct(true).where(
|
|
query.distinct(true).where(
|
|
|
- // where userId=some id
|
|
|
|
|
- criteriaBuilder.equal(root.get("userId"), userId),
|
|
|
|
|
- // and (lockTo is null or (lockTo is not null and lockTo < now))
|
|
|
|
|
- criteriaBuilder.or(criteriaBuilder.isNull(root.get("lockTo")),
|
|
|
|
|
- criteriaBuilder.and(criteriaBuilder.isNotNull(root.get("lockTo")),
|
|
|
|
|
- criteriaBuilder.lessThan(root.get("lockTo"), LocalDateTime.now()))),
|
|
|
|
|
- // and status = 'NORMAL'
|
|
|
|
|
- criteriaBuilder.equal(root.get("status"), AssetStatus.NORMAL),
|
|
|
|
|
- // and has some tagId
|
|
|
|
|
- root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
|
|
|
|
|
|
|
+ // where userId=some id
|
|
|
|
|
+ criteriaBuilder.equal(root.get("userId"), userId),
|
|
|
|
|
+ // and (lockTo is null or (lockTo is not null and lockTo < now))
|
|
|
|
|
+ criteriaBuilder.or(criteriaBuilder.isNull(root.get("lockTo")),
|
|
|
|
|
+ criteriaBuilder.and(criteriaBuilder.isNotNull(root.get("lockTo")),
|
|
|
|
|
+ criteriaBuilder.lessThan(root.get("lockTo"), LocalDateTime.now()))),
|
|
|
|
|
+ // and status = 'NORMAL'
|
|
|
|
|
+ criteriaBuilder.equal(root.get("status"), AssetStatus.NORMAL),
|
|
|
|
|
+ // and has some tagId
|
|
|
|
|
+ root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
|
|
|
.getRestriction(), pageable);
|
|
.getRestriction(), pageable);
|
|
|
} else {
|
|
} else {
|
|
|
return assetRepo.findByUserIdAndStatusAndNameLike(userId, AssetStatus.NORMAL,
|
|
return assetRepo.findByUserIdAndStatusAndNameLike(userId, AssetStatus.NORMAL,
|
|
@@ -830,7 +833,7 @@ public class AssetService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void destroy(Long id, Long userId ,String tradeCode) {
|
|
|
|
|
|
|
+ public void destroy(Long id, Long userId, String tradeCode) {
|
|
|
Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
if (!asset.getUserId().equals(userId)) {
|
|
if (!asset.getUserId().equals(userId)) {
|
|
|
throw new BusinessException("此藏品不属于你");
|
|
throw new BusinessException("此藏品不属于你");
|
|
@@ -843,7 +846,7 @@ public class AssetService {
|
|
|
// cancelPublic(asset);
|
|
// cancelPublic(asset);
|
|
|
}
|
|
}
|
|
|
User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
- if (StringUtils.isEmpty(user.getTradeCode())){
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(user.getTradeCode())) {
|
|
|
throw new BusinessException("未设置交易密码");
|
|
throw new BusinessException("未设置交易密码");
|
|
|
}
|
|
}
|
|
|
if (!passwordEncoder.matches(tradeCode, user.getTradeCode())) {
|
|
if (!passwordEncoder.matches(tradeCode, user.getTradeCode())) {
|
|
@@ -886,6 +889,7 @@ public class AssetService {
|
|
|
//加积分
|
|
//加积分
|
|
|
userRepo.addDestroyPoint(userId, 1);
|
|
userRepo.addDestroyPoint(userId, 1);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public double getRoyalties(Long minterId, double royalties, Long userId) {
|
|
public double getRoyalties(Long minterId, double royalties, Long userId) {
|
|
|
if (royalties == 2) {
|
|
if (royalties == 2) {
|
|
|
return 2;
|
|
return 2;
|
|
@@ -980,7 +984,7 @@ public class AssetService {
|
|
|
MetaPlayerRoleClassify metaPlayerRoleClassify = new MetaPlayerRoleClassify();
|
|
MetaPlayerRoleClassify metaPlayerRoleClassify = new MetaPlayerRoleClassify();
|
|
|
metaPlayerRoleClassify.setClassify(name);
|
|
metaPlayerRoleClassify.setClassify(name);
|
|
|
List<MetaPlayerRole> metaPlayerRoleList;
|
|
List<MetaPlayerRole> metaPlayerRoleList;
|
|
|
- if("MUGEN".equals(name)) {
|
|
|
|
|
|
|
+ if ("MUGEN".equals(name)) {
|
|
|
metaPlayerRoleList = Arrays.asList(new MetaPlayerRole(id, "无限集团"),
|
|
metaPlayerRoleList = Arrays.asList(new MetaPlayerRole(id, "无限集团"),
|
|
|
new MetaPlayerRole(id + 1, "苍茫雷道"),
|
|
new MetaPlayerRole(id + 1, "苍茫雷道"),
|
|
|
new MetaPlayerRole(id + 2, "炼炉天族"),
|
|
new MetaPlayerRole(id + 2, "炼炉天族"),
|
|
@@ -996,10 +1000,11 @@ public class AssetService {
|
|
|
return metaPlayerRoleClassify;
|
|
return metaPlayerRoleClassify;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private List<MetaPlayerRole> build (Long userId, List<MetaPlayerRole> metaPlayerRoleList) {
|
|
|
|
|
|
|
+ private List<MetaPlayerRole> build(Long userId, List<MetaPlayerRole> metaPlayerRoleList) {
|
|
|
metaPlayerRoleList.forEach(metaPlayerRole -> {
|
|
metaPlayerRoleList.forEach(metaPlayerRole -> {
|
|
|
metaPlayerRole.setType(UserHoldTypeEnum.ASSET);
|
|
metaPlayerRole.setType(UserHoldTypeEnum.ASSET);
|
|
|
- metaPlayerRole.setAddress("https://www.raex.vip/9th/productSearch?search=" + metaPlayerRole.getName() + "&source=TRANSFER");
|
|
|
|
|
|
|
+ metaPlayerRole.setAddress("https://www.raex.vip/9th/productSearch?search=" + metaPlayerRole
|
|
|
|
|
+ .getName() + "&source=TRANSFER");
|
|
|
List<Asset> assets = assetRepo.findAllByUserIdAndNameLike(userId, "%" + metaPlayerRole.getName() + "%");
|
|
List<Asset> assets = assetRepo.findAllByUserIdAndNameLike(userId, "%" + metaPlayerRole.getName() + "%");
|
|
|
metaPlayerRole.setHold(CollectionUtils.isNotEmpty(assets));
|
|
metaPlayerRole.setHold(CollectionUtils.isNotEmpty(assets));
|
|
|
});
|
|
});
|