Commit a6c40ea0 by fudahua

离职继承fix

parent cc91b4ac
...@@ -19,6 +19,14 @@ public interface HandoverOperationApiService { ...@@ -19,6 +19,14 @@ public interface HandoverOperationApiService {
* 定时处理拉取企业微信信息 * 定时处理拉取企业微信信息
*/ */
public void batchQywxHandoverTimeTask(String params); public void batchQywxHandoverTimeTask(String params);
/**
* 定时处理企业微信 离职基础的结果
*
* @param params
*/
public void BatchQywxHandoverResultTimeTask(String params);
/** /**
* 处理企业微信信息 * 处理企业微信信息
* *
...@@ -27,6 +35,13 @@ public interface HandoverOperationApiService { ...@@ -27,6 +35,13 @@ public interface HandoverOperationApiService {
public void dealQywxEnterpriseHandover(String wxEnterpriseId); public void dealQywxEnterpriseHandover(String wxEnterpriseId);
/** /**
* 处理企业微信信息 结果处理
*
* @param wxEnterpriseId
*/
public void dealQywxEnterpriseHandoverResult(String wxEnterpriseId);
/**
* 获取离职继承所在的门店下的待分配导购列表 * 获取离职继承所在的门店下的待分配导购列表
* *
* @param storeId * @param storeId
......
...@@ -65,4 +65,12 @@ public interface HandoverExternalMapper { ...@@ -65,4 +65,12 @@ public interface HandoverExternalMapper {
/** /**
*/ */
int updateAfterTransfer(@Param("ids") List<String> ids, @Param("transferId") String transferId); int updateAfterTransfer(@Param("ids") List<String> ids, @Param("transferId") String transferId);
/**
* 查询待分配客户列表
*
* @param wxEnterpriseId
* @return
*/
TabHandoverExternal getByTransferId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("transferId") String transferId, @Param("externalUserId") String externalUserId);
} }
\ No newline at end of file
...@@ -79,4 +79,13 @@ public interface HandoverTransferMapper { ...@@ -79,4 +79,13 @@ public interface HandoverTransferMapper {
* @return * @return
*/ */
public List<TabHandoverTransfer> listTransferByIds(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("ids") List<String> ids); public List<TabHandoverTransfer> listTransferByIds(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("ids") List<String> ids);
/**
* 获取分配列表 企业级别
*
* @param wxEnterpriseId
* @param date
* @return
*/
public List<TabHandoverTransfer> listTransferByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("date") String date);
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ import com.gic.haoban.manage.api.dto.HandoverExternalDTO; ...@@ -6,6 +6,7 @@ import com.gic.haoban.manage.api.dto.HandoverExternalDTO;
import com.gic.haoban.manage.service.entity.TabHandoverExternal; import com.gic.haoban.manage.service.entity.TabHandoverExternal;
import com.gic.haoban.manage.service.entity.TabHandoverStaff; import com.gic.haoban.manage.service.entity.TabHandoverStaff;
import com.gic.haoban.manage.service.entity.TabHandoverTransfer; import com.gic.haoban.manage.service.entity.TabHandoverTransfer;
import com.gic.wechat.api.dto.qywx.QywxTransferCustomerInfoDTO;
import com.gic.wechat.api.dto.qywx.QywxUnassignedInfoDTO; import com.gic.wechat.api.dto.qywx.QywxUnassignedInfoDTO;
import java.util.List; import java.util.List;
...@@ -95,4 +96,20 @@ public interface HandoverService { ...@@ -95,4 +96,20 @@ public interface HandoverService {
*/ */
public List<TabHandoverTransfer> listTransferByIds(String wxEnterpriseId, List<String> ids); public List<TabHandoverTransfer> listTransferByIds(String wxEnterpriseId, List<String> ids);
/**
* 继承记录列表 企业下所有
*
* @param wxEnterpriseId
* @return
*/
public List<TabHandoverTransfer> listTransferByWxEnterpriseId(String wxEnterpriseId, String date);
/**
* 处理结果
*
* @param list
* @return
*/
public boolean dealResult(String wxEnterpriseId, String transferId, List<QywxTransferCustomerInfoDTO> list);
} }
...@@ -10,11 +10,14 @@ import com.gic.haoban.manage.service.dao.mapper.*; ...@@ -10,11 +10,14 @@ import com.gic.haoban.manage.service.dao.mapper.*;
import com.gic.haoban.manage.service.entity.*; import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.service.HandoverService; import com.gic.haoban.manage.service.service.HandoverService;
import com.gic.haoban.manage.service.service.SecretSettingService; import com.gic.haoban.manage.service.service.SecretSettingService;
import com.gic.wechat.api.dto.qywx.QywxTransferCustomerInfoDTO;
import com.gic.wechat.api.dto.qywx.QywxUnassignedInfoDTO; import com.gic.wechat.api.dto.qywx.QywxUnassignedInfoDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -226,4 +229,30 @@ public class HandoverServiceImpl implements HandoverService { ...@@ -226,4 +229,30 @@ public class HandoverServiceImpl implements HandoverService {
public List<TabHandoverTransfer> listTransferByIds(String wxEnterpriseId, List<String> ids) { public List<TabHandoverTransfer> listTransferByIds(String wxEnterpriseId, List<String> ids) {
return handoverTransferMapper.listTransferByIds(wxEnterpriseId, ids); return handoverTransferMapper.listTransferByIds(wxEnterpriseId, ids);
} }
@Override
public List<TabHandoverTransfer> listTransferByWxEnterpriseId(String wxEnterpriseId, String date) {
List<TabHandoverTransfer> ret = handoverTransferMapper.listTransferByWxEnterpriseId(wxEnterpriseId, date);
return ret;
}
@Override
public boolean dealResult(String wxEnterpriseId, String transferId, List<QywxTransferCustomerInfoDTO> list) {
if (CollectionUtils.isEmpty(list)) {
logger.info("没有需要处理的" + wxEnterpriseId);
return false;
}
list.forEach(dto -> {
TabHandoverExternal handoverExternal = handoverExternalMapper.getByTransferId(wxEnterpriseId, transferId, dto.getExternalUserid());
if (dto.getTakeoverTime() > 0) {
Date date = new Date(dto.getTakeoverTime() * 1000);
handoverExternal.setTakeoverTime(date);
}
handoverExternal.setTransferStatus(dto.getStatus());
handoverExternal.setUpdateTime(new Date());
handoverExternalMapper.updateByPrimaryKeySelective(handoverExternal);
});
return true;
}
} }
...@@ -22,11 +22,14 @@ import com.gic.wechat.api.dto.qywx.response.QywxTransferCustomerDTO; ...@@ -22,11 +22,14 @@ import com.gic.wechat.api.dto.qywx.response.QywxTransferCustomerDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -65,6 +68,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -65,6 +68,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
@Override @Override
public void batchQywxHandoverTimeTask(String params) { public void batchQywxHandoverTimeTask(String params) {
logger.info("定时拉取离职基础的人员:{}", params);
List<YwWxEnterpriseDTO> dtoList = wxEnterpriseApiService.listAll(); List<YwWxEnterpriseDTO> dtoList = wxEnterpriseApiService.listAll();
for (YwWxEnterpriseDTO enterpriseDTO : dtoList) { for (YwWxEnterpriseDTO enterpriseDTO : dtoList) {
try { try {
...@@ -77,6 +81,20 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -77,6 +81,20 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
} }
@Override @Override
public void BatchQywxHandoverResultTimeTask(String params) {
logger.info("离职基础结果开始:{}", params);
List<YwWxEnterpriseDTO> dtoList = wxEnterpriseApiService.listAll();
for (YwWxEnterpriseDTO enterpriseDTO : dtoList) {
try {
} catch (Exception e) {
e.printStackTrace();
logger.info("商户处理异常:{},{}", JSONObject.toJSONString(enterpriseDTO), e);
}
}
}
@Override
public void dealQywxEnterpriseHandover(String wxEnterpriseId) { public void dealQywxEnterpriseHandover(String wxEnterpriseId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
logger.info("拉取单个企业微信的离职成员:{}", wxEnterpriseId, JSONObject.toJSONString(wxEnterpriseDTO)); logger.info("拉取单个企业微信的离职成员:{}", wxEnterpriseId, JSONObject.toJSONString(wxEnterpriseDTO));
...@@ -99,6 +117,34 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -99,6 +117,34 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
return ret; return ret;
} }
@Override
public void dealQywxEnterpriseHandoverResult(String wxEnterpriseId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
Date date = DateUtils.addDays(new Date(), -3);
String day = DateFormatUtils.format(date, "yyyy-MM-dd");
List<TabHandoverTransfer> transfers = handoverService.listTransferByWxEnterpriseId(wxEnterpriseId, day);
if (CollectionUtils.isEmpty(transfers)) {
logger.info("没有需要转化的");
return;
}
transfers.forEach(dto -> {
try {
TabHaobanStaff handover = staffService.selectById(dto.getHandoverStaffId());
TabHaobanStaff takeover = staffService.selectById(dto.getTakeoverStaffId());
QywxTransferCustomerDTO customerDTO = qywxUserApiService.transferResult(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), handover.getWxUserId(), takeover.getWxUserId(), true);
if (customerDTO.getErrorcode() != 0) {
return;
}
List<QywxTransferCustomerInfoDTO> customerResults = customerDTO.getCustomer();
handoverService.dealResult(wxEnterpriseId, dto.getHandoverTransferId(), customerResults);
} catch (Exception e) {
logger.info("处理异常:{},{}", JSONObject.toJSONString(dto), e);
}
});
}
@Override @Override
public List<HandoverStaffInfoDTO> listHandoverStaff(String wxEnterpriseId, String storeId) { public List<HandoverStaffInfoDTO> listHandoverStaff(String wxEnterpriseId, String storeId) {
List<TabHandoverStaff> handoverStaffs = handoverService.listByStoreId(wxEnterpriseId, storeId); List<TabHandoverStaff> handoverStaffs = handoverService.listByStoreId(wxEnterpriseId, storeId);
...@@ -181,7 +227,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -181,7 +227,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
//分配人与客户的关联map //分配人与客户的关联map
Map<String, List<String>> handoverStaffExternalMap = externalList.stream().collect(Collectors.groupingBy(dto -> dto.getUserId(), Collectors.mapping(TabHandoverExternal::getExternalUserId, Collectors.toList()))); Map<String, List<String>> handoverStaffExternalMap = externalList.stream().collect(Collectors.groupingBy(dto -> dto.getUserId(), Collectors.mapping(TabHandoverExternal::getExternalUserId, Collectors.toList())));
//分配人wxUserId 对应的staffIdMap //分配人wxUserId 对应的staffIdMap
Map<String, String> handoverStaffIdMap = externalList.stream().collect(Collectors.toMap(dto -> dto.getUserId(), dto -> dto.getStaffId())); Map<String, String> handoverStaffIdMap = externalList.stream().collect(Collectors.toMap(dto -> dto.getUserId(), dto -> dto.getStaffId(), (o, n) -> o));
//TabHandoverExternal 根据分配人wxUserId 分类 主键id //TabHandoverExternal 根据分配人wxUserId 分类 主键id
Map<String, List<String>> userByIdMap = externalList.stream().collect(Collectors.groupingBy(dto -> dto.getUserId(), Collectors.mapping(dto -> dto.getHandoverExternalId(), Collectors.toList()))); Map<String, List<String>> userByIdMap = externalList.stream().collect(Collectors.groupingBy(dto -> dto.getUserId(), Collectors.mapping(dto -> dto.getHandoverExternalId(), Collectors.toList())));
......
...@@ -303,4 +303,14 @@ ...@@ -303,4 +303,14 @@
#{item} #{item}
</foreach> </foreach>
</update> </update>
<select id="getByTransferId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_handover_external
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and handover_transfer_id = #{transferId,jdbcType=VARCHAR}
and external_user_id=#{externalUserId}
and status_flag=2
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -199,4 +199,14 @@ ...@@ -199,4 +199,14 @@
</foreach> </foreach>
and status_flag=1 and status_flag=1
</select> </select>
<select id="listTransferByWxEnterpriseId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_handover_transfer
where wx_enterprise_id=#{wxEnterpriseId}
and create_time > #{date}
and status_flag=1
</select>
</mapper> </mapper>
\ No newline at end of file
import cn.hutool.core.thread.ConcurrencyTester; import cn.hutool.core.thread.ConcurrencyTester;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.HandoverExternalDTO;
import com.gic.haoban.manage.api.service.*; import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.service.service.StaffService; import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.TestService; import com.gic.haoban.manage.service.service.TestService;
...@@ -14,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
...@@ -31,4 +36,20 @@ public class HandoverTest { ...@@ -31,4 +36,20 @@ public class HandoverTest {
String wxEnterpriseId = "ca66a01b79474c40b3e7c7f93daf1a3b"; String wxEnterpriseId = "ca66a01b79474c40b3e7c7f93daf1a3b";
handoverOperationApiService.dealQywxEnterpriseHandover(wxEnterpriseId); handoverOperationApiService.dealQywxEnterpriseHandover(wxEnterpriseId);
} }
@Test
public void test1() {
String wxEnterpriseId = "ca66a01b79474c40b3e7c7f93daf1a3b";
handoverOperationApiService.dealQywxEnterpriseHandoverResult(wxEnterpriseId);
}
@Test
public void test2() {
String wxEnterpriseId = "ca66a01b79474c40b3e7c7f93daf1a3b";
List<String> staffIds = new ArrayList<>();
staffIds.add("471ef6fbeed84319944e68265855ecb4");
Page<HandoverExternalDTO> handoverExternalDTOPage = handoverOperationApiService.pageHandoverFriend(wxEnterpriseId, null, staffIds, null, new BasePageInfo());
System.out.println(JSONObject.toJSONString(handoverExternalDTOPage));
}
} }
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