Commit 88319d66 by 程裕兵

feat:callback

parent 5834916f
...@@ -340,35 +340,56 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -340,35 +340,56 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
StudioMerchantApply toModify = MerchantConvert.convertApply(apply, event, StudioMerchantApply toModify = MerchantConvert.convertApply(apply, event,
configService.getDefaultBrandSubChannelInfo().getSubChannels()); configService.getDefaultBrandSubChannelInfo().getSubChannels());
studioMerchantApplyRpService.updateById(toModify); studioMerchantApplyRpService.updateById(toModify);
if (!OpenStateEnums.SUCCESS.getCode().equals(toModify.getOpenState())) { if (OpenStateEnums.SUCCESS != OpenStateEnums.getByCode(toModify.getOpenState())) {
return;
}
if (OpenStateEnums.SUCCESS == OpenStateEnums.getByCode(apply.getOpenState())) {
// 绑定逻辑幂等处理
return; return;
} }
// 所有子通道全部开通成功
PartyToMerchant old = getRelation(apply.getStudioId());
// 1. 如果当前场馆绑定的是自己的商户号(old),则需要将绑定了该商户号的所有其他场馆进行解绑 // 绑定商户
if (null != old && !old.getMerchantId().equals(event.getMerchantId())) { this.bindWhenOpenSuccess(event, apply);
StudioMerchantApply oldApply = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(
old.getMerchantId()); }
if (!oldApply.getStudioId().equals(apply.getStudioId())) {
// 1.1 如果当前场馆绑定的是自己的商户号(old),则需要将绑定了该商户号的所有其他场馆进行解绑 private Long unbindWhenOpenSuccess(StudioMerchantApply apply) {
this.unbindAll(old.getMerchantId()); PartyToMerchant old = this.getRelation(apply.getStudioId());
// 1.2 场馆商户发生了变更,解绑掉绑定了老商户号的品牌 if (null == old) {
brandMerchantService.unbind(apply.getBrandId(), old.getMerchantId()); return null;
}
} }
Long oldMerchantId = old.getMerchantId();
StudioMerchantApply exist = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(oldMerchantId);
if (!exist.getStudioId().equals(apply.getStudioId())) {
// 之前绑定的商户不是自己的商户,不需要解绑
return oldMerchantId;
}
// 1. 如果当前场馆绑定的是自己的商户号(old),则需要将绑定了该商户号的所有其他场馆进行解绑
this.unbindAll(oldMerchantId);
// 2. 场馆商户发生了变更,解绑掉绑定了老商户号的品牌
brandMerchantService.unbind(apply.getBrandId(), oldMerchantId);
return oldMerchantId;
}
private void bindWhenOpenSuccess(MerchantEvent event, StudioMerchantApply apply) {
// 1. 解绑历史商户
Long oldMerchantId = this.unbindWhenOpenSuccess(apply);
// 2. 绑定场馆 // 2. 绑定场馆
this.bind(apply.getStudioId(), event.getMerchantId(), false); this.bind(apply.getStudioId(), event.getMerchantId(), false);
// 3. 绑定品牌 // 3. 绑定品牌
brandMerchantService.bind(apply.getBrandId(), event.getMerchantId()); brandMerchantService.bind(apply.getBrandId(), event.getMerchantId());
// 4. 其他操作 // 4. 其他操作
executor.execute(() -> this.doAfterMerchantSuccess(event, executor.execute(() -> this.doAfterMerchantSuccess(event, oldMerchantId));
Optional.ofNullable(old).map(PartyToMerchant::getMerchantId).orElse(null)));
} }
private void doAfterMerchantSuccess(MerchantEvent event, Long oldMerchantId) { private void doAfterMerchantSuccess(MerchantEvent event, Long oldMerchantId) {
// 1. 配置场馆小程序appId // 1. 配置场馆小程序appId
this.rebindMiniAppId(oldMerchantId, event.getMerchantId()); this.rebindMiniAppId(oldMerchantId, event.getMerchantId());
......
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