jiangping
2024-07-11 fc1030ae8bd1da1fed6e6f7138cb63de605467ef
提交
已添加6个文件
已修改5个文件
335 ■■■■■ 文件已修改
server/service/src/main/java/com/doumee/biz/zbom/ZbomCRMService.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/biz/zbom/ZbomIAMService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/biz/zbom/ZbomSMSService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/biz/zbom/ZbomZhongTaiService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomCRMServiceImpl.java 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomSMSServiceImpl.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/biz/zbom/model/CrmCustomerInfoModel.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/biz/zbom/model/CrmCustomerSubmmitModel.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/Constants.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/CrmInterfaceLog.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/InitService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/biz/zbom/ZbomCRMService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package com.doumee.biz.zbom;
import com.doumee.biz.zbom.model.CrmCustomerSubmmitModel;
import com.doumee.biz.zbom.model.IamUpateShopModel;
import com.doumee.biz.zbom.model.IamUpateUserModel;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * å¿—邦CRM对接业务接口
 * @author æ±Ÿè¹„蹄
 * @date 2023/11/30 15:33
 */
@Service
public interface ZbomCRMService {
    int postDataToCrm(CrmCustomerSubmmitModel entity );
}
server/service/src/main/java/com/doumee/biz/zbom/ZbomIAMService.java
@@ -9,7 +9,7 @@
import java.util.List;
/**
 * äººå‘˜ä¿¡æ¯è¡¨Service实现
 * å¿—邦IAM对接业务接口
 * @author æ±Ÿè¹„蹄
 * @date 2023/11/30 15:33
 */
server/service/src/main/java/com/doumee/biz/zbom/ZbomSMSService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
package com.doumee.biz.zbom;
import com.doumee.biz.zbom.model.CrmCustomerSubmmitModel;
import org.springframework.stereotype.Service;
/**
 * å¿—邦短信通道对接业务接口
 * @author æ±Ÿè¹„蹄
 * @date 2023/11/30 15:33
 */
@Service
public interface ZbomSMSService {
    boolean sendMessage(String content,String phone) ;
}
server/service/src/main/java/com/doumee/biz/zbom/ZbomZhongTaiService.java
@@ -5,7 +5,7 @@
import org.springframework.stereotype.Service;
/**
 * äººå‘˜ä¿¡æ¯è¡¨Service实现
 * å¿—邦中台对接业务接口
 * @author æ±Ÿè¹„蹄
 * @date 2023/11/30 15:33
 */
server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomCRMServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,116 @@
package com.doumee.biz.zbom.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.doumee.biz.zbom.ZbomCRMService;
import com.doumee.biz.zbom.model.CrmCustomerInfoModel;
import com.doumee.biz.zbom.model.CrmCustomerSubmmitModel;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.HttpsUtil;
import com.doumee.dao.business.CrmInterfaceLogMapper;
import com.doumee.dao.business.CustomerLogMapper;
import com.doumee.dao.business.model.CrmInterfaceLog;
import com.doumee.dao.business.model.CustomerLog;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.*;
/**
 * å¿—邦CRM客户信息提交接口
 * @author æ±Ÿè¹„蹄
 * @date 2023/11/30 15:33
 */
