<?php

/**
 * Notes:测试model
 * User : wsc
 * Date : 2020/1/11 16:22
 * Class ModelA_test
 */
class ModelA_test{
    /**
     * Notes:
     * User : wsc
     * Date : 2020/1/9 18:05
     * @param $uid
     * @param $data
     * @return bool|mysqli_result
     */
    public function addOneLog($uid,$data){
        $insertDate['uid'] = $uid;
        $insertDate['ts'] = $data['ts'];
        $insertDate['type'] = $data['type'];
        $table = "crazyGod_api_user.t_test_log";
        $sql = "INSERT INTO {$table} (uid,ts,type) VALUES ({$uid},{$insertDate['ts']},{$insertDate['type']})";
//        oo::logs()->commlog( oo::$config['db_common'], 'async/dbconf' );
        $res = oo::commonOprDb('common')->query($sql);
        return $res;
    }

    public function dbSlotLog(){
        for ($i=0;$i<10000;$i++){
            $uid = rand(0,99);
            $table = otable::slotlog($uid);
            $sql = sprintf("INSERT INTO %s (`uid`, `type`, `first_money`, `first_energy`, `first_shield`, `addnum`, `multiple`, `last_money`, `last_energy`, `last_shield`, `slotid`, `slottype`, `time`, `remark`) VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,'%s')",$table,$uid,1,1,1,1,1,1,1,1,1,1,1,time(),'测试');
            oo::commonOprDb('slotlog')->query($sql);
            if ( oo::commonOprDb('slotlog')->affectedRows() <= 0 ) { //插入失败
                return array(0=>-9, 1=>'7,4,5', 2=>0, 3=>0);
            }
        }
    }

    public function redisSlotLog(){
        for ($i=0;$i<10000;$i++){
            oo::commonOprModel('asynclog')->push("SLOT",[
                'uid'  =>rand(0,99),
                'type' =>1,
                'first_money'=>1,
                'first_energy'=>1,
                'first_shield'=>1,
                'addnum'=>1,
                'multiple'=>1,
                'last_money'=>1,
                'last_energy'=>1,
                'last_shield'=>1,
                'slotid'=>1,
                'slottype'=>1,
                'time'=>time(),
                'remark'=>"測試",
            ]);
        }
        oo::commonOprModel('asynclog')->cacheIntoDb();
    }

}
