From 1265510e43d993ffde7cbbb5580e5f7fae275e50 Mon Sep 17 00:00:00 2001 From: luzhaofeng <574317128@qq.com> Date: Tue, 5 Nov 2019 17:10:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=95=E5=B8=81=E6=A8=A1=E5=9D=97-=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=B8=82=E5=95=86=E6=97=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=B9=BF=E5=91=8A=E6=98=AF=E5=90=A6=E5=B7=B2?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E5=AE=8C=E7=BB=93=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/otc/common/enums/OtcEnums.java | 1 + .../server/otc/service/AdService.java | 2 +- .../service/impl/MarketApplyServiceImpl.java | 25 ++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/common/enums/OtcEnums.java b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/common/enums/OtcEnums.java index 6915203..f9ca476 100644 --- a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/common/enums/OtcEnums.java +++ b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/common/enums/OtcEnums.java @@ -67,6 +67,7 @@ public enum OtcEnums { MARKET_USER_NULL(8766, "您还不是商家,无法申请取消!", "You are not a marketer and cannot apply for cancellation!"), CANCEL_MARKET_USER_STATUS_ERROR(8767, "当前商家状态无法取消!", "The current market status cannot be cancelled!"), USER_IS_MRAKET(8768, "您已是商家,请勿重复操作!", "You are already a merchant, do not repeat the operation!"), + CANCEL_MARKET_AD_NO_NULL(8769, "操作失败,还有未完结广告!", "Operation failed, and there is an unfinished commercial!"), ; @Getter diff --git a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/AdService.java b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/AdService.java index e7abeca..dcdc8d5 100644 --- a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/AdService.java +++ b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/AdService.java @@ -39,7 +39,7 @@ public interface AdService { * @param userId * @param adId */ - void setAdToDefault(String userId,String adId); + void setAdToDefault(String userId, String adId); /*** * 查询交易大厅广告列表 diff --git a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/MarketApplyServiceImpl.java b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/MarketApplyServiceImpl.java index 758b03d..13ad188 100644 --- a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/MarketApplyServiceImpl.java +++ b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/MarketApplyServiceImpl.java @@ -1,11 +1,14 @@ package com.blockchain.server.otc.service.impl; import com.blockchain.common.base.dto.ResultDTO; +import com.blockchain.server.otc.common.constant.AdConstants; import com.blockchain.server.otc.common.constant.BillConstants; import com.blockchain.server.otc.common.constant.MarketApplyConstants; import com.blockchain.server.otc.common.constant.MarketUserConstants; import com.blockchain.server.otc.common.enums.OtcEnums; import com.blockchain.server.otc.common.exception.OtcException; +import com.blockchain.server.otc.dto.ad.ListUserAdDTO; +import com.blockchain.server.otc.entity.Ad; import com.blockchain.server.otc.entity.MarketApply; import com.blockchain.server.otc.entity.MarketFreeze; import com.blockchain.server.otc.entity.MarketUser; @@ -19,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.Date; +import java.util.List; import java.util.UUID; @Service @@ -37,6 +41,8 @@ public class MarketApplyServiceImpl implements MarketApplyService { @Autowired private BillService billService; @Autowired + private AdService adService; + @Autowired private UserFeign userFeign; //保证金固定为CNY @@ -113,7 +119,8 @@ public class MarketApplyServiceImpl implements MarketApplyService { if (!marketUser.getStatus().equals(MarketUserConstants.MARKET)) { throw new OtcException(OtcEnums.CANCEL_MARKET_USER_STATUS_ERROR); } - + //检查用户广告是否全部已完成或撤销 + checkAdWhenCancel(userId); //新建市商申请 String applyId = insertAgreeMarketApply(userId, MarketApplyConstants.CANCEL); @@ -189,6 +196,22 @@ public class MarketApplyServiceImpl implements MarketApplyService { } } + /*** + * 申请取消市商时,检查广告是否全部已完成或撤销 + * @param userId + */ + private void checkAdWhenCancel(String userId) { + //查询用户发布的广告列表 + List ads = adService.listUserAd(userId, null, null, + null, null, null, null); + //如果用户的广告列表有未完成或着未取消的广告,抛出异常 + for (ListUserAdDTO ad : ads) { + if (!ad.getAdStatus().equals(AdConstants.CANCEL) || !ad.getAdStatus().equals(AdConstants.FINISH)) { + throw new OtcException(OtcEnums.CANCEL_MARKET_AD_NO_NULL); + } + } + } + /*** * 新建状态为'已同意'的申请记录 * @param userId