Jelajahi Sumber

企业微信+个微

三七 2 hari lalu
induk
melakukan
c27abe35cd

+ 1 - 1
fs-service/src/main/java/com/fs/common/service/impl/SmsServiceImpl.java

@@ -921,7 +921,7 @@ public class SmsServiceImpl implements ISmsService
      * @param temp
      * @param param
      */
-    @Async
+//    @Async
     public void batchSmsOp4AiSend(CompanySmsTemp temp, SmsSendBatchParam param){
         CompanyUser companyUser=companyUserService.selectCompanyUserById(param.getCompanyUserId());
         for(Long id:param.getCustomerIds()){

+ 15 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyUser.java

@@ -195,11 +195,26 @@ public class CompanyUser extends BaseEntity
     @TableField(exist = false)
     private List<Long> deptList;
 
+
+
+    /**
+     * 多个用户ID,逗号分隔
+     */
+    private  String  fsUserId;
+
     /**
      * cid服务id
      */
     private Long cidServerId;
 
+    public String getFsUserId() {
+        return fsUserId;
+    }
+
+    public void setFsUserId(String fsUserId) {
+        this.fsUserId = fsUserId;
+    }
+
     public String getMaOpenId() {
         return maOpenId;
     }

+ 5 - 1
fs-service/src/main/java/com/fs/company/domain/CompanyVoiceRoboticCallLogAddwx.java

@@ -69,7 +69,10 @@ public class CompanyVoiceRoboticCallLogAddwx extends BaseEntity{
 
     @TableField(exist = false)
     private List<Long> wxclientIds;
-    public static CompanyVoiceRoboticCallLogAddwx initCallLog( String runParam, Long keyId, Long taskId,Long wxAccountId,Long companyId) {
+
+    private Integer qwWxAddWayId;
+
+    public static CompanyVoiceRoboticCallLogAddwx initCallLog( String runParam, Long keyId, Long taskId,Long wxAccountId,Long companyId,int qwWxAddWayId) {
         CompanyVoiceRoboticCallLogAddwx log = new CompanyVoiceRoboticCallLogAddwx();
         log.wxClientId = keyId;
         log.runParam = runParam;
@@ -77,6 +80,7 @@ public class CompanyVoiceRoboticCallLogAddwx extends BaseEntity{
         log.runTime = new Date();
         log.wxAccountId = wxAccountId;
         log.companyId = companyId;
+        log.qwWxAddWayId=qwWxAddWayId;
         return log;
     }
 

+ 1 - 1
fs-service/src/main/java/com/fs/company/domain/CompanyWxClient.java

@@ -10,7 +10,7 @@ import java.time.LocalDateTime;
 
 /**
  * 添加个微信账号对象 company_wx_client
- * 
+ *
  * @author fs
  * @date 2024-12-09
  */

+ 0 - 1
fs-service/src/main/java/com/fs/company/service/impl/CompanyVoiceRoboticServiceImpl.java

@@ -1152,7 +1152,6 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
             initAndExecuteWorkflows(robotic, roboticBusinesseList);
         }
     }
-
     /**
      * 初始化场景任务客户流程
      * @param robotic

+ 14 - 0
fs-service/src/main/java/com/fs/company/vo/CompanyWxClient4WorkFlowVO.java

@@ -80,6 +80,20 @@ public class CompanyWxClient4WorkFlowVO extends BaseEntityTow {
     private String memo;
     private String workflowInstanceId;
     private String currentNodeKey;
+    /**
+    *  加微方式配置
+    */
+    private String nodeConfig;
     private String currentNodeName;
     private Integer currentNodeType;
+
+    /**
+    * 外呼id
+    */
+    private Long calleeId;
+
+    /**
+    * 投流 id
+    */
+    private String traceId;
 }

+ 7 - 2
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCouponIssueScrmMapper.java

@@ -83,9 +83,10 @@ public interface FsStoreCouponIssueScrmMapper
             "update fs_store_coupon_issue_scrm  set remain_count=(select ifnull(count(1),0) from fs_store_coupon_issue_user_scrm where issue_id=#{id}) where id=#{id}  " +
             "</script>"})
     void updateFsStoreCouponIssueCount(Long id);
+
     @Select({"<script> " +
             "select i.*,c.coupon_price,c.use_min_price,c.coupon_time   from fs_store_coupon_issue_scrm i left join fs_store_coupon_scrm c on c.coupon_id=i.coupon_id  " +
-            "where i.limit_time &gt; now() and i.is_del=0 and i.status=1   " +
+            "where i.limit_time &gt; now() and i.is_del=0 and i.status=1  and (i.is_permanent = 1 or (i.is_permanent = 0 and i.remain_count &lt; i.total_count)) and c.coupon_id is not null " +
             "<if test = 'maps.cateId != null and maps.cateId!=0     '> " +
             "and find_in_set(#{maps.cateId},c.package_cate_ids) " +
             "</if>" +
@@ -95,9 +96,13 @@ public interface FsStoreCouponIssueScrmMapper
             "<if test = 'maps.couponPrice != null     '> " +
             "and c.coupon_price =  #{maps.couponPrice} " +
             "</if>" +
-            " order by c.coupon_price desc "+
+            "<if test='maps.couponName != null and maps.couponName != \"\"'> " +
+            "and i.coupon_name like concat(#{maps.couponName},'%') " +
+            "</if>" +
+            " order by c.coupon_price desc " +
             "</script>"})
     List<FsStoreCouponIssueVO> getCompanyCouponIssueList(@Param("maps") FsCouponIssueParam map);
