Browse Source

不能购买自己的藏品

xiongzhu 4 years ago
parent
commit
7659844b38
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/main/java/com/izouma/nineth/service/OrderService.java

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

@@ -179,8 +179,11 @@ public class OrderService {
             if (collection.getAssetId() != null && collection.getAssetId().equals(778359L)) {
             if (collection.getAssetId() != null && collection.getAssetId().equals(778359L)) {
                 throw new BusinessException("很遗憾,藏品已售罄", ErrorCode.SOLD_OUT);
                 throw new BusinessException("很遗憾,藏品已售罄", ErrorCode.SOLD_OUT);
             }
             }
-            if (collection.getAssetId() != null) {
+            if (collection.getSource() == CollectionSource.TRANSFER) {
                 Asset asset = assetRepo.findById(collection.getAssetId()).orElseThrow(new BusinessException("藏品不存在"));
                 Asset asset = assetRepo.findById(collection.getAssetId()).orElseThrow(new BusinessException("藏品不存在"));
+                if (Objects.equals(asset.getUserId(), userId)) {
+                    throw new BusinessException("不能购买自己的藏品");
+                }
                 if (asset.getStatus() != AssetStatus.NORMAL) {
                 if (asset.getStatus() != AssetStatus.NORMAL) {
                     throw new BusinessException("藏品已下架");
                     throw new BusinessException("藏品已下架");
                 }
                 }