Merge branch 'hxd/feat/ecSyncLabel' into dev/feat/partner1.3_20230904

This commit is contained in:
xiaodong.hu
2023-08-30 15:33:12 +08:00
21 changed files with 460 additions and 65 deletions

View File

@@ -29,4 +29,6 @@ public class ExcelErrorConstants {
public static final String COUNT_MORE = "每次数据最多导入500条请分批上传"; public static final String COUNT_MORE = "每次数据最多导入500条请分批上传";
public static final String MOBILE_REPEAT = "手机号重复";
} }

View File

@@ -1,6 +1,7 @@
package com.cool.store.mapper; package com.cool.store.mapper;
import com.cool.store.entity.HyPartnerBaseInfoDO; import com.cool.store.entity.HyPartnerBaseInfoDO;
import com.cool.store.entity.SyncEcCustomerLabelDO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@@ -63,4 +64,10 @@ public interface HyPartnerBaseInfoMapper {
@Param("idCardPhotoBlack") String idCardPhotoBlack, @Param("idCardPhotoBlack") String idCardPhotoBlack,
@Param("partnerLineId") Long partnerLineId); @Param("partnerLineId") Long partnerLineId);
int selectAllList();
List<SyncEcCustomerLabelDO> selectListByLimit(@Param("limit1") Integer limit1, @Param("limit2") Integer limit2);
void updateByMobile(HyPartnerBaseInfoDO record);
} }

View File

@@ -297,6 +297,12 @@
left join hy_partner_line_info b on a.partner_line_id = b.id left join hy_partner_line_info b on a.partner_line_id = b.id
where a.id_card = #{idCard} and ( b.line_status != 3 and b.deleted = 0 ) where a.id_card = #{idCard} and ( b.line_status != 3 and b.deleted = 0 )
</select> </select>
<select id="selectAllList" resultType="java.lang.Integer">
SELECT count(*) FROM hy_partner_base_info where mobile is not null and user_portrait is null
</select>
<select id="selectListByLimit" resultType="com.cool.store.entity.SyncEcCustomerLabelDO">
SELECT id,mobile,user_portrait as userPortrait FROM hy_partner_base_info where mobile is not null and user_portrait is null LIMIT #{limit1},#{limit2}
</select>
<update id="cleanIdCardInfoByPartnerLineId"> <update id="cleanIdCardInfoByPartnerLineId">
update hy_partner_base_info update hy_partner_base_info
@@ -306,5 +312,15 @@
id_card_photo_black = #{idCardPhotoBlack} id_card_photo_black = #{idCardPhotoBlack}
where partner_line_id = #{partnerLineId} where partner_line_id = #{partnerLineId}
</update> </update>
<update id="updateByMobile">
update hy_partner_base_info
<set>
update_time=now(),
<if test="userPortrait != null and userPortrait!=''">
user_portrait = #{userPortrait},
</if>
</set>
where mobile = #{mobile}
</update>
</mapper> </mapper>

View File

