Commit ddeefbc7 by 杨卫

feat(smartcarlife): 添加园区店主服务商更新功能

- 新增 YqMerchantConfigUpdatePartnerMerchantRequest 请求类
- 新增 YqMerchantConfigUpdatePartnerMerchantReqDTO 数据传输对象
- 在 YqMerchantConfigController 中添加 updatePartnerMerchant 接口
- 在 YqMerchantConfigRemote 和 YqMerchantConfigRemoteImpl 中添加远程调用支持
- 在 YqMerchantConfigService 中实现更新逻辑,增加场景代码验证
- 在 SceneMerchantRefNewMapper 中新增按场景查询园区店的方法
- 更新接口文档注释和错误处理机制
- 修改 pom.xml 版本号从 5.8.6 到 5.8.7
1 parent c40881a2
......@@ -14,7 +14,7 @@
<properties>
<shopmall.api.version>5.6.4-SNAPSHOT</shopmall.api.version>
<stoassistant.api.version>5.6.4-SNAPSHOT</stoassistant.api.version>
<smartcarlife.api.version>5.8.6-SNAPSHOT</smartcarlife.api.version>
<smartcarlife.api.version>5.8.7-SNAPSHOT</smartcarlife.api.version>
<sale.api.version>5.8.2-SNAPSHOT</sale.api.version>
<mindworkplate.api.version>5.8.5-SNAPSHOT</mindworkplate.api.version>
<strategy.api.version>5.8.5-SNAPSHOT</strategy.api.version>
......
package cn.com.glsx.dj.smartcarlife.controller.smartCarLife;
import cn.com.glsx.dj.smartcarlife.convert.YqMerchantConfigDTOConvert;
import cn.com.glsx.dj.smartcarlife.convert.YqPartnerMerchantRefPageResponseConvert;
import cn.com.glsx.dj.smartcarlife.dto.*;
import cn.com.glsx.dj.smartcarlife.dto.construction.ConstructionServiceItmesDTO;
import cn.com.glsx.dj.smartcarlife.remote.YqMerchantConfigRemote;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.*;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.serviceMerchant.ServiceMerchantRelateQrcodeRequest;
import cn.com.glsx.dj.smartcarlife.response.smartcarlife.YqMerchantConfigDetailResponse;
import cn.com.glsx.dj.smartcarlife.response.smartcarlife.YqMerchantConfigPageResponse;
import cn.com.glsx.dj.smartcarlife.response.smartcarlife.YqMerchantConfigUpdateResponse;
import cn.com.glsx.dj.smartcarlife.util.CommonUtil;
import cn.com.glsx.dj.smartcarlife.util.QRCodeUtils;
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.rop.response.RopResponse;
import cn.com.glsx.merchants.model.request.MerchantRequest;
import cn.com.glsx.merchants.model.request.MerchantStaffRequest;
import cn.com.glsx.merchants.model.response.MerchantResponse;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import cn.com.glsx.scrm.equity.enums.DeleteFlagEnum;
import cn.com.glsx.scrm.proxy.dto.merchant.ListMerchantRequest;
......@@ -35,7 +32,6 @@ import org.springframework.core.env.Environment;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
......@@ -96,19 +92,27 @@ public class YqMerchantConfigController {
return RopResponse.success(YqMerchantConfigDTOConvert.INSTANCE.toYqMerchantConfigUpdateResponse(res.getResult()));
}
@ApiOperation("获取园区店配置项")
@ServiceMethod(method = "dj.api.smarcarlife.yqMerchantConfig.detail", needInSession = NeedInSessionType.YES)
public RopResponse<YqMerchantConfigDetailResponse> detail(YqMerchantConfigGetRequest request){
RpcResponse<YqMerchantConfigDTO> res = yqMerchantConfigRemote.getByMerchantId(request.getYqMerchantId());
if(!res.hasResult()){
return RopResponse.error("未关联4S店,请确认后重新操作");
@ApiOperation("更新园区店主服务商")
@ServiceMethod(method = "dj.api.smarcarlife.yqMerchantConfig.updatePartnerMerchant", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> updatePartnerMerchant(YqMerchantConfigUpdatePartnerMerchantRequest request) {
try {
YqMerchantConfigUpdatePartnerMerchantReqDTO requestDTO =
YqMerchantConfigDTOConvert.INSTANCE
.fromYqMerchantConfigUpdatePartnerMerchantRequest(request);
requestDTO.setUpdatedBy(CommonUtil.getAccountName());
RpcResponse<Boolean> response = yqMerchantConfigRemote.updatePartnerMerchant(requestDTO);
return CommonUtil.convertRopResponse(response);
} catch (RpcServiceException e) {
log.info("dj.api.smarcarlife.yqMerchantConfig.updatePartnerMerchant occur RpcServiceException error!", e);
return RopResponse.error(e);
} catch (Exception e) {
log.info("dj.api.smarcarlife.yqMerchantConfig.updatePartnerMerchant occur error!", e);
return RopResponse.result(DefaultErrorEnum.SERVICE_ERROR);
}
return RopResponse.success(YqMerchantConfigDTOConvert.INSTANCE.toYqMerchantConfigDetailResponse(res.getResult()));
}
@ApiOperation("获服务商列表")
@ApiOperation("获取服务商列表")
@ServiceMethod(method = "dj.api.smarcarlife.yqMerchantConfig.partnerMerchantDetail", needInSession = NeedInSessionType.NO)
public RopResponse<List<YqPartnerMerchantRefDTO>> partnerMerchantDetail(YqMerchantConfigGetRequest request){
RpcResponse<List<YqPartnerMerchantRefDTO>> res = yqMerchantConfigRemote.getPartnerMerchantDetail(request.getYqMerchantId());
......
package cn.com.glsx.dj.smartcarlife.convert;
import cn.com.glsx.dj.smartcarlife.dto.YqMerchantConfigDTO;
import cn.com.glsx.dj.smartcarlife.dto.YqMerchantConfigUpdatePartnerMerchantReqDTO;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.YqMerchantConfigSearchRequest;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.YqMerchantConfigUpdatePartnerMerchantRequest;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.YqMerchantConfigUpdateRequest;
import cn.com.glsx.dj.smartcarlife.request.smartcarlife.serviceMerchant.ServiceMerchantRelateQrcodeRequest;
import cn.com.glsx.dj.smartcarlife.response.smartcarlife.YqMerchantConfigDetailResponse;
......@@ -24,6 +26,15 @@ public interface YqMerchantConfigDTOConvert {
})
YqMerchantConfigDTO fromYqMerchantConfigUpdateRequest(YqMerchantConfigUpdateRequest sourceEntity);
/**
* 转换更新主服务商请求
*
* @param sourceEntity ROP请求
* @return 更新主服务商请求DTO
*/
YqMerchantConfigUpdatePartnerMerchantReqDTO fromYqMerchantConfigUpdatePartnerMerchantRequest(
YqMerchantConfigUpdatePartnerMerchantRequest sourceEntity);
@Mappings({
@Mapping(source = "merchantId",target = "yqMerchantId"),
@Mapping(target = "supportPayTypes", expression = "java(cn.com.glsx.dj.smartcarlife.convert.helper.YqMerchantConfigDTOConvertHelper.getSupportPayTypes(sourceEntity.getSupportPayType()))")
......
package cn.com.glsx.dj.smartcarlife.request.smartcarlife;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 更新园区店主服务商请求
*
* @author yangwei_by_claude
* @version 1.0
* @since 2026/10/08 16:00
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class YqMerchantConfigUpdatePartnerMerchantRequest extends AbstractRopRequest {
/**
* 4S店商户号
*/
@ApiModelProperty(value = "4S店商户号", required = true)
private Integer merchantId;
/**
* 主服务商商户id
*/
@ApiModelProperty(value = "主服务商商户id", required = true)
private Integer partnerMerchantId;
/**
* 主服务商商户名称
*/
@ApiModelProperty(value = "主服务商商户名称", required = true)
private String partnerMerchantName;
/**
* 场景代码
*/
@ApiModelProperty(value = "场景代码", required = true)
private String baseSceneCode;
}
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(仅限 Top 3)

    1. 异常日志级别错误(可维护性与规范 - 违反阿里巴巴Java开发手册)

    • 位置:YqMerchantConfigController.java 中的 updatePartnerMerchant 方法。
    • 问题:捕获到 RpcServiceException 和 Exception 时,使用了 log.info(...) 来记录异常堆栈。根据《阿里巴巴Java开发手册》异常处理规范,记录异常信息必须使用 log.error 级别。使用 info 级别会导致生产环境排查错误极其困难,且会污染正常业务日志。
    • 建议:将 log.info("... occur error!", e); 修改为 log.error("... occur error!", e);。

    2. 缺失请求参数校验(健壮性与安全性)

    • 位置:YqMerchantConfigUpdatePartnerMerchantRequest.java。
    • 问题:新增的请求类中,虽然使用了 @ApiModelProperty(required = true),但这仅用于 Swagger 接口文档展示,并不能在运行时拦截非法参数。如果前端传入 null 或空字符串,会导致下游服务出现 NPE 或脏数据。
    • 建议:引入 JSR-303 (Hibernate Validator) 校验注解。例如为 merchantId 和 partnerMerchantId 添加 @NotNull(message = "商户号不能为空"),为 partnerMerchantName 和 baseSceneCode 添加 @NotBlank(message = "XXX不能为空"),并在 Controller 层配合 @Valid 或框架自带的校验机制使用。

    3. 未经声明的 API 接口删除(功能正确性与潜在风险)

    • 位置:YqMerchantConfigController.java。
    • 问题:代码比对显示,原有的 detail 接口(dj.api.smarcarlife.yqMerchantConfig.detail)被直接删除了。且提交信息(commit message)中仅提到了“添加园区店主服务商更新功能”,并未提及删除接口。
    • 建议:确认该接口是否确实废弃。如果废弃,按照平滑发布规范,应先标记 @Deprecated,通知前端/客户端替换接口,等待一个版本后再物理删除;如果是误删,请立即恢复该代码,避免引发线上客户端请求 404 的重大故障。

    二、评分明细

    评审维度 权重 得分 扣分说明
    1. 功能正确性与健壮性 40分 30分 核心逻辑实现正常,但未经说明直接删除了原有 detail 接口,存在极大的线上兼容性风险(-10分)。
    2. 安全性与潜在风险 30分 25分 缺少服务端运行时参数校验(如 @NotNull/@NotBlank),仅依赖 Swagger 注解存在防御穿透风险(-5分)。
    3. 最佳实践与可维护性 20分 15分 违反阿里巴巴Java开发规范,在 catch 块中使用 log.info 打印异常堆栈(-5分)。
    4. 性能与资源利用 5分 5分 未发现明显的性能瓶颈,对象转换使用了高效的 MapStruct。
    5. 提交信息质量 5分 4分 提交信息较详细,涵盖了新增功能点,但遗漏了说明重要代码的删除操作(-1分)。

    总分:79分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!