public function idcode() { $config = new MemberConfigApi(); $map = array('uid' => array('gt', 30)); $page = array('curpage' => 1, 'size' => 100); $result = $config->query($map, $page); $list = $result['info']['list']; foreach ($list as $vo) { $entity = array('IDCode' => $this->getIDCode($vo['uid'])); $result = $config->saveByID($vo['uid'], $entity); } }
/** * POST: 注册 * username 用户名 * password 密码 * mobile 手机 * realname真实姓名 * email 电子邮箱 * idnumber身份证号 * birthday生日 */ public function register() { $notes = "应用" . $this->client_id . ",调用注册接口"; addLog("User/register", $_GET, $_POST, $notes); if (IS_POST) { $device_id = $this->_post("device_id", ''); $device_type = $this->_post("device_type", ''); if (empty($device_id)) { $device_id = time(); } if (empty($device_type)) { $device_type = 2; } $entity = array('device_id' => $device_id, 'device_type' => $device_type); $result = apiCall(DevicePhoneApi::GET_INFO, array($entity)); addLog("User/register", $entity, $result, "检测该手机是否已注册"); if ($result['status'] && is_array($result['info'])) { $this->apiReturnErr('一台手机只能注册一个帐号!'); } $entity['create_time'] = time(); $result = apiCall(DevicePhoneApi::ADD, array($entity)); if (!$result['status']) { $this->error("登录失败(code=-2)"); } $type = $this->_post("type", 1); $username = $this->_post("username", ""); $from = $this->_post("from", ""); $invite_code = $this->_post("invite_code", ""); $invite_id = 0; $invite_code = strtolower($invite_code); $map = array('IDCode' => $invite_code); $result = apiCall(MemberConfigApi::GET_INFO, array($map)); if ($result['status'] && is_array($result['info'])) { $member = $result['info']; $invite_id = $member['uid']; } addLog("User/register", $invite_id, $invite_code, "邀请人ID与邀请码"); $error = $this->isLegal($type, $username, $from); if (!($error === false)) { $this->apiReturnErr($error); } $password = $this->_post("password"); $email = ""; $mobile = ""; $idcode = $username; if ($type == UcenterMemberModel::ACCOUNT_TYPE_EMAIL) { $email = $username; } elseif ($type == UcenterMemberModel::ACCOUNT_TYPE_MOBILE) { $mobile = $username; $username = '******' . $mobile; $idcode = $mobile; } if (strlen($idcode) >= 6) { $idcode = substr($idcode, strlen($idcode) - 6, 6); } if (empty($idcode)) { $this->apiReturnErr("注册失败!请重试"); } $nickname = $this->_post("nickname", ""); if (empty($nickname)) { $nickname = '昵称' . $mobile; } $entity = array('username' => $username, 'password' => $password, 'from' => $from, 'mobile' => $mobile, 'realname' => '', 'nickname' => $nickname, 'email' => $email, 'idnumber' => '', 'birthday' => time(), 'idcode' => $idcode, 'type' => $type, 'invite_id' => $invite_id); $result = apiCall(AccountApi::REGISTER, array($entity)); if ($result['status']) { // $member_config = new MemberConfigApi(); $entity = array('IDCode' => $this->getIDCode($result['info'])); $member_config->saveByID($result['info'], $entity); //生成IDCode //赠送流量包 $this->giveFlowPacketTo($invite_id, $mobile); $this->apiReturnSuc("注册成功"); } else { $this->apiReturnErr($result['info']); } } else { $this->apiReturnErr("只支持POST请求!"); } }