Commit 437f0a5a by 杨卫

feat:新增根据商户id查询商户名称

1 parent 4b48dc4c
package cn.com.glsx.merchants.model.response;
import lombok.Data;
import java.io.Serializable;
/**
* @author yangwei
* @version 1.0
* @since 2026/01/19 16:00
*/
@Data
public class MerchantNameDTO implements Serializable {
/**
* 商户号
*/
private Integer merchantId;
/**
* 商户名称
*/
private String merchantName;
}
......@@ -554,4 +554,9 @@ public interface MerchantRemote {
RpcResponse<List<MerchantProvinceDTO>> findMerchantListByBrandIdsProvince(CarBrandProvinceRequestDTO requestDTO);
RpcResponse<List<MerchantProvinceDTO>> findMerchantProvinceListByIds(List<Integer> merchantIds);
@ApiMethod("查询商户名称")
@ApiParams({@ApiParam(name = "merchantId", notes = "查询商户名称", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("查询商户名称")
RpcResponse<List<MerchantNameDTO>> getMerchantNameByMerchantIds(List<Integer> merchantIds);
}
......@@ -948,4 +948,24 @@ public class MerchantRemoteImpl implements MerchantRemote {
return RpcResponse.error(e);
}
}
/**
* 查询商户名称
* @author yangwei
* @since 2026/1/23 16:49
* @param merchantIds 商户id
* @return cn.com.glsx.framework.core.beans.rpc.RpcResponse<java.util.List<cn.com.glsx.merchants.model.response.MerchantNameDTO>>
*/
@Override
public RpcResponse<List<MerchantNameDTO>> getMerchantNameByMerchantIds(List<Integer> merchantIds) {
try {
return RpcResponse.success(merchantService.getMerchantNameByMerchantIds(merchantIds));
} catch (RpcServiceException e) {
log.error("查询商户名称失败", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("查询商户名称失败:", e);
return RpcResponse.error(e);
}
}
}
......@@ -61,6 +61,7 @@ import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import tk.mybatis.mapper.entity.Example;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
......@@ -2797,4 +2798,20 @@ public class MerchantService {
public List<cn.com.glsx.merchants.model.response.MerchantBrandDTO> getBrandByMerchantIds(List<Integer> merchantId) {
return merchantMapper.getBrandByMerchantIds(merchantId);
}
public List<MerchantNameDTO> getMerchantNameByMerchantIds(List<Integer> merchantIds) {
Example example = new Example(Merchant.class);
example.createCriteria()
.andIn("merchantNo", merchantIds);
return Optional.ofNullable(merchantMapper.selectByExample(example))
.orElseGet(ArrayList::new)
.stream()
.map(element -> {
MerchantNameDTO merchantNameDTO = new MerchantNameDTO();
merchantNameDTO.setMerchantId(element.getMerchantNo());
merchantNameDTO.setMerchantName(element.getMerchantName());
return merchantNameDTO;
}).collect(Collectors.toList());
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!