Commit b49c4138 by wenyang

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

2.团队业绩,加一个“去年”的时间段
3.团队业绩,进入后,上面的面板增加3列 目标FYP,目标FYC,完成率 。下面的排名,增加1列,目标FYC
parent dc267e14
...@@ -757,4 +757,19 @@ public class PractitionerController { ...@@ -757,4 +757,19 @@ public class PractitionerController {
result.setData(responseVO); result.setData(responseVO);
return result; 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 { ...@@ -274,4 +274,13 @@ public interface PractitionerService {
* @author Yan Wenyang * @author Yan Wenyang
*/ */
CommonResultIDResponseVO signUnionSales(SignUnionSalesRequestVO requestVO); 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; ...@@ -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.OpportunityBasicInformationInfo;
import com.yd.api.practitioner.vo.opportunity.OpportunityConsultationInfo; import com.yd.api.practitioner.vo.opportunity.OpportunityConsultationInfo;
import com.yd.api.practitioner.vo.opportunity.OpportunityCustomerTag; 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.OpportunityRecordInfo;
import com.yd.api.practitioner.vo.opportunity.OpportunityRecordSituationInfo; import com.yd.api.practitioner.vo.opportunity.OpportunityRecordSituationInfo;
import com.yd.api.practitioner.vo.opportunity.OpportunityScore; import com.yd.api.practitioner.vo.opportunity.OpportunityScore;
...@@ -795,8 +796,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -795,8 +796,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
// fycOther = practitionerRankInfo != null ? practitionerRankInfo.getFyc() : 0D; // fycOther = practitionerRankInfo != null ? practitionerRankInfo.getFyc() : 0D;
// Double fycSum = CommonUtil.doubleFormat(fyc + fycOther, 2); // Double fycSum = CommonUtil.doubleFormat(fyc + fycOther, 2);
if (fyc != 0) { if (fyc != 0) {
Double completeRate = getCompletionRate(practitionerId, null, fyc, time); SubordinateSystemStatisticInfo statisticInfo = new SubordinateSystemStatisticInfo();
practitionerInfo.setCompletionRate(completeRate); getCompletionRate(statisticInfo,practitionerId, null, fyc, time);
practitionerInfo.setCompletionRate(statisticInfo.getCompletionRate());
} }
} }
} }
...@@ -1146,6 +1148,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1146,6 +1148,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
MktLeadsAssignedTrack mktLeadsAssignedTrack = new MktLeadsAssignedTrack(); MktLeadsAssignedTrack mktLeadsAssignedTrack = new MktLeadsAssignedTrack();
mktLeadsAssignedTrack.setPractitionerId(practitionerId); mktLeadsAssignedTrack.setPractitionerId(practitionerId);
mktLeadsAssignedTrack.setCustomerId(customerId); mktLeadsAssignedTrack.setCustomerId(customerId);
mktLeadsAssignedTrack.setIsActive(1);
PageHelper.orderBy("created_at DESC"); PageHelper.orderBy("created_at DESC");
List<MktLeadsAssignedTrack> mktLeadsAssignedTracks = mktLeadsAssignedTrackDALService.findByMktLeadsAssignedTrack(mktLeadsAssignedTrack); List<MktLeadsAssignedTrack> mktLeadsAssignedTracks = mktLeadsAssignedTrackDALService.findByMktLeadsAssignedTrack(mktLeadsAssignedTrack);
Long opportunityDropOptionId = 0L; Long opportunityDropOptionId = 0L;
...@@ -1160,6 +1163,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1160,6 +1163,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
MktLeadsAssigneds mktLeadsAssigneds = new MktLeadsAssigneds(); MktLeadsAssigneds mktLeadsAssigneds = new MktLeadsAssigneds();
mktLeadsAssigneds.setCustomerId(customerId); mktLeadsAssigneds.setCustomerId(customerId);
mktLeadsAssigneds.setAssignedPractitionerId(practitionerId); mktLeadsAssigneds.setAssignedPractitionerId(practitionerId);
mktLeadsAssigneds.setIsActive(1);
List<MktLeadsAssigneds> mktLeadsAssignedsList = mktLeadsAssignedsDALService.findByMktLeadsAssigneds(mktLeadsAssigneds); List<MktLeadsAssigneds> mktLeadsAssignedsList = mktLeadsAssignedsDALService.findByMktLeadsAssigneds(mktLeadsAssigneds);
mktLeadsAssigneds = mktLeadsAssignedsList.get(0); mktLeadsAssigneds = mktLeadsAssignedsList.get(0);
String leadsAssignedsCustomerName = mktLeadsAssigneds.getCustomerName(); String leadsAssignedsCustomerName = mktLeadsAssigneds.getCustomerName();
...@@ -1713,6 +1717,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1713,6 +1717,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
if (aclCustomer != null) { if (aclCustomer != null) {
MktLeadsAssigneds mktLeadsAssigneds = new MktLeadsAssigneds(); MktLeadsAssigneds mktLeadsAssigneds = new MktLeadsAssigneds();
mktLeadsAssigneds.setCustomerId(aclCustomer.getId()); mktLeadsAssigneds.setCustomerId(aclCustomer.getId());
mktLeadsAssigneds.setIsActive(1);
List<MktLeadsAssigneds> mktLeadsAssignedsList = mktLeadsAssignedsDALService.findByMktLeadsAssigneds(mktLeadsAssigneds); List<MktLeadsAssigneds> mktLeadsAssignedsList = mktLeadsAssignedsDALService.findByMktLeadsAssigneds(mktLeadsAssigneds);
if (!mktLeadsAssignedsList.isEmpty()) { if (!mktLeadsAssignedsList.isEmpty()) {
...@@ -2604,13 +2609,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -2604,13 +2609,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
} }
//总预测值 //总预测值
BigDecimal quarterGoal = BigDecimal.ZERO; BigDecimal quarterGoal = BigDecimal.ZERO;
BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
for (MktLeadsGoals leadsGoals : mktLeadsGoalsList) { for (MktLeadsGoals leadsGoals : mktLeadsGoalsList) {
if (leadsGoals.getStatisticTimeUnit() == 1) { if (leadsGoals.getStatisticTimeUnit() == 1) {
quarterGoal = quarterGoal.add(BigDecimal.valueOf(leadsGoals.getCommission())); 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. ...@@ -2619,7 +2620,8 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
List<MktLeadsAssigneds> mktLeadsAssignedsList = (List<MktLeadsAssigneds>) CollectionUtils.select(mktLeadsAssigneds, predicate); List<MktLeadsAssigneds> mktLeadsAssignedsList = (List<MktLeadsAssigneds>) CollectionUtils.select(mktLeadsAssigneds, predicate);
BigDecimal defaultCommission = BigDecimal.ZERO; BigDecimal defaultCommission = BigDecimal.ZERO;
defaultCommission = quarterGoal; BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) { for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) {
String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd"); String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd");
if (CommonUtil.isNullOrBlank(timeToClose)) { if (CommonUtil.isNullOrBlank(timeToClose)) {
...@@ -2671,9 +2673,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -2671,9 +2673,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
} }
//总预测值 //总预测值
BigDecimal quarterGoal = BigDecimal.ZERO; BigDecimal quarterGoal = BigDecimal.ZERO;
BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
for (MktLeadsGoals leadsGoals : mktLeadsGoalsList) { for (MktLeadsGoals leadsGoals : mktLeadsGoalsList) {
if (leadsGoals.getStatisticTimeUnit() == 3) { if (leadsGoals.getStatisticTimeUnit() == 3) {
//月目标 //月目标
...@@ -2681,8 +2680,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -2681,8 +2680,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
Integer monthNum = leadsGoals.getSeqTime(); Integer monthNum = leadsGoals.getSeqTime();
if (Arrays.asList(quarter).contains(monthNum)) { if (Arrays.asList(quarter).contains(monthNum)) {
quarterGoal = quarterGoal.add(BigDecimal.valueOf(leadsGoals.getCommission())); 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. ...@@ -2692,7 +2689,8 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
List<MktLeadsAssigneds> mktLeadsAssignedsList = (List<MktLeadsAssigneds>) CollectionUtils.select(mktLeadsAssigneds, predicate); List<MktLeadsAssigneds> mktLeadsAssignedsList = (List<MktLeadsAssigneds>) CollectionUtils.select(mktLeadsAssigneds, predicate);
BigDecimal defaultCommission = BigDecimal.ZERO; BigDecimal defaultCommission = BigDecimal.ZERO;
defaultCommission = quarterGoal; BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0;
for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) { for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) {
String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd"); String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd");
if (CommonUtil.isNullOrBlank(timeToClose)) { if (CommonUtil.isNullOrBlank(timeToClose)) {
...@@ -2738,12 +2736,12 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -2738,12 +2736,12 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
BigDecimal defaultCommission = BigDecimal.ZERO; BigDecimal defaultCommission = BigDecimal.ZERO;
BigDecimal defaultPremium = BigDecimal.ZERO; BigDecimal defaultPremium = BigDecimal.ZERO;
Integer defaultPieces = 0; Integer defaultPieces = 0;
if (!mktLeadsGoalsList.isEmpty()) { // if (!mktLeadsGoalsList.isEmpty()) {
MktLeadsGoals leadsGoals = mktLeadsGoalsList.get(0); // MktLeadsGoals leadsGoals = mktLeadsGoalsList.get(0);
defaultCommission = new BigDecimal(leadsGoals.getCommission()); // defaultCommission = new BigDecimal(leadsGoals.getCommission());
defaultPremium = new BigDecimal(leadsGoals.getPremium()); // defaultPremium = new BigDecimal(leadsGoals.getPremium());
defaultPieces = leadsGoals.getPieces(); // defaultPieces = leadsGoals.getPieces();
} // }
for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) { for (MktLeadsAssigneds leadsAssigneds : mktLeadsAssignedsList) {
String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd"); String timeToClose = CommonUtil.dateParseString(leadsAssigneds.getTimeToClose(), "yyyy-MM-dd");
if (CommonUtil.isNullOrBlank(timeToClose)) { if (CommonUtil.isNullOrBlank(timeToClose)) {
...@@ -3033,7 +3031,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -3033,7 +3031,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
AclPractitionerSubordinateSystem subordinateSystem = aclPractitionerSubordinateSystemDALService.findByPractitionerId(practitionerId); AclPractitionerSubordinateSystem subordinateSystem = aclPractitionerSubordinateSystemDALService.findByPractitionerId(practitionerId);
if (subordinateSystem != null) { if (subordinateSystem != null) {
Long subordinateSystemId = subordinateSystem.getId(); Long subordinateSystemId = subordinateSystem.getId();
statisticInfo.setCompletionRate(getCompletionRate(null, subordinateSystemId, fycSum, time)); getCompletionRate(statisticInfo,null, subordinateSystemId, fycSum, time);
responseVO.setId(subordinateSystemId); responseVO.setId(subordinateSystemId);
responseVO.setSubordinateSystemName(subordinateSystem.getName()); responseVO.setSubordinateSystemName(subordinateSystem.getName());
responseVO.setContactName(subordinateSystem.getContactName()); responseVO.setContactName(subordinateSystem.getContactName());
...@@ -3357,6 +3355,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -3357,6 +3355,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
for (AclPractitioner practitioner : practitionerList) { for (AclPractitioner practitioner : practitionerList) {
double fyp = 0D, fyc = 0D; double fyp = 0D, fyc = 0D;
int count = 0; int count = 0;
double targetFyc = 0D;
double targetFyp = 0D;
int targetCount = 0;
practitionerIdForMember = practitioner.getId(); practitionerIdForMember = practitioner.getId();
practitionerLevelId = practitionerSettingMap.get(practitionerIdForMember); practitionerLevelId = practitionerSettingMap.get(practitionerIdForMember);
memberInfo = new SubordinateSystemMemberInfo(); memberInfo = new SubordinateSystemMemberInfo();
...@@ -3369,10 +3370,16 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -3369,10 +3370,16 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
fyc = Double.valueOf(customerFortuneStatisticsItem.getFyc()); fyc = Double.valueOf(customerFortuneStatisticsItem.getFyc());
fyp = Double.valueOf(customerFortuneStatisticsItem.getFyp()); fyp = Double.valueOf(customerFortuneStatisticsItem.getFyp());
count = Integer.valueOf(customerFortuneStatisticsItem.getCount()); 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.setFyc(CommonUtil.doubleFormat(fyc, 2));
memberInfo.setFyp(CommonUtil.doubleFormat(fyp, 2)); memberInfo.setFyp(CommonUtil.doubleFormat(fyp, 2));
memberInfo.setCount(count); memberInfo.setCount(count);
memberInfo.setTargetFyc(CommonUtil.doubleFormat(targetFyc, 2));
memberInfo.setTargetFyp(CommonUtil.doubleFormat(targetFyp, 2));
memberInfo.setTargetCount(targetCount);
memberInfoMap.put(practitionerIdMobileNoMap.get(practitionerIdForMember), memberInfo); memberInfoMap.put(practitionerIdMobileNoMap.get(practitionerIdForMember), memberInfo);
} }
} }
...@@ -3387,17 +3394,36 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -3387,17 +3394,36 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
* @param time 时间 * @param time 时间
* @return 完成率 * @return 完成率
*/ */
private Double getCompletionRate(Long practitionerId, Long subordinateSystemId, Double fycSum, Integer time) { @SuppressWarnings("unchecked")
if ((practitionerId != null || subordinateSystemId != null) && fycSum != null && time != null && fycSum > 0) { 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; List<MktLeadsGoals> leadsGoals;
Double goalsPremium = null; Double goalsPremium = null;
if (time == 2) { if (time == 2 || time == 4) {
if (practitionerId != null) { if (practitionerId != null) {
leadsGoals = mktLeadsGoalsDALService.findByTypeAndTimeUnitAndPractitionerId(1, 1, practitionerId); leadsGoals = mktLeadsGoalsDALService.findByTypeAndTimeUnitAndPractitionerId(1, 1, practitionerId);
} else { } else {
leadsGoals = mktLeadsGoalsDALService.findByTypeAndTimeUnitAndSubordinateSystemId(2, 1, subordinateSystemId); 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 { } else {
if (practitionerId != null) { if (practitionerId != null) {
leadsGoals = mktLeadsGoalsDALService.findByTypeAndTimeUnitAndPractitionerId(1, 3, practitionerId); leadsGoals = mktLeadsGoalsDALService.findByTypeAndTimeUnitAndPractitionerId(1, 3, practitionerId);
...@@ -3406,28 +3432,43 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -3406,28 +3432,43 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
} }
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
int month = calendar.get(Calendar.MONTH) + 1; 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); List<Integer> monthList = getMonthListForQuarter(month);
for (MktLeadsGoals item : leadsGoals) { for (MktLeadsGoals item : leadsGoals) {
if (time == 1) {//月份 if (time == 1) {//月份
if (item.getSeqTime() == month) { if (item.getSeqTime() == month) {
goalsPremium = item.getCommission(); goalsPremium = item.getCommission();
statisticInfo.setTargetFyc(item.getCommission());
statisticInfo.setTargetFyp(item.getPremium());
statisticInfo.setTargetCount(item.getPieces());
break; break;
} }
} else {//季度 } else {//季度
if (monthList.contains(item.getSeqTime())) { if (monthList.contains(item.getSeqTime())) {
goalsPremium = (goalsPremium == null) ? item.getCommission() : goalsPremium + item.getCommission(); 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) { if (goalsPremium != null && goalsPremium > 0) {
BigDecimal fycBigDecimal = new BigDecimal(fycSum), goalsBigDecimal = new BigDecimal(goalsPremium); 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) { private List<Integer> getMonthListForQuarter(int month) {
if (month < 4) { if (month < 4) {
return Arrays.asList(1, 2, 3); return Arrays.asList(1, 2, 3);
...@@ -4960,5 +5001,87 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -4960,5 +5001,87 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
cells.setNoWrap(false); cells.setNoWrap(false);
return cells; 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 { ...@@ -12,6 +12,9 @@ public class AclCustomerFortuneStatistics implements Serializable {
private Integer count; private Integer count;
private Double fyp; private Double fyp;
private Double fyc; private Double fyc;
private Double targetFyc; //目标FYP
private Double targetFyp; //目标FYC
private Integer targetCount;//目标件数
public Integer getRank() { public Integer getRank() {
return rank; return rank;
...@@ -92,6 +95,30 @@ public class AclCustomerFortuneStatistics implements Serializable { ...@@ -92,6 +95,30 @@ public class AclCustomerFortuneStatistics implements Serializable {
public void setFyc(Double fyc) { public void setFyc(Double fyc) {
this.fyc = 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 { ...@@ -8,6 +8,9 @@ public class SubordinateSystemMemberInfo {
private Double fyp; private Double fyp;
private Double fyc; private Double fyc;
private Integer count; private Integer count;
private Double targetFyc; //目标FYP
private Double targetFyp; //目标FYC
private Integer targetCount;//目标件数
public Long getPractitionerId() { public Long getPractitionerId() {
return practitionerId; return practitionerId;
...@@ -64,4 +67,29 @@ public class SubordinateSystemMemberInfo { ...@@ -64,4 +67,29 @@ public class SubordinateSystemMemberInfo {
public void setCount(Integer count) { public void setCount(Integer count) {
this.count = 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; ...@@ -2,7 +2,7 @@ package com.yd.api.practitioner.vo.subordinate;
public class SubordinateSystemMemberQueryRequestVO { public class SubordinateSystemMemberQueryRequestVO {
private Long practitionerId; 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 private Integer type;//1=online,2=offLine
......
...@@ -5,6 +5,9 @@ public class SubordinateSystemStatisticInfo { ...@@ -5,6 +5,9 @@ public class SubordinateSystemStatisticInfo {
private Double fyp; private Double fyp;
private Integer count; private Integer count;
private Double completionRate; private Double completionRate;
private Double targetFyc;//目标FYP
private Double targetFyp;//目标FYC,目标件数
private Integer targetCount;//目标件数
public Double getFyc() { public Double getFyc() {
return fyc; return fyc;
...@@ -37,4 +40,29 @@ public class SubordinateSystemStatisticInfo { ...@@ -37,4 +40,29 @@ public class SubordinateSystemStatisticInfo {
public void setCompletionRate(Double completionRate) { public void setCompletionRate(Double completionRate) {
this.completionRate = 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; package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.marketing.MktLeadsExpertAssign;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.yd.dal.entity.marketing.MktLeadsExpertAssign;
public interface MktLeadsExpertAssignMapper { public interface MktLeadsExpertAssignMapper {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
......
package com.yd.dal.service.marketing.Impl; 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.entity.marketing.MktLeadsExpertAssign;
import com.yd.dal.mapper.marketing.MktLeadsExpertAssignMapper; import com.yd.dal.mapper.marketing.MktLeadsExpertAssignMapper;
import com.yd.dal.service.marketing.MktLeadsExpertAssignDALService; import com.yd.dal.service.marketing.MktLeadsExpertAssignDALService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service("mktLeadsExpertAssignDALService") @Service("mktLeadsExpertAssignDALService")
public class MktLeadsExpertAssignDALServiceImpl implements MktLeadsExpertAssignDALService { public class MktLeadsExpertAssignDALServiceImpl implements MktLeadsExpertAssignDALService {
...@@ -17,4 +18,10 @@ public class MktLeadsExpertAssignDALServiceImpl implements MktLeadsExpertAssignD ...@@ -17,4 +18,10 @@ public class MktLeadsExpertAssignDALServiceImpl implements MktLeadsExpertAssignD
public MktLeadsExpertAssign findByLeadsExpertRequestId(Long mktLeadsExpertRequestId) { public MktLeadsExpertAssign findByLeadsExpertRequestId(Long mktLeadsExpertRequestId) {
return mktLeadsExpertAssignMapper.selectByLeadsExpertRequestId(mktLeadsExpertRequestId); return mktLeadsExpertAssignMapper.selectByLeadsExpertRequestId(mktLeadsExpertRequestId);
} }
@Override
public int updateByPrimaryKeySelective(MktLeadsExpertAssign mktLeadsExpertAssign) {
return mktLeadsExpertAssignMapper.updateByPrimaryKeySelective(mktLeadsExpertAssign);
}
} }
...@@ -27,4 +27,9 @@ public class MktLeadsExpertRequestDALServiceImpl implements MktLeadsExpertReques ...@@ -27,4 +27,9 @@ public class MktLeadsExpertRequestDALServiceImpl implements MktLeadsExpertReques
public MktLeadsExpertRequest findByCustomerId(Long customerId) { public MktLeadsExpertRequest findByCustomerId(Long customerId) {
return mktLeadsExpertRequestMapper.selectByCustomerId(customerId); return mktLeadsExpertRequestMapper.selectByCustomerId(customerId);
} }
@Override
public int updateByPrimaryKeySelective(MktLeadsExpertRequest mktLeadsExpertRequest) {
return mktLeadsExpertRequestMapper.updateByPrimaryKeySelective(mktLeadsExpertRequest);
}
} }
package com.yd.dal.service.marketing.Impl; 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.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statistics.LeadsStatisticsInfo; 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.leads.LeadsStatusInfo;
import com.yd.dal.entity.marketing.MktLeadsPool; import com.yd.dal.entity.marketing.MktLeadsPool;
import com.yd.dal.mapper.marketing.MktLeadsPoolMapper; import com.yd.dal.mapper.marketing.MktLeadsPoolMapper;
import com.yd.dal.service.marketing.MktLeadsPoolDALService; 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") @Service("mktLeadsPoolDALService")
public class MktLeadsPoolDALServiceImpl implements MktLeadsPoolDALService { public class MktLeadsPoolDALServiceImpl implements MktLeadsPoolDALService {
...@@ -56,4 +57,9 @@ public class MktLeadsPoolDALServiceImpl implements MktLeadsPoolDALService { ...@@ -56,4 +57,9 @@ public class MktLeadsPoolDALServiceImpl implements MktLeadsPoolDALService {
PageInfo<LeadsStatisticsInfo> pageInfo = new PageInfo<>(statementData); PageInfo<LeadsStatisticsInfo> pageInfo = new PageInfo<>(statementData);
return pageInfo; return pageInfo;
} }
@Override
public void updateMktLeadsAssigneds(MktLeadsPool pool){
mktLeadsPoolMapper.updateByPrimaryKeySelective(pool);
}
} }
...@@ -4,4 +4,6 @@ import com.yd.dal.entity.marketing.MktLeadsExpertAssign; ...@@ -4,4 +4,6 @@ import com.yd.dal.entity.marketing.MktLeadsExpertAssign;
public interface MktLeadsExpertAssignDALService { public interface MktLeadsExpertAssignDALService {
MktLeadsExpertAssign findByLeadsExpertRequestId(Long mktLeadsExpertRequestId); MktLeadsExpertAssign findByLeadsExpertRequestId(Long mktLeadsExpertRequestId);
int updateByPrimaryKeySelective(MktLeadsExpertAssign mktLeadsExpertAssign);
} }
...@@ -8,4 +8,7 @@ public interface MktLeadsExpertRequestDALService { ...@@ -8,4 +8,7 @@ public interface MktLeadsExpertRequestDALService {
MktLeadsExpertRequest findByLeadsAssignedId(Long assignedId); MktLeadsExpertRequest findByLeadsAssignedId(Long assignedId);
MktLeadsExpertRequest findByCustomerId(Long customerId); MktLeadsExpertRequest findByCustomerId(Long customerId);
int updateByPrimaryKeySelective(MktLeadsExpertRequest mktLeadsExpertRequest);
} }
package com.yd.dal.service.marketing; package com.yd.dal.service.marketing;
import java.util.List;
import java.util.Map;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statistics.LeadsStatisticsInfo; import com.yd.api.agms.vo.statistics.LeadsStatisticsInfo;
import com.yd.dal.entity.marketing.MktLeadsPool; import com.yd.dal.entity.marketing.MktLeadsPool;
import java.util.List;
import java.util.Map;
public interface MktLeadsPoolDALService { public interface MktLeadsPoolDALService {
MktLeadsPool findByCustomerId(Long customerId); MktLeadsPool findByCustomerId(Long customerId);
...@@ -19,4 +19,6 @@ public interface MktLeadsPoolDALService { ...@@ -19,4 +19,6 @@ public interface MktLeadsPoolDALService {
Map<Long, Long> findLeadsStatusMap(); Map<Long, Long> findLeadsStatusMap();
PageInfo<LeadsStatisticsInfo> findByConditionPage(int pageNum, int size, Integer isStatement, Integer leadsStatus, Integer expertApplyStatus, String leadsStartTime, String leadsEndTime); 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 @@ ...@@ -978,7 +978,31 @@
ifnull(COUNT(f.id),0) count , ifnull(COUNT(f.id),0) count ,
ifnull(SUM(f.order_price),0) FYP , ifnull(SUM(f.order_price),0) FYP ,
ifnull(SUM(f.fyc_amount),0) FYC , 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 FROM
((ag_acl_practitioner_setting s LEFT JOIN ag_acl_practitioner p ON s.practitioner_id = p.id) ((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') ) 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 @@ ...@@ -992,6 +1016,9 @@
<when test="time == 3"> <when test="time == 3">
and QUARTER(f.order_date) = QUARTER(NOW()) AND year(f.order_date)=year(now()) and QUARTER(f.order_date) = QUARTER(NOW()) AND year(f.order_date)=year(now())
</when> </when>
<when test="time == 4">
and YEAR(f.order_date) = YEAR(now())-1
</when>
<otherwise> <otherwise>
and YEAR(f.order_date) = YEAR(now()) and YEAR(f.order_date) = YEAR(now())
</otherwise> </otherwise>
......
...@@ -1504,9 +1504,10 @@ ...@@ -1504,9 +1504,10 @@
if(ass.id is null ,0,1) expertType if(ass.id is null ,0,1) expertType
FROM FROM
ag_mkt_leads_assigneds a 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_expert_request r on r.customer_id = a.customer_id and r.is_active =1
LEFT JOIN ag_mkt_leads_pool p ON p.customer_id = a.customer_id left join ag_mkt_leads_expert_assign ass on ass.leads_expert_request_id = r.id and ass.is_active =1
LEFT JOIN ag_acl_customer c ON c.id = a.customer_id 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 where a.is_active=1
<if test="practitionerId != null"> <if test="practitionerId != null">
and a.assigned_practitioner_id = #{practitionerId} and a.assigned_practitioner_id = #{practitionerId}
......
...@@ -153,6 +153,7 @@ ...@@ -153,6 +153,7 @@
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from ag_mkt_leads_pool from ag_mkt_leads_pool
where customer_id = #{customerId,jdbcType=BIGINT} where customer_id = #{customerId,jdbcType=BIGINT}
and is_active=1
</select> </select>
<select id="findALLByDate" resultType="com.yd.api.agms.vo.statistics.LeadsStatisticsInfo"> <select id="findALLByDate" resultType="com.yd.api.agms.vo.statistics.LeadsStatisticsInfo">
select c.id as leadsCustomerId, 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