Commit 961cbf42 by 林永健

feat(integral): 添加积分提现标签管理和批量驳回功能

- 新增IntegralTransferOutTagSummaryRemote远程接口及实现
- 实现积分提现标签树查询、保存、删除和绑定功能
- 添加积分提现一键批量驳回功能,支持按ID或筛选条件批量操作
- 扩展导出VO增加限制门店、手动标签、主营品牌和省份字段
- 实现标签级联过滤和批量更新标签功能
- 添加限制门店筛选和商户信息快照功能
- 优化批量驳回的事务处理和错误处理机制
1 parent b86044b4
Showing 21 changed files with 803 additions and 35 deletions
......@@ -11,7 +11,7 @@
<name>rpc-scrm-shopmall-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.shopmall.remote</deploy.scanPackage>
<shopmall.api.version>5.8.4.3-SNAPSHOT</shopmall.api.version>
<shopmall.api.version>5.8.5-SNAPSHOT</shopmall.api.version>
<stoassistant.api.version>5.6.4-SNAPSHOT</stoassistant.api.version>
</properties>
<dependencies>
......
package cn.com.glsx.scrm.shopmall.dto.integral;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 批量操作结果 DTO。
*
* 批量驳回/审批等逐条独立事务场景下返回,供前端展示部分成功与失败原因。
*/
@Data
@ApiModel(value = "IntegralTransferOutBatchResultDTO", description = "批量操作结果DTO")
public class IntegralTransferOutBatchResultDTO implements Serializable {
private static final long serialVersionUID = 1752893746234502981L;
@ApiModelProperty(notes = "成功记录ID集合")
private List<Integer> successIds = new ArrayList<>();
@ApiModelProperty(notes = "失败记录及原因(key=记录ID,value=失败原因)")
private Map<Integer, String> failReasons = new LinkedHashMap<>();
}
......@@ -71,4 +71,52 @@ public class IntegralTransferOutDTO extends IntegralTransferOut implements Seria
* 导出时需要导出提现单对应的订单号列表
*/
private List<String> motivationOrderCodes;
@ApiModelProperty(notes = "限制门店:Y是/N否(基于配置的门店号列表动态判断,不落库)", dataType = "string")
private String limitStoreFlag;
@ApiModelProperty(notes = "手动标签ID", dataType = "int")
private Integer manualTagId;
@ApiModelProperty(notes = "手动标签路径(如 账期逾期/xx/yy,JOIN 标签表取值)", dataType = "string")
private String manualTagPath;
@ApiModelProperty(notes = "主营品牌ID快照(多个品牌ID以英文逗号拼接)", dataType = "string")
private String mainBrandId;
@ApiModelProperty(notes = "主营品牌名称快照", dataType = "string")
private String mainBrandName;
@ApiModelProperty(notes = "省份编码快照", dataType = "string")
private String provinceCode;
@ApiModelProperty(notes = "省份名称快照", dataType = "string")
private String provinceName;
@ApiModelProperty(notes = "限制门店筛选:Y是/N否(不传=全部)", dataType = "string")
private String limitStoreFlagQuery;
@ApiModelProperty(notes = "主营品牌ID多选筛选", dataType = "list")
private List<Integer> mainBrandIds;
@ApiModelProperty(notes = "省份编码多选筛选", dataType = "list")
private List<String> provinceCodes;
@ApiModelProperty(notes = "所属门店ID多选筛选", dataType = "list")
private List<Integer> merchantIds;
@ApiModelProperty(notes = "手动标签筛选ID(前端传入,级联查其全部后代)", dataType = "int")
private Integer transferOutTagIdQuery;
/**
* 级联解析后的标签ID集合(含所选标签及其全部后代,内部使用)
*/
@ApiModelProperty(notes = "级联标签ID集合(内部使用)", dataType = "list")
private List<Integer> transferOutTagIds;
/**
* 限制门店商户号集合(配置驱动,供 SQL 动态判断,不落库)
*/
@ApiModelProperty(notes = "限制门店商户号集合(配置驱动,内部使用)", dataType = "list")
private List<String> limitStoreMerchantNos;
}
......@@ -25,4 +25,10 @@ public class IntegralTransferOutOperationDTO extends IntegralTransferOutOperatio
@ApiModelProperty(notes = "银行通道编码")
private String levyChannelCode;
@ApiModelProperty(notes = "驳回原因")
private String rejectReason;
@ApiModelProperty(notes = "模式B:筛选条件(与列表页查询条件一致,ids 为空时按该条件解析全部匹配记录后统一操作)")
private IntegralTransferOutDTO condition;
}
package cn.com.glsx.scrm.shopmall.dto.integral;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 积分提现记录打标签请求 DTO。
*
* 需求 1049744:打标不强制限定三级标签,已补全的二级标签路径同样可用于打标。
* 支持两种批量模式:按 ids 列表打标,或按筛选条件(condition)一键打标全部匹配记录。
*/
@Data
@ApiModel(value = "IntegralTransferOutTagBindDTO", description = "积分提现记录打标签请求DTO")
public class IntegralTransferOutTagBindDTO implements Serializable {
private static final long serialVersionUID = -5177466569762273422L;
@ApiModelProperty(notes = "提现记录ID集合(模式A:按id打标,单条传一个元素,批量传多个元素;为空则走模式B按筛选条件打标)")
private List<Integer> ids;
@ApiModelProperty(notes = "目标标签ID(二级/三级均可),传空表示解绑")
private Integer transferOutTagId;
@ApiModelProperty(notes = "模式B:筛选条件(与列表页查询条件一致,ids 为空时按该条件解析全部匹配记录后统一打标)")
private IntegralTransferOutDTO condition;
@ApiModelProperty(notes = "操作人")
private String operator;
}
package cn.com.glsx.scrm.shopmall.dto.integral;
import cn.com.glsx.scrm.shopmall.model.IntegralTransferOutTag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
/**
* 积分提现标签 DTO。
*/
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "IntegralTransferOutTagDTO", description = "积分提现标签DTO")
public class IntegralTransferOutTagDTO extends IntegralTransferOutTag {
private static final long serialVersionUID = 8736905432981404601L;
@ApiModelProperty(notes = "子节点列表")
private List<IntegralTransferOutTagDTO> children;
}
package cn.com.glsx.scrm.shopmall.dto.integral;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 积分提现标签树查询 DTO。
*/
@Data
@ApiModel(value = "IntegralTransferOutTagQueryDTO", description = "积分提现标签树查询DTO")
public class IntegralTransferOutTagQueryDTO implements Serializable {
private static final long serialVersionUID = 4034730023655482230L;
@ApiModelProperty(notes = "节点ID")
private Integer id;
@ApiModelProperty(notes = "父节点ID")
private Integer parentId;
@ApiModelProperty(notes = "层级")
private Integer level;
@ApiModelProperty(notes = "名称模糊查询")
private String nameLike;
@ApiModelProperty(notes = "path 前缀过滤,查询当前节点及全部子孙节点")
private String path;
@ApiModelProperty(notes = "是否为结果补齐全部祖先节点")
private Boolean appendAncestors;
/**
* 仅返回已补全(level >= 2)标签路径
*/
@ApiModelProperty(notes = "是否仅返回已补全二级及以上的标签路径")
private Boolean onlyComplete;
}
......@@ -251,4 +251,39 @@ public class IntegralTransferOut implements Serializable {
@ApiModelProperty(notes = "平台方商户名称(逗号拼接)")
@Column(name = "reality_platform_merchant_name")
private String realityMerchantName;
/**
* 手动标签ID(二级/三级均可),需求 1049744
*/
@ApiModelProperty(notes = "手动标签ID")
@Column(name = "transfer_out_tag_id")
private Integer transferOutTagId;
/**
* 主营品牌ID快照(多个品牌ID以英文逗号拼接,如 1,5,9)
*/
@ApiModelProperty(notes = "主营品牌ID快照(多个品牌ID以英文逗号拼接)")
@Column(name = "main_brand_id")
private String mainBrandId;
/**
* 主营品牌名称快照(对应商户域 MerchantBrandDTO.name)
*/
@ApiModelProperty(notes = "主营品牌名称快照")
@Column(name = "main_brand_name")
private String mainBrandName;
/**
* 省份编码快照(对应商户域 provinceCode)
*/
@ApiModelProperty(notes = "省份编码快照")
@Column(name = "province_code")
private String provinceCode;
/**
* 省份名称快照(对应商户域 provinceName)
*/
@ApiModelProperty(notes = "省份名称快照")
@Column(name = "province_name")
private String provinceName;
}
\ No newline at end of file
package cn.com.glsx.scrm.shopmall.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 积分提现标签目录。
*
* 需求 1049744 阳光激励积分:SCRM 积分提现管理自定义三级标签树。
* 默认含一级标签「账期逾期」「结算账期」,至少补全到二级方可使用。
*/
@Data
@ToString
@ApiModel(value = "IntegralTransferOutTag", description = "积分提现标签目录")
@Table(name = "integral_transfer_out_tag")
public class IntegralTransferOutTag implements Serializable {
private static final long serialVersionUID = 7701288035213438409L;
/**
* 主键ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(notes = "主键ID")
private Integer id;
@ApiModelProperty(notes = "标签名称")
private String name;
@Column(name = "parent_id")
@ApiModelProperty(notes = "父节点ID,一级节点为空")
private Integer parentId;
@ApiModelProperty(notes = "标签层级,仅支持 1/2/3")
private Integer level;
@ApiModelProperty(notes = "节点ID路径,如 ,1,12,35,")
private String path;
@Column(name = "path_name")
@ApiModelProperty(notes = "节点名称路径,如 A/B/C")
private String pathName;
@Column(name = "sort_num")
@ApiModelProperty(notes = "同级排序值,升序")
private Integer sortNum;
@ApiModelProperty(notes = "备注")
private String remark;
@Column(name = "created_date")
@ApiModelProperty(notes = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
@Column(name = "created_by")
@ApiModelProperty(notes = "创建人")
private String createdBy;
@Column(name = "updated_date")
@ApiModelProperty(notes = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updatedDate;
@Column(name = "updated_by")
@ApiModelProperty(notes = "修改人")
private String updatedBy;
@Column(name = "deleted_flag")
@ApiModelProperty(notes = "删除标识:D已删除,N未删除")
private String deletedFlag;
}
......@@ -71,6 +71,11 @@ public interface IntegralTransferOutRemote {
@ApiResponse("结果")
RpcResponse<Boolean> reject(IntegralTransferOutOperationDTO request);
@ApiMethod("批量一键驳回提现记录")
@ApiParam(name = "request", notes = "参数(ids + rejectReason,或 condition + rejectReason)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("批量驳回结果(成功/失败记录明细)")
RpcResponse<IntegralTransferOutBatchResultDTO> batchReject(IntegralTransferOutOperationDTO request);
@ApiMethod("提现导入")
@ApiParams({
@ApiParam(name = "file", notes = "excel的文件字节数组", dataType = ApiParam.DataTypeEnum.ARRAY, required = true),
......
package cn.com.glsx.scrm.shopmall.remote;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.scrm.shopmall.dto.integral.IntegralTransferOutTagBindDTO;
import cn.com.glsx.scrm.shopmall.dto.integral.IntegralTransferOutTagDTO;
import cn.com.glsx.scrm.shopmall.dto.integral.IntegralTransferOutTagQueryDTO;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 积分提现标签远程接口。
*
* 需求 1049744:SCRM 积分提现管理自定义三级标签树。
*/
@ApiService(value = "积分提现标签", owner = "scrm")
public interface IntegralTransferOutTagSummaryRemote {
@ApiMethod("查询积分提现标签树")
@ApiParam(name = "queryDTO", notes = "标签树查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("标签树")
RpcResponse<List<IntegralTransferOutTagDTO>> queryTagTree(@NotNull IntegralTransferOutTagQueryDTO queryDTO);
@ApiMethod("保存积分提现标签")
@ApiParam(name = "tagDTO", notes = "标签信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("保存结果")
RpcResponse<Integer> saveTag(@NotNull IntegralTransferOutTagDTO tagDTO);
@ApiMethod("删除积分提现标签")
@ApiParam(name = "tagDTO", notes = "标签信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("删除结果")
RpcResponse<Boolean> deleteTag(@NotNull IntegralTransferOutTagDTO tagDTO);
@ApiMethod("积分提现记录打标签")
@ApiParam(name = "bindDTO", notes = "打标签参数", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("打标签结果")
RpcResponse<Boolean> bindTag(@NotNull IntegralTransferOutTagBindDTO bindDTO);
}
......@@ -13,7 +13,7 @@
<properties>
<stoassistant.api.version>5.6.4-SNAPSHOT</stoassistant.api.version>
<shopmall.api.version>5.8.4.3-SNAPSHOT</shopmall.api.version>
<shopmall.api.version>5.8.5-SNAPSHOT</shopmall.api.version>
<smartcarlife.api.version>5.6.4-SNAPSHOT</smartcarlife.api.version>
<platform-payment.api.version>5.8.4.3-SNAPSHOT</platform-payment.api.version>
</properties>
......
......@@ -49,4 +49,14 @@ public interface IntegralTransferOutMapper extends OreMapper<IntegralTransferOut
int removeAllFromApproval(@Param("approvalId") Integer approvalId, @Param("updatedBy") String updatedBy);
int updateRealityMerchant(IntegralTransferOut order);
/**
* 批量更新手动标签ID
*
* @param ids 提现记录ID集合
* @param tagId 目标标签ID
* @param updatedBy 操作人
* @return 更新数量
*/
int updateTagBatch(@Param("ids") List<Integer> ids, @Param("tagId") Integer tagId, @Param("updatedBy") String updatedBy);
}
\ No newline at end of file
package cn.com.glsx.scrm.shopmall.mapper;
import cn.com.glsx.scrm.shopmall.dto.integral.IntegralTransferOutTagQueryDTO;
import cn.com.glsx.scrm.shopmall.model.IntegralTransferOutTag;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Date;
import java.util.List;
/**
* 积分提现标签 Mapper。
*
* 需求 1049744:SCRM 积分提现管理自定义三级标签树。
*/
@Mapper
public interface IntegralTransferOutTagMapper extends OreMapper<IntegralTransferOutTag> {
/**
* 按条件查询标签树节点。
*
* @param queryDTO 标签树查询条件
* @return 标签列表
*/
List<IntegralTransferOutTag> queryTagTreeByCondition(@Param("query") IntegralTransferOutTagQueryDTO queryDTO);
/**
* 查询全部有效标签。
*
* @return 标签列表
*/
List<IntegralTransferOutTag> listAllActiveTags();
/**
* 根据ID集合查询标签
*
* @param ids ID集合
* @return 标签列表
*/
List<IntegralTransferOutTag> listByIds(@Param("ids") List<Integer> ids);
/**
* 统计子标签数量。
*
* @param tagId 标签ID
* @return 子标签数量
*/
Integer countChildTag(@Param("tagId") Integer tagId);
/**
* 统计当前节点下的全部子孙标签数量。
*
* @param pathPrefix 路径前缀
* @return 子孙标签数量
*/
Integer countDescendantTag(@Param("pathPrefix") String pathPrefix);
/**
* 查询当前路径下的全部三级标签ID(供已用校验)。
*
* @param pathPrefix 路径前缀
* @return 三级标签ID集合
*/
List<Integer> listLeafTagIdsByPathPrefix(@Param("pathPrefix") String pathPrefix);
/**
* 查询指定路径下的所有子孙节点ID(含当前节点)。
*
* 用于提现记录按标签级联过滤:选中一级标签时需查出其全部二级/三级后代标签ID。
*
* @param pathPrefix 路径前缀(如 ,1,)
* @return 节点ID集合(含自身)
*/
List<Integer> listDescendantIdsByPath(@Param("pathPrefix") String pathPrefix);
/**
* 按完整路径名称统计重名标签数。
*
* @param currentId 当前标签ID
* @param pathName 完整路径名称
* @return 重名数量
*/
Integer countDuplicateByPathName(@Param("currentId") Integer currentId,
@Param("pathName") String pathName);
/**
* 按路径批量刷新子孙节点路径信息。
*
* @param oldPath 原路径
* @param oldPathName 原名称路径
* @param newPath 新路径
* @param newPathName 新名称路径
* @param operator 操作人
* @param now 更新时间
* @return 更新数量
*/
Integer updateDescendantPath(@Param("oldPath") String oldPath,
@Param("oldPathName") String oldPathName,
@Param("newPath") String newPath,
@Param("newPathName") String newPathName,
@Param("operator") String operator,
@Param("now") Date now);
}
......@@ -207,6 +207,21 @@ public class IntegralTransferOutRemoteImpl implements IntegralTransferOutRemote
}
@Override
public RpcResponse<IntegralTransferOutBatchResultDTO> batchReject(IntegralTransferOutOperationDTO request) {
try {
return RpcResponse.success(integralTransferOutService.batchReject(request));
} catch (Exception e) {
log.error("IntegralTransferOutRemote.batchReject exception:{}", e);
if (e instanceof RpcServiceException) {
RpcServiceException rse = (RpcServiceException) e;
return RpcResponse.error(rse);
} else {
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR);
}
}
}
@Override
public RpcResponse<TransferOutImportResponseDTO> transferOutImport(byte[] file, String createdBy) {
try {
return RpcResponse.success(integralTransferOutService.transferOutImport(file, createdBy));
......
package cn.com.glsx.scrm.shopmall.remote;
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.scrm.shopmall.dto.integral.IntegralTransferOutTagBindDTO;
import cn.com.glsx.scrm.shopmall.dto.integral.IntegralTransferOutTagDTO;
import cn.com.glsx.scrm.shopmall.dto.integral.IntegralTransferOutTagQueryDTO;
import cn.com.glsx.scrm.shopmall.service.integral.IntegralTransferOutTagSummaryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* 积分提现标签远程接口实现。
*
* 需求 1049744:SCRM 积分提现管理自定义三级标签树。
*/
@Slf4j
@DubboService(validation = "true")
public class IntegralTransferOutTagSummaryRemoteImpl implements IntegralTransferOutTagSummaryRemote {
@Autowired
private IntegralTransferOutTagSummaryService integralTransferOutTagSummaryService;
@Override
public RpcResponse<List<IntegralTransferOutTagDTO>> queryTagTree(IntegralTransferOutTagQueryDTO queryDTO) {
try {
return RpcResponse.success(integralTransferOutTagSummaryService.queryTagTree(queryDTO));
} catch (Exception e) {
log.error("IntegralTransferOutTagSummaryRemote.queryTagTree exception:{}", e);
if (e instanceof RpcServiceException) {
RpcServiceException rse = (RpcServiceException) e;
return RpcResponse.error(rse);
} else {
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR);
}
}
}
@Override
public RpcResponse<Integer> saveTag(IntegralTransferOutTagDTO tagDTO) {
try {
return RpcResponse.success(integralTransferOutTagSummaryService.saveTag(tagDTO));
} catch (Exception e) {
log.error("IntegralTransferOutTagSummaryRemote.saveTag exception:{}", e);
if (e instanceof RpcServiceException) {
RpcServiceException rse = (RpcServiceException) e;
return RpcResponse.error(rse);
} else {
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR);
}
}
}
@Override
public RpcResponse<Boolean> deleteTag(IntegralTransferOutTagDTO tagDTO) {
try {
return RpcResponse.success(integralTransferOutTagSummaryService.deleteTag(tagDTO));
} catch (Exception e) {
log.error("IntegralTransferOutTagSummaryRemote.deleteTag exception:{}", e);
if (e instanceof RpcServiceException) {
RpcServiceException rse = (RpcServiceException) e;
return RpcResponse.error(rse);
} else {
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR);
}
}
}
@Override
public RpcResponse<Boolean> bindTag(IntegralTransferOutTagBindDTO bindDTO) {
try {
return RpcResponse.success(integralTransferOutTagSummaryService.bindTag(bindDTO));
} catch (Exception e) {
log.error("IntegralTransferOutTagSummaryRemote.bindTag exception:{}", e);
if (e instanceof RpcServiceException) {
RpcServiceException rse = (RpcServiceException) e;
return RpcResponse.error(rse);
} else {
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR);
}
}
}
}
......@@ -336,11 +336,22 @@ public class StaffMotivationService {
if (Objects.nonNull(item.getRefundType()) && item.getRefundType().equals(OrderRefundEnum.PART_REFUND.getValue())) {
return handleRefundPart(item);
}
// 扣减类型的积分审批的 integralIncome 改为负数存储
convertSubtractScoreIntegralIncome(item);
thiz.handleMotivationItem(item);
log.info("subtractScore 修改阳光积分发放成功");
return true;
}
/**
* 扣减类型的积分审批的 integralIncome 改为负数存储
*/
private void convertSubtractScoreIntegralIncome(ShopmallStaffMotivationDTO item) {
if (item.getIntegralIncome() != null) {
item.setIntegralIncome(item.getIntegralIncome().abs().multiply(new BigDecimal(-1)));
}
}
public boolean handleRefundPart(ShopmallStaffMotivationDTO item) {
// 退款类型校验
if (Objects.isNull(item.getRefundType()) || !item.getRefundType().equals(OrderRefundEnum.PART_REFUND.getValue())) {
......@@ -353,19 +364,20 @@ public class StaffMotivationService {
.findFirst().orElseThrow(() -> new RpcServiceException(DefaultErrorEnum.DATA_NOT_EXIST, "此订单无收益记录,无法进行退款"));
// 检验已审核积分审批记录的剩余积分,和抵扣值对比
BigDecimal currentScore = completeItem.getIntegralIncome();
if (currentScore.compareTo(item.getIntegralIncome()) < 0) {
log.error("部分退款抵扣失败, 抵扣值: {}, 已审核积分审批记录剩余值: {}", item.getIntegralIncome(), currentScore);
BigDecimal refundScore = item.getIntegralIncome();
if (currentScore.compareTo(refundScore) < 0) {
log.error("部分退款抵扣失败, 抵扣值: {}, 已审核积分审批记录剩余值: {}", refundScore, currentScore);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "部分退款抵扣失败");
}
// 原积分审批记录值修改
completeItem.setUpdatedTime(item.getUpdatedTime());
// 扣减后的剩余积分
BigDecimal remainScore = currentScore.subtract(item.getIntegralIncome());
BigDecimal remainScore = currentScore.subtract(refundScore);
// 拷贝生成新的退款抵扣记录
ShopmallStaffMotivationDTO newRefundItem = new ShopmallStaffMotivationDTO();
BeanUtils.copyProperties(completeItem, newRefundItem);
completeItem.setIntegralIncome(remainScore);
log.info("handleRefundPart, currentScore: {}, refundScore: {}", currentScore, item.getIntegralIncome());
log.info("handleRefundPart, currentScore: {}, refundScore: {}", currentScore, refundScore);
// 若剩余积分为0,则删除原审批记录
if (remainScore.compareTo(BigDecimal.ZERO) == 0) {
completeItem.setFailRemark("部分退款至0");
......@@ -374,7 +386,7 @@ public class StaffMotivationService {
staffMotivationMapper.updateByPrimaryKeySelective(completeItem);
// 新增退款抵扣记录
newRefundItem.setStatus(item.getStatus());
newRefundItem.setIntegralIncome(item.getIntegralIncome());
newRefundItem.setIntegralIncome(refundScore);
newRefundItem.setOrderMoney(item.getOrderMoney());
newRefundItem.setSupervisorStatus(item.getSupervisorStatus());
newRefundItem.setFailType(item.getFailType());
......@@ -385,6 +397,7 @@ public class StaffMotivationService {
newRefundItem.setRefundSubOrderCode(item.getRefundSubOrderCode());
newRefundItem.setUpdatedTime((Objects.isNull(item.getUpdatedTime()) ? new Date() : item.getUpdatedTime()));
newRefundItem.setDeletedFlag(Objects.isNull(item.getDeletedFlag()) ? newRefundItem.getDeletedFlag() : item.getDeletedFlag());
convertSubtractScoreIntegralIncome(newRefundItem);
staffMotivationMapper.insertUseGeneratedKeys(newRefundItem);
// 新增退款抵扣操作记录
this.addOperationItem(newRefundItem, item);
......
......@@ -47,6 +47,11 @@
<result column="id_card_front" jdbcType="VARCHAR" property="idCardFront" />
<result column="id_card_back" jdbcType="VARCHAR" property="idCardBack" />
<result column="disclaimer_agreement_url" jdbcType="VARCHAR" property="disclaimerAgreementUrl" />
<result column="transfer_out_tag_id" jdbcType="INTEGER" property="transferOutTagId" />
<result column="main_brand_id" jdbcType="VARCHAR" property="mainBrandId" />
<result column="main_brand_name" jdbcType="VARCHAR" property="mainBrandName" />
<result column="province_code" jdbcType="VARCHAR" property="provinceCode" />
<result column="province_name" jdbcType="VARCHAR" property="provinceName" />
</resultMap>
<sql id="Base_Column_List">
<!--
......@@ -58,7 +63,8 @@
channel, payment_entity_code, payment_entity_name, pay_date, receipt_date, error_message, batch_no, created_by, created_date,
updated_by, updated_date, deleted_flag, mode, source, appid, approval_id,
id_card_front, id_card_back, disclaimer_agreement_url,levy_code,levy_name,levy_channel_code,levy_channel_name,
reality_platform_merchant_id,reality_platform_merchant_name
reality_platform_merchant_id,reality_platform_merchant_name,
transfer_out_tag_id, main_brand_id, main_brand_name, province_code, province_name
</sql>
<resultMap extends="BaseResultMap" id="DTOResultMap" type="cn.com.glsx.scrm.shopmall.dto.integral.IntegralTransferOutDTO">
......@@ -76,78 +82,126 @@
<select id="list" resultMap="DTOResultMap">
select
<include refid="Base_Column_List" />
from shopmall_integral_transfer_out
<include refid="Base_Column_List" />,
tag.path_name as manualTagPath
from shopmall_integral_transfer_out ito
left join integral_transfer_out_tag tag on tag.id = ito.transfer_out_tag_id and tag.deleted_flag = 'N'
<where>
deleted_flag = 'N'
ito.deleted_flag = 'N'
<if test="merchantId != null">
and merchant_id = #{merchantId}
and ito.merchant_id = #{merchantId}
</if>
<if test="merchantName != null and merchantName != ''">
and merchant_name = #{merchantName}
and ito.merchant_name = #{merchantName}
</if>
<if test="channel != null and channel != ''">
and channel = #{channel}
and ito.channel = #{channel}
</if>
<if test="outSettleOrderId != null and outSettleOrderId != ''">
and out_settle_order_id like CONCAT('%',#{outSettleOrderId},'%')
and ito.out_settle_order_id like CONCAT('%',#{outSettleOrderId},'%')
</if>
<if test="customerName != null and customerName != ''">
and customer_name like CONCAT('%',#{customerName},'%')
and ito.customer_name like CONCAT('%',#{customerName},'%')
</if>
<if test="customerPhone != null and customerPhone != ''">
and customer_phone like CONCAT('%',#{customerPhone},'%')
and ito.customer_phone like CONCAT('%',#{customerPhone},'%')
</if>
<if test="name != null and name != ''">
and name like CONCAT('%',#{name},'%')
and ito.name like CONCAT('%',#{name},'%')
</if>
<if test="status != null and status != ''">
and status = #{status}
and ito.status = #{status}
</if>
<if test="applyDateStart != null and applyDateStart != ''">
and created_date &gt;= #{applyDateStart}
and ito.created_date &gt;= #{applyDateStart}
</if>
<if test="applyDateEnd != null and applyDateEnd != ''">
and created_date &lt;= #{applyDateEnd}
and ito.created_date &lt;= #{applyDateEnd}
</if>
<if test="payDateStart != null and payDateStart != ''">
and pay_date &gt;= #{payDateStart}
and ito.pay_date &gt;= #{payDateStart}
</if>
<if test="payDateEnd != null and payDateEnd != ''">
and pay_date &lt;= #{payDateEnd}
and ito.pay_date &lt;= #{payDateEnd}
</if>
<if test="receiptDateStart != null and receiptDateStart != ''">
and receipt_date &gt;= #{receiptDateStart}
and ito.receipt_date &gt;= #{receiptDateStart}
</if>
<if test="receiptDateEnd != null and receiptDateEnd != ''">
and receipt_date &lt;= #{receiptDateEnd}
and ito.receipt_date &lt;= #{receiptDateEnd}
</if>
<if test="transferType != null">
and transfer_type = #{transferType}
and ito.transfer_type = #{transferType}
</if>
<if test="mode != null">
and mode = #{mode}
and ito.mode = #{mode}
</if>
<if test="withdrawalSource != null">
and source = #{withdrawalSource}
and ito.source = #{withdrawalSource}
</if>
<if test="paymentEntityCode != null and paymentEntityCode != ''">
and payment_entity_code = #{paymentEntityCode}
and ito.payment_entity_code = #{paymentEntityCode}
</if>
<if test="levyCode != null and levyCode != ''">
and levy_code = #{levyCode}
and ito.levy_code = #{levyCode}
</if>
<if test="levyChannelCode != null and levyChannelCode != ''">
and levy_channel_code = #{levyChannelCode}
and ito.levy_channel_code = #{levyChannelCode}
</if>
<if test="approvalId != null">
and approval_id = #{approvalId}
and ito.approval_id = #{approvalId}
</if>
<if test="realityMerchantName != null and realityMerchantName != ''">
and reality_platform_merchant_name like CONCAT('%',#{realityMerchantName},'%')
</if>
and ito.reality_platform_merchant_name like CONCAT('%',#{realityMerchantName},'%')
</if>
<if test="mainBrandIds != null and mainBrandIds.size() > 0">
and
<foreach collection="mainBrandIds" item="brandId" open="(" close=")" separator=" or ">
FIND_IN_SET(#{brandId}, ito.main_brand_id)
</foreach>
</if>
<if test="provinceCodes != null and provinceCodes.size() > 0">
and ito.province_code in
<foreach collection="provinceCodes" item="code" open="(" close=")" separator=",">
#{code}
</foreach>
</if>
<if test="merchantIds != null and merchantIds.size() > 0">
and ito.merchant_id in
<foreach collection="merchantIds" item="merchantIdItem" open="(" close=")" separator=",">
#{merchantIdItem}
</foreach>
</if>
<if test="transferOutTagIds != null and transferOutTagIds.size() > 0">
and ito.transfer_out_tag_id in
<foreach collection="transferOutTagIds" item="tagId" open="(" close=")" separator=",">
#{tagId}
</foreach>
</if>
<choose>
<when test="limitStoreFlagQuery != null and limitStoreFlagQuery == 'Y'.toString()">
<if test="limitStoreMerchantNos != null and limitStoreMerchantNos.size() > 0">
and ito.merchant_id in
<foreach collection="limitStoreMerchantNos" item="merchantNo" open="(" close=")" separator=",">
#{merchantNo}
</foreach>
</if>
<if test="limitStoreMerchantNos == null or limitStoreMerchantNos.size() == 0">
and 1=0
</if>
</when>
<when test="limitStoreFlagQuery != null and limitStoreFlagQuery == 'N'.toString()">
<if test="limitStoreMerchantNos != null and limitStoreMerchantNos.size() > 0">
and (ito.merchant_id not in
<foreach collection="limitStoreMerchantNos" item="merchantNo" open="(" close=")" separator=",">
#{merchantNo}
</foreach>
or ito.merchant_id is null)
</if>
</when>
</choose>
</where>
order by id desc
order by ito.id desc
</select>
<select id="getDetailById" resultMap="DetailResultMap">
......@@ -297,4 +351,14 @@
</if>
</where>
</select>
<update id="updateTagBatch">
update shopmall_integral_transfer_out
set transfer_out_tag_id = #{tagId}, updated_by = #{updatedBy}, updated_date = now()
where deleted_flag = 'N'
and id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.scrm.shopmall.mapper.IntegralTransferOutTagMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.scrm.shopmall.model.IntegralTransferOutTag">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="parent_id" jdbcType="INTEGER" property="parentId" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="path" jdbcType="VARCHAR" property="path" />
<result column="path_name" jdbcType="VARCHAR" property="pathName" />
<result column="sort_num" jdbcType="INTEGER" property="sortNum" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="deleted_flag" jdbcType="CHAR" property="deletedFlag" />
</resultMap>
<sql id="Base_Column_List">
id, name, parent_id, level, path, path_name, sort_num, remark,
created_date, created_by, updated_date, updated_by, deleted_flag
</sql>
<select id="queryTagTreeByCondition" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from integral_transfer_out_tag
<where>
deleted_flag = 'N'
<if test="query != null and query.id != null">
and id = #{query.id}
</if>
<if test="query != null and query.parentId != null">
and parent_id = #{query.parentId}
</if>
<if test="query != null and query.level != null">
and level = #{query.level}
</if>
<if test="query != null and query.nameLike != null and query.nameLike != ''">
and name like concat('%', #{query.nameLike}, '%')
</if>
<if test="query != null and query.path != null and query.path != ''">
and path like concat(#{query.path}, '%')
</if>
<if test="query != null and query.onlyComplete != null and query.onlyComplete">
and level &gt;= 2
</if>
</where>
order by level asc, sort_num asc, id asc
</select>
<select id="listAllActiveTags" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from integral_transfer_out_tag
where deleted_flag = 'N'
order by level asc, sort_num asc, id asc
</select>
<select id="listByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from integral_transfer_out_tag
where deleted_flag = 'N'
<if test="ids != null and ids.size() > 0">
and id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
order by level asc, sort_num asc, id asc
</select>
<select id="countChildTag" resultType="java.lang.Integer">
select count(1)
from integral_transfer_out_tag
where deleted_flag = 'N'
and parent_id = #{tagId}
</select>
<select id="countDescendantTag" resultType="java.lang.Integer">
select count(1)
from integral_transfer_out_tag
where deleted_flag = 'N'
and path like concat(#{pathPrefix}, '%')
and path != #{pathPrefix}
</select>
<select id="listLeafTagIdsByPathPrefix" resultType="java.lang.Integer">
select id
from integral_transfer_out_tag
where deleted_flag = 'N'
and path like concat(#{pathPrefix}, '%')
order by level asc, sort_num asc, id asc
</select>
<select id="listDescendantIdsByPath" resultType="java.lang.Integer">
select id
from integral_transfer_out_tag
where deleted_flag = 'N'
and path like concat(#{pathPrefix}, '%')
order by level asc, sort_num asc, id asc
</select>
<select id="countDuplicateByPathName" resultType="java.lang.Integer">
select count(1)
from integral_transfer_out_tag
where deleted_flag = 'N'
and path_name = #{pathName}
<if test="currentId != null">
and id != #{currentId}
</if>
</select>
<update id="updateDescendantPath">
update integral_transfer_out_tag
set path = concat(#{newPath}, substring(path, char_length(#{oldPath}) + 1)),
path_name = concat(#{newPathName}, substring(path_name, char_length(#{oldPathName}) + 1)),
updated_by = #{operator},
updated_date = #{now}
where deleted_flag = 'N'
and path like concat(#{oldPath}, '%')
</update>
</mapper>
  • @wangxw1
    commented
    Owner

    一、关键问题与优化建议,如果必要,给出代码示例(仅限 Top 3)

    1. 违反核心规范:Dubbo Remote 接口已有请求参数变更(高风险)

    • 问题描述:在 IntegralTransferOutOperationDTO 中新增了 rejectReason 和 condition 字段。由于该 DTO 已经被现有的 Dubbo 服务(如 IntegralTransferOutRemote.reject 等)作为请求参数使用,这种修改违反了“dubbo服务提供者Remote接口中的已有请求参数变更视为危险实现”的重要规则。
    • 影响分析:在分布式微服务架构中,直接修改已被广泛使用的已有 DTO 会导致新老版本的 Provider 和 Consumer 之间出现序列化不一致或兼容性问题,极易引发线上调用异常(如反序列化失败、字段丢失等)。
    • 优化建议:对于新增加的 batchReject 接口,应为其单独创建一个专用的请求 DTO(例如 IntegralTransferOutBatchRejectDTO),而不是去污染并修改已有的公共操作 DTO。 java // 建议新增专门的 DTO @Data public class IntegralTransferOutBatchRejectDTO implements Serializable { private List<Integer> ids; private String rejectReason; private IntegralTransferOutDTO condition; // ...其他必要字段 }

    2. 内存溢出(OOM)风险:全量加载数据提取 ID(高风险)

    • 问题描述:在 IntegralTransferOutService.listTransferOutIdsByCondition 方法中,为了获取符合条件的记录 ID 集合,直接调用了 integralTransferOutMapper.list(condition) 将所有匹配的完整对象(IntegralTransferOutDTO)加载到内存中,然后再通过 Stream API 提取 ID。
    • 影响分析:如果 condition 匹配到的记录数非常庞大(如数万、数十万条),将全量的大对象加载到内存中会极大地消耗 JVM 堆内存,导致频繁的 Full GC,甚至直接引发 OOM(OutOfMemoryError)导致服务崩溃。
    • 优化建议:在 Mapper 层面新增一个专门用于查询 ID 列表的 SQL 接口,仅从数据库中 SELECT id,避免拉取不必要的大字段和关联数据。 java // IntegralTransferOutService.java 优化 public List<Integer> listTransferOutIdsByCondition(IntegralTransferOutDTO condition) { // ... 前置条件处理 // 替换为专门只查询 ID 的 Mapper 方法 return integralTransferOutMapper.listIdsByCondition(condition); }

    3. 性能损耗:高频次动态解析环境变量与字符串(低效实现)

    • 问题描述:IntegralTransferOutService.listLimitStoreMerchantNos() 方法在每次执行列表查询(listWithPage)和条件查询时,都会调用 env.getProperty 读取配置,并执行字符串的 split、trim、filter、distinct 等一系列操作。
    • 影响分析:分页查询通常是高频接口。每次请求都去动态读取环境变量并进行复杂的字符串解析,会产生大量短生命周期的对象,增加 CPU 消耗和 GC 压力,属于典型的资源浪费。
    • 优化建议:建议将该配置通过 @Value 注入,并在配置初始化或变更时解析为 List<String> 缓存起来,直接使用解析好的集合。如果使用的是 Apollo/Nacos 等配置中心,可以配合 @RefreshScope 或监听器更新缓存。 ```java // 建议在 Service 中缓存解析结果 @Value("${scrm.integral.limit.store.merchantNos:}") private String limitStoreMerchantNosStr;

    private volatile List cachedLimitStoreMerchantNos = Collections.emptyList();

    @PostConstruct public void initLimitStoreMerchantNos() { if (StringUtils.isNotBlank(limitStoreMerchantNosStr)) { cachedLimitStoreMerchantNos = Arrays.stream(limitStoreMerchantNosStr.split(",")) .map(String::trim) .filter(StringUtils::isNotBlank) .distinct() .collect(Collectors.toList()); } } // 后续直接返回 cachedLimitStoreMerchantNos

    
    ---
    
    #### 二、评分明细
    
    - **功能实现的正确性与健壮性(32/40分)**:
      扣分原因:`listTransferOutIdsByCondition` 方法在处理大批量数据时存在明显的内存隐患(未分页全量拉取);标签不存在时赋哨兵值 `-1` 的逻辑虽然可用,但强耦合了魔法值,健壮性稍弱。未发现违反“Mybatis 不允许使用子查询”规则的明显证据。
    
    - **安全性与潜在风险(15/30分)**:
      扣分原因:严重违反了“Dubbo 服务提供者 Remote 接口中的已有请求参数变更视为危险实现”的重要规则。直接修改已有的 `IntegralTransferOutOperationDTO` 给线上微服务调用带来了极高的兼容性风险。
    
    - **最佳实践与可维护性(16/20分)**:
      扣分原因:将批量操作(模式A/模式B)的参数和单体操作参数混在一个 DTO 中,导致类的职责不单一;`IntegralTransferOutService` 类过于臃肿,部分商户相关逻辑(如 `parseMerchantId`)建议内聚到专门的工具类或商户域服务中。
    
    - **性能与资源利用(2/5分)**:
      扣分原因:高频查询接口中存在每次动态读取环境变量并拆分字符串的低效操作,且全量拉取对象只为获取 ID,造成了不必要的 CPU 和内存资源浪费。
    
    - **提交信息质量(5/5分)**:
      得分原因:Commit 信息非常清晰,采用了规范的 `feat:` 前缀,且采用多行列表详细描述了具体的变更点(远程接口、批量驳回、标签级联等),可追溯性极强。
    
    总分:70分
    
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!