瀏覽代碼

initAccountConfig

wangyunpeng 1 月之前
父節點
當前提交
0252a78396

+ 7 - 0
api-module/src/main/java/com/tzld/piaoquan/api/controller/wecom/thirdpart/WeComThirdPartyAccountController.java

@@ -75,4 +75,11 @@ public class WeComThirdPartyAccountController {
         return CommonResponse.success();
     }
 
+    @ApiOperation(value = "初始化账号配置")
+    @PostMapping("/initAccountConfig")
+    public CommonResponse<Void> initAccountConfig() {
+        service.initAccountConfig();
+        return CommonResponse.success();
+    }
+
 }

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/wecom/thirdparty/WeComThirdPartyAccountService.java

@@ -29,4 +29,6 @@ public interface WeComThirdPartyAccountService {
     void logout(ThirdPartyAccountLogOutParam param);
 
     List<ThirdPartWeComStaffConfig> getStaffConfigListByStaffIds(List<Long> staffIdList);
+
+    void initAccountConfig();
 }

+ 60 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/wecom/thirdparty/impl/WeComThirdPartyAccountServiceImpl.java

@@ -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;
+    }
+
 }

+ 0 - 1
api-module/src/main/resources/mapper/wecom/thirdpart/ext/ThirdPartWeComStaffMapperExt.xml

@@ -58,7 +58,6 @@
             </if>
         ) t2 on staff.id = t2.id
         where staff.status = 0
-        and staff.id != #{accountId}
         <if test="name != null and name != ''">
             and staff.name like concat('%', #{name}, '%')
         </if>