Commit 45f47bd4 by 程裕兵

feat:rebind mini appid

parent 77618169
......@@ -48,6 +48,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
......@@ -90,6 +91,9 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Resource
private BrandMerchantService brandMerchantService;
@Resource(name = "financeThreadPool")
private Executor executor;
@Async(value = "financeThreadPool")
@Override
public void apply(ApplyStudioMerchantParams params) {
......@@ -238,27 +242,30 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
private void doOpenMerchantSuccess(MerchantEvent event) {
StudioMerchantApply apply = studioMerchantApplyRpService.getByIdForUpdate(
Long.parseLong(event.getApplyNo())).orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
StudioMerchantApply applyToModify = MerchantConvert.convertApply(apply, event,
StudioMerchantApply toModify = MerchantConvert.convertApply(apply, event,
getDefaultBrandSubChannelInfo().getSubChannels());
studioMerchantApplyRpService.updateById(applyToModify);
studioMerchantApplyRpService.updateById(toModify);
if (OpenStateEnums.SUCCESS != toModify.getOpenState()) {
return;
}
// 所有子通道全部开通成功
PartyToMerchant old = getRelation(apply.getStudioId());
if (OpenStateEnums.SUCCESS == applyToModify.getOpenState()) {
// 所有子通道全部开通成功
// 1. 绑定场馆
this.bind(apply.getStudioId(), event.getMerchantId());
// 1. 配置场馆小程序appId
PartyToMerchant relation = getRelation(apply.getStudioId());
if (null != relation) {
this.rebindMiniAppId(relation.getMerchantId(), event.getMerchantId());
}
// 2. 绑定品牌
brandMerchantService.bind(apply.getBrandId(), event.getMerchantId());
// 2. 绑定场馆
this.bind(apply.getStudioId(), event.getMerchantId());
// 3. 其他操作
executor.execute(() -> this.doAfterMerchantSuccess(event,
Optional.ofNullable(old).map(PartyToMerchant::getMerchantId).orElse(null)));
// 3. 绑定品牌
brandMerchantService.bind(apply.getBrandId(), event.getMerchantId());
}
}
private void doAfterMerchantSuccess(MerchantEvent event, Long oldMerchantId) {
// 1. 配置场馆小程序appId
this.rebindMiniAppId(oldMerchantId, event.getMerchantId());
}
private void rebindMiniAppId(Long oldMerchantId, Long newMerchantId) {
......
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