|
|
@@ -1,8 +1,10 @@
|
|
|
package com.ruixuan.salesLeads.service.impl;
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.ruixuan.common.core.domain.ResultResponse;
|
|
|
import com.ruixuan.common.core.page.TableDataInfo;
|
|
|
import com.ruixuan.common.core.redis.RedisCache;
|
|
|
@@ -13,14 +15,8 @@ import com.ruixuan.common.utils.file.FileTypeUtils;
|
|
|
import com.ruixuan.common.utils.http.HttpUtil;
|
|
|
import com.ruixuan.salesLeads.constant.RobotConstant;
|
|
|
import com.ruixuan.salesLeads.listener.ImportExcelListener;
|
|
|
-import com.ruixuan.salesLeads.mapper.SaleClueDistributionInfoMapper;
|
|
|
-import com.ruixuan.salesLeads.mapper.SaleClueInfoMapper;
|
|
|
-import com.ruixuan.salesLeads.mapper.SaleClueRecordInfoMapper;
|
|
|
-import com.ruixuan.salesLeads.mapper.SaleQuotaInfoMapper;
|
|
|
-import com.ruixuan.salesLeads.pojo.SaleClueDistributionInfoPojo;
|
|
|
-import com.ruixuan.salesLeads.pojo.SaleClueInfoPojo;
|
|
|
-import com.ruixuan.salesLeads.pojo.SaleClueRecordInfoPojo;
|
|
|
-import com.ruixuan.salesLeads.pojo.SaleQuotaInfoPojo;
|
|
|
+import com.ruixuan.salesLeads.mapper.*;
|
|
|
+import com.ruixuan.salesLeads.pojo.*;
|
|
|
import com.ruixuan.salesLeads.pojo.vo.SaleRecordVo;
|
|
|
import com.ruixuan.salesLeads.pojo.vo.SaleTaskInfoVo;
|
|
|
import com.ruixuan.salesLeads.service.ISaleClueInfoService;
|
|
|
@@ -62,6 +58,12 @@ public class TelephoneRobotServiceImpl implements ITelephoneRobotService {
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SaleClueInfoMapper saleClueInfoMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SaleClueCallRecordMapper saleClueCallRecordMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
@@ -95,4 +97,63 @@ public class TelephoneRobotServiceImpl implements ITelephoneRobotService {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultResponse importRobotTelephone(List<Long> sellerIds,String userId){
|
|
|
+ Map<String,String> headers = new HashMap<>();
|
|
|
+ Map<String,Object> result = new HashMap<>();
|
|
|
+ result.put("taskId",123);
|
|
|
+ result.put("batchId",123);
|
|
|
+ result.put("callBackUrl",RobotConstant.CALL_BACK_URL);
|
|
|
+ result.put("canCover",true);
|
|
|
+
|
|
|
+ List customerList = new ArrayList();
|
|
|
+ for (Long sellerId : sellerIds) {
|
|
|
+ SaleRecordVo saleInfo = saleClueInfoMapper.selectSaleClueInfoBySellerId(sellerId);
|
|
|
+ Map<String,Object> param = new HashMap<>();
|
|
|
+ param.put("id",saleInfo.getSellerId());
|
|
|
+ param.put("name",saleInfo.getSellerName());
|
|
|
+ param.put("companyName","");
|
|
|
+ param.put("phone","17778037644");
|
|
|
+ param.put("website","");
|
|
|
+ customerList.add(param);
|
|
|
+ }
|
|
|
+ result.put("customerList",customerList);
|
|
|
+
|
|
|
+ //headers.put("Auth-Token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJndW95YW5saW5nIiwiZXhwIjoxNjU4MTMyMjEyfQ.OyhpastRRzBxAlSc8JOfdxO3rK3NG592U3Qlh752xDQ");
|
|
|
+
|
|
|
+ JSONObject tokenObj = redisCache.getCacheObject("salesLeads:robotToken:str");
|
|
|
+ if (!StringUtils.isEmpty(tokenObj)){
|
|
|
+ log.info("导入时获取redis中的token信息----->>>{}",tokenObj);
|
|
|
+ headers.put("Auth-Token",tokenObj.getString("token"));
|
|
|
+ }else {
|
|
|
+ getTelephoneRobotToken();
|
|
|
+ log.info("导入时redis中的token信息已失效,重新获取token----->>>{}");
|
|
|
+ }
|
|
|
+ String content = HttpUtil.httpPostRequest(RobotConstant.CUSTOMER_IMPORT,result,headers);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ if (!"0".equals(jsonObject.getString("code"))){
|
|
|
+ return ResultResponse.error("导入数据接口异常======>>>>>"+jsonObject);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //更新记录 用户
|
|
|
+ saleClueCallRecordMapper.updateCallRecordUser(userId);
|
|
|
+
|
|
|
+ //查询导入回调记录
|
|
|
+ SaleClueCallRecordPojo callRecordPojo = saleClueCallRecordMapper.getSaleClueCallRecordInfo();
|
|
|
+ String record = callRecordPojo.getContent();
|
|
|
+ JSONObject recordJson = JSONObject.parseObject(record);
|
|
|
+ JSONArray success = recordJson.getJSONArray("success");
|
|
|
+ JSONArray error = recordJson.getJSONArray("error");
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap();
|
|
|
+ map.put("successList",success);
|
|
|
+ map.put("errorList",error);
|
|
|
+ return ResultResponse.successMsg("导入记录查询成功。",map);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|