@Service
public class ZbomCRMServiceImpl implements ZbomCRMService {
    @Autowired
    private CustomerLogMapper customerLogMapper;
    @Autowired
    private CrmInterfaceLogMapper crmInterfaceLogMapper;
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    /**
     * å¿—邦客户信息提交接口
     * @param entity
     * @return
     */
    @Override
    public int postDataToCrm(CrmCustomerSubmmitModel entity )  {
        // TODO Auto-generated method stub
        int status = 2;
        if(entity==null || entity.getCusInfo()==null || entity.getCusInfo().size() ==0){
            return status;
        }
        String type = "postCusData";
        String appid = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_CRM_API_KEY);
        String urlStr =  (String)redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_CRM_API_URL) ;
        long _t = System.currentTimeMillis();
        String crmInfo="提交失败";
        if (StringUtils.isNotBlank(appid)||StringUtils.isNotBlank(urlStr)) {
            String token = DigestUtils.md5Hex(type + _t + appid);
            String url = urlStr + "?type=" + type + "&_t=" + _t + "&token=" + token;// æäº¤CRM地址
            String param = JSONObject.toJSONString(entity);
            int success =1;
            String result = null;
            try {
                  result = HttpsUtil.postJson(url,param);
                if (StringUtils.isNotBlank(result)) {
                    JSONObject r = JSONObject.parseObject(result.replace("(", "").replace(")", ""));
                    if (r != null && (StringUtils.equalsIgnoreCase(r.getString("code"), "1")
                            || StringUtils.equalsIgnoreCase(r.getString("code"), "2"))) {
                          status = 1;
                          crmInfo="提交成功";
                        success =0;
                    }else{
                        status = 2;
                        crmInfo="提交失败["+ result+"]";
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
                crmInfo+= e.getMessage();
            }finally {
                saveInterfaceLog(url,"志邦CRM客户留资信息提交",param,success,result);
            }
        }else{
            status = 2;
            crmInfo="提交失败crm配置有误,appid:["+ appid+"]"+"url:["+ urlStr+"]";
        }
        List<Long> idList = new ArrayList<>();
        for(CrmCustomerInfoModel info : entity.getCusInfo()){
            idList.add(info.getId());
        }
        // å¦‚果提交成功
        CustomerLog d = new CustomerLog();
        d.setId(entity.getCusInfo().get(0).getId());
        d.setCrmStatus(Constants.ONE);
        customerLogMapper.update(null,new UpdateWrapper<CustomerLog>().lambda()
                .in(CustomerLog::getId,idList)
                .set(CustomerLog::getCrmStatus,Constants.ONE )
                .set(CustomerLog::getCrmInfo,crmInfo )
                .set(CustomerLog::getCrmDate,new Date() ));// æ›´æ–°çŠ¶æ€
        return status;// é»˜è®¤å¤±è´¥
    }
    public  void  saveInterfaceLog(String url,String name,String  param,Integer success,String respone){
            CrmInterfaceLog log = new CrmInterfaceLog();
            log.setCreateDate(new Date());
            log.setUrl(url);
            log.setEditDate(log.getCreateDate());
            log.setPlat(Constants.ZERO);
            log.setName(name);
            log.setIsdeleted(Constants.ZERO);
            log.setRequest(param);
            log.setType(Constants.ONE);
            log.setSuccess(success);
            log.setRepose(respone);
            crmInterfaceLogMapper.insert(log);
    }
}
server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomSMSServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,107 @@
package com.doumee.biz.zbom.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.doumee.biz.zbom.ZbomCRMService;
import com.doumee.biz.zbom.ZbomSMSService;
import com.doumee.biz.zbom.model.CrmCustomerInfoModel;
import com.doumee.biz.zbom.model.CrmCustomerSubmmitModel;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.HttpsUtil;
import com.doumee.dao.business.CrmInterfaceLogMapper;
import com.doumee.dao.business.CustomerLogMapper;
import com.doumee.dao.business.model.CrmInterfaceLog;
import com.doumee.dao.business.model.CustomerLog;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * å¿—邦CRM客户信息提交接口
 * @author æ±Ÿè¹„蹄
 * @date 2023/11/30 15:33
 */
