Commit 324b1442 by 章家宝

提成方案:提成方案添加,审批相关

1 parent 87dcea42
Showing 53 changed files with 1015 additions and 137 deletions
package cn.com.glsx.dj.staff.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PerformanceCommissionStaffDTO implements java.io.Serializable{
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "员工姓名")
private String staffPhone;
@ApiModelProperty(notes = "员工姓名")
private String staffName;
}
package cn.com.glsx.dj.staff.dto;
import cn.com.glsx.dj.staff.model.PerformanceConfigMerchantBrandRef;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.*;
import lombok.experimental.SuperBuilder;
@SuperBuilder
@ToString(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper=false)
public class PerformanceConfigMerchantBrandRefDTO extends PerformanceConfigMerchantBrandRef {
private static final long serialVersionUID = 1L;
private Byte businessType;
}
\ No newline at end of file
package cn.com.glsx.dj.staff.dto;
import cn.com.glsx.dj.staff.model.PerformanceConfigRule;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.*;
import lombok.experimental.SuperBuilder;
@SuperBuilder
@ToString(callSuper = true)
@Data
@EqualsAndHashCode(callSuper=false)
@NoArgsConstructor
public class PerformanceConfigRuleDTO extends PerformanceConfigRule {
private static final long serialVersionUID = -448678837056991912L;
}
......@@ -10,6 +10,8 @@ import lombok.experimental.SuperBuilder;
@ToString(callSuper = true)
@Data
@EqualsAndHashCode(callSuper=false)
@AllArgsConstructor
@NoArgsConstructor
public class PerformanceParamConfigConditionDTO extends PerformanceParamConfigCondition {
private MerchantPerformanceProductDefineDTO productDefine;
@ApiModelProperty(notes = "提成方案置ID")
......
......@@ -4,13 +4,15 @@ import cn.com.glsx.dj.staff.dto.PerformanceConfigMerchantBrandRefDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.io.Serializable;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PerformanceConfigApproveDetailDTO {
public class PerformanceConfigApproveDetailDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "主键ID")
private Integer id;
......
package cn.com.glsx.dj.staff.dto.performance;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PerformanceConfigApproveHandleDTO {
@ApiModelProperty(notes = "performanceConfigApproveId")
private Integer performanceConfigApproveId;
@ApiModelProperty(notes = "审批状态 2:已通过;3:已驳回")
private Integer status;
@ApiModelProperty(notes = "手机号码")
private String mobile;
@ApiModelProperty(notes = "审批意见")
private String approveOpinion;
}
......@@ -4,10 +4,12 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class PerformanceConfigApprovePageDTO {
public class PerformanceConfigApprovePageDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "主键ID")
private Integer id;
......
......@@ -3,8 +3,11 @@ package cn.com.glsx.dj.staff.dto.performance;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class PerformanceConfigApprovePermissionDTO {
public class PerformanceConfigApprovePermissionDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "主键ID")
private Integer id;
......
package cn.com.glsx.dj.staff.dto.performance;
import cn.com.glsx.dj.staff.dto.PerformanceConfigMerchantBrandRefDTO;
import cn.com.glsx.dj.staff.dto.PerformanceConfigRuleDTO;
import cn.com.glsx.dj.staff.dto.PerformanceParamConfigDTO;
import cn.com.glsx.dj.staff.dto.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
......@@ -19,6 +17,9 @@ public class PerformanceConfigDetailDTO implements Serializable {
@ApiModelProperty(notes = "主键ID")
private Integer id;
@ApiModelProperty(notes = "源提成方案配置ID(dj_car_life_performance_config.id)")
private Integer originPerformanceConfigId;
@ApiModelProperty(notes = "方案名称")
private String schemeName;
......
......@@ -3,11 +3,14 @@ package cn.com.glsx.dj.staff.dto.performance;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class PerformanceConfigPageByMerchantDTO {
public class PerformanceConfigPageByMerchantDTO implements Serializable {
private static final long serialVersionUID = 1L;
// 业务类型
private Byte businessType;
// 状态
......
......@@ -2,10 +2,7 @@ package cn.com.glsx.dj.staff.dto.performance;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.*;
import java.io.Serializable;
import java.util.Date;
......@@ -16,6 +13,7 @@ import java.util.Date;
@ToString
public class PerformanceConfigPageDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer schemeType;
@ApiModelProperty(notes = "主键ID")
private Long id;
......
package cn.com.glsx.dj.staff.dto.performance;
import cn.com.glsx.dj.staff.model.PerformanceTimeCycle;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.SuperBuilder;
import java.util.Date;
@Data
@ToString
@SuperBuilder
@EqualsAndHashCode(callSuper=false)
public class PerformanceTimeCycleDTO extends PerformanceTimeCycle {
@ApiModelProperty(notes = "周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startDate;
@ApiModelProperty(notes = "周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endDate;
}
\ No newline at end of file
......@@ -4,11 +4,35 @@ import cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
public class StaffPerformanceGetDTO {
public class StaffPerformanceGetDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(name = "staffPerformanceList", notes = "工资提成列表获取")
private String month;
private String staffPhone;
@ApiModelProperty(notes = "员工姓名")
private String staffName;
@ApiModelProperty(notes = "门店ID")
private Integer merchantId;
@ApiModelProperty(notes = "门店名称")
private String merchantName;
@ApiModelProperty(notes = "有效引荐量")
private Integer effectiveReferralQuantity;
@ApiModelProperty(notes = "实际售前触客数总数")
private Integer touchNumber;
@ApiModelProperty(notes = "总提成金额")
private BigDecimal totalPerformanceAmount;
@ApiModelProperty(name = "staffPerformanceList", notes = "工资提成列表")
private List<StaffProductPerformanceDTO> staffPerformanceList;
}
......@@ -6,7 +6,8 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum PerformanceApproveStatusEnum {
public enum PerformanceApproveOperatorStatusEnum {
INIT(0, "初始化"),
// 已读
READ(1, "已读"),
// 已通过
......
package cn.com.glsx.dj.staff.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum PerformanceApprovePushStatusEnum {
FAILED(0, "失败"),
SUCCESS(1, "成功"),
;
private Integer code;
private String desc;
}
package cn.com.glsx.dj.staff.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum PerformanceApproverTypeEnum {
READER(1, "查阅人"),
APPROVER(2, "审批人"),
;
private final Integer code;
private final String desc;
}
package cn.com.glsx.dj.staff.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum PerformanceConfigApproveStatusEnum {
APPROVEING(1, "审批中"),
APPROVE_SUCCESS(2, "已通过"),
APPROVE_FAIL(3, "已驳回"),
;
private final Integer code;
private final String desc;
}
package cn.com.glsx.dj.staff.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum PerformanceConfigStatusEnum {
DRAFT(0, "草稿"),
APPROVING(1, "审批中"),
EFFECTIVE(2, "生效"),
NOT_EFFECTIVE(3, "失效"),
;
private final Integer code;
private final String desc;
public static PerformanceConfigStatusEnum getByCode(Integer code) {
for (PerformanceConfigStatusEnum value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}
}
......@@ -33,10 +33,18 @@ public class PerformanceConfigApproveOperationRecord implements Serializable {
@Column(name = "performance_config_approve_id")
private Integer performanceConfigApproveId;
@ApiModelProperty(notes = "审批状态(1:审批中;2:已通过;3:已驳回)")
@ApiModelProperty(notes = "审批状态(0:初始化状态 1:已查看;2:已通过;3:已驳回)")
@Column(name = "approve_status")
private Integer status;
@ApiModelProperty(notes = "审批人类型(1:查阅人;2:审批人)")
@Column(name = "approver_type")
private Integer approverType;
@ApiModelProperty(notes = "推送状态 0推送失败 1推送成功")
@Column(name = "push_status")
private Integer pushStatus;
@ApiModelProperty(notes = "审批操作时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "approve_time")
......
......@@ -42,18 +42,13 @@ public class PerformanceTimeCycle implements Serializable {
private String cycleItem;
@ApiModelProperty(notes = "周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "start_date")
private Date startDate;
@Column(name = "start_day_of_month")
private String stratDayOfMonth;
@ApiModelProperty(notes = "周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "end_date")
private Date endDate;
@ApiModelProperty(notes = "是否启用(N:否,Y:是)")
@Column(name = "enable_flag")
private String enableFlag;
@JsonFormat(pattern = "dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "end_day_of_month")
private String endDayOfMonth;
@ApiModelProperty(notes = "创建人")
@Column(name = "created_by")
......
package cn.com.glsx.dj.staff.remote;
import cn.com.glsx.dj.staff.dto.PerformanceCommissionStaffDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceGetDTO;
import cn.com.glsx.framework.core.annotation.*;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import java.util.List;
@ApiService(value = "员工提成", owner = "zhangjb", protocol = ApiService.ProtocolEnum.dubbo, version = "1.0.0")
public interface StaffProductPerformanceRemote {
@ApiMethod("查询员工提成构成")
@ApiParam(name = "dto", notes = "提成构成信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("提成构成列表")
RpcResponse<List<StaffPerformanceGetDTO>> getPerformanceCommissionCompositionForStaff(StaffPerformanceGetDTO dto);
@ApiMethod("查询有绩效提成的人员")
@ApiResponse("有绩效提成的人员列表(员工名称、手机号码)")
RpcResponse<List<PerformanceCommissionStaffDTO>> listStaffWithPerformanceCommission();
}
......@@ -22,4 +22,14 @@ public interface PerformanceConfigApproveRemote {
@ApiParam(name = "dto", notes = "查询信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("提成方案审批详情")
RpcResponse<PerformanceConfigApprovePermissionDTO> performanceConfigApproveDetailAndPermission(PerformanceConfigApproveDTO dto);
@ApiMethod("提交提成方案审批")
@ApiParam(name = "dto", notes = "提成方案信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("提交提成方案审批")
RpcResponse<Boolean> approveSubmit(PerformanceConfigApproveDTO dto);
@ApiMethod("提成方案审批")
@ApiParam(name = "dto", notes = "提成方案审批信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("提成方案审批")
RpcResponse<Boolean> approveHandle(PerformanceConfigApproveHandleDTO request);
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ public interface PerformanceConfigRemote {
@ApiMethod("提成方案新增")
@ApiParam(name = "dto", notes = "提成方案信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("是否成功")
RpcResponse<Boolean> performanceConfigAdd(@NotNull PerformanceConfigDTO dto);
RpcResponse<Integer> performanceConfigSave(@NotNull PerformanceConfigDTO dto);
@ApiMethod("提成方案修改")
@ApiParam(name = "dto", notes = "提成方案信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
......@@ -52,5 +52,10 @@ public interface PerformanceConfigRemote {
@ApiMethod("查询门店是否有有效的提成方案")
@ApiParam(name = "dto", notes = "门店id", dataType = DataTypeEnum.INT, required = true)
@ApiResponse("提成方案")
RpcResponse<Boolean> isEffectivePerformanceExist(@NotNull Integer merchantId);
RpcResponse<Boolean> hasEffectivePerformanceConfigForMerchant(@NotNull Integer merchantId);
@ApiMethod("查询门店是否有有效的提成方案")
@ApiParam(name = "dto", notes = "门店id", dataType = DataTypeEnum.INT, required = true)
@ApiResponse("提成方案")
RpcResponse<List<PerformanceConfigDetailDTO>> performanceConfigDetailWithMerchant(PerformanceConfigDTO dto);
}
package cn.com.glsx.dj.staff.job;
import cn.com.glsx.dj.staff.service.staffPerformance.PerformanceConfigService;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
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 org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ElasticJobConf(name = "PerformanceConfigEnableJob", cron = "0 0 0 1 * ?", description = "提成方案启用定时任务", overwrite = false)
public class PerformanceConfigEnableJob implements SimpleJob {
@Autowired
private PerformanceConfigService performanceConfigService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("----------------提成方案启用定时任务-----------------");
long beginTime = System.currentTimeMillis();
try {
performanceConfigService.enblePerformanceConfig();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
} finally {
log.info("----------------提成方案启用定时任务,耗时:{}-----------------", System.currentTimeMillis() - beginTime);
}
}
}
......@@ -15,4 +15,12 @@ public interface PerformanceConfigApproveMapper extends OreMapper<PerformanceCon
PerformanceConfigApproveDetailDTO getPerformanceConfigApproveDetail(PerformanceConfigApproveDTO dto);
PerformanceConfigApprovePermissionDTO getPerformanceConfigApproveDetailAndPermission(PerformanceConfigApproveDTO dto);
Integer insertOne(PerformanceConfigApproveDTO dto);
PerformanceConfigApproveDTO selectById(Integer id);
void updateById(PerformanceConfigApproveDTO approveDTO);
List<PerformanceConfigApproveDTO> selectByPerformanceConfigId(Integer performanceConfigId);
}
\ No newline at end of file
......@@ -5,8 +5,14 @@ import cn.com.glsx.dj.staff.model.PerformanceConfigApproveOperationRecord;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper
public interface PerformanceConfigApproveOperationRecordMapper extends OreMapper<PerformanceConfigApproveOperationRecord> {
void addOp(PerformanceConfigApproveOperationRecordDTO dto);
List<PerformanceConfigApproveOperationRecordDTO> listByPerformanceConfigApproveId(Integer performanceConfigApproveId);
void updateApproveOpinionAndStatusById(PerformanceConfigApproveOperationRecordDTO dto);
void updateReadStatusByMobile(String mobile);
}
\ No newline at end of file
......@@ -25,5 +25,11 @@ public interface PerformanceConfigMapper extends OreMapper<PerformanceConfig> {
List<PerformanceConfigDTO> effectivePerformanceConfigByMerchantId(@Param("merchantId") Integer merchantId);
Boolean isEffectivePerformanceExist(Integer merchantId);
Boolean hasEffectivePerformanceConfigForMerchant(Integer merchantId);
int insertOne(PerformanceConfigDTO dto);
void updateById(PerformanceConfigDTO dto);
void enblePerformanceConfig();
}
\ No newline at end of file
package cn.com.glsx.dj.staff.mapper;
import cn.com.glsx.dj.staff.dto.PerformanceConfigMerchantBrandRefDTO;
import cn.com.glsx.dj.staff.model.PerformanceConfigMerchantBrandRef;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper
public interface PerformanceConfigMerchantBrandRefMapper extends OreMapper<PerformanceConfigMerchantBrandRef> {
void deleteByConfigId(Integer performanceConfigId);
void insertLists(List<PerformanceConfigMerchantBrandRefDTO> merchantBrandModelPageBrands);
List<PerformanceConfigMerchantBrandRefDTO> listByConfigId(Integer id);
void invalidByBusinessTypeAndMerchantBrand(PerformanceConfigMerchantBrandRefDTO merchantBrandRef);
}
\ No newline at end of file
package cn.com.glsx.dj.staff.mapper;
import cn.com.glsx.dj.staff.dto.PerformanceConfigRuleDTO;
import cn.com.glsx.dj.staff.model.PerformanceConfigRule;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface PerformanceConfigRuleMapper extends OreMapper<PerformanceConfigRule> {
PerformanceConfigRuleDTO listByConfigId(Integer id);
void insertOne(PerformanceConfigRuleDTO performanceConfigRule);
void deleteByConfigId(Integer performanceConfigId);
}
\ No newline at end of file
......@@ -13,4 +13,6 @@ public interface PerformanceParamConfigConditionMapper extends OreMapper<Perform
List<PerformanceParamConfigConditionDTO> listByParamConfigId(
PerformanceParamConfigConditionDTO dto);
void deleteByPerformanceConfigId(@Param("performanceConfigId") Integer performanceConfigId);
void insertLists(List<PerformanceParamConfigConditionDTO> performanceParamConfigConditionDTOList);
}
\ No newline at end of file
......@@ -12,4 +12,6 @@ public interface PerformanceParamConfigMapper extends OreMapper<PerformanceParam
List<PerformanceParamConfigDTO> listByConfigId(PerformanceParamConfigDTO dto);
void deleteByPerformanceParamConfigId(Integer id);
int insertOne(PerformanceParamConfigDTO performanceParamConfig);
}
\ No newline at end of file
package cn.com.glsx.dj.staff.mapper;
import cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO;
import cn.com.glsx.dj.staff.dto.PerformanceCommissionStaffDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO;
import cn.com.glsx.dj.staff.model.StaffPerformance;
import org.apache.ibatis.annotations.Mapper;
......@@ -19,4 +19,9 @@ public interface StaffPerformanceMapper extends OreMapper<StaffPerformance> {
* @return
*/
int removeStaffPerformance(StaffPerformance staffPerformance);
/**
* 查询有生成过绩效工资的员工信息
*/
List<PerformanceCommissionStaffDTO> listStaffWithPerformanceCommission();
}
\ No newline at end of file
package cn.com.glsx.dj.staff.remote;
import cn.com.glsx.dj.staff.dto.PerformanceCommissionStaffDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceGetDTO;
import cn.com.glsx.dj.staff.service.staffPerformance.StaffPerformanceService;
import cn.com.glsx.dj.staff.service.staffPerformance.StaffProductPerformanceService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@Slf4j
@DubboService(version = "1.0.0", validation = "true")
public class StaffProductPerformanceRemoteImpl implements StaffProductPerformanceRemote{
@Autowired
private StaffProductPerformanceService staffProductPerformanceService;
@Autowired
private StaffPerformanceService staffPerformanceService;
@Override
public RpcResponse<List<StaffPerformanceGetDTO>> getPerformanceCommissionCompositionForStaff(StaffPerformanceGetDTO dto) {
return RpcResponse.success(staffProductPerformanceService.getPerformanceCommissionCompositionForStaff(dto));
}
@Override
public RpcResponse<List<PerformanceCommissionStaffDTO>> listStaffWithPerformanceCommission() {
return RpcResponse.success(staffPerformanceService.listStaffWithPerformanceCommission());
}
}
......@@ -30,4 +30,13 @@ public class PerformanceConfigApproveRemoteImpl implements PerformanceConfigAppr
return RpcResponse.success(performanceConfigApproveService.getPerformanceConfigApproveDetailAndPermission(dto));
}
@Override
public RpcResponse<Boolean> approveSubmit(PerformanceConfigApproveDTO dto) {
return RpcResponse.success(performanceConfigApproveService.submit(dto));
}
@Override
public RpcResponse<Boolean> approveHandle(PerformanceConfigApproveHandleDTO dto) {
return RpcResponse.success(performanceConfigApproveService.approveHandle(dto));
}
}
\ No newline at end of file
......@@ -19,8 +19,8 @@ public class PerformanceConfigRemoteImpl implements PerformanceConfigRemote {
@Override
public RpcResponse<Boolean> performanceConfigAdd(PerformanceConfigDTO dto) {
return null;
public RpcResponse<Integer> performanceConfigSave(PerformanceConfigDTO dto) {
return performanceConfigService.savePerformanceConfig(dto);
}
@Override
......@@ -57,8 +57,13 @@ public class PerformanceConfigRemoteImpl implements PerformanceConfigRemote {
}
@Override
public RpcResponse<Boolean> isEffectivePerformanceExist(Integer merchantId) {
return RpcResponse.success(performanceConfigService.isEffectivePerformanceExist(merchantId));
public RpcResponse<Boolean> hasEffectivePerformanceConfigForMerchant(Integer merchantId) {
return RpcResponse.success(performanceConfigService.hasEffectivePerformanceConfigForMerchant(merchantId));
}
@Override
public RpcResponse<List<PerformanceConfigDetailDTO>> performanceConfigDetailWithMerchant(PerformanceConfigDTO dto) {
return RpcResponse.success(performanceConfigService.performanceConfigDetailWithMerchant(dto));
}
......
package cn.com.glsx.dj.staff.service.staffPerformance;
import cn.com.glsx.dj.staff.dto.performance.PerformanceConfigApproveOperationRecordDTO;
import cn.com.glsx.dj.staff.enums.PerformanceApproveStatusEnum;
import cn.com.glsx.dj.staff.mapper.PerformanceConfigApproveOperationRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class PerformanceConfigApproveOperationRecordService {
@Autowired
PerformanceConfigApproveOperationRecordMapper performanceConfigApproveOperationRecordMapper;
public void addOperatorRecord(Integer id, String mobile, PerformanceApproveStatusEnum performanceApproveStatusEnum, String approveName, String opinion) {
PerformanceConfigApproveOperationRecordDTO dto = new PerformanceConfigApproveOperationRecordDTO();
dto.setApproverMobile(mobile);
dto.setStatus(performanceApproveStatusEnum.getCode());
dto.setPerformanceConfigApproveId(id);
dto.setApproveOpinion(opinion);
dto.setApproverName(approveName);
performanceConfigApproveOperationRecordMapper.addOp(dto);
public List<PerformanceConfigApproveOperationRecordDTO> listByPerformanceConfigApproveId(Integer performanceConfigApproveId) {
return performanceConfigApproveOperationRecordMapper.listByPerformanceConfigApproveId(performanceConfigApproveId);
}
public void updateApproveOpinionAndStatusById(PerformanceConfigApproveOperationRecordDTO dto) {
performanceConfigApproveOperationRecordMapper.updateApproveOpinionAndStatusById(dto);
}
public void insertList(List<PerformanceConfigApproveOperationRecordDTO> recordDTOList) {
performanceConfigApproveOperationRecordMapper.insertList(recordDTOList);
}
public void updateReadStatusByMobile(String mobile) {
performanceConfigApproveOperationRecordMapper.updateReadStatusByMobile(mobile);
}
}
......@@ -21,6 +21,19 @@ public class PerformanceConfigMerchantBrandRefService {
public List<PerformanceConfigMerchantBrandRefDTO> listByConfigId(Integer id) {
return null;
return performanceConfigMerchantBrandRefMapper.listByConfigId(id);
}
public void addRef(List<PerformanceConfigMerchantBrandRefDTO> merchantBrandModelPageBrands, Integer performanceConfigId) {
for (PerformanceConfigMerchantBrandRefDTO merchantBrandModelPageBrand : merchantBrandModelPageBrands) {
merchantBrandModelPageBrand.setPerformanceConfigId(performanceConfigId);
}
performanceConfigMerchantBrandRefMapper.deleteByConfigId(performanceConfigId);
performanceConfigMerchantBrandRefMapper.insertLists(merchantBrandModelPageBrands);
}
public void invalidByBusinessTypeAndMerchantBrand(Byte businessType, PerformanceConfigMerchantBrandRefDTO merchantBrandRef) {
merchantBrandRef.setBusinessType(businessType);
performanceConfigMerchantBrandRefMapper.invalidByBusinessTypeAndMerchantBrand(merchantBrandRef);
}
}
......@@ -17,6 +17,12 @@ public class PerformanceConfigRuleService {
@Autowired
private PerformanceConfigRuleMapper performanceConfigRuleMapper;
public PerformanceConfigRuleDTO listByConfigId(Integer id) {
return null;
return performanceConfigRuleMapper.listByConfigId(id);
}
public void addRule(PerformanceConfigRuleDTO performanceConfigRule, Integer performanceConfigId) {
performanceConfigRuleMapper.deleteByConfigId(performanceConfigId);
performanceConfigRule.setPerformanceConfigId(performanceConfigId);
performanceConfigRuleMapper.insertOne(performanceConfigRule);
}
}
......@@ -5,6 +5,7 @@ import cn.com.glsx.dj.staff.dto.performance.*;
import cn.com.glsx.dj.staff.mapper.PerformanceConfigMapper;
import cn.com.glsx.dj.staff.model.PerformanceConfig;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
......@@ -15,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -147,7 +149,70 @@ public class PerformanceConfigService {
return performanceConfigDTOS;
}
public Boolean isEffectivePerformanceExist(Integer merchantId) {
return performanceConfigMapper.isEffectivePerformanceExist(merchantId);
public Boolean hasEffectivePerformanceConfigForMerchant(Integer merchantId) {
return performanceConfigMapper.hasEffectivePerformanceConfigForMerchant(merchantId);
}
/**
* 保存一个方案
*/
public RpcResponse<Integer> savePerformanceConfig(PerformanceConfigDTO dto) {
Integer id = dto.getId();
if (id == null) {
performanceConfigMapper.insertOne(dto);
id = dto.getId();
} else {
performanceConfigMapper.updateById(dto);
}
performanceParamConfigService.addParamConfig(dto.getPerformanceParamConfigs(), id);
performanceConfigRuleService.addRule(dto.getPerformanceConfigRule(), id);
performanceConfigMerchantBrandRefService.addRef(dto.getMerchantBrandModelPageBrands(), id);
return RpcResponse.success(id);
}
public PerformanceConfigDTO selectById(Integer id) {
return performanceConfigMapper.selectById(id);
}
public void updateById(PerformanceConfigDTO config) {
performanceConfigMapper.updateById(config);
}
public List<PerformanceConfigDetailDTO> performanceConfigDetailWithMerchant(PerformanceConfigDTO dto) {
log.info("selectEffectiveConfig dto: {}", dto);
RpcAssert.assertNotNull(dto, DefaultErrorEnum.DATA_NULL, "dto不能为空");
RpcAssert.assertNotNull(dto.getMerchantId(), DefaultErrorEnum.DATA_NULL, "merchantId不能为空");
// 1 查询生效中的方案
List<PerformanceConfigDTO> performanceConfigDTOS = performanceConfigMapper.effectivePerformanceConfigByMerchantId(dto.getMerchantId());
List<PerformanceConfigDetailDTO> result = new ArrayList<>();
for (PerformanceConfigDTO performanceConfigDTO : performanceConfigDTOS) {
PerformanceConfigDetailDTO detailDTO = PerformanceConfigDetailDTO.builder()
.id(null)
.originPerformanceConfigId(performanceConfigDTO.getId())
.schemeName(performanceConfigDTO.getSchemeName())
.schemeType(2)
.businessType(performanceConfigDTO.getBusinessType())
.effectiveMonth(performanceConfigDTO.getEffectiveMonth())
.build();
// 查询rule
PerformanceConfigRuleDTO ruleDTO = performanceConfigRuleService
.listByConfigId(performanceConfigDTO.getId());
detailDTO.setPerformanceConfigRule(ruleDTO);
// 查询参数配置
List<PerformanceParamConfigDTO> performanceParamConfigs = performanceParamConfigService
.listByConfigId(performanceConfigDTO.getId());
detailDTO.setParamConfigList(performanceParamConfigs);
// 查询商户品牌
List<PerformanceConfigMerchantBrandRefDTO> merchantBrandRefs = performanceConfigMerchantBrandRefService
.listByConfigId(performanceConfigDTO.getId());
merchantBrandRefs.removeIf(merchantBrandRef -> !merchantBrandRef.getMerchantId().equals(dto.getMerchantId()));
detailDTO.setMerchantBrandRefList(merchantBrandRefs);
result.add(detailDTO);
}
return result;
}
public void enblePerformanceConfig() {
performanceConfigMapper.enblePerformanceConfig();
}
}
......@@ -13,10 +13,10 @@ import java.util.List;
public class PerformanceParamConfigConditionService {
@Autowired
private PerformanceParamConfigConditionMapper performanceParamConfigConditionMapper;
public void deleteByPerformanceConfigId(Integer performanceConfigId) {
performanceParamConfigConditionMapper.deleteByPerformanceConfigId(performanceConfigId);
}
public void insertList(List<PerformanceParamConfigConditionDTO> performanceParamConfigConditionDTOList) {
// 1 把物理删除久的condition
performanceParamConfigConditionMapper.deleteByPerformanceConfigId(performanceParamConfigConditionDTOList.get(0).getPerformanceConfigId());
// 2 插入新的condition
performanceParamConfigConditionMapper.insertList(performanceParamConfigConditionDTOList);
performanceParamConfigConditionMapper.insertLists(performanceParamConfigConditionDTOList);
}
}
package cn.com.glsx.dj.staff.service.staffPerformance;
import cn.com.glsx.dj.staff.dto.PerformanceParamConfigConditionDTO;
import cn.com.glsx.dj.staff.dto.PerformanceParamConfigDTO;
import cn.com.glsx.dj.staff.mapper.PerformanceParamConfigMapper;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
......@@ -20,6 +21,9 @@ public class PerformanceParamConfigService {
@Autowired
private PerformanceParamConfigMapper performanceParamConfigMapper;
@Autowired
private PerformanceParamConfigConditionService performanceParamConfigConditionService;
/**
* 根据配置ID查询参数列表
*
......@@ -32,4 +36,24 @@ public class PerformanceParamConfigService {
PerformanceParamConfigDTO dto = PerformanceParamConfigDTO.builder().performanceConfigId(configId).build();
return performanceParamConfigMapper.listByConfigId(dto);
}
public void addParamConfig(List<PerformanceParamConfigDTO> performanceParamConfigs, Integer performanceConfigId) {
// 1. 先删掉原来的配置
performanceParamConfigMapper.deleteByPerformanceParamConfigId(performanceConfigId);
// 2. 删除掉原有的条件
performanceParamConfigConditionService.deleteByPerformanceConfigId(performanceConfigId);
for (PerformanceParamConfigDTO performanceParamConfig : performanceParamConfigs) {
performanceParamConfig.setPerformanceConfigId(performanceConfigId);
// 3. 执行插入,拿到id
int id = performanceParamConfigMapper.insertOne(performanceParamConfig);
// 4. 插入条件
List<PerformanceParamConfigConditionDTO> performanceParamConfigConditions = performanceParamConfig.getPerformanceParamConfigConditions();
if (performanceParamConfigConditions != null && !performanceParamConfigConditions.isEmpty()) {
for (PerformanceParamConfigConditionDTO performanceParamConfigCondition : performanceParamConfigConditions) {
performanceParamConfigCondition.setPerformanceConfigId(id);
}
performanceParamConfigConditionService.insertList(performanceParamConfigConditions);
}
}
}
}
package cn.com.glsx.dj.staff.service.staffPerformance;
import cn.com.glsx.dj.staff.constant.CommonConstants;
import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO;
import cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO;
import cn.com.glsx.dj.staff.dto.*;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO;
import cn.com.glsx.dj.staff.enums.CommissionTypeEnum;
import cn.com.glsx.dj.staff.mapper.StaffPerformanceMapper;
......@@ -220,4 +219,14 @@ public class StaffPerformanceService {
cn.com.glsx.framework.core.enums.DefaultErrorEnum.DATABASE_ERROR);
}
}
public List<PerformanceCommissionStaffDTO> listStaffWithPerformanceCommission() {
try {
return staffPerformanceMapper.listStaffWithPerformanceCommission();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new cn.com.glsx.framework.core.exception.RpcServiceException(
cn.com.glsx.framework.core.enums.DefaultErrorEnum.DATABASE_ERROR);
}
}
}
......@@ -3,10 +3,9 @@ package cn.com.glsx.dj.staff.service.staffPerformance;
import cn.com.glsx.dj.smartcarlife.constant.CommonConstants;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO;
import cn.com.glsx.dj.smartcarlife.remote.MerchantPerformanceProductDefineRemote;
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.dto.*;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceGetDTO;
import cn.com.glsx.dj.staff.enums.CommissionTypeEnum;
import cn.com.glsx.dj.staff.enums.GoodsConfigTypeEnum;
import cn.com.glsx.dj.staff.mapper.StaffProductPerformanceMapper;
......@@ -28,8 +27,6 @@ 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;
......@@ -48,6 +45,8 @@ public class StaffProductPerformanceService {
private StaffProductPerformanceMapper staffProductPerformanceMapper;
@Autowired
private MerchantPerformanceProductDefineRemote merchantPerformanceProductDefineRemote;
@Autowired
private StaffPerformanceService staffPerformanceService;
StaffProductPerformanceService(AutoPerformRuleService autoPerformRuleService) {
this.autoPerformRuleService = autoPerformRuleService;
......@@ -299,6 +298,42 @@ public class StaffProductPerformanceService {
return DataCalUtil.divideToPercent(new BigDecimal(upgradeOrderNum), personalTargetTouchCount);
}
public List<StaffPerformanceGetDTO> getPerformanceCommissionCompositionForStaff(StaffPerformanceGetDTO dto) {
StaffProductPerformanceDTO query = StaffProductPerformanceDTO.builder().staffPhone(dto.getStaffPhone()).month(dto.getMonth()).build();
List<StaffProductPerformanceDTO> staffProductPerformanceDTOList = staffProductPerformanceMapper.listStaffPerformance(query);
if (staffProductPerformanceDTOList.isEmpty()) {
return new ArrayList<>();
}
StaffPerformanceDTO staffPerformanceDTO = StaffPerformanceDTO.builder().staffPhone(dto.getStaffPhone()).month(dto.getMonth()).build();
List<StaffPerformanceDTO> staffPerformanceDTOList = staffPerformanceService.listStaffPerformance(staffPerformanceDTO);
Map<Integer, List<StaffProductPerformanceDTO>> map = staffProductPerformanceDTOList.stream().collect(Collectors.groupingBy(StaffProductPerformanceDTO::getMerchantId));
List<StaffPerformanceGetDTO> staffPerformanceGetDTOList = new ArrayList<>();
for (List<StaffProductPerformanceDTO> value : map.values()) {
StaffProductPerformanceDTO staffProductPerformanceDTO = value.get(0);
StaffPerformanceGetDTO staffPerformanceGetDTO = new StaffPerformanceGetDTO();
staffPerformanceGetDTOList.add(staffPerformanceGetDTO);
staffPerformanceGetDTO.setStaffName(staffProductPerformanceDTO.getStaffName());
staffPerformanceGetDTO.setMerchantId(staffProductPerformanceDTO.getMerchantId());
int effectiveReferralQuantity = 0;
int touchNumber = 0;
BigDecimal totalPerformanceAmount = BigDecimal.ZERO;
for (StaffPerformanceDTO performanceDTO : staffPerformanceDTOList) {
if (performanceDTO.getMerchantId().equals(staffProductPerformanceDTO.getMerchantId())) {
effectiveReferralQuantity += performanceDTO.getEffectiveReferralQuantity();
touchNumber += performanceDTO.getTouchNumber();
}
}
for (StaffProductPerformanceDTO productPerformanceDTO : value) {
totalPerformanceAmount = totalPerformanceAmount.add(productPerformanceDTO.getPerformanceAmount());
}
staffPerformanceGetDTO.setEffectiveReferralQuantity(effectiveReferralQuantity);
staffPerformanceGetDTO.setTouchNumber(touchNumber);
staffPerformanceGetDTO.setStaffPerformanceList(value);
}
return staffPerformanceGetDTOList;
}
private static class MetricsResult {
private final int upgradeOrderNum;
private final BigDecimal gmvOutput;
......
......@@ -19,15 +19,6 @@
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigApproveDTO" extends="BaseResultMap">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="performance_config_id" property="performanceConfigId" jdbcType="INTEGER" />
<result column="approve_remark" property="approveRemark" jdbcType="VARCHAR" />
<result column="approve_attachments" property="approveAttachments" jdbcType="VARCHAR" />
<result column="attachment_imgs" property="attachmentImgs" jdbcType="VARCHAR" />
<result column="submit_username" property="submitUsername" jdbcType="VARCHAR" />
<result column="approve_status" property="approveStatus" jdbcType="TINYINT" />
<result column="merchant_names" property="merchantNames" jdbcType="VARCHAR" />
<result column="brands_names" property="brandsNames" jdbcType="VARCHAR" />
</resultMap>
<!-- 分页DTO结果映射:联表后完整匹配所有字段 -->
......@@ -74,7 +65,7 @@
SELECT
a.id AS a_id,
c.scheme_name AS c_scheme_name,
c.business_typeG AS c_business_type,
c.business_type AS c_business_type,
c.effective_month AS c_effective_month,
c.status AS c_status,
a.merchant_names AS a_merchant_names,
......@@ -138,4 +129,94 @@
AND a.id = #{id}
LIMIT 1
</select>
<insert id="insertOne"
parameterType="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigApproveDTO"
useGeneratedKeys="true"
keyProperty="id"
keyColumn="id">
INSERT INTO dj_car_life_performance_config_approve (
performance_config_id,
approve_remark,
approve_attachments,
attachment_imgs,
submit_username,
approve_status,
merchant_names,
brands_names,
created_by,
created_date,
updated_by,
updated_date,
deleted_flag
) VALUES (
#{performanceConfigId},
#{approveRemark},
#{approveAttachments},
#{attachmentImgs},
#{submitUsername},
#{approveStatus},
#{merchantNames},
#{brandsNames},
#{createdBy},
NOW(),
#{updatedBy},
NOW(),
'N'
)
</insert>
<select id="selectById" parameterType="java.lang.Integer" resultMap="DTOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
dj_car_life_performance_config_approve
WHERE
deleted_flag = 'N'
AND id = #{id}
LIMIT 1
</select>
<update id="updateById" parameterType="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigApproveDTO">
UPDATE dj_car_life_performance_config_approve
SET
<if test="performanceConfigId != null">
performance_config_id = #{performanceConfigId},
</if>
<if test="approveRemark != null and approveRemark != ''">
approve_remark = #{approveRemark},
</if>
<if test="approveAttachments != null and approveAttachments != ''">
approve_attachments = #{approveAttachments},
</if>
<if test="attachmentImgs != null and attachmentImgs != ''">
attachment_imgs = #{attachmentImgs},
</if>
<if test="submitUsername != null and submitUsername != ''">
submit_username = #{submitUsername},
</if>
<if test="approveStatus != null">
approve_status = #{approveStatus},
</if>
<if test="merchantNames != null and merchantNames != ''">
merchant_names = #{merchantNames},
</if>
<if test="brandsNames != null and brandsNames != ''">
brands_names = #{brandsNames},
</if>
<if test="updatedBy != null and updatedBy != ''">
updated_by = #{updatedBy},
</if>
WHERE
deleted_flag = 'N'
AND id = #{id}
</update>
<select id="selectByPerformanceConfigId" parameterType="java.lang.Integer" resultMap="DTOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
dj_car_life_performance_config_approve
WHERE
deleted_flag = 'N'
AND performance_config_id = #{performanceConfigId}
</select>
</mapper>
\ No newline at end of file
......@@ -7,7 +7,9 @@
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="performance_config_approve_id" property="performanceConfigApproveId" jdbcType="INTEGER" />
<result column="approve_status" property="status" jdbcType="TINYINT" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="approver_type" property="approverType" jdbcType="TINYINT" />
<result column="push_status" property="pushStatus" jdbcType="TINYINT" />
<result column="approve_time" property="approveTime" jdbcType="TIMESTAMP" />
<result column="approve_opinion" property="approveOpinion" jdbcType="VARCHAR" />
<result column="approver_name" property="approverName" jdbcType="VARCHAR" />
......@@ -19,57 +21,54 @@
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<!-- <resultMap id="DTOResultMap" type="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigApproveOperationRecordDTO" extends="BaseResultMap">-->
<!-- </resultMap>-->
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigApproveOperationRecordDTO" extends="BaseResultMap">
</resultMap>
<sql id="Base_Column_List" >
id, performance_config_approve_id, approve_status, approve_time, approve_opinion, approver_name,
approver_mobile, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<!-- 通用字段映射:DTO → 数据库字段 -->
<sql id="column_map">
performance_config_approve_id,
status,
approve_time,
approve_opinion,
approver_name,
approver_mobile,
created_by,
created_date,
updated_by,
updated_date
id, performance_config_approve_id, approve_status, approver_type, push_status, approve_time, approve_opinion, approver_name,
approver_mobile, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<!-- 通用值映射:DTO参数 → 字段值 -->
<sql id="value_map">
#{dto.performanceConfigApproveId},
#{dto.status},
#{dto.approveTime},
#{dto.approveOpinion},
#{dto.approverName},
#{dto.approverMobile},
#{dto.createdBy},
<!-- 创建时间:为空则填充当前时间,否则用传入值 -->
IFNULL(#{dto.createdDate}, NOW()),
#{dto.updatedBy},
<!-- 修改时间:每次操作都更新为当前时间 -->
NOW()
</sql>
<select id="listByPerformanceConfigApproveId" parameterType="java.lang.Integer" resultMap="DTOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
dj_car_life_performance_config_approve_operation_record
WHERE
deleted_flag = 'N'
AND performance_config_approve_id = #{performanceConfigApproveId}
ORDER BY
approve_time DESC
</select>
<update id="updateApproveOpinionAndStatusById" parameterType="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigApproveOperationRecordDTO">
UPDATE dj_car_life_performance_config_approve_operation_record
SET
<if test="status != null">
approve_status = #{status},
</if>
<if test="approveOpinion != null and approveOpinion != ''">
approve_opinion = #{approveOpinion},
</if>
<if test="approveTime != null">
approve_time = #{approveTime},
</if>
<if test="updatedBy != null and updatedBy != ''">
updated_by = #{updatedBy},
</if>
updated_date = NOW()
WHERE
deleted_flag = 'N'
AND id = #{id}
</update>
<!-- 插入/更新审批操作记录:重复则更新最新数据 -->
<insert id="addOp" parameterType="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigApproveOperationRecordDTO">
INSERT INTO dj_car_life_performance_config_approve_operation_record (
<include refid="column_map"/>
) VALUES (
<include refid="value_map"/>
) ON DUPLICATE KEY UPDATE
-- 重复时更新以下字段(保留创建时间,仅更新最新操作数据)
status = #{dto.status},
approve_time = #{dto.approveTime},
approve_opinion = #{dto.approveOpinion},
approver_name = #{dto.approverName},
updated_by = #{dto.updatedBy},
updated_date = NOW() -- 强制更新修改时间
-- created_date 保留原有值,不更新
</insert>
<update id="updateReadStatusByMobile" parameterType="string">
UPDATE dj_car_life_performance_config_approve_operation_record
SET
approve_status = 1
WHERE
deleted_flag = 'N'
AND approver_mobile = #{mobile}
AND approver_type = 2
</update>
</mapper>
\ No newline at end of file
......@@ -73,6 +73,7 @@
<select id="listPerformanceConfig" parameterType="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigPageDTO" resultType="cn.com.glsx.dj.staff.dto.performance.PerformanceConfigPageDTO">
SELECT
c.id,
c.scheme_type,
c.scheme_name AS schemeName,
c.business_type AS businessType,
c.status,
......@@ -85,6 +86,9 @@
AND r.deleted_flag = 'N'
WHERE
c.deleted_flag = 'N'
<if test="scheme_type != null">
AND c.scheme_type = #{schemeType}
</if>
GROUP BY
c.id,
c.scheme_name,
......@@ -156,7 +160,7 @@
GROUP BY
ref.merchant_id, s.merchant_name
ORDER BY
ref.merchant_id ASC;
ref.merchant_id DESC
</select>
......@@ -176,12 +180,13 @@
WHERE
cfg.deleted_flag = 'N'
AND cfg.status = 2
AND cfg.enable_flag = 'Y'
GROUP BY
ref.merchant_id
</select>
<select id="isEffectivePerformanceExist"
<select id="hasEffectivePerformanceConfigForMerchant"
parameterType="java.lang.Integer"
resultType="java.lang.Boolean">
SELECT EXISTS (
......@@ -197,4 +202,55 @@
) AS exist_flag;
</select>
<insert id="insertOne" parameterType="cn.com.glsx.dj.staff.dto.PerformanceConfigDTO"
useGeneratedKeys="true" keyProperty="id" keyColumn="id">
INSERT INTO dj_car_life_performance_config (scheme_name,
scheme_type,
origin_performance_config_id,
business_type,
effective_month,
status)
VALUES (#{schemeName},
#{schemeType},
#{originPerformanceConfigId},
#{businessType},
#{effectiveMonth},
#{status})
</insert>
<update id="updateById" parameterType="cn.com.glsx.dj.staff.dto.PerformanceConfigDTO">
UPDATE dj_car_life_performance_config
SET
<if test="schemeName != null and schemeName != ''">
scheme_name = #{schemeName},
</if>
<if test="schemeType != null">
scheme_type = #{schemeType},
</if>
<if test="originPerformanceConfigId != null">
origin_performance_config_id = #{originPerformanceConfigId},
</if>
<if test="businessType != null">
business_type = #{businessType},
</if>
<if test="effectiveMonth != null and effectiveMonth != ''">
effective_month = #{effectiveMonth},
</if>
<if test="status != null">
status = #{status}
</if>
WHERE id = #{id}
</update>
<update id="enblePerformanceConfig">
UPDATE dj_car_life_performance_config
SET
enable_flag = 'Y',
updated_by = 'system'
WHERE
deleted_flag = 'N'
AND effective_month &lt;= DATE_FORMAT(NOW(), '%Y-%m')
AND status = 2
AND enable_flag = 'N';
</update>
</mapper>
\ No newline at end of file
......@@ -19,6 +19,9 @@
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.staff.dto.PerformanceConfigMerchantBrandRefDTO" extends="BaseResultMap">
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
......@@ -26,4 +29,88 @@
id, performance_config_id, merchant_id, merchant_name, brand_id, brand_name, child_id,
child_name, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<!-- 新增:根据配置ID逻辑删除商户品牌关联数据 -->
<update id="deleteByConfigId" parameterType="java.lang.Integer">
UPDATE dj_car_life_performance_config_merchant_brand_ref
SET
deleted_flag = 'D',
updated_date = NOW()
WHERE
deleted_flag = 'N'
AND performance_config_id = #{performanceConfigId}
</update>
<!-- 新增:批量插入商户品牌关联数据 -->
<insert id="insertLists"
parameterType="java.util.List"
useGeneratedKeys="true"
keyProperty="id"
keyColumn="id">
INSERT INTO dj_car_life_performance_config_merchant_brand_ref (
performance_config_id,
merchant_id,
merchant_name,
brand_id,
brand_name,
child_id,
child_name,
created_by,
created_date,
updated_by,
updated_date,
deleted_flag
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.performanceConfigId},
#{item.merchantId},
#{item.merchantName},
#{item.brandId},
#{item.brandName},
#{item.childId},
#{item.childName},
#{item.createdBy},
NOW(),
#{item.updatedBy},
NOW(),
'N'
)
</foreach>
</insert>
<!-- 新增:根据配置ID查询商户品牌关联列表 -->
<select id="listByConfigId" parameterType="java.lang.Integer" resultMap="DTOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
dj_car_life_performance_config_merchant_brand_ref
WHERE
deleted_flag = 'N'
AND performance_config_id = #{id}
ORDER BY
id DESC
</select>
<update id="invalidByBusinessTypeAndMerchantBrand" parameterType="cn.com.glsx.dj.staff.dto.PerformanceConfigMerchantBrandRefDTO">
UPDATE dj_car_life_performance_config_merchant_brand_ref ref
INNER JOIN dj_car_life_performance_config cfg
ON ref.performance_config_id = cfg.id
AND cfg.deleted_flag = 'N'
AND cfg.status = 2
AND cfg.business_type = #{businessType}
SET
ref.deleted_flag = 'D',
ref.updated_date = NOW(),
WHERE
ref.deleted_flag = 'N'
AND ref.merchant_id = #{merchantId}
AND ref.brand_id = #{brandId}
<!-- 兼容child_id为NULL的场景 -->
<if test="childId != null">
AND ref.child_id = #{childId}
</if>
<if test="childId == null">
AND ref.child_id IS NULL
</if>
</update>
</mapper>
\ No newline at end of file
......@@ -17,6 +17,9 @@
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.staff.dto.PerformanceConfigRuleDTO" extends="BaseResultMap">
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
......@@ -24,4 +27,57 @@
id, performance_config_id, assessment_factors, commission_bases, commission_types,
goods_config_types, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<!-- 新增:根据配置ID查询单条规则 -->
<select id="listByConfigId" parameterType="java.lang.Integer" resultMap="DTOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
dj_car_life_performance_config_rule
WHERE
deleted_flag = 'N'
AND performance_config_id = #{id}
LIMIT 1
</select>
<!-- 新增:单条插入规则数据 -->
<insert id="insertOne"
parameterType="cn.com.glsx.dj.staff.dto.PerformanceConfigRuleDTO"
useGeneratedKeys="true"
keyProperty="id"
keyColumn="id">
INSERT INTO dj_car_life_performance_config_rule (
performance_config_id,
assessment_factors,
commission_bases,
commission_types,
goods_config_types,
created_by,
created_date,
updated_by,
updated_date,
deleted_flag
) VALUES (
#{performanceConfigId},
#{assessmentFactors},
#{commissionBases},
#{commissionTypes},
#{goodsConfigTypes},
#{createdBy},
NOW(),
#{updatedBy},
NOW(),
'N'
)
</insert>
<!-- 新增:根据配置ID逻辑删除规则 -->
<update id="deleteByConfigId" parameterType="java.lang.Integer">
UPDATE dj_car_life_performance_config_rule
SET
deleted_flag = 'D',
updated_date = NOW()
WHERE
deleted_flag = 'N'
AND performance_config_id = #{performanceConfigId}
</update>
</mapper>
\ No newline at end of file
......@@ -88,4 +88,61 @@
ORDER BY
dcpcc.id DESC
</select>
<!-- 新增的批量插入语句 -->
<insert id="insertLists"
parameterType="java.util.List"
useGeneratedKeys="true"
keyProperty="id"
keyColumn="id">
INSERT INTO dj_car_life_performance_param_config_condition (
performance_param_config_id,
condition_type,
condition_goods_config_type,
condition_goods_type,
condition_goods_type_name,
condition_secondary_goods_type,
condition_secondary_goods_type_name,
condition_third_level_goods_type,
condition_third_level_goods_type_name,
condition_product_define_id,
condition_product_define_name,
condition_assessment_factors,
condition_start_value,
condition_end_value,
condition_commission_base,
condition_commission_type,
condition_commission_type_value,
created_by,
created_date,
updated_by,
updated_date,
deleted_flag
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.performanceParamConfigId},
#{item.conditionType},
#{item.conditionGoodsConfigType},
#{item.conditionGoodsType},
#{item.conditionGoodsTypeName},
#{item.conditionSecondaryGoodsType},
#{item.conditionSecondaryGoodsTypeName},
#{item.conditionThirdLevelGoodsType},
#{item.conditionThirdLevelGoodsTypeName},
#{item.conditionProductDefineId},
#{item.conditionProductDefineName},
#{item.conditionAssessmentFactors},
#{item.conditionStartValue},
#{item.conditionEndValue},
#{item.conditionCommissionBase},
#{item.conditionCommissionType},
#{item.conditionCommissionTypeValue},
#{item.createdBy},
NOW(),
#{item.updatedBy},
NOW(),
'N'
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -84,4 +84,54 @@
deleted_flag = 'N'
AND performance_config_id = #{id}
</update>
<insert id="insertOne"
parameterType="cn.com.glsx.dj.staff.dto.PerformanceParamConfigDTO"
useGeneratedKeys="true"
keyProperty="id"
keyColumn="id">
INSERT INTO dj_car_life_performance_param_config (performance_config_id,
template_type,
assessment_factor,
start_value,
end_value,
commission_base,
commission_type,
goods_config_type,
goods_type,
goods_type_name,
secondary_goods_type,
secondary_goods_type_name,
third_level_goods_type,
third_level_goods_type_name,
product_define_id,
product_define_name,
commission_type_value,
created_by,
created_date,
updated_by,
updated_date,
deleted_flag)
VALUES (#{performanceConfigId},
#{templateType},
#{assessmentFactor},
#{startValue},
#{endValue},
#{commissionBase},
#{commissionType},
#{goodsConfigType},
#{goodsType},
#{goodsTypeName},
#{secondaryGoodsType},
#{secondaryGoodsTypeName},
#{thirdLevelGoodsType},
#{thirdLevelGoodsTypeName},
#{productDefineId},
#{productDefineName},
#{commissionTypeValue},
#{createdBy},
NOW(),
#{updatedBy},
NOW(),
'N')
</insert>
</mapper>
\ No newline at end of file
......@@ -9,9 +9,8 @@
<result column="cycle_name" property="cycleName" jdbcType="VARCHAR" />
<result column="cycle_code" property="cycleCode" jdbcType="VARCHAR" />
<result column="cycle_item" property="cycleItem" jdbcType="VARCHAR" />
<result column="start_date" property="startDate" jdbcType="TIMESTAMP" />
<result column="end_date" property="endDate" jdbcType="TIMESTAMP" />
<result column="enable_flag" property="enableFlag" jdbcType="CHAR" />
<result column="start_day_of_month" property="stratDayOfMonth" jdbcType="VARCHAR" />
<result column="end_day_of_month" property="endDayOfMonth" jdbcType="VARCHAR" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
......@@ -20,46 +19,50 @@
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO" extends="BaseResultMap">
<result column="start_date" property="startDate" jdbcType="TIMESTAMP" />
<result column="end_date" property="endDate" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, cycle_name,cycle_code, cycle_item, start_date, end_date, enable_flag,
id, cycle_name,cycle_code, cycle_item, start_day_of_month, end_day_of_month,
created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<sql id="DTO_Column_List" >
<include refid="Base_Column_List"/>,
STR_TO_DATE(CONCAT(DATE_FORMAT(NOW(), '%Y-%m-'), start_day_of_month), '%Y-%m-%d %H:%i:%s') AS start_date,
STR_TO_DATE(CONCAT(DATE_FORMAT(NOW(), '%Y-%m-'), end_day_of_month), '%Y-%m-%d %H:%i:%s') AS end_date
</sql>
<select id="selectCurrCycle" resultMap="DTOResultMap">
SELECT
<include refid="Base_Column_List"/>
<include refid="DTO_Column_List"/>
FROM
dj_car_life_performance_time_cycle
WHERE
deleted_flag = 'N'
AND enable_flag = 'Y'
AND NOW() BETWEEN start_date AND end_date
AND NOW() BETWEEN STR_TO_DATE(CONCAT(DATE_FORMAT(NOW(), '%Y-%m-'), start_day_of_month), '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(CONCAT(DATE_FORMAT(NOW(), '%Y-%m-'), end_day_of_month), '%Y-%m-%d %H:%i:%s')
LIMIT 1
</select>
<select id="list" resultMap="DTOResultMap">
SELECT
<include refid="Base_Column_List"/>
<include refid="DTO_Column_List"/>
FROM
dj_car_life_performance_time_cycle
WHERE
deleted_flag = 'N'
AND enable_flag = 'Y'
</select>
<select id="selectByCode" parameterType="string" resultMap="DTOResultMap">
SELECT
<include refid="Base_Column_List"/>
<include refid="DTO_Column_List"/>
FROM
dj_car_life_performance_time_cycle
WHERE
deleted_flag = 'N'
AND enable_flag = 'Y'
AND cycle_code = #{code}
LIMIT 1
</select>
......
......@@ -79,4 +79,15 @@
AND month = #{month}
AND deleted_flag = 'N'
</update>
<select id="listStaffWithPerformanceCommission" resultType="cn.com.glsx.dj.staff.dto.PerformanceCommissionStaffDTO">
SELECT
staff_name as staffName,
staff_phone as staffPhone
FROM
dj_car_life_staff_performance dclsp
WHERE
dclsp.deleted_flag = 'N'
group by dclsp.staff_phone
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!