Browse Source

判断客户是否有子客户

master
zhaoqifeng 4 years ago
parent
commit
ff70c3e4d3
  1. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/opercrm/CustomerRelationDao.java
  2. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/opercrm/CustomerRelation.java
  3. 15
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/opercrm/impl/CustomerRelationImpl.java
  4. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/opercrm/CustomerRelationDao.xml

9
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/opercrm/CustomerRelationDao.java

@ -13,4 +13,13 @@ import java.util.List;
@Mapper
public interface CustomerRelationDao {
List<String> selectUsedAreaCodeList(String areaCode);
/**
* 根据customerId查询其所有下级子客户id
* @author zhaoqifeng
* @date 2021/6/29 11:04
* @param customerId
* @return java.util.List<java.lang.String>
*/
List<String> selectAllSubCustomerIds(String customerId);
}

9
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/opercrm/CustomerRelation.java

@ -10,4 +10,13 @@ import java.util.List;
*/
public interface CustomerRelation {
List<String> selectUsedAreaCodeList(String areaCode);
/**
* 是否有子客户
* @author zhaoqifeng
* @date 2021/6/29 11:06
* @param customerId
* @return boolean
*/
boolean haveSubCustomer(String customerId);
}

15
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/opercrm/impl/CustomerRelationImpl.java

@ -5,6 +5,7 @@ import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.opercrm.CustomerRelationDao;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -27,4 +28,18 @@ public class CustomerRelationImpl implements CustomerRelation {
public List<String> selectUsedAreaCodeList(String areaCode) {
return customerRelationDao.selectUsedAreaCodeList(areaCode);
}
/**
* 是否有子客户
*
* @param customerId
* @return boolean
* @author zhaoqifeng
* @date 2021/6/29 11:06
*/
@Override
public boolean haveSubCustomer(String customerId) {
List<String> list = customerRelationDao.selectAllSubCustomerIds(customerId);
return CollectionUtils.isNotEmpty(list);
}
}

9
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/opercrm/CustomerRelationDao.xml

@ -14,4 +14,13 @@
AND cr.AREA_CODE LIKE concat(#{areaCode}, '%')
AND cr.AREA_CODE != #{areaCode}
</select>
<select id="selectAllSubCustomerIds" resultType="java.lang.String">
SELECT
cr.CUSTOMER_ID
FROM
customer_relation cr
WHERE
cr.DEL_FLAG = '0'
AND cr.PIDS like CONCAT(#{customerId},'%')
</select>
</mapper>
Loading…
Cancel
Save