Merge branch 'develop' of gitee.com:L-Shilin/go-fly-platform-services into feature_dzc
This commit is contained in:
+71
@@ -45,6 +45,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Order information
|
||||
@@ -780,8 +781,20 @@ public class OrderController {
|
||||
* @return
|
||||
*/
|
||||
private String appendPriceStr(String str){
|
||||
// 参数验证
|
||||
if (str == null || str.trim().isEmpty()) {
|
||||
return "0.00";
|
||||
}
|
||||
|
||||
// 获取字符串长度
|
||||
int length = str.length();
|
||||
|
||||
// 处理长度小于2的情况
|
||||
if (length == 1) {
|
||||
return "0.0" + str;
|
||||
} else if (length == 0) {
|
||||
return "0.00";
|
||||
}
|
||||
|
||||
// 获取除了最后两位字符之外的部分
|
||||
String prefix = str.substring(0, length - 2);
|
||||
@@ -1149,4 +1162,62 @@ public class OrderController {
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
@Operation(summary = "更新订单状态为已支付(优惠券核销成功后调用)")
|
||||
@PostMapping("/order/{orderNo}/status/paid")
|
||||
public Result<String> updateOrderStatusToPaid(@PathVariable("orderNo") String orderNo) {
|
||||
log.info("优惠券核销成功,更新订单状态为已支付,orderNo: {}", orderNo);
|
||||
|
||||
try {
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
if (order == null) {
|
||||
log.error("订单不存在,orderNo: {}", orderNo);
|
||||
return Result.failed("订单不存在");
|
||||
}
|
||||
|
||||
// 检查订单当前状态
|
||||
if (order.getOrderStatus().equals(OrderStatus.UNPAID.getId())) {
|
||||
// 更新订单状态为已支付排队中
|
||||
order.setOrderStatus(OrderStatus.PAID.getId());
|
||||
// 设置支付类型为优惠券支付
|
||||
order.setPayType(2); // 2表示优惠券支付
|
||||
// 设置支付时间
|
||||
order.setPayTime(new Date());
|
||||
|
||||
boolean result = orderService.updateOrder(order);
|
||||
if (result) {
|
||||
log.info("订单状态更新成功,orderNo: {}, 新状态: {}", orderNo, OrderStatus.PAID.getId());
|
||||
return Result.succeed("订单状态更新成功");
|
||||
} else {
|
||||
log.error("订单状态更新失败,orderNo: {}", orderNo);
|
||||
return Result.failed("订单状态更新失败");
|
||||
}
|
||||
} else {
|
||||
log.warn("订单状态不正确,无法更新为已支付,orderNo: {}, 当前状态: {}",
|
||||
orderNo, order.getOrderStatus());
|
||||
return Result.failed("订单状态不正确,无法更新为已支付");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("更新订单状态异常,orderNo: {}", orderNo, e);
|
||||
return Result.failed("更新订单状态异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "根据订单号获取订单信息")
|
||||
@GetMapping("/order/{orderNo}")
|
||||
public Result<Order> getOrderByOrderNo(@PathVariable("orderNo") String orderNo) {
|
||||
log.info("根据订单号获取订单信息,orderNo: {}", orderNo);
|
||||
|
||||
try {
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
if (order == null) {
|
||||
return Result.failed("订单不存在");
|
||||
}
|
||||
return Result.succeed(order);
|
||||
} catch (Exception e) {
|
||||
log.error("获取订单信息异常,orderNo: {}", orderNo, e);
|
||||
return Result.failed("获取订单信息异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user