|
|
@@ -387,6 +387,46 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
entity.setVerifyParamMsg("参数验证成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 开始支付订单(主要是检查订单是否可以支付)
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent initOrderPay(String id) {
|
|
|
+ ExpenseFlow expenseFlow = expenseFlowDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(expenseFlow)) {
|
|
|
+ return ResultContent.buildFail("订单不存在");
|
|
|
+ }
|
|
|
+ OrderPayModel orderPayModel = isCanPay(expenseFlow);
|
|
|
+ if (!orderPayModel.isSuccess()) {
|
|
|
+ return ResultContent.buildFail(orderPayModel.getPayMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消订单
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent cancelOrder(String id) {
|
|
|
+ ExpenseFlow expenseFlow = expenseFlowDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(expenseFlow)) {
|
|
|
+ return ResultContent.buildFail("订单不存在");
|
|
|
+ }
|
|
|
+ OrderPayModel orderPayModel = isCanPay(expenseFlow);
|
|
|
+ if (!orderPayModel.isSuccess()) {
|
|
|
+ return ResultContent.buildFail(orderPayModel.getPayMsg());
|
|
|
+ }
|
|
|
+ expenseFlow.setOrderState(OrderState.CANCEL);
|
|
|
+ expenseFlowDao.save(expenseFlow);
|
|
|
+
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 订单支付
|
|
|
*
|
|
|
@@ -394,7 +434,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
* @return
|
|
|
*/
|
|
|
public ResultContent<ExpenseFlow> orderPay(ExpenseFlow entity) {
|
|
|
- // 判断参数是否符合要求
|
|
|
if (entity.getVerifyParamIsSuccess() == null || !entity.getVerifyParamIsSuccess()) {
|
|
|
// 参数验证失败
|
|
|
entity.setIsPaySuccess(Boolean.FALSE);
|
|
|
@@ -879,24 +918,20 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
*/
|
|
|
public OrderPayModel isCanPay(ExpenseFlow entity) {
|
|
|
OrderPayModel model = new OrderPayModel();
|
|
|
- Boolean isCanPay = Boolean.FALSE;
|
|
|
- String payMsg = "";
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ if (entity.getVerifyParamIsSuccess() == null || !entity.getVerifyParamIsSuccess()) {
|
|
|
+ return model.setFiled(entity.getVerifyParamMsg());
|
|
|
+ }
|
|
|
OrderState orderState = entity.getOrderState();
|
|
|
- // 订单参数验证成功,并且 未支付
|
|
|
- if (entity.getVerifyParamIsSuccess() != null && entity.getVerifyParamIsSuccess() && orderState == OrderState.WAIT_PAYMENT) {
|
|
|
- if (entity.getExpirationTime() >= System.currentTimeMillis()) {
|
|
|
- isCanPay = Boolean.TRUE;
|
|
|
- } else {
|
|
|
- payMsg = "支付超时";
|
|
|
- markOrderTimeOut(entity);
|
|
|
- }
|
|
|
- } else {
|
|
|
- payMsg = entity.getVerifyParamMsg();
|
|
|
+ if (orderState != OrderState.WAIT_PAYMENT) {
|
|
|
+ return model.setFiled(String.format("订单状态:%S", orderState.getRemark()));
|
|
|
+ }
|
|
|
+ if (entity.getExpirationTime() <= System.currentTimeMillis()) {
|
|
|
+ markOrderTimeOut(entity);
|
|
|
+ return model.setFiled("支付超时");
|
|
|
}
|
|
|
}
|
|
|
- model.setIsCanPay(isCanPay);
|
|
|
- model.setPayMsg(payMsg);
|
|
|
+ model.setSuccess();
|
|
|
return model;
|
|
|
}
|
|
|
|