|
@@ -8,8 +8,10 @@ import com.chelvc.cloud.vehicle.client.constant.MerchantApplyStatus;
|
|
|
import com.chelvc.cloud.vehicle.client.param.SxyNotifyParam;
|
|
|
import com.chelvc.cloud.vehicle.server.dao.MerchantApplyRecordMapper;
|
|
|
import com.chelvc.cloud.vehicle.server.entity.MerchantApplyRecord;
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.MerchantAuth;
|
|
|
import com.chelvc.cloud.vehicle.server.handle.TradeHandle;
|
|
|
import com.chelvc.cloud.vehicle.server.service.*;
|
|
|
+import com.chelvc.framework.common.exception.ResourceUnavailableException;
|
|
|
import com.chelvc.framework.common.function.Executor;
|
|
|
import com.chelvc.framework.database.context.DatabaseContextHolder;
|
|
|
import com.upay.sdk.Constants;
|
|
@@ -51,7 +53,13 @@ public class MerchantApplyRecordServiceImpl extends
|
|
|
wrapper.eq(MerchantApplyRecord::getRequestId, requestId);
|
|
|
MerchantApplyRecord record = baseMapper.selectOne(wrapper);
|
|
|
Integer recordStatus = record.getStatus();
|
|
|
- if(MerchantApplyStatus.SUCCESS.getStatus().equals(recordStatus)){
|
|
|
+ MerchantAuth merchantAuth = merchantAuthService.queryByUserId(record.getUserId());
|
|
|
+ if(merchantAuth == null){
|
|
|
+ log.error("商户号申请记录id【{}】查询商户认证信息为空", requestId);
|
|
|
+ return status;
|
|
|
+ }
|
|
|
+ if(MerchantApplyStatus.SUCCESS.getStatus().equals(recordStatus)
|
|
|
+ && String.valueOf(MerchantApplyStatus.SUCCESS.getStatus()).equals(merchantAuth.getReviewStatus())){
|
|
|
return MerchantApplyStatus.SUCCESS.getType();
|
|
|
}
|
|
|
String subMerchantId = responseData.getString("subMerchantId");
|
|
@@ -71,15 +79,27 @@ public class MerchantApplyRecordServiceImpl extends
|
|
|
baseMapper.updateById(record);
|
|
|
if(type == 1){
|
|
|
//更改个人认证状态
|
|
|
- userAuthService.updateStatus(record.getUserId(), resultStatus, merchantReviewRemarks);
|
|
|
+ int i = userAuthService.updateStatus(record.getUserId(), resultStatus, merchantReviewRemarks);
|
|
|
+ if(i != 1){
|
|
|
+ log.error("用户id【{}】更新认证状态【{}】失败", record.getUserId(), status);
|
|
|
+ throw new ResourceUnavailableException("用户id【{"+record.getUserId()+"}】更新认证状态【{"+status+"}】失败");
|
|
|
+ }
|
|
|
}
|
|
|
if(type == 2){
|
|
|
//更改商家认证状态
|
|
|
- merchantAuthService.updateStatus(record.getUserId(), resultStatus, merchantReviewRemarks);
|
|
|
+ int i = merchantAuthService.updateStatus(record.getUserId(), resultStatus, merchantReviewRemarks);
|
|
|
+ if(i != 1){
|
|
|
+ log.error("商家id【{}】更新认证状态【{}】失败", record.getUserId(), status);
|
|
|
+ throw new ResourceUnavailableException("商家id【{"+record.getUserId()+"}】更新认证状态【{"+status+"}】失败");
|
|
|
+ }
|
|
|
}
|
|
|
if("SUCCESS".equals(status)){
|
|
|
int i = merchantRelationService.insert(record.getUserId(), record.getType(), subMerchantId);
|
|
|
- if(i == 1 && record.getType() == 1){
|
|
|
+ if(i != 1){
|
|
|
+ log.error("商家id【{}】更新认证状态【{}】失败", record.getUserId(), status);
|
|
|
+ throw new ResourceUnavailableException("商家id【{"+record.getUserId()+"}】更新认证状态【{"+status+"}】失败");
|
|
|
+ }
|
|
|
+ if(record.getType() == 1){
|
|
|
//用户申请商户号成功,平台转账给用户
|
|
|
BigDecimal total = assetService.queryTotal(record.getUserId(), 1);
|
|
|
assetService.transfer(0L, record.getUserId(), 1, total, "0");
|
|
@@ -122,15 +142,27 @@ public class MerchantApplyRecordServiceImpl extends
|
|
|
baseMapper.updateById(record);
|
|
|
if(type == 1){
|
|
|
//更改个人认证状态
|
|
|
- userAuthService.updateStatus(record.getUserId(), resultStatus, errorMessage);
|
|
|
+ int i = userAuthService.updateStatus(record.getUserId(), resultStatus, errorMessage);
|
|
|
+ if(i != 1){
|
|
|
+ log.error("用户id【{}】更新认证状态【{}】失败", record.getUserId(), status);
|
|
|
+ throw new ResourceUnavailableException("用户id【{"+record.getUserId()+"}】更新认证状态【{"+status+"}】失败");
|
|
|
+ }
|
|
|
}
|
|
|
if(type == 2){
|
|
|
//更改商家认证状态
|
|
|
- merchantAuthService.updateStatus(record.getUserId(), resultStatus, errorMessage);
|
|
|
+ int i = merchantAuthService.updateStatus(record.getUserId(), resultStatus, errorMessage);
|
|
|
+ if(i != 1){
|
|
|
+ log.error("商家id【{}】更新认证状态【{}】失败", record.getUserId(), status);
|
|
|
+ throw new ResourceUnavailableException("商家id【{"+record.getUserId()+"}】更新认证状态【{"+status+"}】失败");
|
|
|
+ }
|
|
|
}
|
|
|
if("SUCCESS".equals(status)){
|
|
|
int i = merchantRelationService.insert(record.getUserId(), record.getType(), subMerchantId);
|
|
|
- if(i == 1 && record.getType() == 1){
|
|
|
+ if(i != 1){
|
|
|
+ log.error("商家id【{}】更新认证状态【{}】失败", record.getUserId(), status);
|
|
|
+ throw new ResourceUnavailableException("商家id【{"+record.getUserId()+"}】更新认证状态【{"+status+"}】失败");
|
|
|
+ }
|
|
|
+ if(record.getType() == 1){
|
|
|
//用户申请商户号成功,平台转账给用户
|
|
|
BigDecimal total = assetService.queryTotal(record.getUserId(), 1);
|
|
|
assetService.transfer(0L, record.getUserId(), 1, total, "0");
|