|
|
|
@ -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<ListUserAdDTO> 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 |
|
|
|
|