Commit 93dace23 by 林永健

[+] 增加旅程实例的阶段-客户统计接口

1 parent 0d206630
package cn.com.glsx.cdp.api.customer; package cn.com.glsx.cdp.api.customer;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO; import cn.com.glsx.cdp.modules.model.customer.*;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDetailDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneySearch;
import cn.com.glsx.cdp.modules.model.customer.ModifySopJourneyStageRequest;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.Result; import com.glsx.plat.core.web.Result;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
...@@ -13,6 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -13,6 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/** /**
* @author caiym * @author caiym
* @version V1.0.0 * @version V1.0.0
...@@ -36,5 +35,9 @@ public interface CustomerSopJourneyFeignClient { ...@@ -36,5 +35,9 @@ public interface CustomerSopJourneyFeignClient {
@PostMapping("/sopJourneyStage/modify") @PostMapping("/sopJourneyStage/modify")
Result<Boolean> modifyStage(@RequestBody ModifySopJourneyStageRequest request); Result<Boolean> modifyStage(@RequestBody ModifySopJourneyStageRequest request);
@Operation(description = "查询客户旅程客户统计数据")
@PostMapping("/statistics")
Result<List<CustomerSopJourneyStatisticsDTO>> statisticsCustomerSopJourney(@RequestBody CustomerSopJourneySearch request);
} }
package cn.com.glsx.cdp.modules.model.customer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
@Schema(description = "客户sop旅程统计信息")
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
public class CustomerSopJourneyStatisticsDTO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "sop旅程ID")
private String sopJourneyId;
@Schema(description = "sop旅程阶段")
private String sopJourneyStage;
@Schema(description = "数量")
private Long count;
}
...@@ -3,10 +3,7 @@ package cn.com.glsx.cdp.modules.api.customer; ...@@ -3,10 +3,7 @@ package cn.com.glsx.cdp.modules.api.customer;
import cn.com.glsx.cdp.api.customer.CustomerSopJourneyFeignClient; import cn.com.glsx.cdp.api.customer.CustomerSopJourneyFeignClient;
import cn.com.glsx.cdp.modules.converter.CustomerSopJourneyBOConvert; import cn.com.glsx.cdp.modules.converter.CustomerSopJourneyBOConvert;
import cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO; import cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO; import cn.com.glsx.cdp.modules.model.customer.*;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDetailDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneySearch;
import cn.com.glsx.cdp.modules.model.customer.ModifySopJourneyStageRequest;
import cn.com.glsx.cdp.modules.service.CustomerSopJourneyService; import cn.com.glsx.cdp.modules.service.CustomerSopJourneyService;
import cn.com.glsx.cdp.modules.util.CommonUtils; import cn.com.glsx.cdp.modules.util.CommonUtils;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
...@@ -23,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -23,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
...@@ -71,6 +69,7 @@ public class CustomerSopJourneyController implements CustomerSopJourneyFeignClie ...@@ -71,6 +69,7 @@ public class CustomerSopJourneyController implements CustomerSopJourneyFeignClie
@Operation(description = "修改客户旅程") @Operation(description = "修改客户旅程")
@PostMapping("/sopJourneyStage/modify") @PostMapping("/sopJourneyStage/modify")
@Override
public Result<Boolean> modifyStage(ModifySopJourneyStageRequest request) { public Result<Boolean> modifyStage(ModifySopJourneyStageRequest request) {
log.info("修改客户旅程:{}", request); log.info("修改客户旅程:{}", request);
try { try {
...@@ -78,9 +77,21 @@ public class CustomerSopJourneyController implements CustomerSopJourneyFeignClie ...@@ -78,9 +77,21 @@ public class CustomerSopJourneyController implements CustomerSopJourneyFeignClie
} catch (Exception e) { } catch (Exception e) {
log.error("修改客户旅程失败", e); log.error("修改客户旅程失败", e);
String msg = e != null && e.getMessage() != null ? e.getMessage() : ""; String msg = e != null && e.getMessage() != null ? e.getMessage() : "";
return Result.failure(SysConstants.ResultStatus.failure.getCode(), "修改客户旅程失败:"+ msg); return Result.failure(SysConstants.ResultStatus.failure.getCode(), "修改客户旅程失败:" + msg);
} }
log.info("修改客户旅程成功"); log.info("修改客户旅程成功");
return Result.success(true); return Result.success(true);
} }
@Operation(description = "查询客户旅程客户统计数据")
@PostMapping("/statistics")
@Override
public Result<List<CustomerSopJourneyStatisticsDTO>> statisticsCustomerSopJourney(@RequestBody CustomerSopJourneySearch request) {
CustomerSopJourneyBO requestBO = CommonUtils.convertRequest(request, CustomerSopJourneyBO.class);
try {
return Result.success(customerSopJourneyService.statistics(requestBO));
} catch (Exception e) {
return Result.failure(SysConstants.ResultStatus.failure.getCode(), e.getMessage());
}
}
} }
...@@ -2,6 +2,7 @@ package cn.com.glsx.cdp.modules.mapper; ...@@ -2,6 +2,7 @@ package cn.com.glsx.cdp.modules.mapper;
import cn.com.glsx.cdp.modules.entity.CustomerSopJourney; import cn.com.glsx.cdp.modules.entity.CustomerSopJourney;
import cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO; import cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyStatisticsDTO;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -10,4 +11,6 @@ import java.util.List; ...@@ -10,4 +11,6 @@ import java.util.List;
@Mapper @Mapper
public interface CustomerSopJourneyMapper extends CommonBaseMapper<CustomerSopJourney> { public interface CustomerSopJourneyMapper extends CommonBaseMapper<CustomerSopJourney> {
List<CustomerSopJourneyBO> listCustomerSopJourney(CustomerSopJourneyBO customerSopJourneyBO); List<CustomerSopJourneyBO> listCustomerSopJourney(CustomerSopJourneyBO customerSopJourneyBO);
List<CustomerSopJourneyStatisticsDTO> statisticsCustomerSopJourney(CustomerSopJourneyBO request);
} }
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ import cn.com.glsx.cdp.modules.entity.CustomerSopJourney; ...@@ -4,6 +4,7 @@ import cn.com.glsx.cdp.modules.entity.CustomerSopJourney;
import cn.com.glsx.cdp.modules.mapper.CustomerSopJourneyMapper; import cn.com.glsx.cdp.modules.mapper.CustomerSopJourneyMapper;
import cn.com.glsx.cdp.modules.model.CarMaintenanceInsuranceBO; import cn.com.glsx.cdp.modules.model.CarMaintenanceInsuranceBO;
import cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO; import cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyStatisticsDTO;
import cn.com.glsx.cdp.modules.model.customer.ModifySopJourneyStageRequest; import cn.com.glsx.cdp.modules.model.customer.ModifySopJourneyStageRequest;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
...@@ -76,11 +77,20 @@ public class CustomerSopJourneyService { ...@@ -76,11 +77,20 @@ public class CustomerSopJourneyService {
if (CollectionUtils.isNotEmpty(request.getOldStages())) { if (CollectionUtils.isNotEmpty(request.getOldStages())) {
criteria.andIn("sopJourneyStage", request.getOldStages()); criteria.andIn("sopJourneyStage", request.getOldStages());
} }
if (CollectionUtils.isNotEmpty(request.getOneIds())) { if (CollectionUtils.isNotEmpty(request.getOneIds())) {
criteria.andIn("oneId", request.getOneIds()); criteria.andIn("oneId", request.getOneIds());
} }
CustomerSopJourney customerSopJourney = CustomerSopJourney.builder().sopJourneyStage(request.getSopJourneyStage()) CustomerSopJourney customerSopJourney = CustomerSopJourney.builder().sopJourneyStage(request.getSopJourneyStage())
.updatedBy(request.getOprBy()).updatedTime(new Date()).build(); .updatedBy(request.getOprBy()).updatedTime(new Date()).build();
customerSopJourneyMapper.updateByExampleSelective(customerSopJourney, example); customerSopJourneyMapper.updateByExampleSelective(customerSopJourney, example);
} }
public List<CustomerSopJourneyStatisticsDTO> statistics(CustomerSopJourneyBO request) {
try {
return customerSopJourneyMapper.statisticsCustomerSopJourney(request);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
}
}
} }
...@@ -71,6 +71,63 @@ ...@@ -71,6 +71,63 @@
--> -->
ex_json ex_json
</sql> </sql>
<sql id="base_param" >
csj.del_flag = 0
<if test="oneId != null">
and csj.one_id = #{oneId}
</if>
<if test="oneIds != null and oneIds.size()>0">
and csj.one_id in
<foreach collection="oneIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sopJourneyId != null">
and csj.sop_journey_id = #{sopJourneyId}
</if>
<if test="sopJourneyIds != null and sopJourneyIds.size()>0">
and csj.sop_journey_id in
<foreach collection="sopJourneyIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sopJourneyStages != null and sopJourneyStages.size()>0">
and csj.sop_journey_stage in
<foreach collection="sopJourneyStages" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="customerPhones != null and customerPhones.size()>0">
and c.customer_phone in
<foreach collection="customerPhones" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="customerPhone != null and customerPhone != ''">
and c.customer_phone like CONCAT('%', #{customerPhone},'%')
</if>
<if test="customerName != null and customerName != ''">
and c.customer_name like CONCAT('%', #{customerName},'%')
</if>
<if test="wechatNickname != null and wechatNickname != ''">
and c.wechat_nickname like CONCAT('%', #{wechatNickname},'%')
</if>
<if test="sopFollowUpPersonIds != null and sopFollowUpPersonIds.size()>0">
and csj.sop_follow_up_person_id in
<foreach collection="sopFollowUpPersonIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sopFollowUpPersonPhone != null and sopFollowUpPersonPhone != ''">
and csj.sop_follow_up_person_phone = #{sopFollowUpPersonPhone}
</if>
<if test="sopJourneyEnterTimeBegin != null and sopJourneyEnterTimeBegin != ''">
and csj.sop_journey_enter_time &gt;= #{sopJourneyEnterTimeBegin}
</if>
<if test="sopJourneyEnterTimeEnd != null and sopJourneyEnterTimeEnd != ''">
and csj.sop_journey_enter_time &lt;= #{sopJourneyEnterTimeEnd}
</if>
</sql>
<select id="listCustomerSopJourney" parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO" resultMap="BOResultMap"> <select id="listCustomerSopJourney" parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO" resultMap="BOResultMap">
select select
csj.id, csj.org_id, csj.one_id, csj.sop_journey_id, csj.sop_journey_stage, csj.id, csj.org_id, csj.one_id, csj.sop_journey_id, csj.sop_journey_stage,
...@@ -85,62 +142,21 @@ ...@@ -85,62 +142,21 @@
from cdp_customer_sop_journey csj from cdp_customer_sop_journey csj
left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0 left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0
<where> <where>
csj.del_flag = 0 <include refid="base_param" />
<if test="oneId != null"> </where>
and csj.one_id = #{oneId} </select>
</if> <select id="statisticsCustomerSopJourney" parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO"
<if test="oneIds != null and oneIds.size()>0"> resultType="cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyStatisticsDTO">
and csj.one_id in select
<foreach collection="oneIds" item="item" open="(" separator="," close=")"> csj.sop_journey_id as sopJourneyId,
#{item} csj.sop_journey_stage as sopJourneyStage,
</foreach> count(csj.id) as count
</if> from cdp_customer_sop_journey csj
<if test="sopJourneyId != null"> left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0
and csj.sop_journey_id = #{sopJourneyId} <where>
</if> <include refid="base_param" />
<if test="sopJourneyIds != null and sopJourneyIds.size()>0">
and csj.sop_journey_id in
<foreach collection="sopJourneyIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sopJourneyStages != null and sopJourneyStages.size()>0">
and csj.sop_journey_stage in
<foreach collection="sopJourneyStages" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="customerPhones != null and customerPhones.size()>0">
and c.customer_phone in
<foreach collection="customerPhones" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="customerPhone != null and customerPhone != ''">
and c.customer_phone like CONCAT('%', #{customerPhone},'%')
</if>
<if test="customerName != null and customerName != ''">
and c.customer_name like CONCAT('%', #{customerName},'%')
</if>
<if test="wechatNickname != null and wechatNickname != ''">
and c.wechat_nickname like CONCAT('%', #{wechatNickname},'%')
</if>
<if test="sopFollowUpPersonIds != null and sopFollowUpPersonIds.size()>0">
and csj.sop_follow_up_person_id in
<foreach collection="sopFollowUpPersonIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sopFollowUpPersonPhone != null and sopFollowUpPersonPhone != ''">
and csj.sop_follow_up_person_phone = #{sopFollowUpPersonPhone}
</if>
<if test="sopJourneyEnterTimeBegin != null and sopJourneyEnterTimeBegin != ''">
and csj.sop_journey_enter_time &gt;= #{sopJourneyEnterTimeBegin}
</if>
<if test="sopJourneyEnterTimeEnd != null and sopJourneyEnterTimeEnd != ''">
and csj.sop_journey_enter_time &lt;= #{sopJourneyEnterTimeEnd}
</if>
</where> </where>
group by csj.sop_journey_id, csj.sop_journey_stage
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!