+
     @Select({"<script> " +
             "select i.*,c.coupon_price,c.use_min_price,c.coupon_time  from fs_store_coupon_issue_scrm i left join fs_store_coupon_scrm c on c.coupon_id=i.coupon_id  " +
             "where i.id=#{id}  order by c.coupon_price desc " +

+ 1 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsCouponIssueParam.java

@@ -13,4 +13,5 @@ public class FsCouponIssueParam extends BaseQueryParam implements Serializable
     private Integer cateId;
     private Integer couponType;
     private BigDecimal couponPrice;
+    private String couponName;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -3086,7 +3086,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         if (param.getCouponUserId() != null) {
             FsStoreCouponUserScrm couponUser = couponUserService.selectFsStoreCouponUserById(param.getCouponUserId());
             if (couponUser != null && couponUser.getStatus() == 0) {
-                if (couponUser.getUseMinPrice().compareTo(storeProductPackage.getPayMoney()) == -1) {
+                if (couponUser.getUseMinPrice().compareTo(storeProductPackage.getPayMoney()) <= 0) {
                     totalMoney = totalMoney.subtract(couponUser.getCouponPrice());
                 }
             }

+ 15 - 1
fs-service/src/main/java/com/fs/qwApi/service/QwApiService.java

@@ -341,15 +341,29 @@ public interface QwApiService {
 
     QwSendMsgResult sendMsg(QwSendMsgParam param,String corpId);
 
+    /**
+    * 获取获客链接列表
+    */
     QwLinkListResult linkList(QwParam param,String corpId);
 
-
+    /**
+    * 获取获客链接详情
+    */
     QwLinkGetResult linkGet(QwLinkGetParam param,String corpId);
 
+    /**
+    * 创建获客链接
+    */
     QwLinkCreateResult linkCreate(QwLinkCreateParam param,String corpId);
 
+    /**
+    * 编辑获客链接
+    */
     QwResult linkUpdate(QwLinkCreateParam param,String corpId);
 
+    /**
+    * 删除获客链接
+    */
     QwResult linkDelete(QwLinkGetParam param,String corpId);
 
     QwLinkCustomerResult linkCustomer(QwLinkCustomerParam param,String corpId);

+ 0 - 4
fs-service/src/main/java/com/fs/qwApi/service/impl/QwApiServiceImpl.java

@@ -1814,7 +1814,6 @@ public class QwApiServiceImpl implements QwApiService {
     public QwLinkCreateResult linkCreate(QwLinkCreateParam param, String corpId) {
         String json = sendPost(QwApiConfig.linkCreate, param,corpId);
         QwLinkCreateResult qwResult = JSON.parseObject(json, QwLinkCreateResult.class);
-        if(qwResult.getErrcode() != 0) throw new BaseException("创建获客链接错误:" + qwResult.getErrmsg());
         return qwResult;
     }
 
@@ -1822,7 +1821,6 @@ public class QwApiServiceImpl implements QwApiService {
     public QwResult linkUpdate(QwLinkCreateParam param, String corpId) {
         String json = sendPost(QwApiConfig.linkUpdate, param,corpId);
         QwResult qwResult = JSON.parseObject(json, QwResult.class);
-        if(qwResult.getErrcode() != 0) throw new BaseException("修改获客链接错误:" + qwResult.getErrmsg());
         return qwResult;
     }
 
@@ -1830,7 +1828,6 @@ public class QwApiServiceImpl implements QwApiService {
     public QwResult linkDelete(QwLinkGetParam param, String corpId) {
         String json = sendPost(QwApiConfig.linkDelete, param,corpId);
         QwResult qwResult = JSON.parseObject(json, QwResult.class);
-        if(qwResult.getErrcode() != 0) throw new BaseException("删除获客链接错误:" + qwResult.getErrmsg());
         return qwResult;
     }
 
@@ -1838,7 +1835,6 @@ public class QwApiServiceImpl implements QwApiService {
     public QwLinkCustomerResult linkCustomer(QwLinkCustomerParam param, String corpId) {
         String json = sendPost(QwApiConfig.linkCustomer, param,corpId);
         QwLinkCustomerResult qwResult = JSON.parseObject(json, QwLinkCustomerResult.class);
-        if(qwResult.getErrcode() != 0) throw new BaseException("获客链接错误:" + qwResult.getErrmsg());
         return qwResult;
     }
 

+ 8 - 5
fs-service/src/main/resources/mapper/company/CompanyVoiceRoboticCallLogAddwxMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.company.mapper.CompanyVoiceRoboticCallLogAddwxMapper">
-    
+
     <resultMap type="CompanyVoiceRoboticCallLogAddwx" id="CompanyVoiceRoboticCallLogAddwxResult">
         <result property="logId"    column="log_id"    />
         <result property="roboticId"    column="robotic_id"    />
@@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="companyId"    column="company_id"    />
         <result property="wxAccountId"    column="wx_account_id"    />
         <result property="isWeCom"    column="is_we_com"    />
+        <result property="qwWxAddWayId"    column="qw_wx_add_way_id"    />
     </resultMap>
 
     <sql id="selectCompanyVoiceRoboticCallLogAddwxVo">
@@ -24,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectCompanyVoiceRoboticCallLogAddwxList" parameterType="CompanyVoiceRoboticCallLogAddwx" resultMap="CompanyVoiceRoboticCallLogAddwxResult">
         <include refid="selectCompanyVoiceRoboticCallLogAddwxVo"/>
-        <where>  
+        <where>
             <if test="roboticId != null "> and robotic_id = #{roboticId}</if>
             <if test="wxClientId != null "> and wx_client_id = #{wxClientId}</if>
             <if test="runTime != null "> and run_time = #{runTime}</if>
@@ -36,12 +37,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isWeCom != null "> and is_we_com = #{isWeCom}</if>
         </where>
     </select>
-    
+
     <select id="selectCompanyVoiceRoboticCallLogAddwxByLogId" parameterType="Long" resultMap="CompanyVoiceRoboticCallLogAddwxResult">
         <include refid="selectCompanyVoiceRoboticCallLogAddwxVo"/>
         where log_id = #{logId}
     </select>
-        
+
     <insert id="insertCompanyVoiceRoboticCallLogAddwx" parameterType="CompanyVoiceRoboticCallLogAddwx" useGeneratedKeys="true" keyProperty="logId">
         insert into company_voice_robotic_call_log_addwx
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -55,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">company_id,</if>
             <if test="wxAccountId != null">wx_account_id,</if>
             <if test="isWeCom != null">is_we_com,</if>
+            <if test="qwWxAddWayId != null">qw_wx_add_way_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="roboticId != null">#{roboticId},</if>
@@ -67,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">#{companyId},</if>
             <if test="wxAccountId != null">#{wxAccountId},</if>
             <if test="isWeCom != null">#{isWeCom},</if>
+            <if test="qwWxAddWayId != null">#{qwWxAddWayId},</if>
          </trim>
     </insert>
 
@@ -92,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteCompanyVoiceRoboticCallLogAddwxByLogIds" parameterType="String">
-        delete from company_voice_robotic_call_log_addwx where log_id in 
+        delete from company_voice_robotic_call_log_addwx where log_id in
         <foreach item="logId" collection="array" open="(" separator="," close=")">
             #{logId}
         </foreach>

+ 9 - 7
fs-service/src/main/resources/mapper/company/CompanyWxClientMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.company.mapper.CompanyWxClientMapper">
-    
+
     <resultMap type="CompanyWxClient" id="CompanyWxClientResult">
         <result property="id"    column="id"    />
         <result property="roboticWxId"    column="robotic_wx_id"    />
@@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="addTime"    column="add_time"    />
         <result property="remark"    column="remark"    />
         <result property="createTime"    column="create_time"    />
+        <result property="traceId"    column="trace_id"    />
     </resultMap>
 
     <sql id="selectCompanyWxClientVo">
-        select a.* from company_wx_client a
+        select * from company_wx_client
     </sql>
 
     <select id="selectCompanyWxClientList" resultType="com.fs.company.domain.CompanyWxClient">
@@ -76,12 +77,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             ${params.dataScope}
         </where>
     </select>
-    
+
     <select id="selectCompanyWxClientById" parameterType="Long" resultMap="CompanyWxClientResult">
         <include refid="selectCompanyWxClientVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertCompanyWxClient" parameterType="CompanyWxClient" useGeneratedKeys="true" keyProperty="id">
         insert into company_wx_client
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -132,7 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteCompanyWxClientByIds" parameterType="String">
-        delete from company_wx_client where id in 
+        delete from company_wx_client where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
@@ -192,9 +193,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     <select id="getQwAddWxList4Workflow" resultType="com.fs.company.vo.CompanyWxClient4WorkFlowVO">
 
-        SELECT t1.*,t3.workflow_instance_id,t3.current_node_key,t3.current_node_name,t3.current_node_type FROM company_wx_client t1
+        SELECT t1.*,t3.workflow_instance_id,t3.current_node_key,t3.current_node_name,t3.current_node_type,t4.node_config,t2.callee_id FROM company_wx_client t1
         inner join company_voice_robotic_business t2 on t1.id = t2.wx_client_id and t1.robotic_id = t2.robotic_id
         inner join company_ai_workflow_exec t3 on t3.business_key = t2.id
+        inner join company_ai_workflow_node t4 on t3.current_node_key=t4.node_key
         where t1.is_add = 0 and t1.account_id is not null and t1.is_we_com = 2
         and t3.current_node_type = #{execNodeType} And t3.status = #{execStatus}
         <if test="accountIdList != null and !accountIdList.isEmpty()">
@@ -222,4 +224,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where 1=1
         <if test="customerId != null">  and customer_id = #{customerId} </if>
     </select>
-</mapper>
+</mapper>

+ 2 - 2
fs-user-app/src/main/java/com/fs/app/controller/store/CouponScrmController.java

@@ -127,8 +127,8 @@ public class CouponScrmController extends AppBaseController {
         try {
             param.setUserId(Long.parseLong(getUserId()));
             List<FsStoreCouponUserScrm> list=fsStoreCouponUserService.selectFsStoreCouponUserListByEnable(param);
-            list=list.stream().filter(s->(s.getCouponPrice().compareTo(param.getUseMinPrice())==-1 )).collect(Collectors.toList());
-            list=list.stream().filter(s->(s.getUseMinPrice().compareTo(param.getUseMinPrice())==-1 )).collect(Collectors.toList());
+            list=list.stream().filter(s->(s.getCouponPrice().compareTo(param.getUseMinPrice()) <= 0 )).collect(Collectors.toList());
+            list=list.stream().filter(s->(s.getUseMinPrice().compareTo(param.getUseMinPrice()) <= 0 )).collect(Collectors.toList());
             return R.ok().put("data",list);
         } catch (Exception e){
             return R.error("操作异常");

+ 674 - 55
fs-wx-task/src/main/java/com/fs/app/service/WxTaskService.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.fs.common.constant.Constants;
+import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.core.redis.RedisCacheT;
 import com.fs.common.utils.PubFun;
@@ -20,6 +21,7 @@ import com.fs.company.service.impl.call.node.AiQwAddWxTaskNode;
 import com.fs.company.service.impl.call.node.WorkflowNodeFactory;
 import com.fs.company.vo.CompanyWxClient4WorkFlowVO;
 import com.fs.course.config.RedisKeyScanner;
+import com.fs.crm.param.SmsSendBatchParam;
 import com.fs.enums.ExecutionStatusEnum;
 import com.fs.enums.NodeTypeEnum;
 import com.fs.company.util.ObjectPlaceholderResolver;
@@ -31,7 +33,11 @@ import com.fs.qw.domain.QwExternalContact;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.mapper.QwExternalContactMapper;
 import com.fs.qw.mapper.QwUserMapper;
+import com.fs.qwApi.domain.QwLinkCreateResult;
+import com.fs.qwApi.param.QwLinkCreateParam;
+import com.fs.qwApi.service.QwApiService;
 import com.fs.system.service.ISysConfigService;
+import com.fs.voice.utils.StringUtil;
 import com.fs.wxcid.dto.friend.AddContactParam;
 import com.fs.wxcid.service.FriendService;
 import com.fs.wxcid.vo.AddContactVo;
@@ -40,6 +46,8 @@ import com.fs.wxwork.dto.WxSearchContactDTO;
 import com.fs.wxwork.dto.WxSearchContactResp;
 import com.fs.wxwork.dto.WxWorkResponseDTO;
 import com.fs.wxwork.service.WxWorkService;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import lombok.AllArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -90,6 +98,11 @@ public class WxTaskService {
     private final CompanyWorkflowEngine companyWorkflowEngine;
     private final CompanyVoiceRoboticBusinessMapper companyVoiceRoboticBusinessMapper;
     private final WorkflowNodeFactory workflowNodeFactory;
+    private final CompanySmsTempServiceImpl smsTempService;
+    private final ICompanySmsService companySmsService;
+    private final ICompanyUserService companyUserService;
+    private final CompanyVoiceRoboticCallLogSendmsgServiceImpl companyVoiceRoboticCallLogSendmsgService;
+    private final QwApiService qwApiService;
     private final RedisCache redisCache2;
     private final ExecutorService cidExcutor = new ThreadPoolExecutor(
             32,
@@ -171,7 +184,7 @@ public class WxTaskService {
                     runParam.put("txt", newTxt);
                     runParam.put("clientId", client.getId());
                     CompanyVoiceRoboticCallLogAddwx addLog = CompanyVoiceRoboticCallLogAddwx.initCallLog(
-                            runParam.toJSONString(), client.getId(), client.getRoboticId(), e.getId(), e.getCompanyId());
+                            runParam.toJSONString(), client.getId(), client.getRoboticId(), e.getId(), e.getCompanyId(),0);
                     log.info("ROBOTIC-ID:{},CLIENT-ID:{},执行加微:{},客户:{}-{},使用话术:{}", client.getRoboticId(), client.getId(), e.getId(), client.getCustomerId(), crmCustomer.getCustomerName(), dialog.getName());
                     if (vo.isSuccess()) {
                         e.setLastAddWxTime(LocalDateTime.now());
@@ -293,7 +306,7 @@ public class WxTaskService {
                     runParam.put("txt", newTxt);
                     runParam.put("clientId", client.getId());
                     CompanyVoiceRoboticCallLogAddwx addLog = CompanyVoiceRoboticCallLogAddwx.initCallLog(
-                            runParam.toJSONString(), client.getId(), client.getRoboticId(), e.getId(), e.getCompanyId());
+                            runParam.toJSONString(), client.getId(), client.getRoboticId(), e.getId(), e.getCompanyId(),0);
                     log.info("ROBOTIC-ID:{},CLIENT-ID:{},执行加微:{},客户:{}-{},使用话术:{}", client.getRoboticId(), client.getId(), e.getId(), client.getCustomerId(), crmCustomer.getCustomerName(), dialog.getName());
                     if (vo.isSuccess()) {
                         e.setLastAddWxTime(LocalDateTime.now());
@@ -860,75 +873,681 @@ public class WxTaskService {
      *
      * @param accountIdList 企微成员id
      */
+
+    /**
+     * 企微加微方式:主动申请
+     */
+    private static final int QW_ADD_WX_TYPE_APPLY = 1;
+
+    /**
+     * 企微加微方式:短信获客链接
+     */
+    private static final int QW_ADD_WX_TYPE_SMS_LINK = 2;
+
+    /**
+     * 默认加微方式 ID
+     */
+    private static final int DEFAULT_QW_WX_ADD_WAY_ID = 1;
+
     public void qwAddWx(List<Long> accountIdList) {
         log.info("==========执行申请企微加好友任务开始==========");
         try {
-            // 需要添加微信的列表
+            // 获取需要添加微信的列表
             List<CompanyWxClient4WorkFlowVO> list = companyWxClientService.getQwAddWxList4Workflow(accountIdList);
             log.info("申请企微加好友任务需要添加微信的数量:{}", list.size());
-            if (list.isEmpty()) return;
-            List<CompanyWxClient> addList = new ArrayList<>();
-            Map<Long, CompanyWxClient4WorkFlowVO> clientMap = PubFun.listToMapByGroupObject(list, CompanyWxClient4WorkFlowVO::getAccountId);
-            // 获取实际企微用户信息
+            if (list.isEmpty()) {
+                return;
+            }
+
+            // 构建客户映射
+            Map<Long, CompanyWxClient4WorkFlowVO> clientMap = PubFun.listToMapByGroupObject(
+                    list, CompanyWxClient4WorkFlowVO::getAccountId);
+
+            // 获取有效的企微用户列表
             List<QwUser> addAccountList = qwUserMapper.selectBatchIds(clientMap.keySet()).stream()
                     .filter(this::isValidQwUser)
                     .collect(Collectors.toList());
             log.info("企微申请加好友任务需要企微的账号数量:{}", addAccountList.size());
-            addAccountList.forEach(qwUser -> {
-                CompanyWxClient4WorkFlowVO client = clientMap.get(qwUser.getId());
-                if (client != null) {
-                    CrmCustomer crmCustomer = crmCustomerService.selectCrmCustomerById(client.getCustomerId());
-                    // 开始申请加微
-                    WxWorkResponseDTO<String> resp = qwAddWxInvokeIpad(crmCustomer.getMobile(), qwUser.getUid(),qwUser.getServerId(),qwUser.getVid(),qwUser.getQwUserName());
-                    JSONObject runParam = new JSONObject();
-                    runParam.put("qwId", qwUser.getId());
-                    runParam.put("mobile", crmCustomer.getMobile());
-                    runParam.put("qwUid", qwUser.getUid());
-                    runParam.put("clientId", client.getId());
-                    CompanyVoiceRoboticCallLogAddwx addLog = CompanyVoiceRoboticCallLogAddwx.initCallLog(
-                            runParam.toJSONString(), client.getId(), client.getRoboticId(), qwUser.getId(), qwUser.getCompanyId());
-                    if (resp != null && resp.getErrcode() == 0) {
-                        // 加微消息已发送成功
-                        client.setIsAdd(2);
-                        client.setAddTime(LocalDateTime.now());
-                        CompanyWxClient addItem = new CompanyWxClient();
-                        BeanUtils.copyProperties(client, addItem);
-                        addList.add(addItem);
-                        addLog.setStatus(1);
-                        addLog.setResult(JSON.toJSONString(resp));
-                        addLog.setIsWeCom(2);
-                        log.info("ROBOTIC-ID:{},企微申请加好友任务申请成功", client.getRoboticId());
-                    } else {
-                        log.error("ROBOTIC-ID:{},企微申请加好友任务加微失败:{}", client.getRoboticId(), runParam);
-                        addLog.setStatus(3);
-                        addLog.setResult(JSON.toJSONString(runParam));
-                    }
-                    asyncSaveCompanyVoiceRoboticCallLog(addLog);
-                } else {
-                    log.error("企微申请加好友任务当前账号暂无需要添加微信:{}-{}", qwUser.getId(), qwUser.getQwUserName());
-                }
-            });
-            if (!addList.isEmpty()) {
-                companyWxClientService.updateBatchById(addList);
-                for (CompanyWxClient client : addList) {
-                    CompanyWxClient4WorkFlowVO vo = clientMap.get(client.getAccountId());
-                    IWorkflowNode node = workflowNodeFactory.createNode(vo.getCurrentNodeKey(),
-                            NodeTypeEnum.fromValue(vo.getCurrentNodeType()),
-                            vo.getCurrentNodeName(), null);
-                    if (node instanceof AiQwAddWxTaskNode) {
-                        CompletableFuture.runAsync(() -> {
-                            AiQwAddWxTaskNode qwAddWxNode = (AiQwAddWxTaskNode) node;
-                            qwAddWxNode.doneQwAddWx(vo.getWorkflowInstanceId());
-                        }, cidExcutor);
-                    }
-                }
+            if (addAccountList.isEmpty()) {
+                return;
+            }
+
+            // 处理每个企微用户的加微请求
+            List<CompanyWxClient> updateList = processQwAddWxRequests(addAccountList, clientMap);
+
+            // 批量更新并触发后续流程
+            if (!updateList.isEmpty()) {
+                companyWxClientService.updateBatchById(updateList);
+                triggerNextWorkflowSteps(updateList, clientMap);
             }
+
         } catch (Exception e) {
             log.error("企微申请加好友任务执行异常", e);
         }
         log.info("==========执行企微申请加好友任务结束==========");
     }
 
+    /**
+     * 处理所有企微用户的加微请求
+     */
+    private List<CompanyWxClient> processQwAddWxRequests(
+            List<QwUser> addAccountList,
+            Map<Long, CompanyWxClient4WorkFlowVO> clientMap) {
+
+        List<CompanyWxClient> updateList = new ArrayList<>();
+
+        for (QwUser qwUser : addAccountList) {
+            CompanyWxClient4WorkFlowVO client = clientMap.get(qwUser.getId());
+            if (client == null) {
+                log.error("企微申请加好友任务当前账号暂无需要添加微信:{}-{}",
+                        qwUser.getId(), qwUser.getQwUserName());
+                continue;
+            }
+
+            try {
+                // 解析配置参数
+                NodeConfig config = parseNodeConfig(client.getNodeConfig());
+
+                // 根据加微方式处理
+                CompanyWxClient result = handleQwAddWxByType(qwUser, client, config);
+                if (result != null) {
+                    updateList.add(result);
+                }
+
+            } catch (Exception e) {
+                log.error("处理企微加微请求失败 - accountId: {}, qwUserId: {}",
+                        client.getAccountId(), qwUser.getId(), e);
+            }
+        }
+
+        return updateList;
+    }
+
+    /**
+     * 解析节点配置
+     */
+    private NodeConfig parseNodeConfig(String nodeConfigStr) {
+        NodeConfig config = new NodeConfig();
+        config.qwWxAddWayId = DEFAULT_QW_WX_ADD_WAY_ID;
+        config.smsTempId = DEFAULT_QW_WX_ADD_WAY_ID;
+
+        if (StringUtils.isBlank(nodeConfigStr)) {
+            return config;
+        }
+
+        try {
+            JsonObject configJson = JsonParser.parseString(nodeConfigStr).getAsJsonObject();
+            if (configJson.has("qwWxAddWayId") && !configJson.get("qwWxAddWayId").isJsonNull()) {
+                config.qwWxAddWayId = configJson.get("qwWxAddWayId").getAsInt();
+            }
+            if (configJson.has("smsTempId") && !configJson.get("smsTempId").isJsonNull()) {
+                config.smsTempId = configJson.get("smsTempId").getAsInt();
+            }
+        } catch (Exception e) {
+            log.error("解析配置出错,使用默认值:{}", e.getMessage());
+        }
+
+        return config;
+    }
+
+    /**
+     * 根据加微方式类型处理
+     */
+    private CompanyWxClient handleQwAddWxByType(
+            QwUser qwUser,
+            CompanyWxClient4WorkFlowVO client,
+            NodeConfig config) {
+
+        switch (config.qwWxAddWayId) {
+            case QW_ADD_WX_TYPE_APPLY:
+                return handleApplyAddWx(qwUser, client, config);
+            case QW_ADD_WX_TYPE_SMS_LINK:
+                return handleSmsLinkAddWx(qwUser, client, config);
+            default:
+                log.warn("未知的加微方式:{}", config.qwWxAddWayId);
+                return null;
+        }
+    }
+
+    /**
+     * 处理主动申请加微
+     */
+    private CompanyWxClient handleApplyAddWx(
+            QwUser qwUser,
+            CompanyWxClient4WorkFlowVO client,
+            NodeConfig config) {
+
+        CrmCustomer crmCustomer = crmCustomerService.selectCrmCustomerById(client.getCustomerId());
+
+        // 发起加微申请
+        WxWorkResponseDTO<String> resp = qwAddWxInvokeIpad(
+                crmCustomer.getMobile(),
+                qwUser.getUid(),
+                qwUser.getServerId(),
+                qwUser.getVid(),
+                qwUser.getQwUserName()
+        );
+
+        // 准备日志参数
+        JSONObject runParam = buildAddWxRunParam(qwUser, client, crmCustomer.getMobile());
+        CompanyVoiceRoboticCallLogAddwx addLog = CompanyVoiceRoboticCallLogAddwx.initCallLog(
+                runParam.toJSONString(),
+                client.getId(),
+                client.getRoboticId(),
+                qwUser.getId(),
+                qwUser.getCompanyId(),
+                config.qwWxAddWayId
+        );
+
+        // 处理结果
+        if (resp != null && resp.getErrcode() == 0) {
+            // 加微成功
+            client.setIsAdd(2);
+            client.setAddTime(LocalDateTime.now());
+
+            CompanyWxClient addItem = new CompanyWxClient();
+            BeanUtils.copyProperties(client, addItem);
+
+            addLog.setStatus(2);
+            addLog.setResult(JSON.toJSONString(resp));
+            addLog.setIsWeCom(2);
+            log.info("ROBOTIC-ID:{},企微申请加好友任务申请成功", client.getRoboticId());
+
+            asyncSaveCompanyVoiceRoboticCallLog(addLog);
+            return addItem;
+        } else {
+            // 加微失败
+            client.setIsAdd(3);
+            client.setAddTime(LocalDateTime.now());
+
+
+            CompanyWxClient addItem = new CompanyWxClient();
+            BeanUtils.copyProperties(client, addItem);
+
+
+            addLog.setStatus(3);
+            addLog.setResult(JSON.toJSONString(runParam));
+            log.error("ROBOTIC-ID:{},企微申请加好友任务加微失败:{}",
+                    client.getRoboticId(), runParam);
+
+            asyncSaveCompanyVoiceRoboticCallLog(addLog);
+            return addItem;
+        }
+    }
+
+    /**
+     * 处理短信获客链接加微
+     */
+    private CompanyWxClient handleSmsLinkAddWx(
+            QwUser qwUser,
+            CompanyWxClient4WorkFlowVO client,
+            NodeConfig config) {
+
+        // 查询短信模板
+        CompanySmsTemp temp = smsTempService.selectCompanySmsTempById((long) config.smsTempId);
+        if (temp == null || !temp.getStatus().equals(1) || !temp.getIsAudit().equals(1)) {
+            log.error("短信模板无效或未审核:{}", temp);
+            throw new RuntimeException("短信模板无效或未审核");
+        }
+
+        // 查询公司短信信息
+        CompanySms sms = companySmsService.selectCompanySmsByCompanyId(qwUser.getCompanyId());
+        if (sms == null) {
+            log.error("公司短信信息不存在:companyId: {}", qwUser.getCompanyId());
+            throw new RuntimeException("公司短信信息不存在");
+        }
+
+        if (sms.getRemainSmsCount() <= 0) {
+            log.error("剩余短信数量不足:companyId: {}", qwUser.getCompanyId());
+            throw new RuntimeException("剩余短信数量不足,请充值");
+        }
+
+
+        String linkUrl = getLinkUrl(qwUser);
+
+        if (StringUtil.strIsNullOrEmpty(linkUrl)) {
+            return handleLinkGenerationFailure(client, qwUser, config);
+        }
+
+        return handleSmsSendAndAddWx(qwUser, client, temp, linkUrl, config);
+
+
+    }
+    /**
+     * 处理链接生成失败
+     */
+    private CompanyWxClient handleLinkGenerationFailure(
+            CompanyWxClient4WorkFlowVO client,
+            QwUser qwUser,
+            NodeConfig config) {
+
+        client.setIsAdd(3);
+        client.setAddTime(LocalDateTime.now());
+
+        CompanyWxClient addItem = new CompanyWxClient();
+        BeanUtils.copyProperties(client, addItem);
+
+        CompanyVoiceRoboticCallLogAddwx addLogAddWx = CompanyVoiceRoboticCallLogAddwx.initCallLog(
+                "获客链接生成失败",
+                client.getId(),
+                client.getRoboticId(),
+                qwUser.getId(),
+                qwUser.getCompanyId(),
+                config.qwWxAddWayId
+        );
+
+        addLogAddWx.setStatus(3);
+        addLogAddWx.setResult(JSON.toJSONString(R.ok()));
+        addLogAddWx.setIsWeCom(2);
+
+        asyncSaveCompanyVoiceRoboticCallLog(addLogAddWx);
+        return addItem;
+    }
+
+    /**
+     * 处理短信发送和加微
+     */
+    private CompanyWxClient handleSmsSendAndAddWx(
+            QwUser qwUser,
+            CompanyWxClient4WorkFlowVO client,
+            CompanySmsTemp temp,
+            String linkUrl,
+            NodeConfig config) {
+
+        SmsSendBatchParam smsSendBatchParam = buildSmsSendParam(qwUser, client, temp, linkUrl);
+        JSONObject runParamSms = (JSONObject) JSON.toJSON(smsSendBatchParam);
+        runParamSms.put("temp", temp);
+
+        //发送短信并记录日志
+        sendSmsWithLog(smsSendBatchParam, runParamSms, client, qwUser, temp);
+
+        //保存加微日志
+        saveAddWxLog(runParamSms, client, qwUser, config);
+
+        client.setIsAdd(2);
+        client.setAddTime(LocalDateTime.now());
+
+
+        CompanyWxClient addItem = new CompanyWxClient();
+        BeanUtils.copyProperties(client, addItem);
+
+        return addItem;
+    }
+
+    /**
+     * 发送短信并记录日志
+     */
+    private void sendSmsWithLog(
+            SmsSendBatchParam smsSendBatchParam,
+            JSONObject runParamSms,
+            CompanyWxClient4WorkFlowVO client,
+            QwUser qwUser,
+            CompanySmsTemp temp) {
+
+        CompanyVoiceRoboticCallLogSendmsg addLogSms = CompanyVoiceRoboticCallLogSendmsg.initCallLog(
+                runParamSms.toJSONString(),
+                client.getCalleeId(),
+                client.getRoboticId(),
+                qwUser.getCompanyId(),
+                qwUser.getCompanyUserId(),
+                temp.getTempId()
+        );
+
+        try {
+            String callbackUuid = UUID.randomUUID().toString();
+            int smsContentLen = getSmsContentLen(smsSendBatchParam);
+
+            addLogSms.setContentLen(smsContentLen);
+            companyVoiceRoboticServiceImpl.sendMsgBatch(temp, smsSendBatchParam);
+
+            addLogSms.setStatus(2);
+            addLogSms.setCallbackUuid(callbackUuid);
+        } catch (Exception ex) {
+            addLogSms.setStatus(3);
+            addLogSms.setResult(ex.getMessage());
+            log.error("sendMsgBatch 异常:", ex);
+        } finally {
+            companyVoiceRoboticCallLogSendmsgService.asyncInsertCompanyVoiceRoboticCallLog(addLogSms);
+        }
+    }
+
+    /**
+     * 保存加微日志
+     */
+    private void saveAddWxLog(
+            JSONObject runParamSms,
+            CompanyWxClient4WorkFlowVO client,
+            QwUser qwUser,
+            NodeConfig config) {
+
+        CompanyVoiceRoboticCallLogAddwx addLogAddWx = CompanyVoiceRoboticCallLogAddwx.initCallLog(
+                runParamSms.toJSONString(),
+                client.getId(),
+                client.getRoboticId(),
+                qwUser.getId(),
+                qwUser.getCompanyId(),
+                config.qwWxAddWayId
+        );
+
+        addLogAddWx.setStatus(1);
+        addLogAddWx.setResult(JSON.toJSONString(R.ok()));
+        addLogAddWx.setIsWeCom(2);
+
+        asyncSaveCompanyVoiceRoboticCallLog(addLogAddWx);
+    }
+
+
+    /**
+    * 获取获客链接
+    */
+    private String getLinkUrl(QwUser qwUser){
+
+        String link = redisCache2.getCacheObject("customerLink:"+qwUser.getId());
+        if (link!=null && !StringUtil.strIsNullOrEmpty(link)){
+            return link;
+        }
+
+        //获取获客链接
+        QwLinkCreateParam createParam=new QwLinkCreateParam();
+        createParam.setLink_name(qwUser.getQwUserName()+"的获客链接");
+
+        QwLinkCreateParam.Range range=new QwLinkCreateParam.Range();
+        range.setUser_list(Collections.singletonList(qwUser.getQwUserId()));
+        createParam.setRange(range);
+
+        QwLinkCreateResult result = qwApiService.linkCreate(createParam, qwUser.getCorpId());
+
+        if (result.getErrcode()==0){
+
+            redisCache2.setCacheObject("customerLink:"+qwUser.getId(),result.getUrl());
+
+            return  result.getUrl();
+        }else {
+            return null;
+        }
+
+
+    }
+
+    /**
+     * 构建加微请求参数
+     */
+    private JSONObject buildAddWxRunParam(QwUser qwUser, CompanyWxClient4WorkFlowVO client, String mobile) {
+        JSONObject runParam = new JSONObject();
+        runParam.put("qwId", qwUser.getId());
+        runParam.put("mobile", mobile);
+        runParam.put("qwUid", qwUser.getUid());
+        runParam.put("clientId", client.getId());
+        return runParam;
+    }
+
+    /**
+     * 构建短信发送参数
+     */
+    private SmsSendBatchParam buildSmsSendParam(
+            QwUser qwUser,
+            CompanyWxClient4WorkFlowVO client,
+            CompanySmsTemp temp,
+            String cardUrl) {
+
+        SmsSendBatchParam param = new SmsSendBatchParam();
+        param.setCompanyId(qwUser.getCompanyId());
+        param.setCompanyUserId(qwUser.getCompanyUserId());
+        param.setSmsType(temp.getTempType());
+        param.setTempCode(temp.getTempCode());
+        param.setContent(temp.getContent());
+        param.setSenderName(qwUser.getQwUserName());
+        param.setCustomerIds(new Long[]{client.getCustomerId()});
+        if (!StringUtil.strIsNullOrEmpty(client.getTraceId())){
+            param.setCardUrl(cardUrl+"?customer_channel="+client.getTraceId());
+        }else {
+            param.setCardUrl(cardUrl);
+        }
+
+        return param;
+    }
+
+
+    /**
+     * 触发后续工作流步骤
+     */
+    private void triggerNextWorkflowSteps(
+            List<CompanyWxClient> updateList,
+            Map<Long, CompanyWxClient4WorkFlowVO> clientMap) {
+
+        for (CompanyWxClient client : updateList) {
+            CompanyWxClient4WorkFlowVO vo = clientMap.get(client.getAccountId());
+            IWorkflowNode node = workflowNodeFactory.createNode(
+                    vo.getCurrentNodeKey(),
+                    NodeTypeEnum.fromValue(vo.getCurrentNodeType()),
+                    vo.getCurrentNodeName(),
+                    null
+            );
+
+            if (node instanceof AiQwAddWxTaskNode) {
+                CompletableFuture.runAsync(() -> {
+                    AiQwAddWxTaskNode qwAddWxNode = (AiQwAddWxTaskNode) node;
+                    qwAddWxNode.doneQwAddWx(vo.getWorkflowInstanceId());
+                }, cidExcutor);
+            }
+        }
+    }
+
+    /**
+     * 节点配置内部类
+     */
+    private static class NodeConfig {
+        private int qwWxAddWayId;
+        private int smsTempId;
+    }
+
+// ... existing code ...
+
+//    public void qwAddWx(List<Long> accountIdList) {
+//        log.info("==========执行申请企微加好友任务开始==========");
+//        try {
+//            // 需要添加微信的列表
+//            List<CompanyWxClient4WorkFlowVO> list = companyWxClientService.getQwAddWxList4Workflow(accountIdList);
+//            log.info("申请企微加好友任务需要添加微信的数量:{}", list.size());
+//            if (list.isEmpty()) return;
+//            List<CompanyWxClient> addList = new ArrayList<>();
+//            Map<Long, CompanyWxClient4WorkFlowVO> clientMap = PubFun.listToMapByGroupObject(list, CompanyWxClient4WorkFlowVO::getAccountId);
+//            // 获取实际企微用户信息
+//            List<QwUser> addAccountList = qwUserMapper.selectBatchIds(clientMap.keySet()).stream()
+//                    .filter(this::isValidQwUser)
+//                    .collect(Collectors.toList());
+//            log.info("企微申请加好友任务需要企微的账号数量:{}", addAccountList.size());
+//            addAccountList.forEach(qwUser -> {
+//                CompanyWxClient4WorkFlowVO client = clientMap.get(qwUser.getId());
+//                if (client != null) {
+//                    CrmCustomer crmCustomer = crmCustomerService.selectCrmCustomerById(client.getCustomerId());
+//
+//                    int qwWxAddWayId = 1;  // 先固定为1
+//                    int smsTempId= 1; // 先固定为1
+//                    try {
+//                        String nodeConfig = client.getNodeConfig();
+//                        if (nodeConfig != null && !nodeConfig.trim().isEmpty()) {
+//                            JsonObject configJson = JsonParser.parseString(nodeConfig).getAsJsonObject();
+//                            if (configJson.has("qwWxAddWayId") && !configJson.get("qwWxAddWayId").isJsonNull()) {
+//                                qwWxAddWayId = configJson.get("qwWxAddWayId").getAsInt();
+//                            }
+//                            smsTempId = configJson.get("smsTempId").getAsInt();
+//                        }
+//                    } catch (Exception e) {
+//                        // 报错了也不处理,继续使用1
+//                        log.error("解析配置出错,但保持加微使用默认值1: " + e.getMessage());
+//                    }
+//
+//                    switch (qwWxAddWayId){
+//                        case 1:
+//                            // 开始主动申请加微
+//                            WxWorkResponseDTO<String> resp = qwAddWxInvokeIpad(crmCustomer.getMobile(), qwUser.getUid(),qwUser.getServerId(),qwUser.getVid(),qwUser.getQwUserName());
+//                            JSONObject runParam = new JSONObject();
+//                            runParam.put("qwId", qwUser.getId());
+//                            runParam.put("mobile", crmCustomer.getMobile());
+//                            runParam.put("qwUid", qwUser.getUid());
+//                            runParam.put("clientId", client.getId());
+//
+//                            CompanyVoiceRoboticCallLogAddwx addLog = CompanyVoiceRoboticCallLogAddwx.initCallLog(
+//                                    runParam.toJSONString(), client.getId(), client.getRoboticId(), qwUser.getId(), qwUser.getCompanyId(),qwWxAddWayId);
+//                            if (resp != null && resp.getErrcode() == 0) {
+//                                // 加微消息已发送成功
+//                                client.setIsAdd(2);
+//                                client.setAddTime(LocalDateTime.now());
+//                                CompanyWxClient addItem = new CompanyWxClient();
+//                                BeanUtils.copyProperties(client, addItem);
+//                                addList.add(addItem);
+//                                addLog.setStatus(1);
+//                                addLog.setResult(JSON.toJSONString(resp));
+//                                addLog.setIsWeCom(2);
+//                                log.info("ROBOTIC-ID:{},企微申请加好友任务申请成功", client.getRoboticId());
+//                            } else {
+//                                log.error("ROBOTIC-ID:{},企微申请加好友任务加微失败:{}", client.getRoboticId(), runParam);
+//                                addLog.setStatus(3);
+//                                addLog.setResult(JSON.toJSONString(runParam));
+//
+//                                client.setIsAdd(3);
+//                                client.setAddTime(LocalDateTime.now());
+//                                CompanyWxClient addItem = new CompanyWxClient();
+//                                BeanUtils.copyProperties(client, addItem);
+//                                addList.add(addItem);
+//                            }
+//                            asyncSaveCompanyVoiceRoboticCallLog(addLog);
+//                            break;
+//                        case 2:
+//                            //短信-获客链接
+//
+//                            CompanySmsTemp temp = smsTempService.selectCompanySmsTempById((long) smsTempId);
+//
+//                            if (temp != null && temp.getStatus().equals(1) && temp.getIsAudit().equals(1)) {
+//
+//                                CompanySms sms=companySmsService.selectCompanySmsByCompanyId(qwUser.getCompanyId());
+//                                if(sms!=null){
+//                                    if(sms.getRemainSmsCount()>0){
+//                                        SmsSendBatchParam smsSendBatchParam = new SmsSendBatchParam();
+//                                        smsSendBatchParam.setCompanyId(qwUser.getCompanyId());
+//                                        smsSendBatchParam.setCompanyUserId(qwUser.getCompanyUserId());
+//                                        smsSendBatchParam.setSmsType(temp.getTempType());
+//                                        smsSendBatchParam.setTempCode(temp.getTempCode());
+//                                        smsSendBatchParam.setContent(temp.getContent());
+//                                        smsSendBatchParam.setSenderName(client.getWxNickName());
+//                                        smsSendBatchParam.setCustomerIds(new Long[]{client.getCustomerId()});
+//                                        //记录工作流级短信日志
+//                                        JSONObject runParamSms = (JSONObject) JSON.toJSON(smsSendBatchParam);
+//                                        runParamSms.put("temp", temp);
+//                                        CompanyVoiceRoboticCallLogSendmsg addLogSms = CompanyVoiceRoboticCallLogSendmsg.initCallLog(
+//                                                runParamSms.toJSONString(),
+//                                                null,
+//                                                null,
+//                                                qwUser.getCompanyId(),
+//                                                qwUser.getCompanyUserId(),
+//                                                temp.getTempId()
+//                                        );
+//
+//                                        addLogSms.setStatus(1);
+//                                        try{
+//                                            String callbackUuid = UUID.randomUUID().toString();
+//                                            int smsContentLen = getSmsContentLen(smsSendBatchParam);
+//                                            addLogSms.setContentLen(smsContentLen);
+//                                            companyVoiceRoboticServiceImpl.sendMsgBatch(temp,smsSendBatchParam);
+//                                            addLogSms.setStatus(2);
+//                                            addLogSms.setCallbackUuid(callbackUuid);
+//                                        } catch(Exception ex){
+//                                            addLogSms.setStatus(3);
+//                                            addLogSms.setResult(ex.getMessage());
+//                                            log.error("sendMsgOne异常:",ex);
+//                                        } finally {
+//                                            //短信记录表
+//                                            companyVoiceRoboticCallLogSendmsgService.asyncInsertCompanyVoiceRoboticCallLog(addLogSms);
+//                                        }
+//
+//                                        CompanyVoiceRoboticCallLogAddwx addLogAddWx = CompanyVoiceRoboticCallLogAddwx.initCallLog(
+//                                                runParamSms.toJSONString(), client.getId(), client.getRoboticId(), qwUser.getId(), qwUser.getCompanyId(),qwWxAddWayId);
+//
+//                                            // 加微中
+//                                            client.setIsAdd(2);
+//                                            client.setAddTime(LocalDateTime.now());
+//                                            CompanyWxClient addItem = new CompanyWxClient();
+//                                            BeanUtils.copyProperties(client, addItem);
+//                                            addList.add(addItem);
+//
+//                                            addLogAddWx.setStatus(1);
+//                                            addLogAddWx.setResult(JSON.toJSONString(R.ok()));
+//                                            addLogAddWx.setIsWeCom(2);
+//
+//                                        asyncSaveCompanyVoiceRoboticCallLog(addLogAddWx);
+//
+//                                    }
+//                                    else{
+//                                        log.error("qw剩余短信数量不足,请充值:{}",client.getCompanyId());
+//                                        throw new RuntimeException("剩余短信数量不足,请充值");
+//                                    }
+//                                }
+//                                else{
+//                                    log.error("qw请充值:companyId:{}",client.getCompanyId());
+//                                    throw new RuntimeException("请充值");
+//                                }
+//
+//                            } else {
+//                                log.error("模板未审核:smsTemp:{}", temp);
+//                                throw new RuntimeException("模板未审核");
+//                            }
+//
+//
+//                            break;
+//                        default:
+//                            break;
+//                    }
+//
+//
+//                } else {
+//                    log.error("企微申请加好友任务当前账号暂无需要添加微信:{}-{}", qwUser.getId(), qwUser.getQwUserName());
+//                }
+//            });
+//            if (!addList.isEmpty()) {
+//                companyWxClientService.updateBatchById(addList);
+//                for (CompanyWxClient client : addList) {
+//                    CompanyWxClient4WorkFlowVO vo = clientMap.get(client.getAccountId());
+//                    IWorkflowNode node = workflowNodeFactory.createNode(vo.getCurrentNodeKey(),
+//                            NodeTypeEnum.fromValue(vo.getCurrentNodeType()),
+//                            vo.getCurrentNodeName(), null);
+//                    if (node instanceof AiQwAddWxTaskNode) {
+//                        CompletableFuture.runAsync(() -> {
+//                            AiQwAddWxTaskNode qwAddWxNode = (AiQwAddWxTaskNode) node;
+//                            qwAddWxNode.doneQwAddWx(vo.getWorkflowInstanceId());
+//                        }, cidExcutor);
+//                    }
+//                }
+//            }
+//        } catch (Exception e) {
+//            log.error("企微申请加好友任务执行异常", e);
+//        }
+//        log.info("==========执行企微申请加好友任务结束==========");
+//    }
+
+
+
+    public int getSmsContentLen(SmsSendBatchParam param){
+        CompanyUser companyUser=companyUserService.selectCompanyUserById(param.getCompanyUserId());
+
+        CrmCustomer crmCustomer=crmCustomerService.selectCrmCustomerById(param.getCustomerIds()[0].longValue());
+        String  content=param.getContent();
+        if(StringUtils.isNotEmpty(crmCustomer.getCustomerName())){
+            content=content.replace("${sms.csName}",crmCustomer.getCustomerName());
+        }
+        if(companyUser!=null&& StringUtils.isNotEmpty(companyUser.getPhonenumber())){
+            content=content.replace("${sms.phoneNumber}",companyUser.getPhonenumber());
+        }
+        if(StringUtils.isNotEmpty(param.getCardUrl())){
+            content=content.replace("${sms.cardUrl}",param.getCardUrl());
+        }
+        if(StringUtils.isNotEmpty(param.getSenderName())){
+            content=content.replace("${sms.senderName}",param.getSenderName());
+        }
+
+        return content.length();
+    }
+
     /**
      * 企微加微结果处理
      */