Commit 6be0e033 by 程裕兵

feat:添加半屏小程序

parent 222c702d
...@@ -27,3 +27,5 @@ finance: ...@@ -27,3 +27,5 @@ finance:
wx: wx:
component: component:
appId: wxe6c4979bafd48126 appId: wxe6c4979bafd48126
authorizer:
appId: wx06a084dcba4f0a05
\ No newline at end of file
...@@ -27,3 +27,5 @@ finance: ...@@ -27,3 +27,5 @@ finance:
wx: wx:
component: component:
appId: wxda913f3b6f1439b4 appId: wxda913f3b6f1439b4
authorizer:
appId: wxf187be22c2234300
\ No newline at end of file
...@@ -32,3 +32,5 @@ finance: ...@@ -32,3 +32,5 @@ finance:
wx: wx:
component: component:
appId: wxda913f3b6f1439b4 appId: wxda913f3b6f1439b4
authorizer:
appId: wxf187be22c2234300
...@@ -27,3 +27,5 @@ finance: ...@@ -27,3 +27,5 @@ finance:
wx: wx:
component: component:
appId: wxe6c4979bafd48126 appId: wxe6c4979bafd48126
authorizer:
appId: wx06a084dcba4f0a05
\ No newline at end of file
...@@ -27,3 +27,5 @@ finance: ...@@ -27,3 +27,5 @@ finance:
wx: wx:
component: component:
appId: wxfe4c26daa7e85d14 appId: wxfe4c26daa7e85d14
authorizer:
appId: wxf187be22c2234300
\ No newline at end of file
...@@ -131,6 +131,9 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -131,6 +131,9 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Value("${wx.component.appId}") @Value("${wx.component.appId}")
private String wxComponentAppId; private String wxComponentAppId;
@Value("${wx.authorizer.appId}")
private String authorizerAppId;
private static final Integer WX_SUCCESS_CODE = 0; private static final Integer WX_SUCCESS_CODE = 0;
private final static List<String> SPECIAL_FAIL_LIST = Lists.newArrayList( private final static List<String> SPECIAL_FAIL_LIST = Lists.newArrayList(
...@@ -258,9 +261,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -258,9 +261,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Override @Override
public StudioEmbeddedXcxVO getEmbeddedXcx(Long studioId, String appId) { public StudioEmbeddedXcxVO getEmbeddedXcx(Long studioId, String appId) {
String systemAppId = this.listSystemXcxAppIds().stream().findFirst().orElse(null);
StudioEmbeddedXcxApply embeddedXcx = studioEmbeddedXcxApplyRpService.getByStudioIdAndAppId( StudioEmbeddedXcxApply embeddedXcx = studioEmbeddedXcxApplyRpService.getByStudioIdAndAppId(
studioId, wxComponentAppId, systemAppId, appId); studioId, wxComponentAppId, authorizerAppId, appId);
if (null == embeddedXcx) { if (null == embeddedXcx) {
return null; return null;
} }
...@@ -273,13 +275,9 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -273,13 +275,9 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
if (CollectionUtil.isEmpty(appIds)) { if (CollectionUtil.isEmpty(appIds)) {
return; return;
} }
String systemXcxAppId = this.listSystemXcxAppIds().stream().findFirst().orElse(null);
if (StringUtil.isBlank(systemXcxAppId)) {
return;
}
Map<String, StudioEmbeddedXcxApply> existMap = studioEmbeddedXcxApplyRpService.mapByStudioIdAndAppId( Map<String, StudioEmbeddedXcxApply> existMap = studioEmbeddedXcxApplyRpService.mapByStudioIdAndAppId(
studioId, wxComponentAppId, systemXcxAppId, appIds); studioId, wxComponentAppId, authorizerAppId, appIds);
appIds.stream() appIds.stream()
.filter(appId -> null == existMap.get(appId) || EmbededXcxEnum.isFail(existMap.get(appId).getState())) .filter(appId -> null == existMap.get(appId) || EmbededXcxEnum.isFail(existMap.get(appId).getState()))
.forEach(appId -> { .forEach(appId -> {
...@@ -287,13 +285,13 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -287,13 +285,13 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
StudioEmbeddedXcxApply entity = existMap.get(appId); StudioEmbeddedXcxApply entity = existMap.get(appId);
if (null == entity) { if (null == entity) {
entity = StudioEmbeddedXcxConvert.toEntity(studioId, wxComponentAppId, systemXcxAppId, appId); entity = StudioEmbeddedXcxConvert.toEntity(studioId, wxComponentAppId, authorizerAppId, appId);
studioEmbeddedXcxApplyRpService.insert(entity); studioEmbeddedXcxApplyRpService.insert(entity);
} else { } else {
studioEmbeddedXcxApplyRpService.updateById(StudioEmbeddedXcxConvert.toInit(entity)); studioEmbeddedXcxApplyRpService.updateById(StudioEmbeddedXcxConvert.toInit(entity));
} }
try { try {
JSONObject result = weXcxService.addEmbeddedXcx(wxComponentAppId, systemXcxAppId, appId, JSONObject result = weXcxService.addEmbeddedXcx(wxComponentAppId, authorizerAppId, appId,
"申请半屏小程序"); "申请半屏小程序");
Integer code = result.getInteger("errcode"); Integer code = result.getInteger("errcode");
String message = result.getString("errmsg"); String message = result.getString("errmsg");
...@@ -315,14 +313,13 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -315,14 +313,13 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Override @Override
public void syncEmbeddedXcx() { public void syncEmbeddedXcx() {
String systemAppId = this.listSystemXcxAppIds().stream().findFirst().orElse(null); List<AuthXcxInfo> list = this.listBoundAppIds();
List<AuthXcxInfo> list = this.listBoundAppIds(systemAppId);
if (CollectionUtil.isEmpty(list)) { if (CollectionUtil.isEmpty(list)) {
return; return;
} }
List<StudioEmbeddedXcxApply> applies = studioEmbeddedXcxApplyRpService.listByAppIds( List<StudioEmbeddedXcxApply> applies = studioEmbeddedXcxApplyRpService.listByAppIds(wxComponentAppId,
wxComponentAppId, systemAppId, list.stream().map(AuthXcxInfo::getAppId).collect(Collectors.toList())); authorizerAppId, list.stream().map(AuthXcxInfo::getAppId).collect(Collectors.toList()));
if (CollectionUtil.isEmpty(applies)) { if (CollectionUtil.isEmpty(applies)) {
return; return;
} }
...@@ -362,13 +359,13 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -362,13 +359,13 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
}); });
} }
private List<AuthXcxInfo> listBoundAppIds(String systemAppId) { private List<AuthXcxInfo> listBoundAppIds() {
List<AuthXcxInfo> result = new ArrayList<>(); List<AuthXcxInfo> result = new ArrayList<>();
int num = 100; int num = 100;
for (int start = 0; start < 10; start++) { for (int start = 0; start < 10; start++) {
HalfScreenXcxAuthVO vo = weXcxService.listEmbeddedXcx(wxComponentAppId, systemAppId, start, num); HalfScreenXcxAuthVO vo = weXcxService.listEmbeddedXcx(wxComponentAppId, authorizerAppId, start, num);
if (CollectionUtil.isEmpty(vo.getWxaEmbeddedList())) { if (CollectionUtil.isEmpty(vo.getWxaEmbeddedList())) {
break; break;
} }
......
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