コード例 #1
0
ファイル: notify.php プロジェクト: OranTing/gdby_github_repo
    if ($notify->query_data['return_code'] == 'SUCCESS') {
        //$data['id'] = $orderId = substr($notify->query_data['out_trade_no'], 14);
        $data['id'] = $orderId = $notify->query_data['out_trade_no'];
        $data['pay_type'] = Config::ORDER_PAY_TYPE;
        $data['pay_status'] = Config::ORDER_PAY_FAILED_CODE;
        if ($notify->query_data['result_code'] == 'SUCCESS') {
            $data['pay_status'] = Config::ORDER_PAY_SUCCESS_CODE;
        }
        //$data['pay_discount'] = Config::ORDER_PAY_DISCOUNT;
        // 微信会轮训回调通知接口,更新订单支付状态前需要先查询订单是否已经更改
        $order_info = Order::get_order_by_id($data['id']);
        if ((int) $order_info['pay_status'] !== Config::ORDER_PAY_WAITTINT_CODE) {
            return;
        }
        if ($notify->request_data['attach'] !== PAY_ENV) {
            return;
        }
        $update_result = Order::update_order_status($data, $orderId);
        if ($update_result === true) {
            // 如果订单支付状态更新成功,则记录支付流水
            $update_suborder = Order::update_suborder_status($data['pay_status'], $orderId);
            $add_result = Trade::add_trade_bill($notify->request_data, $data);
        } else {
            throw new Exception('order pay status update failed');
        }
    } else {
        Log::DEBUG(sprintf('callback error|file:%s|line:%s|require_data:%s', __FILE__, __LINE__, json_encode($notify->request_data)));
    }
} catch (Exception $e) {
    Log::ERROR(sprintf('run exceptin:%s|file:%s|line:%s', $e->getMessage(), $e->getFile(), $e->getLine()));
}