Commit ba6517fa authored by jay's avatar jay

4.9.2版本提交

parent 0d9e75e9
......@@ -34,9 +34,6 @@ import java.util.Date;
*/
public class MarketingActivityEntity extends DomainObject {
/**
*
*/
private static final long serialVersionUID = 1L;
//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
......@@ -49,14 +46,6 @@ public class MarketingActivityEntity extends DomainObject {
private String activityName;
public String getActivityName() {
return activityName;
}
public void setActivityName(String activityName) {
this.activityName = activityName;
}
/**
* 活动类型
*/
......@@ -64,14 +53,6 @@ public class MarketingActivityEntity extends DomainObject {
private Integer activityId;
public Integer getActivityId() {
return activityId;
}
public void setActivityId(Integer activityId) {
this.activityId = activityId;
}
/**
* 周期(天)
*/
......@@ -84,38 +65,6 @@ public class MarketingActivityEntity extends DomainObject {
private String browseProjectId;
private String browseProject;
public String getBrowseProjectId() {
return browseProjectId;
}
public void setBrowseProjectId(String browseProjectId) {
this.browseProjectId = browseProjectId;
}
public String getBrowseProject() {
return browseProject;
}
public void setBrowseProject(String browseProject) {
this.browseProject = browseProject;
}
public String getBuildingId() {
return buildingId;
}
public void setBuildingId(String buildingId) {
this.buildingId = buildingId;
}
public String getBuildingName() {
return buildingName;
}
public void setBuildingName(String buildingName) {
this.buildingName = buildingName;
}
/**
* 希望提取数
*/
......@@ -198,14 +147,6 @@ public class MarketingActivityEntity extends DomainObject {
private String reVisitResult;
public String getReVisitResult() {
return reVisitResult;
}
public void setReVisitResult(String reVisitResult) {
this.reVisitResult = reVisitResult;
}
/**
* createBy
*/
......@@ -251,7 +192,6 @@ public class MarketingActivityEntity extends DomainObject {
*/
private Integer waitVisitCount;
//show not assign
private Integer notAssign;
/**
......@@ -1097,6 +1037,14 @@ public class MarketingActivityEntity extends DomainObject {
return this.returnVisitStatusName;
}
public String getActivityName() {
return activityName;
}
public void setActivityName(String activityName) {
this.activityName = activityName;
}
/**
* 实体的toString方法
*
......@@ -1216,5 +1164,53 @@ public class MarketingActivityEntity extends DomainObject {
public void setDescSub(String descSub) {
this.descSub = descSub;
}
public String getBrowseProjectId() {
return browseProjectId;
}
public void setBrowseProjectId(String browseProjectId) {
this.browseProjectId = browseProjectId;
}
public String getBrowseProject() {
return browseProject;
}
public void setBrowseProject(String browseProject) {
this.browseProject = browseProject;
}
public String getBuildingId() {
return buildingId;
}
public void setBuildingId(String buildingId) {
this.buildingId = buildingId;
}
public String getBuildingName() {
return buildingName;
}
public void setBuildingName(String buildingName) {
this.buildingName = buildingName;
}
public Integer getActivityId() {
return activityId;
}
public void setActivityId(Integer activityId) {
this.activityId = activityId;
}
public String getReVisitResult() {
return reVisitResult;
}
public void setReVisitResult(String reVisitResult) {
this.reVisitResult = reVisitResult;
}
}
......@@ -140,6 +140,13 @@ public class CloudActivityController extends BaseController {
return "----------updateDutyStaff success---------";
}
@RequestMapping(value = "/addMarketActivity")
@ResponseBody
public String addMarketActivity() {
activityInterface.addMarketActivity();
System.out.println("----------addMarketActivity成功---------");
return "----------addMarketActivity success---------";
}
/**
......
......@@ -298,80 +298,80 @@ public class LoginController extends BaseController {
//限制登陆
//获取Ip地址
UserEntity loginentity = user.getLimitLoginById(account);
String address = "";
String ip = "";
if ("1".equals(loginentity.getLimitLogin())) {
ip = RequestFromUtil.getIpAddr(request);
LOGGER.error("**********请求IP地址1:***********" + ip);
if (ip.contains(",")) {
ip = ip.split(",")[0];
}
LOGGER.error("**********请求IP地址2:***********" + ip);
//获取地理位置
address = AddressUtils.readJsonFromUrl("http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&ip=" + ip);
}
// UserEntity loginentity = user.getLimitLoginById(account);
// String address = "";
// String ip = "";
// if ("1".equals(loginentity.getLimitLogin())) {
// ip = RequestFromUtil.getIpAddr(request);
// LOGGER.error("**********请求IP地址1:***********" + ip);
// if (ip.contains(",")) {
// ip = ip.split(",")[0];
// }
// LOGGER.error("**********请求IP地址2:***********" + ip);
// //获取地理位置
// address = AddressUtils.readJsonFromUrl("http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&ip=" + ip);
// }
LOGGER.error("*******************************PC端请求:***************************");
if ("1".equals(loginentity.getLimitLogin()) && (!"218.94.115.128".equals(ip) && !"218.94.115.129".equals(ip) && !"218.94.115.130".equals(ip) && !"218.94.115.131".equals(ip)
&& !"218.94.115.132".equals(ip) && !"218.94.115.133".equals(ip) && !"218.94.115.134".equals(ip)) && !"218.94.115.135".equals(ip)) {
//先确定是否已经登陆授权并未超时失效
RequestLoginEntity requestlogin = new RequestLoginEntity();
//需授权的账号在外部登陆PC端,记录登陆信息
Date dateStr = new Date();
requestlogin.setName(account);
requestlogin.setLoginIp(ip);
requestlogin.setRealName(accountEntity.getRealName());
requestlogin.setLoginTime(dateStr);
requestlogin.setLoginCity(address);
requestlogin.setUserId(accountEntity.getId());
List<RequestLoginEntity> requestList = user.getRequestLoginInfo(requestlogin);
if (requestList != null && requestList.size() > 0) {
Date requestTime = requestList.get(0).getLoginTime();
Date authorizationTime = requestList.get(0).getAuthorizationTime();
String status = requestList.get(0).getStatus();
long min1 = AddressUtils.getDatePoor(dateStr, requestTime);
//请求超过10分钟未授权重新请求再授权
if ("0".equals(status)) {
if (min1 > 10) {
user.addRequestLoginInfo(requestlogin);
return "limit_error1";
} else {
user.addRequestLoginInfo(requestlogin);
return "limit_error1";
}
}
//已经授权但并未超过3分钟鉴权通过登陆
if ("1".equals(status)) {
if (authorizationTime != null) {
long min2 = AddressUtils.getDatePoor(dateStr, authorizationTime);
if (min2 > 3) {
user.addRequestLoginInfo(requestlogin);
return "limit_error2";
}
} else {
user.addRequestLoginInfo(requestlogin);
return "limit_error2";
}
}
//已失效
if ("2".equals(status)) {
if (authorizationTime != null) {
long min2 = AddressUtils.getDatePoor(dateStr, authorizationTime);
if (min1 > 10 || min2 > 3) {
user.addRequestLoginInfo(requestlogin);
return "limit_error3";
}
} else {
user.addRequestLoginInfo(requestlogin);
return "limit_error3";
}
}
} else {
user.addRequestLoginInfo(requestlogin);
return "limit_error1";
}
}
// if ("1".equals(loginentity.getLimitLogin()) && (!"218.94.115.128".equals(ip) && !"218.94.115.129".equals(ip) && !"218.94.115.130".equals(ip) && !"218.94.115.131".equals(ip)
// && !"218.94.115.132".equals(ip) && !"218.94.115.133".equals(ip) && !"218.94.115.134".equals(ip)) && !"218.94.115.135".equals(ip)) {
// //先确定是否已经登陆授权并未超时失效
// RequestLoginEntity requestlogin = new RequestLoginEntity();
// //需授权的账号在外部登陆PC端,记录登陆信息
// Date dateStr = new Date();
// requestlogin.setName(account);
// requestlogin.setLoginIp(ip);
// requestlogin.setRealName(accountEntity.getRealName());
// requestlogin.setLoginTime(dateStr);
// requestlogin.setLoginCity(address);
// requestlogin.setUserId(accountEntity.getId());
// List<RequestLoginEntity> requestList = user.getRequestLoginInfo(requestlogin);
// if (requestList != null && requestList.size() > 0) {
// Date requestTime = requestList.get(0).getLoginTime();
// Date authorizationTime = requestList.get(0).getAuthorizationTime();
// String status = requestList.get(0).getStatus();
// long min1 = AddressUtils.getDatePoor(dateStr, requestTime);
// //请求超过10分钟未授权重新请求再授权
// if ("0".equals(status)) {
// if (min1 > 10) {
// user.addRequestLoginInfo(requestlogin);
// return "limit_error1";
// } else {
// user.addRequestLoginInfo(requestlogin);
// return "limit_error1";
// }
// }
// //已经授权但并未超过3分钟鉴权通过登陆
// if ("1".equals(status)) {
// if (authorizationTime != null) {
// long min2 = AddressUtils.getDatePoor(dateStr, authorizationTime);
// if (min2 > 3) {
// user.addRequestLoginInfo(requestlogin);
// return "limit_error2";
// }
// } else {
// user.addRequestLoginInfo(requestlogin);
// return "limit_error2";
// }
// }
// //已失效
// if ("2".equals(status)) {
// if (authorizationTime != null) {
// long min2 = AddressUtils.getDatePoor(dateStr, authorizationTime);
// if (min1 > 10 || min2 > 3) {
// user.addRequestLoginInfo(requestlogin);
// return "limit_error3";
// }
// } else {
// user.addRequestLoginInfo(requestlogin);
// return "limit_error3";
// }
// }
// } else {
// user.addRequestLoginInfo(requestlogin);
// return "limit_error1";
// }
// }
UserRequest userRequest = new UserRequest();
accountEntity.setPreLoginTime(accountEntity.getLastLoginTime());
......@@ -379,6 +379,7 @@ public class LoginController extends BaseController {
userRequest.setEntity(accountEntity);
user.updateUser(userRequest);
setUserInfoToScope(request, accountEntity);
System.out.println("即将跳转index页面,userId 为 : " + account + " password为 " + password);
return "redirect:index";
} else {
model.addAttribute("errorMessge", "用户不存在!");
......
......@@ -29,7 +29,7 @@ import java.util.*;
@RequestMapping("/platformmanagement")
public class PlatformManagementController extends BaseController {
Logger logger = LoggerFactory.getLogger(getClass());
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* 自动注入客户信息WS实现
......@@ -181,12 +181,10 @@ public class PlatformManagementController extends BaseController {
searchParams.put("EQ_customerSourceType", "8");
searchParams.put("EQ_platformCreateSource", "PT");
//过滤公海、跟进中
boolean seaDel = false;
String eqPlatProjectStatus = String.valueOf(searchParams.get("EQ_platProjectStatus"));
if (eqPlatProjectStatus != null && "7".equals(eqPlatProjectStatus)) {//跟进中
searchParams.remove("EQ_platProjectStatus");
searchParams.put("EQ_platProjectStatus7", "7");
seaDel = true;
}
if (eqPlatProjectStatus != null && "8".equals(eqPlatProjectStatus)) {//回公海
searchParams.remove("EQ_platProjectStatus");
......@@ -200,17 +198,7 @@ public class PlatformManagementController extends BaseController {
if (response != null && response.getObjectList() != null) {
List<CustomerEntity> resultList = response.getObjectList();
logger.info("***********查询结果集************" + resultList.size());
Iterator<CustomerEntity> iterator = resultList.iterator();
//删除跟进中回公海的数据
// if (seaDel) {
// while (iterator.hasNext()) {
// CustomerEntity tmpce = iterator.next();
// if (StringUtils.isEmpty(String.valueOf(tmpce.getManagerId()))) {
// iterator.remove();
// }
// }
// }
logger.info("***********展示结果集大小************" + resultList.size());
// 按objectList大小初始化list
customers = new ArrayList<>(response.getObjectList().size());
// customerId集合
......
......@@ -319,7 +319,7 @@ public class UserController extends BaseController {
saveUnbindLog(userEntity, delUser);
}
}
user.deleteUserById(Integer.valueOf(ids[i]),userEntity.getId());
user.deleteUserById(Integer.valueOf(ids[i]), userEntity.getId());
}
}
} else {
......@@ -334,7 +334,7 @@ public class UserController extends BaseController {
saveUnbindLog(userEntity, delUser);
}
}
user.deleteUserById(Integer.valueOf(id),userEntity.getId());
user.deleteUserById(Integer.valueOf(id), userEntity.getId());
}
}
}
......@@ -572,7 +572,6 @@ public class UserController extends BaseController {
SessionConstants.SESSION_CURRNET_DEPT_KEY);
String cityId = departmentEntity.getCityID();
DepartmentResponse departmentResponse = department.getDepartmentById(Integer.valueOf(cityId));
DepartmentEntity city = departmentResponse.getEntity();
searchParams.put("EQ_deptUrlPath3", ue.getDeptUrlPath());
searchParams.put("LIKE_deptUrlPath2", ue.getDeptUrlPath());
......@@ -608,6 +607,7 @@ public class UserController extends BaseController {
} else {
model.addAttribute("showIm", 0);
}
// model.addAttribute("showIm", 1);
model.addAttribute("page", response.getPaging());
model.addAttribute("users", lstUserVo);
......@@ -1008,4 +1008,15 @@ public class UserController extends BaseController {
return result;
}
@RequestMapping(value = "/judgeAdmin/{id}")
@ResponseBody
public HResult judgeAdmin(@PathVariable int id) {
HResult result = new HResult();
UserEntity userEntity = user.getById(id);
if(userEntity.getDeptId() != 1){
result.setStatus(200);
}
return result;
}
}
......@@ -84,6 +84,23 @@
</option>
</select>
</c:if>
<c:if test="${'assigned' eq type}">
回访状态:
<select style="width: 6rem" name="search_backStatus" id="search_backStatus">
<option value="0"
<c:if test="${'0' eq param['search_backStatus']}">selected="selected"</c:if>>
全部
</option>
<option value="1"
<c:if test="${'1' eq param['search_backStatus']}">selected="selected"</c:if>>
已回访
</option>
<option value="2"
<c:if test="${'2' eq param['search_backStatus']}">selected="selected"</c:if>>
未回访
</option>
</select>
</c:if>
<i class="icon-search icon-2x pointer" onclick="$('#filterForm').submit();" title="搜索"></i>
</div>
......
......@@ -29,7 +29,6 @@
<ul class="breadcrumb">
<li><a href="/house365-hgs-web/">首页</a>
<span class="divider" style="color:#26a0da;font-weight:bold;"> > </span>
<%--<a href="/house365-hgs-web/customer/myCustomer">我的客户</a>--%>
<a href="/house365-hgs-web/platformmanagement/myPlatformCustomer">平台客户</a>
<span class="divider" style="color:#26a0da;font-weight:bold;"> > </span>
客户信息
......
......@@ -250,6 +250,7 @@
<c:if test="${user.entity.identityType eq '7'}"> <c:out value="客服"/></c:if>
<c:if test="${user.entity.identityType eq '20'}"> <c:out value="平台人员"/></c:if>
<c:if test="${user.entity.identityType eq '13'}"> <c:out value="房博士测试"/></c:if>
<c:if test="${user.entity.identityType eq '14'}"> <c:out value="其他房博士"/></c:if>
<c:if test="${null eq user.entity.identityType || '' eq user.entity.identityType}">
<c:out value=""/>
</c:if>
......@@ -297,19 +298,21 @@
</div>
<div id="choosemask" class="choosemask" style="display: none">
<div class="choosemask-wrap" style="width: 400px;height: 200px;">
<div class="choosemask-wrap" style="width: 500px;height: 200px;">
<div class="choosemask-top">
<span id="choosemask_2" class="choosemask-close" onclick="hiddenChoosemask()" style="">×</span>
</div>
<div class="choosemask-bottom" style="width: 350px;">
<div class="choosemask-bottom" style="width: 400px;">
<div class="choosemask-title">请选择身份:</div>
<ul class="choosemask-twobtn clearfix">
<ul class="choosemask-twobtn clearfix" id="fbs">
<li class="choosemask-fbs" onclick="saveIM(3)">新房房博士</li>
<li class="choosemask-fbs" onclick="saveIM(6)" style="margin-left: 10px;">二手房房博士</li>
<li class="choosemask-fbs" onclick="saveIM(10)" style="margin-left: 10px;">租房房博士</li>
<li class="choosemask-fbs" onclick="saveIM(14)" style="margin-left: 10px;">其他房博士</li>
</ul>
<ul class="choosemask-twobtn clearfix">
<li class="choosemask-fbs" onclick="saveIM(7)">客服</li>
<li class="choosemask-fbs" onclick="saveIM(7)" id="kefu">客服</li>
<li class="choosemask-fbs" onclick="saveIM(1)" style="margin-left: 10px;">安家顾问</li>
<li class="choosemask-fbs" onclick="saveIM(20)" style="margin-left: 10px;">平台人员</li>
</ul>
......@@ -326,11 +329,27 @@
$('#filterForm').submit();
}
});
function identityIM(uid, mobile) {
var choosemask = document.getElementById("choosemask");
choosemask.style.display = "block";
$("#uid").val(uid);
$("#mobile").val(mobile);
$.ajax({
url: '${ctx}/user/judgeAdmin/' + uid,
type: 'GET',
contentType: 'application/json',
dataType: 'json',
cache: false,
success: function (result) {
debugger;
if (result.status != 0) {
$("#kefu").css("display", "none");
$("#fbs").css("display", "none");
}
var choosemask = document.getElementById("choosemask");
choosemask.style.display = "block";
$("#uid").val(uid);
$("#mobile").val(mobile);
}
});
}
function saveIM(identityType) {
......@@ -366,6 +385,7 @@
}
});
}
function unlock(obj) {
$.ajax({
url: '${ctx}/user/unlock/' + obj,
......@@ -459,7 +479,7 @@
} else {
House365Util.createModal("删除员工", "删除后将无法恢复员工账号,请确认是否继续?", function () {
debugger;
if (selectedId.includes("257") == true) {
if (selectedId.includes("257") == true) {
alert("appstore账户,请勿操作");
return;
}
......
......@@ -34,4 +34,6 @@ public interface ICloudActivityInterface {
void updateStatus();
void updateDutyStaff();
void addMarketActivity();
}
......@@ -2,10 +2,11 @@
* Description: MarketBuildingRelWS接口
* Copyright: Copyright (c)2017
* Company: 江苏三六五网络股份有限公司
* @author: 江苏三六五网络股份有限公司
* @version: 1.0
*
* @author: 江苏三六五网络股份有限公司
* @version: 1.0
* Create at: 2017-12-05 下午 19:20:56
*
* <p>
* Modification History:
* Date Author Version Description
* ------------------------------------------------------------------
......@@ -22,65 +23,55 @@ import com.house365.ws.beans.response.MarketBuildingRelResponse;
/**
* MarketBuildingRelWS接口<br>
*
*
* @author 江苏三六五网络股份有限公司
* @version 1.0, 2017-12-05
* @see
* @since 1.0
*/
public interface IMarketBuildingRel extends IService{
public interface IMarketBuildingRel extends IService {
/**
* MarketBuildingRel列表查询
*
* @param request
* MarketBuildingRel列表查询请求
*
* @param request MarketBuildingRel列表查询请求
* @return MarketBuildingRel列表查询响应
*/
MarketBuildingRelListResponse getMarketBuildingRelList(
MarketBuildingRelListRequest request
MarketBuildingRelListResponse getMarketBuildingRelList(MarketBuildingRelListRequest request
);
/**
* 保存MarketBuildingRel
*
* @param request
* MarketBuildingRel请求
*
* @param request MarketBuildingRel请求
* @return 保存MarketBuildingRel响应
*/
MarketBuildingRelResponse addMarketBuildingRel(MarketBuildingRelRequest request);
/**
* 删除MarketBuildingRel通过唯一标识
*
* @param id
* 唯一标识
*
* @param id 唯一标识
* @return 删除MarketBuildingRel响应
*/
MarketBuildingRelResponse deleteMarketBuildingRelById(Integer id);
/**
* 修改MarketBuildingRel
*
* @param request
* 修改MarketBuildingRel请求
*
* @param request 修改MarketBuildingRel请求
* @return 修改MarketBuildingRel响应
*/
MarketBuildingRelResponse updateMarketBuildingRel(
MarketBuildingRelRequest request
);
MarketBuildingRelResponse updateMarketBuildingRel(MarketBuildingRelRequest request);
/**
* 通过ID获取MarketBuildingRel
*
* @param id
* 唯一标识
*
* @param id 唯一标识
* @return 通过ID获取MarketBuildingRel响应
*/
MarketBuildingRelResponse getMarketBuildingRelById(Integer id);
void deleteByActiveId(Integer id);
}
......@@ -377,6 +377,11 @@ public class CloudActivityImpl implements ICloudActivityInterface {
staffDuty.updateDutyStaff();
}
@Override
public void addMarketActivity() {
staffDuty.addMarketActivity();
}
private String dealRate(int count1, int count2) {
String rate = "";
if (count1 > 0 && count2 > 0) {
......
......@@ -57,9 +57,10 @@ public class CloudCustomerImpl implements ICloudCustomerInterface {
List<Map<String, Object>> list;
int count = 0;
//todo 添加状态查询
if (null != searchParams.get("status")) {
int status = Integer.parseInt(searchParams.get("status").toString());
int backStatus = Integer.parseInt(searchParams.get("backStatus").toString());
String backIdKey = "cloud_back_id" + activeId;
String seeIdKey = "cloud_see_Id" + activeId;
String daoIdKey = "cloud_dao_Id" + activeId;
String buyIdKey = "cloud_buy_Id" + activeId;
......@@ -67,6 +68,13 @@ public class CloudCustomerImpl implements ICloudCustomerInterface {
String cancelIdKey = "cloud_cancel_Id" + activeId;
String renIdKey = "cloud_ren_Id" + activeId;
list = mapper.queryList(map);
if (backStatus == 1) {
String value = redisUtil.getValByKey(backIdKey);
dealList(list, value);
} else if (backStatus == 2) {
String value = redisUtil.getValByKey(backIdKey);
list.removeIf(l -> value.contains(l.get("phone").toString()));
}
if (status == 1) {
String value = redisUtil.getValByKey(seeIdKey);
dealList(list, value);
......
......@@ -142,6 +142,8 @@ public class CustomerImpl implements ICustomer {
private CloudActivityMapper activityMapper;
@Autowired
private CloudCustomerMapper cloudCustomerMapper;
@Autowired
private UserMapper userMapper;
@Value("${crm.sync.url}")
......@@ -243,6 +245,32 @@ public class CustomerImpl implements ICustomer {
restObject.setParaMap(result);
return restObject;
}
UserEntity userEntity = userMapper.getById(userId);
Map<String, Object> queryMap = new HashMap<>(10);
queryMap.put("deptId", userEntity.getDeptId());
List<UserEntity> userList = userMapper.queryByConditions(queryMap);
if (CollectionUtils.isNotEmpty(userList)) {
List<String> createList = new ArrayList<>();
userList.forEach(u -> createList.add(String.valueOf(u.getId())));
//3天内添加人当前所在分组所有添加过的客户手机号(15天内);
Date date = new Date();
date = DateTimeUtils.getDaysAgo(date, 15);
Map<String, Object> map = new HashMap<>(10);
map.put("isPrivate", 1);
map.put("createTime", date);
map.put("phone", customerPhone);
map.put("createIdList", createList);
queryManagerMap.put("customerSourceType", 8);
List<CustomerEntity> mergeList = mergeMapper.queryByConditions(map);
if (CollectionUtils.isNotEmpty(mergeList)) {
result.put("result", "0");
result.put("msg", "该号码已由其他人上报,请勿重复操作");
restObject.setParaMap(result);
return restObject;
}
}
result.put("result", "1");
restObject.setParaMap(result);
}
......
......@@ -339,7 +339,6 @@ public class MarketingActivityImpl implements IMarketingActivity {
String confirmresult = HttpClientUtil.doPost(confirmUrl, inParam);
LOGGER.info("******通知CRM营销拉取客户信息返回结果:" + confirmresult);
}
// marketCustomer.updateSignupSourceName();
MarketingActivityRequest request = new MarketingActivityRequest();
MarketingActivityEntity entity = marketingActivityService.getById(activeId);
......
package com.house365.ws.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.house365.beans.entity.*;
import com.house365.commons.system.HttpClientUtil;
......@@ -9,9 +10,11 @@ import com.house365.web.util.MemoryPropertyPlaceholderConfigurer;
import com.house365.ws.cached.RedisUtilsInterface;
import com.house365.ws.dao.mapper.*;
import com.house365.ws.interfaces.server.ICustomerProject;
import com.house365.ws.service.interfaces.IProjectService;
import com.house365.ws.service.interfaces.IStaffDuty;
import com.house365.ws.service.interfaces.*;
import com.house365.ws.util.Constant;
import com.house365.ws.util.OperateLogUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
......@@ -19,8 +22,11 @@ import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.net.URLEncoder;
import java.text.DecimalFormat;
......@@ -72,6 +78,22 @@ public class StaffDuty implements IStaffDuty {
private ICustomerProject customerProject;
@Autowired
private CloudCountMapper cloudCountMapper;
@Autowired
private IMarketingActivityService<MarketingActivityEntity> marketingActivityService;
@Autowired
private CrmSourceMapper crmSourceMapper;
@Autowired
private IMarketCustomerService marketCustomer;
@Autowired
private ICrmSourceService<CrmSourceEntity> crmSourceService;
@Autowired
private DutyStaffMapper staffMapper;
@Autowired
private RedisUtilsInterface redisUtils;
@Value("${CRM.CUSTOMERQUERY.URL}")
private String crmQueryUrl;
@Override
......@@ -316,6 +338,9 @@ public class StaffDuty implements IStaffDuty {
List<CloudActivityEntity> list = activityMapper.queryByConditions(map);
if (CollectionUtils.isNotEmpty(list)) {
for (CloudActivityEntity c : list) {
// if(c.getId() != 912){
// continue;
// }
//开启线程池跑定时,防止超时
final CloudActivityEntity a = c;
ExecutorService executor = Executors.newCachedThreadPool();
......@@ -350,6 +375,8 @@ public class StaffDuty implements IStaffDuty {
String daoKey = "cloud_dao_count" + a.getId();
String buyKey = "cloud_buy_count" + a.getId();
String signKey = "cloud_sign_count" + a.getId();
String backIdKey = "cloud_back_id" + a.getId();
String seeIdKey = "cloud_see_Id" + a.getId();
String daoIdKey = "cloud_dao_Id" + a.getId();
String buyIdKey = "cloud_buy_Id" + a.getId();
......@@ -362,9 +389,14 @@ public class StaffDuty implements IStaffDuty {
Map<String, Object> backMap = new HashMap<>(10);
backMap.put("idList", idAllList);
backMap.put("notId", 1);
StringBuilder builderBack = new StringBuilder();
List<String> backKeyIdList = new ArrayList<>();
List<Map<String, Object>> backList = callbackMapper.queryCloudBackCount(backMap);
if (CollectionUtils.isNotEmpty(backList)) {
redisUtil.setValueNew(backKey, String.valueOf(backList.size()));
backList.forEach(s -> backKeyIdList.add(s.get("phone").toString()));
backKeyIdList.forEach(s -> builderBack.append(s).append(","));
redisUtil.setValueNew(backIdKey, builderBack.toString());
}
Map<String, Object> queryMap = new HashMap<>(5);
......@@ -433,6 +465,7 @@ public class StaffDuty implements IStaffDuty {
redisUtil.setValueNew(buyKey, "0");
redisUtil.setValueNew(signKey, "0");
redisUtil.setValueNew(backIdKey, "");
redisUtil.setValueNew(seeIdKey, "");
redisUtil.setValueNew(daoIdKey, "");
redisUtil.setValueNew(renIdKey, "");
......@@ -1015,4 +1048,362 @@ public class StaffDuty implements IStaffDuty {
return map;
}
/**
* 定时添加营销活动并拉取数据,只针对南京站
*/
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
public void addMarketActivity() {
try {
String city = "nj";
Map<String, Object> queryMap = new HashMap<>(5);
queryMap.put("onduty", 1);
List<DutyStaffEntity> list = staffMapper.queryByConditions(queryMap);
if (CollectionUtils.isNotEmpty(list)) {
DutyStaffEntity dutyStaffEntity = list.get(0);
int userId = Integer.parseInt(dutyStaffEntity.getUserId());
String userName = dutyStaffEntity.getName();
MarketingActivityEntity entity = new MarketingActivityEntity();
setMarketActivity(entity, userId, userName);
int id = marketingActivityService.save(entity);
System.out.println(id);
addMarketCustomer(id, city, entity);
//通知CRM所使用的数据
MarketCustomerEntity mce = new MarketCustomerEntity();
mce.setActiveId(id);
List<MarketCustomerEntity> useList = marketCustomer.getUseMarketingActivity(mce);
System.out.println("success" + useList.size());
if (CollectionUtils.isNotEmpty(useList)) {
String confirmUrl = MemoryPropertyPlaceholderConfigurer.getContextProperty("CRM.CONFIRM.URL");
List<NameValuePair> inParam = new ArrayList<>();
inParam.add(new BasicNameValuePair("city", city));
inParam.add(new BasicNameValuePair("timestamp", String.valueOf(System.currentTimeMillis() / 1000)));
JSONArray array = new JSONArray();
useList.forEach(u -> {
JSONObject jo = new JSONObject();
jo.put("phone", u.getPhone());
jo.put("crm_id", u.getCrmId());
array.add(jo);
});
inParam.add(new BasicNameValuePair("data", array.toString()));
String confirmResult = HttpClientUtil.doPost(confirmUrl, inParam);
logger.info("******通知CRM营销拉取客户信息返回结果:" + confirmResult);
}
entity.setGainCount(redisUtils.getIntegerByKey("active:done:" + id));
entity.setProtectCount(redisUtils.getIntegerByKey("active:protect:" + id));
marketingActivityService.update(entity);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("创建营销活动失败", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
sendErrorMsg();
}
}
private void sendErrorMsg() {
try {
String city = "nj";
String mobile = "18862152977";
String msg = "定时营销活动拉取失败";
msg = URLEncoder.encode(msg, "GBK");
String smUrl = "http://mysms.house365.com:81/index.php/Interface/apiSendMobil/jid/104/depart/1/city/";
smUrl = smUrl + city + "/" + "mobileno/" + mobile;
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("msg", msg));
String result = HttpClientUtil.doGet(smUrl, params, null);
if (result != null) {
logger.info("定时发送拉取提醒短信成功");
} else {
logger.error("定时发送拉取提醒短信失败");
}
System.out.println(msg);
} catch (Exception e) {
e.printStackTrace();
logger.error("发送营销提醒短信失败");
}
}
private void setMarketActivity(MarketingActivityEntity entity, int userId, String userName) {
String source = "2,3,29,30,31";
Date now = new Date();
now = DateTimeUtils.getDaysAgo(now, 1);
String date = new SimpleDateFormat("yyyy-MM-dd").format(now);
date = date.replace("-", "");
String name = "系统自动抓取" + date;
entity.setName(name);
entity.setType(1);
entity.setCycle(10);
entity.setExpectExtractCount(999);
entity.setProjectName("");
entity.setMobileType(null);
entity.setApplyStartTime(now);
entity.setApplyEndTime(now);
setApplySource(source, entity);
entity.setActiveType(null);
entity.setTotalPriceLower(null);
entity.setTotalPriceHigher(null);
entity.setAreaLower(null);
entity.setAreaHigher(null);
entity.setReturnVisitTimeStart(null);
entity.setReturnVisitTimeEnd(null);
entity.setReturnVisitStatus(null);
entity.setReturnVisitResult(null);
entity.setCreateBy(userId);
entity.setCreateName(userName);
entity.setCreateTime(now);
entity.setUpdateBy(userId);
entity.setUpdateTime(now);
entity.setGainCount(0);
entity.setOverTimeCount(0);
entity.setVisitBackCount(0);
entity.setWaitVisitCount(0);
entity.setBoughtCount(0);
entity.setProtectCount(0);
entity.setActiveTypeName(null);
entity.setReturnVisitStatusName("");
entity.setStatus(1);
entity.setFinishTime(DateTimeUtils.getTimeAfterDays(now, 10));
entity.setCity("nj");
entity.setBlock("");
entity.setBlockName("");
entity.setDistrict("");
entity.setDistrictName("");
entity.setChannel("");
entity.setChannelName("");
entity.setActivityName("");
entity.setMobile("");
entity.setCallNum("");
entity.setSeeProjectName("");
entity.setSeeStartTime(null);
entity.setSeeEndTime(null);
entity.setSeeCount(0);
}
private void addMarketCustomer(int activeId, String city, MarketingActivityEntity entity) throws Exception {
try {
if (redisUtils.hasKey("active:protect:" + activeId)) {
redisUtils.deleteByKeyNew("active:protect:" + activeId);
}
if (redisUtils.hasKey("active:done:" + activeId)) {
redisUtils.deleteByKeyNew("active:done:" + activeId);
}
List<NameValuePair> pairList = new ArrayList<>();
wrapNameValuePairList(pairList, entity);
pairList.add(new BasicNameValuePair("page", "1"));
pairList.add(new BasicNameValuePair("limit", "1000"));
pairList.add(new BasicNameValuePair("city", city));
String result = HttpClientUtil.doGet(crmQueryUrl, pairList, 60000, "utf-8");
String url = crmQueryUrl + "?";
List<String> params = new ArrayList<>();
pairList.forEach(p -> params.add(p.getName() + "=" + p.getValue()));
url += Joiner.on("&").join(params);
logger.warn("定时营销拉取URL===[{}]", url);
logger.warn("定时营销拉取线程:" + "-" + " -> 运行..." + "result:" + result);
JSONObject resobj = JSONObject.fromObject(result);
if (resobj.containsKey("docs") && resobj.get("docs") != null) {
JSONArray objArray = (JSONArray) resobj.get("docs");
Map<String, Object> dicMap = new HashMap<>(10);
dicMap.put("city", city);
dicMap.put("dicKey", "customer.protect.day");
List<DictionaryEntity> dictionaryList = dictionaryMapper.getNoApproximateConfig(dicMap);
List<CustomerEntity> list = new ArrayList<>();
if (CollectionUtils.isNotEmpty(dictionaryList) && !"0".equals(dictionaryList.get(0).getDicValue())) {
Map<String, Object> hotMap = new HashMap<>(10);
hotMap.put("status", 0);
hotMap.put("createSource", "HOTLINE");
hotMap.put("isProtect", dictionaryList.get(0).getDicValue());
hotMap.put("isAdd", 1);
hotMap.put("city", city);
list = customerMapper.queryForAddHot(hotMap);
}
if (CollectionUtils.isNotEmpty(list)) {
try {
for (CustomerEntity c : list) {
Iterator<Map<String, Object>> iterator = objArray.iterator();
while (iterator.hasNext()) {
Map<String, Object> iterMap = iterator.next();
if (iterMap.get("phone").toString().equals(c.getPhone())) {
iterator.remove();
}
}
}
} catch (Exception e) {
throw new Exception("去重失败");
}
}
for (Object c : objArray) {
JSONObject cu = (JSONObject) c;
MarketCustomerEntity customerEntity = getCustomer(cu);
//check protect customer and save
if (marketCustomer.queryProtectCount(customerEntity.getPhone()) > 0) {
increaseProtectKey(activeId);
continue;
} else {
increaseDoneKey(activeId);
customerEntity.setActiveId(activeId);
//同时获取signupSourceName
setSignSourceName(customerEntity);
marketCustomer.save(customerEntity);
//数据库负载较大,为避免报警,调大阀值
Thread.sleep(300);
}
}
}
} catch (Exception e) {
throw new Exception("拉取客户失败");
}
}
private synchronized Long increaseProtectKey(Integer activeId) {
return redisUtils.increaseByKey("active:protect:" + activeId);
}
private synchronized Long increaseDoneKey(Integer activeId) {
return redisUtils.increaseByKey("active:done:" + activeId);
}
private void setApplySource(String quickSource, MarketingActivityEntity entity) {
Set<String> crmSourceSet = new HashSet<>();
//根据快捷来源选择所有下级CRM来源 v3.2.0
for (String source : quickSource.split(",")) {
List<CrmSourceEntity> sourceList = crmSourceService.getListByCategory(source);
if (CollectionUtils.isNotEmpty(sourceList)) {
sourceList.removeIf(m -> m.getSourceId() == 99 || m.getSourceId() == 562);
sourceList.forEach(s -> crmSourceSet.add(String.valueOf(s.getSourceId())));
}
}
if (!crmSourceSet.isEmpty()) {
String source = Joiner.on(",").join(crmSourceSet);
entity.setApplySource(source);
entity.setApplySourceName("电商、房博士、400电话、楼盘订阅、看房团");
}
}
private synchronized static MarketCustomerEntity getCustomer(Map<String, Object> map) {
String name = getMapValueByKey(Constant.CUSTOMER_NAME, map, "", 150);
String phone = getMapValueByKey(Constant.CUSTOMER_PHONE, map, "", 90);
String cityCode = getMapValueByKey(Constant.CITY_CODE, map, "", 15);
String cityName = getMapValueByKey(Constant.CITY_NAME, map, "", 15);
String crmId = getMapValueByKey(Constant.CRMID, map, "", 20);
String sex = getMapValueByKey(Constant.CUSTOMER_SEX, map, String.valueOf(Constant.CustomerSexEnum.NOTSURE.getMsg()), 5);
String actSource = getMapValueByKey(Constant.CUSTOMER_ACTSOURCE, map, "", 300);
String firstSource = getMapValueByKey(Constant.CUSTOMER_FIRSTSOURCE, map, "", 100);
String latestSource = getMapValueByKey(Constant.CUSTOMER_LATESTSOURCE, map, "", 100);
String latestCall = getMapValueByKey(Constant.CUSTOMER_CRM_LATESTSCALL, map, "", 100);
String latestCallResult = getMapValueByKey(Constant.CUSTOMER_CRM_LATESTSCALL_RESULT, map, "", 100);
String bizPort = getMapValueByKey("bizPort", map, "", 30);
String buyIntention = getMapValueByKey("latestCallResult", map, "", 30);
String projectIds = getMapValueByKey("projectIds", map, "", 200);
String projectSourceId = getMapValueByKey("projectSourceId", map, "", 10);
String projectSourceTime = getMapValueByKey("projectSourceTime", map, "", 30);
List<String> contact = new ArrayList<>();
if (!Strings.isNullOrEmpty(projectIds)) {
JSONArray pids = JSONArray.fromObject(projectIds);
for (Object object : pids) {
contact.add(String.valueOf(object));
}
}
Date date = new Date();
actSource = com.house365.web.util.StringUtils.StringFilter(actSource);
MarketCustomerEntity customerEntity = new MarketCustomerEntity();
customerEntity.setName(name);
customerEntity.setPhone(phone);
customerEntity.setCityCode(cityCode);
customerEntity.setCityName(cityName);
customerEntity.setCrmId(crmId);
customerEntity.setSex(Integer.valueOf(sex));
customerEntity.setBizPort(bizPort);
customerEntity.setActSource(actSource);
customerEntity.setFirstSource(firstSource);
customerEntity.setCreateSource("CRM拉取");
customerEntity.setCustomerType(Constant.CustomerTypeEnum.ONLINE.getMsg());
customerEntity.setLatestSource(latestSource);
customerEntity.setCrmLatestCall(latestCall);
customerEntity.setCrmLatestCallResult(latestCallResult);
customerEntity.setCreateTime(date);
customerEntity.setCreater(Constant.CustomerSourceEnum.CRM.getMsg());
customerEntity.setUpdater(Constant.CustomerSourceEnum.CRM.getMsg());
customerEntity.setUpdateTime(date);
customerEntity.setStatus(Constant.CustomerStatusEnum.NORECORD.getStatus());
customerEntity.setBuyIntention(buyIntention);
customerEntity.setTraceStatus(1);
customerEntity.setCrmSync("1");
customerEntity.setIsDelete(0);
customerEntity.setIsOvertime(0);
customerEntity.setSignupSourceId(projectSourceId);
customerEntity.setSignupSourceName("");
customerEntity.setSignupTime(projectSourceTime);
customerEntity.setSignupHouseId(Joiner.on(",").join(contact));
customerEntity.setSignupHouseName("");
return customerEntity;
}
private static String getMapValueByKey(String key, Map<String, Object> map, String defaultValue, Integer length) {
String value = "";
if (map.containsKey(key) && map.get(key) != null && !Strings.isNullOrEmpty(String.valueOf((map.get(key))))) {
value = String.valueOf(map.get(key));
}
if (Strings.isNullOrEmpty(value) || "null".equalsIgnoreCase(value)) {
value = defaultValue;
}
if (null != length) {
value = value.length() > length ? value.substring(0, length) : value;
}
return value;
}
private void wrapNameValuePairList(List<NameValuePair> nameValuePairList, MarketingActivityEntity entity) {
//报名来源
if (StringUtils.isNotBlank(entity.getApplySource())) {
String[] sources = entity.getApplySource().split(",");
int i = 0;
for (String source : sources) {
if (!Strings.isNullOrEmpty(source)) {
nameValuePairList.add(new BasicNameValuePair("target_source[" + i + "]", source));
i++;
}
}
}
//报名时间
if (entity.getApplyStartTime() != null && entity.getApplyEndTime() != null) {
nameValuePairList.add(new BasicNameValuePair("join_time[0]",
DateTimeUtils.parseDate(entity.getApplyStartTime(), DateTimeUtils.DEFAULT_DATE_FORMAT_PATTERN_SHORT)));
nameValuePairList.add(new BasicNameValuePair("join_time[1]",
DateTimeUtils.parseDate(entity.getApplyEndTime(), DateTimeUtils.DEFAULT_DATE_FORMAT_PATTERN_SHORT)));
}
}
/**
* 设置crm来源名称
*
* @param entity
*/
private void setSignSourceName(MarketCustomerEntity entity) {
if (StringUtils.isNotBlank(entity.getSignupSourceId())) {
int sourceId = Integer.parseInt(entity.getSignupSourceId());
Map<String, Object> map = new HashMap<>(3);
map.put("sourceId", sourceId);
List<CrmSourceEntity> list = crmSourceMapper.queryByConditions(map);
if (CollectionUtils.isNotEmpty(list)) {
entity.setSignupSourceName(list.get(0).getSourceName());
}
} else {
entity.setSignupSourceName("");
}
}
}
......@@ -35,4 +35,6 @@ public interface IStaffDuty {
void setCloudReportCountJi();
void setCloudReportCountBn();
void addMarketActivity();
}
......@@ -71,9 +71,9 @@
order by create_time desc
</select>
<select id="queryCloudBackCount" resultMap="infoMap" parameterType="map">
<select id="queryCloudBackCount" resultType="map" parameterType="map">
SELECT
DISTINCT c.phone
DISTINCT c.phone AS phone
FROM customer_callback_log ccl
left JOIN customer c on c.id = ccl.customer_id
where c.is_delete = 0
......
......@@ -846,6 +846,18 @@
AND (isWaitCall = 0 OR isWaitCall IS NULL)
AND (STATUS = 0 OR STATUS = 11 OR status = 99)
</if>
<if test="createTime != null and createTime != ''">
AND create_time > #{createTime}
</if>
<if test="customerSourceType != null and customerSourceType >=0">
AND customer_source_type = #{customerSourceType}
</if>
<if test="createIdList != null and createIdList.size() > 0 ">
AND creater IN
<foreach collection="createIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="limit != null and limit > 0 ">
limit 10
</if>
......
......@@ -147,6 +147,9 @@
<if test="onlineStatus != null and onlineStatus >= 0">
AND online_status = #{onlineStatus}
</if>
<if test="deptId != null and deptId >= 0 ">
AND deptId = #{deptId}
</if>
<if test="order != null and order > 0 ">
ORDER BY name ASC
</if>
......
......@@ -761,4 +761,30 @@
</bean>
<!--设置云迹年度报表定时结束-->
<!--定时创建营销活动拉取客户开始-->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="addMarketActivity"/>
</list>
</property>
</bean>
<bean id="addMarketActivity" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="addMarketCus"/>
<property name="cronExpression" value="0 10 0 * * ? *"/>
</bean>
<bean id="addMarketCus" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!--调用的类-->
<property name="targetObject">
<ref bean="staffDuty"/>
</property>
<!--调用类中的方法-->
<property name="targetMethod">
<value>addMarketActivity</value>
</property>
</bean>
<!--定时创建营销活动拉取客户结束-->
</beans>
......@@ -71,7 +71,7 @@
order by create_time desc
</select>
<select id="queryCloudBackCount" resultMap="infoMap" parameterType="map">
<select id="queryCloudBackCount" resultType="map" parameterType="map">
SELECT
DISTINCT c.phone
FROM customer_callback_log ccl
......
......@@ -855,6 +855,18 @@
AND (isWaitCall = 0 OR isWaitCall IS NULL)
AND (STATUS = 0 OR STATUS = 11 OR status = 99)
</if>
<if test="createTime != null and createTime != ''">
AND create_time > #{createTime}
</if>
<if test="customerSourceType != null and customerSourceType >=0">
AND customer_source_type = #{customerSourceType}
</if>
<if test="createIdList != null and createIdList.size() > 0 ">
AND creater IN
<foreach collection="createIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="limit != null and limit > 0 ">
limit 10
</if>
......
......@@ -147,6 +147,9 @@
<if test="onlineStatus != null and onlineStatus >= 0">
AND online_status = #{onlineStatus}
</if>
<if test="deptId != null and deptId >= 0 ">
AND deptId = #{deptId}
</if>
<if test="order != null and order > 0 ">
ORDER BY name ASC
</if>
......
......@@ -71,7 +71,7 @@
order by create_time desc
</select>
<select id="queryCloudBackCount" resultMap="infoMap" parameterType="map">
<select id="queryCloudBackCount" resultType="map" parameterType="map">
SELECT
DISTINCT c.phone
FROM customer_callback_log ccl
......
......@@ -855,6 +855,18 @@
AND (isWaitCall = 0 OR isWaitCall IS NULL)
AND (STATUS = 0 OR STATUS = 11 OR status = 99)
</if>
<if test="createTime != null and createTime != ''">
AND create_time > #{createTime}
</if>
<if test="customerSourceType != null and customerSourceType >=0">
AND customer_source_type = #{customerSourceType}
</if>
<if test="createIdList != null and createIdList.size() > 0 ">
AND creater IN
<foreach collection="createIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="limit != null and limit > 0 ">
limit 10
</if>
......
......@@ -147,6 +147,9 @@
<if test="onlineStatus != null and onlineStatus >= 0">
AND online_status = #{onlineStatus}
</if>
<if test="deptId != null and deptId >= 0 ">
AND deptId = #{deptId}
</if>
<if test="order != null and order > 0 ">
ORDER BY name ASC
</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment