| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 | <?php/** * CountryConfModel.php UTF-8 * * * @date    : 2017/12/19 11:18 * * @license 这不是一个自由软件,未经授权不许任何使用和传播。 * @author  : liguanglong <lgl@huosdk.com> * @version : HUOSDK 8.0 */namespace huo\model\district;use  huo\model\common\CommonModel;use think\Request;class CountryConfModel extends CommonModel {    protected $name = 'country_conf';    protected $field='mobile_prefix';    protected $field_txt = 'country';    /**     * @param $_data     *     * @return array     */    public function addCountryName($_data = array()) {        if (!is_array($_data)) {            return $_data;        }        $_where = [];        if (is_array($_data)) {            if (isset($_data[$this->field]) && !empty($_data[$this->field])) {                $_where[] = $_data[$this->field];            }            foreach ($_data as $_k=>$_v) {                if (!is_array($_v)) {                    break;                }                if (is_array($_v) && !empty($_v[$this->field])) {                    $_where[] = $_v[$this->field];                }            }        }        $_map['id'] = array('in', $_where);        $request = Request::instance();        $langSet = $request->langset();        if ('zh-cn' == $langSet) {            $_name = $this->where($_map)->column('id, cn_name_abbr');        } else if ('en-us' == $langSet) {            $_name = $this->where($_map)->column('id, en_name_abbr');        }        if (is_array($_data)) {            if (isset($_data[$this->field]) && !empty($_data[$this->field])) {                $_data[$this->field_txt] = $_name[$_data[$this->field]];            }            foreach ($_data as $_k=>$_v) {                if (!is_array($_v)) {                    break;                }                if (is_array($_v) && !empty($_v[$this->field])) {                    $_data[$_k][$this->field_txt] = $_name[$_v[$this->field]];                }            }        }        return $_data;    }    /**     * 获取所有国家的名称     */    public function getAllCountry() {        $_lang = cmf_current_lang();        if ('zh-cn' == $_lang) {            $_field = 'id country_id, cn_name_abbr country';        } else if ('en-us' == $_lang) {            $_field = 'id country_id, en_name_abbr country';        }        $_countries_data = $this->column($_field);        return $_countries_data;    }    /**     * 获取地址     */    public function getCountryAddr($_param) {        if(isset($_param['id']) && !empty($_param['id'])) {            $_map['id'] = $_param['id'];        } else {            return false;        }        $_data = $this->where($_map)->value('currency_abbr');        return $_data;    }}
 |