Commit 154710e5 by 程裕兵

feat:apply

parent 0efab09d
...@@ -67,4 +67,8 @@ public class ApplyStudioMerchantRequest { ...@@ -67,4 +67,8 @@ public class ApplyStudioMerchantRequest {
@Valid @Valid
private Map<String, BrandResourceInfo> resourceMap; private Map<String, BrandResourceInfo> resourceMap;
@ApiModelProperty(value = "验证码", required = true)
@NotBlank(message = "验证码不能为空")
private String smsCode;
} }
...@@ -37,6 +37,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -37,6 +37,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
"com.jiejing.filecenter.api", "com.jiejing.filecenter.api",
"com.jiejing.paycenter.api", "com.jiejing.paycenter.api",
"com.jiejing.studio.api", "com.jiejing.studio.api",
"com.jiejing.message.api",
}) })
@SpringBootApplication(scanBasePackages = "com.jiejing", exclude = { @SpringBootApplication(scanBasePackages = "com.jiejing", exclude = {
DruidDataSourceAutoConfigure.class DruidDataSourceAutoConfigure.class
......
...@@ -76,6 +76,11 @@ ...@@ -76,6 +76,11 @@
<artifactId>studio-api</artifactId> <artifactId>studio-api</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.jiejing.base</groupId>
<artifactId>message-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- ======================= jiejing api end ======================= --> <!-- ======================= jiejing api end ======================= -->
......
...@@ -15,11 +15,14 @@ ...@@ -15,11 +15,14 @@
package com.jiejing.fitness.finance.repository.service; package com.jiejing.fitness.finance.repository.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.jiejing.common.utils.text.StringUtil; import com.jiejing.common.utils.text.StringUtil;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.mapper.StudioMerchantApplyMapper; import com.jiejing.fitness.finance.repository.mapper.StudioMerchantApplyMapper;
import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery; import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery;
import com.jiejing.mbp.MapperRepoService; import com.jiejing.mbp.MapperRepoService;
import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import java.util.Optional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -80,5 +83,14 @@ public class StudioMerchantApplyRpService extends ...@@ -80,5 +83,14 @@ public class StudioMerchantApplyRpService extends
wrapper.eq(StudioMerchantApply.STUDIO_ID, studioId); wrapper.eq(StudioMerchantApply.STUDIO_ID, studioId);
return this.baseMapper.getLatestOneSuccessByStudioId(studioId); return this.baseMapper.getLatestOneSuccessByStudioId(studioId);
} }
public Integer countProcessByStudioId(Long studioId) {
QueryWrapper<StudioMerchantApply> wrapper = new QueryWrapper<>();
wrapper.eq(StudioMerchantApply.STUDIO_ID, studioId);
wrapper.in(StudioMerchantApply.OPEN_STATE,
Lists.newArrayList(OpenStateEnums.PROCESS, OpenStateEnums.INIT));
Integer count = this.baseMapper.selectCount(wrapper);
return Optional.ofNullable(count).orElse(0);
}
} }
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
<artifactId>studio-api</artifactId> <artifactId>studio-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.jiejing.base</groupId>
<artifactId>message-api</artifactId>
</dependency>
<dependency>
<groupId>com.jiejing.event</groupId> <groupId>com.jiejing.event</groupId>
<artifactId>scs-event</artifactId> <artifactId>scs-event</artifactId>
</dependency> </dependency>
......
...@@ -16,12 +16,14 @@ public enum FinanceErrorEnums implements BaseBizError { ...@@ -16,12 +16,14 @@ public enum FinanceErrorEnums implements BaseBizError {
PARAMS_ERROR("【参数错误】${message}"), PARAMS_ERROR("【参数错误】${message}"),
THIRD_ERROR("【三方异常】${message}"), THIRD_ERROR("【三方异常】${message}"),
BIZ_ERROR("【业务错误】${message}"), BIZ_ERROR("【业务错误】${message}"),
REPEAT_SUBMIT("请勿重复提交"),
NOT_EXIST("数据不存在"), NOT_EXIST("数据不存在"),
NOT_SUPPORT_METHOD("不支持的方法"), NOT_SUPPORT_METHOD("不支持的方法"),
NOT_SUPPORT_TYPE("不支持的类型"), NOT_SUPPORT_TYPE("不支持的类型"),
CHANNEL_NOT_OPEN("未开通当前支付通道"), CHANNEL_NOT_OPEN("未开通当前支付通道"),
MERCHANT_NOT_OPEN("未进件"), MERCHANT_NOT_OPEN("未进件"),
NOT_SUPPORT_FILE_TYPE("不支持的文件类型"), NOT_SUPPORT_FILE_TYPE("不支持的文件类型"),
EXIST_PROCESS_APPLY("存在处理中的申请"),
; ;
@Getter @Getter
......
...@@ -62,16 +62,16 @@ import java.util.stream.Collectors; ...@@ -62,16 +62,16 @@ import java.util.stream.Collectors;
*/ */
public class MerchantConvert { public class MerchantConvert {
public static ApplyMerchantRequest convertRequest(String channelNo, String applyNo, public static ApplyMerchantRequest convertRequest(ApplyStudioMerchantParams params,
ApplyStudioMerchantParams params, StudioVO studio, Map<ResourceTypeEnums, ResourceInfo> resourceMap, StudioMerchantApply apply, Map<ResourceTypeEnums, ResourceInfo> resourceMap,
SubChannelInfoDTO subChannelInfo) { SubChannelInfoDTO subChannelInfo) {
return ApplyMerchantRequest.builder() return ApplyMerchantRequest.builder()
.bizCode(PartyTypeEnum.STUDIO.getCode()) .bizCode(PartyTypeEnum.STUDIO.getCode())
.applyNo(applyNo) .applyNo(apply.getApplyNo())
.channelNo(channelNo) .channelNo(apply.getChannelNo())
.companyType(params.getCompanyType()) .companyType(apply.getCompanyType())
.merchantName(params.getMerchantName()) .merchantName(apply.getMerchantName())
.shortName(studio.getName()) .shortName(apply.getShortName())
.legal(convertLegal(params)) .legal(convertLegal(params))
.bankCard(convertBankCard(params)) .bankCard(convertBankCard(params))
.license(convertLicense(params)) .license(convertLicense(params))
......
...@@ -18,12 +18,14 @@ import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService; ...@@ -18,12 +18,14 @@ import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService; import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums; import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.global.ConfigService; import com.jiejing.fitness.finance.service.global.ConfigService;
import com.jiejing.fitness.finance.service.global.dto.SubChannelInfoDTO;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService; import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.StudioMerchantService; import com.jiejing.fitness.finance.service.merchant.StudioMerchantService;
import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert; import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert;
import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantParams; import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantParams;
import com.jiejing.fitness.finance.service.merchant.params.PageStudioMerchantApplyParams; import com.jiejing.fitness.finance.service.merchant.params.PageStudioMerchantApplyParams;
import com.jiejing.fitness.finance.service.rpc.MerchantRpcService; import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
import com.jiejing.fitness.finance.service.rpc.MessageRpcService;
import com.jiejing.fitness.finance.service.rpc.ResourceRpcService; import com.jiejing.fitness.finance.service.rpc.ResourceRpcService;
import com.jiejing.fitness.finance.service.rpc.StudioRpcService; import com.jiejing.fitness.finance.service.rpc.StudioRpcService;
import com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest; import com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest;
...@@ -50,7 +52,6 @@ import javax.annotation.Resource; ...@@ -50,7 +52,6 @@ import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -87,37 +88,39 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -87,37 +88,39 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Resource @Resource
private ConfigService configService; private ConfigService configService;
@Resource
private MessageRpcService messageRpcService;
@Resource(name = "financeThreadPool") @Resource(name = "financeThreadPool")
private Executor executor; private Executor executor;
@Async(value = "financeThreadPool")
@Override @Override
public Long apply(ApplyStudioMerchantParams params) { public Long apply(ApplyStudioMerchantParams params) {
Long id = IdWorker.getId(); this.checkBeforeApply(params);
StudioVO studio = studioRpcService.getStudio(params.getStudioId());
StudioMerchantApply exist = studioMerchantApplyRpService.getLatestOneSuccessByStudioId(studio.getId());
StudioMerchantApply apply = MerchantConvert.convertApply(id, params, studio, exist, channel);
studioMerchantApplyRpService.insert(apply); StudioMerchantApply apply = this.saveApply(params);
try { executor.execute(() -> {
try {
Map<ResourceTypeEnums, ResourceInfo> resourceMap = this.upload(params); Map<ResourceTypeEnums, ResourceInfo> resourceMap = this.upload(params);
ApplyMerchantRequest request = MerchantConvert.convertRequest(channel, apply.getApplyNo(), params,
studio, resourceMap, configService.getDefaultBrandSubChannelInfo());
merchantRpcService.apply(request);
} catch (Exception e) { SubChannelInfoDTO subChannel = configService.getDefaultBrandSubChannelInfo();
log.error("apply brand merchant fail {}, brand id = {}, studio id = {}", id, studio.getBrandId(),
params.getStudioId(), e); ApplyMerchantRequest request = MerchantConvert.convertRequest(params, apply, resourceMap, subChannel);
this.doOpenMerchantFail(id, e.getMessage()); merchantRpcService.apply(request);
return id;
}
this.doOpenMerchantProcess(id); } catch (Exception e) {
log.error("apply brand merchant fail {}, studio id = {}", apply.getId(), params.getStudioId(), e);
this.doOpenMerchantFail(apply.getId(), e.getMessage());
return;
}
return id; this.doOpenMerchantProcess(apply.getId());
});
return apply.getId();
} }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
...@@ -326,4 +329,28 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -326,4 +329,28 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
StudioMerchantApply.builder().id(id).openState(OpenStateEnums.PROCESS).build()); StudioMerchantApply.builder().id(id).openState(OpenStateEnums.PROCESS).build());
} }
private void validSmsCode(String phone, String smsCode) {
messageRpcService.validSmsCode(phone, smsCode, "FINANCE_MERCHANT");
}
private StudioMerchantApply saveApply(ApplyStudioMerchantParams params) {
Long id = IdWorker.getId();
StudioVO studio = studioRpcService.getStudio(params.getStudioId());
StudioMerchantApply exist = studioMerchantApplyRpService.getLatestOneSuccessByStudioId(studio.getId());
StudioMerchantApply apply = MerchantConvert.convertApply(id, params, studio, exist, channel);
studioMerchantApplyRpService.insert(apply);
return apply;
}
private void checkBeforeApply(ApplyStudioMerchantParams params) {
// 校验验证码
this.validSmsCode(params.getBankCard().getPhone(), params.getSmsCode());
// 重复提交
Integer count = studioMerchantApplyRpService.countProcessByStudioId(params.getStudioId());
if (count.compareTo(0) > 0) {
throw new BizException(FinanceErrorEnums.EXIST_PROCESS_APPLY);
}
}
} }
...@@ -69,6 +69,10 @@ public class ApplyStudioMerchantParams { ...@@ -69,6 +69,10 @@ public class ApplyStudioMerchantParams {
@Valid @Valid
private Map<String, BrandResourceInfo> resourceMap; private Map<String, BrandResourceInfo> resourceMap;
@ApiModelProperty(value = "验证码", required = true)
@NotBlank(message = "验证码不能为空")
private String smsCode;
public ApplyStudioMerchantParams encrypt(String salt) { public ApplyStudioMerchantParams encrypt(String salt) {
ApplyStudioMerchantParams copy = JSON.parseObject(JSON.toJSONString(this), ApplyStudioMerchantParams copy = JSON.parseObject(JSON.toJSONString(this),
ApplyStudioMerchantParams.class); ApplyStudioMerchantParams.class);
......
package com.jiejing.fitness.finance.service.rpc;
import com.jiejing.message.api.SendMessageApi;
import com.jiejing.message.api.request.VerifyCodeCheckRequest;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @author chengyubing
* @since 2024/4/2 10:00
*/
@Slf4j
@Service
public class MessageRpcService {
@Resource
private SendMessageApi sendMessageApi;
public void validSmsCode(String phone, String code, String bizType) {
VerifyCodeCheckRequest request = VerifyCodeCheckRequest.builder().phone(phone).bizType(bizType).code(code)
.build();
sendMessageApi.verifyCodeCheck(request).assertSuccess();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment