DracScrmWelcomeConfigService.java 22.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
package cn.com.glsx.entmicro.service;

import cn.com.glsx.entmicro.constants.Constants;
import cn.com.glsx.entmicro.constants.DracConstant;
import cn.com.glsx.entmicro.converter.DracScrmWelcomeConfigConvert;
import cn.com.glsx.entmicro.dto.DracScrmWelcomeConfigDTO;
import cn.com.glsx.entmicro.entity.Customer;
import cn.com.glsx.entmicro.entity.DracScrmWelcomeConfigEntity;
import cn.com.glsx.entmicro.manager.QyMediaUplaodComponent;
import cn.com.glsx.entmicro.manager.QySendContactMsgComponent;
import cn.com.glsx.entmicro.mapper.DracScrmWelcomeConfigMapper;
import cn.com.glsx.entmicro.model.CustomerReceiptModel;
import cn.com.glsx.entmicro.model.MassBuryingPointParameter;
import cn.com.glsx.entmicro.model.request.DracChannelCodeWelcomeInfoRequest;
import cn.com.glsx.entmicro.model.request.MediaReuquest;
import cn.com.glsx.entmicro.model.response.drainage.DracScrmWelcomeConfigEntityVO;
import cn.com.glsx.entmicro.model.response.DracChannelCodeWelcomeInfoResponse;
import cn.com.glsx.entmicro.util.EmojiUtils;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.CollectionUtils;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author wangxw
 * @version 1.0.0
 * @ClassName DracScrmWelcomeConfigService.java
 * @description: 欢迎语配置服务
 * @createTime 2021年11月10日 11:29:00
 */
@Slf4j
@Service
public class DracScrmWelcomeConfigService {

    // 1文本,2图片,3视频,4链接,5小程序,6附件,7活动
    private static final String uploadQyMediaType = "2,3,6";

    @Autowired
    private DracScrmWelcomeConfigMapper dracScrmWelcomeConfigMapper;

    @Autowired
    private QyMediaUplaodComponent qyMediaUplaodComponent;
    @Autowired
    private QySendContactMsgComponent qySendContactMsgComponent;

    @Autowired
    private Environment environment;

