<?php
namespace app\admin\controller\pay;

use app\admin\controller\BaseController;
use support\Redis;
use support\Request;
use app\admin\server\payment\TonglianPayment;
use app\admin\server\payment\UnionOrder;

class Index extends BaseController
{
    /**
     * Notes:通联退款
     * @return \support\Response
     * User: ycp
     * Date: 2023/3/28
     */
    public function refund()
    {
        $order_don = $this->request->post('order_don');//订单号
        $info = UnionOrder::getOrderInfo2($order_don);
        if(empty($info))
        {
            throw new \Exception('订单不存在');
        }

        if($info['order_status'] != 5)
        {
            throw new \Exception('该订单状态不允许退款');
        }
        $result = TonglianPayment::refund($info['order_price']*100, $order_don);

        if($result['trxstatus'] == '0000')
        {
            UnionOrder::updateRefund($order_don);
        }
        
        return json_success($result);        
        
    }

    


    

}
