| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 | <?phpnamespace console\index\controller;use huo\controller\request\Channel;use huo\controller\request\Device;use huo\controller\request\Game;use huo\controller\request\Mem;use huo\model\log\MemLoginLogModel;use huo\model\member\MemberModel;use huo\model\order\OrderModel;use think\Controller;class Index extends Controller {    protected $rq_data = [];    protected $g_i;    public function index() {//        $this->create();//        $this->login();//        $this->charge();        echo 'test';        exit;    }    /**     * 添加游戏     */    public function addGame() {    }    /**     * 创建账号     *     * @throws \think\db\exception\DataNotFoundException     * @throws \think\db\exception\ModelNotFoundException     * @throws \think\exception\DbException     */    public function create() {        $_map['create_time'] = ['between', ['1527782400', '2527782400']];        $_map = [];        $_data = (new MemberModel())->with('ext')->where($_map)->field('id,username,app_id,create_time,update_time')                                    ->select();        $_cnt = 0;        foreach ($_data as $_k => $_v) {            $_v = $_v->toArray();            print_r($_v['id'].' ');//            print_r('<br>');            $_game_rq = $this->setGameData();            $_channel_rq = $this->setChannelData();            $_device_rq = $this->setDeviceData();            $_mem_rq = $this->setMemData();            $_mem_rq->setMemId($_v['id']);            /* 异步处理数据 */            $_mem_rq->setRegTime($_v['create_time']);            $_mem_rq->setLoginTime($_v['ext']['last_login_time']);            $_channel_rq->setCh($_v['agent_id']);            $_game_rq->setHAppId($_v['app_id']);            (new \huo\controller\queue\Mem($_game_rq->getHAppId()))->create(                $_device_rq, $_game_rq, $_channel_rq, $_mem_rq            );            $_cnt++;        }        $this->g_i += $_cnt;        print_r('create ok'.PHP_EOL.$_cnt);    }    /**     * 玩家登陆     *     * @throws \think\db\exception\DataNotFoundException     * @throws \think\db\exception\ModelNotFoundException     * @throws \think\exception\DbException     */    public function login() {        $_cnt = 0;        for ($_i = 5; $_i < 7; $_i++) {            $_date = '2018-0'.$_i;            $_data = (new MemLoginLogModel())->computeTable($_date)->where('mem_id>0')->select();            foreach ($_data as $_k => $_v) {                $_v = $_v->toArray();                print_r($_v['id'].' ');                $_game_rq = $this->setGameData();                $_channel_rq = $this->setChannelData();                $_device_rq = $this->setDeviceData();                $_mem_rq = $this->setMemData();                /* 异步处理数据 */                $_mem_rq->setMemId($_v['mem_id']);                $_mem_rq->setMgMemId($_v['mg_mem_id']);                $_mem_rq->setRegTime($_v['reg_time']);                $_mem_rq->setLoginTime($_v['create_time']);                $_channel_rq->setCh($_v['agent_id']);                $_game_rq->setHAppId($_v['app_id']);                (new \huo\controller\queue\Mem($_game_rq->getHAppId()))->online(                    $_device_rq, $_game_rq, $_channel_rq, $_mem_rq                );                $_cnt++;            }        }        $this->g_i += $_cnt;        print_r('login ok'.PHP_EOL.$_cnt);    }    /**     * 玩家充值     */    public function charge() {        $_map['status'] = 2;        $_order_ids = (new OrderModel())->where($_map)->limit(0, 100000)->order('id asc')->column('order_id');        foreach ($_order_ids as $_k => $order_id) {            print_r($order_id.' ');            (new \huo\controller\queue\Order())->fromSdkOrder($order_id);        }        $this->g_i += count($_order_ids);        $_map['order_id'] = ['in', $_order_ids];        print_r((new OrderModel())->where($_map)->order('id asc')->sum('amount'));        print_r(PHP_EOL.'g_i='.$this->g_i);    }    /**     * @return Device     */    public function setDeviceData() {        $_device = new Device();        return $_device;    }    /**     * @return Game     */    public function setGameData() {        $_game = new Game();        return $_game;    }    /**     * @return Channel     *     */    public function setChannelData() {        $_channel = new Channel();        return $_channel;    }    /**     * 设置玩家入参     *     * @param bool $is_reg     *     * @return Mem     */    public function setMemData($is_reg = false) {        $_mem = new Mem();        return $_mem;    }}
 |