<?php !defined('CRACK_BY_T') && die('亲！您的网站还没有授权呢？');
class tocode {private $go_list;
public $go_code;
public $go_content;
public $cyrs;
public $count_time = '';
public function __construct() {$this -> db = System :: load_sys_class("model");
}public function run_tocode($time = '', $num = 100, $cyrs = '233') {if (empty($time))return false;
if (empty($num))return false;
if (empty($cyrs))return false;
$this -> cyrs = $cyrs;
$this -> go_list = $this -> db -> GetList("select * from `@#_member_go_record` where `status` = '已付款,未发货' and `time` < '$time' limit 0,$num");
if ($this -> go_list && count($this -> go_list) >= $num) {return $this -> get_code_dabai();
} else {return $this -> get_code_yibai($time, $this -> cyrs);
}}private function get_code_dabai() {$go_list = $this -> go_list;
$html = array();
$count_time = 0;
foreach($go_list as $key => $v) {$html[$key]['time'] = $v['time'];
$html[$key]['username'] = $v['username'];
$html[$key]['uid'] = $v['uid'];
$html[$key]['shopid'] = $v['shopid'];
$html[$key]['shopname'] = $v['shopname'];
$html[$key]['shopqishu'] = $v['shopqishu'];
$html[$key]['gonumber'] = $v['gonumber'];
$h = abs(date("H", $v['time']));
$i = date("i", $v['time']);
$s = date("s", $v['time']);
list($time, $ms) = explode(".", $v['time']);
$time = $h . $i . $s . $ms;
$html[$key]['timeadd'] = $time;
$count_time += $time;
}$this -> go_content = serialize($html);
$this -> count_time = $count_time;
$this -> go_code = 10000001 + fmod($count_time, $this -> cyrs);
}private function get_code_yibai($time = '', $money = '') {$h = abs(date("H", $time));
$i = date("i", $time);
$s = date("s", $time);
$w = substr($time, 11, 3);
$num = $h . $i . $s . $w;
if (!$money)$money = 1;
$this -> go_code = 10000001 + fmod($num * 100, $money);
$this -> go_content = false;
}}