Commit b30e8cbb by 章家宝

feat:查询客户标签接口逻辑修改

1 parent 8f353971
package cn.com.glsx.dj.strategy.mapper; package cn.com.glsx.dj.strategy.mapper;
import cn.com.glsx.dj.strategy.dto.CustomerProfileRespDTO;
import cn.com.glsx.dj.strategy.model.CustomerTagProfile; import cn.com.glsx.dj.strategy.model.CustomerTagProfile;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -23,7 +24,7 @@ public interface CustomerTagProfileMapper extends OreMapper<CustomerTagProfile> ...@@ -23,7 +24,7 @@ public interface CustomerTagProfileMapper extends OreMapper<CustomerTagProfile>
* @param phoneList 手机号列表 * @param phoneList 手机号列表
* @return 客户画像列表 * @return 客户画像列表
*/ */
List<CustomerTagProfile> selectByPhoneList(@Param("phoneList") List<String> phoneList); List<CustomerProfileRespDTO> selectByPhoneList(@Param("phoneList") List<String> phoneList);
/** /**
* 根据手机号和类别代码物理删除记录 * 根据手机号和类别代码物理删除记录
......
...@@ -6,14 +6,12 @@ import cn.com.glsx.dj.strategy.enums.ArchiveTagEnum; ...@@ -6,14 +6,12 @@ import cn.com.glsx.dj.strategy.enums.ArchiveTagEnum;
import cn.com.glsx.dj.strategy.mapper.CustomerTagProfileMapper; import cn.com.glsx.dj.strategy.mapper.CustomerTagProfileMapper;
import cn.com.glsx.dj.strategy.model.CustomerTagProfile; import cn.com.glsx.dj.strategy.model.CustomerTagProfile;
import cn.com.glsx.dj.strategy.util.GopApiUtil; import cn.com.glsx.dj.strategy.util.GopApiUtil;
import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -97,25 +95,10 @@ public class CustomerTagProfileService { ...@@ -97,25 +95,10 @@ public class CustomerTagProfileService {
* @return 画像列表 * @return 画像列表
*/ */
public List<CustomerProfileRespDTO> queryProfileByPhones(List<String> phoneList) { public List<CustomerProfileRespDTO> queryProfileByPhones(List<String> phoneList) {
log.info("批量查询客户画像:phoneList size={}", phoneList != null ? phoneList.size() : 0);
if (CollectionUtils.isEmpty(phoneList)) { if (CollectionUtils.isEmpty(phoneList)) {
return Collections.emptyList(); return Collections.emptyList();
} }
return customerTagProfileMapper.selectByPhoneList(phoneList);
List<CustomerTagProfile> profileList = customerTagProfileMapper.selectByPhoneList(phoneList);
if (CollectionUtils.isEmpty(profileList)) {
return Collections.emptyList();
}
List<CustomerProfileRespDTO> result = new ArrayList<>();
for (CustomerTagProfile profile : profileList) {
CustomerProfileRespDTO dto = convertToDTO(profile);
result.add(dto);
}
log.info("批量查询客户画像完成:result size={}", result.size());
return result;
} }
/** /**
...@@ -167,13 +150,4 @@ public class CustomerTagProfileService { ...@@ -167,13 +150,4 @@ public class CustomerTagProfileService {
return sb.toString(); return sb.toString();
} }
/**
* 转换为DTO
*
* @param profile 画像实体
* @return DTO
*/
private CustomerProfileRespDTO convertToDTO(CustomerTagProfile profile) {
return BeanUtil.copyProperties(profile, CustomerProfileRespDTO.class);
}
} }
...@@ -23,11 +23,25 @@ ...@@ -23,11 +23,25 @@
</sql> </sql>
<!-- 根据手机号列表批量查询客户画像 --> <!-- 根据手机号列表批量查询客户画像 -->
<select id="selectByPhoneList" resultMap="BaseResultMap"> <select id="selectByPhoneList" resultType="cn.com.glsx.dj.strategy.dto.CustomerProfileRespDTO">
SELECT <include refid="Base_Column_List"/> SELECT
FROM dj_car_life_customer_tag_profile p.phone,
WHERE deleted_flag = 'N' p.category_code AS categoryCode,
AND phone IN c.category_name AS categoryName,
p.dimension_code AS dimensionCode,
d.dimension_name AS dimensionName,
p.enum_code AS enumCode,
e.enum_name AS enumName,
p.score_basis AS scoreBasis,
p.score,
p.source_type AS sourceType,
p.create_time AS createTime
FROM dj_car_life_customer_tag_profile p
LEFT JOIN dj_car_life_tag_category c ON p.category_code = c.category_code AND c.deleted_flag = 'N'
LEFT JOIN dj_car_life_tag_dimension d ON p.dimension_code = d.dimension_code AND d.deleted_flag = 'N'
LEFT JOIN dj_car_life_tag_enum e ON p.enum_code = e.enum_code AND e.deleted_flag = 'N'
WHERE p.deleted_flag = 'N'
AND p.phone IN
<foreach collection="phoneList" item="phone" open="(" separator="," close=")"> <foreach collection="phoneList" item="phone" open="(" separator="," close=")">
#{phone} #{phone}
</foreach> </foreach>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!