Commit 2e35178a by 叶立庆

Merge remote-tracking branch 'origin/master' into v5.6.0

# Conflicts:
#	platform-merchants-api/pom.xml
#	platform-merchants-api/src/main/java/cn/com/glsx/merchants/remote/MerchantRemote.java
#	platform-merchants-container/pom.xml
#	platform-merchants-container/src/main/java/cn/com/glsx/merchants/mapper/MerchantMapper.java
#	platform-merchants-container/src/main/java/cn/com/glsx/merchants/remote/MerchantRemoteImpl.java
#	platform-merchants-container/src/main/java/cn/com/glsx/merchants/service/MerchantService.java
#	platform-merchants-container/src/main/resources/META-INF/orm/MerchantMapper.xml
2 parents e72b9e72 f410eedf
package cn.com.glsx.merchants.model.request;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString
public class StaffBatchRequest extends DefaultRequest implements Serializable {
/**
......@@ -13,6 +17,8 @@ public class StaffBatchRequest extends DefaultRequest implements Serializable {
*/
public List<Integer> staffIds;
public String staffUuid;
public String staffPhone;
public String merchantId;
......
......@@ -19,4 +19,9 @@ public class MerchantStaffListRequest extends DefaultRequest implements Serializ
*/
private List<Integer> merchantIds;
/**
* 状态列表 0正常 -1删除 2禁用 (默认只查询正常数据)
*/
private List<Integer> statusList;
}
\ No newline at end of file
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 MerchantBrandDTO implements Serializable {
/**
* 商户号
*/
private Integer merchantId;
/**
* 一级品牌id
*/
private Integer firstBrandId;
/**
* 二级品牌id
*/
private Integer secBrandId;
}
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;
}
......@@ -540,6 +540,11 @@ public interface MerchantRemote {
@ApiResponse("品牌")
RpcResponse<List<MerchantBrandResponse>> getBrand(Integer merchantId);
@ApiMethod("查询品牌列表")
@ApiParams({@ApiParam(name = "merchantId", notes = "查询品牌列表", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("品牌")
RpcResponse<List<MerchantBrandDTO>> getBrandByMerchantIds(List<Integer> merchantId);
@ApiMethod("根据一级品牌,省份id查询商户号列表")
@ApiParams({@ApiParam(name = "requestDTO", notes = "查询商户列表", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("查询商户列表(对外简化)")
......@@ -547,6 +552,11 @@ public interface MerchantRemote {
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);
@ApiMethod("分页查询dj门店/品牌/子品牌列表")
@ApiParam(name = "pagination", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("门店/品牌/子品牌列表")
......
......@@ -173,6 +173,8 @@ public interface MerchantMapper extends CommonBaseMapper<Merchant> {
List<MerchantProvinceDTO> findMerchantProvinceListByIds(@Param("merchantIds") List<Integer> merchantIds);
List<MerchantBrandDTO> getBrandByMerchantIds(@Param("merchantIds") List<Integer> merchantIds);
List<Integer> pageListMerchantIds(RpcPagination<MerchantPageWithBrandDTO> pagination);
List<MerchantPageWithBrandDTO> listMerchantWithBrandByMerchantIds(@Param("merchantIds") List<Integer> merchantIds);
......
......@@ -905,6 +905,19 @@ public class MerchantRemoteImpl implements MerchantRemote {
}
@Override
public RpcResponse<List<MerchantBrandDTO>> getBrandByMerchantIds(List<Integer> merchantId) {
try {
return RpcResponse.success(merchantService.getBrandByMerchantIds(merchantId));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("根据商户号列表查询品牌失败:", e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<String>> qryPhoneInStaffList(List<String> phones) {
try {
return RpcResponse.success(merchantService.qryPhoneInStaffList(phones));
......@@ -947,4 +960,24 @@ public class MerchantRemoteImpl implements MerchantRemote {
}
}
/**
* 查询商户名称
* @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);
}
}
}
......@@ -12,7 +12,9 @@ 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.*;
import cn.com.glsx.merchants.dto.MerchantBrandDTO;
import cn.com.glsx.merchants.dto.MerchantFirstBrandDTO;
import cn.com.glsx.merchants.dto.MerchantPageWithBrandDTO;
import cn.com.glsx.merchants.dto.merchant.*;
import cn.com.glsx.merchants.entity.*;
import cn.com.glsx.merchants.enums.*;
......@@ -60,6 +62,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;
......@@ -495,7 +498,7 @@ public class MerchantService {
*
* @param merchantRequest
*/
@BeiSenNotice(type = AccountEventSyncBeiSenEnum.UPDATE_ACCOUNT_YQ_MERCHANT, description = "更新商户")
@BeiSenNotice(type = AccountEventSyncBeiSenEnum.UPDATE_ACCOUNT_YQ_MERCHANT, description = "更新商户")
@Transactional(rollbackFor = RpcServiceException.class)
public String updateMerchant(MerchantRequest merchantRequest) {
Merchant merchant = new Merchant();
......@@ -2547,8 +2550,8 @@ public class MerchantService {
&& StringUtils.isEmpty(request.getMerchantName())
&& CollectionUtils.isEmpty(request.getBrandRequestList())
&& CollectionUtils.isEmpty(request.getProvinceNameList())
&& CollectionUtils.isEmpty(request.getCityNameList())){
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL,"商户号、商户名称、品牌信息、区域不能同时为空");
&& CollectionUtils.isEmpty(request.getCityNameList())) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, "商户号、商户名称、品牌信息、区域不能同时为空");
}
Page<MerchantBasicInfoListResponse> merchantList = new Page<>();
......@@ -2737,26 +2740,26 @@ public class MerchantService {
}
public List<MerchantSimpleResponse> findMerchantListByBrandIds(CarBrandRequestDTO requestDTO) {
if (CollectionUtils.isEmpty(requestDTO.getFirstBrandIdList())&& CollectionUtils.isEmpty(requestDTO.getSecBrandIdList())){
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL,"参数不能为空!");
if (CollectionUtils.isEmpty(requestDTO.getFirstBrandIdList()) && CollectionUtils.isEmpty(requestDTO.getSecBrandIdList())) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, "参数不能为空!");
}
try {
return merchantMapper.findMerchantListByBrandIds(requestDTO);
} catch (Exception e) {
log.error(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR,"查询商户失败!");
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, "查询商户失败!");
}
}
public List<MerchantSimpleResponse> findMerchantListByBrandIds2(CarBrandRequestDTO requestDTO) {
if (CollectionUtils.isEmpty(requestDTO.getFirstBrandIdList())&& CollectionUtils.isEmpty(requestDTO.getSecBrandIdList())){
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL,"一级二级品牌参数不能都为空!");
if (CollectionUtils.isEmpty(requestDTO.getFirstBrandIdList()) && CollectionUtils.isEmpty(requestDTO.getSecBrandIdList())) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, "一级二级品牌参数不能都为空!");
}
try {
return merchantMapper.findMerchantListByBrandIds2(requestDTO);
} catch (Exception e) {
log.error(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR,"查询商户失败!");
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, "查询商户失败!");
}
}
......@@ -2773,10 +2776,11 @@ public class MerchantService {
/**
* 查询系统中存在的手机号
* @author yangwei
* @since 2025/10/24 10:51
*
* @param phones 被校验的手机号列表
* @return java.util.List<java.lang.String> 存在于系统的手机号列表
* @author yangwei
* @since 2025/10/24 10:51
*/
public List<String> qryPhoneInStaffList(List<String> phones) {
if (CollectionUtils.isEmpty(phones)) {
......@@ -2793,10 +2797,30 @@ public class MerchantService {
return merchantMapper.findMerchantProvinceListByIds(merchantIds);
}
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());
}
public Page<MerchantPageWithBrandDTO> pageListMerchantWithBrand(RpcPagination<MerchantPageWithBrandDTO> pagination) {
RpcAssert.assertNotNull(pagination, DefaultErrorEnum.DATA_NULL,"RpcPagination not be null");
try{
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));
......@@ -2818,9 +2842,9 @@ public class MerchantService {
resultPage.setStartRow(idPage.getStartRow());
resultPage.setEndRow(idPage.getEndRow());
return resultPage;
}catch(Exception e){
} catch (Exception e) {
log.error("分页查询商户带品牌数据异常", e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR,e.getMessage());
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, e.getMessage());
}
}
......
......@@ -721,29 +721,33 @@ public class MerchantStaffService {
* @return
*/
public String saveOrUpdateStaff(MerchantStaffRequest merchantRequest) {
RpcAssert.assertNotNull(merchantRequest.getMerchantNo(), DefaultErrorEnum.SERVICE_ERROR, "商户号不能为空");
String loginAccount = StringUtils.isBlank(merchantRequest.getLoginAccount()) ? merchantRequest.getStaffPhone() : merchantRequest.getLoginAccount();
MerchantUserResponse byAccount = merchantUserService.findByAccount(new MerchantLogin(loginAccount, merchantRequest.getMerchantId(),Constants.STAFF_USER));
MerchantUserResponse byAccount = merchantUserService.findByAccount(new MerchantLogin(loginAccount, merchantRequest.getMerchantNo(),Constants.STAFF_USER));
String uuid;
if (byAccount != null && byAccount.getBussinessId() != null) {
uuid = byAccount.getUuid();
merchantRequest.setId(byAccount.getBussinessId());
updateMerchantStaff(merchantRequest);
thiz.updateMerchantStaff(merchantRequest);
if (merchantRequest.getPassword() != null) {
merchantUserService.updateOpenUser(new MerchantLogin(Constants.STAFF_USER, merchantRequest.getPassword(), merchantRequest.getId(),merchantRequest.getMesVerifyFlag()));
}
} else {
uuid = saveMerchantStaff(merchantRequest);
uuid = thiz.saveMerchantStaff(merchantRequest);
}
return uuid;
}
/**
* 其他系统传递的merchantId非主键id,这里进行转化
*/
public void parseMerchantNo(MerchantStaffRequest merchantRequest) {
if (merchantRequest.getMerchantId() != null) {
List<MerchantResponse> byMerchantNo = merchantService.findByMerchantNo(merchantRequest.getMerchantId() + "");
RpcAssert.assertNotEmpty(byMerchantNo, DefaultErrorEnum.DATA_INVALID, merchantRequest.getMerchantId() + "商户号不存在");
merchantRequest.setMerchantId(byMerchantNo.get(0).getId());
merchantRequest.setVisibleInferiorMer(byMerchantNo.get(0).getId() + "");
}
RpcAssert.assertNotNull(merchantRequest.getMerchantId(), DefaultErrorEnum.SERVICE_ERROR, "商户id不能为空");
List<MerchantResponse> byMerchantNo = merchantService.findByMerchantNo(merchantRequest.getMerchantId() + "");
RpcAssert.assertNotEmpty(byMerchantNo, DefaultErrorEnum.DATA_INVALID, merchantRequest.getMerchantId() + "商户号不存在");
merchantRequest.setMerchantId(byMerchantNo.get(0).getId());
merchantRequest.setVisibleInferiorMer(byMerchantNo.get(0).getId() + "");
merchantRequest.setMerchantNo(byMerchantNo.get(0).getMerchantNo());
}
@BeiSenNotice(type = AccountEventSyncBeiSenEnum.UPDATE_ACCOUNT, description = "更新账户")
......@@ -872,11 +876,20 @@ public class MerchantStaffService {
}
public void updateStaffStatusByPhone(StaffBatchRequest staffBatchRequest) {
String phone = staffBatchRequest.getStaffPhone();
if (StringUtils.isBlank(staffBatchRequest.getStaffPhone()) && StringUtils.isBlank(staffBatchRequest.getStaffUuid())) {
log.error("参数错误, {}", staffBatchRequest);
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "手机号或者编号为空");
}
Example example = new Example(MerchantStaff.class);
Example.Criteria criteria = example.createCriteria();
criteria.andNotEqualTo("delFlag", -1).andEqualTo("staffPhone", phone);
criteria.andNotEqualTo("delFlag", -1);
if (StringUtils.isNotBlank(staffBatchRequest.getStaffPhone())){
criteria.andEqualTo("staffPhone", staffBatchRequest.getStaffPhone());
}
if (StringUtils.isNotBlank(staffBatchRequest.getStaffUuid())){
criteria.andEqualTo("staffUuid", staffBatchRequest.getStaffUuid());
}
if (StringUtils.isNotBlank(staffBatchRequest.getMerchantId())){
Example merchantExample = new Example(Merchant.class);
merchantExample.createCriteria().andNotEqualTo("delFlag", -1).andEqualTo("merchantNo", staffBatchRequest.getMerchantId());
......@@ -888,7 +901,7 @@ public class MerchantStaffService {
List<MerchantStaff> staffList = merchantStaffMapper.selectByExample(example);
RpcAssert.assertNotEmpty(staffList, DefaultErrorEnum.DATA_NULL, "手机号搜索不到员工");
staffBatchRequest.setStaffIds(staffList.stream().map(MerchantStaff::getId).collect(Collectors.toList()));
log.info("[{}]查询到的员工信息:{}", phone, staffBatchRequest.getStaffIds());
log.info("查询到的员工信息:{}", staffBatchRequest);
thiz.updateStaffStatusBatch(staffBatchRequest);
}
......
......@@ -1279,6 +1279,21 @@
</if>
</select>
<select id="getBrandByMerchantIds" resultType="cn.com.glsx.merchants.model.response.MerchantBrandDTO">
select
merchant_id as merchantId,
first_brand_id as firstBrandId,
sec_brand_id as secBrandId
from platform_merchant_brand
where del_flag = 0
<if test="merchantIds != null and merchantIds.size() > 0">
AND merchant_id IN
<foreach collection="merchantIds" item="item" separator="," index="index" open="(" close=")">
#{item}
</foreach>
</if>
</select>
<!-- 1. 分页查询商户ID(仅查merchant_id,用于分页) -->
<select id="pageListMerchantIds" parameterType="cn.com.glsx.merchants.dto.MerchantPageWithBrandDTO"
......
......@@ -513,7 +513,16 @@
<foreach collection="request.merchantIds" open="(" close=")" separator="," item="merchantNo">
#{merchantNo}
</foreach>
AND s.`del_flag` = 0 AND m.`del_flag`=0
AND m.`del_flag`=0
<if test="request.statusList != null and request.statusList.size() > 0">
AND s.`del_flag` in
<foreach collection="request.statusList" open="(" close=")" separator="," item="status">
#{status}
</foreach>
</if>
<if test="request.statusList == null or request.statusList.size() == 0">
AND s.`del_flag` = 0
</if>
</select>
<select id="selectStaffListByMerchantIdAndStaffLabels" resultMap="resultMap">
SELECT s.* FROM `platform_merchant_staff` s LEFT JOIN `platform_merchant` m ON m.`id`=s.`merchant_id`
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!