update 生成订单,校验小程序所属运营商

This commit is contained in:
2023-08-31 14:06:25 +08:00
parent acff945822
commit 6e2b769dbb
5 changed files with 28 additions and 0 deletions

View File

@@ -63,6 +63,11 @@ public class OrderController extends BaseController {
if (StringUtils.isEmpty(memberId)) {
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
}
String appId = request.getHeader("appId");
if (StringUtils.isBlank(appId)) {
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_WECHAT_APP_ID_IS_NULL);
}
dto.setAppId(appId);
dto.setMemberId(memberId);
// 生成订单
dto.setStartMode(Constants.ONE); // 启动方式 1-app启动

View File

@@ -83,4 +83,9 @@ public class GenerateOrderDTO extends BasicPileDTO{
* 站点id
*/
private String stationId;
/**
* 微信小程序appId
*/
private String appId;
}

View File

@@ -114,4 +114,6 @@ public interface IPileMerchantInfoService {
* 通过merchantId获取一级运营商信息
*/
PileMerchantInfo getFirstLevelMerchantByMerchantId(String merchantId);
String getFirstLevelMerchantIdByMerchantId(String merchantId);
}

View File

@@ -3225,6 +3225,13 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
throw new BusinessException(ReturnCodeEnum.CODE_STATION_IS_NOT_OPEN);
}
// 校验启动桩使用的小程序,和充电桩所属一级运营商是否一致
String merchantIdByAppId = pileMerchantInfoService.getFirstLevelMerchantIdByAppId(dto.getAppId());
String merchantIdByMerchantId = pileMerchantInfoService.getFirstLevelMerchantIdByMerchantId(stationInfo.getMerchantId());
if (!StringUtils.equals(merchantIdByAppId, merchantIdByMerchantId)) {
throw new BusinessException("", "当前桩运营商与小程序所属运营商不一致");
}
// 如果是鉴权卡或者vin启动不判断枪口状态
if (!(StringUtils.equals(dto.getStartMode(), StartModeEnum.AUTH_CARD.getValue())
|| StringUtils.equals(dto.getStartMode(), StartModeEnum.VIN_CODE.getValue()))) {

View File

@@ -430,4 +430,13 @@ public class PileMerchantInfoServiceImpl implements IPileMerchantInfoService {
return pileMerchantInfo;
}
@Override
public String getFirstLevelMerchantIdByMerchantId(String merchantId) {
PileMerchantInfo merchantInfo = getFirstLevelMerchantByMerchantId(merchantId);
if (merchantInfo != null) {
return String.valueOf(merchantInfo.getId());
}
return null;
}
}