class Balance extends ApiBase
{
public function balance($order_id)
{
$post = $this->request->post();
switch ($post) {
case 'order':
$order = Order::get($post['order_id']);
break;
}
//找不到订单
if (empty($order)) {
$this->_error('订单不存在');
}
//已支付
if ($order['pay_status'] == Pay::ISPAID || $order['order_amount'] == 0) {
$this->_success('支付成功', ['order_id' => $order['id']], 10001);
}
$result = PaymentLogic::pay($post['from'], $order, $post['order_source']);
var_dump($result);
if (false === $result) {
$this->_error(PaymentLogic::getError(), ['order_id' => $order['id']], PaymentLogic::getReturnCode());
}
$this->_success('', $result);
}
}
1.判断订单是否支付。
2.生成支付单数据(支付方式,金额,时间,支付状态)
3.生成余额支付流水记录(扣减账户余额)
4.支付完成后修改订单状态,支付单状态,流水状态。