<?php
/**
 * 充值提现
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author zhaoh <1070309178@qq.com>
 */

namespace Mobile\Controller;
use Think\Controller;
class PayController extends BaseController {
	//确认支付
    public function index(){
        $order_id=I('order_id');
        $map=array();
        $map['id']=$order_id;
        $order_info=M('OrderInfo')->where($map)->field('id,pay_amount,goods_amount')->find();
        if($order_info){
            if(is_weixin()){
                $pay_code='HANCHAO_SWEIXIN';
                $payment_id=14;
            }else{
                $pay_code='HANCHAO_SALIPAY';
                $payment_id=13;
            }
            $map=array();
            $save_data=array();
            $map['id']=$order_id;
            $map['pay_status']=1;
            $save_data['pay_code']=$pay_code;
            $save_data['payment_id']=$payment_id;
            M('OrderInfo')->where($map)->save($save_data);
            $this->assign('tplseo_title', '支付' . '_' . C('WEB_SITE_TITLE'));
            $this->assign('page_title', '确认支付');
            $this->assign('order_info',$order_info);
            $this->display();
        }else{
            $this->error('');
        }
    }
	//充值操作
	public function confirm_pay(){
        $return=array('status'=>0,'msg'=>'');
		/*$postdata=I('post.');
	    $map=array();
        $map['id']=$postdata['id'];
        $map['pay_status']=1;
        $map['status']=1;
        $map['shipping_status']=array('lt',3);
        $save_data=array();
        $save_data['pay_status']=3;
        $save_data['status']=3;
        $save_data['shipping_status']=4;
        $result=M('OrderInfo')->where($map)->save($save_data);*/
        //if($result){
            $return['status']=1;
            $return['msg']='暂不支持此支付功能';
        //}else{
            //$return['msg']='支付失败';
        //}
		$this->ajaxReturn($return);
    }
    public function order_success(){
        $this->assign('page_title', '支付成功');
        $this->display();
    }
    public function pay_shop(){
        $param = I('get.');
        $map['id']=$this->member_info['id'];
        $user_info=M("Member")->where($map)->field(true)->find();
        $this->assign('member_info',$user_info);
        $this->assign($param);
        $this->display();
    }
    /**
     * 提交订单
     */
    public function add_order(){
        $return=array('status'=>1,'msg'=>'');
        $postdata=I('post.');
        $postdata['is_pos'] = 1;
        //$postdata['bank_money'] = $postdata['total_price'];//台卡支付金额
        $postdata['pay_type']=explode(',',strtr($postdata['pay_type'],array('['=>'',']'=>'')));
        // if(in_array(3,$postdata['pay_type']) && in_array(4,$postdata['pay_type'])){
        //     $return['status']=3;
        //     $return['msg']='台卡支付和扫码支付不能同时使用';
        //     $this->ajaxReturn($return);
        // }
        if($postdata['ids_list']){
            $ids_lists=$this->StrToparamArray($postdata['ids_list']);
            $ids_arr = array();
            if($ids_lists){
                foreach($ids_lists as $k => $v){
                    $ids_arr[$k] = $k;
                }
            }
            $postdata['ids_list'] = $ids_arr;
        }
        if($postdata['cart_list']) $postdata['cart_list']=$this->StrToparamArray($postdata['cart_list']);
        //print_r($postdata);exit;
        $result=D('Pad/Cashier')->add_order($postdata);
        if($result['status']==1){
            $this->ajaxReturn($result);
        }
        // if(empty($result['msg'])){
        //     $result['msg']='支付失败';
        // }
        $return['status']=3;
        $return['msg']=$result['msg'];
        $this->ajaxReturn($return);
    }
}
?>