Commit 7973697a by 章家宝

工资绩效:账户中心查询4s店下面的品牌

1 parent 8233f1fb
package cn.com.glsx.merchants.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class MerchantBrandModelDTO implements java.io.Serializable{
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "主品牌id")
private Integer brandId;
@ApiModelProperty(notes = "子品牌id")
private Integer childId;
}
package cn.com.glsx.merchants.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.util.List;
import java.util.Set;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class MerchantPageWithBrandDTO implements java.io.Serializable{
private static final long serialVersionUID = 1L;
private Set<Integer> brandIdList;
private List<Integer> merchantIds;
@ApiModelProperty(notes = "门店ID")
private Integer merchantId;
@ApiModelProperty(notes = "门店名称")
private String merchantName;
@ApiModelProperty(name = "merchantBrandList", notes = "品牌列表")
private List<MerchantBrandModelDTO> merchantBrandList;
}
......@@ -3,20 +3,17 @@ package cn.com.glsx.merchants.remote;
import cn.com.glsx.framework.core.annotation.*;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.merchants.dto.merchant.CarBrandProvinceRequestDTO;
import cn.com.glsx.merchants.dto.merchant.CarBrandRequestDTO;
import cn.com.glsx.merchants.dto.merchant.CarbrandResponse;
import cn.com.glsx.merchants.dto.merchant.StaffPhoneRequestDTO;
import cn.com.glsx.merchants.dto.MerchantPageWithBrandDTO;
import cn.com.glsx.merchants.dto.merchant.*;
import cn.com.glsx.merchants.model.request.*;
import cn.com.glsx.merchants.model.request.merchant.*;
import cn.com.glsx.merchants.model.request.serviceCenter.*;
import cn.com.glsx.merchants.model.response.*;
import cn.com.glsx.merchants.model.response.merchant.MerchantBasicInfoListResponse;
import cn.com.glsx.merchants.model.response.merchant.MerchantBrandAndProvinceResponse;
import cn.com.glsx.merchants.model.response.merchant.MerchantNameResponse;
import cn.com.glsx.merchants.model.response.merchant.*;
import cn.com.glsx.merchants.model.response.serviceCenter.MerchantDetailResponse;
import cn.com.glsx.merchants.model.response.serviceCenter.SearchMerchantRpcResponse;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
......@@ -549,4 +546,10 @@ public interface MerchantRemote {
RpcResponse<List<MerchantProvinceDTO>> findMerchantListByBrandIdsProvince(CarBrandProvinceRequestDTO requestDTO);
RpcResponse<List<MerchantProvinceDTO>> findMerchantProvinceListByIds(List<Integer> merchantIds);
@ApiMethod("分页查询dj门店/品牌/子品牌列表")
@ApiParam(name = "pagination", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("门店/品牌/子品牌列表")
RpcResponse<RpcPagination<MerchantPageWithBrandDTO>> pageListMerchantWithBrand(@NotNull RpcPagination<MerchantPageWithBrandDTO> pagination);
}
package cn.com.glsx.merchants.mapper;
import cn.com.glsx.merchants.dto.merchant.CarBrandProvinceRequestDTO;
import cn.com.glsx.merchants.dto.merchant.CarBrandRequestDTO;
import cn.com.glsx.merchants.dto.merchant.MerchantBasicInfo;
import cn.com.glsx.merchants.dto.merchant.StaffPhoneRequestDTO;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.merchants.dto.MerchantPageWithBrandDTO;
import cn.com.glsx.merchants.dto.merchant.*;
import cn.com.glsx.merchants.entity.Merchant;
import cn.com.glsx.merchants.model.request.*;
import cn.com.glsx.merchants.model.request.merchant.FindBySupMerchantNoRpcRequest;
import cn.com.glsx.merchants.model.request.merchant.MerchantBasicInfoRequest;
import cn.com.glsx.merchants.model.request.merchant.MerchantListByConditionRpcRequest;
import cn.com.glsx.merchants.model.request.merchant.MerchantNoRpcRequest;
import cn.com.glsx.merchants.model.request.merchant.*;
import cn.com.glsx.merchants.model.request.serviceCenter.SearchMerchantRpcRequest;
import cn.com.glsx.merchants.model.request.serviceCenter.UpdateMerchantRpcRequest;
import cn.com.glsx.merchants.model.response.*;
......@@ -176,4 +172,8 @@ public interface MerchantMapper extends CommonBaseMapper<Merchant> {
List<MerchantProvinceDTO> findMerchantListByBrandIdsProvince(CarBrandProvinceRequestDTO requestDTO);
List<MerchantProvinceDTO> findMerchantProvinceListByIds(@Param("merchantIds") List<Integer> merchantIds);
List<Integer> pageListMerchantIds(RpcPagination<MerchantPageWithBrandDTO> pagination);
List<MerchantPageWithBrandDTO> listMerchantWithBrandByMerchantIds(Page<Integer> idPage);
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ 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;
import cn.com.glsx.merchants.dto.MerchantPageWithBrandDTO;
import cn.com.glsx.merchants.dto.merchant.CarBrandProvinceRequestDTO;
import cn.com.glsx.merchants.dto.merchant.CarBrandRequestDTO;
import cn.com.glsx.merchants.dto.merchant.CarbrandResponse;
......@@ -935,4 +936,15 @@ public class MerchantRemoteImpl implements MerchantRemote {
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<RpcPagination<MerchantPageWithBrandDTO>> pageListMerchantWithBrand(RpcPagination<MerchantPageWithBrandDTO> pagination) {
try {
return RpcResponse.success(RpcPagination.copyPage(merchantService.pageListMerchantWithBrand(pagination)));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
}
......@@ -12,8 +12,7 @@ import cn.com.glsx.merchant.facade.remote.MerchantFacadeRemote;
import cn.com.glsx.merchants.annotation.beisen.BeiSenNotice;
import cn.com.glsx.merchants.config.SystemProperty;
import cn.com.glsx.merchants.contants.Constants;
import cn.com.glsx.merchants.dto.MerchantBrandDTO;
import cn.com.glsx.merchants.dto.MerchantFirstBrandDTO;
import cn.com.glsx.merchants.dto.*;
import cn.com.glsx.merchants.dto.merchant.*;
import cn.com.glsx.merchants.entity.*;
import cn.com.glsx.merchants.enums.*;
......@@ -2793,4 +2792,36 @@ public class MerchantService {
public List<MerchantProvinceDTO> findMerchantProvinceListByIds(List<Integer> merchantIds) {
return merchantMapper.findMerchantProvinceListByIds(merchantIds);
}
public Page<MerchantPageWithBrandDTO> pageListMerchantWithBrand(RpcPagination<MerchantPageWithBrandDTO> pagination) {
RpcAssert.assertNotNull(pagination, DefaultErrorEnum.DATA_NULL,"RpcPagination not be null");
try{
// 1:分页查询商户ID
Page<Integer> idPage = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(), pagination.isNeedCount())
.doSelectPage(() -> merchantMapper.pageListMerchantIds(pagination));
// 2:空结果处理
if (CollectionUtils.isEmpty(idPage)) {
Page<MerchantPageWithBrandDTO> emptyPage = new Page<>(pagination.getPageNum(), pagination.getPageSize(), pagination.isNeedCount());
emptyPage.setTotal(0);
return emptyPage;
}
// 3:根据ID查询商户详情
List<MerchantPageWithBrandDTO> merchantList = merchantMapper.listMerchantWithBrandByMerchantIds(idPage);
// 4:组装最终分页结果
Page<MerchantPageWithBrandDTO> resultPage = new Page<>(idPage.getPageNum(), idPage.getPageSize(), idPage.isCount());
resultPage.setTotal(idPage.getTotal());
resultPage.addAll(merchantList);
resultPage.setStartRow(idPage.getStartRow());
resultPage.setEndRow(idPage.getEndRow());
return resultPage;
}catch(Exception e){
log.error("分页查询商户带品牌数据异常", e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR,e.getMessage());
}
}
}
......@@ -115,6 +115,21 @@
<result column="created_source" jdbcType="VARCHAR" property="createdSource"/>
<result column="created_account" jdbcType="VARCHAR" property="createdAccount"/>
</resultMap>
<resultMap id="MerchantBrandDTOMap" type="cn.com.glsx.merchants.dto.MerchantBrandModelDTO">
<result column="brand_id" property="brandId" jdbcType="INTEGER" />
<result column="child_id" property="childId" jdbcType="INTEGER" />
</resultMap>
<resultMap id="MerchantPageWithBrandDTOMap" type="cn.com.glsx.merchants.dto.MerchantPageWithBrandDTO">
<id column="merchant_id" property="merchantId" jdbcType="INTEGER" />
<result column="merchant_name" property="merchantName" jdbcType="VARCHAR" />
<collection
property="merchantBrandList"
ofType="cn.com.glsx.merchants.dto.MerchantBrandModelDTO"
resultMap="MerchantBrandDTOMap"
fetchType="eager"
/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
......@@ -1264,4 +1279,46 @@
</if>
</select>
<!-- 1. 分页查询商户ID(仅查merchant_id,用于分页) -->
<select id="pageListMerchantIds" parameterType="cn.com.glsx.merchants.dto.MerchantPageWithBrandDTO"
resultType="java.lang.Integer">
SELECT DISTINCT s.merchantNo as merchantId
FROM platform_merchant s
INNER JOIN platform_merchant_brand m ON s.merchantNo = m.merchant_id
WHERE s.del_flag = 0
AND m.del_flag = 0
<if test="condition.brandIdList != null and condition.brandIdList.size() > 0">
AND m.first_brand_id IN
<foreach collection="brandIdList" item="brandId" open="(" separator="," close=")">
#{brandId}
</foreach>
</if>
<if test="condition.merchantIds != null and condition.merchantIds.size() > 0">
AND s.merchantNo IN
<foreach collection="merchantIds" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
</if>
ORDER BY s.merchantNo DESC
</select>
<!-- 2. 根据商户ID列表查询带品牌的详情 -->
<select id="listMerchantWithBrandByMerchantIds" parameterType="map" resultMap="MerchantPageWithBrandDTOMap">
SELECT DISTINCT s.merchantNo,
s.merchant_name,
IFNULL(m.first_brand_id, 0) AS brand_id,
IFNULL(m.sec_brand_id, 0) AS child_id
FROM platform_merchant s
INNER JOIN platform_merchant_brand m ON s.merchantNo = m.merchant_id
WHERE s.del_flag = 0
AND m.del_flag = 0
AND s.merchantNo IN
<foreach collection="merchantIds" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
ORDER BY s.merchantNo DESC
</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!