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 { ...@@ -25,5 +25,6 @@ public class EffectiveReferralCountDTO implements Serializable {
private Integer deliveryCount; private Integer deliveryCount;
@ApiModelProperty(value = "有效引荐数") @ApiModelProperty(value = "有效引荐数")
@NotNull(message = "有效引荐数不能为空")
private Integer effectiveReferralCount; private Integer effectiveReferralCount;
} }
package cn.com.glsx.dj.staff.dto.perfSalary; package cn.com.glsx.dj.staff.dto.perfSalary;
import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview; import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List; import java.util.List;
...@@ -35,4 +38,17 @@ public class EffectiveReferralReviewCommonDTO extends EffectiveReferralReview { ...@@ -35,4 +38,17 @@ public class EffectiveReferralReviewCommonDTO extends EffectiveReferralReview {
@ApiModelProperty(value = "商户号集合,无须前端传") @ApiModelProperty(value = "商户号集合,无须前端传")
private List<Integer> merchantIds; 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 \ No newline at end of file
...@@ -10,7 +10,7 @@ import java.math.BigDecimal; ...@@ -10,7 +10,7 @@ import java.math.BigDecimal;
*/ */
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public enum CommissionMethodEnum { public enum CommissionTypeEnum {
BL("BL", "比例", BigDecimal.ZERO, BigDecimal.valueOf(100)), BL("BL", "比例", BigDecimal.ZERO, BigDecimal.valueOf(100)),
XS("XS", "系数", BigDecimal.ONE, BigDecimal.valueOf(10)), XS("XS", "系数", BigDecimal.ONE, BigDecimal.valueOf(10)),
GDJE("GDJE", "固定金额", BigDecimal.ZERO, BigDecimal.valueOf(9999999)); GDJE("GDJE", "固定金额", BigDecimal.ZERO, BigDecimal.valueOf(9999999));
...@@ -20,8 +20,8 @@ public enum CommissionMethodEnum { ...@@ -20,8 +20,8 @@ public enum CommissionMethodEnum {
private final BigDecimal min; private final BigDecimal min;
private final BigDecimal max; private final BigDecimal max;
public static CommissionMethodEnum getByCode(String code) { public static CommissionTypeEnum getByCode(String code) {
for (CommissionMethodEnum value : values()) { for (CommissionTypeEnum value : values()) {
if (value.getCode().equals(code)) { if (value.getCode().equals(code)) {
return value; return value;
} }
...@@ -31,10 +31,10 @@ public enum CommissionMethodEnum { ...@@ -31,10 +31,10 @@ public enum CommissionMethodEnum {
// 检测区间 // 检测区间
public static boolean check(String code, BigDecimal value) { public static boolean check(String code, BigDecimal value) {
CommissionMethodEnum commissionMethodEnum = getByCode(code); CommissionTypeEnum commissionTypeEnum = getByCode(code);
if (commissionMethodEnum == null) { if (commissionTypeEnum == null) {
return false; 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 \ No newline at end of file
...@@ -3,22 +3,31 @@ package cn.com.glsx.dj.staff.enums; ...@@ -3,22 +3,31 @@ package cn.com.glsx.dj.staff.enums;
/** /**
* 商品配置类型枚举 * 商品配置类型枚举
*/ */
public enum ProductConfigTypeEnum implements BaseEnum<Integer, String> { public enum GoodsConfigTypeEnum implements BaseEnum<Byte, String> {
ALL_PRODUCT(-1, "全部商品"), ALL_PRODUCT((byte) -1, "全部商品"),
PRODUCT_CATEGORY(0, "商品分类"), PRODUCT_CATEGORY((byte) 0, "商品分类"),
DESIGNATED_PRODUCT(1, "圈定产品"), DESIGNATED_PRODUCT((byte) 1, "圈定产品"),
DESIGNATED_PACKAGE(2, "圈定套餐"); DESIGNATED_PACKAGE((byte) 2, "圈定套餐");
private final Integer code; private final Byte code;
private final String desc; private final String desc;
ProductConfigTypeEnum(Integer code, String desc) { GoodsConfigTypeEnum(Byte code, String desc) {
this.code = code; this.code = code;
this.desc = desc; this.desc = desc;
} }
public static GoodsConfigTypeEnum getByCode(Byte goodsConfigType) {
for (GoodsConfigTypeEnum type : GoodsConfigTypeEnum.values()) {
if (type.getCode().equals(goodsConfigType)) {
return type;
}
}
return null;
}
@Override @Override
public Integer getCode() { public Byte getCode() {
return code; 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 { ...@@ -34,13 +34,13 @@ public class PerformanceParamConfigCondition implements Serializable {
@Column(name = "performance_param_config_id") @Column(name = "performance_param_config_id")
private Integer performanceParamConfigId; private Integer performanceParamConfigId;
@ApiModelProperty(notes = "条件类型(1:渗透率限制,2.订单数不足扣减,3.整体指标达成奖励,4.订单数剔除/包含)") @ApiModelProperty(notes = "条件类型(1:渗透率限制,2.订单数不足扣减,3.整体指标达成奖励,4.订单数剔除/包含), 详见PerformanceConditionTypeEnum")
@Column(name = "condition_type") @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") @Column(name = "condition_goods_config_type")
private Integer conditionGoodsConfigType; private Byte conditionGoodsConfigType;
@ApiModelProperty(notes = "条件商品分类(一级)") @ApiModelProperty(notes = "条件商品分类(一级)")
@Column(name = "condition_goods_type") @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 ...@@ -19,5 +19,5 @@ public interface StaffProductPerformanceMapper extends OreMapper<StaffProductPer
@Param("staffPhone") String staffPhone, @Param("staffPhone") String staffPhone,
@Param("updatedBy") String updatedBy); @Param("updatedBy") String updatedBy);
List<StaffProductPerformanceDTO> listStaffPerformance(@Param("dto") StaffProductPerformanceDTO dto); List<StaffProductPerformanceDTO> listStaffPerformance(StaffProductPerformanceDTO dto);
} }
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ import cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewCommonDTO; ...@@ -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.dto.perfSalary.EffectiveReferralReviewDTO;
import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview; import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List; import java.util.List;
...@@ -35,4 +36,7 @@ public interface EffectiveReferralReviewMapper extends OreMapper<EffectiveReferr ...@@ -35,4 +36,7 @@ public interface EffectiveReferralReviewMapper extends OreMapper<EffectiveReferr
* @return 门店列表 * @return 门店列表
*/ */
List<EffectiveReferralReviewCommonDTO> selectStoreEffectiveReferralList(EffectiveReferralReviewCommonDTO query); List<EffectiveReferralReviewCommonDTO> selectStoreEffectiveReferralList(EffectiveReferralReviewCommonDTO query);
List<String> queryQwSendMobilePhoneList(@Param("date") String date);
} }
\ No newline at end of file \ No newline at end of file
...@@ -33,4 +33,6 @@ public interface PerformanceEvaluationMapper extends OreMapper<PerformanceEvalua ...@@ -33,4 +33,6 @@ public interface PerformanceEvaluationMapper extends OreMapper<PerformanceEvalua
StaffMonthSalaryDTO queryStaffMonthSalary(@Param("evaluationMonth") String evaluationMonth, @Param("mobilePhone") String mobilePhone); StaffMonthSalaryDTO queryStaffMonthSalary(@Param("evaluationMonth") String evaluationMonth, @Param("mobilePhone") String mobilePhone);
List<String> querySuperiorLeaderMobilePhoneLeader(@Param("date") String date);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.service.common; package cn.com.glsx.dj.staff.service.common;
import cn.com.glsx.dj.staff.util.HttpUtil; 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.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.response.SendWorkWechatMessageResponseDTO; import cn.com.glsx.scrm.wechat.dto.workwechat.message.response.SendWorkWechatMessageResponseDTO;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; 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.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class QWManager { public class QWManager {
...@@ -17,8 +28,10 @@ public class QWManager { ...@@ -17,8 +28,10 @@ public class QWManager {
@Autowired @Autowired
private Environment environment; private Environment environment;
public SendWorkWechatMessageResponseDTO sendMessage( @Resource
SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) { private EntmicroStaffRemote entmicroStaffRemote;
public SendWorkWechatMessageResponseDTO sendMessage(SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("发送企微应用消息:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO)); log.info("发送企微应用消息:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
SendWorkWechatMessageResponseDTO responseDTO=null; SendWorkWechatMessageResponseDTO responseDTO=null;
try { try {
...@@ -60,4 +73,41 @@ public class QWManager { ...@@ -60,4 +73,41 @@ public class QWManager {
} }
return userId; 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; 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.dto.merchant.CarBrandDTO;
import cn.com.glsx.dj.smartcarlife.response.ServiceStaffRopResponse; import cn.com.glsx.dj.smartcarlife.response.ServiceStaffRopResponse;
import cn.com.glsx.dj.staff.dto.perfSalary.*; import cn.com.glsx.dj.staff.dto.perfSalary.*;
...@@ -182,20 +181,36 @@ public class EffectiveReferralReviewMiniProgramService { ...@@ -182,20 +181,36 @@ public class EffectiveReferralReviewMiniProgramService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public Boolean effectiveReferralStoreSubmit(StoreEffectiveReferralSubmitDTO dto) { 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( dto.getEffectiveReferralCountDTOS().forEach(
item -> { item -> {
EffectiveReferralReview review = new EffectiveReferralReview(); EffectiveReferralReview review = new EffectiveReferralReview();
review.setId(item.getId()); review.setId(item.getId());
if (item.getEffectiveReferralCount() != null) { review.setAreaEffectiveCount(item.getEffectiveReferralCount());
review.setAreaEffectiveCount(item.getEffectiveReferralCount());
}
if (StringUtils.isNotBlank(dto.getImageUrls())) { if (StringUtils.isNotBlank(dto.getImageUrls())) {
review.setImageUrls(dto.getImageUrls()); review.setImageUrls(dto.getImageUrls());
} }
if (StringUtils.isNotBlank(dto.getRemark())) { if (StringUtils.isNotBlank(dto.getRemark())) {
review.setRemark(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.setStatus(dto.getStatus());
review.setUpdatedBy(dto.getUpdatedBy()); review.setUpdatedBy(dto.getUpdatedBy());
review.setUpdatedDate(new Date()); 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; ...@@ -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.EffectiveReferralReviewCommonDTO;
import cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewDTO; 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.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.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
@Slf4j @Slf4j
@Service @Service
...@@ -23,26 +32,67 @@ public class EffectiveReferralReviewService { ...@@ -23,26 +32,67 @@ public class EffectiveReferralReviewService {
@Resource @Resource
private EffectiveReferralReviewMapper effectiveReferralReviewMapper; private EffectiveReferralReviewMapper effectiveReferralReviewMapper;
@Resource
private PerformanceTimeCycleService performanceTimeCycleService;
/**
* 查询门店有效数列表
*
* @param pagination 列表参数
* @return 门店列表
*/
public RpcPagination<EffectiveReferralReviewCommonDTO> effectiveReferralPage(RpcPagination<EffectiveReferralReviewCommonDTO> pagination) { public RpcPagination<EffectiveReferralReviewCommonDTO> effectiveReferralPage(RpcPagination<EffectiveReferralReviewCommonDTO> pagination) {
PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize()); Page<EffectiveReferralReviewCommonDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
List<EffectiveReferralReviewCommonDTO> list = null; effectiveReferralReviewMapper.selectStoreEffectiveReferralList(pagination.getCondition());
Page<EffectiveReferralReviewCommonDTO> page = (Page<EffectiveReferralReviewCommonDTO>) list;
pagination = RpcPagination.copyPage(page); pagination = RpcPagination.copyPage(page);
return pagination; return pagination;
} }
/**
* 查询门店有效数审核列表
*
* @param pagination 查询参数
* @return 门店列表
*/
public RpcPagination<EffectiveReferralReviewCommonDTO> effectiveReferralAuditPage(RpcPagination<EffectiveReferralReviewCommonDTO> pagination) { public RpcPagination<EffectiveReferralReviewCommonDTO> effectiveReferralAuditPage(RpcPagination<EffectiveReferralReviewCommonDTO> pagination) {
PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize()); //1、查询需要复核的有效引荐数列表
List<EffectiveReferralReviewCommonDTO> list = null; Page<EffectiveReferralReviewCommonDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
Page<EffectiveReferralReviewCommonDTO> page = (Page<EffectiveReferralReviewCommonDTO>) list; 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); pagination = RpcPagination.copyPage(page);
return pagination; return pagination;
} }
/**
* 查询有效引荐数详情
*
* @param id 主键
* @return 详情
*/
public EffectiveReferralReviewCommonDTO effectiveReferralDetail(Integer id) { 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) @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 { ...@@ -50,9 +50,9 @@ public class StaffPerformanceDetailService {
return; return;
} }
// 1. 调用mapper,通过update更新相同merchantId businessType brandId childBrandId // 1. 逻辑删除旧数据
// performanceMonth的记录的deletedFlag = 'D'
StaffPerformanceDetail query = StaffPerformanceDetail.builder() StaffPerformanceDetail query = StaffPerformanceDetail.builder()
.staffPhone(performanceDetailDTOS.get(0).getStaffPhone())
.merchantId(config.getMerchantId()) .merchantId(config.getMerchantId())
.businessType(config.getBusinessType()) .businessType(config.getBusinessType())
.brandId(config.getBrandId()) .brandId(config.getBrandId())
......
...@@ -5,7 +5,7 @@ import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO; ...@@ -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.StaffPerformanceDetailDTO;
import cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO; import cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO; 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.mapper.StaffPerformanceMapper;
import cn.com.glsx.dj.staff.model.StaffBeisenBaseInfo; import cn.com.glsx.dj.staff.model.StaffBeisenBaseInfo;
import cn.com.glsx.dj.staff.model.StaffPerformance; import cn.com.glsx.dj.staff.model.StaffPerformance;
...@@ -52,43 +52,31 @@ public class StaffPerformanceService { ...@@ -52,43 +52,31 @@ public class StaffPerformanceService {
log.error("输入数据无效: context 为空或 performanceDetailDTOS 为空"); log.error("输入数据无效: context 为空或 performanceDetailDTOS 为空");
return; return;
} }
String staffPhone = context.getStaffPhone();
// 1. 根据 merchantId, businessType, brandId, childBrandId 分组 Integer merchantId = context.getMerchantId();
Map<String, List<StaffPerformanceDetailDTO>> groupedMap = groupPerformanceDetails(performanceDetailDTOS); 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. 检查是否处于新人保护期 // 2. 检查是否处于新人保护期
boolean isNewcomerProtection = checkNewcomerProtection(context.getStaffPhone(), context.getPerformanceMonth()); boolean isNewcomerProtection = checkNewcomerProtection(context.getStaffPhone(), context.getPerformanceMonth());
List<StaffPerformance> insertList = new ArrayList<>(); // 3. 构建 StaffPerformance
Date now = new Date(); StaffPerformance staffPerformance = buildStaffPerformance(performanceDetailDTOS, context, isNewcomerProtection);
for (List<StaffPerformanceDetailDTO> groupList : groupedMap.values()) {
if (CollectionUtils.isEmpty(groupList)) {
continue;
}
// 3. 构建 StaffPerformance
StaffPerformance staffPerformance = buildStaffPerformance(groupList, context, isNewcomerProtection, now);
insertList.add(staffPerformance);
// 4. 逻辑删除旧数据 // 4. 逻辑删除旧数据
staffPerformanceMapper.removeStaffPerformance(staffPerformance); staffPerformanceMapper.removeStaffPerformance(staffPerformance);
}
// 5. 批量插入新数据
if (CollectionUtils.isNotEmpty(insertList)) {
staffPerformanceMapper.insertList(insertList);
}
}
/** // 5. 插入新数据
* 对详情数据进行分组 staffPerformanceMapper.insertSelective(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()));
} }
/** /**
...@@ -136,8 +124,7 @@ public class StaffPerformanceService { ...@@ -136,8 +124,7 @@ public class StaffPerformanceService {
*/ */
private StaffPerformance buildStaffPerformance(List<StaffPerformanceDetailDTO> groupList, private StaffPerformance buildStaffPerformance(List<StaffPerformanceDetailDTO> groupList,
StaffPerformanceCalContextDTO context, StaffPerformanceCalContextDTO context,
boolean isNewcomerProtection, boolean isNewcomerProtection) {
Date now) {
StaffPerformanceDetailDTO first = groupList.get(0); StaffPerformanceDetailDTO first = groupList.get(0);
StaffPerformance staffPerformance = new StaffPerformance(); StaffPerformance staffPerformance = new StaffPerformance();
...@@ -153,6 +140,7 @@ public class StaffPerformanceService { ...@@ -153,6 +140,7 @@ public class StaffPerformanceService {
staffPerformance.setChildBrandName(first.getChildBrandName()); staffPerformance.setChildBrandName(first.getChildBrandName());
staffPerformance.setMonth(first.getMonth()); staffPerformance.setMonth(first.getMonth());
Date now = new Date();
staffPerformance.setCreatedBy(CommonConstants.DEFAULT_UPDATE_BY); staffPerformance.setCreatedBy(CommonConstants.DEFAULT_UPDATE_BY);
staffPerformance.setUpdatedBy(CommonConstants.DEFAULT_UPDATE_BY); staffPerformance.setUpdatedBy(CommonConstants.DEFAULT_UPDATE_BY);
staffPerformance.setCreatedDate(now); staffPerformance.setCreatedDate(now);
...@@ -193,7 +181,7 @@ public class StaffPerformanceService { ...@@ -193,7 +181,7 @@ public class StaffPerformanceService {
// 遍历详情计算 // 遍历详情计算
for (StaffPerformanceDetailDTO detail : groupList) { for (StaffPerformanceDetailDTO detail : groupList) {
// 判断是否为系数类型 (假设 'XS' 为系数代码) // 判断是否为系数类型 (假设 'XS' 为系数代码)
if (CommissionMethodEnum.XS.getCode().equals(detail.getCommissionType())) { if (CommissionTypeEnum.XS.getCode().equals(detail.getCommissionType())) {
if (detail.getCommissionTypeValue() != null) { if (detail.getCommissionTypeValue() != null) {
multiplyCoeff = multiplyCoeff.multiply(detail.getCommissionTypeValue()); multiplyCoeff = multiplyCoeff.multiply(detail.getCommissionTypeValue());
} }
......
...@@ -3,8 +3,9 @@ package cn.com.glsx.dj.staff.service.staffPerformance.util; ...@@ -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.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO;
import cn.com.glsx.dj.smartcarlife.model.MerchantPerformanceProductDefineItem; import cn.com.glsx.dj.smartcarlife.model.MerchantPerformanceProductDefineItem;
import cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO; 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.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert; import cn.com.glsx.framework.core.util.RpcAssert;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -81,37 +82,47 @@ public class StaffPerformanceOrderUtil { ...@@ -81,37 +82,47 @@ public class StaffPerformanceOrderUtil {
* @param productDefine 圈定商品定义(含套餐) * @param productDefine 圈定商品定义(含套餐)
* @return 匹配数量 * @return 匹配数量
*/ */
public static long countMatchingOrders(List<StaffPerformanceSubOrderDTO> orders, public static Integer countMatchingOrders(List<StaffPerformanceSubOrderDTO> orders,
Integer goodsConfigType, Byte goodsConfigType,
Integer goodsType, Integer goodsType,
Integer secondaryGoodsType, Integer secondaryGoodsType,
Integer thirdLevelGoodsType, Integer thirdLevelGoodsType,
MerchantPerformanceProductDefineDTO productDefine) { MerchantPerformanceProductDefineDTO productDefine) {
if (CollectionUtils.isEmpty(orders) || goodsConfigType == null) { if (CollectionUtils.isEmpty(orders)) {
return 0; 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) { Map<String, List<StaffPerformanceSubOrderDTO>> groupedOrders = orders.stream()
RpcAssert.assertNotNull(productDefine, DefaultErrorEnum.DATA_NULL, .collect(Collectors.groupingBy(StaffPerformanceSubOrderDTO::getOrderCode));
"conditionProductDefine be null"); return (int) groupedOrders.values().stream()
RpcAssert.assertNotEmpty(productDefine.getPackageItemList(), DefaultErrorEnum.DATA_NULL, .filter(o -> isOrderMatchPackage(o, productDefine.getPackageItemList()))
"conditionProductDefine.getPackageItemList() is empty"); .count();
case ALL_PRODUCT:
Map<String, List<StaffPerformanceSubOrderDTO>> groupedOrders = orders.stream() case PRODUCT_CATEGORY:
.collect(Collectors.groupingBy(StaffPerformanceSubOrderDTO::getOrderCode)); case DESIGNATED_PRODUCT:
return groupedOrders.values().stream() return (int) orders.stream()
.filter(o -> isOrderMatchPackage(o, productDefine.getPackageItemList())) .filter(o -> isOrderMatchCategory(o,
.count(); goodsConfigType,
} else { goodsType,
return orders.stream() secondaryGoodsType,
.filter(o -> isOrderMatchCategory(o, thirdLevelGoodsType,
goodsConfigType.byteValue(), productDefine))
goodsType, .count();
secondaryGoodsType, default:
thirdLevelGoodsType, throw new RpcServiceException("不支持的商品配置类型: " + goodsConfigType);
productDefine))
.count();
} }
} }
/** /**
...@@ -134,12 +145,12 @@ public class StaffPerformanceOrderUtil { ...@@ -134,12 +145,12 @@ public class StaffPerformanceOrderUtil {
RpcAssert.assertNotNull(goodsConfigType, DefaultErrorEnum.DATA_NULL, "goodsConfigType不能为空"); RpcAssert.assertNotNull(goodsConfigType, DefaultErrorEnum.DATA_NULL, "goodsConfigType不能为空");
// TODO 改用枚举 // TODO 改用枚举
// -1:全部商品 // -1:全部商品
if (Objects.equals(ProductConfigTypeEnum.ALL_PRODUCT.getCode(), goodsConfigType)) { if (Objects.equals(GoodsConfigTypeEnum.ALL_PRODUCT.getCode(), goodsConfigType)) {
return true; return true;
} }
// 0:商品分类 // 0:商品分类
if (Objects.equals(ProductConfigTypeEnum.PRODUCT_CATEGORY.getCode(), goodsConfigType)) { if (Objects.equals(GoodsConfigTypeEnum.PRODUCT_CATEGORY.getCode(), goodsConfigType)) {
boolean match = true; boolean match = true;
if (goodsType != null) { if (goodsType != null) {
match = match && Objects.equals(goodsType, order.getGoodsType()); match = match && Objects.equals(goodsType, order.getGoodsType());
...@@ -154,7 +165,7 @@ public class StaffPerformanceOrderUtil { ...@@ -154,7 +165,7 @@ public class StaffPerformanceOrderUtil {
} }
// 1:圈定产品 // 1:圈定产品
if (Objects.equals(ProductConfigTypeEnum.DESIGNATED_PRODUCT.getCode(), goodsConfigType)) { if (Objects.equals(GoodsConfigTypeEnum.DESIGNATED_PRODUCT.getCode(), goodsConfigType)) {
RpcAssert.assertNotNull(productDefine, DefaultErrorEnum.DATA_NULL, RpcAssert.assertNotNull(productDefine, DefaultErrorEnum.DATA_NULL,
"productDefine不能为空"); "productDefine不能为空");
return productDefine.getItemList().stream() return productDefine.getItemList().stream()
......
...@@ -6,6 +6,9 @@ import java.math.BigDecimal; ...@@ -6,6 +6,9 @@ import java.math.BigDecimal;
public class DataCalUtil { public class DataCalUtil {
public static BigDecimal divideToPercent(BigDecimal dividend, BigDecimal divisor) { public static BigDecimal divideToPercent(BigDecimal dividend, BigDecimal divisor) {
if (dividend == null || divisor == null) {
return null;
}
if (divisor.compareTo(BigDecimal.ZERO) == 0) { if (divisor.compareTo(BigDecimal.ZERO) == 0) {
return null; return null;
} }
...@@ -14,8 +17,10 @@ public class DataCalUtil { ...@@ -14,8 +17,10 @@ public class DataCalUtil {
BigDecimal.ROUND_HALF_UP); BigDecimal.ROUND_HALF_UP);
} }
public static BigDecimal divide(BigDecimal dividend, BigDecimal divisor) { public static BigDecimal divide(BigDecimal dividend, BigDecimal divisor) {
if (dividend == null || divisor == null) {
return null;
}
if (divisor.compareTo(BigDecimal.ZERO) == 0) { if (divisor.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.ZERO; return BigDecimal.ZERO;
} }
......
...@@ -93,20 +93,20 @@ ...@@ -93,20 +93,20 @@
<if test="createdDate != null and createdDate != ''"> <if test="createdDate != null and createdDate != ''">
AND DATE_FORMAT(serr.created_date, '%Y-%m') = #{createdDate} AND DATE_FORMAT(serr.created_date, '%Y-%m') = #{createdDate}
</if> </if>
GROUP BY
serr.merchant_id
<if test="submitStatus != null"> <if test="submitStatus != null">
HAVING HAVING
CASE CASE
WHEN MAX( WHEN MAX(
CASE CASE
WHEN serr.status IN (0, 1) THEN 1 WHEN serr.status IN (0, 1) THEN 1
ELSE 0 ELSE 0
END END
) = 1 THEN 0 ) = 1 THEN 0
ELSE 1 ELSE 1
END = #{submitStatus} END = #{submitStatus}
</if> </if>
GROUP BY
serr.merchant_id
ORDER BY ORDER BY
CONVERT(MIN(dclsm.merchant_name) USING gbk) DESC CONVERT(MIN(dclsm.merchant_name) USING gbk) DESC
</select> </select>
...@@ -119,13 +119,61 @@ ...@@ -119,13 +119,61 @@
LEFT JOIN dj_car_life_service_merchant dclsm ON serr.merchant_id = dclsm.merchant_id LEFT JOIN dj_car_life_service_merchant dclsm ON serr.merchant_id = dclsm.merchant_id
AND dclsm.deleted_flag = 'N' AND dclsm.deleted_flag = 'N'
WHERE serr.deleted_flag = 'N' WHERE serr.deleted_flag = 'N'
<if test="merchantId != null and merchantId != ''"> <if test="merchantId != null'">
AND serr.merchant_id = #{merchantId} AND serr.merchant_id = #{merchantId}
</if> </if>
<if test="merchantName != null and merchantName != ''"> <if test="merchantName != null and merchantName != ''">
AND dclsm.merchant_name LIKE CONCAT('%', #{merchantName}, '%') AND dclsm.merchant_name LIKE CONCAT('%', #{merchantName}, '%')
</if> </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> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -506,4 +506,13 @@ ...@@ -506,4 +506,13 @@
</select> </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> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -71,7 +71,8 @@ ...@@ -71,7 +71,8 @@
updated_by = #{updatedBy}, updated_by = #{updatedBy},
updated_date = now() updated_date = now()
WHERE WHERE
merchant_id = #{merchantId,jdbcType=INTEGER} staff_phone = #{staffPhone,jdbcType=VARCHAR}
AND merchant_id = #{merchantId,jdbcType=INTEGER}
AND business_type = #{businessType,jdbcType=TINYINT} AND business_type = #{businessType,jdbcType=TINYINT}
AND brand_id = #{brandId,jdbcType=INTEGER} AND brand_id = #{brandId,jdbcType=INTEGER}
AND child_brand_id = #{childBrandId,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!