c端用户

This commit is contained in:
wangxiaopeng
2024-03-20 20:47:11 +08:00
parent b07be9cde8
commit cab0b90e38
8 changed files with 255 additions and 12 deletions

View File

@@ -0,0 +1,37 @@
package com.cool.store.dao;
import com.cool.store.entity.HyPartnerUserChannelDO;
import com.cool.store.mapper.HyPartnerUserChannelMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author suzhuhong
* @Date 2023/8/21 11:38
* @Version 1.0
*/
@Repository
public class HyPartnerUserChannelDAO {
@Resource
HyPartnerUserChannelMapper hyPartnerUserChannelMapper;
public Map<Integer, String> getChannelMapByIds(List<Integer> userChannelIds){
if (CollectionUtils.isEmpty(userChannelIds)){
return new HashMap<>(1);
}
List<HyPartnerUserChannelDO> userChannelList = hyPartnerUserChannelMapper.getUserChannelByIds(userChannelIds);
Map<Integer, String> channelMap = userChannelList.stream().filter(date->date.getChannelId()!=null).collect(Collectors.toMap(x->x.getChannelId().intValue(), HyPartnerUserChannelDO::getChannelName));
return channelMap;
}
}

View File

@@ -0,0 +1,34 @@
package com.cool.store.mapper;
import com.cool.store.entity.HyPartnerUserChannelDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@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);
List<HyPartnerUserChannelDO> getAllUserChannel();
List<HyPartnerUserChannelDO> getUserChannelByIds(List<Integer> userChannelIds);
HyPartnerUserChannelDO selectByChannel(@Param("channelId") Long channelId,@Param("channelName") String channelName);
}

View File

@@ -0,0 +1,114 @@
<?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 xfsg_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 xfsg_partner_user_channel
where channel_id = #{channelId} limit 1
</select>
<select id="selectByChannelName" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xfsg_partner_user_channel
where channel_name = #{channelName} limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from xfsg_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 xfsg_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 xfsg_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 xfsg_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 xfsg_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>
<select id="getAllUserChannel" resultMap="BaseResultMap">
select * from xfsg_partner_user_channel
</select>
<select id="getUserChannelByIds" resultMap="BaseResultMap">
select * from xfsg_partner_user_channel
<where>
<if test="userChannelIds!=null and userChannelIds.size>0">
<foreach collection="userChannelIds" item="userChannelId" open="channel_id in (" close=")" separator=",">
#{userChannelId}
</foreach>
</if>
</where>
</select>
<select id="selectByChannel" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xfsg_partner_user_channel
where channel_id = #{channelId} and channel_name=#{channelName} limit 1
</select>
</mapper>

View File

@@ -31,28 +31,28 @@
<select id="selectByPartnerId" resultMap="BaseResultMap" > <select id="selectByPartnerId" resultMap="BaseResultMap" >
select select
<include refid="Base_Column_List"></include> <include refid="Base_Column_List"></include>
from hy_partner_user_info from xfsg_partner_user_info
where partner_id = #{partnerId} where partner_id = #{partnerId}
</select> </select>
<select id="selectByMobile" resultMap="BaseResultMap" > <select id="selectByMobile" resultMap="BaseResultMap" >
select select
<include refid="Base_Column_List"></include> <include refid="Base_Column_List"></include>
from hy_partner_user_info from xfsg_partner_user_info
where mobile = #{mobile} where mobile = #{mobile}
</select> </select>
<select id="selectByOpenid" resultMap="BaseResultMap" > <select id="selectByOpenid" resultMap="BaseResultMap" >
select select
<include refid="Base_Column_List"></include> <include refid="Base_Column_List"></include>
from hy_partner_user_info from xfsg_partner_user_info
where openid = #{openid} where openid = #{openid}
</select> </select>
<select id="selectByPartnerIds" resultMap="BaseResultMap" > <select id="selectByPartnerIds" resultMap="BaseResultMap" >
select select
<include refid="Base_Column_List"></include> <include refid="Base_Column_List"></include>
from hy_partner_user_info from xfsg_partner_user_info
<where> <where>
<if test="partnerIdList!=null and partnerIdList.size>0"> <if test="partnerIdList!=null and partnerIdList.size>0">
<foreach collection="partnerIdList" open="and partner_id in (" close=")" separator="," item="partnerId"> <foreach collection="partnerIdList" open="and partner_id in (" close=")" separator="," item="partnerId">
@@ -67,7 +67,7 @@
count(*) count(*)
FROM FROM
hy_partner_line_info a hy_partner_line_info a
LEFT JOIN hy_partner_user_info b ON a.partner_id = b.partner_id LEFT JOIN xfsg_partner_user_info b ON a.partner_id = b.partner_id
AND a.deleted = 0 AND a.deleted = 0
LEFT JOIN hy_partner_user_channel c ON b.user_channel_id = c.channel_id LEFT JOIN hy_partner_user_channel c ON b.user_channel_id = c.channel_id
LEFT JOIN enterprise_user d ON a.investment_manager = d.user_id LEFT JOIN enterprise_user d ON a.investment_manager = d.user_id
@@ -88,11 +88,11 @@
a.update_time BETWEEN #{selectTime} and #{now} ) and b.partner_id is not null a.update_time BETWEEN #{selectTime} and #{now} ) and b.partner_id is not null
</select> </select>
<select id="selectLastCrmCreateTime" resultType="java.lang.String"> <select id="selectLastCrmCreateTime" resultType="java.lang.String">
SELECT crm_create_time as crmCreateTime FROM hy_partner_user_info ORDER BY crm_create_time desc limit 1 SELECT crm_create_time as crmCreateTime FROM xfsg_partner_user_info ORDER BY crm_create_time desc limit 1
</select> </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 xfsg_partner_user_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.partnerId != null"> <if test="record.partnerId != null">
partner_id, partner_id,
@@ -219,7 +219,7 @@
</trim> </trim>
</insert> </insert>
<update id="updateByPrimaryKeySelective"> <update id="updateByPrimaryKeySelective">
update hy_partner_user_info update xfsg_partner_user_info
<set> <set>
<if test="record.partnerId != null"> <if test="record.partnerId != null">
partner_id = #{record.partnerId}, partner_id = #{record.partnerId},
@@ -280,13 +280,13 @@
</update> </update>
<update id="updateJoinKnowById"> <update id="updateJoinKnowById">
update hy_partner_user_info update xfsg_partner_user_info
set `is_write_partner_know`=#{isWritePartnerKnow,jdbcType=INTEGER} set `is_write_partner_know`=#{isWritePartnerKnow,jdbcType=INTEGER}
where id=#{id,jdbcType=BIGINT} where id=#{id,jdbcType=BIGINT}
</update> </update>
<update id="updateByPartnerId"> <update id="updateByPartnerId">
update hy_partner_user_info update xfsg_partner_user_info
<set> <set>
<if test="record.mobile != null"> <if test="record.mobile != null">
mobile = #{record.mobile}, mobile = #{record.mobile},

