Bläddra i källkod

不能购买自己的藏品

xiongzhu 4 år sedan
förälder
incheckning
7659844b38
1 ändrade filer med 4 tillägg och 1 borttagningar
  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)) {
                 throw new BusinessException("很遗憾,藏品已售罄", ErrorCode.SOLD_OUT);
             }
-            if (collection.getAssetId() != null) {
+            if (collection.getSource() == CollectionSource.TRANSFER) {
                 Asset asset = assetRepo.findById(collection.getAssetId()).orElseThrow(new BusinessException("藏品不存在"));
+                if (Objects.equals(asset.getUserId(), userId)) {
+                    throw new BusinessException("不能购买自己的藏品");
+                }
                 if (asset.getStatus() != AssetStatus.NORMAL) {
                     throw new BusinessException("藏品已下架");
                 }