Commit f8915ea2 by 叶立庆

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

2 parents 8f373b33 2b7cd9bc
Showing 26 changed files with 638 additions and 114 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);
}
}
}
......@@ -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());
}
......
......@@ -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!