<?php

namespace Vip\Lib;

use Dever;

class Manage
{
    public function showOrderUser($id)
    {
        $info = Dever::db('vip/order')->one($id);

        $table = array();

        $user = Dever::db('passport/user')->one($info['uid']);

        $table['用户名'] = $user['username'] . '('.$info['uid'].')';
        $table['手机号'] = $user['mobile'];
        $table['产品名'] = $info['name'];
        if ($info['type'] == 1) {
            $table['支付方式'] = '购买小刊';
            $table['支付金额'] = $info['cash'];
        } elseif ($info['type'] == 3) {
            $table['支付方式'] = '购买小刊兑换码';
            //$table['兑换码'] = $info['code'];
            $table['支付金额'] = $info['cash'];
        } else {
            $table['支付方式'] = '兑换小刊';
            $table['兑换码'] = $info['code'];
        }
        //$table['购买数量'] = $info['num'];
        
        if ($info['source_uid'] && $info['source_uid'] != $info['uid']) {
            $user = Dever::db('passport/user')->one($info['source_uid']);
            $table['邀请人'] = $user['username'];
        }

        return Dever::table($table);
    }

    public function showOrderStatus($id)
    {
        $info = Dever::db('vip/order')->one($id);
        if ($info) {
            if ($info['status'] == 1) {
                #return '*已支付';
                return '待支付';
            } elseif ($info['status'] == 2) {
                return '已支付';
            } elseif ($info['status'] == 3) {
                return '支付失败';
            } elseif ($info['status'] == 5) {
                $table['状态'] = '已退款';
                $manage = Dever::db('manage/admin')->one($info['tk_admin']);
                $table['备注'] = $info['tk_desc'];
                $table['截图'] = '<a href="'.$info['tk_pic'].'" target="_blank"><img src="'.$info['tk_pic'].'" style="width:150px" /></a>';
                //$table['退款时间'] = date('Y-m-d H:i:s', $info['tk_time']);
                $table['操作人'] = $manage['username'];
                return Dever::table($table);
            }
        }
    }
}