<?php
/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 2016/10/17
 * Time: 下午4:42
 */

class pay_returnControl extends mobileHomeControl
{
    public function __construct()
    {
        parent::__construct();
    }

    public function cmbpayOp()
    {
        $pay_sn = $_GET['pay_sn'];
        $order_sn = $_GET['order_sn'];
        $member_id = intval($_GET['member_id']);

        if(empty($pay_sn) || empty($order_sn) || $member_id <= 0) {
            return self::outsuccess(array("pay_state" => 'no_order',),"pay/cmbret",'wap');
        }
        else
        {
            $mod_order = Model('order');
            $condition = array();
            $condition['buyer_id'] = $member_id;
            $condition['pay_sn'] = $pay_sn;

            $order = $mod_order->getNormalOrderList($condition, $this->page_size, '*');
            if(empty($order)) {
                return self::outsuccess(array("pay_state" => "no_order"),"pay/cmbret",'wap');
            }
            else
            {
                $state = intval($order['order_state']);
                $paied = array(ORDER_STATE_PAY,ORDER_STATE_SEND,ORDER_STATE_SUCCESS);
                if(in_array($state,$paied)) {
                    return self::outsuccess(array("pay_state" => "success",'pay_sn' => $pay_sn),"pay/cmbret",'wap');
                } else {
                    return self::outsuccess(array("pay_state" => "unpaied",'pay_sn' => $pay_sn),"pay/cmbret",'wap');
                }
            }
        }
    }
}