@@ -55,18 +55,23 @@
</select> </select>
<select id="selectByHourDate" resultType="com.cool.store.entity.SyncEcCustomerDO" > <select id="selectByHourDate" resultType="com.cool.store.entity.SyncEcCustomerDO" >
SELECT SELECT
a.id AS id,b.partner_id, a.id AS id,
a.username AS customername, b.partner_id,
a.mobile AS customermobile, b.username AS customername,
b.mobile AS customermobile,
d.`name` AS followname, d.`name` AS followname,
d.mobile AS followmobile,b.line_status as lineStatus, d.mobile AS followmobile,
c.channel_id AS channelId ,ifnull(tl_l.followCount,0) as followCount a.line_status AS lineStatus,
c.channel_id AS channelId,
ifnull( tl_l.followCount, 0 ) AS followCount
FROM FROM
hy_partner_user_info a hy_partner_line_info a
LEFT JOIN hy_partner_line_info b ON a.partner_id = b.partner_id and b.deleted=0 LEFT JOIN hy_partner_user_info b ON a.partner_id = b.partner_id
LEFT JOIN hy_partner_user_channel c ON a.user_channel_id = c.channel_id AND a.deleted = 0
LEFT JOIN enterprise_user d ON b.investment_manager = d.user_id and d.deleted=0 LEFT JOIN hy_partner_user_channel c ON b.user_channel_id = c.channel_id
LEFT JOIN ( LEFT JOIN enterprise_user d ON a.investment_manager = d.user_id
AND d.deleted = 0
LEFT JOIN (
SELECT SELECT
partner_id, partner_id,
IFNULL( COUNT( 1 ), 0 ) AS followCount IFNULL( COUNT( 1 ), 0 ) AS followCount
@@ -76,31 +81,35 @@
( deleted = 1 OR ( deleted = 0 AND line_status IN ( 0, 3 ) AND close_time IS NOT NULL ) ) ( deleted = 1 OR ( deleted = 0 AND line_status IN ( 0, 3 ) AND close_time IS NOT NULL ) )
AND investment_manager IS NOT NULL AND investment_manager IS NOT NULL
GROUP BY GROUP BY
partner_id ) tl_l on b.partner_id=tl_l.partner_id partner_id
) tl_l ON b.partner_id = tl_l.partner_id
WHERE ( b.update_time BETWEEN #{selectTime} and #{now} or WHERE ( b.update_time BETWEEN #{selectTime} and #{now} or
a.update_time BETWEEN #{selectTime} and #{now} ) and a.username is not null order by a.id Limit #{limit1},#{limit2} a.update_time BETWEEN #{selectTime} and #{now} ) and b.partner_id is not null order by a.id Limit #{limit1},#{limit2}
</select> </select>
<select id="selectByHourDateCount" resultType="java.lang.Integer"> <select id="selectByHourDateCount" resultType="java.lang.Integer">
SELECT SELECT
count(*) count(*)
FROM FROM
hy_partner_user_info a hy_partner_line_info a
LEFT JOIN hy_partner_line_info b ON a.partner_id = b.partner_id and b.deleted=0 LEFT JOIN hy_partner_user_info b ON a.partner_id = b.partner_id
LEFT JOIN hy_partner_user_channel c ON a.user_channel_id = c.channel_id AND a.deleted = 0
LEFT JOIN enterprise_user d ON b.investment_manager = d.user_id and d.deleted=0 LEFT JOIN hy_partner_user_channel c ON b.user_channel_id = c.channel_id
LEFT JOIN ( LEFT JOIN enterprise_user d ON a.investment_manager = d.user_id
SELECT AND d.deleted = 0
partner_id, LEFT JOIN (
IFNULL( COUNT( 1 ), 0 ) AS followCount SELECT
FROM partner_id,
hy_partner_line_info IFNULL( COUNT( 1 ), 0 ) AS followCount
WHERE FROM
( deleted = 1 OR ( deleted = 0 AND line_status IN ( 0, 3 ) AND close_time IS NOT NULL ) ) hy_partner_line_info
AND investment_manager IS NOT NULL WHERE
GROUP BY ( deleted = 1 OR ( deleted = 0 AND line_status IN ( 0, 3 ) AND close_time IS NOT NULL ) )
partner_id ) tl_l on b.partner_id=tl_l.partner_id AND investment_manager IS NOT NULL
GROUP BY
partner_id
) tl_l ON b.partner_id = tl_l.partner_id
WHERE (b.update_time BETWEEN #{selectTime} and #{now} or WHERE (b.update_time BETWEEN #{selectTime} and #{now} or
a.update_time BETWEEN #{selectTime} and #{now} ) and a.username is not null a.update_time BETWEEN #{selectTime} and #{now} ) and b.partner_id is not null
</select> </select>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">

View File

@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date; import java.util.Date;
@@ -16,6 +17,7 @@ import java.util.Date;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Accessors(chain = true)
public class HyPartnerLabelDO { public class HyPartnerLabelDO {
@ApiModelProperty("") @ApiModelProperty("")
private Long id; private Long id;

View File

@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date; import java.util.Date;
@@ -16,6 +17,7 @@ import java.util.Date;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Accessors(chain = true)
public class HyPartnerLabelGroupDO { public class HyPartnerLabelGroupDO {
@ApiModelProperty("id") @ApiModelProperty("id")

View File

@@ -0,0 +1,16 @@
package com.cool.store.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class SyncEcCustomerLabelDO {
private String mobile;
private String userPortrait;
}

View File

@@ -0,0 +1,27 @@
package com.cool.store.request;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author hxd
*/
@Data
@Accessors(chain = true)
public class GetTagRequest {
private Long groupId;
private String groupName;
private Integer sort;
private Integer type;
private List<GetTagItem> list;
@Data
@Accessors(chain = true)
public static class GetTagItem{
private Long classId;
private String className;
private int sort;
}
}

View File

@@ -0,0 +1,91 @@
package com.cool.store.job;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.cool.store.entity.HyPartnerBaseInfoDO;
import com.cool.store.entity.SyncEcCustomerDO;
import com.cool.store.entity.SyncEcCustomerLabelDO;
import com.cool.store.mapper.HyPartnerBaseInfoMapper;
import com.cool.store.sdk.ec.EcClient;
import com.cool.store.sdk.ec.request.SyncEcCustomerLabelRequest;
import com.cool.store.sdk.ec.request.SyncEcCustomerRequest;
import com.cool.store.sdk.ec.response.SyncEcCustomerLabelResponse;
import com.cool.store.service.HyPartnerBaseInfoService;
import com.cool.store.utils.MybatisBatchUtils;
import com.cool.store.utils.StringUtil;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author hxd
*/
@Slf4j
@Component
public class SyncEcCustomerLabelJob {
@Value("${ec.baseUrl:null}")
private String baseUrl;
@Resource
private HyPartnerBaseInfoMapper hyPartnerBaseInfoMapper;
@XxlJob("SyncEcCustomerLabelJob")
public void execute() {
XxlJobHelper.log("-------------------------------同步ec客户标签数据到小程序开始-------------------------------");
syncEcLabelExecute();
XxlJobHelper.log("-------------------------------同步ec标签数据到小程序结束-------------------------------");
XxlJobHelper.handleSuccess();
}
@Autowired
private MybatisBatchUtils mybatisBatchUtils;
private final Integer count = 20;
/**
* 同步ec标签到招商数据库中
*/
private void syncEcLabelExecute() {
//获取总数
int size = hyPartnerBaseInfoMapper.selectAllList();
//执行数
int counts = size / count;
//取余如果大于1就再加一
int yu = size % count;
if (yu > 0) {
counts += 1;
}
for (int i = 1; i <= counts; i++) {
XxlJobHelper.log("执行limit1" + count * (i - 1) + "执行limit2" + count);
List<SyncEcCustomerLabelDO> list = hyPartnerBaseInfoMapper.selectListByLimit(count * (i - 1), count);
SyncEcCustomerLabelRequest syncEcCustomerLabelRequest = new SyncEcCustomerLabelRequest();
syncEcCustomerLabelRequest.setParameter(list);
EcClient ecClient = new EcClient();
SyncEcCustomerLabelResponse exec = ecClient.exec(baseUrl, syncEcCustomerLabelRequest);
if (ObjectUtil.isNull(exec)) {
continue;
}
List<SyncEcCustomerLabelDO> execList = exec.getData();
if (CollectionUtils.isEmpty(execList)) {
continue;
}
List<HyPartnerBaseInfoDO> collect = execList.stream().map((item) -> {
HyPartnerBaseInfoDO hyPartnerBaseInfoDO = new HyPartnerBaseInfoDO();
BeanUtil.copyProperties(item, hyPartnerBaseInfoDO);
return hyPartnerBaseInfoDO;
}).collect(Collectors.toList());
mybatisBatchUtils.batchInsertOrUpdate(collect, HyPartnerBaseInfoMapper.class, (record, mapper) -> mapper.updateByMobile(record));
}
}
}

View File

@@ -0,0 +1,21 @@
package com.cool.store.sdk.ec.request;
import com.cool.store.sdk.ec.core.EcRequest;
import com.cool.store.sdk.ec.response.SyncEcCustomerLabelResponse;
/**
* @author hxd
*/
public class SyncEcCustomerLabelRequest extends EcRequest<SyncEcCustomerLabelResponse> {
@Override
public String getApiUrl() {
return "/ec/appletToEcLabel";
}
@Override
public Class<SyncEcCustomerLabelResponse> getResponseClass() {
return SyncEcCustomerLabelResponse.class;
}
}

View File

@@ -0,0 +1,22 @@
package com.cool.store.sdk.ec.response;
import com.cool.store.entity.SyncEcCustomerLabelDO;
import com.cool.store.sdk.ec.core.EcResponse;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author hxd
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class SyncEcCustomerLabelResponse extends EcResponse {
private List<SyncEcCustomerLabelDO> data;
}

View File

@@ -1,6 +1,7 @@
package com.cool.store.service; package com.cool.store.service;
import com.cool.store.request.CustomerInfoRequest; import com.cool.store.request.CustomerInfoRequest;
import com.cool.store.request.GetTagRequest;
import java.util.List; import java.util.List;
@@ -8,4 +9,7 @@ public interface EcSyncService {
boolean ecToApplet(List<CustomerInfoRequest> queryListData); boolean ecToApplet(List<CustomerInfoRequest> queryListData);
void getChannelSource(); void getChannelSource();
Boolean labelInfo(List<GetTagRequest> getTagRequestList);
} }

View File

@@ -4,6 +4,7 @@ import com.cool.store.dto.label.LabelGroupAddDTO;
import com.cool.store.dto.label.LabelGroupDeleteDTO; import com.cool.store.dto.label.LabelGroupDeleteDTO;
import com.cool.store.dto.label.LabelGroupListDTO; import com.cool.store.dto.label.LabelGroupListDTO;
import com.cool.store.dto.label.LabelGroupUpdateDTO; import com.cool.store.dto.label.LabelGroupUpdateDTO;
import com.cool.store.entity.HyPartnerLabelGroupDO;
import com.cool.store.exception.ApiException; import com.cool.store.exception.ApiException;
import com.cool.store.vo.LabelGroupListVo; import com.cool.store.vo.LabelGroupListVo;
@@ -44,4 +45,12 @@ public interface LabelGroupService {
*/ */
List<LabelGroupListVo> getAllLabelGroupList(); List<LabelGroupListVo> getAllLabelGroupList();
/**
* 添加ec标签组
* @param hyPartnerLabelGroupDO
*/
void addEcLabelGroup(HyPartnerLabelGroupDO hyPartnerLabelGroupDO);
HyPartnerLabelGroupDO selectByPrimaryKey(Long id);
} }

View File

@@ -4,6 +4,7 @@ import com.cool.store.dto.label.LabelAddDTO;
import com.cool.store.dto.label.LabelDeleteDTO; import com.cool.store.dto.label.LabelDeleteDTO;
import com.cool.store.dto.label.LabelListDTO; import com.cool.store.dto.label.LabelListDTO;
import com.cool.store.dto.label.LabelUpdateDTO; import com.cool.store.dto.label.LabelUpdateDTO;
import com.cool.store.entity.HyPartnerLabelDO;
import com.cool.store.exception.ApiException; import com.cool.store.exception.ApiException;
import com.cool.store.vo.LabelListVo; import com.cool.store.vo.LabelListVo;
@@ -55,4 +56,9 @@ public interface LabelService {
* @param dto * @param dto
*/ */
void deleteLabel(LabelDeleteDTO dto); void deleteLabel(LabelDeleteDTO dto);
HyPartnerLabelDO selectByPrimaryKey(Long classId);
void addEcLabel(HyPartnerLabelDO hyPartnerLabelDO);
} }

View File

@@ -9,14 +9,18 @@ import com.cool.store.dao.EnterpriseUserDAO;
import com.cool.store.dao.HyPartnerBaseInfoDAO; import com.cool.store.dao.HyPartnerBaseInfoDAO;
import com.cool.store.dao.HyPartnerLineInfoDAO; import com.cool.store.dao.HyPartnerLineInfoDAO;
import com.cool.store.dao.HyPartnerUserInfoDAO; import com.cool.store.dao.HyPartnerUserInfoDAO;
import com.cool.store.dto.partner.LineCountDTO;
import com.cool.store.entity.*; import com.cool.store.entity.*;
import com.cool.store.enums.LineStatusEnum; import com.cool.store.enums.LineStatusEnum;
import com.cool.store.enums.WorkflowStageEnum; import com.cool.store.enums.WorkflowStageEnum;
import com.cool.store.enums.WorkflowStatusEnum; import com.cool.store.enums.WorkflowStatusEnum;
import com.cool.store.exception.ApiException; import com.cool.store.exception.ApiException;
import com.cool.store.http.UserSourceResponse; import com.cool.store.http.UserSourceResponse;
import com.cool.store.mapper.HyPartnerLabelGroupMapper;
import com.cool.store.mapper.HyPartnerLabelMapper;
import com.cool.store.mapper.HyPartnerUserChannelMapper; import com.cool.store.mapper.HyPartnerUserChannelMapper;
import com.cool.store.request.CustomerInfoRequest; import com.cool.store.request.CustomerInfoRequest;
import com.cool.store.request.GetTagRequest;
import com.cool.store.sdk.ec.EcClient; import com.cool.store.sdk.ec.EcClient;
import com.cool.store.sdk.ec.bo.ChangeFollowUserBo; import com.cool.store.sdk.ec.bo.ChangeFollowUserBo;
import com.cool.store.sdk.ec.bo.UpdateCustomerBo; import com.cool.store.sdk.ec.bo.UpdateCustomerBo;
@@ -25,6 +29,8 @@ import com.cool.store.sdk.ec.request.UpdateCustomerRequest;
import com.cool.store.sdk.ec.response.ChangeFollowUserResponse; import com.cool.store.sdk.ec.response.ChangeFollowUserResponse;
import com.cool.store.sdk.ec.response.UpdateCustomerResponse; import com.cool.store.sdk.ec.response.UpdateCustomerResponse;
import com.cool.store.service.EcSyncService; import com.cool.store.service.EcSyncService;
import com.cool.store.service.LabelGroupService;
import com.cool.store.service.LabelService;
import com.cool.store.utils.Post; import com.cool.store.utils.Post;
import com.cool.store.utils.StringUtil; import com.cool.store.utils.StringUtil;
import com.cool.store.utils.UUIDUtils; import com.cool.store.utils.UUIDUtils;
@@ -33,9 +39,11 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -45,10 +53,10 @@ import java.util.List;
public class EcSyncServiceImpl implements EcSyncService { public class EcSyncServiceImpl implements EcSyncService {
@Value("${ec.baseUrl:null}") @Value("${ec.baseUrl:null}")
private String baseUrl; private String baseUrl;
@Resource @Resource
private HyPartnerLineInfoDAO hyPartnerLineInfoDAO; private HyPartnerLineInfoDAO hyPartnerLineInfoDAO;
@@ -65,6 +73,12 @@ public class EcSyncServiceImpl implements EcSyncService {
@Resource @Resource
private HyPartnerUserChannelMapper hyPartnerUserChannelMapper; private HyPartnerUserChannelMapper hyPartnerUserChannelMapper;
@Resource
private LabelGroupService labelGroupService;
@Resource
private LabelService labelService;
@Override @Override
public boolean ecToApplet(List<CustomerInfoRequest> queryListData) { public boolean ecToApplet(List<CustomerInfoRequest> queryListData) {
@@ -73,7 +87,7 @@ public class EcSyncServiceImpl implements EcSyncService {
insertSelectiveSync(customerInfoItem); insertSelectiveSync(customerInfoItem);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
sendFeiShuRobotMessage("推送:"+JSONObject.toJSONString(e),"27243d49-97ca-4981-8aec-7c3bf84eb660"); sendFeiShuRobotMessage("推送:" + JSONObject.toJSONString(e), "27243d49-97ca-4981-8aec-7c3bf84eb660");
} }
} }
return false; return false;
@@ -81,7 +95,7 @@ public class EcSyncServiceImpl implements EcSyncService {
@Override @Override
public void getChannelSource() { public void getChannelSource() {
String s = HttpUtil.get(baseUrl+"/ec/getChannelSource"); String s = HttpUtil.get(baseUrl + "/ec/getChannelSource");
UserSourceResponse userSourceResponse = JSONObject.parseObject(s, UserSourceResponse.class); UserSourceResponse userSourceResponse = JSONObject.parseObject(s, UserSourceResponse.class);
for (UserSourceResponse.ChannelSource channelSource : userSourceResponse.getData()) { for (UserSourceResponse.ChannelSource channelSource : userSourceResponse.getData()) {
Long id = channelSource.getId(); Long id = channelSource.getId();
@@ -92,13 +106,35 @@ public class EcSyncServiceImpl implements EcSyncService {
if (ObjectUtil.isNotNull(selectByChannel)) { if (ObjectUtil.isNotNull(selectByChannel)) {
hyPartnerUserChannel.setUpdateTime(new Date()).setId(selectByChannel.getId()); hyPartnerUserChannel.setUpdateTime(new Date()).setId(selectByChannel.getId());
hyPartnerUserChannelMapper.updateByPrimaryKeySelective(hyPartnerUserChannel); hyPartnerUserChannelMapper.updateByPrimaryKeySelective(hyPartnerUserChannel);
}else { } else {
hyPartnerUserChannel.setCreateTime(new Date()); hyPartnerUserChannel.setCreateTime(new Date());
hyPartnerUserChannelMapper.insertSelective(hyPartnerUserChannel); hyPartnerUserChannelMapper.insertSelective(hyPartnerUserChannel);
} }
} }
} }
@Override
public Boolean labelInfo(List<GetTagRequest> getTagRequestList) {
for (GetTagRequest getTagRequest : getTagRequestList) {
Long groupId = getTagRequest.getGroupId();
if (ObjectUtil.isNotNull(labelGroupService.selectByPrimaryKey(groupId))) {
continue;
}
HyPartnerLabelGroupDO hyPartnerLabelGroupDO = new HyPartnerLabelGroupDO();
hyPartnerLabelGroupDO.setLabelGroupName(getTagRequest.getGroupName()).setId(groupId);
labelGroupService.addEcLabelGroup(hyPartnerLabelGroupDO);
for (GetTagRequest.GetTagItem item : getTagRequest.getList()) {
if (ObjectUtil.isNotNull(labelService.selectByPrimaryKey(item.getClassId()))) {
continue;
}
HyPartnerLabelDO hyPartnerLabelDO = new HyPartnerLabelDO();
hyPartnerLabelDO.setLabelName(item.getClassName()).setId(item.getClassId()).setLabelGroupId(groupId);
labelService.addEcLabel(hyPartnerLabelDO);
}
}
return Boolean.TRUE;
}
/** /**
* 同步ec数据到表中 同时将部分数据同步到ec * 同步ec数据到表中 同时将部分数据同步到ec
* *
@@ -112,13 +148,13 @@ public class EcSyncServiceImpl implements EcSyncService {
//获取客户来源id //获取客户来源id
String channel = customerInfoItem.getChannel(); String channel = customerInfoItem.getChannel();
HyPartnerUserChannelDO hyPartnerUserChannelDO = hyPartnerUserChannelMapper.selectByChannelName(channel); HyPartnerUserChannelDO hyPartnerUserChannelDO = hyPartnerUserChannelMapper.selectByChannelName(channel);
Long channelId =null; Long channelId = null;
if (StringUtil.isNotEmpty(channel)) { if (StringUtil.isNotEmpty(channel)) {
if (ObjectUtil.isNull(hyPartnerUserChannelDO)||ObjectUtil.isNull(hyPartnerUserChannelDO.getChannelId())) { if (ObjectUtil.isNull(hyPartnerUserChannelDO) || ObjectUtil.isNull(hyPartnerUserChannelDO.getChannelId())) {
getChannelSource(); getChannelSource();
} }
HyPartnerUserChannelDO channelDO = hyPartnerUserChannelMapper.selectByChannelName(channel); HyPartnerUserChannelDO channelDO = hyPartnerUserChannelMapper.selectByChannelName(channel);
channelId=channelDO.getChannelId(); channelId = channelDO.getChannelId();
} }
String newPartnerId = UUIDUtils.get32UUID(); String newPartnerId = UUIDUtils.get32UUID();
HyPartnerUserInfoDO resultUser = new HyPartnerUserInfoDO(); HyPartnerUserInfoDO resultUser = new HyPartnerUserInfoDO();
@@ -128,11 +164,11 @@ public class EcSyncServiceImpl implements EcSyncService {
String followUserName = customerInfoItem.getFollowUserName(); String followUserName = customerInfoItem.getFollowUserName();
String followUserMobile = customerInfoItem.getFollowUserMobile(); String followUserMobile = customerInfoItem.getFollowUserMobile();
//传递过来有跟进人的情况下查询跟进人是否存在 //传递过来有跟进人的情况下查询跟进人是否存在
if (StringUtil.isNotEmpty(followUserMobile)&&StringUtil.isNotEmpty(followUserName)) { if (StringUtil.isNotEmpty(followUserMobile) && StringUtil.isNotEmpty(followUserName)) {
String userId = enterpriseUserDAO.selectByMobile(followUserMobile); String userId = enterpriseUserDAO.selectByMobile(followUserMobile);
if (StringUtil.isEmpty(userId)) { if (StringUtil.isEmpty(userId)) {
// 给飞书群发送消息 跟进人找不到 // 给飞书群发送消息 跟进人找不到
sendFeiShuRobotMessage("推送:飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile,"27243d49-97ca-4981-8aec-7c3bf84eb660"); sendFeiShuRobotMessage("推送:飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile, "27243d49-97ca-4981-8aec-7c3bf84eb660");
throw new ApiException("飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile); throw new ApiException("飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile);
} }
resultLine.setInvestmentManager(userId); resultLine.setInvestmentManager(userId);
@@ -144,7 +180,7 @@ public class EcSyncServiceImpl implements EcSyncService {
resultBase.setUsername(customerInfoItem.getName()).setMobile(customerInfoItem.getMobile()); resultBase.setUsername(customerInfoItem.getName()).setMobile(customerInfoItem.getMobile());
HyPartnerUserInfoDO newUserInfo = hyPartnerUserInfoDAO.selectByMobile(resultUser.getMobile()); HyPartnerUserInfoDO newUserInfo = hyPartnerUserInfoDAO.selectByMobile(resultUser.getMobile());
EcClient ecClient=new EcClient(); EcClient ecClient = new EcClient();
//有就更新ec没有就插入 //有就更新ec没有就插入
if (newUserInfo != null) { if (newUserInfo != null) {
//招商客户姓名为空 //招商客户姓名为空
@@ -154,11 +190,11 @@ public class EcSyncServiceImpl implements EcSyncService {
} }
// EC与沪姨合伙人同时存在的线索用户但用户姓名不同将沪姨合伙人线索姓名同步至EC覆盖原EC线索姓名 // EC与沪姨合伙人同时存在的线索用户但用户姓名不同将沪姨合伙人线索姓名同步至EC覆盖原EC线索姓名
if (!newUserInfo.getUsername().equals(resultUser.getUsername())) { if (!newUserInfo.getUsername().equals(resultUser.getUsername())) {
UpdateCustomerRequest updateUserRequest=new UpdateCustomerRequest(); UpdateCustomerRequest updateUserRequest = new UpdateCustomerRequest();
UpdateCustomerBo updateCustomerBo = new UpdateCustomerBo(); UpdateCustomerBo updateCustomerBo = new UpdateCustomerBo();
updateCustomerBo.setUsername(newUserInfo.getUsername()).setMobile(newUserInfo.getMobile()).setCrmId(customerInfoItem.getCrmId()); updateCustomerBo.setUsername(newUserInfo.getUsername()).setMobile(newUserInfo.getMobile()).setCrmId(customerInfoItem.getCrmId());
updateUserRequest.setParameter(updateCustomerBo); updateUserRequest.setParameter(updateCustomerBo);
UpdateCustomerResponse updateUserExec = ecClient.exec(baseUrl,updateUserRequest); UpdateCustomerResponse updateUserExec = ecClient.exec(baseUrl, updateUserRequest);
} }
String oldPartnerId = newUserInfo.getPartnerId(); String oldPartnerId = newUserInfo.getPartnerId();
//线索表 //线索表
@@ -169,30 +205,33 @@ public class EcSyncServiceImpl implements EcSyncService {
if (StringUtil.isNotEmpty(resultLine.getInvestmentManager())) { if (StringUtil.isNotEmpty(resultLine.getInvestmentManager())) {
resultLine.setId(partnerLine.getId()).setUpdateTime(new Date()); resultLine.setId(partnerLine.getId()).setUpdateTime(new Date());
//沪姨合伙人线索存在黑名单EC该线索分配跟进人同步到沪姨合伙人但线索状态不变还存在黑名单中 //沪姨合伙人线索存在黑名单EC该线索分配跟进人同步到沪姨合伙人但线索状态不变还存在黑名单中
resultLine.setLineStatus(partnerLine.getLineStatus().intValue()==LineStatusEnum.BLACKLIST.getCode().intValue() resultLine.setLineStatus(partnerLine.getLineStatus().intValue() == LineStatusEnum.BLACKLIST.getCode().intValue()
?LineStatusEnum.BLACKLIST.getCode():resultLine.getLineStatus()); ? LineStatusEnum.BLACKLIST.getCode() : resultLine.getLineStatus());
hyPartnerLineInfoDAO.updateByPrimaryKeySelective(resultLine); hyPartnerLineInfoDAO.updateByPrimaryKeySelective(resultLine);
} }
}else { } else {
EnterpriseUserDO enterpriseUser = enterpriseUserDAO.getUserInfoById(partnerLine.getInvestmentManager()); if (!getFollowLineStatus(partnerLine)) {
enterpriseUser.setMobile(getNoWith86Number(enterpriseUser.getMobile())); //私海
//电话相同但是名字不同 EnterpriseUserDO enterpriseUser = enterpriseUserDAO.getUserInfoById(partnerLine.getInvestmentManager());
if (enterpriseUser.getMobile().equals(followUserMobile) && !enterpriseUser.getName().equals(followUserName)) { enterpriseUser.setMobile(getNoWith86Number(enterpriseUser.getMobile()));
ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest(); //电话相同但是名字不同
ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo(); if (enterpriseUser.getMobile().equals(followUserMobile) && !enterpriseUser.getName().equals(followUserName)) {
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId()) ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest();
.setType(1).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile()); ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo();
changeFollowUserRequest.setParameter(changeFollowUserBo); changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl,changeFollowUserRequest); .setType(1).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
} changeFollowUserRequest.setParameter(changeFollowUserBo);
//电话不同 ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl, changeFollowUserRequest);
if (!enterpriseUser.getMobile().equals(followUserMobile)) { }
ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest(); //电话不同
ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo(); if (!enterpriseUser.getMobile().equals(followUserMobile)) {
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId()) ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest();
.setType(2).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile()); ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo();
changeFollowUserRequest.setParameter(changeFollowUserBo); changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl,changeFollowUserRequest); .setType(2).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
changeFollowUserRequest.setParameter(changeFollowUserBo);
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl, changeFollowUserRequest);
}
} }
} }
//base表 //base表
@@ -223,10 +262,23 @@ public class EcSyncServiceImpl implements EcSyncService {
} }
} }
public static void main(String[] args) {
Integer a=null;
System.out.println(a.equals("bb"));
/**
*招商公海内跟进次数大于等于1的用户EC同步该用户进去公海,假若跟进次数为0的同步到EC跟进人就是唐佑玉
* @param partnerLine
* @return true为公海 false:私海
*/
public Boolean getFollowLineStatus(HyPartnerLineInfoDO partnerLine){
if(partnerLine.getLineStatus()!=0){
return Boolean.FALSE;
}
ArrayList<String> list = new ArrayList<>();
list.add(partnerLine.getPartnerId());
List<LineCountDTO> followCountList = hyPartnerLineInfoDAO.getFollowCountList(list);
if (!CollectionUtils.isEmpty(followCountList)) {
return followCountList.get(0).getFollowCount()>0;
}
return Boolean.FALSE;
} }
/** /**

View File

@@ -14,6 +14,7 @@ import com.cool.store.mapper.HyPartnerLabelMapper;
import com.cool.store.service.LabelGroupService; import com.cool.store.service.LabelGroupService;
import com.cool.store.vo.LabelGroupListVo; import com.cool.store.vo.LabelGroupListVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -33,6 +34,10 @@ public class LabelGroupServiceImpl implements LabelGroupService {
@Autowired @Autowired
private HyPartnerLabelMapper labelMapper; private HyPartnerLabelMapper labelMapper;
@Value("${ec.sync.createUserId:null}")
private String createUserId;
/** /**
* 查询标签组信息列表 * 查询标签组信息列表
* @param dto 查询条件 * @param dto 查询条件
@@ -110,6 +115,18 @@ public class LabelGroupServiceImpl implements LabelGroupService {
return labelGroupMapper.getLabelGroupList(labelGroupDO); return labelGroupMapper.getLabelGroupList(labelGroupDO);
} }
@Override
public HyPartnerLabelGroupDO selectByPrimaryKey(Long id){
return labelGroupMapper.selectByPrimaryKey(id);
}
@Override
public void addEcLabelGroup(HyPartnerLabelGroupDO hyPartnerLabelGroupDO) {
hyPartnerLabelGroupDO.setCreateTime(new Date()).setCreateUserId(createUserId).setEditDate(new Date())
.setEditUserId(createUserId);
labelGroupMapper.insertSelective(hyPartnerLabelGroupDO);
}
/** /**
* 某个标签组内是否有未删除的标签 * 某个标签组内是否有未删除的标签
* @param id 标签组 id * @param id 标签组 id

View File

@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -32,6 +33,11 @@ public class LabelServiceImpl implements LabelService {
@Autowired @Autowired
private HyPartnerLabelMapper labelMapper; private HyPartnerLabelMapper labelMapper;
@Value("${ec.sync.createUserId:null}")
private String createUserId;
/** /**
* 获取数组列表 * 获取数组列表
* *
@@ -98,6 +104,18 @@ public class LabelServiceImpl implements LabelService {
labelMapper.updateByPrimaryKeySelective(labelDO); labelMapper.updateByPrimaryKeySelective(labelDO);
} }
@Override
public HyPartnerLabelDO selectByPrimaryKey(Long classId) {
return labelMapper.selectByPrimaryKey(classId);
}
@Override
public void addEcLabel(HyPartnerLabelDO hyPartnerLabelDO) {
hyPartnerLabelDO.setEditDate(new Date()).setCreateTime(new Date()).setEditUserId(createUserId).setCreateUserId(createUserId)
.setUpdateUserId(createUserId);
labelMapper.insertSelective(hyPartnerLabelDO);
}
private Boolean whetherLabelRepeat(HyPartnerLabelDO label) throws ApiException { private Boolean whetherLabelRepeat(HyPartnerLabelDO label) throws ApiException {
Long id = label.getId(); Long id = label.getId();
label.setId(null); label.setId(null);

View File

@@ -36,6 +36,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Service @Service
public class LineHighSeasServiceImpl implements LineHighSeasService { public class LineHighSeasServiceImpl implements LineHighSeasService {
@@ -145,6 +146,10 @@ public class LineHighSeasServiceImpl implements LineHighSeasService {
String fileStr = ossServer.uploadFileServer(stream, dir + getExcelName()); String fileStr = ossServer.uploadFileServer(stream, dir + getExcelName());
return new ResponseResult(500, "共上传" + lineDOList.size() + "条线索,其中" + styleCells.size() + "条存在异常", new ErrorExcelResponse(lineDOList.size(), styleCells.size(), fileStr)); return new ResponseResult(500, "共上传" + lineDOList.size() + "条线索,其中" + styleCells.size() + "条存在异常", new ErrorExcelResponse(lineDOList.size(), styleCells.size(), fileStr));
} }
//获取重复手机号集合
List<String> uniqueList = lineDOList.stream().filter(item->StringUtil.isNotEmpty(item.getMobile())).collect(Collectors.groupingBy(HyPartnerLineDO::getMobile, Collectors.counting()))
.entrySet().stream().filter(e -> e.getValue() > 1)
.map(Map.Entry::getKey).collect(Collectors.toList());
for (int i = 0; i < lineDOList.size(); i++) { for (int i = 0; i < lineDOList.size(); i++) {
HyPartnerLineDO hyPartnerLineDO = lineDOList.get(i); HyPartnerLineDO hyPartnerLineDO = lineDOList.get(i);
String partnerName = hyPartnerLineDO.getPartnerName(); String partnerName = hyPartnerLineDO.getPartnerName();
@@ -174,6 +179,11 @@ public class LineHighSeasServiceImpl implements LineHighSeasService {
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.MOBILE_EXIST : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_EXIST)); hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.MOBILE_EXIST : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_EXIST));
ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED}); ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED});
} }
//手机号重复
if (uniqueList.contains(mobile)) {
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.MOBILE_REPEAT : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_REPEAT));
ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED});
}
} }
//常驻区域为空 //常驻区域为空
String liveArea = hyPartnerLineDO.getLiveAreaReplace().trim(); String liveArea = hyPartnerLineDO.getLiveAreaReplace().trim();

View File

@@ -0,0 +1,56 @@
package com.cool.store.utils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.function.BiConsumer;
@Component
@ConditionalOnClass({SqlSessionFactory.class, SqlSessionFactoryBean.class})
public class MybatisBatchUtils {
/**
* 每次处理500条
*/
private static final int BATCH_SIZE = 500;
@Resource
private SqlSessionFactory sqlSessionFactory;
/**
* 批量处理修改或者插入
*
* @param data 需要被处理的数据
* @param mapperClass Mybatis的Mapper类
* @param consumer 自定义处理逻辑
* @return int 影响的总行数
* @author renwd
*/
public <T, U> int batchInsertOrUpdate(List<T> data, Class<U> mapperClass, BiConsumer<T, U> consumer) {
int i = 1;
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
try {
U mapper = sqlSession.getMapper(mapperClass);
int size = data.size();
for (T element : data) {
consumer.accept(element, mapper);
if ((i % BATCH_SIZE == 0) || i == size) {
sqlSession.flushStatements();
}
i++;
}
sqlSession.commit();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
sqlSession.close();
}
return i - 1;
}
}

View File

@@ -51,6 +51,7 @@ public class TokenValidateFilter implements Filter {
//TODO 800回调地址暂时不做验证 //TODO 800回调地址暂时不做验证
"/partner/pc/flow/qualificationReview/callback", "/partner/pc/flow/qualificationReview/callback",
"/**/ecSync/ecToApplet/**", "/**/ecSync/ecToApplet/**",
"/**/ecSync/labelInfo/**",
"/partner/pc/websocket/**", "/partner/pc/websocket/**",
"/partner/pc/call/**"); "/partner/pc/call/**");

View File

@@ -2,6 +2,7 @@ package com.cool.store.controller;
import com.cool.store.request.CustomerInfoRequest; import com.cool.store.request.CustomerInfoRequest;
import com.cool.store.request.GetTagRequest;
import com.cool.store.response.ResponseResult; import com.cool.store.response.ResponseResult;
import com.cool.store.service.EcSyncService; import com.cool.store.service.EcSyncService;
import com.cool.store.vo.InterviewScheduleInfoVO; import com.cool.store.vo.InterviewScheduleInfoVO;
@@ -28,4 +29,10 @@ public class EcSyncController {
return ResponseResult.success(ecSyncService.ecToApplet(queryListData)); return ResponseResult.success(ecSyncService.ecToApplet(queryListData));
} }
@PostMapping(path = "/labelInfo")
@ApiOperation("ec同步标签数据到小程序")
public ResponseResult<Boolean> labelInfo(@RequestBody List<GetTagRequest> getTagRequestList){
return ResponseResult.success(ecSyncService.labelInfo(getTagRequestList));
}
} }