Commit f8915ea2 by 叶立庆

Merge remote-tracking branch 'origin/v5.6.0' into v5.6.0

2 parents 8f373b33 2b7cd9bc
Showing 26 changed files with 869 additions and 230 deletions
......@@ -25,5 +25,6 @@ public class EffectiveReferralCountDTO implements Serializable {
private Integer deliveryCount;
@ApiModelProperty(value = "有效引荐数")
@NotNull(message = "有效引荐数不能为空")
private Integer effectiveReferralCount;
}
package cn.com.glsx.dj.staff.dto.perfSalary;
import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
......@@ -35,4 +38,17 @@ public class EffectiveReferralReviewCommonDTO extends EffectiveReferralReview {
@ApiModelProperty(value = "商户号集合,无须前端传")
private List<Integer> merchantIds;
@ApiModelProperty(value = "区域经理-提交开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date managerCommitStartTime;
@ApiModelProperty(value = "区域经理-提交结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date managerCommitEndTime;
@ApiModelProperty(value = "主键ids,无须前端传")
private List<Integer> ids;
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ import java.math.BigDecimal;
*/
@AllArgsConstructor
@Getter
public enum CommissionMethodEnum {
public enum CommissionTypeEnum {
BL("BL", "比例", BigDecimal.ZERO, BigDecimal.valueOf(100)),
XS("XS", "系数", BigDecimal.ONE, BigDecimal.valueOf(10)),
GDJE("GDJE", "固定金额", BigDecimal.ZERO, BigDecimal.valueOf(9999999));
......@@ -20,8 +20,8 @@ public enum CommissionMethodEnum {
private final BigDecimal min;
private final BigDecimal max;
public static CommissionMethodEnum getByCode(String code) {
for (CommissionMethodEnum value : values()) {
public static CommissionTypeEnum getByCode(String code) {
for (CommissionTypeEnum value : values()) {
if (value.getCode().equals(code)) {
return value;
}
......@@ -31,10 +31,10 @@ public enum CommissionMethodEnum {
// 检测区间
public static boolean check(String code, BigDecimal value) {
CommissionMethodEnum commissionMethodEnum = getByCode(code);
if (commissionMethodEnum == null) {
CommissionTypeEnum commissionTypeEnum = getByCode(code);
if (commissionTypeEnum == null) {
return false;
}
return value.doubleValue() >= commissionMethodEnum.getMin().doubleValue() && value.doubleValue() <= commissionMethodEnum.getMax().doubleValue();
return value.doubleValue() >= commissionTypeEnum.getMin().doubleValue() && value.doubleValue() <= commissionTypeEnum.getMax().doubleValue();
}
}
\ No newline at end of file
......@@ -3,22 +3,31 @@ package cn.com.glsx.dj.staff.enums;
/**
* 商品配置类型枚举
*/
public enum ProductConfigTypeEnum implements BaseEnum<Integer, String> {
ALL_PRODUCT(-1, "全部商品"),
PRODUCT_CATEGORY(0, "商品分类"),
DESIGNATED_PRODUCT(1, "圈定产品"),
DESIGNATED_PACKAGE(2, "圈定套餐");
public enum GoodsConfigTypeEnum implements BaseEnum<Byte, String> {
ALL_PRODUCT((byte) -1, "全部商品"),
PRODUCT_CATEGORY((byte) 0, "商品分类"),
DESIGNATED_PRODUCT((byte) 1, "圈定产品"),
DESIGNATED_PACKAGE((byte) 2, "圈定套餐");
private final Integer code;
private final Byte code;
private final String desc;
ProductConfigTypeEnum(Integer code, String desc) {
GoodsConfigTypeEnum(Byte code, String desc) {
this.code = code;
this.desc = desc;
}
public static GoodsConfigTypeEnum getByCode(Byte goodsConfigType) {
for (GoodsConfigTypeEnum type : GoodsConfigTypeEnum.values()) {
if (type.getCode().equals(goodsConfigType)) {
return type;
}
}
return null;
}
@Override
public Integer getCode() {
public Byte getCode() {
return code;
}
......
package cn.com.glsx.dj.staff.enums;
/**
* 绩效参数配置条件类型枚举
*/
public enum PerformanceConditionTypeEnum implements BaseEnum<Byte, String> {
PENETRATION_RATE_LIMIT((byte) 1, "渗透率限制"),
ORDER_COUNT_DEDUCTION((byte) 2, "订单数不足扣减"),
TARGET_ACHIEVEMENT_REWARD((byte) 3, "整体指标达成奖励"),
ORDER_EXCLUSION_INCLUSION((byte) 4, "订单数剔除/包含");
private final Byte code;
private final String desc;
PerformanceConditionTypeEnum(Byte code, String desc) {
this.code = code;
this.desc = desc;
}
public static PerformanceConditionTypeEnum getByCode(Number code) {
if (code == null) {
return null;
}
for (PerformanceConditionTypeEnum type : PerformanceConditionTypeEnum.values()) {
if (type.getCode().equals(code.intValue())) {
return type;
}
}
return null;
}
@Override
public Byte getCode() {
return code;
}
@Override
public String getDesc() {
return desc;
}
}
......@@ -34,13 +34,13 @@ public class PerformanceParamConfigCondition implements Serializable {
@Column(name = "performance_param_config_id")
private Integer performanceParamConfigId;
@ApiModelProperty(notes = "条件类型(1:渗透率限制,2.订单数不足扣减,3.整体指标达成奖励,4.订单数剔除/包含)")
@ApiModelProperty(notes = "条件类型(1:渗透率限制,2.订单数不足扣减,3.整体指标达成奖励,4.订单数剔除/包含), 详见PerformanceConditionTypeEnum")
@Column(name = "condition_type")
private Integer conditionType;
private Byte conditionType;
@ApiModelProperty(notes = "条件商品配置类型(-1:全部商品,0:商品分类,1:圈定产品,2圈定套餐)")
@ApiModelProperty(notes = "条件商品配置类型(-1:全部商品,0:商品分类,1:圈定产品,2圈定套餐), 详见ProductConfigTypeEnum")
@Column(name = "condition_goods_config_type")
private Integer conditionGoodsConfigType;
private Byte conditionGoodsConfigType;
@ApiModelProperty(notes = "条件商品分类(一级)")
@Column(name = "condition_goods_type")
......
package cn.com.glsx.dj.staff.job;
import cn.com.glsx.dj.staff.service.perfSalary.EffectiveReferralReviewQwService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import javax.annotation.Resource;
@Slf4j
@ElasticJobConf(name = "EffectiveReferralReviewManagerQwNotificationJob", cron = "0 0 7,19 * * ? ", description = "有效引荐数区域经理复核企微通知", overwrite = false)
public class EffectiveReferralReviewManagerQwNotificationJob implements SimpleJob {
@Resource
private EffectiveReferralReviewQwService effectiveReferralReviewQwService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("----------------有效引荐数区域经理复核企微通知开始-----------------");
try {
effectiveReferralReviewQwService.qwManagerNotification();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.info("----------------有效引荐数区域经理复核企微通知结束-----------------");
}
}
package cn.com.glsx.dj.staff.job;
import cn.com.glsx.dj.staff.service.perfSalary.EffectiveReferralReviewQwService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import javax.annotation.Resource;
@Slf4j
@ElasticJobConf(name = "EffectiveReferralReviewManagerQwNotificationJob", cron = "0 0 7,19 * * ? ", description = "有效引荐数总部线上复核企微通知", overwrite = false)
public class EffectiveReferralReviewOnLineQwNotificationJob implements SimpleJob {
@Resource
private EffectiveReferralReviewQwService effectiveReferralReviewQwService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("----------------有效引荐数总部线上复核企微通知开始-----------------");
try {
effectiveReferralReviewQwService.qwOnLineNotification();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.info("----------------有效引荐数总部线上复核企微通知结束-----------------");
}
}
package cn.com.glsx.dj.staff.job;
import cn.com.glsx.dj.staff.service.perfSalary.PerfQwNotificationService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import javax.annotation.Resource;
@Slf4j
@ElasticJobConf(name = "PerfQwNotificationJob", cron = "0 0 7,19 * * ? ", description = "绩效评分企微通知", overwrite = false)
public class PerfQwNotificationJob implements SimpleJob {
@Resource
private PerfQwNotificationService perfQwNotificationService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("----------------绩效评分企微通知开始-----------------");
try {
perfQwNotificationService.perfQwNotification();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.info("----------------绩效评分企微通知结束-----------------");
}
}
......@@ -19,5 +19,5 @@ public interface StaffProductPerformanceMapper extends OreMapper<StaffProductPer
@Param("staffPhone") String staffPhone,
@Param("updatedBy") String updatedBy);
List<StaffProductPerformanceDTO> listStaffPerformance(@Param("dto") StaffProductPerformanceDTO dto);
List<StaffProductPerformanceDTO> listStaffPerformance(StaffProductPerformanceDTO dto);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewCommonDTO;
import cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewDTO;
import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
......@@ -35,4 +36,7 @@ public interface EffectiveReferralReviewMapper extends OreMapper<EffectiveReferr
* @return 门店列表
*/
List<EffectiveReferralReviewCommonDTO> selectStoreEffectiveReferralList(EffectiveReferralReviewCommonDTO query);
List<String> queryQwSendMobilePhoneList(@Param("date") String date);
}
\ No newline at end of file
......@@ -33,4 +33,6 @@ public interface PerformanceEvaluationMapper extends OreMapper<PerformanceEvalua
StaffMonthSalaryDTO queryStaffMonthSalary(@Param("evaluationMonth") String evaluationMonth, @Param("mobilePhone") String mobilePhone);
List<String> querySuperiorLeaderMobilePhoneLeader(@Param("date") String date);
}
\ No newline at end of file
package cn.com.glsx.dj.staff.service.common;
import cn.com.glsx.dj.staff.util.HttpUtil;
import cn.com.glsx.entmicro.model.request.EntmicroStaffRequest;
import cn.com.glsx.entmicro.model.response.EntmicroStaffResponse;
import cn.com.glsx.entmicro.remote.EntmicroStaffRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.response.SendWorkWechatMessageResponseDTO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class QWManager {
......@@ -17,8 +28,10 @@ public class QWManager {
@Autowired
private Environment environment;
public SendWorkWechatMessageResponseDTO sendMessage(
SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
@Resource
private EntmicroStaffRemote entmicroStaffRemote;
public SendWorkWechatMessageResponseDTO sendMessage(SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("发送企微应用消息:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
SendWorkWechatMessageResponseDTO responseDTO=null;
try {
......@@ -60,4 +73,41 @@ public class QWManager {
}
return userId;
}
/**
* 获取全量广联数科员工企微
*/
public Map<String, String> getSendUserIds() {
EntmicroStaffRequest entmicroStaffRequest = new EntmicroStaffRequest();
// dev = 44209813 test = 44209813 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id",Integer.class,44202977);
entmicroStaffRequest.setMerchantId(merchantId);
RpcResponse<List<EntmicroStaffResponse>> staffResponse = entmicroStaffRemote.findStaffByMerchantId(entmicroStaffRequest);
if (staffResponse.hasResult()) {
List<EntmicroStaffResponse> result = staffResponse.getResult();
return result.stream().filter(item ->
StringUtils.isNotBlank(item.getStaffPhone()) && StringUtils.isNotBlank(item.getUserId()))
.collect(Collectors.toMap(EntmicroStaffResponse::getStaffPhone, EntmicroStaffResponse::getUserId, (a, b) -> a));
}
if (staffResponse.isFailed()) {
log.warn("获取发送员工失败,失败原因:{}", staffResponse.getException().getMessage());
}
return null;
}
public String getJoinedUserIds(Map<String, String> phoneToUserIdMap, List<String> phoneNumbers) {
StringBuilder userIds = new StringBuilder();
for (String phoneNumber : phoneNumbers) {
String userId = phoneToUserIdMap.get(phoneNumber);
if (userId != null) {
if (userIds.length() > 0) {
userIds.append("|");
}
userIds.append(userId);
}
}
return userIds.toString();
}
}
package cn.com.glsx.dj.staff.service.perfSalary;
import cn.com.glsx.dj.smartcarlife.constant.CommonConstants;
import cn.com.glsx.dj.smartcarlife.dto.merchant.CarBrandDTO;
import cn.com.glsx.dj.smartcarlife.response.ServiceStaffRopResponse;
import cn.com.glsx.dj.staff.dto.perfSalary.*;
......@@ -182,20 +181,36 @@ public class EffectiveReferralReviewMiniProgramService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public Boolean effectiveReferralStoreSubmit(StoreEffectiveReferralSubmitDTO dto) {
//根据id更新引荐数、上传凭证、备注、状态
//1、根据id查询引荐数
EffectiveReferralReviewCommonDTO commonDTO = new EffectiveReferralReviewCommonDTO();
List<Integer> ids = dto.getEffectiveReferralCountDTOS().stream().map(EffectiveReferralCountDTO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(ids)) {
throw new RpcServiceException("主键id不能为空");
}
commonDTO.setIds(ids);
List<EffectiveReferralReviewCommonDTO> referralReviewCommonDTOS = effectiveReferralReviewMapper.selectStoreEffectiveReferralList(commonDTO);
//将referralReviewCommonDTOS转化为key-value,key为id,value为EffectiveReferralReviewCommonDTO
Map<Integer, EffectiveReferralReviewCommonDTO> referralReviewCommonDTOSMap =
referralReviewCommonDTOS.stream().collect(Collectors.toMap(EffectiveReferralReviewCommonDTO::getId, item -> item));
//2、根据id更新引荐数、上传凭证、备注、状态
dto.getEffectiveReferralCountDTOS().forEach(
item -> {
EffectiveReferralReview review = new EffectiveReferralReview();
review.setId(item.getId());
if (item.getEffectiveReferralCount() != null) {
review.setAreaEffectiveCount(item.getEffectiveReferralCount());
}
review.setAreaEffectiveCount(item.getEffectiveReferralCount());
if (StringUtils.isNotBlank(dto.getImageUrls())) {
review.setImageUrls(dto.getImageUrls());
}
if (StringUtils.isNotBlank(dto.getRemark())) {
review.setRemark(dto.getRemark());
}
if (referralReviewCommonDTOSMap.containsKey(item.getId()) &&
!item.getEffectiveReferralCount().equals(referralReviewCommonDTOSMap.get(item.getId()).getTotalDeliveryCount())) {
review.setIsNeedReviewed(1);
review.setIsReviewed(0);
}
review.setStatus(dto.getStatus());
review.setUpdatedBy(dto.getUpdatedBy());
review.setUpdatedDate(new Date());
......
package cn.com.glsx.dj.staff.service.perfSalary;
import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO;
import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum;
import cn.com.glsx.dj.staff.mapper.PerformanceTimeCycleMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.EffectiveReferralReviewMapper;
import cn.com.glsx.dj.staff.service.common.QWManager;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.WorkWechatTextCardMessageDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.enums.WorkWechatAppMessageTypeEnum;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class EffectiveReferralReviewQwService {
@Resource
private QWManager qWManager;
@Resource
private PerformanceTimeCycleMapper performanceTimeCycleMapper;
@Resource
private EffectiveReferralReviewMapper effectiveReferralReviewMapper;
public void qwManagerNotification() {
// 判断当前时间是否在T1范围内 如果不在则return
// 校验是否在修改的时间
PerformanceTimeCycleDTO performanceTimeCycleDTO = performanceTimeCycleMapper.selectByCode(PerformanceTimeCycleCodeEnum.T1.getCode());
Date startDate = performanceTimeCycleDTO.getStartDate();
Date endDate = performanceTimeCycleDTO.getEndDate();
Date now = DateUtil.date();
// 判断当前时间是否在考核时间范围内 当前时间需要大于等于开始时间,小于等于结束时间
boolean judgeTime = now.compareTo(startDate) < 0 || now.compareTo(endDate) > 0;
if (judgeTime) {
return;
}
// 获取所有未处理绩效的员工的上级领导手机号
// 上个月
DateTime lastMonthDate = DateUtil.offsetMonth(new Date(), -1);
String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN);
List<String> mobilePhoneList = effectiveReferralReviewMapper.queryQwSendMobilePhoneList(lastMonth);
if (CollUtil.isEmpty(mobilePhoneList)) {
log.info("没有未处理有效引荐书对应的区域运营手机号");
return;
}
Map<String, String> sendUserIds = qWManager.getSendUserIds();
String joinedUserIds = qWManager.getJoinedUserIds(sendUserIds, mobilePhoneList);
SendWorkWechatMessageRequestDTO requestDTO = new SendWorkWechatMessageRequestDTO();
// dev = 44209813 test = 44209813
// 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id", Integer.class, 44202977);
String title = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.title", String.class, "有效引荐数复核提醒通知");
String btnTxt = OrePropertyConfigurer.getProperty("dj.send.work.wechat.btnTxt", String.class, "去处理");
String url = OrePropertyConfigurer.getProperty("dj.send.work.wechat.perf.url", String.class, "");
String descriptionEvn = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.description", String.class,
"你好,本月的门店复核有效引荐数存在未复核的,请尽快去完成~ \n" +
"亲,超过总部配置的每月{}号,就无法复核门店有效引荐数了哦");
// 获取endDate的日期数
Integer dayDate = DateUtil.dayOfMonth(endDate);
requestDTO.setMerchantId(merchantId);
requestDTO.setToUser(joinedUserIds);
requestDTO.setMsgType(WorkWechatAppMessageTypeEnum.TEXTCARD.getValue());
String description = StrUtil.format(descriptionEvn, dayDate);
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title);
textCard.setDescription(description);
textCard.setBtnTxt(btnTxt);
textCard.setUrl(url);
requestDTO.setTextCard(textCard);
try {
qWManager.sendMessage(requestDTO);
} catch (Exception e) {
log.error("发送企微应用消息异常:", e);
}
}
public void qwOnLineNotification() {
}
}
......@@ -2,18 +2,27 @@ package cn.com.glsx.dj.staff.service.perfSalary;
import cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewCommonDTO;
import cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewDTO;
import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO;
import cn.com.glsx.dj.staff.dto.salary.StaffSalaryDetailDTO;
import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum;
import cn.com.glsx.dj.staff.mapper.perfSalary.EffectiveReferralReviewMapper;
import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview;
import cn.com.glsx.dj.staff.service.staffPerformance.PerformanceTimeCycleService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Slf4j
@Service
......@@ -23,26 +32,67 @@ public class EffectiveReferralReviewService {
@Resource
private EffectiveReferralReviewMapper effectiveReferralReviewMapper;
@Resource
private PerformanceTimeCycleService performanceTimeCycleService;
/**
* 查询门店有效数列表
*
* @param pagination 列表参数
* @return 门店列表
*/
public RpcPagination<EffectiveReferralReviewCommonDTO> effectiveReferralPage(RpcPagination<EffectiveReferralReviewCommonDTO> pagination) {
PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
List<EffectiveReferralReviewCommonDTO> list = null;
Page<EffectiveReferralReviewCommonDTO> page = (Page<EffectiveReferralReviewCommonDTO>) list;
Page<EffectiveReferralReviewCommonDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
effectiveReferralReviewMapper.selectStoreEffectiveReferralList(pagination.getCondition());
pagination = RpcPagination.copyPage(page);
return pagination;
}
/**
* 查询门店有效数审核列表
*
* @param pagination 查询参数
* @return 门店列表
*/
public RpcPagination<EffectiveReferralReviewCommonDTO> effectiveReferralAuditPage(RpcPagination<EffectiveReferralReviewCommonDTO> pagination) {
PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
List<EffectiveReferralReviewCommonDTO> list = null;
Page<EffectiveReferralReviewCommonDTO> page = (Page<EffectiveReferralReviewCommonDTO>) list;
//1、查询需要复核的有效引荐数列表
Page<EffectiveReferralReviewCommonDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
List<EffectiveReferralReviewCommonDTO> list = effectiveReferralReviewMapper.selectStoreEffectiveReferralList(pagination.getCondition());
//2、查询T1时间配置
PerformanceTimeCycleDTO performanceTimeCycleDTO = performanceTimeCycleService.selectByCode(PerformanceTimeCycleCodeEnum.T1.getCode());
//3、填充复核状态,待复核状态下的数据,如果当前时间大于T1时间配置内的结束时间,置为已失效
for (EffectiveReferralReviewCommonDTO item : list) {
if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null
&& item.getIsReviewed().equals(0)) {
if (new Date().after(performanceTimeCycleDTO.getEndDate())) {
item.setIsReviewed(2);
}
}
}
//4、返回结果
pagination = RpcPagination.copyPage(page);
return pagination;
}
/**
* 查询有效引荐数详情
*
* @param id 主键
* @return 详情
*/
public EffectiveReferralReviewCommonDTO effectiveReferralDetail(Integer id) {
return (EffectiveReferralReviewCommonDTO) effectiveReferralReviewMapper.selectByPrimaryKey(id);
EffectiveReferralReviewCommonDTO commonDTO = new EffectiveReferralReviewCommonDTO();
commonDTO.setIds(Lists.newArrayList(id));
List<EffectiveReferralReviewCommonDTO> referralReviewCommonDTOS = effectiveReferralReviewMapper.selectStoreEffectiveReferralList(commonDTO);
if (referralReviewCommonDTOS.isEmpty()) {
return null;
}
return referralReviewCommonDTOS.get(0);
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
......
package cn.com.glsx.dj.staff.service.perfSalary;
import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO;
import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum;
import cn.com.glsx.dj.staff.mapper.PerformanceTimeCycleMapper;
import cn.com.glsx.dj.staff.mapper.perfSalary.PerformanceEvaluationMapper;
import cn.com.glsx.dj.staff.service.common.QWManager;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.WorkWechatTextCardMessageDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.enums.WorkWechatAppMessageTypeEnum;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class PerfQwNotificationService {
@Resource
private QWManager qWManager;
@Resource
private PerformanceTimeCycleMapper performanceTimeCycleMapper;
@Resource
private PerformanceEvaluationMapper performanceEvaluationMapper;
public void perfQwNotification() {
// 判断当前时间是否在T1范围内 如果不在则return
// 校验是否在修改的时间
PerformanceTimeCycleDTO performanceTimeCycleDTO = performanceTimeCycleMapper.selectByCode(PerformanceTimeCycleCodeEnum.T1.getCode());
Date startDate = performanceTimeCycleDTO.getStartDate();
Date endDate = performanceTimeCycleDTO.getEndDate();
Date now = DateUtil.date();
// 判断当前时间是否在考核时间范围内 当前时间需要大于等于开始时间,小于等于结束时间
boolean judgeTime = now.compareTo(startDate) < 0 || now.compareTo(endDate) > 0;
if (judgeTime) {
return;
}
// 获取所有未处理绩效的员工的上级领导手机号
// 上个月
DateTime lastMonthDate = DateUtil.offsetMonth(new Date(), -1);
String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN);
List<String> mobilePhoneList = performanceEvaluationMapper.querySuperiorLeaderMobilePhoneLeader(lastMonth);
if (CollUtil.isEmpty(mobilePhoneList)) {
log.info("没有未处理绩效的员工的上级领导手机号");
return;
}
Map<String, String> sendUserIds = qWManager.getSendUserIds();
String joinedUserIds = qWManager.getJoinedUserIds(sendUserIds, mobilePhoneList);
SendWorkWechatMessageRequestDTO requestDTO = new SendWorkWechatMessageRequestDTO();
// dev = 44209813 test = 44209813
// 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id", Integer.class, 44202977);
String title = OrePropertyConfigurer.getProperty("dj.send.work.wechat.perf.title", String.class, "驻店销售评绩效通知");
String btnTxt = OrePropertyConfigurer.getProperty("dj.send.work.wechat.btnTxt", String.class, "去处理");
String url = OrePropertyConfigurer.getProperty("dj.send.work.wechat.perf.url", String.class, "");
String descriptionEvn = OrePropertyConfigurer.getProperty("dj.send.work.wechat.perf.description", String.class,
"你好,本月的驻店销售评分开始了,请尽快去完成~\n" +
"1号凌晨1点,根据总部配置的自动评绩效规则,已出首轮续效哦,支持手工修改;\n" +
"亲,超过总部配置的每月{}号,就无法评绩效了哦;");
// 获取endDate的日期数
Integer dayDate = DateUtil.dayOfMonth(endDate);
requestDTO.setMerchantId(merchantId);
requestDTO.setToUser(joinedUserIds);
requestDTO.setMsgType(WorkWechatAppMessageTypeEnum.TEXTCARD.getValue());
String description = StrUtil.format(descriptionEvn, dayDate);
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title);
textCard.setDescription(description);
textCard.setBtnTxt(btnTxt);
textCard.setUrl(url);
requestDTO.setTextCard(textCard);
try {
qWManager.sendMessage(requestDTO);
} catch (Exception e) {
log.error("发送企微应用消息异常:", e);
}
}
}
......@@ -9,8 +9,9 @@ import cn.com.glsx.dj.staff.dto.*;
import cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO;
import cn.com.glsx.dj.staff.enums.AssessmentFactorEnum;
import cn.com.glsx.dj.staff.enums.CommissionMethodEnum;
import cn.com.glsx.dj.staff.enums.ProductConfigTypeEnum;
import cn.com.glsx.dj.staff.enums.CommissionTypeEnum;
import cn.com.glsx.dj.staff.enums.PerformanceConditionTypeEnum;
import cn.com.glsx.dj.staff.enums.GoodsConfigTypeEnum;
import cn.com.glsx.dj.staff.mapper.StaffPerformanceCalMapper;
import cn.com.glsx.dj.staff.service.perfSalary.EffectiveReferralReviewService;
import cn.com.glsx.dj.staff.service.staffPerformance.util.StaffPerformanceOrderUtil;
......@@ -477,13 +478,13 @@ public class StaffPerformanceCalService {
}
/**
* 创建绩效明细DTO
* 创建提成明细DTO
*
* @param context 计算上下文
* @param paramConfig 绩效参数配置
* @param paramConfig 提成参数配置
* @param actualValue 考核因子实际值
* @param paramConfigs 该组所有绩效参数配置
* @return 绩效明细DTO
* @param paramConfigs 该组所有提成参数配置
* @return 提成明细DTO
*/
private StaffPerformanceDetailDTO createPerformanceDetailDTO(StaffPerformanceCalContextDTO context,
PerformanceParamConfigDTO paramConfig,
......@@ -531,15 +532,14 @@ public class StaffPerformanceCalService {
/**
* 计算最终提成金额
*
* @param detailDTO 绩效明细DTO
* @param detailDTO 提成明细DTO
*/
private void calculateFinalCommission(StaffPerformanceDetailDTO detailDTO) {
// 非系数的计算提成金额
BigDecimal commission = null;
// TODO 换成枚举
if ("DDJE".equals(detailDTO.getCommissionType())) {
if (Objects.equals(detailDTO.getCommissionType(), CommissionTypeEnum.GDJE.getCode())) {
commission = detailDTO.getCommissionTypeValue();
} else if ("BL".equals(detailDTO.getCommissionType())) {
} else if (Objects.equals(detailDTO.getCommissionType(), CommissionTypeEnum.BL.getCode())) {
// 比例:基数 * 比例
if (detailDTO.getCommissionTypeValue() != null) {
commission = detailDTO.getGmvOutput()
......@@ -554,11 +554,11 @@ public class StaffPerformanceCalService {
}
/**
* 根据条件计算额外的绩效参数(如扣减、奖励、降档等)
* 根据条件计算额外的提成参数(如扣减、奖励、降档等)
*
* @param detailDTO 绩效明细DTO
* @param paramConfig 当前绩效参数配置
* @param paramConfigs 该组所有绩效参数配置
* @param detailDTO 提成明细DTO
* @param paramConfig 当前提成参数配置
* @param paramConfigs 该组所有提成参数配置
* @param context 计算上下文
*/
private void calculateByConditions(StaffPerformanceDetailDTO detailDTO, PerformanceParamConfigDTO paramConfig,
......@@ -581,16 +581,33 @@ public class StaffPerformanceCalService {
JSONObject resultLog = new JSONObject();
try {
if (condition.getConditionType() == 1) {
skipPenetrationRateCondition = processPenetrationRateCondition(detailDTO,
paramConfig, paramConfigs,
context, condition, resultLog, skipPenetrationRateCondition);
} else if (condition.getConditionType() == 2) {
processOrderCountDeductionCondition(detailDTO, context, condition, resultLog);
} else if (condition.getConditionType() == 3) {
processTargetAchievementRewardCondition(detailDTO, condition, resultLog);
} else if (condition.getConditionType() == 4) {
processOrderExclusionCondition(detailDTO, context, condition, resultLog);
PerformanceConditionTypeEnum conditionTypeEnum = PerformanceConditionTypeEnum
.getByCode(condition.getConditionType());
if (conditionTypeEnum == null) {
throw new RpcServiceException("未知的条件类型: " + condition.getConditionType());
}
switch (conditionTypeEnum) {
case PENETRATION_RATE_LIMIT:
skipPenetrationRateCondition = processPenetrationRateCondition(
detailDTO,
paramConfig, paramConfigs,
context, condition, resultLog,
skipPenetrationRateCondition);
break;
case ORDER_COUNT_DEDUCTION:
processOrderCountDeductionCondition(detailDTO, context, condition,
resultLog);
break;
case TARGET_ACHIEVEMENT_REWARD:
processTargetAchievementRewardCondition(detailDTO, condition,
resultLog);
break;
case ORDER_EXCLUSION_INCLUSION:
processOrderExclusionCondition(detailDTO, context, condition,
resultLog);
break;
default:
throw new RpcServiceException("未处理的条件类型: " + conditionTypeEnum);
}
} catch (RpcServiceException e) {
// 业务异常主要针对渗透率限制的校验,需要抛出
......@@ -610,15 +627,15 @@ public class StaffPerformanceCalService {
paramsJson.put("conditionExecutions", conditionExecutions);
detailDTO.setParamsJson(paramsJson.toJSONString());
log.info("条件计算完成: staffPhone={}, paramsJson={}", detailDTO.getStaffPhone(), paramsJson.toJSONString());
log.debug("条件计算完成: staffPhone={}, paramsJson={}", detailDTO.getStaffPhone(), paramsJson.toJSONString());
}
/**
* 处理渗透率限制条件
*
* @param detailDTO 绩效明细DTO
* @param paramConfig 当前绩效参数配置
* @param paramConfigs 该组所有绩效参数配置
* @param detailDTO 提成明细DTO
* @param paramConfig 当前提成参数配置
* @param paramConfigs 该组所有提成参数配置
* @param context 计算上下文
* @param condition 当前条件
* @param resultLog 结果日志
......@@ -646,18 +663,19 @@ public class StaffPerformanceCalService {
resultLog.put("limitStart", condition.getConditionStartValue());
resultLog.put("limitEnd", condition.getConditionEndValue());
// 判断是否在区间内 [start, end)
// 判断是否在区间内 [start, end]
boolean inRange = false;
BigDecimal start = condition.getConditionStartValue() == null ? BigDecimal.ZERO
: condition.getConditionStartValue();
BigDecimal end = condition.getConditionEndValue();
boolean inRange;
if (end == null) {
inRange = conditionProductPenetrationRate.compareTo(start) >= 0;
} else {
inRange = conditionProductPenetrationRate.compareTo(start) >= 0
&& conditionProductPenetrationRate.compareTo(end) <= 0;
if (conditionProductPenetrationRate != null) {
if (end == null) {
inRange = conditionProductPenetrationRate.compareTo(start) >= 0;
} else {
inRange = conditionProductPenetrationRate.compareTo(start) >= 0
&& conditionProductPenetrationRate.compareTo(end) <= 0;
}
}
log.info("渗透率限制检查: rate={}, range=[{}, {}], pass={}", conditionProductPenetrationRate, start, end,
inRange);
......@@ -671,9 +689,9 @@ public class StaffPerformanceCalService {
/**
* 处理降档逻辑
*
* @param detailDTO 绩效明细DTO
* @param paramConfig 当前绩效参数配置
* @param paramConfigs 该组所有绩效参数配置
* @param detailDTO 提成明细DTO
* @param paramConfig 当前提成参数配置
* @param paramConfigs 该组所有提成参数配置
* @param resultLog 结果日志
*/
private void handleDegradation(StaffPerformanceDetailDTO detailDTO, PerformanceParamConfigDTO paramConfig,
......@@ -725,7 +743,7 @@ public class StaffPerformanceCalService {
/**
* 处理订单数不足扣减条件
*
* @param detailDTO 绩效明细DTO
* @param detailDTO 提成明细DTO
* @param context 计算上下文
* @param condition 当前条件
* @param resultLog 结果日志
......@@ -783,7 +801,7 @@ public class StaffPerformanceCalService {
/**
* 处理整体指标达成奖励条件
*
* @param detailDTO 绩效明细DTO
* @param detailDTO 提成明细DTO
* @param condition 当前条件
* @param resultLog 结果日志
*/
......@@ -803,7 +821,7 @@ public class StaffPerformanceCalService {
/**
* 处理订单数剔除条件
*
* @param detailDTO 绩效明细DTO
* @param detailDTO 提成明细DTO
* @param context 计算上下文
* @param condition 当前条件
* @param resultLog 结果日志
......@@ -816,7 +834,7 @@ public class StaffPerformanceCalService {
context.getBusinessType(), context.getBrandId(),
context.getChildBrandId());
List<StaffPerformanceSubOrderDTO> orders = context.getGroupedOrdersMap().get(groupKey);
int excludedOrderCount = (int) StaffPerformanceOrderUtil.countMatchingOrders(orders,
Integer excludedOrderCount = StaffPerformanceOrderUtil.countMatchingOrders(orders,
condition.getConditionGoodsConfigType(),
condition.getConditionGoodsType(),
condition.getConditionSecondaryGoodsType(),
......@@ -1006,7 +1024,7 @@ public class StaffPerformanceCalService {
childBrandId,
context.getPerformanceMonth());
if (config == null) {
log.error("未找到有效的绩效配置,不计算提成: merchantId={}, brandId={}, month={}",
log.error("未找到有效的提成配置,不计算提成: merchantId={}, brandId={}, month={}",
merchantId, brandId, context.getPerformanceMonth());
return;
}
......@@ -1014,7 +1032,7 @@ public class StaffPerformanceCalService {
context.setPerformanceConfig(config);
if (CollectionUtils.isEmpty(config.getPerformanceParamConfigs())) {
log.error("未找到绩效参数配置,不计算提成: configId:{}", config.getId());
log.error("未找到提成参数配置,不计算提成: configId:{}", config.getId());
return;
}
List<StaffPerformanceDetailDTO> performanceDetailDTOS = thiz.evaluatePerformanceConfigs(context);
......@@ -1028,14 +1046,14 @@ public class StaffPerformanceCalService {
}
/**
* 获取有效的绩效配置
* 获取有效的提成配置
*
* @param merchantId 商户ID
* @param businessType 业务类型
* @param brandId 品牌ID
* @param childBrandId 子品牌ID
* @param month 月份
* @return 绩效配置DTO
* @return 提成配置DTO
*/
private PerformanceConfigDTO getEffectivePerformanceConfig(Integer merchantId, Byte businessType,
Integer brandId,
......@@ -1054,7 +1072,7 @@ public class StaffPerformanceCalService {
.build();
PerformanceConfigDTO config = performanceConfigService.selectEffectiveConfig(queryConfig);
if (config == null) {
log.warn("未找到有效的绩效配置: merchantId={}, businessType={}, brandId={}, childBrandId={}, month={}",
log.warn("未找到有效的提成配置: merchantId={}, businessType={}, brandId={}, childBrandId={}, month={}",
merchantId, businessType, brandId, childBrandId, month);
}
return config;
......@@ -1088,9 +1106,9 @@ public class StaffPerformanceCalService {
assessmentFactor, goodsConfigType, goodsType, secondaryGoodsType,
thirdLevelGoodsType, productDefineId);
if (Objects.equals(firstConfig.getCommissionType(), CommissionMethodEnum.XS.getCode())
if (Objects.equals(firstConfig.getCommissionType(), CommissionTypeEnum.XS.getCode())
&& !Objects.equals(goodsConfigType,
ProductConfigTypeEnum.ALL_PRODUCT.getCode())) {
GoodsConfigTypeEnum.ALL_PRODUCT.getCode())) {
throw new RpcServiceException(DefaultErrorEnum.DATA_INVALID, "系数计算方式必须指定为全部品类");
}
BigDecimal actualValue = getActualValue(assessmentFactor, context,
......@@ -1104,10 +1122,14 @@ public class StaffPerformanceCalService {
goodsConfigType, goodsType,
secondaryGoodsType, thirdLevelGoodsType,
productDefineId, assessmentFactor, actualValue);
if (actualValue == null) {
log.warn("实际值为空,跳过计算");
continue;
}
for (PerformanceParamConfigDTO paramConfig : paramConfigs) {
if (isConfigMatch(paramConfig, actualValue)) {
log.info("匹配到绩效配置ID: {}", paramConfig.getId());
log.info("匹配到提成配置ID: {}", paramConfig.getId());
StaffPerformanceDetailDTO performanceDTO = createPerformanceDetailDTO(context,
paramConfig, actualValue, paramConfigs);
groupResults.add(performanceDTO);
......@@ -1158,15 +1180,25 @@ public class StaffPerformanceCalService {
final List<Byte> validOrderTypes = getValidDjOrderTypesForCommissionBasic();
// 3. 根据配置类型分别处理
if (Objects.equals(ProductConfigTypeEnum.PRODUCT_CATEGORY.getCode(), goodsConfigType)
|| Objects.equals(ProductConfigTypeEnum.DESIGNATED_PRODUCT.getCode(),
goodsConfigType)) {
processCategoryOrProductData(context, orders, goodsConfigType, goodsType, secondaryGoodsType,
thirdLevelGoodsType, productDefine, validOrderTypes);
} else if (Objects.equals(ProductConfigTypeEnum.DESIGNATED_PACKAGE.getCode(), goodsConfigType)) {
processPackageData(context, orders, productDefine, validOrderTypes);
} else {
GoodsConfigTypeEnum configType = GoodsConfigTypeEnum.getByCode(goodsConfigType);
if (configType == null) {
log.warn("未知的商品配置类型: {}", goodsConfigType);
return;
}
switch (configType) {
case DESIGNATED_PACKAGE:
processPackageData(context, orders, productDefine, validOrderTypes);
break;
case ALL_PRODUCT:
case PRODUCT_CATEGORY:
case DESIGNATED_PRODUCT:
processCategoryOrProductData(context, orders, goodsConfigType, goodsType,
secondaryGoodsType,
thirdLevelGoodsType, productDefine, validOrderTypes);
break;
default:
log.warn("未知的商品配置类型: {}", goodsConfigType);
break;
}
}
......@@ -1179,8 +1211,8 @@ public class StaffPerformanceCalService {
*/
private MerchantPerformanceProductDefineDTO getMerchantPerformanceProductDefine(Byte goodsConfigType,
Integer productDefineId) {
if (Objects.equals(ProductConfigTypeEnum.DESIGNATED_PRODUCT.getCode(), goodsConfigType)
|| Objects.equals(ProductConfigTypeEnum.DESIGNATED_PACKAGE.getCode(),
if (Objects.equals(GoodsConfigTypeEnum.DESIGNATED_PRODUCT.getCode(), goodsConfigType)
|| Objects.equals(GoodsConfigTypeEnum.DESIGNATED_PACKAGE.getCode(),
goodsConfigType)) {
RpcAssert.assertNotNull(productDefineId, DefaultErrorEnum.DATA_NULL, "圈定商品ID不能为空");
MerchantPerformanceProductDefineDTO productDefine = merchantPerformanceProductDefineRemote
......@@ -1238,7 +1270,7 @@ public class StaffPerformanceCalService {
orderData.setSubOrderCountByBrandAndCategory(subOrderCount);
orderData.setCategoryOrderOutputTotalByBrandAndCategory(outputTotal);
log.info("品类/单品基础数据: mainOrderCount={}, subOrderCount={}, outputTotal={}", mainOrderCount,
log.debug("品类/单品基础数据: mainOrderCount={}, subOrderCount={}, outputTotal={}", mainOrderCount,
subOrderCount,
outputTotal);
......@@ -1255,7 +1287,7 @@ public class StaffPerformanceCalService {
orderData.setCommissionBaseSubOrderCountByBrandAndCategory(commissionBaseSubOrderCount);
orderData.setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory(commissionBaseOutputTotal);
log.info("品类/单品提成基数数据: baseSubOrderCount={}, baseOutputTotal={}", commissionBaseSubOrderCount,
log.debug("品类/单品提成基数数据: baseSubOrderCount={}, baseOutputTotal={}", commissionBaseSubOrderCount,
commissionBaseOutputTotal);
}
......@@ -1299,7 +1331,7 @@ public class StaffPerformanceCalService {
orderData.setSubOrderCountByBrandAndCategory(subOrderCount);
orderData.setCategoryOrderOutputTotalByBrandAndCategory(outputTotal);
log.info("套系基础数据: mainOrderCount={}, outputTotal={}", mainOrderCount, outputTotal);
log.debug("套系基础数据: mainOrderCount={}, outputTotal={}", mainOrderCount, outputTotal);
// 计算提成基数相关数据 (过滤特定订单类型)
// 注意:这里原文是 filter groupedOrders.values() 再 filter matchPackage,这里直接复用
......@@ -1319,7 +1351,7 @@ public class StaffPerformanceCalService {
orderData.setCommissionBaseSubOrderCountByBrandAndCategory(commissionBaseMainOrderCount);
orderData.setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory(commissionBaseOutputTotal);
log.info("套系提成基数数据: baseMainOrderCount={}, baseOutputTotal={}", commissionBaseMainOrderCount,
log.debug("套系提成基数数据: baseMainOrderCount={}, baseOutputTotal={}", commissionBaseMainOrderCount,
commissionBaseOutputTotal);
}
......
......@@ -50,9 +50,9 @@ public class StaffPerformanceDetailService {
return;
}
// 1. 调用mapper,通过update更新相同merchantId businessType brandId childBrandId
// performanceMonth的记录的deletedFlag = 'D'
// 1. 逻辑删除旧数据
StaffPerformanceDetail query = StaffPerformanceDetail.builder()
.staffPhone(performanceDetailDTOS.get(0).getStaffPhone())
.merchantId(config.getMerchantId())
.businessType(config.getBusinessType())
.brandId(config.getBrandId())
......
......@@ -5,7 +5,7 @@ import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO;
import cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO;
import cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO;
import cn.com.glsx.dj.staff.enums.CommissionMethodEnum;
import cn.com.glsx.dj.staff.enums.CommissionTypeEnum;
import cn.com.glsx.dj.staff.mapper.StaffPerformanceMapper;
import cn.com.glsx.dj.staff.model.StaffBeisenBaseInfo;
import cn.com.glsx.dj.staff.model.StaffPerformance;
......@@ -52,43 +52,31 @@ public class StaffPerformanceService {
log.error("输入数据无效: context 为空或 performanceDetailDTOS 为空");
return;
}
// 1. 根据 merchantId, businessType, brandId, childBrandId 分组
Map<String, List<StaffPerformanceDetailDTO>> groupedMap = groupPerformanceDetails(performanceDetailDTOS);
String staffPhone = context.getStaffPhone();
Integer merchantId = context.getMerchantId();
Byte businessType = context.getBusinessType();
Integer brandId = context.getBrandId();
Integer childBrandId = context.getChildBrandId();
String performanceMonth = context.getPerformanceMonth();
if (merchantId == null || businessType == null || brandId == null || childBrandId == null
|| StringUtils.isBlank(performanceMonth) || StringUtils.isBlank(staffPhone)) {
log.error(
"输入数据无效: merchantId={}, businessType={}, brandId={}, childBrandId={}, performanceMonth={}, staffPhone={}",
merchantId, businessType, brandId, childBrandId, performanceMonth, staffPhone);
return;
}
// 2. 检查是否处于新人保护期
boolean isNewcomerProtection = checkNewcomerProtection(context.getStaffPhone(), context.getPerformanceMonth());
List<StaffPerformance> insertList = new ArrayList<>();
Date now = new Date();
for (List<StaffPerformanceDetailDTO> groupList : groupedMap.values()) {
if (CollectionUtils.isEmpty(groupList)) {
continue;
}
// 3. 构建 StaffPerformance
StaffPerformance staffPerformance = buildStaffPerformance(groupList, context, isNewcomerProtection, now);
insertList.add(staffPerformance);
// 3. 构建 StaffPerformance
StaffPerformance staffPerformance = buildStaffPerformance(performanceDetailDTOS, context, isNewcomerProtection);
// 4. 逻辑删除旧数据
staffPerformanceMapper.removeStaffPerformance(staffPerformance);
}
// 5. 批量插入新数据
if (CollectionUtils.isNotEmpty(insertList)) {
staffPerformanceMapper.insertList(insertList);
}
}
// 4. 逻辑删除旧数据
staffPerformanceMapper.removeStaffPerformance(staffPerformance);
/**
* 对详情数据进行分组
*/
private Map<String, List<StaffPerformanceDetailDTO>> groupPerformanceDetails(
List<StaffPerformanceDetailDTO> details) {
return details.stream()
.collect(Collectors.groupingBy(dto -> dto.getMerchantId() + "_" + dto.getBusinessType()
+ "_" + dto.getBrandId() + "_" + dto.getChildBrandId()));
// 5. 插入新数据
staffPerformanceMapper.insertSelective(staffPerformance);
}
/**
......@@ -136,8 +124,7 @@ public class StaffPerformanceService {
*/
private StaffPerformance buildStaffPerformance(List<StaffPerformanceDetailDTO> groupList,
StaffPerformanceCalContextDTO context,
boolean isNewcomerProtection,
Date now) {
boolean isNewcomerProtection) {
StaffPerformanceDetailDTO first = groupList.get(0);
StaffPerformance staffPerformance = new StaffPerformance();
......@@ -153,6 +140,7 @@ public class StaffPerformanceService {
staffPerformance.setChildBrandName(first.getChildBrandName());
staffPerformance.setMonth(first.getMonth());
Date now = new Date();
staffPerformance.setCreatedBy(CommonConstants.DEFAULT_UPDATE_BY);
staffPerformance.setUpdatedBy(CommonConstants.DEFAULT_UPDATE_BY);
staffPerformance.setCreatedDate(now);
......@@ -193,7 +181,7 @@ public class StaffPerformanceService {
// 遍历详情计算
for (StaffPerformanceDetailDTO detail : groupList) {
// 判断是否为系数类型 (假设 'XS' 为系数代码)
if (CommissionMethodEnum.XS.getCode().equals(detail.getCommissionType())) {
if (CommissionTypeEnum.XS.getCode().equals(detail.getCommissionType())) {
if (detail.getCommissionTypeValue() != null) {
multiplyCoeff = multiplyCoeff.multiply(detail.getCommissionTypeValue());
}
......
......@@ -7,15 +7,20 @@ import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO;
import cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO;
import cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO;
import cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO;
import cn.com.glsx.dj.staff.enums.CommissionTypeEnum;
import cn.com.glsx.dj.staff.enums.GoodsConfigTypeEnum;
import cn.com.glsx.dj.staff.mapper.StaffProductPerformanceMapper;
import cn.com.glsx.dj.staff.model.StaffProductPerformance;
import cn.com.glsx.dj.staff.service.perfSalary.AutoPerformRuleService;
import cn.com.glsx.dj.staff.service.staffPerformance.util.StaffPerformanceOrderUtil;
import cn.com.glsx.dj.staff.util.DataCalUtil;
import cn.com.glsx.framework.core.beans.BaseModel.DeletedFlagEnum;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
......@@ -23,6 +28,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.ctc.wstx.util.StringUtil;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
......@@ -32,6 +39,8 @@ import java.util.stream.Collectors;
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class StaffProductPerformanceService {
private final AutoPerformRuleService autoPerformRuleService;
@Lazy
@Autowired
private StaffProductPerformanceService thiz;
......@@ -40,6 +49,10 @@ public class StaffProductPerformanceService {
@Autowired
private MerchantPerformanceProductDefineRemote merchantPerformanceProductDefineRemote;
StaffProductPerformanceService(AutoPerformRuleService autoPerformRuleService) {
this.autoPerformRuleService = autoPerformRuleService;
}
public List<StaffProductPerformanceDTO> listStaffPerformance(StaffProductPerformanceDTO dto) {
try {
return staffProductPerformanceMapper.listStaffPerformance(dto);
......@@ -57,18 +70,26 @@ public class StaffProductPerformanceService {
log.error("saveStaffProductPerformance param error 1");
return;
}
if (context.getMerchantId() == null || context.getBusinessType() == null || context.getBrandId() == null
|| context.getChildBrandId() == null || context.getPerformanceMonth() == null
|| context.getStaffPhone() == null) {
Integer merchantId = context.getMerchantId();
Byte businessType = context.getBusinessType();
Integer brandId = context.getBrandId();
Integer childBrandId = context.getChildBrandId();
String performanceMonth = context.getPerformanceMonth();
String staffPhone = context.getStaffPhone();
if (merchantId == null || businessType == null || brandId == null || childBrandId == null
|| StringUtils.isBlank(performanceMonth) || StringUtils.isBlank(staffPhone)) {
log.error("saveStaffProductPerformance param error 2");
return;
}
log.info(
"saveStaffProductPerformance, staffPhone:{}, performanceMonth:{}, merchantId:{}, businessType:{}, brandId:{}, childBrandId:{}, ",
staffPhone, performanceMonth, merchantId, businessType, brandId, childBrandId);
// 2. 构建StaffProductPerformance列表
List<StaffProductPerformance> insertList = buildStaffProductPerformances(context, performanceDetailDTOS);
// 3. 逻辑删除之前的数据
staffProductPerformanceMapper.removeStaffProductPerformance(
int removeStaffProductPerformance = staffProductPerformanceMapper.removeStaffProductPerformance(
context.getMerchantId(),
context.getBusinessType(),
context.getBrandId(),
......@@ -76,15 +97,22 @@ public class StaffProductPerformanceService {
context.getPerformanceMonth(),
context.getStaffPhone(),
CommonConstants.DEFAULT_UPDATE_BY);
log.debug("removeStaffProductPerformance, removeStaffProductPerformance count:{}, ",
removeStaffProductPerformance);
// 4.入库
if (CollectionUtils.isNotEmpty(insertList)) {
staffProductPerformanceMapper.insertList(insertList);
log.debug("insertStaffProductPerformance, insertStaffProductPerformance count:{}, ", insertList.size());
}
}
private List<StaffProductPerformance> buildStaffProductPerformances(StaffPerformanceCalContextDTO context,
List<StaffPerformanceDetailDTO> performanceDetailDTOS) {
if (CollectionUtils.isEmpty(performanceDetailDTOS)) {
return new ArrayList<>();
}
// 品类分组
Map<String, List<StaffPerformanceDetailDTO>> groupedMap = performanceDetailDTOS.stream()
.collect(Collectors.groupingBy(this::generateGroupKey));
List<StaffProductPerformance> insertList = new ArrayList<>();
......@@ -98,7 +126,7 @@ public class StaffProductPerformanceService {
// 2.2 累计得到提成金额
BigDecimal totalAmount = dtoList.stream()
.filter(d -> !"XS".equals(d.getCommissionType()))
.filter(d -> !CommissionTypeEnum.XS.getCode().equals(d.getCommissionType()))
.map(d -> Optional.ofNullable(d.getPerformanceAmount()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
productPerformance.setPerformanceAmount(totalAmount);
......@@ -153,22 +181,13 @@ public class StaffProductPerformanceService {
private void calculateAndFillMetrics(StaffProductPerformance productPerformance,
StaffPerformanceDetailDTO detailDTO, StaffPerformanceCalContextDTO context) {
Byte goodsConfigType = detailDTO.getGoodsConfigType();
Integer goodsType = detailDTO.getGoodsType();
Integer secondaryGoodsType = detailDTO.getSecondaryGoodsType();
Integer thirdLevelGoodsType = detailDTO.getThirdLevelGoodsType();
Integer productDefineId = detailDTO.getProductDefineId();
MerchantPerformanceProductDefineDTO productDefine = null;
if (goodsConfigType != null && (goodsConfigType == 1 || goodsConfigType == 2)) {
if (productDefineId != null) {
productDefine = merchantPerformanceProductDefineRemote
.getByIdWithRadicalUpgradeGoodsItem(productDefineId).getResult();
}
}
// 1. 获取产品定义配置
MerchantPerformanceProductDefineDTO productDefine = fetchProductDefine(goodsConfigType, productDefineId);
String groupKey = StaffPerformanceCalService.generateGroupOrderMapKey(context.getMerchantId(),
context.getBusinessType(), context.getBrandId(), context.getChildBrandId());
List<StaffPerformanceSubOrderDTO> orders = context.getGroupedOrdersMap().get(groupKey);
// 2. 获取当前层级关联的所有原始订单
List<StaffPerformanceSubOrderDTO> orders = getRelevantOrders(context);
if (CollectionUtils.isEmpty(orders)) {
productPerformance.setUpgradeOrderNum(0);
productPerformance.setPersonalPenetrationRate(BigDecimal.ZERO);
......@@ -176,62 +195,126 @@ public class StaffProductPerformanceService {
return;
}
// 过滤订单
final MerchantPerformanceProductDefineDTO finalProductDefine = productDefine;
final List<Byte> VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC = Arrays.stream(OrePropertyConfigurer
// 3. 根据配置类型计算指标(升级订单数、产值)
MetricsResult metrics = calculateMetricsByConfigType(orders, detailDTO, productDefine);
productPerformance.setUpgradeOrderNum(metrics.getUpgradeOrderNum());
productPerformance.setGmvOutput(metrics.getGmvOutput());
// 4. 计算并填充个人渗透率
BigDecimal penetrationRate = calculatePersonalPenetrationRate(context, metrics.getUpgradeOrderNum());
productPerformance.setPersonalPenetrationRate(penetrationRate);
}
private MerchantPerformanceProductDefineDTO fetchProductDefine(Byte goodsConfigType, Integer productDefineId) {
if (goodsConfigType == null || productDefineId == null) {
return null;
}
GoodsConfigTypeEnum configTypeEnum = GoodsConfigTypeEnum.getByCode(goodsConfigType);
if (configTypeEnum == GoodsConfigTypeEnum.DESIGNATED_PRODUCT
|| configTypeEnum == GoodsConfigTypeEnum.DESIGNATED_PACKAGE) {
return merchantPerformanceProductDefineRemote
.getByIdWithRadicalUpgradeGoodsItem(productDefineId).getResult();
}
return null;
}
private List<StaffPerformanceSubOrderDTO> getRelevantOrders(StaffPerformanceCalContextDTO context) {
String groupKey = StaffPerformanceCalService.generateGroupOrderMapKey(context.getMerchantId(),
context.getBusinessType(), context.getBrandId(), context.getChildBrandId());
return context.getGroupedOrdersMap().get(groupKey);
}
private MetricsResult calculateMetricsByConfigType(List<StaffPerformanceSubOrderDTO> orders,
StaffPerformanceDetailDTO detailDTO, MerchantPerformanceProductDefineDTO productDefine) {
final List<Byte> validDjOrderTypes = Arrays.stream(OrePropertyConfigurer
.getString("valid.dj.order.type.for.commission.basic", "1,5").split(","))
.map(Byte::parseByte).collect(Collectors.toList());
long upgradeOrderNum = 0;
BigDecimal gmvOutput = BigDecimal.ZERO;
if (goodsConfigType != null && goodsConfigType == 2) {
// 套餐逻辑
if (finalProductDefine != null && CollectionUtils.isNotEmpty(finalProductDefine.getPackageItemList())) {
GoodsConfigTypeEnum configTypeEnum = GoodsConfigTypeEnum.getByCode(detailDTO.getGoodsConfigType());
if (configTypeEnum == null) {
return new MetricsResult(0, BigDecimal.ZERO);
}
switch (configTypeEnum) {
case DESIGNATED_PACKAGE:
// 套餐逻辑
RpcAssert.assertNotNull(productDefine, DefaultErrorEnum.DATA_NOT_EXIST, "productDefine is null");
RpcAssert.assertNotEmpty(productDefine.getPackageItemList(), DefaultErrorEnum.DATA_NOT_EXIST,
"productDefine.getPackageItemList() is empty");
Map<String, List<StaffPerformanceSubOrderDTO>> groupedOrders = orders.stream()
.collect(Collectors.groupingBy(StaffPerformanceSubOrderDTO::getOrderCode));
// 计算产值 (所有匹配的子订单)
gmvOutput = groupedOrders.values().stream()
.filter(o -> VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
.contains(o.get(0).getDjOrderType()))
.filter(o -> validDjOrderTypes.contains(o.get(0).getDjOrderType()))
.flatMap(o -> StaffPerformanceOrderUtil
.matchPackageSubOrders(o, finalProductDefine.getPackageItemList()).stream())
.matchPackageSubOrders(o, productDefine.getPackageItemList()).stream())
.map(o -> Optional.ofNullable(o.getOutputAmount()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 计算升级订单数 (满足 commission basic 类型的)
// 计算升级订单数
upgradeOrderNum = groupedOrders.values().stream()
.filter(o -> VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC.contains(o.get(0).getDjOrderType())
.filter(o -> validDjOrderTypes.contains(o.get(0).getDjOrderType())
&& StaffPerformanceOrderUtil.isOrderMatchPackage(o,
finalProductDefine.getPackageItemList()))
productDefine.getPackageItemList()))
.count();
}
} else {
// 单品逻辑
List<StaffPerformanceSubOrderDTO> matchedOrders = orders.stream()
.filter(o -> VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC.contains(o.getDjOrderType())
&& StaffPerformanceOrderUtil.isOrderMatchCategory(o, goodsConfigType, goodsType,
secondaryGoodsType,
thirdLevelGoodsType, finalProductDefine))
.collect(Collectors.toList());
gmvOutput = matchedOrders.stream()
.map(o -> Optional.ofNullable(o.getOutputAmount()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
break;
case ALL_PRODUCT:
case PRODUCT_CATEGORY:
case DESIGNATED_PRODUCT:
// 单品或品类逻辑
List<StaffPerformanceSubOrderDTO> matchedOrders = orders.stream()
.filter(o -> validDjOrderTypes.contains(o.getDjOrderType())
&& StaffPerformanceOrderUtil.isOrderMatchCategory(o, detailDTO.getGoodsConfigType(),
detailDTO.getGoodsType(), detailDTO.getSecondaryGoodsType(),
detailDTO.getThirdLevelGoodsType(), productDefine))
.collect(Collectors.toList());
upgradeOrderNum = matchedOrders.size();
gmvOutput = matchedOrders.stream()
.map(o -> Optional.ofNullable(o.getOutputAmount()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
upgradeOrderNum = matchedOrders.size();
break;
default:
log.error("Unsupported goodsConfigType: {}", detailDTO.getGoodsConfigType());
break;
}
productPerformance.setUpgradeOrderNum((int) upgradeOrderNum);
productPerformance.setGmvOutput(gmvOutput);
return new MetricsResult((int) upgradeOrderNum, gmvOutput);
}
// 计算个人渗透率
// 个人渗透率 = 升级订单数 / 个人应触客数
private BigDecimal calculatePersonalPenetrationRate(StaffPerformanceCalContextDTO context, int upgradeOrderNum) {
BigDecimal personalTargetTouchCount = context.getAssessmentFactorDependencyData().getDailyData()
.getPersonalTargetTouchCount();
BigDecimal targetTouch = Optional.ofNullable(personalTargetTouchCount).orElse(BigDecimal.ZERO);
BigDecimal penetrationRate = DataCalUtil.divideToPercent(new BigDecimal(upgradeOrderNum), targetTouch);
productPerformance.setPersonalPenetrationRate(penetrationRate);
if (personalTargetTouchCount == null) {
log.error("personalTargetTouchCount is null");
return BigDecimal.ZERO;
}
return DataCalUtil.divideToPercent(new BigDecimal(upgradeOrderNum), personalTargetTouchCount);
}
private static class MetricsResult {
private final int upgradeOrderNum;
private final BigDecimal gmvOutput;
public MetricsResult(int upgradeOrderNum, BigDecimal gmvOutput) {
this.upgradeOrderNum = upgradeOrderNum;
this.gmvOutput = gmvOutput;
}
public int getUpgradeOrderNum() {
return upgradeOrderNum;
}
public BigDecimal getGmvOutput() {
return gmvOutput;
}
}
}
......@@ -3,8 +3,9 @@ package cn.com.glsx.dj.staff.service.staffPerformance.util;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO;
import cn.com.glsx.dj.smartcarlife.model.MerchantPerformanceProductDefineItem;
import cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO;
import cn.com.glsx.dj.staff.enums.ProductConfigTypeEnum;
import cn.com.glsx.dj.staff.enums.GoodsConfigTypeEnum;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import org.apache.commons.collections.CollectionUtils;
......@@ -81,37 +82,47 @@ public class StaffPerformanceOrderUtil {
* @param productDefine 圈定商品定义(含套餐)
* @return 匹配数量
*/
public static long countMatchingOrders(List<StaffPerformanceSubOrderDTO> orders,
Integer goodsConfigType,
public static Integer countMatchingOrders(List<StaffPerformanceSubOrderDTO> orders,
Byte goodsConfigType,
Integer goodsType,
Integer secondaryGoodsType,
Integer thirdLevelGoodsType,
MerchantPerformanceProductDefineDTO productDefine) {
if (CollectionUtils.isEmpty(orders) || goodsConfigType == null) {
if (CollectionUtils.isEmpty(orders)) {
return 0;
}
// 3. 根据配置类型分别处理
GoodsConfigTypeEnum configType = GoodsConfigTypeEnum.getByCode(goodsConfigType);
if (configType == null) {
throw new RpcServiceException("不支持的商品配置类型: " + goodsConfigType);
}
switch (configType) {
case DESIGNATED_PACKAGE:
RpcAssert.assertNotNull(productDefine, DefaultErrorEnum.DATA_NULL,
"conditionProductDefine be null");
RpcAssert.assertNotEmpty(productDefine.getPackageItemList(), DefaultErrorEnum.DATA_NULL,
"conditionProductDefine.getPackageItemList() is empty");
if (goodsConfigType == 2) {
RpcAssert.assertNotNull(productDefine, DefaultErrorEnum.DATA_NULL,
"conditionProductDefine be null");
RpcAssert.assertNotEmpty(productDefine.getPackageItemList(), DefaultErrorEnum.DATA_NULL,
"conditionProductDefine.getPackageItemList() is empty");
Map<String, List<StaffPerformanceSubOrderDTO>> groupedOrders = orders.stream()
.collect(Collectors.groupingBy(StaffPerformanceSubOrderDTO::getOrderCode));
return groupedOrders.values().stream()
.filter(o -> isOrderMatchPackage(o, productDefine.getPackageItemList()))
.count();
} else {
return orders.stream()
.filter(o -> isOrderMatchCategory(o,
goodsConfigType.byteValue(),
goodsType,
secondaryGoodsType,
thirdLevelGoodsType,
productDefine))
.count();
Map<String, List<StaffPerformanceSubOrderDTO>> groupedOrders = orders.stream()
.collect(Collectors.groupingBy(StaffPerformanceSubOrderDTO::getOrderCode));
return (int) groupedOrders.values().stream()
.filter(o -> isOrderMatchPackage(o, productDefine.getPackageItemList()))
.count();
case ALL_PRODUCT:
case PRODUCT_CATEGORY:
case DESIGNATED_PRODUCT:
return (int) orders.stream()
.filter(o -> isOrderMatchCategory(o,
goodsConfigType,
goodsType,
secondaryGoodsType,
thirdLevelGoodsType,
productDefine))
.count();
default:
throw new RpcServiceException("不支持的商品配置类型: " + goodsConfigType);
}
}
/**
......@@ -134,12 +145,12 @@ public class StaffPerformanceOrderUtil {
RpcAssert.assertNotNull(goodsConfigType, DefaultErrorEnum.DATA_NULL, "goodsConfigType不能为空");
// TODO 改用枚举
// -1:全部商品
if (Objects.equals(ProductConfigTypeEnum.ALL_PRODUCT.getCode(), goodsConfigType)) {
if (Objects.equals(GoodsConfigTypeEnum.ALL_PRODUCT.getCode(), goodsConfigType)) {
return true;
}
// 0:商品分类
if (Objects.equals(ProductConfigTypeEnum.PRODUCT_CATEGORY.getCode(), goodsConfigType)) {
if (Objects.equals(GoodsConfigTypeEnum.PRODUCT_CATEGORY.getCode(), goodsConfigType)) {
boolean match = true;
if (goodsType != null) {
match = match && Objects.equals(goodsType, order.getGoodsType());
......@@ -154,7 +165,7 @@ public class StaffPerformanceOrderUtil {
}
// 1:圈定产品
if (Objects.equals(ProductConfigTypeEnum.DESIGNATED_PRODUCT.getCode(), goodsConfigType)) {
if (Objects.equals(GoodsConfigTypeEnum.DESIGNATED_PRODUCT.getCode(), goodsConfigType)) {
RpcAssert.assertNotNull(productDefine, DefaultErrorEnum.DATA_NULL,
"productDefine不能为空");
return productDefine.getItemList().stream()
......
......@@ -6,6 +6,9 @@ import java.math.BigDecimal;
public class DataCalUtil {
public static BigDecimal divideToPercent(BigDecimal dividend, BigDecimal divisor) {
if (dividend == null || divisor == null) {
return null;
}
if (divisor.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
......@@ -14,8 +17,10 @@ public class DataCalUtil {
BigDecimal.ROUND_HALF_UP);
}
public static BigDecimal divide(BigDecimal dividend, BigDecimal divisor) {
if (dividend == null || divisor == null) {
return null;
}
if (divisor.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.ZERO;
}
......
......@@ -93,20 +93,20 @@
<if test="createdDate != null and createdDate != ''">
AND DATE_FORMAT(serr.created_date, '%Y-%m') = #{createdDate}
</if>
GROUP BY
serr.merchant_id
<if test="submitStatus != null">
HAVING
CASE
WHEN MAX(
CASE
WHEN serr.status IN (0, 1) THEN 1
ELSE 0
END
) = 1 THEN 0
ELSE 1
END = #{submitStatus}
CASE
WHEN MAX(
CASE
WHEN serr.status IN (0, 1) THEN 1
ELSE 0
END
) = 1 THEN 0
ELSE 1
END = #{submitStatus}
</if>
GROUP BY
serr.merchant_id
ORDER BY
CONVERT(MIN(dclsm.merchant_name) USING gbk) DESC
</select>
......@@ -119,13 +119,61 @@
LEFT JOIN dj_car_life_service_merchant dclsm ON serr.merchant_id = dclsm.merchant_id
AND dclsm.deleted_flag = 'N'
WHERE serr.deleted_flag = 'N'
<if test="merchantId != null and merchantId != ''">
<if test="merchantId != null'">
AND serr.merchant_id = #{merchantId}
</if>
<if test="merchantName != null and merchantName != ''">
AND dclsm.merchant_name LIKE CONCAT('%', #{merchantName}, '%')
</if>
<if test="sceneType != null ">
AND serr.scene_type = #{sceneType}
</if>
<if test="managerName != null and managerName != '' ">
AND serr.manager_name LIKE CONCAT('%', #{managerName}, '%')
</if>
<if test="isNeedReviewed != null and isNeedReviewed != '' ">
AND serr.is_need_reviewed = #{isNeedReviewed}
</if>
<if test="isReviewed != null ">
AND serr.is_reviewed = #{isReviewed}
</if>
<if test="brandName != null and brandName != '' ">
AND serr.brand_name = #{brandName}
</if>
<if test="managerCommitStartTime != null">
AND serr.manager_commit_time &gt;= #{managerCommitStartTime}
</if>
<if test="managerCommitEndTime != null ">
AND serr.manager_commit_time &lt;= #{managerCommitEndTime}
</if>
<if test="merchantIdList != null and merchantIdList.size() > 0">
AND serr.merchant_id IN
<foreach collection="merchantIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="ids != null and ids.size() > 0">
AND serr.id IN
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<select id="queryQwSendMobilePhoneList" resultType="java.lang.String">
SELECT DISTINCT dc.director_phone
FROM sal_effective_referral_review sr
LEFT JOIN
dj_car_life_shop_merchant_director_config dc
ON sr.merchant_id = dc.merchant_id
AND dc.deleted_flag = 'N'
AND ((sr.scene_type = 1 AND dc.director_type = 8)
OR (sr.scene_type IN (2, 3) AND dc.director_type = 9))
WHERE sr.status != 2
AND sr.deleted_flag = 'N'
AND sr.review_month = #{date}
AND dc.director_phone IS NOT NULL;
</select>
</mapper>
\ No newline at end of file
......@@ -506,4 +506,13 @@
</select>
<select id="querySuperiorLeaderMobilePhoneLeader" resultType="java.lang.String">
select distinct(superior_leader_mobile_phone)
from sal_performance_evaluation
where deleted_flag = 'N'
and evaluation_month = #{date}
and handle_status = 0
</select>
</mapper>
\ No newline at end of file
......@@ -71,7 +71,8 @@
updated_by = #{updatedBy},
updated_date = now()
WHERE
merchant_id = #{merchantId,jdbcType=INTEGER}
staff_phone = #{staffPhone,jdbcType=VARCHAR}
AND merchant_id = #{merchantId,jdbcType=INTEGER}
AND business_type = #{businessType,jdbcType=TINYINT}
AND brand_id = #{brandId,jdbcType=INTEGER}
AND child_brand_id = #{childBrandId,jdbcType=INTEGER}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!