12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- /**
- * MemBaseModel.php UTF-8
- * 获取用户ID
- *
- * @date : 2018/4/24 20:13
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\model\member;
- use huo\model\common\CommonModel;
- class MemBaseModel extends CommonModel {
- protected $name = 'mem_base';
- public function genUsername($prefix = 't') {
- $_base_num = 10000;
- // 生成用户名
- $_min = $this->min('base');
- $_map['base'] = $_min;
- $_cnt = $this->where($_map)->count('id');
- $_limit = rand(0, $_cnt);
- $_sql_limit = "$_limit,1";
- $_mem_id = $this->where($_map)->limit($_sql_limit)->value('id');
- $_rs = $this->where('id', $_mem_id)->setInc('base');
- $_username = false;
- if (false != $_rs) {
- $_username = $_base_num * $_min + $_mem_id;
- $_username = $prefix.$_username.rand(100, 999);
- }
- return $_username;
- }
- }
|