    /**
     * 保存欢迎语信息
     *
     * @param dracScrmWelcomeConfigDTO
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {RpcServiceException.class})
    public DracScrmWelcomeConfigDTO saveDracScrmWelcomeConfig(DracScrmWelcomeConfigDTO dracScrmWelcomeConfigDTO) {
        if (dracScrmWelcomeConfigDTO == null) {
            return dracScrmWelcomeConfigDTO;
        }
        DracScrmWelcomeConfigEntity dracScrmWelcomeConfigEntity = new DracScrmWelcomeConfigEntity();
        /*
        保存时不再生成企微临时素材
        // 上传企微多媒体资料
        String mediaId = qyMediaUplaodComponent.uploadMediaToQy(dracScrmWelcomeConfigDTO);
        dracScrmWelcomeConfigDTO.setMediaId(mediaId);*/
        dracScrmWelcomeConfigDTO.setMediaDate(new Date());
        BeanUtils.copyProperties(dracScrmWelcomeConfigDTO, dracScrmWelcomeConfigEntity);
        dracScrmWelcomeConfigMapper.insertUseGeneratedKeys(dracScrmWelcomeConfigEntity);
        log.info("drac scrm welcome config single insert result:{}", JSONObject.toJSONString(dracScrmWelcomeConfigEntity));
        if (dracScrmWelcomeConfigEntity.getId() != null) {
            dracScrmWelcomeConfigDTO.setId(dracScrmWelcomeConfigEntity.getId());
        }
        return dracScrmWelcomeConfigDTO;
    }

    /**
     * 批量保存欢迎语信息
     *
     * @param saveDracScrmWelcomeConfigList
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {RpcServiceException.class})
    public Boolean saveDracScrmWelcomeConfigList(List<DracScrmWelcomeConfigDTO> saveDracScrmWelcomeConfigList) {
        if (CollectionUtils.isEmpty(saveDracScrmWelcomeConfigList)) {
            return false;
        }

        List<DracScrmWelcomeConfigEntity> saveList = new ArrayList<>();
        // 附件内容的排序,从2开始(文本内容默认1)
        int i = 2;
        for (DracScrmWelcomeConfigDTO dracScrmWelcome : saveDracScrmWelcomeConfigList) {
            if (dracScrmWelcome.getAttType().equals(DracConstant.AttType.TEXT)) {
                // 文本内容的排序在最前面
                dracScrmWelcome.setAttNum(1);
            } else {
                dracScrmWelcome.setAttNum(i);
            }
            dracScrmWelcome.setMediaDate(new Date());
            DracScrmWelcomeConfigEntity dracScrmWelcomeEntity = new DracScrmWelcomeConfigEntity();
            BeanUtils.copyProperties(dracScrmWelcome, dracScrmWelcomeEntity);
            saveList.add(dracScrmWelcomeEntity);
            i++;
        }
        dracScrmWelcomeConfigMapper.insertList(saveList);
        return true;
    }

    /**
     * 批量 更新欢迎语信息
     *
     * @param saveDracScrmWelcomeConfigList
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {RpcServiceException.class})
    public Boolean updateDracScrmWelcomeConfigList(String uuid, String businessDesc, List<DracScrmWelcomeConfigDTO> saveDracScrmWelcomeConfigList) {
        if (CollectionUtils.isEmpty(saveDracScrmWelcomeConfigList)) {
            return false;
        }

        // 删除旧的数据,保存新的附件内容
        deleteByUuid(uuid, businessDesc);
        // 保存欢迎语 附件内容
        saveDracScrmWelcomeConfigList(saveDracScrmWelcomeConfigList);
        return true;
    }

    /**
     * 发送欢迎语
     *
     * @param welcomeCode
     * @param uuid
     * @param businessDesc
     * @param externalUserNickName
     * @return
     */
    public Boolean sendWelcomeCode(String welcomeCode, String uuid, String businessDesc, String externalUserNickName) throws RpcServiceException {
        RpcAssert.assertNotEmpty(welcomeCode, DefaultErrorEnum.PARAMETER_NULL, "welcomeCode must not be empty");
        RpcAssert.assertNotEmpty(uuid, DefaultErrorEnum.PARAMETER_NULL, "uuid must not be empty");
        RpcAssert.assertNotEmpty(businessDesc, DefaultErrorEnum.PARAMETER_NULL, "businessDesc must not be empty");
        log.info("send welcomeconfig to customer:{}, UUID:{}, businessDesc:{}", welcomeCode, uuid, businessDesc);
        List<DracScrmWelcomeConfigDTO> dracScrmWelcomeConfigDTOList = getQySendContactDataList(uuid, businessDesc, externalUserNickName, null, null, null);
        if (CollectionUtils.isEmpty(dracScrmWelcomeConfigDTOList)) {
            throw new RpcServiceException("welcome config content is empty");
        }
        Boolean sendResult = qySendContactMsgComponent.sendContactWelcome(welcomeCode, dracScrmWelcomeConfigDTOList);
        log.info("send welcomeconfig result:{}", sendResult);
        return sendResult;
    }

    /**
     * 获取可发送的企微消息内容(执行素材上传,昵称替换)
     *
     * @param uuid
     * @param businessDesc
     * @param externalUserNickName 非必填,客户昵称
     * @param customerId           非必填,客户ID(用于手机号回填)
     * @return
     */
    public List<DracScrmWelcomeConfigDTO> getQySendContactDataList(String uuid, String businessDesc, String externalUserNickName, Integer customerId, Boolean flag, Boolean momentflag) {
        List<DracScrmWelcomeConfigDTO> scrmWelcomeConfigList = getDracScrmWelcomeConfigList(uuid, businessDesc);
        if (flag != null && flag) {
            return scrmWelcomeConfigList;
        }
        if (CollectionUtils.isEmpty(scrmWelcomeConfigList)) {
            return null;
        }

        String externalUserNickHolder = environment.getProperty("drac.welcomeconfig.qywechat.message.nickname.holder");
        DracScrmWelcomeConfigDTO miniPathConvert = null;
        for (DracScrmWelcomeConfigDTO scrmDTO : scrmWelcomeConfigList) {
            String mediaId = StringUtils.EMPTY;
            if (uploadQyMediaType.contains(String.valueOf(scrmDTO.getAttType()))) {
                // 1、支持多媒体文件发送
                mediaId = qyMediaUplaodComponent.uploadMediaToQy(scrmDTO, momentflag);
            } else if (scrmDTO.getAttType().equals(DracConstant.AttType.ACTIVITY)) {
                // 先生成测试链接
                miniPathConvert = qyMediaUplaodComponent.buildUriInfo(scrmDTO, customerId);
                // 2、支持活动-小程序发送
                String content = qyMediaUplaodComponent.getActivityMiniConfig(scrmDTO, customerId, momentflag);
                if (momentflag == null || !momentflag) {
                    scrmDTO.setAttType(DracConstant.AttType.MINIPROGRAM);
                    scrmDTO.setAttContent(content);
                } else {
                    JSONObject jsonObject = JSONObject.parseObject(content);
                    mediaId = jsonObject.getString("mediaId");
                    scrmDTO.setAttType(DracConstant.AttType.URI);
                    scrmDTO.setAttContent(miniPathConvert.getAttContent());
                }
            }else if (scrmDTO.getAttType().equals(DracConstant.AttType.MINIPROGRAM)) {
                // 先生成测试链接
                miniPathConvert = qyMediaUplaodComponent.getTestUriInfo(scrmDTO, customerId);
                String content=qyMediaUplaodComponent.getMiniConfig(scrmDTO);
                log.info("发送小程序参数{}",content);
                scrmDTO.setAttType(DracConstant.AttType.MINIPROGRAM);
                scrmDTO.setAttContent(content);
            } else if (scrmDTO.getAttType().equals(DracConstant.AttType.URI)) {
                mediaId = qyMediaUplaodComponent.uploadMediaToQy(scrmDTO, momentflag);
            }
            // 3、支持昵称
            if (scrmDTO.getAttType().equals(DracConstant.AttType.TEXT)) {
                String content = scrmDTO.getAttContent().replace(externalUserNickHolder, (StringUtils.isNotBlank(externalUserNickName)) ? externalUserNickName : StringUtil.EMPTY_STRING);
                String messageContent = EmojiUtils.parseToUnicode(content);
                scrmDTO.setAttContent(messageContent);
            }
            scrmDTO.setMediaId(mediaId);
        }

        /*
            支持测试环境测试活动小程序链接,如果存在活动则自动生成一个小程序短链用于测试
         */
        String miniPathConvertUri = environment.getProperty("drac.welcomeconfig.qywechat.message.minipath.convert");
        if (!org.springframework.util.StringUtils.isEmpty(miniPathConvertUri) && "on".equals(miniPathConvertUri) && miniPathConvert != null) {
            if (momentflag == null || !momentflag) {
                scrmWelcomeConfigList.add(miniPathConvert);
            }
        }
        return scrmWelcomeConfigList;
    }

    /**
     * 获取可发送的企微消息内容(执行素材上传,昵称替换)(群发助手使用)
     *
     * @param uuid
     * @param businessDesc
     * @param externalUserNickName 非必填,客户昵称
     * @param customerId           非必填,客户ID(用于手机号回填)
     * @param parameterList        活动埋点参数
     * @return
     */
    public List<DracScrmWelcomeConfigDTO> getQySendContactDataList(String uuid, String businessDesc, String externalUserNickName, Integer customerId, Boolean flag, Boolean momentflag, List<MassBuryingPointParameter> parameterList) {
        List<DracScrmWelcomeConfigDTO> scrmWelcomeConfigList = getDracScrmWelcomeConfigList(uuid, businessDesc);
        if (flag != null && flag) {
            return scrmWelcomeConfigList;
        }
        if (CollectionUtils.isEmpty(scrmWelcomeConfigList)) {
            return null;
        }

        String externalUserNickHolder = environment.getProperty("drac.welcomeconfig.qywechat.message.nickname.holder");
        DracScrmWelcomeConfigDTO miniPathConvert = null;
        for (DracScrmWelcomeConfigDTO scrmDTO : scrmWelcomeConfigList) {
            String mediaId = StringUtils.EMPTY;
            if (uploadQyMediaType.contains(String.valueOf(scrmDTO.getAttType()))) {
                // 1、支持多媒体文件发送
                mediaId = qyMediaUplaodComponent.uploadMediaToQy(scrmDTO, momentflag);
            } else if (scrmDTO.getAttType().equals(DracConstant.AttType.ACTIVITY)) {
                // 先生成测试链接
                if (parameterList == null || parameterList.isEmpty()) {
                    miniPathConvert = qyMediaUplaodComponent.buildUriInfo(scrmDTO, customerId);
                } else {
                    miniPathConvert = qyMediaUplaodComponent.buildUriInfo(scrmDTO, customerId, parameterList);
                }
                // 2、支持活动-小程序发送
                String content = StringUtils.EMPTY;
                if (parameterList == null || parameterList.isEmpty()) {
                    content = qyMediaUplaodComponent.getActivityMiniConfig(scrmDTO, customerId, momentflag);
                } else {
                    content = qyMediaUplaodComponent.getActivityMiniConfig(scrmDTO, customerId, momentflag, parameterList);
                }
                if (momentflag == null || !momentflag) {
                    scrmDTO.setAttType(DracConstant.AttType.MINIPROGRAM);
                    scrmDTO.setAttContent(content);
                } else {
                    JSONObject jsonObject = JSONObject.parseObject(content);
                    mediaId = jsonObject.getString("mediaId");
                    scrmDTO.setAttType(DracConstant.AttType.URI);
                    scrmDTO.setAttContent(miniPathConvert.getAttContent());
                }
            } else if (scrmDTO.getAttType().equals(DracConstant.AttType.URI)) {
                if (momentflag != null && momentflag){
                    mediaId = qyMediaUplaodComponent.uploadMediaToQy(scrmDTO, momentflag);
                } else {
                    qyMediaUplaodComponent.buildLinkUriInfo(scrmDTO,parameterList);
                }
            }else if (scrmDTO.getAttType().equals(DracConstant.AttType.MINIPROGRAM)) {
                String content=qyMediaUplaodComponent.getMiniConfig(scrmDTO);
                log.info("发送小程序参数{}",content);
                scrmDTO.setAttType(DracConstant.AttType.MINIPROGRAM);
                scrmDTO.setAttContent(content);
            }

            // 3、支持昵称
            if (scrmDTO.getAttType().equals(DracConstant.AttType.TEXT)) {
                String content = scrmDTO.getAttContent().replace(externalUserNickHolder, (StringUtils.isNotBlank(externalUserNickName)) ? externalUserNickName : StringUtil.EMPTY_STRING);
                String messageContent = EmojiUtils.parseToUnicode(content);
                scrmDTO.setAttContent(messageContent);
            }
            scrmDTO.setMediaId(mediaId);
        }

        /*
            支持测试环境测试活动小程序链接,如果存在活动则自动生成一个小程序短链用于测试
         */
        String miniPathConvertUri = environment.getProperty("drac.welcomeconfig.qywechat.message.minipath.convert");
        if (!org.springframework.util.StringUtils.isEmpty(miniPathConvertUri) && "on".equals(miniPathConvertUri) && miniPathConvert != null) {
            if (momentflag == null || !momentflag) {
                scrmWelcomeConfigList.add(miniPathConvert);
            }
        }
        return scrmWelcomeConfigList;
    }

    /**
     * 发送欢迎语 - 增加客户ID用于回填手机号
     *
     * @param welcomeCode
     * @param uuid
     * @param businessDesc
     * @param externalUserNickName
     * @param customerId
     * @return
     */
    public Boolean sendWelcomeCodeAddPhone(String welcomeCode, String uuid, String businessDesc, String externalUserNickName, Integer customerId) throws RpcServiceException {
        RpcAssert.assertNotEmpty(welcomeCode, DefaultErrorEnum.PARAMETER_NULL, "welcomeCode must not be empty");
        RpcAssert.assertNotEmpty(uuid, DefaultErrorEnum.PARAMETER_NULL, "uuid must not be empty");
        RpcAssert.assertNotEmpty(businessDesc, DefaultErrorEnum.PARAMETER_NULL, "businessDesc must not be empty");
        log.info("send welcomeconfig to customer:{}, UUID:{}, externalUserNickName: {},businessDesc:{}", welcomeCode, uuid, externalUserNickName, businessDesc);
        List<DracScrmWelcomeConfigDTO> dracScrmWelcomeConfigDTOList = getQySendContactDataList(uuid, businessDesc, externalUserNickName, customerId, null, null);
        if (CollectionUtils.isEmpty(dracScrmWelcomeConfigDTOList)) {
            throw new RpcServiceException("welcome config content is empty");
        }
        Boolean sendResult = qySendContactMsgComponent.sendContactWelcome(welcomeCode, dracScrmWelcomeConfigDTOList);
        log.info("send welcomeconfig result:{}", sendResult);
        return sendResult;
    }

    /**
     * 获取欢迎语列表
     *
     * @param uuid
     * @param businessDesc
     * @return
     */
    public List<DracScrmWelcomeConfigDTO> getDracScrmWelcomeConfigList(String uuid, String businessDesc) {
        if (StringUtils.isEmpty(uuid) || StringUtils.isEmpty(businessDesc)) {
            return null;
        }
        /*DracScrmWelcomeConfigEntity selectCondition = new DracScrmWelcomeConfigEntity();
        selectCondition.setBusinessUuid(uuid);
        selectCondition.setBusinessDesc(businessDesc);*/
        Example condition = new Example(DracScrmWelcomeConfigEntity.class);
        condition.setOrderByClause("att_num");
        condition.createCriteria().
                andEqualTo("businessUuid", uuid).
                andEqualTo("businessDesc", businessDesc);
        List<DracScrmWelcomeConfigEntity> dataList = dracScrmWelcomeConfigMapper.selectByExample(condition);
        return DracScrmWelcomeConfigConvert.convertDataToDTOList(dataList);
    }

    /**
     * 通过uuid删除
     *
     * @param uuid
     * @param businessDesc
     */
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {RpcServiceException.class})
    public void deleteByUuid(String uuid, String businessDesc) {
        dracScrmWelcomeConfigMapper.deleteByUuid(uuid, businessDesc);
    }

    /**
     * 通过uuid批量删除
     *
     * @param uuidList
     * @param businessDesc
     */
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {RpcServiceException.class})
    public void deleteByBatchUuid(List<String> uuidList, String businessDesc) {
        dracScrmWelcomeConfigMapper.deleteByBatchUuid(uuidList, businessDesc);
    }

    /**
     * 获取素材url
     *
     * @param mediaIds 素材ids列表
     * @return
     */
    public Map<String, String> getMediaUrl(List<MediaReuquest> mediaIds) {
        Map<String, String> map = new HashMap<>();
        mediaIds.forEach(index -> {
            String mediaUrl = qyMediaUplaodComponent.getMediaUrl(index);
            map.put(index.getMediaId(), mediaUrl);
        });
        return map;
    }

    /**
     * uuid查询是否有欢迎语
     *
     * @param uuidList
     * @return
     */
    public List<DracScrmWelcomeConfigEntityVO> getWelcomeMap(List<String> uuidList, String businessDesc) {
        return dracScrmWelcomeConfigMapper.getListByUuid(uuidList, businessDesc);
    }

    /**
     * 获取并转化欢迎语内容
     *
     * @param dracScrmWelcomeConfigList
     * @return
     */
    public List<DracChannelCodeWelcomeInfoResponse> getAndTransformWelcomeConfig(List<DracScrmWelcomeConfigDTO> dracScrmWelcomeConfigList) {
        //参数转换
        List<DracChannelCodeWelcomeInfoResponse> codeWelcomeInfoResponses = new ArrayList<>();
        if (!org.springframework.util.CollectionUtils.isEmpty(dracScrmWelcomeConfigList)) {
            codeWelcomeInfoResponses = dracScrmWelcomeConfigList.stream().map(index -> {
                DracChannelCodeWelcomeInfoResponse codeWelcomeInfoResponse = new DracChannelCodeWelcomeInfoResponse();
                codeWelcomeInfoResponse.setAttNum(index.getAttNum());
                codeWelcomeInfoResponse.setAttType(index.getAttType());
                //欢迎语文本内容emoji转化
                if (index.getAttType().equals(DracConstant.AttType.TEXT)) {
                    codeWelcomeInfoResponse.setAttContent(index.getAttContent() != null ? EmojiUtils.parseToUnicode(index.getAttContent()) : null);
                } else {
                    codeWelcomeInfoResponse.setAttContent(index.getAttContent());
                }
                codeWelcomeInfoResponse.setBusinessDesc(index.getBusinessDesc());
                codeWelcomeInfoResponse.setMerchantId(index.getMerchantId());
                codeWelcomeInfoResponse.setMediaId(index.getMediaId());
                return codeWelcomeInfoResponse;
            }).collect(Collectors.toList());
        }
        return codeWelcomeInfoResponses;
    }

    /**
     * 上传临时素材到企微
     *
     * @param attContent
     * @param attType
     * @param merchantId
     * @param momentflag
     * @return
     */
    public String uploadMediaGetMediaId(String attContent, Integer attType, Integer merchantId, Boolean momentflag) {
        String mediaId = qyMediaUplaodComponent.uploadMediaGetMediaId(attContent, attType, merchantId, momentflag);
        return mediaId;
    }

    /**
     * 其他业务类保存欢迎语参数构建
     *
     * @param attachmentList
     * @param businessUuid
     * @param businessDesc   {@link cn.com.glsx.entmicro.constants.DracConstant}
     * @param merchantId
     * @return
     */
    public List<DracScrmWelcomeConfigDTO> parseWelcomeInfo(List<DracChannelCodeWelcomeInfoRequest> attachmentList,
                                                           String businessUuid, String businessDesc, Integer merchantId) {
        if (CollectionUtils.isEmpty(attachmentList)) {
            return null;
        }
        Date now = new Date();
        int len = attachmentList.size();
        List<DracScrmWelcomeConfigDTO> list = new ArrayList<>(len);
        for (DracChannelCodeWelcomeInfoRequest request : attachmentList) {
            DracScrmWelcomeConfigDTO attachment = new DracScrmWelcomeConfigDTO();
            attachment.setBusinessUuid(businessUuid);
            attachment.setBusinessDesc(businessDesc);
            attachment.setAttType(request.getAttType());
            attachment.setAttContent(request.getAttContent());
            attachment.setMerchantId(merchantId);
            attachment.setDelFlag(Constants.NORMAL_FLAG);
            attachment.setCreatedTime(now);
            list.add(attachment);
        }
        return list;
    }

}