Commit 9d6ec49a by Water Wang

optimzie--practitioner rank and polciy list query

parent cc2174be
package com.yd.api.practitioner;
import com.yd.api.practitioner.service.PractitionerPolicyService;
import com.yd.api.practitioner.service.PractitionerService;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginResponseVO;
import com.yd.api.practitioner.vo.media.MediaGetReqVO;
import com.yd.api.practitioner.vo.media.MediaGetRespVO;
import com.yd.api.practitioner.vo.opportunity.*;
import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO;
import com.yd.api.practitioner.vo.policy.PolicyListQueryResponseVO;
import com.yd.api.practitioner.vo.rank.PractitionerRankRequestVO;
import com.yd.api.practitioner.vo.rank.PractitionerRankResponseVO;
import com.yd.api.practitioner.vo.recruit.*;
......@@ -27,6 +30,8 @@ public class PractitionerController {
@Autowired
private PractitionerService practitionerService;
@Autowired
private PractitionerPolicyService practitionerPolicyService;
/**
* 经纪人登录
......@@ -395,4 +400,18 @@ public class PractitionerController {
result.addResult(responseVO);
return result;
}
/**
* 经纪人保单列表查询接口
* @param requestVO 请求信息
* @return PolicyListQueryResponseVO
*/
@RequestMapping("/policyListQuery")
public Object practitionerPolicyListQuery(@RequestBody PolicyListQueryRequestVO requestVO){
JsonResult result = new JsonResult();
PolicyListQueryResponseVO responseVO = practitionerPolicyService.policyListQuery(requestVO);
result.setData(responseVO);
result.addResult(responseVO);
return result;
}
}
package com.yd.api.practitioner.service;
import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO;
import com.yd.api.practitioner.vo.policy.PolicyListQueryResponseVO;
import org.springframework.stereotype.Service;
@Service("practitionerPolicyService")
public interface PractitionerPolicyService {
/**
* 经纪人保单列表查询
* @param requestVO 请求信息
* @return PolicyListQueryResponseVO
*/
PolicyListQueryResponseVO policyListQuery(PolicyListQueryRequestVO requestVO);
}
......@@ -202,4 +202,6 @@ public interface PractitionerService {
* @return 响应数据
*/
PotentialActivityQueryResponseVO potentialActivityQuery(PotentialActivityQueryRequestVO requestVO);
}
package com.yd.api.practitioner.service.impl;
import com.google.common.base.Strings;
import com.yd.api.practitioner.service.PractitionerPolicyService;
import com.yd.api.practitioner.vo.policy.PolicyInfo;
import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO;
import com.yd.api.practitioner.vo.policy.PolicyListQueryResponseVO;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.customer.AclPractitioner;
import com.yd.dal.entity.order.CustomerPolicyInfo;
import com.yd.dal.entity.product.Product;
import com.yd.dal.entity.product.ProductE;
import com.yd.dal.entity.product.ProductPlan;
import com.yd.dal.service.customer.AclPractitionerDALService;
import com.yd.dal.service.order.PoOrderDALService;
import com.yd.dal.service.product.ProductDALService;
import com.yd.dal.service.product.ProductPlanDALService;
import com.yd.util.config.ZHBErrorConfig;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service("practitionerPolicyService")
public class PractitionerPolicyServiceImpl implements PractitionerPolicyService {
@Autowired
private AclPractitionerDALService aclPractitionerDALService;
@Autowired
private PoOrderDALService poOrderDALService;
@Autowired
private ProductPlanDALService productPlanDALService;
@Autowired
private ProductDALService productDALService;
@Override
public PolicyListQueryResponseVO policyListQuery(PolicyListQueryRequestVO requestVO) {
PolicyListQueryResponseVO responseVO = new PolicyListQueryResponseVO();
Long practitionerId = requestVO.getPractitionerId();
if(practitionerId !=null){
String mobileNo = aclPractitionerDALService.findMobileNoByPractitionerId(practitionerId);
if(!Strings.isNullOrEmpty(mobileNo) && mobileNo.length() == 11){
List<PolicyInfo> policyInfoList = new ArrayList<>();
Integer time = requestVO.getTime();
time = (time == null) ? 1 : time;
//1、线上
getPolicyListForYD(policyInfoList,practitionerId,time);
//2、线下
getPolicyListForEGolden(policyInfoList,mobileNo,time);
responseVO.setPolicyInfoList(policyInfoList);
Collections.sort(policyInfoList);
responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000")));
}else{
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("820001")));
}
}else{
String[] params = {"practitionerId"};
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("610001", params)));
}
return responseVO;
}
/**
* EGolden--查询经纪人保单列表
* @param policyInfoList 保单列表
* @param mobileNo 手机号码
* @param time 时间段
*/
private void getPolicyListForEGolden(List<PolicyInfo> policyInfoList, String mobileNo, Integer time) {
if(!Strings.isNullOrEmpty(mobileNo)){
PolicyInfo policyInfo ;
List<CustomerPolicyInfo> policyInfos = poOrderDALService.findPolicyInfoByMobileNoE(mobileNo,time);
if(!policyInfos.isEmpty()){
String productId ;
Map<String,String> productNameMap = new HashMap<>();
List<ProductE> products = productDALService.findAllE();
products.forEach(i->productNameMap.put(i.getProductId(),i.getProductName()));
for(CustomerPolicyInfo item : policyInfos){
policyInfo = new PolicyInfo();
productId = item.getProductName();
BeanUtils.copyProperties(item,policyInfo);
policyInfo.setProductName(productNameMap.get(productId));
policyInfo.setPlatform(2);
policyInfoList.add(policyInfo);
}
}
}
}
/**
* 银盾保险在线--查询经纪人保单列表
* @param policyInfoList 保单列表
* @param practitionerId 经纪人id
* @param time 时间段
*/
private void getPolicyListForYD(List<PolicyInfo> policyInfoList, Long practitionerId, Integer time) {
if(practitionerId != null ){
AclPractitioner practitioner = aclPractitionerDALService.findById(practitionerId);
Long customerId = practitioner.getCustomerId();
if(customerId != null){
List<CustomerPolicyInfo> policyInfos = poOrderDALService.findPolicyInfoByCustomerId(customerId,time);
if(!policyInfos.isEmpty()){
PolicyInfo policyInfo ;
Map<Long,String> planNameMap = new HashMap<>();
Map<Long,String> productNameMap = new HashMap<>();
List<ProductPlan> plans = productPlanDALService.findAll();
List<Product> products = productDALService.findAll();
products.forEach(i->productNameMap.put(i.getId(),i.getName()));
plans.forEach(i->planNameMap.put(i.getId(),i.getName()));
Long planId ;
for(CustomerPolicyInfo item : policyInfos){
planId = item.getPlanId();
policyInfo = new PolicyInfo();
BeanUtils.copyProperties(item,policyInfo);
if(planId != null){
policyInfo.setPlanName(planNameMap.get(planId));
policyInfo.setNoPlanProduct(false);
}else{
policyInfo.setProductName(productNameMap.get(item.getProductId()));
policyInfo.setNoPlanProduct(true);
}
policyInfo.setPlatform(1);
policyInfoList.add(policyInfo);
}
}
}
}
}
}
package com.yd.api.practitioner.vo.policy;
import com.yd.dal.entity.order.CustomerPolicyInfo;
public class PolicyInfo extends CustomerPolicyInfo {
}
\ No newline at end of file
package com.yd.api.practitioner.vo.policy;
public class PolicyListQueryRequestVO {
private Long practitionerId;
private Integer time;
public Long getPractitionerId() {
return practitionerId;
}
public void setPractitionerId(Long practitionerId) {
this.practitionerId = practitionerId;
}
public Integer getTime() {
return time;
}
public void setTime(Integer time) {
this.time = time;
}
}
package com.yd.api.practitioner.vo.policy;
import com.yd.api.result.CommonResult;
import java.util.List;
public class PolicyListQueryResponseVO {
private List<PolicyInfo> policyInfoList;
private CommonResult commonResult;
public List<PolicyInfo> getPolicyInfoList() {
return policyInfoList;
}
public void setPolicyInfoList(List<PolicyInfo> policyInfoList) {
this.policyInfoList = policyInfoList;
}
public CommonResult getCommonResult() {
return commonResult;
}
public void setCommonResult(CommonResult commonResult) {
this.commonResult = commonResult;
}
}
package com.yd.dal.entity.order;
import com.google.common.base.Strings;
import com.yd.util.CommonUtil;
import java.util.Date;
public class CustomerPolicyInfo implements Comparable<CustomerPolicyInfo>{
private Long orderId;
private String orderNo;
private String policyNo;
private String holderName;
private String destination;
private String planName;
private String productName;
private String orderDate;
private String startDate;
private String endDate;
private Double referralAmount;
private Double orderPrice;
private boolean noPlanProduct;
private Integer platform;//1、银盾在线,2、EGolden
private Long planId;
private Long productId;
public Long getOrderId() {
return orderId;
}
public void setOrderId(Long orderId) {
this.orderId = orderId;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public String getPolicyNo() {
return policyNo;
}
public void setPolicyNo(String policyNo) {
this.policyNo = policyNo;
}
public String getHolderName() {
return holderName;
}
public void setHolderName(String holderName) {
this.holderName = holderName;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
public String getPlanName() {
return planName;
}
public void setPlanName(String planName) {
this.planName = planName;
}
public String getOrderDate() {
return orderDate;
}
public void setOrderDate(String orderDate) {
this.orderDate = orderDate;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public Double getReferralAmount() {
return referralAmount;
}
public void setReferralAmount(Double referralAmount) {
this.referralAmount = referralAmount;
}
public Double getOrderPrice() {
return orderPrice;
}
public void setOrderPrice(Double orderPrice) {
this.orderPrice = orderPrice;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public boolean isNoPlanProduct() {
return noPlanProduct;
}
public void setNoPlanProduct(boolean noPlanProduct) {
this.noPlanProduct = noPlanProduct;
}
public Integer getPlatform() {
return platform;
}
public void setPlatform(Integer platform) {
this.platform = platform;
}
public Long getPlanId() {
return planId;
}
public void setPlanId(Long planId) {
this.planId = planId;
}
public Long getProductId() {
return productId;
}
public void setProductId(Long productId) {
this.productId = productId;
}
@Override
public int compareTo(CustomerPolicyInfo o) {
String orderDate1 = o.getOrderDate();
if(!Strings.isNullOrEmpty(orderDate) && !Strings.isNullOrEmpty(orderDate1)){
Date orderDateDT = CommonUtil.stringParseDate(orderDate,"yyyy-MM-dd HH:mm:ss");
Date orderDate1DT = CommonUtil.stringParseDate(orderDate1,"yyyy-MM-dd HH:mm:ss");
if(orderDate1DT != null && orderDateDT != null){
return orderDate1DT.compareTo(orderDateDT);
}else{
return 0;
}
}else{
return 0;
}
}
}
package com.yd.dal.entity.product;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* ag_product
* @author
*/
@Data
public class Product implements Serializable {
/**
* serial id
*/
private Long id;
/**
* FK ag_acl_insurer.id
*/
private Long insurerId;
private String insurerName;
/**
* FK ag_acl_insurer_branch.id
*/
private Long insurerBranchId;
/**
* FK ag_product_category.id
*/
private Long productCategoryId;
/**
* Product#
*/
private String no;
/**
* Product Chinese name/Description
*/
private String name;
/**
* Product English name
*/
private String nameEn;
private String description;
/**
* 0000-00-00
*/
private Date effectiveStartDate;
/**
* 0000-00-00
*/
private Date effectiveEndDate;
private BigDecimal salePrice;
/**
* 0=No, 1=Yes
*/
private Integer isActive;
/**
* 保单生效起始日计算 T+X
*/
private Integer policyEffCount;
/**
* 保单生效起始日计算单位 H=时 D=天 W=周 M=月 Y=年
*/
private String policyEffCountUnit;
/**
* 最小保障期限
*/
private Integer minCoverTerm;
/**
* 最小保障期限单位 H=时 D=天 W=周 M=月 Y=年
*/
private String minCoverTermUnit;
/**
* 犹豫期,该产品订单的财富,只有过了犹豫期才能体现(H5)
*/
private Integer hesitatePeroid;
/**
* 1人/天、1人/年
*/
private String uiDisplayUnit;
/**
* 评测icon文章的url
*/
private String articleUrl;
/**
* 是否银盾收保费 0=No, 1=Yes
*/
private Integer isPayToYd;
/**
* 0000-00-00 00:00:00
*/
private Date createdAt;
/**
* FK ag_acl_user.id
*/
private Long createdBy;
/**
* 0000-00-00 00:00:00
*/
private Date updatedAt;
/**
* latest updator
*/
private Long updatedBy;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.yd.dal.entity.product;
public class ProductE {
private String productId;
private String productName;
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
}
package com.yd.dal.entity.product;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* ag_product_plan
* @author
*/
@Data
public class ProductPlan implements Serializable {
/**
* serial id
*/
private Long id;
/**
* FK ag_acl_insurer.id
*/
private Long insurerId;
/**
* FK ag_product.id
*/
private Long productId;
/**
* plan#= plan code
*/
private String planCode;
/**
* contract_id for Starr; Risk-Duty code for Fosun
*/
private String contractId;
/**
* plan Chinese name
*/
private String name;
/**
* plan Level name 档次显示
*/
private String nameSub;
/**
* plan Eng name
*/
private String nameEn;
/**
* 0, 1=low, 2=mid 3=high, 4=super
*/
private Integer level;
private BigDecimal commisionRate;
private BigDecimal referralRate;
private BigDecimal salePrice;
/**
* 0000-00-00
*/
private Date effectiveStartDate;
/**
* 0000-00-00
*/
private Date effectiveEndDate;
/**
* 0=No, 1=Yes
*/
private Integer isActive;
/**
* 0=No, 1=Yes
*/
private Integer isGlobal;
/**
* FK ag_acl_continent.id
*/
private Long continentId;
/**
* FK ag_md_country.id
*/
private Long countryId;
/**
* FK ag_md_region.id
*/
private Long regionId;
/**
* 0=No, 1=Yes
*/
private Integer isPopular;
/**
* incremental +1
*/
private Integer salesCount;
/**
* version control
*/
private Integer version;
/**
* 支持社保类型(1-仅支持有社保; 0-仅支持无社保; 3-同时支持有、无社保)
*/
private Integer isSocialInsured;
/**
* 适用性别(1-男;2-女)
*/
private Integer appGender;
/**
* 创建时间
*/
private Date createdAt;
/**
* 创建人
*/
private Long createdBy;
/**
* 修改时间
*/
private Date updatedAt;
/**
* 修改人
*/
private Long updatedBy;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.yd.dal.mapper.order;
import com.yd.dal.entity.order.CustomerPolicyInfo;
import com.yd.dal.entity.order.PoOrder;
import org.apache.ibatis.annotations.Param;
......@@ -19,4 +20,8 @@ public interface PoOrderMapper {
int updateByPrimaryKey(PoOrder record);
List<PoOrder> findByStatusAndShareCodeInGroupByCustomerId(@Param("status") int status, @Param("customerShareCodes") List<String> customerShareCodes);
List<CustomerPolicyInfo> findPolicyInfoByCustomerId(@Param("customerId")Long customerId, @Param("time")Integer time);
List<CustomerPolicyInfo> findPolicyInfoByMobileNoE(@Param("mobileNo")String mobileNo, @Param("time")Integer time);
}
\ No newline at end of file
package com.yd.dal.mapper.product;
import com.yd.dal.entity.product.Product;
import com.yd.dal.entity.product.ProductE;
import java.util.List;
public interface ProductMapper {
int deleteByPrimaryKey(Long id);
int insert(Product record);
int insertSelective(Product record);
Product selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(Product record);
int updateByPrimaryKey(Product record);
List<Product> findAll();
List<ProductE> findAllE();
}
\ No newline at end of file
package com.yd.dal.mapper.product;
import com.yd.dal.entity.product.ProductPlan;
import java.util.List;
public interface ProductPlanMapper {
int deleteByPrimaryKey(Long id);
int insert(ProductPlan record);
int insertSelective(ProductPlan record);
ProductPlan selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(ProductPlan record);
int updateByPrimaryKey(ProductPlan record);
List<ProductPlan> findAll();
}
\ No newline at end of file
......@@ -116,4 +116,11 @@ public interface AclPractitionerDALService {
* @return 查询结果
*/
PractitionerBasicInfo findByMobileNoE(String mobileNo);
/**
* 根据id查询经纪人信息
* @param practitionerId 经纪人id
* @return 查询结果
*/
AclPractitioner findById(Long practitionerId);
}
......@@ -119,4 +119,9 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService
public PractitionerBasicInfo findByMobileNoE(String mobileNo) {
return aclPractitionerMapper.findByMobileNoE(mobileNo);
}
@Override
public AclPractitioner findById(Long practitionerId) {
return aclPractitionerMapper.selectByPrimaryKey(practitionerId);
}
}
package com.yd.dal.service.order.Impl;
import com.yd.dal.entity.order.CustomerPolicyInfo;
import com.yd.dal.entity.order.PoOrder;
import com.yd.dal.mapper.order.PoOrderMapper;
import com.yd.dal.service.order.PoOrderDALService;
import com.yd.util.intercept.annotation.TargetDataSource;
import com.yd.util.intercept.commons.DataSourceKey;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -22,4 +25,15 @@ public class PoOrderDALServiceImpl implements PoOrderDALService {
public PoOrder findByOrderId(Long orderId) {
return poOrderMapper.selectByPrimaryKey(orderId);
}
@Override
public List<CustomerPolicyInfo> findPolicyInfoByCustomerId(Long customerId, Integer time) {
return poOrderMapper.findPolicyInfoByCustomerId(customerId,time);
}
@Override
@TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
public List<CustomerPolicyInfo> findPolicyInfoByMobileNoE(String mobileNo, Integer time) {
return poOrderMapper.findPolicyInfoByMobileNoE(mobileNo,time);
}
}
package com.yd.dal.service.order;
import com.yd.dal.entity.order.CustomerPolicyInfo;
import com.yd.dal.entity.order.PoOrder;
import java.util.List;
......@@ -8,4 +9,8 @@ public interface PoOrderDALService {
List<PoOrder> findByStatusAndShareCodeInGroupByCustomerId(int status, List<String> customerShareCodes);
PoOrder findByOrderId(Long orderId);
List<CustomerPolicyInfo> findPolicyInfoByCustomerId(Long customerId, Integer time);
List<CustomerPolicyInfo> findPolicyInfoByMobileNoE(String mobileNo, Integer time);
}
package com.yd.dal.service.product;
import com.yd.dal.entity.product.Product;
import com.yd.dal.entity.product.ProductE;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("productDALService")
public interface ProductDALService {
List<Product> findAll();
List<ProductE> findAllE();
}
package com.yd.dal.service.product;
import com.yd.dal.entity.product.ProductPlan;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("productPlanDALService")
public interface ProductPlanDALService {
List<ProductPlan> findAll();
}
package com.yd.dal.service.product.impl;
import com.yd.dal.entity.product.Product;
import com.yd.dal.entity.product.ProductE;
import com.yd.dal.mapper.product.ProductMapper;
import com.yd.dal.service.product.ProductDALService;
import com.yd.util.intercept.annotation.TargetDataSource;
import com.yd.util.intercept.commons.DataSourceKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("productDALService")
public class ProductDALServiceImpl implements ProductDALService {
@Autowired
private ProductMapper productMapper;
@Override
public List<Product> findAll() {
return productMapper.findAll();
}
@Override
@TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
public List<ProductE> findAllE() {
return productMapper.findAllE();
}
}
package com.yd.dal.service.product.impl;
import com.yd.dal.entity.product.ProductPlan;
import com.yd.dal.mapper.product.ProductPlanMapper;
import com.yd.dal.service.product.ProductPlanDALService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("productPlanDALService")
public class ProductPlanDALServiceImpl implements ProductPlanDALService {
@Autowired
private ProductPlanMapper productPlanMapper;
@Override
public List<ProductPlan> findAll() {
return productPlanMapper.findAll();
}
}
......@@ -540,34 +540,66 @@
<result column="fyc" property="fyc"/>
</resultMap>
<select id="getPractitionerRankInfoForOffline" resultMap="practitioner_rank_map" resultType="java.lang.Integer">
SELECT
p.SAL_MST_ID as practitionerId ,
p.SAL_MST_NAME as name ,-- 姓名
md.DRP_TITLE_LEVEL as titleCode,-- 职称code
md.DRP_TITLE_NAME as titleName,-- 职称名称
spc.SPC_DIV_NAME as spcDivName,-- 体系id
ifnull(count(m.MON025_002),0) as count,-- 保单id
ifnull(sum(m.MON025_401),0) as fyp,-- 保费
ifnull(sum(policy.INS001_FYCTOTAL),0) as fyc -- 应发佣金
FROM MON025 m INNER JOIN sal001 p on m.MON025_007 = p.SAL_MST_ID -- 业务员id
left join DRP003 md on p.FK_DRP_TITLE_CODE = md.DRP_TITLE_CODE
inner JOIN ins001 policy on m.MON025_002 = policy.INS_MST_ID -- 保单id
inner join spc004 spc on m.MON025_006 = spc.SPC_DIV_ID -- 体系
WHERE m.MON025_109 IN (1,2,3) AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'
<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>
<!-- <select id="getPractitionerRankInfoForOffline" resultMap="practitioner_rank_map" resultType="java.lang.Integer">-->
<!-- SELECT-->
<!-- p.SAL_MST_ID as practitionerId ,-->
<!-- p.SAL_MST_NAME as name ,&#45;&#45; 姓名-->
<!-- md.DRP_TITLE_LEVEL as titleCode,&#45;&#45; 职称code-->
<!-- md.DRP_TITLE_NAME as titleName,&#45;&#45; 职称名称-->
<!-- spc.SPC_DIV_NAME as spcDivName,&#45;&#45; 体系id-->
<!-- ifnull(count(m.MON025_002),0) as count,&#45;&#45; 保单id-->
<!-- ifnull(sum(m.MON025_401),0) as fyp,&#45;&#45; 保费-->
<!-- ifnull(sum(policy.INS001_FYCTOTAL),0) as fyc &#45;&#45; 应发佣金-->
<!-- FROM MON025 m INNER JOIN sal001 p on m.MON025_007 = p.SAL_MST_ID &#45;&#45; 业务员id-->
<!-- left join DRP003 md on p.FK_DRP_TITLE_CODE = md.DRP_TITLE_CODE-->
<!-- inner JOIN ins001 policy on m.MON025_002 = policy.INS_MST_ID &#45;&#45; 保单id-->
<!-- inner join spc004 spc on m.MON025_006 = spc.SPC_DIV_ID &#45;&#45; 体系-->
<!-- WHERE m.MON025_109 IN (1,2,3) AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'-->
<!-- <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>-->
<select id="getPractitionerRankInfoForOffline" resultMap="practitioner_rank_map" resultType="java.lang.Integer">
SELECT
p.SAL_MST_ID as practitionerId ,
p.SAL_MST_NAME as name ,-- 姓名
p.SAL_MST_ID_TYPE as titleCode,-- 职称code
p.SAL_MST_OFFICIAL_TITLE as titleName,-- 职称名称
spc.SPC_DIV_NAME as spcDivName,-- 体系id
ifnull(count(distinct policy.INS_MST_ID),0) as count,-- 保单id
ifnull(sum(policy.INS_MST_TOTAL_PREIUM),0) as fyp,-- 保费
ifnull(sum(policy.INS001_FYCTOTAL),0) as fyc -- 应发佣金
FROM
ins001 policy INNER JOIN mon025 m on policy.INS_MST_ID = m.MON025_002 and m.MON025_109 IN (1,2,3) AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'
INNER JOIN (
SELECT mon025_002,MAX(MON025_405) as MON025_405 FROM mon025 group by mon025_002 ORDER BY mon025_002
) b on m.mon025_002 = b.mon025_002 AND m.MON025_405 = b.MON025_405
INNER JOIN sal001 p on m.MON025_007 = p.SAL_MST_ID -- 业务员id
inner join spc004 spc on m.MON025_006 = spc.SPC_DIV_ID -- 体系
where
<choose>
<when test="time == 1">
DATE_FORMAT(policy.INS_MST_ACCEPT_DATE, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when test="time == 3">
QUARTER(policy.INS_MST_ACCEPT_DATE) = QUARTER(NOW()) AND year(policy.INS_MST_ACCEPT_DATE)=year(now())
</when>
<otherwise>
YEAR(policy.INS_MST_ACCEPT_DATE) = YEAR(now())
</otherwise>
</choose>
group by p.SAL_MST_ID;
</select>
<select id="getPractitionerRankInfoForOnline" resultMap="practitioner_rank_map">
SELECT
......
......@@ -975,8 +975,62 @@
#{item}
</foreach>
</if>
</select>
<select id="findPolicyInfoByCustomerId" resultType="com.yd.dal.entity.order.CustomerPolicyInfo">
SELECT
o.id as orderId,
o.order_no as orderNo ,
o.policy_no as policyNo ,
p.name as holderName,
o.destination as destination,
date_format(o.order_date, '%Y-%m-%d %H:%i:%s') as orderDate,
date_format(o.effective_start_date, '%Y-%m-%d %H:%i:%s') as startDate,
date_format(o.effective_end_date, '%Y-%m-%d %H:%i:%s') as endDate,
f.referral_amount as referralAmount,
f.order_price as orderPrice,
o.plan_id as planId,
o.product_id as productId
FROM ag_acl_customer_fortune f INNER JOIN ag_po_order o ON f.order_id = o.id and o.status = 3 and o.order_price > 0
inner JOIN ag_acl_policyholder p ON o.id = p.order_id and p.type = 2
WHERE f.customer_id = #{customerId,jdbcType=BIGINT}
<choose>
<when test="time == 1">
and DATE_FORMAT(f.order_date, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when test="time == 3">
and QUARTER(f.order_date) = QUARTER(NOW()) AND year(f.order_date)=year(now())
</when>
<otherwise>
and YEAR(f.order_date) = YEAR(now())
</otherwise>
</choose>
</select>
<select id="findPolicyInfoByMobileNoE" resultType="com.yd.dal.entity.order.CustomerPolicyInfo">
SELECT
policy.INS_MST_ID as orderNo ,
policy.INS_MST_POLICY_NUM as policyyNo ,
c.CUS_MST_NAME as holderName,
date_format(policy.INS_MST_ACCEPT_DATE, '%Y-%m-%d %H:%i:%s') as orderDate,
date_format(policy.INS_MST_EFFECT_DATE, '%Y-%m-%d %H:%i:%s') as startDate,
date_format(policy.INS_MST_INVALID_DATE, '%Y-%m-%d %H:%i:%s') as endDate,
sum(m.MON025_405) as referralAmount,
sum(m.MON025_401) as orderPrice,
m.MON025_004 as productName
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
inner join cus001 c on policy.FK_CUS_PRO_ID = c.CUS_MST_ID
WHERE p.SAL_MST_MOBILE like concat(concat('%',#{mobileNo,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 policy.ins_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