@Service
public class ZbomSMSServiceImpl implements ZbomSMSService  {
    @Autowired
    private CustomerLogMapper customerLogMapper;
    @Autowired
    private CrmInterfaceLogMapper crmInterfaceLogMapper;
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    /**
     * å¿—邦客户信息提交接口
     * @return
     */
    @Override
    public   boolean sendMessage(String content,String phone) {
        // TODO Auto-generated method stub
        if(StringUtils.isBlank(content)){
            return false;
        }
        String appkey = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_SMS_API_KEY);
        String urlStr =  (String)redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_SMS_API_URL) ;
        try {
            StringBuffer sb = new StringBuffer(urlStr);
            Integer _t = (int) System.currentTimeMillis();
            // å‘StringBuffer追加用户名
            sb.append("_t=" + _t);
            sb.append("&smsphone=" + phone);
            sb.append("&smscode=10005");
            // å‘StringBuffer追加密码(登陆网页版,在管理中心--基本资料--接口密码,是28位的)
            sb.append("&smsmsg=" + URLEncoder.encode(content.replace(" ", ""), "UTF-8"));
            // åР坆
            // 497fbc01e744ef44001296b7466148e8
            sb.append("&token=" + DigestUtils.md5Hex(phone + _t + appkey));
            // åˆ›å»ºurl对象
            URL url = new URL(sb.toString());
            // æ‰“å¼€url连接
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            // è®¾ç½®url请求方式 â€˜get’ æˆ–者 â€˜post’
            connection.setRequestMethod("POST");
            connection.setConnectTimeout(500);
            connection.setReadTimeout(500);
            // å‘送
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            // è¿”回发送结果
            String inputline = in.readLine();
            // è¿”回结果为‘0,20140009090990,1,提交成功’ å‘送成功 å…·ä½“见说明文档
            System.out.println(inputline);
            saveInterfaceLog(urlStr,"志邦短信发送接口", sb.toString(), 0,inputline);
            return true;//
        }catch (Exception e){
            return false;
        }
    }
    public  void  saveInterfaceLog(String url,String name,String  param,Integer success,String respone){
            CrmInterfaceLog log = new CrmInterfaceLog();
            log.setCreateDate(new Date());
            log.setUrl(url);
            log.setEditDate(log.getCreateDate());
            log.setPlat(Constants.ZERO);
            log.setName(name);
            log.setIsdeleted(Constants.ZERO);
            log.setRequest(param);
            log.setType(Constants.ONE);
            log.setSuccess(success);
            log.setRepose(respone);
            crmInterfaceLogMapper.insert(log);
    }
}
server/service/src/main/java/com/doumee/biz/zbom/model/CrmCustomerInfoModel.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,42 @@
package com.doumee.biz.zbom.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("志邦CRM客户留资提交明细参数")
public class CrmCustomerInfoModel implements Serializable {
    @ApiModelProperty(value = "人员编码")
    private Long id;
    @ApiModelProperty(value = "姓名")
    private String name;
    @ApiModelProperty(value = "手机号")
    private String phone;
    @ApiModelProperty(value = "设计师手机号")
    private String shopper;
    @ApiModelProperty(value = "来源")
    private String source;
    @ApiModelProperty(value = "渠道")
    private String channel;
    @ApiModelProperty(value = "日期 yyyy/MM/dd HH:mm")
    private String date;
    @ApiModelProperty(value = "推荐人手机号")
    private String recphone;
    @ApiModelProperty(value = "推荐人姓名")
    private String recname;
    @ApiModelProperty(value = "县区名称")
    private String areaname;
    @ApiModelProperty(value = "县区编码")
    private String areacode;
    @ApiModelProperty(value = "系统版本号")
    private String sysversion;
    @ApiModelProperty(value = "浏览器信息")
    private String browser;
    @ApiModelProperty(value = "小程序openid")
    private String openid;
    @ApiModelProperty(value = "终端信息")
    private String terminal;
}
server/service/src/main/java/com/doumee/biz/zbom/model/CrmCustomerSubmmitModel.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package com.doumee.biz.zbom.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel("志邦CRM客户留资提交参数")
public class CrmCustomerSubmmitModel implements Serializable {
    @ApiModelProperty(value = "客户信息")
    @JsonProperty("cus_info")
    @SerializedName("cus_info")
    private List<CrmCustomerInfoModel> cusInfo;
}
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -318,6 +318,10 @@
    public static final String WX_PLATFORM_APPID = "WX_PLATFORM_APPID";
    public static final String WX_PLATFORM_SECRET = "WX_PLATFORM_SECRET";
    public static final String WX_PLATFORM_AUDIT_VISIT = "WX_PLATFORM_AUDIT_VISIT";
    public static final String ZBOM_CRM_API_URL = "ZBOM_CRM_API_URL";
    public static final String ZBOM_CRM_API_KEY = "ZBOM_CRM_API_KEY";
    public static final String ZBOM_SMS_API_KEY = "ZBOM_SMS_API_KEY";
    public static final String ZBOM_SMS_API_URL = "ZBOM_SMS_API_URL";
    public static final String WX_PLATFORM_PREFIX = "WX_PLATFORM_PREFIX";
@@ -329,6 +333,10 @@
        public static final String IMPORTING_MEMBER ="IMPORTING_MEMBER";
        public static final String IMPORTING_SHOP ="IMPORTING_SHOP";
        public static final String IAM_APPID ="IAM_APPID";
        public static final String ZBOM_CRM_API_KEY ="ZBOM_CRM_API_KEY";
        public static final String ZBOM_CRM_API_URL ="ZBOM_CRM_API_URL";
        public static final String ZBOM_SMS_API_KEY ="ZBOM_SMS_API_KEY";
        public static final String ZBOM_SMS_API_URL ="ZBOM_SMS_API_URL";
        public static final String IAM_APPKEY ="IAM_APPKEY";
        public static final String SHOP_TREE ="SHOP_TREE";
        public static final String ERP_TOKEN ="ERP_TOKEN";
server/service/src/main/java/com/doumee/dao/business/model/CrmInterfaceLog.java
@@ -59,7 +59,7 @@
    @ApiModelProperty(value = "地址信息")
    @ExcelColumn(name="地址信息")
    private Date url;
    private String url;
    @ApiModelProperty(value = "请求参数")
    @ExcelColumn(name="请求参数")
server/service/src/main/java/com/doumee/service/business/InitService.java
@@ -36,6 +36,10 @@
    public void initIamAppIdAndAppKey(){
        redisTemplate.opsForValue().set(Constants.RedisKeys.IAM_APPKEY,systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_IAM_APPKEY).getCode());
        redisTemplate.opsForValue().set(Constants.RedisKeys.IAM_APPID,systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_IAM_APPID).getCode());
        redisTemplate.opsForValue().set(Constants.RedisKeys.ZBOM_CRM_API_KEY,systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_CRM_API_KEY).getCode());
        redisTemplate.opsForValue().set(Constants.RedisKeys.ZBOM_CRM_API_URL,systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_CRM_API_URL).getCode());
        redisTemplate.opsForValue().set(Constants.RedisKeys.ZBOM_SMS_API_URL,systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_SMS_API_URL).getCode());
        redisTemplate.opsForValue().set(Constants.RedisKeys.ZBOM_SMS_API_KEY,systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_SMS_API_KEY).getCode());
    }
    @PostConstruct
    public void cacheShopTree(){