View File

@@ -0,0 +1,40 @@
package com.cool.store.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 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;
}

View File

@@ -24,7 +24,7 @@ public class HyPartnerUserInfoDO implements Serializable {
@ApiModelProperty("") @ApiModelProperty("")
private Long id; private Long id;
@ApiModelProperty("hy_partner_user_info.partner_id") @ApiModelProperty("xfsg_partner_user_info.partner_id")
private String partnerId; private String partnerId;
@ApiModelProperty("手机号") @ApiModelProperty("手机号")

View File

@@ -20,7 +20,7 @@ public class PartnerUserInfoVO {
@ApiModelProperty("ID") @ApiModelProperty("ID")
private Long id; private Long id;
@ApiModelProperty("hy_partner_user_info.partner_id") @ApiModelProperty("xfsg_partner_user_info.partner_id")
private String partnerId; private String partnerId;
@ApiModelProperty("手机号") @ApiModelProperty("手机号")

View File

@@ -10,6 +10,7 @@ import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.UserChannelEnum; import com.cool.store.enums.UserChannelEnum;
import com.cool.store.exception.ServiceException; import com.cool.store.exception.ServiceException;
import com.cool.store.http.WechatRest; import com.cool.store.http.WechatRest;
import com.cool.store.mapper.HyPartnerUserChannelMapper;
import com.cool.store.request.MobileUpdateRequest; import com.cool.store.request.MobileUpdateRequest;
import com.cool.store.service.WechatMiniAppService; import com.cool.store.service.WechatMiniAppService;
import com.cool.store.utils.RedisUtilPool; import com.cool.store.utils.RedisUtilPool;
@@ -17,11 +18,13 @@ import com.cool.store.utils.UUIDUtils;
import com.cool.store.vo.PartnerUserInfoVO; import com.cool.store.vo.PartnerUserInfoVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
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.Value; 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;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Objects;
/** /**
* @author zhangchenbiao * @author zhangchenbiao
@@ -39,6 +42,10 @@ public class WechatMiniAppServiceImpl implements WechatMiniAppService {
private WechatRest wechatRest; private WechatRest wechatRest;
@Resource @Resource
private HyPartnerUserInfoDAO hyPartnerUserInfoDAO; private HyPartnerUserInfoDAO hyPartnerUserInfoDAO;
@Autowired
private HyPartnerUserChannelMapper hyPartnerUserChannelMapper;
@Resource
private LineInfoDAO lineInfoDAO;
@Resource @Resource
HyOpenAreaInfoDAO hyOpenAreaInfoDAO; HyOpenAreaInfoDAO hyOpenAreaInfoDAO;
@Value("${weixin.appId}") @Value("${weixin.appId}")
@@ -106,6 +113,12 @@ public class WechatMiniAppServiceImpl implements WechatMiniAppService {
}else { }else {
if (StringUtils.isNumeric(userChannel)) { if (StringUtils.isNumeric(userChannel)) {
channelId = Integer.valueOf(userChannel); channelId = Integer.valueOf(userChannel);
HyPartnerUserChannelDO hyPartnerUserChannelDO = hyPartnerUserChannelMapper.selectByChannelId(Long.valueOf(channelId));
if (Objects.isNull(hyPartnerUserChannelDO)|| hyPartnerUserChannelDO.getChannelId() == null ) {
//用户渠道不存在
throw new ServiceException(ErrorCodeEnum.USER_CHANNEL_NOT_EXISTS);
}
} }
} }
} }
@@ -117,6 +130,11 @@ public class WechatMiniAppServiceImpl implements WechatMiniAppService {
} }
} }
BeanUtil.copyProperties(hyPartnerUserInfoDO, userInfoVO); BeanUtil.copyProperties(hyPartnerUserInfoDO, userInfoVO);
/*LineInfoDO lineInfoDO = lineInfoDAO.getByPartnerId(hyPartnerUserInfoDO.getPartnerId());
if (lineInfoDO != null){
userInfoVO.setPartnerLineId(lineInfoDO.getId());
userInfoVO.setLineStatus(lineInfoDO.getLineStatus());
}*/
} }
userInfoVO.setOpenid(openid); userInfoVO.setOpenid(openid);
userInfoVO.setUnionId(unionId); userInfoVO.setUnionId(unionId);