Commit fdba8154 by yao.xiao

修改-经纪人跟进状态及新增经纪人条件

parent 8079bc6a
......@@ -526,11 +526,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//调查问卷答案,咨询服务
OpportunityConsultationInfo opportunityConsultationInfo = getOpportunityConsultation(requestVO);
//商机跟进ag_survey_analysis_sales_record表差字段
OpportunityRecordSituationInfo opportunityRecordSituationInfo = new OpportunityRecordSituationInfo();
List<OpportunityRecordInfo> opportunityRecordInfos = getOpportunityRecords(requestVO);
opportunityRecordSituationInfo.setStatus(getRecordStatus(opportunityRecordInfos));
opportunityRecordSituationInfo.setOpportunityRecordInfos(opportunityRecordInfos);
//商机得分详情
OpportunityScore opportunityScore = getOpportunityScore(opportunityRecordInfos);
responseVO.setOpportunityRecordInfos(opportunityRecordInfos);
responseVO.setOpportunityRecordSituationInfo(opportunityRecordSituationInfo);
responseVO.setOpportunityBasicInformationInfo(basicInformationInfo);
responseVO.setOpportunityConsultationInfo(opportunityConsultationInfo);
responseVO.setOpportunityScore(opportunityScore);
......@@ -538,6 +541,20 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
return responseVO;
}
private Long getRecordStatus(List<OpportunityRecordInfo> opportunityRecordInfos) {
Long mdDropOptionId = opportunityRecordInfos.get(0).getMdDropOptionId();
List<MdDropOptions> mdDropOptions = mdDropOptionsDALService.findByDropMasterCode("bizchance_promotion_action");
ConcurrentMap<String,Long> optionCodeToId = new ConcurrentHashMap<>();
for (MdDropOptions info : mdDropOptions){
optionCodeToId.put(info.getDropOptionCode(),info.getId());
}
Long refusedId = optionCodeToId.get("refused");
if (mdDropOptionId==refusedId){
return 1L;
}
return 0L;
}
private OpportunityScore getOpportunityScore(List<OpportunityRecordInfo> opportunityRecordInfos) {
OpportunityScore opportunityScore = new OpportunityScore();
Integer scoreDay = 0;
......@@ -1104,13 +1121,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
mktLeadsAssigneds.setCustomerId(aclCustomer.getId());
List<MktLeadsAssigneds> mktLeadsAssignedsList = mktLeadsAssignedsDALService.findByMktLeadsAssigneds(mktLeadsAssigneds);
if (!mktLeadsAssignedsList.isEmpty()){
for (MktLeadsAssigneds info :mktLeadsAssignedsList){
Long assignedPractitionerId = info.getAssignedPractitionerId();
if (assignedPractitionerId.equals(requestVO.getAssignedPractitionerId())){
break;
}
MktLeadsAssignedTrack leadsAssignedTrack = mktLeadsAssignedTrackDALService.findByListNotesForCustomerId(aclCustomer.getId());
Long mdDropOptionId = leadsAssignedTrack.getMdDropOptionId();
//判断最后一条跟进状态是否为失败,是失败则无需判断经纪人id和之前是否一致
MdDropOptions mdDropOption = mdDropOptionsDALService.findById(mdDropOptionId);
if (!"refused".equalsIgnoreCase(mdDropOption.getDropOptionCode())){
//跳出错误
return new CommonResult(false,ZHBErrorConfig.getErrorInfo("830014"));
}
return new CommonResult(false,ZHBErrorConfig.getErrorInfo("830014"));
}
}else {
//此人为第一次进来
......@@ -1159,8 +1177,10 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
mktLeadsAssignedsDALService.save(assigneds);
//更新跟进表初始值
String mdDropOptionsId = systemConfigService.getSingleConfigValue("OpportunityToBeFollowedUp");
MdDropOptions mdDropOptions = mdDropOptionsDALService.findById(Long.valueOf(mdDropOptionsId));
MktLeadsAssignedTrack leadsAssignedTrack = new MktLeadsAssignedTrack();
leadsAssignedTrack.setSalesNotice("获得此商机,"+CommonUtil.dateParseString(new Date(),"yyyy-MM-dd HH:mm:ss"));
leadsAssignedTrack.setTrackScore(mdDropOptions.getDropOptionScore());
leadsAssignedTrack.setIsActive(1);
leadsAssignedTrack.setCreatedAt(new Date());
leadsAssignedTrack.setCreatedBy(requestVO.getAssignedPractitionerId());
......@@ -1546,24 +1566,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//拿到商机跟踪,失败id
Long refusedId = optionCodeToId.get("refused");
HashMap<String,BigDecimal> performanceForecast = mktLeadsAssignedsDALService.performanceForecastForTeam(practitionerIds,refusedId);
//月平均保费
Double premiumMonth = performanceForecast.get("totalFYCMonth").doubleValue();
//月平均佣金
Double commissionMonth = performanceForecast.get("totalFYPMonth").doubleValue();
//月平均件数
Double piecesMonth = performanceForecast.get("totalPiecesMonth").doubleValue();
// 季度平均保费
Double premiumQuarter = performanceForecast.get("totalFYCQuarter").doubleValue();
// 季度平均佣金
Double commissionQuarter = performanceForecast.get("totalFYPQuarter").doubleValue();
//季度平均件数
Double piecesQuarter = performanceForecast.get("totalPiecesQuarter").doubleValue();
//年平均保费
Double premiumYear = performanceForecast.get("totalFYCYear").doubleValue();
//年平均佣金
Double commissionYear = performanceForecast.get("totalFYPYear").doubleValue();
//年平均件数
Double piecesYear = performanceForecast.get("totalPiecesYear").doubleValue();
List<MktLeadsGoals> leadsGoals = getYearTeamGoals(practitionerId);
ConcurrentHashMap<String,Double> achievementRateMap = new ConcurrentHashMap<>();
......@@ -1576,15 +1578,15 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
responseVO.setScoreWeekAverage(scoreWeekAverage);
responseVO.setScoreMonthAverage(scoreMonthAverage);
responseVO.setOpportunitiesNum(opportunitiesNum);
responseVO.setPremiumMonth(premiumMonth);
responseVO.setCommissionMonth(commissionMonth);
responseVO.setPiecesMonth(piecesMonth);
responseVO.setPremiumQuarter(premiumQuarter);
responseVO.setCommissionQuarter(commissionQuarter);
responseVO.setPiecesQuarter(piecesQuarter);
responseVO.setPremiumYear(premiumYear);
responseVO.setCommissionYear(commissionYear);
responseVO.setPiecesYear(piecesYear);
responseVO.setPremiumMonth(performanceForecast.get("totalFYCMonth").doubleValue());
responseVO.setCommissionMonth(performanceForecast.get("totalFYPMonth").doubleValue());
responseVO.setPiecesMonth(performanceForecast.get("totalPiecesMonth").doubleValue());
responseVO.setPremiumQuarter(performanceForecast.get("totalFYCQuarter").doubleValue());
responseVO.setCommissionQuarter(performanceForecast.get("totalFYPQuarter").doubleValue());
responseVO.setPiecesQuarter(performanceForecast.get("totalPiecesQuarter").doubleValue());
responseVO.setPremiumYear(performanceForecast.get("totalFYCYear").doubleValue());
responseVO.setCommissionYear(performanceForecast.get("totalFYPYear").doubleValue());
responseVO.setPiecesYear(performanceForecast.get("totalPiecesYear").doubleValue());
responseVO.setAchievementRateYear(achievementRateMap.get("achievementRateYear"));
responseVO.setAchievementRateQuarter(achievementRateMap.get("achievementRateQuarter"));
responseVO.setAchievementRateMonth(achievementRateMap.get("achievementRateMonth"));
......@@ -1598,7 +1600,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
Calendar cal = Calendar.getInstance();
int month = cal.get(Calendar.MONTH)+1;
//查询这个月所在季度是那几个月
Integer[] quarter = null;
Integer[] quarter = new Integer[]{};
if (month == 1 || month == 2 || month == 3){
quarter = new Integer[]{1, 2, 3};
}else if (month == 4 || month == 5 || month == 6){
......@@ -1609,9 +1611,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
quarter = new Integer[]{10, 11, 12};
}
Integer yearGoal = 0;
Integer quarterGoal = 0;
Integer monthGoal = 0;
Double yearGoal = 0D;
Double quarterGoal = 0D;
Double monthGoal = 0D;
for (MktLeadsGoals info : leadsGoals){
if (info.getStatisticTimeUnit()==1){
//年目标
......@@ -1672,7 +1674,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
* @return 均分
*/
private Double getScoreAverage(BigDecimal total, BigDecimal practitionerNum) {
Double scoreAverage = 0D;
double scoreAverage = 0D;
if (!CommonUtil.isNullOrZero(total)){
scoreAverage = total
.divide(practitionerNum,2,BigDecimal.ROUND_HALF_UP)
......@@ -1761,10 +1763,10 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
* @param year 当前年份
*/
private void saveYearGoal(SalesTargetSaveRequestVO requestVO,Long practitionerId,Date date,int year,Integer goalsType,AclPractitionerSubordinateSystem subordinate) {
Integer premium = requestVO.getPremium();
Integer commission = requestVO.getCommission();
Double premium = requestVO.getPremium();
Double commission = requestVO.getCommission();
Integer pieces = requestVO.getPieces();
Integer pieceAveragePremium = requestVO.getPieceAveragePremium();
Double pieceAveragePremium = requestVO.getPieceAveragePremium();
MktLeadsGoals mktLeadsGoals = new MktLeadsGoals();
mktLeadsGoals.setPractitionerId(practitionerId);
mktLeadsGoals.setGoalsType(goalsType);
......@@ -1775,6 +1777,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
mktLeadsGoals.setPieces(pieces);
mktLeadsGoals.setPieceAveragePremium(pieceAveragePremium);
mktLeadsGoals.setCurrentYear(year);
mktLeadsGoals.setSeqTime(year);
mktLeadsGoals.setStatisticTimeUnit(1);
mktLeadsGoals.setCurrentVersion(date);
mktLeadsGoals.setCreatedAt(new Date());
......
package com.yd.api.practitioner.vo.opportunity;
import lombok.Data;
import java.util.List;
@Data
public class OpportunityRecordSituationInfo {
private Long status;//0.可编辑 1.不可编辑
private List<OpportunityRecordInfo> opportunityRecordInfos;//商机跟进
}
......@@ -8,7 +8,7 @@ import java.util.List;
public class OwnOpportunityDetailQueryResponseVO {
private OpportunityBasicInformationInfo opportunityBasicInformationInfo;//基本信息
private OpportunityConsultationInfo opportunityConsultationInfo;//服务咨询
private List<OpportunityRecordInfo> opportunityRecordInfos;//商机跟进
private OpportunityRecordSituationInfo opportunityRecordSituationInfo;
private OpportunityScore opportunityScore;//商机分数
private CommonResult commonResult;
}
......@@ -4,9 +4,9 @@ import lombok.Data;
@Data
public class SalesTargetMonth {
private Integer premium;
private Integer commission;
private Double premium;
private Double commission;
private Integer pieces;
private Integer pieceAveragePremium;
private Double pieceAveragePremium;
private Integer monthNum;
}
......@@ -8,10 +8,10 @@ import java.util.List;
@Data
public class SalesTargetQueryResponseVO {
private Long practitionerId;
private Integer premium;
private Integer commission;
private Double premium;
private Double commission;
private Integer pieces;
private Integer pieceAveragePremium;
private Double pieceAveragePremium;
private List<SalesTargetMonth> salesTargetMonths;
private List<SalesTargetActions> salesTargetActions;
private CommonResult commonResult;
......
......@@ -9,11 +9,11 @@ public class SalesTargetSaveRequestVO {
/**
* 保费
*/
private Integer premium;
private Double premium;
/**
* 佣金
*/
private Integer commission;
private Double commission;
/**
* 件数
*/
......@@ -21,7 +21,7 @@ public class SalesTargetSaveRequestVO {
/**
* 均价
*/
private Integer pieceAveragePremium;
private Double pieceAveragePremium;
/**
* 目标类型:1:经纪人指标,2:团队指标
*/
......
package com.yd.dal.entity.marketing;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
......@@ -51,12 +52,12 @@ public class MktLeadsGoals {
/**
* 保费
*/
private Integer premium;
private Double premium;
/**
* 佣金
*/
private Integer commission;
private Double commission;
/**
* 件数
......@@ -66,7 +67,7 @@ public class MktLeadsGoals {
/**
* 件均保费: 计算生成 FYP/件数
*/
private Integer pieceAveragePremium;
private Double pieceAveragePremium;
/**
* 版本控制
......
......@@ -25,4 +25,6 @@ public interface MktLeadsAssignedTrackMapper {
List<MktLeadsAssignedTrack> findByTrackTimeForNew(MktLeadsAssignedTrack mktLeadsAssignedTrack);
HashMap<String, BigDecimal> totalStatisticsForTeam(List<Long> practitionerIds);
MktLeadsAssignedTrack findByListNotesForCustomerId(Long customerId);
}
\ No newline at end of file
......@@ -44,4 +44,9 @@ public class MktLeadsAssignedTrackDALServiceImpl implements MktLeadsAssignedTrac
public HashMap<String, BigDecimal> totalStatisticsForTeam(List<Long> practitionerIds) {
return mktLeadsAssignedTrackMapper.totalStatisticsForTeam(practitionerIds);
}
@Override
public MktLeadsAssignedTrack findByListNotesForCustomerId(Long customerId) {
return mktLeadsAssignedTrackMapper.findByListNotesForCustomerId(customerId);
}
}
......@@ -21,4 +21,6 @@ public interface MktLeadsAssignedTrackDALService {
* @return 返回他们的分数统计 1.天得分 2.周得分 3.月得分
*/
HashMap<String, BigDecimal> totalStatisticsForTeam(List<Long> practitionerIds);
MktLeadsAssignedTrack findByListNotesForCustomerId(Long customerId);
}
......@@ -334,4 +334,12 @@
#{practitionerId,jdbcType=BIGINT}
</foreach>
</select>
<select id="findByListNotesForCustomerId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_mkt_leads_assigned_track
where customer_id = #{customerId,jdbcType=BIGINT}
order by id desc
limit 0,1
</select>
</mapper>
\ No newline at end of file
......@@ -12,10 +12,10 @@
<result column="current_year" jdbcType="INTEGER" property="currentYear" />
<result column="statistic_time_unit" jdbcType="INTEGER" property="statisticTimeUnit" />
<result column="seq_time" jdbcType="INTEGER" property="seqTime" />
<result column="premium" jdbcType="INTEGER" property="premium" />
<result column="commission" jdbcType="INTEGER" property="commission" />
<result column="premium" jdbcType="DECIMAL" property="premium" />
<result column="commission" jdbcType="DECIMAL" property="commission" />
<result column="pieces" jdbcType="INTEGER" property="pieces" />
<result column="piece_average_premium" jdbcType="INTEGER" property="pieceAveragePremium" />
<result column="piece_average_premium" jdbcType="DECIMAL" property="pieceAveragePremium" />
<result column="current_version" jdbcType="TIMESTAMP" property="currentVersion" />
<result column="is_active" jdbcType="INTEGER" property="isActive" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
......@@ -51,8 +51,8 @@
updated_at, updated_by)
values (#{goalsType,jdbcType=INTEGER}, #{practitionerId,jdbcType=BIGINT}, #{subordinateSystemId,jdbcType=BIGINT},
#{subordinateSystemName,jdbcType=VARCHAR}, #{currentYear,jdbcType=INTEGER}, #{statisticTimeUnit,jdbcType=INTEGER},
#{seqTime,jdbcType=INTEGER}, #{premium,jdbcType=INTEGER}, #{commission,jdbcType=INTEGER},
#{pieces,jdbcType=INTEGER}, #{pieceAveragePremium,jdbcType=INTEGER}, #{currentVersion,jdbcType=TIMESTAMP},
#{seqTime,jdbcType=INTEGER}, #{premium,jdbcType=DECIMAL}, #{commission,jdbcType=DECIMAL},
#{pieces,jdbcType=INTEGER}, #{pieceAveragePremium,jdbcType=DECIMAL}, #{currentVersion,jdbcType=TIMESTAMP},
#{isActive,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT},
#{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT})
</insert>
......@@ -135,16 +135,16 @@
#{seqTime,jdbcType=INTEGER},
</if>
<if test="premium != null">
#{premium,jdbcType=INTEGER},
#{premium,jdbcType=DECIMAL},
</if>
<if test="commission != null">
#{commission,jdbcType=INTEGER},
#{commission,jdbcType=DECIMAL},
</if>
<if test="pieces != null">
#{pieces,jdbcType=INTEGER},
</if>
<if test="pieceAveragePremium != null">
#{pieceAveragePremium,jdbcType=INTEGER},
#{pieceAveragePremium,jdbcType=DECIMAL},
</if>
<if test="currentVersion != null">
#{currentVersion,jdbcType=TIMESTAMP},
......@@ -192,16 +192,16 @@
seq_time = #{seqTime,jdbcType=INTEGER},
</if>
<if test="premium != null">
premium = #{premium,jdbcType=INTEGER},
premium = #{premium,jdbcType=DECIMAL},
</if>
<if test="commission != null">
commission = #{commission,jdbcType=INTEGER},
commission = #{commission,jdbcType=DECIMAL},
</if>
<if test="pieces != null">
pieces = #{pieces,jdbcType=INTEGER},
</if>
<if test="pieceAveragePremium != null">
piece_average_premium = #{pieceAveragePremium,jdbcType=INTEGER},
piece_average_premium = #{pieceAveragePremium,jdbcType=DECIMAL},
</if>
<if test="currentVersion != null">
current_version = #{currentVersion,jdbcType=TIMESTAMP},
......@@ -234,10 +234,10 @@
current_year = #{currentYear,jdbcType=INTEGER},
statistic_time_unit = #{statisticTimeUnit,jdbcType=INTEGER},
seq_time = #{seqTime,jdbcType=INTEGER},
premium = #{premium,jdbcType=INTEGER},
commission = #{commission,jdbcType=INTEGER},
premium = #{premium,jdbcType=DECIMAL},
commission = #{commission,jdbcType=DECIMAL},
pieces = #{pieces,jdbcType=INTEGER},
piece_average_premium = #{pieceAveragePremium,jdbcType=INTEGER},
piece_average_premium = #{pieceAveragePremium,jdbcType=DECIMAL},
current_version = #{currentVersion,jdbcType=TIMESTAMP},
is_active = #{isActive,jdbcType=INTEGER},
created_at = #{createdAt,jdbcType=TIMESTAMP},
......
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