Commit a158089f by 程裕兵

feat:listBoundEmbeddedXcx

parent c6c26678
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
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.jiejing.fitness.enums.finance.EmbededXcxEnum;
import com.jiejing.fitness.finance.repository.entity.StudioEmbeddedXcxApply; import com.jiejing.fitness.finance.repository.entity.StudioEmbeddedXcxApply;
import com.jiejing.fitness.finance.repository.mapper.StudioEmbeddedXcxApplyMapper; import com.jiejing.fitness.finance.repository.mapper.StudioEmbeddedXcxApplyMapper;
import com.jiejing.mbp.MapperRepoService; import com.jiejing.mbp.MapperRepoService;
...@@ -69,4 +70,12 @@ public class StudioEmbeddedXcxApplyRpService extends ...@@ -69,4 +70,12 @@ public class StudioEmbeddedXcxApplyRpService extends
wrapper.in(StudioEmbeddedXcxApply.AUTHORIZER_APP_ID, appIds); wrapper.in(StudioEmbeddedXcxApply.AUTHORIZER_APP_ID, appIds);
return Optional.ofNullable(this.baseMapper.selectList(wrapper)).orElse(new ArrayList<>(1)); return Optional.ofNullable(this.baseMapper.selectList(wrapper)).orElse(new ArrayList<>(1));
} }
public List<StudioEmbeddedXcxApply> listAllInit(String componentAppId, String embeddedAppId) {
QueryWrapper<StudioEmbeddedXcxApply> wrapper = new QueryWrapper<>();
wrapper.eq(StudioEmbeddedXcxApply.COMPONENT_APP_ID, componentAppId);
wrapper.eq(StudioEmbeddedXcxApply.EMBEDDED_APP_ID, embeddedAppId);
wrapper.eq(StudioEmbeddedXcxApply.STATE, EmbededXcxEnum.INIT.getCode());
return Optional.ofNullable(this.baseMapper.selectList(wrapper)).orElse(new ArrayList<>(1));
}
} }
...@@ -347,67 +347,23 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -347,67 +347,23 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Override @Override
public void syncEmbeddedXcx() { public void syncEmbeddedXcx() {
List<AuthXcxInfo> list = this.listBoundAppIds(); List<StudioEmbeddedXcxApply> applies = studioEmbeddedXcxApplyRpService.listAllInit(wxComponentAppId,
if (CollectionUtil.isEmpty(list)) { embeddedAppId);
return;
}
List<StudioEmbeddedXcxApply> applies = studioEmbeddedXcxApplyRpService.listByAppIds(wxComponentAppId,
embeddedAppId, list.stream().map(AuthXcxInfo::getAppId).collect(Collectors.toList()));
if (CollectionUtil.isEmpty(applies)) { if (CollectionUtil.isEmpty(applies)) {
return; return;
} }
Map<EmbededXcxEnum, List<AuthXcxInfo>> map = list.stream() applies.forEach(apply -> {
.collect(Collectors.groupingBy(e -> EmbededXcxEnum.getByWxCode(Integer.parseInt(e.getStatus())))); log.info("start sync embedded xcx {}, {}", apply.getId(), apply.getAuthorizerAppId());
try {
map.keySet().forEach(status -> { this.doComplete(apply.getId(), apply.getAuthorizerAppId());
List<AuthXcxInfo> authXcxInfos = map.getOrDefault(status, Lists.newArrayList()); } catch (Exception e) {
if (CollectionUtil.isEmpty(authXcxInfos)) { log.info("fail sync embedded xcx {}, {}", apply.getId(), apply.getAuthorizerAppId(), e);
return;
}
List<String> appIds = authXcxInfos.stream().map(AuthXcxInfo::getAppId)
.collect(Collectors.toList());
switch (status) {
case SUCCESS:
List<Long> toSuccessList = StudioEmbeddedXcxConvert.filterAppIds(applies, appIds);
if (CollectionUtil.isEmpty(toSuccessList)) {
break;
}
studioEmbeddedXcxApplyRpService.updateByIds(StudioEmbeddedXcxConvert.toSuccess(null),
toSuccessList);
break;
case CANCEL:
case REFUSE:
case TIMEOUT:
case REVOKE:
List<StudioEmbeddedXcxApply> toFailList = StudioEmbeddedXcxConvert.toFailList(status, applies,
authXcxInfos);
if (CollectionUtil.isEmpty(toFailList)) {
break;
}
studioEmbeddedXcxApplyRpService.updateBatchById(toFailList);
default:
break;
} }
log.info("complete sync embedded xcx {}, {}", apply.getId(), apply.getAuthorizerAppId());
}); });
} }
private List<AuthXcxInfo> listBoundAppIds() {
List<AuthXcxInfo> result = new ArrayList<>();
int num = 100;
for (int start = 0; start < 10; start++) {
HalfScreenXcxAuthVO vo = weXcxService.listEmbeddedXcx(wxComponentAppId, embeddedAppId, start, num);
if (CollectionUtil.isEmpty(vo.getWxaEmbeddedList())) {
break;
}
result.addAll(vo.getWxaEmbeddedList());
}
return result;
}
@Override @Override
public StudioMerchantApplyVO getApply(Long id) { public StudioMerchantApplyVO getApply(Long id) {
StudioMerchantApply apply = studioMerchantApplyRpService.getById(id) StudioMerchantApply apply = studioMerchantApplyRpService.getById(id)
......
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