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

namespace Member\Controller;
use Think\Controller;
class ReturnGoodsController extends BaseController
{
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 退款列表
     */
    public function index()
    {
        $postdata = I('param.');
        if (!empty($postdata['order_sn'])) {
            $order_id = idtoname($postdata['order_sn'], 'OrderInfo', 'id', 'order_sn');
            if ($order_id) $map['order_id'] = $order_id;
        }
        if (!empty($postdata['time_form'])) $map['addtime'][] = array('egt', strtotime($postdata['time_form']));
        if (!empty($postdata['time_to'])) $map['addtime'][] = array('elt', strtotime($postdata['time_to']));
        $map['uid'] = MID;
        $info = page_list('RefundOrder', $map, 'id desc', true, 10, '', 1);
        $this->assign($info);
        $this->assign($postdata);
        $this->assign('tplseo_title', '退款列表_会员中心_' . C('WEB_SITE_TITLE'));
        $this->display();
    }

    /**
     * 退货列表
     */
    public function goods()
    {
        $postdata = I('param.');
        if (!empty($postdata['order_sn'])) {
            $order_id = idtoname($postdata['order_sn'], 'OrderInfo', 'id', 'order_sn');
            if ($order_id) $map['order_id'] = $order_id;
        }
        if (!empty($postdata['time_form'])) $map['add_time'][] = array('egt', strtotime($postdata['time_form']));
        if (!empty($postdata['time_to'])) $map['add_time'][] = array('elt', strtotime($postdata['time_to']));
        $map['uid'] = MID;
        $info = page_list('ReturnGoods', $map, 'id desc', true, 10, '', 1);
        if ($info['list']) {
            foreach ($info['list'] as $k => $v) {
                $goods_info = unserialize($v['goods_info']);
                foreach ($goods_info as $ke => $vo) {
                    $goods_info[$ke]['img'] = idtoname($vo['goods_id'], 'Goods', 'img');
                    $goods_info[$ke]['name'] = idtoname($vo['goods_id'], 'Goods', 'goods_name');
                }
                $info['list'][$k]['goods_info'] = $goods_info;
            }
        }
        $this->assign($info);
        $this->assign($postdata);
        $this->assign('tplseo_title', '退货列表_会员中心_' . C('WEB_SITE_TITLE'));
        $this->display();
    }
}
?>