Commit cc2174be by Water Wang

add broker team performance query

parent b6d35e88
......@@ -31,7 +31,6 @@ import com.yd.dal.entity.marketing.MktLeadsAssignedTrack;
import com.yd.dal.entity.marketing.MktLeadsAssigneds;
import com.yd.dal.entity.marketing.MktLeadsGoals;
import com.yd.dal.entity.marketing.MktLeadsPool;
import com.yd.dal.entity.meta.*;
import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo;
import com.yd.dal.entity.order.PoOrder;
import com.yd.dal.entity.practitioner.opportunity.PlayerSalesActivityInfo;
......@@ -56,7 +55,6 @@ import com.yd.rmi.tencent.wechatinterf.pojo.token.TokenRequest;
import com.yd.util.CommonUtil;
import com.yd.util.HttpUtil;
import com.yd.util.config.ZHBErrorConfig;
import com.yd.util.deshandler.DESTypeHandler;
import org.apache.commons.beanutils.BeanPropertyValueEqualsPredicate;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
......@@ -2310,10 +2308,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//eGolden
getMemberInfoForEGolden(memberInfoMap,mobileNo,time);
//查询出来的结果按照fyp进行排序
List<SubordinateSystemMemberInfo> memberInfoList = (List<SubordinateSystemMemberInfo>)memberInfoMap.values();
List<SubordinateSystemMemberInfo> memberInfoList = new ArrayList<>(memberInfoMap.values());
memberInfoList.sort(Comparator.comparingDouble(SubordinateSystemMemberInfo::getFyp));
Collections.reverse(memberInfoList);
for(SubordinateSystemMemberInfo item : memberInfoList){
fypSum += item.getFyp();
fycSum += item.getFyc();
countSum += item.getCount();
}
statisticInfo.setCount(countSum);
statisticInfo.setFyc(CommonUtil.doubleFormat(fycSum,2));
statisticInfo.setFyp(CommonUtil.doubleFormat(fypSum,2));
......@@ -2328,7 +2330,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
responseVO.setMemberInfoList(memberInfoList);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
}else{
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830054")));
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830017")));
}
}else{
String[] params = {"practitionerId"};
......@@ -2344,9 +2346,58 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
* @param time 时间
*/
private void getMemberInfoForEGolden(Map<String, SubordinateSystemMemberInfo> memberInfoMap, String mobileNo, Integer time) {
if(!Strings.isNullOrEmpty(mobileNo)){
if(!Strings.isNullOrEmpty(mobileNo) && mobileNo.length() == 11){
//1、通过手机号码查询用户
PractitionerBasicInfo practitionerBasicInfo = aclPractitionerDALService.findByMobileNoE(mobileNo);
//2、判断该用户是否是为团队长
String practitionerId = practitionerBasicInfo.getPractitionerId();
if(!Strings.isNullOrEmpty(practitionerId)){
PractitionerSubordinateInfo subordinateInfo = aclPractitionerSubordinateSystemDALService.findByOwnerE(practitionerId);
if(subordinateInfo != null){
//3、通过团队长编号查询出该团队下的所有成员
String subordinateIdForEGolden = subordinateInfo.getSubordinateCode();
List<SubordinateSystemMemberInfoE> subordinateSystemMemberInfoEList = aclPractitionerSubordinateSystemDALService.findStatisticsE(subordinateIdForEGolden,time);
if(!subordinateSystemMemberInfoEList.isEmpty()){
String mobileNoForMember;
SubordinateSystemMemberInfo memberInfo;
Double fyp, fyc;
Integer count;
//4、根据id查询出所有的成员的fyc和fyp
for(SubordinateSystemMemberInfoE item : subordinateSystemMemberInfoEList){
mobileNoForMember = getMobileNo(item.getMobileNo());
if(memberInfoMap.containsKey(mobileNoForMember)){
memberInfo = memberInfoMap.get(mobileNoForMember);
fyp = memberInfo.getFyp();
fyc = memberInfo.getFyc();
count = memberInfo.getCount();
memberInfo.setFyc(CommonUtil.doubleFormat(fyc + item.getFyc(),2));
memberInfo.setFyp(CommonUtil.doubleFormat(fyp + item.getFyp(),2));
memberInfo.setCount(count + item.getCount());
}else{
memberInfo = new SubordinateSystemMemberInfo();
BeanUtils.copyProperties(item,memberInfo);
memberInfoMap.put(mobileNoForMember,memberInfo);
}
}
}
}
}
}
}
/**
* 获取EGOlden中的手机号码
* @param mobileNo 手机号码
* @return 校验后的手机号码
*/
private String getMobileNo(String mobileNo) {
if(!Strings.isNullOrEmpty(mobileNo) && mobileNo.length() > 11){
if(mobileNo.contains(" ")){
String[] mobiles = mobileNo.split(" ");
return mobiles[1];
}
}
return mobileNo;
}
/**
......@@ -2410,7 +2461,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
memberInfo.setFyp(CommonUtil.doubleFormat(fyp,2));
memberInfo.setCount(count);
memberInfoMap.put(practitionerIdMobileNoMap.get(practitionerIdForMember),memberInfo);
// memberInfoList.add(memberInfo);
}
}
}
......
......@@ -64,4 +64,5 @@ public class PractitionerBasicInfo {
public void setGender(String gender) {
this.gender = gender;
}
}
package com.yd.dal.entity.customer.practitioner;
public class SubordinateSystemMemberInfoE {
private Long practitionerId;
private String name;
private String levelCode;
private String levelName;
private Double fyp;
private Double fyc;
private Integer count;
private String mobileNo;
public Long getPractitionerId() {
return practitionerId;
}
public void setPractitionerId(Long practitionerId) {
this.practitionerId = practitionerId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLevelCode() {
return levelCode;
}
public void setLevelCode(String levelCode) {
this.levelCode = levelCode;
}
public String getLevelName() {
return levelName;
}
public void setLevelName(String levelName) {
this.levelName = levelName;
}
public Double getFyp() {
return fyp;
}
public void setFyp(Double fyp) {
this.fyp = fyp;
}
public Double getFyc() {
return fyc;
}
public void setFyc(Double fyc) {
this.fyc = fyc;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public String getMobileNo() {
return mobileNo;
}
public void setMobileNo(String mobileNo) {
this.mobileNo = mobileNo;
}
}
......@@ -48,4 +48,6 @@ public interface AclPractitionerMapper {
List<AclPractitioner> findBySubordinateSystemId(@Param("subordinateSystemId")Long subordinateSystemId);
String findMobileNoByPractitionerId(@Param("practitionerId")Long practitionerId);
PractitionerBasicInfo findByMobileNoE(@Param("mobileNo")String mobileNo);
}
\ No newline at end of file
......@@ -2,10 +2,8 @@ package com.yd.dal.mapper.customer;
import com.yd.dal.entity.customer.AclPractitionerSubordinateSystem;
import com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo;
import com.yd.dal.entity.customer.practitioner.SubordinateSystemMemberInfoE;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.List;
public interface AclPractitionerSubordinateSystemMapper {
......@@ -28,4 +26,8 @@ public interface AclPractitionerSubordinateSystemMapper {
List<AclPractitionerSubordinateSystem> findByOwnerPractitionerId(Long practitionerId);
List<AclPractitionerSubordinateSystem> findByOwner(@Param("practitionerId") Long practitionerId);
PractitionerSubordinateInfo findByOwnerE(@Param("practitionerId")String practitionerId);
List<SubordinateSystemMemberInfoE> findStatisticsE(@Param("subordinateIdForEGolden")String subordinateIdForEGolden, @Param("time")Integer time);
}
\ No newline at end of file
......@@ -109,4 +109,11 @@ public interface AclPractitionerDALService {
* @return 查询结果
*/
String findMobileNoByPractitionerId(Long practitionerId);
/**
* EGolden -- 根据手机号码查询经纪人的基本信息
* @param mobileNo 手机号码
* @return 查询结果
*/
PractitionerBasicInfo findByMobileNoE(String mobileNo);
}
......@@ -2,6 +2,7 @@ package com.yd.dal.service.customer;
import com.yd.dal.entity.customer.AclPractitionerSubordinateSystem;
import com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo;
import com.yd.dal.entity.customer.practitioner.SubordinateSystemMemberInfoE;
import org.springframework.stereotype.Service;
import java.util.List;
......@@ -17,4 +18,7 @@ public interface AclPractitionerSubordinateSystemDALService {
List<AclPractitionerSubordinateSystem> findByOwner(Long practitionerId);
PractitionerSubordinateInfo findByOwnerE(String practitionerId);
List<SubordinateSystemMemberInfoE> findStatisticsE(String subordinateIdForEGolden, Integer time);
}
......@@ -113,4 +113,10 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService
}
return mobileNo;
}
@Override
@TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
public PractitionerBasicInfo findByMobileNoE(String mobileNo) {
return aclPractitionerMapper.findByMobileNoE(mobileNo);
}
}
......@@ -2,8 +2,11 @@ package com.yd.dal.service.customer.impl;
import com.yd.dal.entity.customer.AclPractitionerSubordinateSystem;
import com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo;
import com.yd.dal.entity.customer.practitioner.SubordinateSystemMemberInfoE;
import com.yd.dal.mapper.customer.AclPractitionerSubordinateSystemMapper;
import com.yd.dal.service.customer.AclPractitionerSubordinateSystemDALService;
import com.yd.util.intercept.annotation.TargetDataSource;
import com.yd.util.intercept.commons.DataSourceKey;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -40,4 +43,16 @@ public class AclPractitionerSubordinateSystemDALServiceImpl implements AclPracti
public List<AclPractitionerSubordinateSystem> findByOwner(Long practitionerId) {
return aclPractitionerSubordinateSystemMapper.findByOwner(practitionerId);
}
@Override
@TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
public PractitionerSubordinateInfo findByOwnerE(String practitionerId) {
return aclPractitionerSubordinateSystemMapper.findByOwnerE(practitionerId);
}
@Override
@TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
public List<SubordinateSystemMemberInfoE> findStatisticsE(String subordinateIdForEGolden, Integer time) {
return aclPractitionerSubordinateSystemMapper.findStatisticsE(subordinateIdForEGolden,time);
}
}
......@@ -770,4 +770,14 @@
from ag_acl_practitioner p left join ag_acl_customer c on p.customer_id = c.id and c.is_active = 1
where p.id = #{practitionerId,jdbcType=BIGINT} limit 1;
</select>
<select id="findByMobileNoE" resultType="com.yd.dal.entity.customer.practitioner.PractitionerBasicInfo">
SELECT
p.SAL_MST_ID as practitionerId,
p.SAL_MST_NAME as name,
p.SAL_MST_GENDER as gender,
p.SAL_MST_ID_TYPE as titleCode,
p.SAL_MST_OFFICIAL_TITLE as titleName
FROM sal001 p
where p.SAL_MST_MOBILE like concat(concat('%',#{mobileNo,jdbcType=VARCHAR}),'%')
</select>
</mapper>
\ No newline at end of file
......@@ -260,4 +260,38 @@
from ag_acl_practitioner_subordinate_system
where owner_practitioner_id = #{practitionerId,jdbcType=BIGINT} and is_active = 1
</select>
<select id="findByOwnerE" resultType="com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo">
SELECT
p.SPC_DIV_NAME as subordinateName,
p.SPC_DIV_ID as subordinateCode,
p.FK_DIV_BOSS_ID as subordinateLeader
FROM spc004 p
where p.FK_DIV_BOSS_ID = #{practitionerId,jdbcType=VARCHAR}
</select>
<select id="findStatisticsE"
resultType="com.yd.dal.entity.customer.practitioner.SubordinateSystemMemberInfoE">
SELECT
p.SAL_MST_NAME as name ,-- 姓名
p.SAL_MST_ID_TYPE as titleCode,-- 职称code
p.SAL_MST_OFFICIAL_TITLE as titleName,-- 职称名称
p.SAL_MST_MOBILE as mobileNo,
count(m.MON025_002) as count,-- 保单id
sum(m.MON025_401) as fyp,-- 保费
sum(policy.INS001_FYCTOTAL) as fyc -- 应发佣金
FROM sal001 p INNER JOIN MON025 m on m.MON025_007 = p.SAL_MST_ID and m.MON025_109 IN (1,2,3) AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'-- 业务员id
inner JOIN ins001 policy on m.MON025_002 = policy.INS_MST_ID -- 保单id
WHERE p.FK_SPC_DIV_ID = #{subordinateIdForEGolden,jdbcType=VARCHAR}
<choose>
<when test="time == 1">
and DATE_FORMAT(policy.INS_MST_ACCEPT_DATE, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when test="time == 3">
and QUARTER(policy.INS_MST_ACCEPT_DATE) = QUARTER(NOW()) AND year(policy.INS_MST_ACCEPT_DATE)=year(now())
</when>
<otherwise>
and YEAR(policy.INS_MST_ACCEPT_DATE) = YEAR(now())
</otherwise>
</choose>
group by p.SAL_MST_ID;
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment