<?php
namespace Biz\Common;

class Common {

    public function addUrlLog($params) {
//        ini_set("display_errors", "On");
//        error_reporting(E_ALL | E_STRICT);
        $data = array();
        $data['account_identity'] = $params['account_identity'];
        $data['account'] = $params['account'];
        $data['ip'] = $params['ip'];
        $data['url'] = $params['url'];
        $data['name'] = $params['name'];
        $data['add_time'] = $params['add_time'];
        $data['type'] = $params['type'] ? $params['type'] : 0;
        $data['bak'] = $params['bak'];
        $data['orderid'] = $params['orderid'];
        $re = lm('orderurl', 'commons')->insert($data);
        if (!$re) {
            Render('', -3309); //插入查询订单来源为空
        }
        return 1;
    }

    /**
     * 玩法语言包数组
     * @return array
     */
    public function getGameLangs(): array {
        $gl = lm('Game_type', 'Commons')->where('table_name', '<>', '-1')->pluck('table_name')->toArray();
        $arr = [];
        foreach ($gl as $k => $v) {
            $t = lang(ucfirst($v))->getAll();
            $arr = array_merge($arr, $t);
        }

        $arr = array_unique($arr);
        ksort($arr);
        return ($arr);
        //not done blow;
        $tmp = [];
        foreach ($arr as $k => $v) {
            $kArr = explode('-', $k);
            $vArr = explode('-', $v);
            if (isset($kArr[1])) {
                $tmp[$kArr[1]] = $vArr[1];
            }
            $tmp[$kArr[0]] = $vArr[0];
        }
        ksort($tmp);
        return array_unique($tmp);
    }

}

?>
