用户关锁错误优化
This commit is contained in:
parent
8ef2311b94
commit
09d940b1e4
@ -162,26 +162,4 @@ public class EbikeRefundServiceImpl extends ServiceImpl<EbikeRefundMapper, Ebike
|
||||
Long refundInFen = refund.getAmount().getRefund();
|
||||
return calculateRefundAmountInternal(refundInFen, refund.getOutRefundNo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单号
|
||||
*
|
||||
* @param refundOrderId 根据退款回调退款订单号查询订单号
|
||||
*/
|
||||
private Long queryOrderId(String refundOrderId) {
|
||||
if (refundOrderId == null) {
|
||||
log.warn("退款订单ID为空,无法查询主订单ID");
|
||||
return null;
|
||||
}
|
||||
//查询退款中且状态为2的订单
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_REFUND.REFUND_ORDER_ID.eq(refundOrderId));
|
||||
EbikeRefund ebikeRefund = this.mapper.selectOneByQuery(queryWrapper);
|
||||
|
||||
if (ebikeRefund == null) {
|
||||
log.warn("未找到退款订单号为的退款记录,退款单ID: {}", refundOrderId);
|
||||
return null;
|
||||
}
|
||||
return ebikeRefund.getOrderId();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
package com.cdzy.user.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 开锁结果
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-11-11 11:34
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class EbikeUnlockResultDto {
|
||||
|
||||
private boolean success;
|
||||
|
||||
private String errorMsg;
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.cdzy.user.model.dto;
|
||||
|
||||
import com.cdzy.common.model.request.PageParam;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 用户信息实名制 查询参数
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-10-16 09:54
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EbikeUserRealInfoDto {
|
||||
|
||||
/**
|
||||
* 用户注册时间(起)
|
||||
*/
|
||||
private LocalDateTime registerTimeStart;
|
||||
|
||||
/**
|
||||
* 用户注册时间(止)
|
||||
*/
|
||||
private LocalDateTime registerTimeEnd;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 实名状态
|
||||
*/
|
||||
private Integer realNameStatus;
|
||||
|
||||
/**
|
||||
* 分页参数
|
||||
*/
|
||||
private PageParam pageParam;
|
||||
}
|
||||
@ -7,7 +7,6 @@ import com.cdzy.common.model.request.PageParam;
|
||||
import com.cdzy.common.model.response.JsonResult;
|
||||
import com.cdzy.user.enums.*;
|
||||
import com.cdzy.user.mapper.EbikeOrderMapper;
|
||||
import com.cdzy.user.model.dto.EbikeUnlockResultDto;
|
||||
import com.cdzy.user.model.dto.EbikeUserCyclingDto;
|
||||
import com.cdzy.user.model.dto.EbikeUserCyclingEndDto;
|
||||
import com.cdzy.user.model.entity.EbikeOrder;
|
||||
@ -30,7 +29,6 @@ import com.ebike.feign.model.vo.FeignEbikeBikeRadiusVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import feign.FeignException;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -98,9 +96,9 @@ public class EbikeOrderServiceImpl extends ServiceImpl<EbikeOrderMapper, EbikeOr
|
||||
.build();
|
||||
save(order);
|
||||
// 尝试开锁
|
||||
EbikeUnlockResultDto unlockResult = attemptUnlockWithValidation(bikeCode, userId);
|
||||
if (!unlockResult.isSuccess()) {
|
||||
throw new EbikeException("开锁失败: " + unlockResult.getErrorMsg());
|
||||
JsonResult<?> jsonResult = operationsFeignClient.openLock(bikeCode);
|
||||
if (jsonResult.getCode() != Code.SUCCESS) {
|
||||
throw new EbikeException("开锁失败:" + jsonResult.getMessage());
|
||||
}
|
||||
// 开锁成功
|
||||
EbikeOrder orders = EbikeOrder.builder()
|
||||
@ -194,7 +192,7 @@ public class EbikeOrderServiceImpl extends ServiceImpl<EbikeOrderMapper, EbikeOr
|
||||
public EbikeBikeInfoVo queryBikeInfo(String bikeCode) {
|
||||
JsonResult<FeignEbikeUserBikeInfo> jsonResult = operationsFeignClient.bikeInfo(bikeCode);
|
||||
if (jsonResult.getCode() != Code.SUCCESS) {
|
||||
throw new EbikeException("获取车辆详情");
|
||||
throw new EbikeException("获取车辆详情失败");
|
||||
}
|
||||
FeignEbikeUserBikeInfo source = jsonResult.getData();
|
||||
return EbikeBikeInfoVo.builder()
|
||||
@ -240,7 +238,7 @@ public class EbikeOrderServiceImpl extends ServiceImpl<EbikeOrderMapper, EbikeOr
|
||||
ebikeLockVo.setPoint(endDto.getEndPoint());
|
||||
JsonResult<FeignEbikeUserLockDto> jsonResult = operationsFeignClient.lock(ebikeLockVo);
|
||||
if (jsonResult.getCode() != Code.SUCCESS) {
|
||||
throw new EbikeException("关锁失败");
|
||||
throw new EbikeException("关锁失败:" + jsonResult.getMessage());
|
||||
}
|
||||
FeignEbikeUserLockDto data = jsonResult.getData();
|
||||
// 订单费用计算
|
||||
@ -474,37 +472,4 @@ public class EbikeOrderServiceImpl extends ServiceImpl<EbikeOrderMapper, EbikeOr
|
||||
}
|
||||
return userOrders;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开锁
|
||||
*/
|
||||
private EbikeUnlockResultDto attemptUnlockWithValidation(String bikeCode, Long userId) {
|
||||
try {
|
||||
JsonResult<?> jsonResult = operationsFeignClient.openLock(bikeCode);
|
||||
if (jsonResult == null) {
|
||||
String errorMsg = "开锁服务返回结果为空";
|
||||
log.error("开锁失败 - 响应为空, bikeCode={}, userId={}", bikeCode, userId);
|
||||
return new EbikeUnlockResultDto(false, errorMsg);
|
||||
}
|
||||
Integer code = jsonResult.getCode();
|
||||
String msg = jsonResult.getMessage() != null ? jsonResult.getMessage() : "未知错误";
|
||||
if (code != null && code == 200) {
|
||||
log.info("开锁成功,用户: {}, 车辆: {}", userId, bikeCode);
|
||||
return new EbikeUnlockResultDto(true, null);
|
||||
} else {
|
||||
log.warn("开锁失败,用户: {}, 车辆: {}, 错误码: {}, 原因: {}",
|
||||
userId, bikeCode, code, msg);
|
||||
return new EbikeUnlockResultDto(false, msg);
|
||||
}
|
||||
} catch (FeignException e) {
|
||||
String errorMsg = "开锁服务调用失败";
|
||||
log.error("Feign 开锁失败, bikeCode={}, userId={}, status={}, response={}",
|
||||
bikeCode, userId, e.status(), e.contentUTF8(), e);
|
||||
return new EbikeUnlockResultDto(false, errorMsg);
|
||||
} catch (Exception e) {
|
||||
String errorMsg = "系统繁忙,请稍后重试";
|
||||
log.error("开锁过程发生未知异常, bikeCode={}, userId={}", bikeCode, userId, e);
|
||||
return new EbikeUnlockResultDto(false, errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user