|
|
@@ -2,7 +2,6 @@ package com.izouma.nineth.service;
|
|
|
|
|
|
import com.izouma.nineth.domain.Asset;
|
|
|
import com.izouma.nineth.domain.AssetSuperimposition;
|
|
|
-import com.izouma.nineth.domain.Collection;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.enums.AssetOperationType;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
@@ -35,15 +34,11 @@ public class AssetSuperimpositionService {
|
|
|
/**
|
|
|
* 调整各操作藏品叠加的数量信息
|
|
|
*
|
|
|
- * @param asset 资产信息
|
|
|
- * @param type 操作类型
|
|
|
- * @param relatedUserId 相关用户id(买入人,被赠送人)
|
|
|
+ * @param asset 资产信息
|
|
|
+ * @param type 操作类型
|
|
|
+ * @param toUserId 相关用户id(买入人,被赠送人)
|
|
|
*/
|
|
|
- public void adjustNum(Asset asset, AssetOperationType type, Long relatedUserId) {
|
|
|
- Collection collection = null;
|
|
|
- if (Objects.nonNull(asset.getCollectionId())) {
|
|
|
- collection = collectionRepo.findById(asset.getCollectionId()).orElseThrow(new BusinessException("没有该藏品信息"));
|
|
|
- }
|
|
|
+ public void adjustNum(Asset asset, AssetOperationType type, Long toUserId) {
|
|
|
if (Objects.isNull(type)) {
|
|
|
throw new BusinessException("操作类型不能为空");
|
|
|
}
|
|
|
@@ -55,7 +50,7 @@ public class AssetSuperimpositionService {
|
|
|
}
|
|
|
AssetSuperimposition assetSuperimposition = assetSuperimpositionRepo.findByUserIdAndPrefixName(asset.getUserId(), asset.getPrefixName()).orElse(null);
|
|
|
if (Objects.isNull(assetSuperimposition)) {
|
|
|
- assetSuperimposition = AssetSuperimposition.create(collection, asset.getUserId());
|
|
|
+ assetSuperimposition = AssetSuperimposition.create(asset, asset.getUserId());
|
|
|
}
|
|
|
switch (type) {
|
|
|
case OPEN:
|
|
|
@@ -86,7 +81,7 @@ public class AssetSuperimpositionService {
|
|
|
log.info("调整数量 -> 转让成功");
|
|
|
assetSuperimposition.setNum(assetSuperimposition.getNum() - NUM);
|
|
|
assetSuperimposition.setConsignmentNum(assetSuperimposition.getConsignmentNum() - NUM);
|
|
|
- relatedUserAdjustNum(relatedUserId, asset.getPrefixName(), collection);
|
|
|
+ relatedUserAdjustNum(toUserId, asset.getPrefixName(), asset);
|
|
|
break;
|
|
|
case AUCTIONING:
|
|
|
log.info("调整数量 -> 拍卖");
|
|
|
@@ -101,13 +96,13 @@ public class AssetSuperimpositionService {
|
|
|
assetSuperimposition.setNum(assetSuperimposition.getNum() - NUM);
|
|
|
assetSuperimposition.setAuctioningNum(assetSuperimposition.getAuctionedNum() - NUM);
|
|
|
publicShowOrFalseReduce(assetSuperimposition, asset);
|
|
|
- relatedUserAdjustNum(relatedUserId, asset.getPrefixName(), collection);
|
|
|
+ relatedUserAdjustNum(toUserId, asset.getPrefixName(), asset);
|
|
|
break;
|
|
|
case GIFTING:
|
|
|
log.info("调整数量 -> 赠送");
|
|
|
assetSuperimposition.setNum(assetSuperimposition.getNum() - NUM);
|
|
|
publicShowOrFalseReduce(assetSuperimposition, asset);
|
|
|
- relatedUserAdjustNum(relatedUserId, asset.getPrefixName(), collection);
|
|
|
+ relatedUserAdjustNum(toUserId, asset.getPrefixName(), asset);
|
|
|
break;
|
|
|
case BUY:
|
|
|
log.info("调整数量 -> 购买");
|
|
|
@@ -156,17 +151,17 @@ public class AssetSuperimpositionService {
|
|
|
/**
|
|
|
* 相关用户藏品叠加数量(买入人,被转增人等)
|
|
|
*
|
|
|
- * @param relatedUserId 相关用户id
|
|
|
- * @param prefixName 叠加分类
|
|
|
- * @param collection 藏品信息
|
|
|
+ * @param toUserId 相关用户id
|
|
|
+ * @param prefixName 叠加分类
|
|
|
+ * @param asset 资产信息
|
|
|
*/
|
|
|
- private void relatedUserAdjustNum(Long relatedUserId, String prefixName, Collection collection) {
|
|
|
- if (Objects.isNull(relatedUserId)) {
|
|
|
+ private void relatedUserAdjustNum(Long toUserId, String prefixName, Asset asset) {
|
|
|
+ if (Objects.isNull(toUserId)) {
|
|
|
throw new BusinessException("涉及相关用户id为空");
|
|
|
}
|
|
|
- AssetSuperimposition assetSuperimposition = assetSuperimpositionRepo.findByUserIdAndPrefixName(relatedUserId, prefixName).orElse(null);
|
|
|
+ AssetSuperimposition assetSuperimposition = assetSuperimpositionRepo.findByUserIdAndPrefixName(toUserId, prefixName).orElse(null);
|
|
|
if (Objects.isNull(assetSuperimposition)) {
|
|
|
- assetSuperimposition = AssetSuperimposition.create(collection, relatedUserId);
|
|
|
+ assetSuperimposition = AssetSuperimposition.create(asset, toUserId);
|
|
|
}
|
|
|
assetSuperimposition.setNum(assetSuperimposition.getNum() + NUM);
|
|
|
assetSuperimposition.setCloseShowNum(assetSuperimposition.getCloseShowNum() + NUM);
|