订单
This commit is contained in:
@@ -12,7 +12,7 @@ public enum PayStatusEnum {
|
||||
|
||||
// `pay_status` int DEFAULT NULL COMMENT '支付状态 1 待支付 2 待出货 3 待退款 4 已退款 5 已完成',
|
||||
CREATE(1, "待支付"),
|
||||
PENDING(2,"已完成"),
|
||||
COMPLETE(2,"已完成"),
|
||||
WAIT_REFUND(3,"待退款"),
|
||||
REFUND(4,"已退款"),
|
||||
;
|
||||
|
||||
@@ -196,40 +196,41 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult completePayment(String orderId, String tradeNo, String payType) {
|
||||
try {
|
||||
// 查询订单
|
||||
OrderInfo orderInfo = selectOrderByOrderId(orderId);
|
||||
if (orderInfo == null) {
|
||||
return AjaxResult.error("订单不存在");
|
||||
}
|
||||
|
||||
// 检查订单状态
|
||||
if (orderInfo.getPayStatus() != PayStatusEnum.CREATE.getStatus()) {
|
||||
return AjaxResult.error("订单状态不正确");
|
||||
}
|
||||
|
||||
// 更新订单状态
|
||||
orderInfo.setPayStatus(PayStatusEnum.PENDING.getStatus()); // 2-待出货
|
||||
orderInfo.setPayTime(DateUtils.getNowDate());
|
||||
orderInfo.setTradeNo(tradeNo);
|
||||
orderInfo.setCallTime(DateUtils.getNowDate());
|
||||
orderInfo.setCallbackContent("支付成功回调");
|
||||
orderInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
// 计算服务时间
|
||||
calculateServiceTime(orderInfo);
|
||||
|
||||
// 保存订单
|
||||
int result = updateOrderInfo(orderInfo);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("支付完成");
|
||||
} else {
|
||||
return AjaxResult.error("支付完成处理失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("支付完成处理异常: " + e.getMessage());
|
||||
}
|
||||
// try {
|
||||
// // 查询订单
|
||||
// OrderInfo orderInfo = selectOrderByOrderId(orderId);
|
||||
// if (orderInfo == null) {
|
||||
// return AjaxResult.error("订单不存在");
|
||||
// }
|
||||
//
|
||||
// // 检查订单状态
|
||||
// if (orderInfo.getPayStatus() != PayStatusEnum.CREATE.getStatus()) {
|
||||
// return AjaxResult.error("订单状态不正确");
|
||||
// }
|
||||
//
|
||||
// // 更新订单状态
|
||||
// orderInfo.setPayStatus(PayStatusEnum.COMPLETE.getStatus()); // 2-待出货
|
||||
// orderInfo.setPayTime(DateUtils.getNowDate());
|
||||
// orderInfo.setTradeNo(tradeNo);
|
||||
// orderInfo.setCallTime(DateUtils.getNowDate());
|
||||
// orderInfo.setCallbackContent("支付成功回调");
|
||||
// orderInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
//
|
||||
// // 计算服务时间
|
||||
// calculateServiceTime(orderInfo);
|
||||
//
|
||||
// // 保存订单
|
||||
// int result = updateOrderInfo(orderInfo);
|
||||
// if (result > 0) {
|
||||
// return AjaxResult.success("支付完成");
|
||||
// } else {
|
||||
// return AjaxResult.error("支付完成处理失败");
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// return AjaxResult.error("支付完成处理异常: " + e.getMessage());
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,7 +249,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
||||
}
|
||||
|
||||
// 检查订单状态
|
||||
if (orderInfo.getPayStatus() != PayStatusEnum.PENDING.getStatus() && orderInfo.getPayStatus() != PayStatusEnum.WAIT_REFUND.getStatus()) {
|
||||
if ( orderInfo.getPayStatus() != PayStatusEnum.WAIT_REFUND.getStatus()) {
|
||||
return AjaxResult.error("订单状态不允许退款");
|
||||
}
|
||||
|
||||
@@ -312,33 +313,34 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult confirmShipment(String orderId) {
|
||||
try {
|
||||
// 查询订单
|
||||
OrderInfo orderInfo = selectOrderByOrderId(orderId);
|
||||
if (orderInfo == null) {
|
||||
return AjaxResult.error("订单不存在");
|
||||
}
|
||||
|
||||
// 检查订单状态
|
||||
if (orderInfo.getPayStatus() != PayStatusEnum.PENDING.getStatus()) {
|
||||
return AjaxResult.error("订单状态不正确,只有已支付的订单才能确认出货");
|
||||
}
|
||||
|
||||
// 更新订单状态为已完成
|
||||
orderInfo.setPayStatus(PayStatusEnum.COMPLETE.getStatus()); // 3-已完成
|
||||
orderInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
// 保存订单
|
||||
int result = updateOrderInfo(orderInfo);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("确认出货成功");
|
||||
} else {
|
||||
return AjaxResult.error("确认出货失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("确认出货异常: " + e.getMessage());
|
||||
}
|
||||
// try {
|
||||
// // 查询订单
|
||||
// OrderInfo orderInfo = selectOrderByOrderId(orderId);
|
||||
// if (orderInfo == null) {
|
||||
// return AjaxResult.error("订单不存在");
|
||||
// }
|
||||
//
|
||||
// // 检查订单状态
|
||||
// if (orderInfo.getPayStatus() != PayStatusEnum.PENDING.getStatus()) {
|
||||
// return AjaxResult.error("订单状态不正确,只有已支付的订单才能确认出货");
|
||||
// }
|
||||
//
|
||||
// // 更新订单状态为已完成
|
||||
// orderInfo.setPayStatus(PayStatusEnum.COMPLETE.getStatus()); // 3-已完成
|
||||
// orderInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
//
|
||||
// // 保存订单
|
||||
// int result = updateOrderInfo(orderInfo);
|
||||
// if (result > 0) {
|
||||
// return AjaxResult.success("确认出货成功");
|
||||
// } else {
|
||||
// return AjaxResult.error("确认出货失败");
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// return AjaxResult.error("确认出货异常: " + e.getMessage());
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user