public PayOrderBag ToNextState(string alipayId = "") { if (PayOrder.PayStateID == PayStateEnum.Created.ToString()) { if (!alipayId.HasValue()) { return(this); } PayOrder.AliPayID = alipayId; PayOrder.PayStateID = PayStateEnum.Pending.ToString(); } else if (PayOrder.PayStateID == PayStateEnum.Pending.ToString()) { PayOrder.PayStateID = PayStateEnum.Successful.ToString(); //充值订单 if (PayOrder.PayOrderTypeID == PayOrderTypeEnum.AliPay.ToString()) { Payer.Expense(PayOrder.PayNum); Receiver.Charge(PayOrder.PayNum); } else {//转账订单 Payer.Expense(PayOrder.PayNum); Receiver.Charge(PayOrder.PayNum); } } else if (PayOrder.PayStateID == PayStateEnum.Successful.ToString()) { PayOrder.PayStateID = PayStateEnum.Finished.ToString(); } return(this); }
public PayOrderBag FinishOrder() {//手动完成订单 if (PayOrder.PayStateID == PayStateEnum.Created.ToString()) { PayOrder.AliPayID = "---"; PayOrder.PayStateID = PayStateEnum.Finished.ToString(); //扣款 Payer.Expense(PayOrder.PayNum); Receiver.Charge(PayOrder.PayNum); return(this); } else { throw new Exception("手动完成只支持状态为Created的订单"); } }