|
@@ -65,6 +65,7 @@ public class DomainOrderService {
|
|
|
private RockRecordService rockRecordService;
|
|
private RockRecordService rockRecordService;
|
|
|
private AssetRepo assetRepo;
|
|
private AssetRepo assetRepo;
|
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
+ private CacheService cacheService;
|
|
|
|
|
|
|
|
public Page<DomainOrder> all(PageQuery pageQuery) {
|
|
public Page<DomainOrder> all(PageQuery pageQuery) {
|
|
|
return domainOrderRepo
|
|
return domainOrderRepo
|
|
@@ -151,45 +152,52 @@ public class DomainOrderService {
|
|
|
return domainOrderRepo.save(domainOrder);
|
|
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);
|
|
|
|
|
|
|
+ public void increaseCount(Long userId, Integer usePoint) {
|
|
|
|
|
+ if (usePoint > 0) {
|
|
|
|
|
+ // 扣除积分
|
|
|
|
|
+ userRepo.addVipPoint(userId, -usePoint);
|
|
|
|
|
+ cacheService.clearUserMy(userId);
|
|
|
}
|
|
}
|
|
|
- ops.increment(count);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void decreaseCount(Long userId) {
|
|
|
|
|
- increaseCount(userId, -1);
|
|
|
|
|
|
|
+ public void decreaseCount(DomainOrder order) {
|
|
|
|
|
+ userRepo.addVipPoint(order.getUserId(), 1);
|
|
|
|
|
+ cacheService.clearUserMy(order.getUserId());
|
|
|
|
|
+ log.info("取消加积分用户ID:{},订单ID:{},积分:{}", order.getUserId(), order.getId(), 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public AtomicBoolean checkPoint(Long userId) {
|
|
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);
|
|
|
|
|
|
|
+ AtomicBoolean atomicBoolean = new AtomicBoolean(false);
|
|
|
|
|
+ User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
|
|
+ if (user.getVipPoint() > 0) {
|
|
|
|
|
+ atomicBoolean.set(true);
|
|
|
}
|
|
}
|
|
|
- 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;
|
|
|
|
|
|
|
+ return atomicBoolean;
|
|
|
|
|
+// 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 > 0) {
|
|
|
|
|
+// vipPoint.set(true);
|
|
|
|
|
+// }
|
|
|
|
|
+// } else {
|
|
|
|
|
+// vipPoint.set(false);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+// return vipPoint;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public Map<String, Object> check(String domain) {
|
|
public Map<String, Object> check(String domain) {
|
|
@@ -317,7 +325,7 @@ public class DomainOrderService {
|
|
|
domainOrder.setOrderStatus(OrderStatus.CANCELLED);
|
|
domainOrder.setOrderStatus(OrderStatus.CANCELLED);
|
|
|
domainOrder.setStatus(CollectionStatus.FAIL);
|
|
domainOrder.setStatus(CollectionStatus.FAIL);
|
|
|
if (domainOrder.getPicName().length() < 5) {
|
|
if (domainOrder.getPicName().length() < 5) {
|
|
|
- decreaseCount(domainOrder.getUserId());
|
|
|
|
|
|
|
+ decreaseCount(domainOrder);
|
|
|
}
|
|
}
|
|
|
domainOrderRepo.save(domainOrder);
|
|
domainOrderRepo.save(domainOrder);
|
|
|
}
|
|
}
|