Commit c3d605d2 by yao.xiao

增加-队员销售活动量列表

parent fdba8154
...@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@Controller @Controller
@RestController @RestController
@RequestMapping("/practitioner") @RequestMapping("/practitioner")
...@@ -287,4 +289,18 @@ public class PractitionerController { ...@@ -287,4 +289,18 @@ public class PractitionerController {
result.setData(responseVO); result.setData(responseVO);
return result; return result;
} }
/**
* 队员销售活动量
* @param requestVO 请求数据
* @return 响应数据
*/
@RequestMapping("/playerSalesActivityQuery")
public Object playerSalesActivityQuery(@RequestBody PlayerSalesActivityQueryRequestVO requestVO){
JsonResult result = new JsonResult();
PlayerSalesActivityQueryResponseVO responseVO = practitionerService.playerSalesActivityQuery(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
} }
...@@ -145,4 +145,11 @@ public interface PractitionerService { ...@@ -145,4 +145,11 @@ public interface PractitionerService {
* @return * @return
*/ */
TeamActionsAverageQueryResponseVO teamScoreAverageQuery(TeamActionsAverageQueryRequestVO requestVO); TeamActionsAverageQueryResponseVO teamScoreAverageQuery(TeamActionsAverageQueryRequestVO requestVO);
/**
* 队员销售活动量
* @param requestVO
* @return
*/
PlayerSalesActivityQueryResponseVO playerSalesActivityQuery(PlayerSalesActivityQueryRequestVO requestVO);
} }
...@@ -23,6 +23,7 @@ import com.yd.dal.entity.marketing.*; ...@@ -23,6 +23,7 @@ import com.yd.dal.entity.marketing.*;
import com.yd.dal.entity.meta.*; import com.yd.dal.entity.meta.*;
import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo; import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo;
import com.yd.dal.entity.order.PoOrder; import com.yd.dal.entity.order.PoOrder;
import com.yd.dal.entity.practitioner.opportunity.PlayerSalesActivityInfo;
import com.yd.dal.entity.survey.SurveyCustomerAnswers; import com.yd.dal.entity.survey.SurveyCustomerAnswers;
import com.yd.dal.service.customer.*; import com.yd.dal.service.customer.*;
import com.yd.dal.service.marketing.*; import com.yd.dal.service.marketing.*;
...@@ -1578,14 +1579,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1578,14 +1579,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
responseVO.setScoreWeekAverage(scoreWeekAverage); responseVO.setScoreWeekAverage(scoreWeekAverage);
responseVO.setScoreMonthAverage(scoreMonthAverage); responseVO.setScoreMonthAverage(scoreMonthAverage);
responseVO.setOpportunitiesNum(opportunitiesNum); responseVO.setOpportunitiesNum(opportunitiesNum);
responseVO.setPremiumMonth(performanceForecast.get("totalFYCMonth").doubleValue()); responseVO.setPremiumMonth(performanceForecast.get("totalFYPMonth").doubleValue());
responseVO.setCommissionMonth(performanceForecast.get("totalFYPMonth").doubleValue()); responseVO.setCommissionMonth(performanceForecast.get("totalFYCMonth").doubleValue());
responseVO.setPiecesMonth(performanceForecast.get("totalPiecesMonth").doubleValue()); responseVO.setPiecesMonth(performanceForecast.get("totalPiecesMonth").doubleValue());
responseVO.setPremiumQuarter(performanceForecast.get("totalFYCQuarter").doubleValue()); responseVO.setPremiumQuarter(performanceForecast.get("totalFYPQuarter").doubleValue());
responseVO.setCommissionQuarter(performanceForecast.get("totalFYPQuarter").doubleValue()); responseVO.setCommissionQuarter(performanceForecast.get("totalFYCQuarter").doubleValue());
responseVO.setPiecesQuarter(performanceForecast.get("totalPiecesQuarter").doubleValue()); responseVO.setPiecesQuarter(performanceForecast.get("totalPiecesQuarter").doubleValue());
responseVO.setPremiumYear(performanceForecast.get("totalFYCYear").doubleValue()); responseVO.setPremiumYear(performanceForecast.get("totalFYPYear").doubleValue());
responseVO.setCommissionYear(performanceForecast.get("totalFYPYear").doubleValue()); responseVO.setCommissionYear(performanceForecast.get("totalFYCYear").doubleValue());
responseVO.setPiecesYear(performanceForecast.get("totalPiecesYear").doubleValue()); responseVO.setPiecesYear(performanceForecast.get("totalPiecesYear").doubleValue());
responseVO.setAchievementRateYear(achievementRateMap.get("achievementRateYear")); responseVO.setAchievementRateYear(achievementRateMap.get("achievementRateYear"));
responseVO.setAchievementRateQuarter(achievementRateMap.get("achievementRateQuarter")); responseVO.setAchievementRateQuarter(achievementRateMap.get("achievementRateQuarter"));
...@@ -1594,6 +1595,40 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1594,6 +1595,40 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
return responseVO; return responseVO;
} }
@Override
public PlayerSalesActivityQueryResponseVO playerSalesActivityQuery(PlayerSalesActivityQueryRequestVO requestVO) {
PlayerSalesActivityQueryResponseVO responseVO = new PlayerSalesActivityQueryResponseVO();
Long practitionerId = requestVO.getPractitionerId();
MdDropOptions mdDropOptions = mdDropOptionsDALService.findByMasterCodeAndOptionsCode("bizchance_promotion_action","refused");
List<PlayerSalesActivityInfo> playerSalesActivityInfos = aclPractitionerDALService.playerSalesActivityQuery(practitionerId,mdDropOptions.getId());
//计算完成率
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
//通过团队长经纪人id查询出团队所有人设置的目标
List<MktLeadsGoalsActions> mktLeadsGoalsActions = mktLeadsGoalsActionsDALService.findTeamGoalsMonth(practitionerId,year);
List<MdDropOptions> mdDropOptionsList = mdDropOptionsDALService.findByDropMasterCode("bizchance_promotion_action");
ConcurrentHashMap<Long , Integer> optionsIdToScore = new ConcurrentHashMap<>();
for (MdDropOptions info : mdDropOptionsList){
optionsIdToScore.put(info.getId(),info.getDropOptionScore());
}
for (PlayerSalesActivityInfo info : playerSalesActivityInfos){
//总分数
Integer predictionScore = 0;
for (MktLeadsGoalsActions actions : mktLeadsGoalsActions){
if (info.getPractitionerId() == actions.getPractitionerId()){
predictionScore += actions.getActionStandards() * optionsIdToScore.get(actions.getLeadsActionId());
}
}
if (!CommonUtil.isNullOrZero(predictionScore)){
BigDecimal achievementRateMonth = info.getScoreMonth().divide(BigDecimal.valueOf(predictionScore),4,BigDecimal.ROUND_HALF_UP);
info.setAchievementRateMonth(achievementRateMonth.doubleValue());
}
}
responseVO.setPlayerSalesActivityInfo(playerSalesActivityInfos);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
return responseVO;
}
private ConcurrentHashMap<String, Double> getAchievementRate(List<MktLeadsGoals> leadsGoals,HashMap<String,BigDecimal> performanceForecast) { private ConcurrentHashMap<String, Double> getAchievementRate(List<MktLeadsGoals> leadsGoals,HashMap<String,BigDecimal> performanceForecast) {
ConcurrentHashMap<String, Double> achievementRateMap = new ConcurrentHashMap<>(); ConcurrentHashMap<String, Double> achievementRateMap = new ConcurrentHashMap<>();
//获取当前月份 //获取当前月份
......
package com.yd.api.practitioner.vo.opportunity;
import lombok.Data;
@Data
public class PlayerSalesActivityQueryRequestVO {
private Long practitionerId;
}
package com.yd.api.practitioner.vo.opportunity;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.practitioner.opportunity.PlayerSalesActivityInfo;
import lombok.Data;
import java.util.List;
@Data
public class PlayerSalesActivityQueryResponseVO {
private List<PlayerSalesActivityInfo> playerSalesActivityInfo;
private CommonResult commonResult;
}
package com.yd.dal.entity.practitioner.opportunity;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PlayerSalesActivityInfo {
private String name;
private Long practitionerId;
private BigDecimal scoreDay;
private BigDecimal scoreWeek;
private BigDecimal scoreMonth;
private Integer addOpportunityNum;
private Double achievementRateMonth;
}
package com.yd.dal.mapper.customer; package com.yd.dal.mapper.customer;
import com.yd.dal.entity.practitioner.opportunity.PlayerSalesActivityInfo;
import com.yd.dal.entity.customer.AclPractitioner; import com.yd.dal.entity.customer.AclPractitioner;
import com.yd.dal.entity.customer.practitioner.PractitionerBasicInfo; import com.yd.dal.entity.customer.practitioner.PractitionerBasicInfo;
import com.yd.dal.entity.customer.practitioner.PractitionerInfo; import com.yd.dal.entity.customer.practitioner.PractitionerInfo;
...@@ -41,4 +42,6 @@ public interface AclPractitionerMapper { ...@@ -41,4 +42,6 @@ public interface AclPractitionerMapper {
List<AclPractitioner> findByIds(@Param("practitionerIdList") List<Long> practitionerIdList); List<AclPractitioner> findByIds(@Param("practitionerIdList") List<Long> practitionerIdList);
List<AclPractitioner> findForSubordinateIdByPractitionerId(Long practitionerId); List<AclPractitioner> findForSubordinateIdByPractitionerId(Long practitionerId);
List<PlayerSalesActivityInfo> playerSalesActivityQuery(@Param("practitionerId") Long practitionerId,@Param("optionsId") Long optionsId);
} }
\ No newline at end of file
...@@ -18,4 +18,6 @@ public interface MktLeadsGoalsActionsMapper { ...@@ -18,4 +18,6 @@ public interface MktLeadsGoalsActionsMapper {
void updateIsActiveIsNull(@Param("practitionerId") Long practitionerId, @Param("year") Integer year, @Param("goalsType") Integer goalsType); void updateIsActiveIsNull(@Param("practitionerId") Long practitionerId, @Param("year") Integer year, @Param("goalsType") Integer goalsType);
List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions); List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions);
List<MktLeadsGoalsActions> findTeamGoalsMonth(@Param("practitionerId") Long practitionerId, @Param("year") Integer year);
} }
\ No newline at end of file
...@@ -24,4 +24,6 @@ public interface MdDropOptionsMapper { ...@@ -24,4 +24,6 @@ public interface MdDropOptionsMapper {
List<MdDropOptions> findByMasterCode(@Param("masterCode")String masterCode); List<MdDropOptions> findByMasterCode(@Param("masterCode")String masterCode);
List<MdDropOptions> findByMasterCodeAndOrderId(@Param("masterCode")String masterCode, @Param("orderId")int orderId); List<MdDropOptions> findByMasterCodeAndOrderId(@Param("masterCode")String masterCode, @Param("orderId")int orderId);
MdDropOptions findByMasterCodeAndOptionsCode(@Param("masterCode") String masterCode, @Param("optionsCode") String optionsCode);
} }
\ No newline at end of file
package com.yd.dal.service.customer; package com.yd.dal.service.customer;
import com.yd.dal.entity.practitioner.opportunity.PlayerSalesActivityInfo;
import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo; import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo;
import com.yd.dal.entity.customer.AclPractitioner; import com.yd.dal.entity.customer.AclPractitioner;
import com.yd.dal.entity.customer.practitioner.AclPractitionerInfo;
import com.yd.dal.entity.customer.practitioner.PractitionerBasicInfo; import com.yd.dal.entity.customer.practitioner.PractitionerBasicInfo;
import com.yd.dal.entity.customer.practitioner.PractitionerInfo; import com.yd.dal.entity.customer.practitioner.PractitionerInfo;
import com.yd.dal.entity.customer.practitioner.PractitionerRankInfo; import com.yd.dal.entity.customer.practitioner.PractitionerRankInfo;
...@@ -89,4 +89,11 @@ public interface AclPractitionerDALService { ...@@ -89,4 +89,11 @@ public interface AclPractitionerDALService {
* @return * @return
*/ */
List<AclPractitioner> findForSubordinateIdByPractitionerId(Long practitionerId); List<AclPractitioner> findForSubordinateIdByPractitionerId(Long practitionerId);
/**
* 通过团队长经纪人id查询团队中组员的销售活动量(跟进分数,除去以失败的跟进)
* @param practitionerId
* @return
*/
List<PlayerSalesActivityInfo> playerSalesActivityQuery(Long practitionerId, Long optionsId);
} }
package com.yd.dal.service.customer.impl; package com.yd.dal.service.customer.impl;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.yd.dal.entity.customer.practitioner.AclPractitionerInfo; import com.yd.dal.entity.practitioner.opportunity.PlayerSalesActivityInfo;
import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo; import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo;
import com.yd.dal.entity.customer.AclPractitioner; import com.yd.dal.entity.customer.AclPractitioner;
import com.yd.dal.entity.customer.practitioner.PractitionerBasicInfo; import com.yd.dal.entity.customer.practitioner.PractitionerBasicInfo;
...@@ -93,4 +93,9 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService ...@@ -93,4 +93,9 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService
public List<AclPractitioner> findForSubordinateIdByPractitionerId(Long practitionerId) { public List<AclPractitioner> findForSubordinateIdByPractitionerId(Long practitionerId) {
return aclPractitionerMapper.findForSubordinateIdByPractitionerId(practitionerId) ; return aclPractitionerMapper.findForSubordinateIdByPractitionerId(practitionerId) ;
} }
@Override
public List<PlayerSalesActivityInfo> playerSalesActivityQuery(Long practitionerId, Long optionsId) {
return aclPractitionerMapper.playerSalesActivityQuery(practitionerId,optionsId);
}
} }
...@@ -28,4 +28,9 @@ public class MktLeadsGoalsActionsDALServiceImpl implements MktLeadsGoalsActionsD ...@@ -28,4 +28,9 @@ public class MktLeadsGoalsActionsDALServiceImpl implements MktLeadsGoalsActionsD
public List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions) { public List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions) {
return mktLeadsGoalsActionsMapper.findByMktLeadsGoalsActions(mktLeadsGoalsActions); return mktLeadsGoalsActionsMapper.findByMktLeadsGoalsActions(mktLeadsGoalsActions);
} }
@Override
public List<MktLeadsGoalsActions> findTeamGoalsMonth(Long practitionerId, int year) {
return mktLeadsGoalsActionsMapper.findTeamGoalsMonth(practitionerId, year);
}
} }
...@@ -10,4 +10,6 @@ public interface MktLeadsGoalsActionsDALService { ...@@ -10,4 +10,6 @@ public interface MktLeadsGoalsActionsDALService {
void updateIsActiveIsNull(Long practitionerId, int year,Integer goalsType); void updateIsActiveIsNull(Long practitionerId, int year,Integer goalsType);
List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions); List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions);
List<MktLeadsGoalsActions> findTeamGoalsMonth(Long practitionerId, int year);
} }
...@@ -14,4 +14,6 @@ public interface MdDropOptionsDALService { ...@@ -14,4 +14,6 @@ public interface MdDropOptionsDALService {
List<MdDropOptions> findByMasterCode(String masterCode); List<MdDropOptions> findByMasterCode(String masterCode);
List<MdDropOptions> findByMasterCodeAndOrderId(String masterCode, int orderId); List<MdDropOptions> findByMasterCodeAndOrderId(String masterCode, int orderId);
MdDropOptions findByMasterCodeAndOptionsCode(String masterCode, String optionsCode);
} }
...@@ -43,4 +43,9 @@ public class MdDropOptionsDALServiceImpl implements MdDropOptionsDALService { ...@@ -43,4 +43,9 @@ public class MdDropOptionsDALServiceImpl implements MdDropOptionsDALService {
public List<MdDropOptions> findByMasterCodeAndOrderId(String masterCode, int orderId) { public List<MdDropOptions> findByMasterCodeAndOrderId(String masterCode, int orderId) {
return mdDropOptionsMapper.findByMasterCodeAndOrderId(masterCode,orderId); return mdDropOptionsMapper.findByMasterCodeAndOrderId(masterCode,orderId);
} }
@Override
public MdDropOptions findByMasterCodeAndOptionsCode(String masterCode, String optionsCode) {
return mdDropOptionsMapper.findByMasterCodeAndOptionsCode(masterCode, optionsCode);
}
} }
...@@ -727,4 +727,35 @@ ...@@ -727,4 +727,35 @@
and p.is_active = 1 and p.is_active = 1
and s.is_active = 1 and s.is_active = 1
</select> </select>
<resultMap id="playerSalesActivityQuery" type="com.yd.dal.entity.practitioner.opportunity.PlayerSalesActivityInfo">
<result column="practitionerId" property="practitionerId"/>
<result column="name" property="name"/>
<result column="scoreDay" property="scoreDay"/>
<result column="scoreWeek" property="scoreWeek"/>
<result column="scoreMonth" property="scoreMonth"/>
<result column="addOpportunityNum" property="addOpportunityNum"/>
</resultMap>
<select id="playerSalesActivityQuery" resultMap="playerSalesActivityQuery">
select
p.id practitionerId,
p.name name ,
sum(case when to_days(t.track_time)=to_days(now()) then t.track_score end) scoreDay,
sum(case when YEARWEEK(date_format(t.track_time,'%Y-%m-%d')) = YEARWEEK(now()) then t.track_score end) scoreWeek,
sum(case when date_format(t.track_time,'%Y-%m')=date_format(now(),'%Y-%m') then t.track_score end) scoreMonth,
count(case when YEARWEEK(date_format(a.created_at,'%Y-%m-%d')) = YEARWEEK(now()) then t.id end) addOpportunityNum
from ag_acl_practitioner p
left join ag_mkt_leads_assigned_track t on p.id = t.practitioner_id
left join ag_mkt_leads_assigneds a on a.id = t.leads_assigned_id
left join ag_acl_practitioner_subordinate_system s on s.id = p.subordinate_system_id
where
s.owner_practitioner_id = #{practitionerId,jdbcType=BIGINT}
and s.is_active=1
and not EXISTS (select t.leads_assigned_id
from ag_mkt_leads_assigned_track t
where t.md_drop_option_id = #{optionsId,jdbcType=BIGINT}
and t.practitioner_id = p.id
and a.id = t.leads_assigned_id)
group by p.id
order by scoreDay desc ,scoreWeek desc ,scoreMonth desc ,addOpportunityNum desc
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -259,4 +259,14 @@ ...@@ -259,4 +259,14 @@
</if> </if>
</where> </where>
</select> </select>
<select id="findTeamGoalsMonth" resultMap="BaseResultMap">
select a.*
from ag_mkt_leads_goals_actions a
left join ag_acl_practitioner p left join ag_acl_practitioner_subordinate_system s on p.subordinate_system_id = s.id on a.practitioner_id = p.id
where owner_practitioner_id = #{practitionerId,jdbcType=BIGINT}
and a.current_year= #{year,jdbcType=INTEGER}
and a.is_active = 1
and a.goals_type = 1
and a.statistic_time_unit = 3
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -218,4 +218,11 @@ ...@@ -218,4 +218,11 @@
from ag_md_drop_master m left join ag_md_drop_options o on m.id = o.drop_master_id and o.is_active = 1 and o.drop_option_order = #{orderId,jdbcType=INTEGER} from ag_md_drop_master m left join ag_md_drop_options o on m.id = o.drop_master_id and o.is_active = 1 and o.drop_option_order = #{orderId,jdbcType=INTEGER}
where m.scenario_code = #{masterCode,jdbcType=BIGINT} where m.scenario_code = #{masterCode,jdbcType=BIGINT}
</select> </select>
<select id="findByMasterCodeAndOptionsCode" resultMap="BaseResultMap">
SELECT o.*
FROM ag_md_drop_options o
LEFT JOIN ag_md_drop_master m ON m.id = o.drop_master_id
WHERE m.scenario_code = #{masterCode,jdbcType=VARCHAR,jdbcType=VARCHAR}
and o.drop_option_code = #{optionsCode,jdbcType=VARCHAR}
</select>
</mapper> </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