Commit 81347470 by 程裕兵

feat:添加半屏小程序

parent 4136ba07
...@@ -27,5 +27,5 @@ finance: ...@@ -27,5 +27,5 @@ finance:
wx: wx:
component: component:
appId: wxe6c4979bafd48126 appId: wxe6c4979bafd48126
authorizer: embedded:
appId: wx06a084dcba4f0a05 appId: wx06a084dcba4f0a05
\ No newline at end of file
...@@ -27,5 +27,5 @@ finance: ...@@ -27,5 +27,5 @@ finance:
wx: wx:
component: component:
appId: wxda913f3b6f1439b4 appId: wxda913f3b6f1439b4
authorizer: embedded:
appId: wxf187be22c2234300 appId: wxf187be22c2234300
\ No newline at end of file
...@@ -32,5 +32,5 @@ finance: ...@@ -32,5 +32,5 @@ finance:
wx: wx:
component: component:
appId: wxda913f3b6f1439b4 appId: wxda913f3b6f1439b4
authorizer: embedded:
appId: wxf187be22c2234300 appId: wxf187be22c2234300
...@@ -27,5 +27,5 @@ finance: ...@@ -27,5 +27,5 @@ finance:
wx: wx:
component: component:
appId: wxe6c4979bafd48126 appId: wxe6c4979bafd48126
authorizer: embedded:
appId: wx06a084dcba4f0a05 appId: wx06a084dcba4f0a05
\ No newline at end of file
...@@ -27,5 +27,5 @@ finance: ...@@ -27,5 +27,5 @@ finance:
wx: wx:
component: component:
appId: wxfe4c26daa7e85d14 appId: wxfe4c26daa7e85d14
authorizer: embedded:
appId: wxf187be22c2234300 appId: wxf187be22c2234300
\ No newline at end of file
...@@ -37,39 +37,39 @@ public class StudioEmbeddedXcxApplyRpService extends ...@@ -37,39 +37,39 @@ public class StudioEmbeddedXcxApplyRpService extends
MapperRepoService<Long, StudioEmbeddedXcxApply, StudioEmbeddedXcxApplyMapper> { MapperRepoService<Long, StudioEmbeddedXcxApply, StudioEmbeddedXcxApplyMapper> {
public Map<String, StudioEmbeddedXcxApply> mapByStudioIdAndAppId(Long studioId, public Map<String, StudioEmbeddedXcxApply> mapByStudioIdAndAppId(Long studioId,
String componentAppId, String systemXcxAppId, List<String> appIds) { String componentAppId, String embeddedAppId, List<String> appIds) {
return this.listByStudioIdAndAppId(studioId, componentAppId, systemXcxAppId, appIds) return this.listByStudioIdAndAppId(studioId, componentAppId, embeddedAppId, appIds)
.stream().collect(Collectors.toMap(StudioEmbeddedXcxApply::getAppId, e -> e)); .stream().collect(Collectors.toMap(StudioEmbeddedXcxApply::getAppId, e -> e));
} }
public List<StudioEmbeddedXcxApply> listByStudioIdAndAppId(Long studioId, String componentAppId, public List<StudioEmbeddedXcxApply> listByStudioIdAndAppId(Long studioId, String componentAppId,
String systemXcxAppId, List<String> appIds) { String embeddedAppId, List<String> appIds) {
QueryWrapper<StudioEmbeddedXcxApply> wrapper = new QueryWrapper<>(); QueryWrapper<StudioEmbeddedXcxApply> wrapper = new QueryWrapper<>();
wrapper.eq(StudioEmbeddedXcxApply.STUDIO_ID, studioId); wrapper.eq(StudioEmbeddedXcxApply.STUDIO_ID, studioId);
wrapper.eq(StudioEmbeddedXcxApply.COMPONENT_APP_ID, componentAppId); wrapper.eq(StudioEmbeddedXcxApply.COMPONENT_APP_ID, componentAppId);
wrapper.eq(StudioEmbeddedXcxApply.AUTHORIZER_APP_ID, systemXcxAppId); wrapper.eq(StudioEmbeddedXcxApply.APP_ID, embeddedAppId);
wrapper.in(StudioEmbeddedXcxApply.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 StudioEmbeddedXcxApply getByStudioIdAndAppId(Long studioId, String componentAppId, public StudioEmbeddedXcxApply getByStudioIdAndAppId(Long studioId, String componentAppId,
String systemXcxAppId, String appId) { String embeddedAppId, String appId) {
QueryWrapper<StudioEmbeddedXcxApply> wrapper = new QueryWrapper<>(); QueryWrapper<StudioEmbeddedXcxApply> wrapper = new QueryWrapper<>();
wrapper.eq(StudioEmbeddedXcxApply.STUDIO_ID, studioId); wrapper.eq(StudioEmbeddedXcxApply.STUDIO_ID, studioId);
wrapper.eq(StudioEmbeddedXcxApply.COMPONENT_APP_ID, componentAppId); wrapper.eq(StudioEmbeddedXcxApply.COMPONENT_APP_ID, componentAppId);
wrapper.eq(StudioEmbeddedXcxApply.APP_ID, appId); wrapper.eq(StudioEmbeddedXcxApply.APP_ID, embeddedAppId);
wrapper.eq(StudioEmbeddedXcxApply.AUTHORIZER_APP_ID, systemXcxAppId); wrapper.eq(StudioEmbeddedXcxApply.AUTHORIZER_APP_ID, appId);
return Optional.ofNullable(this.baseMapper.selectList(wrapper)) return Optional.ofNullable(this.baseMapper.selectList(wrapper))
.orElse(new ArrayList<>(1)) .orElse(new ArrayList<>(1))
.stream().findFirst().orElse(null); .stream().findFirst().orElse(null);
} }
public List<StudioEmbeddedXcxApply> listByAppIds(String componentAppId, String systemXcxAppId, public List<StudioEmbeddedXcxApply> listByAppIds(String componentAppId, String embeddedAppId,
List<String> appIds) { List<String> appIds) {
QueryWrapper<StudioEmbeddedXcxApply> wrapper = new QueryWrapper<>(); QueryWrapper<StudioEmbeddedXcxApply> wrapper = new QueryWrapper<>();
wrapper.eq(StudioEmbeddedXcxApply.COMPONENT_APP_ID, componentAppId); wrapper.eq(StudioEmbeddedXcxApply.COMPONENT_APP_ID, componentAppId);
wrapper.eq(StudioEmbeddedXcxApply.AUTHORIZER_APP_ID, systemXcxAppId); wrapper.eq(StudioEmbeddedXcxApply.APP_ID, embeddedAppId);
wrapper.in(StudioEmbeddedXcxApply.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));
} }
} }
...@@ -16,13 +16,13 @@ import java.util.stream.Collectors; ...@@ -16,13 +16,13 @@ import java.util.stream.Collectors;
*/ */
public class StudioEmbeddedXcxConvert { public class StudioEmbeddedXcxConvert {
public static StudioEmbeddedXcxApply toEntity(Long studioId, String componentAppId, String systemXcxAppId, public static StudioEmbeddedXcxApply toEntity(Long studioId, String componentAppId, String embeddedAppId,
String appId) { String appId) {
StudioEmbeddedXcxApply record = new StudioEmbeddedXcxApply(); StudioEmbeddedXcxApply record = new StudioEmbeddedXcxApply();
record.setId(IdWorker.getId()); record.setId(IdWorker.getId());
record.setComponentAppId(componentAppId); record.setComponentAppId(componentAppId);
record.setAuthorizerAppId(systemXcxAppId); record.setAuthorizerAppId(appId);
record.setAppId(appId); record.setAppId(embeddedAppId);
record.setStudioId(studioId); record.setStudioId(studioId);
record.setState(EmbededXcxEnum.INIT.getCode()); record.setState(EmbededXcxEnum.INIT.getCode());
record.setCreateTime(new Date()); record.setCreateTime(new Date());
......
...@@ -128,11 +128,17 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -128,11 +128,17 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Resource(name = "financeThreadPool") @Resource(name = "financeThreadPool")
private Executor executor; private Executor executor;
/**
* 第三方平台appId
*/
@Value("${wx.component.appId}") @Value("${wx.component.appId}")
private String wxComponentAppId; private String wxComponentAppId;
@Value("${wx.authorizer.appId}") /**
private String authorizerAppId; * 半屏小程序
*/
@Value("${wx.embedded.appId}")
private String embeddedAppId;
private static final Integer WX_SUCCESS_CODE = 0; private static final Integer WX_SUCCESS_CODE = 0;
...@@ -262,7 +268,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -262,7 +268,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Override @Override
public StudioEmbeddedXcxVO getEmbeddedXcx(Long studioId, String appId) { public StudioEmbeddedXcxVO getEmbeddedXcx(Long studioId, String appId) {
StudioEmbeddedXcxApply embeddedXcx = studioEmbeddedXcxApplyRpService.getByStudioIdAndAppId( StudioEmbeddedXcxApply embeddedXcx = studioEmbeddedXcxApplyRpService.getByStudioIdAndAppId(
studioId, wxComponentAppId, authorizerAppId, appId); studioId, wxComponentAppId, embeddedAppId, appId);
if (null == embeddedXcx) { if (null == embeddedXcx) {
return null; return null;
} }
...@@ -277,7 +283,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -277,7 +283,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
} }
Map<String, StudioEmbeddedXcxApply> existMap = studioEmbeddedXcxApplyRpService.mapByStudioIdAndAppId( Map<String, StudioEmbeddedXcxApply> existMap = studioEmbeddedXcxApplyRpService.mapByStudioIdAndAppId(
studioId, wxComponentAppId, authorizerAppId, appIds); studioId, wxComponentAppId, embeddedAppId, 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 -> {
...@@ -285,13 +291,13 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -285,13 +291,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, authorizerAppId, appId); entity = StudioEmbeddedXcxConvert.toEntity(studioId, wxComponentAppId, embeddedAppId, 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, authorizerAppId, appId, JSONObject result = weXcxService.addEmbeddedXcx(wxComponentAppId, appId, embeddedAppId,
"申请半屏小程序"); "申请半屏小程序");
Integer code = result.getInteger("errcode"); Integer code = result.getInteger("errcode");
String message = result.getString("errmsg"); String message = result.getString("errmsg");
...@@ -317,7 +323,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -317,7 +323,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
} }
List<StudioEmbeddedXcxApply> applies = studioEmbeddedXcxApplyRpService.listByAppIds(wxComponentAppId, List<StudioEmbeddedXcxApply> applies = studioEmbeddedXcxApplyRpService.listByAppIds(wxComponentAppId,
authorizerAppId, list.stream().map(AuthXcxInfo::getAppId).collect(Collectors.toList())); embeddedAppId, list.stream().map(AuthXcxInfo::getAppId).collect(Collectors.toList()));
if (CollectionUtil.isEmpty(applies)) { if (CollectionUtil.isEmpty(applies)) {
return; return;
} }
...@@ -363,7 +369,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -363,7 +369,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
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, authorizerAppId, start, num); HalfScreenXcxAuthVO vo = weXcxService.listEmbeddedXcx(wxComponentAppId, embeddedAppId, 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