|
|
@@ -2,6 +2,7 @@ package com.tzld.piaoquan.api.service.wecom.thirdparty.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.tzld.piaoquan.api.common.Constant;
|
|
|
import com.tzld.piaoquan.api.common.enums.ExceptionEnum;
|
|
|
import com.tzld.piaoquan.api.common.enums.wecom.ConfigSyncEnum;
|
|
|
@@ -68,6 +69,12 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
|
|
|
|
|
|
@Value("${wecom.thirdpart.callback.url:https://test-tp-open.piaoquantv.com/wecom/thirdparty/callback}")
|
|
|
private String callbackUrl;
|
|
|
+ @ApolloJsonValue("${send.room.msg.staff.put.scene.config:{}}")
|
|
|
+ private Map<Long, String> staffPutSceneConfig;
|
|
|
+ @ApolloJsonValue("${send.room.msg.staff.channel.config:{}}")
|
|
|
+ private Map<Long, String> staffChannelConfig;
|
|
|
+ @ApolloJsonValue("${send.room.msg.auto.open.staff:[]}")
|
|
|
+ private List<Long> autoOpenStaffList;
|
|
|
|
|
|
@Override
|
|
|
public AccountQrCodeVO getQrCode(Long id) {
|
|
|
@@ -169,7 +176,14 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
|
|
|
@Override
|
|
|
public List<IdNameVO<Long>> getPushAccountList(Long accountId, String name) {
|
|
|
List<ThirdPartWeComStaff> pushStaffList = staffMapperExt.getPushStaffList(accountId, null, name);
|
|
|
- return pushStaffList.stream().map(staff -> new IdNameVO<>(staff.getThirdStaffId(), staff.getName())).collect(Collectors.toList());
|
|
|
+ List<Long> staffIds = new ArrayList<>();
|
|
|
+ return pushStaffList.stream().map(staff -> new IdNameVO<>(staff.getThirdStaffId(), staff.getName()))
|
|
|
+ .filter(staff -> {
|
|
|
+ boolean res = !staffIds.contains(staff.getId());
|
|
|
+ staffIds.add(staff.getId());
|
|
|
+ return res;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -406,4 +420,49 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
|
|
|
return staffConfigMapper.selectByExample(example);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void initAccountConfig() {
|
|
|
+ List<ThirdPartWeComStaff> staffList = staffMapper.selectByExample(new ThirdPartWeComStaffExample());
|
|
|
+ if (CollectionUtils.isEmpty(staffList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (ThirdPartWeComStaff staff : staffList) {
|
|
|
+ ThirdPartyAccountConfigParam configParam = buildThirdPartyAccountConfigParam(staff);
|
|
|
+ saveAccountConfig(configParam);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private ThirdPartyAccountConfigParam buildThirdPartyAccountConfigParam(ThirdPartWeComStaff staff) {
|
|
|
+ ThirdPartyAccountConfigParam newConfig = new ThirdPartyAccountConfigParam();
|
|
|
+ newConfig.setAccountId(staff.getId());
|
|
|
+ newConfig.setPutScene(staffPutSceneConfig.getOrDefault(staff.getThirdStaffId(), "touliu"));
|
|
|
+ newConfig.setChannel(staffChannelConfig.getOrDefault(staff.getThirdStaffId(), "tencentqw"));
|
|
|
+ newConfig.setSwitchFlag(1);
|
|
|
+ if (autoOpenStaffList.contains(staff.getThirdStaffId())) {
|
|
|
+ newConfig.setOpenRoomSendSwitchNum(20);
|
|
|
+ }
|
|
|
+ newConfig.setPrimaryThirdStaffId(staff.getThirdStaffId());
|
|
|
+ newConfig.setConfigSync(1);
|
|
|
+
|
|
|
+ ThirdPartyAccountConfigTaskParam newTask = new ThirdPartyAccountConfigTaskParam();
|
|
|
+ newTask.setSwitchFlag(1);
|
|
|
+ List<String> sendTime = JSONObject.parseArray("[\"08:00\",\"11:00\",\"16:00\",\"21:00\"]", String.class);
|
|
|
+ newTask.setSendTime(sendTime);
|
|
|
+ newTask.setRandomMin(20);
|
|
|
+ newTask.setSeq(0);
|
|
|
+ newConfig.setTaskList(Collections.singletonList(newTask));
|
|
|
+
|
|
|
+ List<ThirdPartyAccountConfigTaskContentParam> contentList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
+ ThirdPartyAccountConfigTaskContentParam newContent = new ThirdPartyAccountConfigTaskContentParam();
|
|
|
+ newContent.setType(1);
|
|
|
+ newContent.setSource(0);
|
|
|
+ newContent.setSeq(i);
|
|
|
+ contentList.add(newContent);
|
|
|
+ }
|
|
|
+ newTask.setContentList(contentList);
|
|
|
+
|
|
|
+ return newConfig;
|
|
|
+ }
|
|
|
+
|
|
|
}
|