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