Merge branch 'hxd/feat/ecSync' into cc_20230520_partner
# Conflicts: # coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserDAO.java # coolstore-partner-webb/src/main/java/com/cool/store/config/TokenValidateFilter.java
This commit is contained in:
@@ -108,4 +108,8 @@ public class EnterpriseUserDAO {
|
|||||||
List<EnterpriseUserDO> userList = getUserInfoByUserIds(userIds);
|
List<EnterpriseUserDO> userList = getUserInfoByUserIds(userIds);
|
||||||
return userList.stream().filter(o->!StringUtils.isAnyBlank(o.getMobile(), o.getName())).collect(Collectors.toMap(k -> k.getUserId(), v -> v.getName() + " " + v.getMobile()));
|
return userList.stream().filter(o->!StringUtils.isAnyBlank(o.getMobile(), o.getName())).collect(Collectors.toMap(k -> k.getUserId(), v -> v.getName() + " " + v.getMobile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String selectByMobile(String mobile) {
|
||||||
|
return enterpriseUserMapper.selectByMobile(mobile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -90,4 +90,7 @@ public interface EnterpriseUserMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<EnterpriseUserDO> getUserListByRegionIds(@Param("regionIds") List<String> regionIds);
|
List<EnterpriseUserDO> getUserListByRegionIds(@Param("regionIds") List<String> regionIds);
|
||||||
|
|
||||||
|
String selectByMobile(@Param("mobile") String mobile);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.cool.store.mapper;
|
||||||
|
|
||||||
|
import com.cool.store.entity.HyPartnerUserChannelDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface HyPartnerUserChannelMapper {
|
||||||
|
int deleteByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
int insert(HyPartnerUserChannelDO record);
|
||||||
|
|
||||||
|
int insertSelective(HyPartnerUserChannelDO record);
|
||||||
|
|
||||||
|
HyPartnerUserChannelDO selectByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
int updateByPrimaryKeySelective(HyPartnerUserChannelDO record);
|
||||||
|
|
||||||
|
int updateByPrimaryKey(HyPartnerUserChannelDO record);
|
||||||
|
|
||||||
|
HyPartnerUserChannelDO selectByChannelId(@Param("channelId") Long id);
|
||||||
|
|
||||||
|
HyPartnerUserChannelDO selectByChannelName(@Param("channelName") String channelName);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.cool.store.mapper;
|
package com.cool.store.mapper;
|
||||||
|
|
||||||
import com.cool.store.entity.HyPartnerUserInfoDO;
|
import com.cool.store.entity.HyPartnerUserInfoDO;
|
||||||
|
import com.cool.store.entity.SyncEcCustomerDO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -43,4 +44,7 @@ public interface HyPartnerUserInfoMapper {
|
|||||||
|
|
||||||
int updateJoinKnowById(@Param("isWritePartnerKnow")Integer isWritePartnerKnow, @Param("id")Long id);
|
int updateJoinKnowById(@Param("isWritePartnerKnow")Integer isWritePartnerKnow, @Param("id")Long id);
|
||||||
|
|
||||||
|
List<SyncEcCustomerDO> selectByHourDate(@Param("selectTime") String hourDayDate, @Param("now") String now,@Param("limit1")Integer limit1,@Param("limit2")Integer limit2);
|
||||||
|
|
||||||
|
int selectByHourDateCount(@Param("selectTime") String hourDayDate, @Param("now") String now);
|
||||||
}
|
}
|
||||||
@@ -308,4 +308,7 @@
|
|||||||
SUBSTR(jobnumber,1,1),
|
SUBSTR(jobnumber,1,1),
|
||||||
CAST(SUBSTR(jobnumber,2) AS UNSIGNED) ASC
|
CAST(SUBSTR(jobnumber,2) AS UNSIGNED) ASC
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectByMobile" resultType="java.lang.String">
|
||||||
|
SELECT user_id FROM enterprise_user WHERE mobile =#{mobile} LIMIT 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -20,12 +20,13 @@
|
|||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
<result column="close_time" jdbcType="TIMESTAMP" property="closeTime" />
|
<result column="close_time" jdbcType="TIMESTAMP" property="closeTime" />
|
||||||
<result column="close_user_id" jdbcType="VARCHAR" property="closeUserId" />
|
<result column="close_user_id" jdbcType="VARCHAR" property="closeUserId" />
|
||||||
|
<result column="user_channel_id" jdbcType="BIGINT" property="userChannelId" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, partner_id, workflow_stage, workflow_status, line_status, investment_manager,
|
id, partner_id, workflow_stage, workflow_status, line_status, investment_manager,
|
||||||
development_director, development_manager, deadline, pass_reason, reject_public_reason,
|
development_director, development_manager, deadline, pass_reason, reject_public_reason,
|
||||||
reject_real_reason, certify_file, deleted, create_time, update_time, close_time,
|
reject_real_reason, certify_file, deleted, create_time, update_time, close_time,
|
||||||
close_user_id
|
close_user_id,user_channel_id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectByPrimaryKeySelective" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKeySelective" resultMap="BaseResultMap">
|
||||||
@@ -124,6 +125,9 @@
|
|||||||
<if test="record.closeUserId != null">
|
<if test="record.closeUserId != null">
|
||||||
close_user_id,
|
close_user_id,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.userChannelId != null">
|
||||||
|
user_channel_id,
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="record.partnerId != null">
|
<if test="record.partnerId != null">
|
||||||
@@ -177,6 +181,9 @@
|
|||||||
<if test="record.closeUserId != null">
|
<if test="record.closeUserId != null">
|
||||||
#{record.closeUserId},
|
#{record.closeUserId},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.userChannelId != null">
|
||||||
|
#{record.userChannelId},
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<update id="updateByPrimaryKeySelective">
|
<update id="updateByPrimaryKeySelective">
|
||||||
@@ -239,6 +246,9 @@
|
|||||||
<if test="record.removeBlackReason != null">
|
<if test="record.removeBlackReason != null">
|
||||||
remove_black_reason = #{record.removeBlackReason},
|
remove_black_reason = #{record.removeBlackReason},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.userChannelId != null">
|
||||||
|
user_channel_id = #{record.userChannelId},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where id = #{record.id}
|
where id = #{record.id}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cool.store.mapper.HyPartnerUserChannelMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.cool.store.entity.HyPartnerUserChannelDO">
|
||||||
|
<id column="id" jdbcType="BIGINT" property="id" />
|
||||||
|
<result column="channel_id" jdbcType="BIGINT" property="channelId" />
|
||||||
|
<result column="channel_name" jdbcType="VARCHAR" property="channelName" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, channel_id, channel_name, create_time, update_time
|
||||||
|
</sql>
|
||||||
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from hy_partner_user_channel
|
||||||
|
where id = #{id,jdbcType=BIGINT}
|
||||||
|
</select>
|
||||||
|
<select id="selectByChannelId" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from hy_partner_user_channel
|
||||||
|
where channel_id = #{channelId} limit 1
|
||||||
|
</select>
|
||||||
|
<select id="selectByChannelName" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from hy_partner_user_channel
|
||||||
|
where channel_name = #{channelName} limit 1
|
||||||
|
</select>
|
||||||
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||||
|
delete from hy_partner_user_channel
|
||||||
|
where id = #{id,jdbcType=BIGINT}
|
||||||
|
</delete>
|
||||||
|
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.cool.store.entity.HyPartnerUserChannelDO" useGeneratedKeys="true">
|
||||||
|
insert into hy_partner_user_channel (channel_id, channel_name, create_time,
|
||||||
|
update_time)
|
||||||
|
values (#{channelId,jdbcType=BIGINT}, #{channelName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
|
||||||
|
#{updateTime,jdbcType=TIMESTAMP})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.cool.store.entity.HyPartnerUserChannelDO" useGeneratedKeys="true">
|
||||||
|
insert into hy_partner_user_channel
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="channelId != null">
|
||||||
|
channel_id,
|
||||||
|
</if>
|
||||||
|
<if test="channelName != null">
|
||||||
|
channel_name,
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="channelId != null">
|
||||||
|
#{channelId,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
<if test="channelName != null">
|
||||||
|
#{channelName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
#{createTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<update id="updateByPrimaryKeySelective" parameterType="com.cool.store.entity.HyPartnerUserChannelDO">
|
||||||
|
update hy_partner_user_channel
|
||||||
|
<set>
|
||||||
|
<if test="channelId != null">
|
||||||
|
channel_id = #{channelId,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
<if test="channelName != null">
|
||||||
|
channel_name = #{channelName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id,jdbcType=BIGINT}
|
||||||
|
</update>
|
||||||
|
<update id="updateByPrimaryKey" parameterType="com.cool.store.entity.HyPartnerUserChannelDO">
|
||||||
|
update hy_partner_user_channel
|
||||||
|
set channel_id = #{channelId,jdbcType=BIGINT},
|
||||||
|
channel_name = #{channelName,jdbcType=VARCHAR},
|
||||||
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||||
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
where id = #{id,jdbcType=BIGINT}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
||||||
@@ -51,6 +51,18 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectByHourDate" resultType="com.cool.store.entity.SyncEcCustomerDO" >
|
||||||
|
SELECT a.id as id, a.username as customername,a.mobile as customermobile,c.`name` as followname,c.mobile as followmobile FROM hy_partner_user_info a LEFT join hy_partner_line_info b on
|
||||||
|
a.partner_id=b.partner_id left join enterprise_user c on b.investment_manager=c.user_id
|
||||||
|
WHERE a.create_time BETWEEN #{selectTime} and #{now} or
|
||||||
|
a.update_time BETWEEN #{selectTime} and #{now} order by a.id Limit #{limit1},#{limit2}
|
||||||
|
</select>
|
||||||
|
<select id="selectByHourDateCount" resultType="java.lang.Integer">
|
||||||
|
SELECT count(*) FROM hy_partner_user_info a LEFT join hy_partner_line_info b on
|
||||||
|
a.partner_id=b.partner_id left join enterprise_user c on b.investment_manager=c.user_id
|
||||||
|
WHERE a.create_time BETWEEN #{selectTime} and #{now} or
|
||||||
|
a.update_time BETWEEN #{selectTime} and #{now}
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||||
insert into hy_partner_user_info
|
insert into hy_partner_user_info
|
||||||
|
|||||||
@@ -7,6 +7,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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -17,6 +18,7 @@ import lombok.NoArgsConstructor;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class HyPartnerBaseInfoDO implements Serializable {
|
public class HyPartnerBaseInfoDO implements Serializable {
|
||||||
@ApiModelProperty("")
|
@ApiModelProperty("")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|||||||
@@ -7,6 +7,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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -17,6 +18,7 @@ import lombok.NoArgsConstructor;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class HyPartnerLineInfoDO implements Serializable {
|
public class HyPartnerLineInfoDO implements Serializable {
|
||||||
@ApiModelProperty("")
|
@ApiModelProperty("")
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -77,4 +79,7 @@ public class HyPartnerLineInfoDO implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty("移除黑名单原因")
|
@ApiModelProperty("移除黑名单原因")
|
||||||
private String removeBlackReason;
|
private String removeBlackReason;
|
||||||
|
|
||||||
|
@ApiModelProperty("hy_partner_user_channel.id")
|
||||||
|
private Integer userChannelId;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.cool.store.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.naming.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hy_partner_user_channel
|
||||||
|
* @author
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class HyPartnerUserChannelDO implements Serializable {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来源id
|
||||||
|
*/
|
||||||
|
private Long channelId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来源名称
|
||||||
|
*/
|
||||||
|
private String channelName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
@@ -7,6 +7,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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -17,6 +18,7 @@ import lombok.NoArgsConstructor;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class HyPartnerUserInfoDO implements Serializable {
|
public class HyPartnerUserInfoDO implements Serializable {
|
||||||
@ApiModelProperty("")
|
@ApiModelProperty("")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.cool.store.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class SyncEcCustomerDO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String customername;
|
||||||
|
|
||||||
|
private String customermobile;
|
||||||
|
|
||||||
|
private String followname;
|
||||||
|
|
||||||
|
private String followmobile;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.cool.store.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hxd
|
||||||
|
* @since 2023/2/28
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CustomerInfoRequest {
|
||||||
|
|
||||||
|
|
||||||
|
private Long crmId;
|
||||||
|
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String channel;
|
||||||
|
|
||||||
|
private String followUserMobile;
|
||||||
|
|
||||||
|
private Long lastFollowUserId;
|
||||||
|
|
||||||
|
private String followUserName;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.cool.store.http;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class UserSourceResponse {
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
private List<ChannelSource> data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public static class ChannelSource{
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Integer userId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package com.cool.store.job;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.cool.store.entity.SyncEcCustomerDO;
|
||||||
|
import com.cool.store.mapper.HyPartnerLineInfoMapper;
|
||||||
|
import com.cool.store.mapper.HyPartnerUserInfoMapper;
|
||||||
|
import com.cool.store.sdk.ec.EcClient;
|
||||||
|
import com.cool.store.sdk.ec.request.SyncEcCustomerRequest;
|
||||||
|
import com.cool.store.service.EcSyncService;
|
||||||
|
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.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class EcSyncDataJob {
|
||||||
|
|
||||||
|
@XxlJob("SyncUserSourceJob")
|
||||||
|
public void syncUserSourceJob() {
|
||||||
|
XxlJobHelper.log("-------------------------------定时同步客户来源开始-------------------------------");
|
||||||
|
syncUserSourceExecute();
|
||||||
|
XxlJobHelper.log("-------------------------------定时同步客户来源结束-------------------------------");
|
||||||
|
XxlJobHelper.handleSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${ec.baseUrl}")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
@XxlJob("SyncAppletToEcJob")
|
||||||
|
public void syncAppletToEcJob() {
|
||||||
|
XxlJobHelper.log("-------------------------------定时同步小程序数据到ec开始-------------------------------");
|
||||||
|
syncAppletToEcExecute();
|
||||||
|
XxlJobHelper.log("-------------------------------定时同步小程序数据到ec结束-------------------------------");
|
||||||
|
XxlJobHelper.handleSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EcSyncService ecSyncService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private HyPartnerUserInfoMapper hyPartnerUserInfoMapper;
|
||||||
|
|
||||||
|
|
||||||
|
//定时同步用户来源开始
|
||||||
|
private void syncUserSourceExecute() {
|
||||||
|
ecSyncService.getChannelSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Integer count=50;
|
||||||
|
|
||||||
|
//定时同步小程序数据到ec
|
||||||
|
private void syncAppletToEcExecute() {
|
||||||
|
//获取总数
|
||||||
|
int size = hyPartnerUserInfoMapper.selectByHourDateCount(getHourDayDate(-5, 0), DateUtil.now());
|
||||||
|
//执行数
|
||||||
|
int counts = size / count;
|
||||||
|
//取余,如果大于1,就再加一
|
||||||
|
int yu = size % count;
|
||||||
|
if (yu > 0) {
|
||||||
|
counts += 1;
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= counts; i++) {
|
||||||
|
List<SyncEcCustomerDO> list = hyPartnerUserInfoMapper.selectByHourDate(getHourDayDate(-5, 0), DateUtil.now(),count * (i - 1),count);
|
||||||
|
SyncEcCustomerRequest syncEcCustomerRequest = new SyncEcCustomerRequest();
|
||||||
|
syncEcCustomerRequest.setParameter(list);
|
||||||
|
EcClient ecClient = new EcClient();
|
||||||
|
ecClient.exec(baseUrl,syncEcCustomerRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String getHourDayDate(int hour, int day) {
|
||||||
|
Date today = new Date();
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(today);
|
||||||
|
calendar.add(Calendar.HOUR, hour);
|
||||||
|
calendar.add(Calendar.DAY_OF_MONTH, day);
|
||||||
|
Date twoDay = calendar.getTime();
|
||||||
|
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(twoDay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.cool.store.sdk.ec;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.cool.store.sdk.ec.core.EcRequest;
|
||||||
|
import com.cool.store.sdk.ec.core.EcResponse;
|
||||||
|
import com.cool.store.utils.Get;
|
||||||
|
import com.cool.store.utils.MapUtil;
|
||||||
|
import com.cool.store.utils.Post;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class EcClient {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public <T extends EcResponse> T exec(String baseUrl,EcRequest<T> request) {
|
||||||
|
String apiUrl = request.getApiUrl();
|
||||||
|
// if (accessToken != null) {
|
||||||
|
// apiUrl += "?token=" + accessToken;
|
||||||
|
// }
|
||||||
|
String method = request.getMethod();
|
||||||
|
String result = "";
|
||||||
|
if (method.equals("GET")) {
|
||||||
|
result = Get.send(baseUrl+apiUrl, MapUtil.entityToUrlParam(request.getParameter()));
|
||||||
|
} else {
|
||||||
|
HashMap<String,String> headers = new HashMap<>(1);
|
||||||
|
headers.put("Content-Type", "application/json");
|
||||||
|
result = Post.send(baseUrl+apiUrl, JSON.toJSONString(request.getParameter()), headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSON.parseObject(result, request.getResponseClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.cool.store.sdk.ec.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hxd
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class ChangeFollowUserBo {
|
||||||
|
|
||||||
|
//跟进人
|
||||||
|
private Long crmId;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
private Long followUserId;
|
||||||
|
|
||||||
|
//1:更新跟进人 2:创建跟进人并更改跟进人
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.cool.store.sdk.ec.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class SyncEcCustomerBo {
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.cool.store.sdk.ec.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class UpdateCustomerBo {
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
private Long crmId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.cool.store.sdk.ec.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hxd
|
||||||
|
*/
|
||||||
|
abstract public class EcRequest <T extends EcResponse> implements EcRequestI<T> {
|
||||||
|
|
||||||
|
private Object parameter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethod() {
|
||||||
|
return "POST";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getParameter() {
|
||||||
|
return parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameter(Object parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<T> getResponseClass() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.cool.store.sdk.ec.core;
|
||||||
|
|
||||||
|
public interface EcRequestI<T extends EcResponse> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址
|
||||||
|
* @return -
|
||||||
|
*/
|
||||||
|
String getApiUrl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方法
|
||||||
|
* @return -
|
||||||
|
*/
|
||||||
|
String getMethod();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置参数
|
||||||
|
* @return -
|
||||||
|
*/
|
||||||
|
Object getParameter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应类类型
|
||||||
|
* @return -
|
||||||
|
*/
|
||||||
|
Class<T> getResponseClass();
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.cool.store.sdk.ec.core;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EcResponse {
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.cool.store.sdk.ec.request;
|
||||||
|
|
||||||
|
import com.cool.store.sdk.ec.core.EcRequest;
|
||||||
|
import com.cool.store.sdk.ec.response.ChangeFollowUserResponse;
|
||||||
|
|
||||||
|
public class ChangeFollowUserRequest extends EcRequest<ChangeFollowUserResponse> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getApiUrl() {
|
||||||
|
return "/ec/selectChangeUser";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ChangeFollowUserResponse> getResponseClass() {
|
||||||
|
return ChangeFollowUserResponse.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.cool.store.sdk.ec.request;
|
||||||
|
|
||||||
|
import com.cool.store.sdk.ec.core.EcRequest;
|
||||||
|
import com.cool.store.sdk.ec.response.SyncEcCustomerResponse;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hxd
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class SyncEcCustomerRequest extends EcRequest<SyncEcCustomerResponse> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getApiUrl() {
|
||||||
|
return "/ec/appletToEc";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<SyncEcCustomerResponse> getResponseClass() {
|
||||||
|
return SyncEcCustomerResponse.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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.UpdateCustomerResponse;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class UpdateCustomerRequest extends EcRequest<UpdateCustomerResponse> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getApiUrl() {
|
||||||
|
return "/ec/updateCustomer";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<UpdateCustomerResponse> getResponseClass() {
|
||||||
|
return UpdateCustomerResponse.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.cool.store.sdk.ec.response;
|
||||||
|
|
||||||
|
import com.cool.store.sdk.ec.core.EcResponse;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hxd
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class ChangeFollowUserResponse extends EcResponse {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.cool.store.sdk.ec.response;
|
||||||
|
|
||||||
|
import com.cool.store.sdk.ec.core.EcResponse;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hxd
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class SyncEcCustomerResponse extends EcResponse {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.cool.store.sdk.ec.response;
|
||||||
|
|
||||||
|
import com.cool.store.sdk.ec.core.EcResponse;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hxd
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class UpdateCustomerResponse extends EcResponse {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.cool.store.service;
|
||||||
|
|
||||||
|
import com.cool.store.request.CustomerInfoRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface EcSyncService {
|
||||||
|
boolean ecToApplet(List<CustomerInfoRequest> queryListData);
|
||||||
|
|
||||||
|
void getChannelSource();
|
||||||
|
}
|
||||||
@@ -0,0 +1,278 @@
|
|||||||
|
package com.cool.store.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.cool.store.dao.EnterpriseUserDAO;
|
||||||
|
import com.cool.store.dao.HyPartnerBaseInfoDAO;
|
||||||
|
import com.cool.store.dao.HyPartnerLineInfoDAO;
|
||||||
|
import com.cool.store.dao.HyPartnerUserInfoDAO;
|
||||||
|
import com.cool.store.entity.*;
|
||||||
|
import com.cool.store.enums.LineStatusEnum;
|
||||||
|
import com.cool.store.enums.WorkflowStageEnum;
|
||||||
|
import com.cool.store.enums.WorkflowStatusEnum;
|
||||||
|
import com.cool.store.exception.ApiException;
|
||||||
|
import com.cool.store.http.UserSourceResponse;
|
||||||
|
import com.cool.store.mapper.HyPartnerUserChannelMapper;
|
||||||
|
import com.cool.store.request.CustomerInfoRequest;
|
||||||
|
import com.cool.store.sdk.ec.EcClient;
|
||||||
|
import com.cool.store.sdk.ec.bo.ChangeFollowUserBo;
|
||||||
|
import com.cool.store.sdk.ec.bo.UpdateCustomerBo;
|
||||||
|
import com.cool.store.sdk.ec.request.ChangeFollowUserRequest;
|
||||||
|
import com.cool.store.sdk.ec.request.UpdateCustomerRequest;
|
||||||
|
import com.cool.store.sdk.ec.response.ChangeFollowUserResponse;
|
||||||
|
import com.cool.store.sdk.ec.response.UpdateCustomerResponse;
|
||||||
|
import com.cool.store.service.EcSyncService;
|
||||||
|
import com.cool.store.utils.Post;
|
||||||
|
import com.cool.store.utils.StringUtil;
|
||||||
|
import com.cool.store.utils.UUIDUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class EcSyncServiceImpl implements EcSyncService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${ec.baseUrl}")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private HyPartnerLineInfoDAO hyPartnerLineInfoDAO;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private HyPartnerBaseInfoDAO hyPartnerBaseInfoDAO;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private HyPartnerUserInfoDAO hyPartnerUserInfoDAO;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseUserDAO enterpriseUserDAO;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private HyPartnerUserChannelMapper hyPartnerUserChannelMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean ecToApplet(List<CustomerInfoRequest> queryListData) {
|
||||||
|
for (CustomerInfoRequest customerInfoItem : queryListData) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(500L);
|
||||||
|
insertSelectiveSync(customerInfoItem);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
sendFeiShuRobotMessage("推送:"+JSONObject.toJSONString(e),"27243d49-97ca-4981-8aec-7c3bf84eb660");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getChannelSource() {
|
||||||
|
String s = HttpUtil.get(baseUrl+"/ec/getChannelSource");
|
||||||
|
UserSourceResponse userSourceResponse = JSONObject.parseObject(s, UserSourceResponse.class);
|
||||||
|
for (UserSourceResponse.ChannelSource channelSource : userSourceResponse.getData()) {
|
||||||
|
Long id = channelSource.getId();
|
||||||
|
HyPartnerUserChannelDO selectByChannel = hyPartnerUserChannelMapper.selectByChannelId(id);
|
||||||
|
HyPartnerUserChannelDO hyPartnerUserChannel = new HyPartnerUserChannelDO();
|
||||||
|
hyPartnerUserChannel.setChannelId(channelSource.getId()).setChannelName(channelSource.getName());
|
||||||
|
//有就更新 没有插入
|
||||||
|
if (ObjectUtil.isNotNull(selectByChannel)) {
|
||||||
|
hyPartnerUserChannel.setUpdateTime(new Date()).setId(selectByChannel.getId());
|
||||||
|
hyPartnerUserChannelMapper.updateByPrimaryKeySelective(hyPartnerUserChannel);
|
||||||
|
}else {
|
||||||
|
hyPartnerUserChannel.setCreateTime(new Date());
|
||||||
|
hyPartnerUserChannelMapper.insertSelective(hyPartnerUserChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步ec数据到表中 同时将部分数据同步到ec
|
||||||
|
*
|
||||||
|
* @param customerInfoItem
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void insertSelectiveSync(CustomerInfoRequest customerInfoItem) throws ApiException {
|
||||||
|
if (StringUtil.isNotEmpty(customerInfoItem.getMobile())) {
|
||||||
|
customerInfoItem.setMobile(customerInfoItem.getMobile().split(" ")[1]);
|
||||||
|
}
|
||||||
|
//获取客户来源id
|
||||||
|
String channel = customerInfoItem.getChannel();
|
||||||
|
HyPartnerUserChannelDO hyPartnerUserChannelDO = hyPartnerUserChannelMapper.selectByChannelName(channel);
|
||||||
|
Long channelId =null;
|
||||||
|
if (StringUtil.isNotEmpty(channel)) {
|
||||||
|
if (ObjectUtil.isNull(hyPartnerUserChannelDO)||ObjectUtil.isNull(hyPartnerUserChannelDO.getId())) {
|
||||||
|
getChannelSource();
|
||||||
|
HyPartnerUserChannelDO channelDO = hyPartnerUserChannelMapper.selectByChannelName(channel);
|
||||||
|
channelId=channelDO.getId();
|
||||||
|
}else {
|
||||||
|
HyPartnerUserChannelDO channelDO = hyPartnerUserChannelMapper.selectByChannelName(channel);
|
||||||
|
channelId=channelDO.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String newPartnerId = UUIDUtils.get32UUID();
|
||||||
|
HyPartnerUserInfoDO resultUser = new HyPartnerUserInfoDO();
|
||||||
|
resultUser.setUsername(customerInfoItem.getName()).setMobile(customerInfoItem.getMobile());
|
||||||
|
|
||||||
|
HyPartnerLineInfoDO resultLine = new HyPartnerLineInfoDO();
|
||||||
|
String followUserName = customerInfoItem.getFollowUserName();
|
||||||
|
String followUserMobile = customerInfoItem.getFollowUserMobile();
|
||||||
|
//传递过来有跟进人的情况下查询跟进人是否存在
|
||||||
|
if (StringUtil.isNotEmpty(followUserMobile)&&StringUtil.isNotEmpty(followUserMobile)) {
|
||||||
|
String userId = enterpriseUserDAO.selectByMobile("+86"+followUserMobile);
|
||||||
|
if (StringUtil.isEmpty(userId)) {
|
||||||
|
// 给飞书群发送消息 跟进人找不到
|
||||||
|
sendFeiShuRobotMessage("推送:飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile,"27243d49-97ca-4981-8aec-7c3bf84eb660");
|
||||||
|
throw new ApiException("飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile);
|
||||||
|
}
|
||||||
|
resultLine.setInvestmentManager(userId);
|
||||||
|
}
|
||||||
|
resultLine.setWorkflowStage(WorkflowStageEnum.INTENT.getCode()).setUserChannelId(Convert.toInt(channelId))
|
||||||
|
.setLineStatus(StringUtil.isEmpty(customerInfoItem.getFollowUserName()) ? LineStatusEnum.PUBLIC_SEAS.getCode() : LineStatusEnum.PRIVATE_SEAS.getCode());
|
||||||
|
|
||||||
|
HyPartnerBaseInfoDO resultBase = new HyPartnerBaseInfoDO();
|
||||||
|
resultBase.setUsername(customerInfoItem.getName()).setMobile(customerInfoItem.getMobile());
|
||||||
|
|
||||||
|
HyPartnerUserInfoDO newUserInfo = hyPartnerUserInfoDAO.selectByMobile(resultUser.getMobile());
|
||||||
|
EcClient ecClient=new EcClient();
|
||||||
|
//有就更新ec没有就插入
|
||||||
|
if (newUserInfo != null) {
|
||||||
|
// EC与沪姨合伙人同时存在的线索用户,但用户姓名不同,将沪姨合伙人线索姓名同步至EC覆盖原EC线索姓名
|
||||||
|
if (!newUserInfo.getUsername().equals(resultUser.getUsername())) {
|
||||||
|
UpdateCustomerRequest updateUserRequest=new UpdateCustomerRequest();
|
||||||
|
UpdateCustomerBo updateCustomerBo = new UpdateCustomerBo();
|
||||||
|
updateCustomerBo.setUsername(newUserInfo.getUsername()).setMobile(newUserInfo.getMobile()).setCrmId(customerInfoItem.getCrmId());
|
||||||
|
updateUserRequest.setParameter(updateCustomerBo);
|
||||||
|
UpdateCustomerResponse updateUserExec = ecClient.exec(baseUrl,updateUserRequest);
|
||||||
|
}
|
||||||
|
String oldPartnerId = newUserInfo.getPartnerId();
|
||||||
|
//线索表
|
||||||
|
HyPartnerLineInfoDO partnerLine = hyPartnerLineInfoDAO.getByPartnerId(oldPartnerId);
|
||||||
|
if (partnerLine != null) {
|
||||||
|
// EC与沪姨合伙人同时存在的线索用户,但存在不同的跟进人,将沪姨合伙人跟进人信息同步至EC覆盖原EC跟进人信息
|
||||||
|
if (StringUtil.isEmpty(partnerLine.getInvestmentManager())) {
|
||||||
|
if (StringUtil.isNotEmpty(resultLine.getInvestmentManager())) {
|
||||||
|
resultLine.setId(partnerLine.getId()).setUpdateTime(new Date());
|
||||||
|
hyPartnerLineInfoDAO.updateByPrimaryKeySelective(resultLine);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
EnterpriseUserDO enterpriseUser = enterpriseUserDAO.getUserInfoById(partnerLine.getInvestmentManager());
|
||||||
|
enterpriseUser.setMobile(getNoWith86Number(enterpriseUser.getMobile()));
|
||||||
|
//电话相同但是名字不同
|
||||||
|
if (enterpriseUser.getMobile().equals(followUserMobile) && !enterpriseUser.getName().equals(followUserName)) {
|
||||||
|
ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest();
|
||||||
|
ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo();
|
||||||
|
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
|
||||||
|
.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();
|
||||||
|
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
|
||||||
|
.setType(2).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
|
||||||
|
changeFollowUserRequest.setParameter(changeFollowUserBo);
|
||||||
|
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl,changeFollowUserRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//base表
|
||||||
|
HyPartnerBaseInfoDO partnerIdAndLine = hyPartnerBaseInfoDAO.getByPartnerIdAndLineId(partnerLine.getPartnerId(), partnerLine.getId());
|
||||||
|
if (partnerIdAndLine == null) {
|
||||||
|
resultBase.setPartnerId(newPartnerId).setPartnerLineId(partnerLine.getId()).setStatus(Integer.valueOf(WorkflowStatusEnum.INTENT_0.getCode())).
|
||||||
|
setCreateTime(new Date());
|
||||||
|
hyPartnerBaseInfoDAO.insertSelective(resultBase);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resultLine.setPartnerId(newPartnerId).setCreateTime(new Date());
|
||||||
|
hyPartnerLineInfoDAO.insertSelective(resultLine);
|
||||||
|
|
||||||
|
resultBase.setPartnerId(newPartnerId).setPartnerLineId(resultLine.getId()).setStatus(Integer.valueOf(WorkflowStatusEnum.INTENT_0.getCode())).
|
||||||
|
setCreateTime(new Date());
|
||||||
|
hyPartnerBaseInfoDAO.insertSelective(resultBase);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resultUser.setPartnerId(newPartnerId).setCreateTime(new Date());
|
||||||
|
hyPartnerUserInfoDAO.insertSelective(resultUser);
|
||||||
|
|
||||||
|
resultLine.setPartnerId(newPartnerId).setCreateTime(new Date());
|
||||||
|
hyPartnerLineInfoDAO.insertSelective(resultLine);
|
||||||
|
|
||||||
|
resultBase.setPartnerId(newPartnerId).setPartnerLineId(resultLine.getId()).setStatus(Integer.valueOf(WorkflowStatusEnum.INTENT_0.getCode())).
|
||||||
|
setCreateTime(new Date());
|
||||||
|
hyPartnerBaseInfoDAO.insertSelective(resultBase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到不带86开头的号码
|
||||||
|
*
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getNoWith86Number(String number) {
|
||||||
|
String regular = number;
|
||||||
|
if (StringUtils.isNotBlank(regular)) {
|
||||||
|
// 去掉+号
|
||||||
|
while (regular.startsWith("+")) {
|
||||||
|
regular = regular.substring(1);
|
||||||
|
}
|
||||||
|
// 号码以0开始,去掉前缀
|
||||||
|
while (regular.startsWith("0")) {
|
||||||
|
regular = regular.substring(1);
|
||||||
|
}
|
||||||
|
// 号码以86开始,去掉前缀
|
||||||
|
while (regular.startsWith("86")) {
|
||||||
|
regular = regular.substring(2);
|
||||||
|
}
|
||||||
|
// 号码以0开始,去掉前缀
|
||||||
|
while (regular.startsWith("0")) {
|
||||||
|
regular = regular.substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return regular;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送飞书机器人
|
||||||
|
*
|
||||||
|
* @param text
|
||||||
|
* @param token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String sendFeiShuRobotMessage(String text, String token) {
|
||||||
|
HashMap<String, Object> map = new HashMap<>(4);
|
||||||
|
HashMap<String, String> textMap = new HashMap<String, String>(4);
|
||||||
|
textMap.put("text", text);
|
||||||
|
map.put("content", textMap);
|
||||||
|
map.put("msg_type", "text");
|
||||||
|
String body = JSON.toJSONString(map);
|
||||||
|
String send = "";
|
||||||
|
try {
|
||||||
|
send = Post.send("https://open.feishu.cn/open-apis/bot/v2/hook/" + token, body, new HashMap<String, String>(4) {{
|
||||||
|
put("Content-Type", "application/json");
|
||||||
|
}});
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return send;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
package com.cool.store.utils;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author leoxie
|
||||||
|
*/
|
||||||
|
public class Client {
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
private String method = "POST";
|
||||||
|
private HashMap<String,String> header;
|
||||||
|
private String data;
|
||||||
|
private Integer timeout = 8000;
|
||||||
|
private Integer maxLength = 10000;
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(Client.class);
|
||||||
|
|
||||||
|
public String exec() throws IOException {
|
||||||
|
|
||||||
|
HttpURLConnection connection = null;
|
||||||
|
OutputStreamWriter out = null;
|
||||||
|
BufferedReader reader = null;
|
||||||
|
StringBuilder res = null;
|
||||||
|
String result = null;
|
||||||
|
Long optTime = 0L;
|
||||||
|
InputStream is = null;
|
||||||
|
|
||||||
|
LocalDateTime beginTime = LocalDateTime.now();
|
||||||
|
|
||||||
|
URL url = new URL(getUrl());
|
||||||
|
connection = (HttpURLConnection) url.openConnection();
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setDoInput(true);
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setInstanceFollowRedirects(true);
|
||||||
|
|
||||||
|
//设置超时时间
|
||||||
|
connection.setConnectTimeout(getTimeout());
|
||||||
|
connection.setReadTimeout(getTimeout());
|
||||||
|
|
||||||
|
// 设置请求方式
|
||||||
|
connection.setRequestMethod(getMethod());
|
||||||
|
// 设置发送数据的格式
|
||||||
|
if (!getHeader().isEmpty()) {
|
||||||
|
for (Map.Entry<String, String> entry : getHeader().entrySet()) {
|
||||||
|
connection.setRequestProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//发起连接
|
||||||
|
connection.connect();
|
||||||
|
|
||||||
|
// utf-8编码[推送提交的参数]
|
||||||
|
if (!getData().isEmpty()) {
|
||||||
|
out = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
|
||||||
|
out.append(getData());
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(connection.getResponseCode() > 2000){
|
||||||
|
is = connection.getErrorStream();
|
||||||
|
}else{
|
||||||
|
is = connection.getInputStream();
|
||||||
|
}
|
||||||
|
// 读取响应
|
||||||
|
reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||||
|
String line;
|
||||||
|
res = new StringBuilder();
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
res.append(line);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
result = res.toString();
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
throw e;
|
||||||
|
}finally {
|
||||||
|
if (connection != null){
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(out != null){
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reader != null){
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// log.info("request url is : " + getUrl());
|
||||||
|
// log.info("request params is : " + getData());
|
||||||
|
// if(result != null && result.length() < maxLength) {
|
||||||
|
// log.info("response : " + result);
|
||||||
|
// }
|
||||||
|
// optTime = Duration.between(beginTime,LocalDateTime.now()).toMillis();
|
||||||
|
// log.info("response time: " + optTime.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
assert !url.isEmpty();
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethod() {
|
||||||
|
assert !method.isEmpty();
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethod(String method) {
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, String> getHeader() {
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeader(HashMap<String, String> header) {
|
||||||
|
this.header = header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交参数
|
||||||
|
*
|
||||||
|
* 如果是json形式,那么就是json字符串,
|
||||||
|
* 如果是表单形式,就是name1=value1&name2=value2 的形式
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
public void setData(String data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTimeout() {
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeout(Integer timeout) {
|
||||||
|
this.timeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package com.cool.store.utils;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author leoxie
|
||||||
|
*/
|
||||||
|
public class Get {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(Get.class);
|
||||||
|
|
||||||
|
private static final Integer connectTimeout = 1000;
|
||||||
|
private static final Integer timeout = 5000;
|
||||||
|
|
||||||
|
public static String send(String url, String param) throws IOException {
|
||||||
|
return send(url,param,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向指定URL发送GET方法的请求
|
||||||
|
*
|
||||||
|
* @param url 发送请求的URL
|
||||||
|
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
||||||
|
* @return URL 所代表远程资源的响应结果
|
||||||
|
*/
|
||||||
|
public static String send(String url, String param,boolean hasLog) throws IOException {
|
||||||
|
return send(url, param, hasLog, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String send(String url, String param, boolean hasLog, HashMap<String,String> headers) throws IOException {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
BufferedReader reader = null;
|
||||||
|
HttpURLConnection connection = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
String urlNameString = url + (param.isEmpty()?"":"?" + param);
|
||||||
|
|
||||||
|
log.info("url:"+url);
|
||||||
|
log.info("param:"+param);
|
||||||
|
|
||||||
|
URL realUrl = new URL(urlNameString);
|
||||||
|
// 打开和URL之间的连接
|
||||||
|
connection = (HttpURLConnection)realUrl.openConnection();
|
||||||
|
// 设置通用的请求属性
|
||||||
|
connection.setRequestProperty("accept", "*/*");
|
||||||
|
connection.setRequestProperty("connection", "Keep-Alive");
|
||||||
|
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||||
|
|
||||||
|
//添加头部信息
|
||||||
|
if(headers != null && !headers.isEmpty()){
|
||||||
|
for (Map.Entry<String,String> entry:headers.entrySet()) {
|
||||||
|
connection.setRequestProperty(entry.getKey(),entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.setConnectTimeout(connectTimeout);
|
||||||
|
connection.setReadTimeout(timeout);
|
||||||
|
// 建立实际的连接
|
||||||
|
connection.connect();
|
||||||
|
|
||||||
|
// 获取所有响应头字段
|
||||||
|
Map<String, List<String>> responseHeader = connection.getHeaderFields();
|
||||||
|
// 遍历所有的响应头字段
|
||||||
|
if(hasLog) {
|
||||||
|
log.info("响应头");
|
||||||
|
for (String key : responseHeader.keySet()) {
|
||||||
|
log.info(key + "--->" + responseHeader.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 BufferedReader输入流来读取URL的响应
|
||||||
|
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
result.append(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasLog) {
|
||||||
|
log.info("响应结果:" + result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
} finally {
|
||||||
|
if (connection != null){
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reader != null) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
package com.cool.store.utils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class MapUtil {
|
||||||
|
public static <T> void setMapValue(Map<String, Object> hashMap, String name, T value) {
|
||||||
|
if (value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hashMap.put(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> void setMapObjectValue(Map<String, Object> hashMap, T obj) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||||
|
if (obj == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Field[] fields = obj.getClass().getDeclaredFields();
|
||||||
|
for (Field field : fields) {
|
||||||
|
String name = field.getName();
|
||||||
|
String uName = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||||
|
|
||||||
|
Method m = obj.getClass().getMethod("get" + uName);
|
||||||
|
Object value = m.invoke(obj);
|
||||||
|
if (value == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 基础类型
|
||||||
|
if (isBaseType(value)) {
|
||||||
|
setMapValue(hashMap, name, value);
|
||||||
|
} else if (value instanceof List) {
|
||||||
|
if (((List) value).size() > 0) {
|
||||||
|
setMapObjectValue(hashMap, ((List) value).get(0));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setMapObjectValue(hashMap, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isBaseType(Object object) {
|
||||||
|
Class className = object.getClass();
|
||||||
|
return className.equals(Integer.class) ||
|
||||||
|
className.equals(Byte.class) ||
|
||||||
|
className.equals(Long.class) ||
|
||||||
|
className.equals(Double.class) ||
|
||||||
|
className.equals(Float.class) ||
|
||||||
|
className.equals(Character.class) ||
|
||||||
|
className.equals(Short.class) ||
|
||||||
|
className.equals(Boolean.class) ||
|
||||||
|
className.equals(String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实体类对象转URL参
|
||||||
|
* @param t 实体类对象
|
||||||
|
* @param callSuper 是否转换父类成员
|
||||||
|
* @param <T> 实体类泛型
|
||||||
|
* @return a=1&b=2
|
||||||
|
*/
|
||||||
|
public static <T> String entityToUrlParam(T t, boolean callSuper){
|
||||||
|
// URL 参数存储器
|
||||||
|
StringBuffer urlParam = new StringBuffer();
|
||||||
|
//扩展转换父类成员功能
|
||||||
|
entitySuperclassToUrlParam(t, t.getClass(),callSuper,urlParam);
|
||||||
|
if(urlParam.length()>0){
|
||||||
|
//去除最后一个&字符
|
||||||
|
urlParam.deleteCharAt(urlParam.length() - 1);
|
||||||
|
}
|
||||||
|
return urlParam.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> String entityToUrlParam(T t) {
|
||||||
|
if (t == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return entityToUrlParam(t, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实体类对象转URL参
|
||||||
|
* @param t 实体类对象
|
||||||
|
* @param clazz 实体类类型
|
||||||
|
* @param callSuper 是否转换父类成员
|
||||||
|
* @param urlParam URL 参数存储器
|
||||||
|
* @param <T> 实体类泛型
|
||||||
|
* @return a=1&b=2
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> void entitySuperclassToUrlParam(T t,Class clazz,boolean callSuper,StringBuffer urlParam){
|
||||||
|
//如果实体类对象为Object类型,则不处理
|
||||||
|
if(!clazz.equals(Object.class)) {
|
||||||
|
//获取实体类对象下的所有成员,并保存到 URL 参数存储器中
|
||||||
|
Arrays.stream(clazz.getDeclaredFields()).forEach(field -> {
|
||||||
|
//设置可以操作私有成员
|
||||||
|
field.setAccessible(true);
|
||||||
|
try {
|
||||||
|
//获取成员值
|
||||||
|
Object value = field.get(t);
|
||||||
|
//成员值为 Null 时,则不处理
|
||||||
|
if (Objects.nonNull(value)) {
|
||||||
|
urlParam.append(field.getName()).append("=").append(value).append("&");
|
||||||
|
}
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//是否转换父类成员
|
||||||
|
if(callSuper){
|
||||||
|
//获取父类类型
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
|
//递归调用,获取父类的处理结果
|
||||||
|
entitySuperclassToUrlParam(t,clazz,callSuper,urlParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.cool.store.utils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author leoxie
|
||||||
|
*/
|
||||||
|
public class Post {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向指定 URL 发送POST方法的请求
|
||||||
|
* @param url 发送请求的 URL
|
||||||
|
* @param data 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
||||||
|
* @return 所代表远程资源的响应结果
|
||||||
|
*/
|
||||||
|
public static String send(String url, String data,HashMap<String,String> headers) throws IOException {
|
||||||
|
Client client = new Client();
|
||||||
|
client.setData(data);
|
||||||
|
client.setUrl(url);
|
||||||
|
|
||||||
|
HashMap<String, String> headerMap = new HashMap<>(16);
|
||||||
|
headerMap.put("Content-Type","application/x-www-form-urlencoded");
|
||||||
|
|
||||||
|
//添加头部信息
|
||||||
|
if(!headers.isEmpty()){
|
||||||
|
for (Map.Entry<String,String> entry:headers.entrySet()) {
|
||||||
|
headerMap.put(entry.getKey(),entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
client.setHeader(headerMap);
|
||||||
|
|
||||||
|
return client.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -48,7 +48,7 @@ public class TokenValidateFilter implements Filter {
|
|||||||
//腾讯音视频回调,单独做验签
|
//腾讯音视频回调,单独做验签
|
||||||
"/partner/pc/video/**",
|
"/partner/pc/video/**",
|
||||||
//TODO 800回调地址暂时不做验证
|
//TODO 800回调地址暂时不做验证
|
||||||
"/partner/pc/flow/qualificationReview/callback");
|
"/partner/pc/flow/qualificationReview/callback","/**/ecSync/ecToApplet/**");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,13 +84,13 @@ public class TokenValidateFilter implements Filter {
|
|||||||
boolean isInWhiteList = excludePath(uri);
|
boolean isInWhiteList = excludePath(uri);
|
||||||
String accessToken = reqs.getHeader("accessToken");
|
String accessToken = reqs.getHeader("accessToken");
|
||||||
String key = "access_token:" + accessToken;
|
String key = "access_token:" + accessToken;
|
||||||
log.info("url:{}", uri);
|
|
||||||
if(StringUtils.isNotBlank(accessToken)){
|
if(StringUtils.isNotBlank(accessToken)){
|
||||||
userStr = redisUtilPool.getString(key);
|
userStr = redisUtilPool.getString(key);
|
||||||
if(StringUtils.isNotBlank(userStr)){
|
if(StringUtils.isNotBlank(userStr)){
|
||||||
currentUser = JSON.parseObject(userStr, LoginUserInfo.class);
|
currentUser = JSON.parseObject(userStr, LoginUserInfo.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("url:{}", uri);
|
||||||
if ( !isInWhiteList && !method.equals("OPTIONS")) {
|
if ( !isInWhiteList && !method.equals("OPTIONS")) {
|
||||||
if (StringUtils.isEmpty(accessToken)) {
|
if (StringUtils.isEmpty(accessToken)) {
|
||||||
response.setStatus(HttpStatus.OK.value());
|
response.setStatus(HttpStatus.OK.value());
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.cool.store.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.cool.store.request.CustomerInfoRequest;
|
||||||
|
import com.cool.store.response.ResponseResult;
|
||||||
|
import com.cool.store.service.EcSyncService;
|
||||||
|
import com.cool.store.vo.InterviewScheduleInfoVO;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ecSync")
|
||||||
|
@Slf4j
|
||||||
|
public class EcSyncController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EcSyncService ecSyncService;
|
||||||
|
|
||||||
|
@PostMapping(path = "/ecToApplet")
|
||||||
|
@ApiOperation("ec同步数据到小程序")
|
||||||
|
public ResponseResult<Boolean> ecToApplet(@RequestBody List<CustomerInfoRequest> queryListData){
|
||||||
|
return ResponseResult.success(ecSyncService.ecToApplet(queryListData));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user