Commit b49c4138 by wenyang

1.商机可以删除,变成不可见,如果重新建立商机,手机号重复,允许

2.团队业绩,加一个“去年”的时间段
3.团队业绩,进入后,上面的面板增加3列 目标FYP,目标FYC,完成率 。下面的排名,增加1列,目标FYC
parent dc267e14
......@@ -757,4 +757,19 @@ public class PractitionerController {
result.setData(responseVO);
return result;
}
/**
* 逻辑删除商机
* @param OpportunityDeleteRequestVO
* @return CommonResultIDResponseVO
* @author Yan Wenyang
*/
@RequestMapping("/deleteOpportunity")
public Object deleteOpportunity(@RequestBody OpportunityDeleteRequestVO requestVO) {
JsonResult result = new JsonResult();
CommonResultIDResponseVO responseVO = practitionerService.updateOpportunity(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
}
......@@ -274,4 +274,13 @@ public interface PractitionerService {
* @author Yan Wenyang
*/
CommonResultIDResponseVO signUnionSales(SignUnionSalesRequestVO requestVO);
/**
* 逻辑删除商机
* @param OpportunityDeleteRequestVO
* @return CommonResultIDResponseVO
* @author Yan Wenyang
*/
CommonResultIDResponseVO updateOpportunity(OpportunityDeleteRequestVO requestVO);
}
......@@ -86,6 +86,7 @@ import com.yd.api.practitioner.vo.opportunity.ApplyForExpertSupportResponseVO;
import com.yd.api.practitioner.vo.opportunity.OpportunityBasicInformationInfo;
import com.yd.api.practitioner.vo.opportunity.OpportunityConsultationInfo;
import com.yd.api.practitioner.vo.opportunity.OpportunityCustomerTag;
import com.yd.api.practitioner.vo.opportunity.OpportunityDeleteRequestVO;
import com.yd.api.practitioner.vo.opportunity.OpportunityRecordInfo;
import com.yd.api.practitioner.vo.opportunity.OpportunityRecordSituationInfo;
import com.yd.api.practitioner.vo.opportunity.OpportunityScore;
......@@ -795,8 +796,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
// fycOther = practitionerRankInfo != null ? practitionerRankInfo.getFyc() : 0D;
// Double fycSum = CommonUtil.doubleFormat(fyc + fycOther, 2);
if (fyc != 0) {
Double completeRate = getCompletionRate(practitionerId, null, fyc, time);
practitionerInfo.setCompletionRate(completeRate);
SubordinateSystemStatisticInfo statisticInfo = new SubordinateSystemStatisticInfo();
getCompletionRate(statisticInfo,practitionerId, null, fyc, time);
practitionerInfo.setCompletionRate(statisticInfo.getCompletionRate());
}
}
}
......@@ -1146,6 +1148,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
MktLeadsAssignedTrack mktLeadsAssignedTrack = new MktLeadsAssignedTrack();
mktLeadsAssignedTrack.setPractitionerId(practitionerId);
mktLeadsAssignedTrack.setCustomerId(customerId);
mktLeadsAssignedTrack.setIsActive(1);
PageHelper.orderBy("created_at DESC");
List<MktLeadsAssignedTrack> mktLeadsAssignedTracks = mktLeadsAssignedTrackDALService.findByMktLeadsAssignedTrack(mktLeadsAssignedTrack);
Long opportunityDropOptionId = 0L;
......@@ -1160,6 +1163,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
MktLeadsAssigneds mktLeadsAssigneds = new MktLeadsAssigneds();
mktLeadsAssigneds.setCustomerId(customerId);
mktLeadsAssigneds.setAssignedPractitionerId(practitionerId);
mktLeadsAssigneds.setIsActive(1);
List<MktLeadsAssigneds> mktLeadsAssignedsList = mktLeadsAssignedsDALService.findByMktLeadsAssigneds(mktLeadsAssigneds);
mktLeadsAssigneds = mktLeadsAssignedsList.get(0);
String leadsAssignedsCustomerName = mktLeadsAssigneds.getCustomerName();
......@@ -1713,6 +1717,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
if (aclCustomer != null) {
MktLeadsAssigneds mktLeadsAssigneds = new MktLeadsAssigneds();
mktLeadsAssigneds.setCustomerId(aclCustomer.getId());
mktLeadsAssigneds.setIsActive(1);
List<MktLeadsAssigneds> mktLeadsAssignedsList = mktLeadsAssignedsDALService.findByMktLeadsAssigneds(mktLeadsAssigneds);
if (!mktLeadsAssignedsList.isEmpty()) {
......@@ -2604,13 +2609,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
}
//总预测值
BigDecimal quarterGoal = BigDecimal.ZERO;
BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
for (MktLeadsGoals leadsGoals : mktLeadsGoalsList) {
if (leadsGoals.getStatisticTimeUnit() == 1) {
quarterGoal = quarterGoal.add(BigDecimal.valueOf(leadsGoals.getCommission()));
defaultPremium = defaultPremium.add(BigDecimal.valueOf(leadsGoals.getPremium()));
defaultPieces = defaultPieces + leadsGoals.getPieces();
}
}
......@@ -2619,7 +2620,8 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
List<MktLeadsAssigneds> mktLeadsAssignedsList = (List<MktLeadsAssigneds>) CollectionUtils.select(mktLeadsAssigneds, predicate);
BigDecimal defaultCommission = BigDecimal.ZERO;
defaultCommission = quarterGoal;
BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) {
String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd");
if (CommonUtil.isNullOrBlank(timeToClose)) {
......@@ -2671,9 +2673,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
}
//总预测值
BigDecimal quarterGoal = BigDecimal.ZERO;
BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
for (MktLeadsGoals leadsGoals : mktLeadsGoalsList) {
if (leadsGoals.getStatisticTimeUnit() == 3) {
//月目标
......@@ -2681,8 +2680,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
Integer monthNum = leadsGoals.getSeqTime();
if (Arrays.asList(quarter).contains(monthNum)) {
quarterGoal = quarterGoal.add(BigDecimal.valueOf(leadsGoals.getCommission()));
defaultPremium = defaultPremium.add(BigDecimal.valueOf(leadsGoals.getPremium()));
defaultPieces = defaultPieces + leadsGoals.getPieces();
}
}
}
......@@ -2692,7 +2689,8 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
List<MktLeadsAssigneds> mktLeadsAssignedsList = (List<MktLeadsAssigneds>) CollectionUtils.select(mktLeadsAssigneds, predicate);
BigDecimal defaultCommission = BigDecimal.ZERO;
defaultCommission = quarterGoal;
BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) {
String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd");
if (CommonUtil.isNullOrBlank(timeToClose)) {
......@@ -2738,12 +2736,12 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
BigDecimal defaultCommission = BigDecimal.ZERO;
BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
if (!mktLeadsGoalsList.isEmpty()) {
MktLeadsGoals leadsGoals = mktLeadsGoalsList.get(0);
defaultCommission = new BigDecimal(leadsGoals.getCommission());
defaultPremium = new BigDecimal(leadsGoals.getPremium());
defaultPieces = leadsGoals.getPieces();
}
// if (!mktLeadsGoalsList.isEmpty()) {
// MktLeadsGoals leadsGoals = mktLeadsGoalsList.get(0);
// defaultCommission = new BigDecimal(leadsGoals.getCommission());
// defaultPremium = new BigDecimal(leadsGoals.getPremium());
// defaultPieces = leadsGoals.getPieces();
// }
for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) {
String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd");
if (CommonUtil.isNullOrBlank(timeToClose)) {
......@@ -3033,7 +3031,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
AclPractitionerSubordinateSystem subordinateSystem = aclPractitionerSubordinateSystemDALService.findByPractitionerId(practitionerId);
if (subordinateSystem != null) {
Long subordinateSystemId = subordinateSystem.getId();
statisticInfo.setCompletionRate(getCompletionRate(null, subordinateSystemId, fycSum, time));
getCompletionRate(statisticInfo,null, subordinateSystemId, fycSum, time);
responseVO.setId(subordinateSystemId);
responseVO.setSubordinateSystemName(subordinateSystem.getName());
responseVO.setContactName(subordinateSystem.getContactName());
......@@ -3357,6 +3355,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
for (AclPractitioner practitioner : practitionerList) {
double fyp = 0D, fyc = 0D;
int count = 0;
double targetFyc = 0D;
double targetFyp = 0D;
int targetCount = 0;
practitionerIdForMember = practitioner.getId();
practitionerLevelId = practitionerSettingMap.get(practitionerIdForMember);
memberInfo = new SubordinateSystemMemberInfo();
......@@ -3369,10 +3370,16 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
fyc = Double.valueOf(customerFortuneStatisticsItem.getFyc());
fyp = Double.valueOf(customerFortuneStatisticsItem.getFyp());
count = Integer.valueOf(customerFortuneStatisticsItem.getCount());
targetFyc = Double.valueOf(customerFortuneStatisticsItem.getTargetFyc());
targetFyp = Double.valueOf(customerFortuneStatisticsItem.getTargetFyp());
targetCount = Integer.valueOf(customerFortuneStatisticsItem.getTargetCount());
}
memberInfo.setFyc(CommonUtil.doubleFormat(fyc, 2));
memberInfo.setFyp(CommonUtil.doubleFormat(fyp, 2));
memberInfo.setCount(count);
memberInfo.setTargetFyc(CommonUtil.doubleFormat(targetFyc, 2));
memberInfo.setTargetFyp(CommonUtil.doubleFormat(targetFyp, 2));
memberInfo.setTargetCount(targetCount);
memberInfoMap.put(practitionerIdMobileNoMap.get(practitionerIdForMember), memberInfo);
}
}
......@@ -3387,17 +3394,36 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
* @param time 时间
* @return 完成率
*/
private Double getCompletionRate(Long practitionerId, Long subordinateSystemId, Double fycSum, Integer time) {
if ((practitionerId != null || subordinateSystemId != null) && fycSum != null && time != null && fycSum > 0) {
@SuppressWarnings("unchecked")
private void getCompletionRate(SubordinateSystemStatisticInfo statisticInfo,Long practitionerId, Long subordinateSystemId, Double fycSum, Integer time) {
statisticInfo.setTargetFyc(0D);
statisticInfo.setTargetFyp(0D);
statisticInfo.setTargetCount(0);
if ((practitionerId != null || subordinateSystemId != null) && fycSum != null && time != null && fycSum > 0) {
List<MktLeadsGoals> leadsGoals;
Double goalsPremium = null;
if (time == 2) {
if (time == 2 || time == 4) {
if (practitionerId != null) {
leadsGoals = mktLeadsGoalsDALService.findByTypeAndTimeUnitAndPractitionerId(1, 1, practitionerId);
} else {
leadsGoals = mktLeadsGoalsDALService.findByTypeAndTimeUnitAndSubordinateSystemId(2, 1, subordinateSystemId);
}
goalsPremium = (leadsGoals != null && leadsGoals.size() > 0) ? leadsGoals.get(0).getCommission() : null;
if(leadsGoals != null && leadsGoals.size() > 0){
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
if (time == 4) {
year = year - 1;
}
for (MktLeadsGoals mktLeadsGoals : leadsGoals) {
if(mktLeadsGoals.getCurrentYear() != null && mktLeadsGoals.getCurrentYear().intValue() == year){
goalsPremium = mktLeadsGoals.getCommission();
statisticInfo.setTargetFyc(mktLeadsGoals.getCommission());
statisticInfo.setTargetFyp(mktLeadsGoals.getPremium());
statisticInfo.setTargetCount(mktLeadsGoals.getPieces());
break;
}
}
}
} else {
if (practitionerId != null) {
leadsGoals = mktLeadsGoalsDALService.findByTypeAndTimeUnitAndPractitionerId(1, 3, practitionerId);
......@@ -3406,28 +3432,43 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
}
Calendar calendar = Calendar.getInstance();
int month = calendar.get(Calendar.MONTH) + 1;
BeanPropertyValueEqualsPredicate predicateClause = new BeanPropertyValueEqualsPredicate("currentYear", calendar.get(Calendar.YEAR));
leadsGoals = (List<MktLeadsGoals>)CollectionUtils.select(leadsGoals, predicateClause);
List<Integer> monthList = getMonthListForQuarter(month);
for (MktLeadsGoals item : leadsGoals) {
if (time == 1) {//月份
if (item.getSeqTime() == month) {
goalsPremium = item.getCommission();
statisticInfo.setTargetFyc(item.getCommission());
statisticInfo.setTargetFyp(item.getPremium());
statisticInfo.setTargetCount(item.getPieces());
break;
}
} else {//季度
if (monthList.contains(item.getSeqTime())) {
goalsPremium = (goalsPremium == null) ? item.getCommission() : goalsPremium + item.getCommission();
if(statisticInfo.getTargetFyc() != null){
statisticInfo.setTargetFyc(item.getCommission() + statisticInfo.getTargetFyc());
}
if(statisticInfo.getTargetFyp() != null){
statisticInfo.setTargetFyp(item.getPremium() + statisticInfo.getTargetFyp());
}
if(statisticInfo.getTargetCount() != null){
statisticInfo.setTargetCount(item.getPieces() + statisticInfo.getTargetCount());
}
}
}
}
}
statisticInfo.setCompletionRate(0D);
if (goalsPremium != null && goalsPremium > 0) {
BigDecimal fycBigDecimal = new BigDecimal(fycSum), goalsBigDecimal = new BigDecimal(goalsPremium);
return CommonUtil.doubleFormat(fycBigDecimal.divide(goalsBigDecimal, 4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100, 2);
statisticInfo.setCompletionRate(CommonUtil.doubleFormat(fycBigDecimal.divide(goalsBigDecimal, 4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100, 2));
}
}
return 0D;
}
}
private List<Integer> getMonthListForQuarter(int month) {
if (month < 4) {
return Arrays.asList(1, 2, 3);
......@@ -4960,5 +5001,87 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
cells.setNoWrap(false);
return cells;
}
/**
* 逻辑删除商机
* @param OpportunityDeleteRequestVO
* @return CommonResultIDResponseVO
* @author Yan Wenyang
*/
public CommonResultIDResponseVO updateOpportunity(OpportunityDeleteRequestVO requestVO){
CommonResultIDResponseVO resp = new CommonResultIDResponseVO();
Long practitionerId = requestVO.getPractitionerId();
if (practitionerId == null) {
resp.setCommonResult(new CommonResult(false, "经纪人ID不可为空"));
return resp;
}
if (requestVO.getOpportunityId() == null) {
resp.setCommonResult(new CommonResult(false, "商机ID不可为空"));
return resp;
}
//等保调整
List<AclCustomer> findByObjSortable = aclPractitionerDALService.getAclCustomers(practitionerId, null);
if (null == findByObjSortable) {
resp.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("630028")));
return resp;
}
resp.setId(requestVO.getOpportunityId());
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
//物理删除需要更新的表
// SELECT t.id, t.customer_id, t.* FROM ag_mkt_leads_assigneds t WHERE t.id ='219' AND t.is_active ='1';;
// SELECT t.* FROM ag_mkt_leads_pool t WHERE t.customer_id ='29397' AND t.is_active ='1';
// SELECT t.* FROM ag_mkt_leads_assigned_track t WHERE t.leads_assigned_id ='219' AND t.is_active ='1';;
// SELECT t.* FROM ag_mkt_leads_expert_request t WHERE t.leads_assigned_id ='219' AND t.is_active ='1';;
// SELECT t.* FROM ag_mkt_leads_expert_assign t WHERE t.leads_expert_request_id='19' AND t.is_active ='1';;
MktLeadsAssigneds mktLeadsAssigneds = mktLeadsAssignedsDALService.findByLeadsAssignedId(requestVO.getOpportunityId());
if(mktLeadsAssigneds != null && mktLeadsAssigneds.getIsActive() != null && mktLeadsAssigneds.getIsActive().intValue() == 1){
mktLeadsAssigneds.setIsActive(0);
mktLeadsAssigneds.setUpdatedAt(new Date());
mktLeadsAssigneds.setUpdatedBy(requestVO.getPractitionerId());
mktLeadsAssignedsDALService.updateMktLeadsAssigneds(mktLeadsAssigneds);
MktLeadsPool pool = mktLeadsPoolDALService.findByCustomerId(mktLeadsAssigneds.getCustomerId());
if (pool != null) {
pool.setIsActive(0);
mktLeadsPoolDALService.updateMktLeadsAssigneds(pool);
}
MktLeadsAssignedTrack mktLeadsAssignedTrack = new MktLeadsAssignedTrack();
mktLeadsAssignedTrack.setLeadsAssignedId(mktLeadsAssigneds.getId());
mktLeadsAssignedTrack.setIsActive(1);
List<MktLeadsAssignedTrack> mktLeadsAssignedTracks = mktLeadsAssignedTrackDALService.findByMktLeadsAssignedTrack(mktLeadsAssignedTrack);
if(mktLeadsAssignedTracks != null && mktLeadsAssignedTracks.size() > 0 ){
for (MktLeadsAssignedTrack item : mktLeadsAssignedTracks) {
item.setIsActive(0);
item.setUpdatedAt(new Date());
item.setUpdatedBy(requestVO.getPractitionerId());
mktLeadsAssignedTrackDALService.updateTrack(item);
}
}
//判断此商机专家支持是否已经申请
MktLeadsExpertRequest isExpertRequest = mktLeadsExpertRequestDALService.findByLeadsAssignedId(mktLeadsAssigneds.getId());
if(isExpertRequest != null){
//有申请专家 查询是否指派专家
MktLeadsExpertAssign mktLeadsExpertAssign = mktLeadsExpertAssignDALService.findByLeadsExpertRequestId(isExpertRequest.getId());
if (mktLeadsExpertAssign != null) {
mktLeadsExpertAssign.setIsActive(0);
mktLeadsExpertAssign.setUpdatedAt(new Date());
mktLeadsExpertAssign.setUpdatedBy(requestVO.getPractitionerId());
mktLeadsExpertAssignDALService.updateByPrimaryKeySelective(mktLeadsExpertAssign);
}
isExpertRequest.setIsActive(0);
isExpertRequest.setUpdatedAt(new Date());
isExpertRequest.setUpdatedBy(requestVO.getPractitionerId());
mktLeadsExpertRequestDALService.updateByPrimaryKeySelective(isExpertRequest);
}
}else{
resp.setCommonResult(new CommonResult(false, "该商机不是有效的商机"));
return resp;
}
return resp;
}
}
package com.yd.api.practitioner.vo.opportunity;
import lombok.Data;
@Data
public class OpportunityDeleteRequestVO {
private Long practitionerId;//经纪人ID
private Long opportunityId;//商机Id
}
......@@ -12,6 +12,9 @@ public class AclCustomerFortuneStatistics implements Serializable {
private Integer count;
private Double fyp;
private Double fyc;
private Double targetFyc; //目标FYP
private Double targetFyp; //目标FYC
private Integer targetCount;//目标件数
public Integer getRank() {
return rank;
......@@ -92,6 +95,30 @@ public class AclCustomerFortuneStatistics implements Serializable {
public void setFyc(Double fyc) {
this.fyc = fyc;
}
public Double getTargetFyc() {
return targetFyc;
}
private static final long serialVersionUID = 1L;
public void setTargetFyc(Double targetFyc) {
this.targetFyc = targetFyc;
}
public Double getTargetFyp() {
return targetFyp;
}
public void setTargetFyp(Double targetFyp) {
this.targetFyp = targetFyp;
}
public Integer getTargetCount() {
return targetCount;
}
public void setTargetCount(Integer targetCount) {
this.targetCount = targetCount;
}
private static final long serialVersionUID = 1L;
}
......@@ -8,6 +8,9 @@ public class SubordinateSystemMemberInfo {
private Double fyp;
private Double fyc;
private Integer count;
private Double targetFyc; //目标FYP
private Double targetFyp; //目标FYC
private Integer targetCount;//目标件数
public Long getPractitionerId() {
return practitionerId;
......@@ -64,4 +67,29 @@ public class SubordinateSystemMemberInfo {
public void setCount(Integer count) {
this.count = count;
}
public Double getTargetFyc() {
return targetFyc;
}
public void setTargetFyc(Double targetFyc) {
this.targetFyc = targetFyc;
}
public Double getTargetFyp() {
return targetFyp;
}
public void setTargetFyp(Double targetFyp) {
this.targetFyp = targetFyp;
}
public Integer getTargetCount() {
return targetCount;
}
public void setTargetCount(Integer targetCount) {
this.targetCount = targetCount;
}
}
......@@ -2,7 +2,7 @@ package com.yd.api.practitioner.vo.subordinate;
public class SubordinateSystemMemberQueryRequestVO {
private Long practitionerId;
private Integer time;//1=month,3=quarter,2=year
private Integer time;//1=month,3=quarter,2=year,4=去年
private Integer type;//1=online,2=offLine
......
......@@ -5,6 +5,9 @@ public class SubordinateSystemStatisticInfo {
private Double fyp;
private Integer count;
private Double completionRate;
private Double targetFyc;//目标FYP
private Double targetFyp;//目标FYC,目标件数
private Integer targetCount;//目标件数
public Double getFyc() {
return fyc;
......@@ -37,4 +40,29 @@ public class SubordinateSystemStatisticInfo {
public void setCompletionRate(Double completionRate) {
this.completionRate = completionRate;
}
public Double getTargetFyc() {
return targetFyc;
}
public void setTargetFyc(Double targetFyc) {
this.targetFyc = targetFyc;
}
public Double getTargetFyp() {
return targetFyp;
}
public void setTargetFyp(Double targetFyp) {
this.targetFyp = targetFyp;
}
public Integer getTargetCount() {
return targetCount;
}
public void setTargetCount(Integer targetCount) {
this.targetCount = targetCount;
}
}
package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.marketing.MktLeadsExpertAssign;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yd.dal.entity.marketing.MktLeadsExpertAssign;
public interface MktLeadsExpertAssignMapper {
int deleteByPrimaryKey(Long id);
......
package com.yd.dal.service.marketing.Impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yd.dal.entity.marketing.MktLeadsExpertAssign;
import com.yd.dal.mapper.marketing.MktLeadsExpertAssignMapper;
import com.yd.dal.service.marketing.MktLeadsExpertAssignDALService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service("mktLeadsExpertAssignDALService")
public class MktLeadsExpertAssignDALServiceImpl implements MktLeadsExpertAssignDALService {
......@@ -17,4 +18,10 @@ public class MktLeadsExpertAssignDALServiceImpl implements MktLeadsExpertAssignD
public MktLeadsExpertAssign findByLeadsExpertRequestId(Long mktLeadsExpertRequestId) {
return mktLeadsExpertAssignMapper.selectByLeadsExpertRequestId(mktLeadsExpertRequestId);
}
@Override
public int updateByPrimaryKeySelective(MktLeadsExpertAssign mktLeadsExpertAssign) {
return mktLeadsExpertAssignMapper.updateByPrimaryKeySelective(mktLeadsExpertAssign);
}
}
......@@ -27,4 +27,9 @@ public class MktLeadsExpertRequestDALServiceImpl implements MktLeadsExpertReques
public MktLeadsExpertRequest findByCustomerId(Long customerId) {
return mktLeadsExpertRequestMapper.selectByCustomerId(customerId);
}
@Override
public int updateByPrimaryKeySelective(MktLeadsExpertRequest mktLeadsExpertRequest) {
return mktLeadsExpertRequestMapper.updateByPrimaryKeySelective(mktLeadsExpertRequest);
}
}
package com.yd.dal.service.marketing.Impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statistics.LeadsStatisticsInfo;
import com.yd.api.agms.vo.statistics.statementData;
import com.yd.dal.entity.leads.LeadsStatusInfo;
import com.yd.dal.entity.marketing.MktLeadsPool;
import com.yd.dal.mapper.marketing.MktLeadsPoolMapper;
import com.yd.dal.service.marketing.MktLeadsPoolDALService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("mktLeadsPoolDALService")
public class MktLeadsPoolDALServiceImpl implements MktLeadsPoolDALService {
......@@ -56,4 +57,9 @@ public class MktLeadsPoolDALServiceImpl implements MktLeadsPoolDALService {
PageInfo<LeadsStatisticsInfo> pageInfo = new PageInfo<>(statementData);
return pageInfo;
}
@Override
public void updateMktLeadsAssigneds(MktLeadsPool pool){
mktLeadsPoolMapper.updateByPrimaryKeySelective(pool);
}
}
......@@ -4,4 +4,6 @@ import com.yd.dal.entity.marketing.MktLeadsExpertAssign;
public interface MktLeadsExpertAssignDALService {
MktLeadsExpertAssign findByLeadsExpertRequestId(Long mktLeadsExpertRequestId);
int updateByPrimaryKeySelective(MktLeadsExpertAssign mktLeadsExpertAssign);
}
......@@ -8,4 +8,7 @@ public interface MktLeadsExpertRequestDALService {
MktLeadsExpertRequest findByLeadsAssignedId(Long assignedId);
MktLeadsExpertRequest findByCustomerId(Long customerId);
int updateByPrimaryKeySelective(MktLeadsExpertRequest mktLeadsExpertRequest);
}
package com.yd.dal.service.marketing;
import java.util.List;
import java.util.Map;
import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statistics.LeadsStatisticsInfo;
import com.yd.dal.entity.marketing.MktLeadsPool;
import java.util.List;
import java.util.Map;
public interface MktLeadsPoolDALService {
MktLeadsPool findByCustomerId(Long customerId);
......@@ -19,4 +19,6 @@ public interface MktLeadsPoolDALService {
Map<Long, Long> findLeadsStatusMap();
PageInfo<LeadsStatisticsInfo> findByConditionPage(int pageNum, int size, Integer isStatement, Integer leadsStatus, Integer expertApplyStatus, String leadsStartTime, String leadsEndTime);
void updateMktLeadsAssigneds(MktLeadsPool pool);
}
......@@ -978,7 +978,31 @@
ifnull(COUNT(f.id),0) count ,
ifnull(SUM(f.order_price),0) FYP ,
ifnull(SUM(f.fyc_amount),0) FYC ,
s.practitioner_level practitionerLevelId
s.practitioner_level practitionerLevelId,
(select ifnull(sum(t.commission),0) from ag_mkt_leads_goals t where t.practitioner_id=p.id and t.goals_type=1 and t.is_active=1
<choose>
<when test="time == 1">
and t.statistic_time_unit=3
and t.current_year=year(now())
and t.seq_time=month(now())
</when>
<when test="time == 3">
and t.statistic_time_unit=3
and t.current_year=year(now())
and quarter(concat(t.current_year,'-',t.seq_time,'-01'))=quarter(now())
</when>
<when test="time == 4">
and t.statistic_time_unit=1
and t.current_year=year(now())-1
</when>
<otherwise>
and t.statistic_time_unit=1
and t.current_year=year(now())
</otherwise>
</choose>
) targetFyc,
0 targetFyp,
0 targetCount
FROM
((ag_acl_practitioner_setting s LEFT JOIN ag_acl_practitioner p ON s.practitioner_id = p.id)
INNER JOIN ag_acl_customer_fortune f ON f.customer_id = p.customer_id and f.drop_option_code in('S01','C01') )
......@@ -992,6 +1016,9 @@
<when test="time == 3">
and QUARTER(f.order_date) = QUARTER(NOW()) AND year(f.order_date)=year(now())
</when>
<when test="time == 4">
and YEAR(f.order_date) = YEAR(now())-1
</when>
<otherwise>
and YEAR(f.order_date) = YEAR(now())
</otherwise>
......
......@@ -1504,9 +1504,10 @@
if(ass.id is null ,0,1) expertType
FROM
ag_mkt_leads_assigneds a
left join ag_mkt_leads_expert_request r left join ag_mkt_leads_expert_assign ass on ass.leads_expert_request_id = r.id on r.customer_id = a.customer_id
LEFT JOIN ag_mkt_leads_pool p ON p.customer_id = a.customer_id
LEFT JOIN ag_acl_customer c ON c.id = a.customer_id
left join ag_mkt_leads_expert_request r on r.customer_id = a.customer_id and r.is_active =1
left join ag_mkt_leads_expert_assign ass on ass.leads_expert_request_id = r.id and ass.is_active =1
left join ag_mkt_leads_pool p ON p.customer_id = a.customer_id and p.is_active =1
left join ag_acl_customer c ON c.id = a.customer_id
where a.is_active=1
<if test="practitionerId != null">
and a.assigned_practitioner_id = #{practitionerId}
......
......@@ -153,6 +153,7 @@
<include refid="Base_Column_List" />
from ag_mkt_leads_pool
where customer_id = #{customerId,jdbcType=BIGINT}
and is_active=1
</select>
<select id="findALLByDate" resultType="com.yd.api.agms.vo.statistics.LeadsStatisticsInfo">
select c.id as leadsCustomerId,
......
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