123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995 |
- <?php
- // +—————————————————————————————————————————————————————————————————————
- // | Created by Yunbao
- // +—————————————————————————————————————————————————————————————————————
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
- // +—————————————————————————————————————————————————————————————————————
- // | Author: https://gitee.com/yunbaokeji
- // +—————————————————————————————————————————————————————————————————————
- // | Date: 2022-02-17
- // +—————————————————————————————————————————————————————————————————————
- /**
- * 用户信息
- */
- if (!session_id()) session_start();
- class Api_User extends PhalApi_Api {
- public function getRules() {
- return array(
- 'iftoken' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- ),
-
- 'getBaseInfo' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- 'version_ios' => array('name' => 'version_ios', 'type' => 'string', 'desc' => 'IOS版本号'),
- ),
-
- 'updateAvatar' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- 'avatar' => array('name' => 'avatar', 'type' => 'string', 'desc' => '用户头像地址'),
- ),
-
- 'updateFields' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- 'fields' => array('name' => 'fields', 'type' => 'string', 'require' => true, 'desc' => '修改信息,json字符串'),
- ),
-
- 'updatePass' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- 'oldpass' => array('name' => 'oldpass', 'type' => 'string', 'require' => true, 'desc' => '旧密码'),
- 'pass' => array('name' => 'pass', 'type' => 'string', 'require' => true, 'desc' => '新密码'),
- 'pass2' => array('name' => 'pass2', 'type' => 'string', 'require' => true, 'desc' => '确认密码'),
- ),
-
- 'getBalance' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- 'type' => array('name' => 'type', 'type' => 'string', 'desc' => '设备类型,0android,1IOS'),
- 'version_ios' => array('name' => 'version_ios', 'type' => 'string', 'desc' => 'IOS版本号'),
- ),
-
- 'getProfit' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- ),
-
- 'setCash' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- 'accountid' => array('name' => 'accountid', 'type' => 'int', 'require' => true, 'desc' => '账号ID'),
- 'cashvote' => array('name' => 'cashvote', 'type' => 'int', 'require' => true, 'desc' => '提现的票数'),
- ),
-
- 'getBindCode' => array(
- 'mobile' => array('name' => 'mobile', 'type' => 'string', 'min' => 1, 'require' => true, 'desc' => '手机号'),
- ),
- 'getLiverecord' => array(
- 'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
- 'p' => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default'=>1,'desc' => '页数'),
- ),
-
- 'getUserHome' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'require' => true, 'desc' => '用户ID'),
- 'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
- ),
-
- 'getUserAccountList' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- ),
- 'setUserAccount' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- 'type' => array('name' => 'type', 'type' => 'int', 'require' => true, 'desc' => '账号类型,1表示支付宝,2表示微信,3表示银行卡'),
- 'account_bank' => array('name' => 'account_bank', 'type' => 'string', 'default' => '', 'desc' => '银行名称'),
- 'account' => array('name' => 'account', 'type' => 'string', 'require' => true, 'desc' => '账号'),
- 'name' => array('name' => 'name', 'type' => 'string', 'default' => '', 'desc' => '姓名'),
- ),
-
- 'delUserAccount' => array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- 'id' => array('name' => 'id', 'type' => 'int', 'require' => true, 'desc' => '账号ID'),
- ),
- 'getAuthInfo'=>array(
- 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
- 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
- ),
-
-
- );
- }
- /**
- * 判断token
- * @desc 用于判断token
- * @return int code 操作码,0表示成功, 1表示用户不存在
- * @return array info
- * @return string msg 提示信息
- */
- public function iftoken() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $checkToken=checkToken($this->uid,$this->token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
- return $rs;
- }
- /**
- * 获取用户信息
- * @desc 用于获取单个用户基本信息
- * @return int code 操作码,0表示成功, 1表示用户不存在
- * @return array info
- * @return array info[0] 用户信息
- * @return int info[0].id 用户ID
- * @return string info[0].level 等级
- * @return string info[0].lives 直播数量
- * @return string info[0].follows 关注数
- * @return string info[0].fans 粉丝数
- * @return string info[0].agent_switch 分销开关
- * @return string info[0].family_switch 家族开关
- * @return string msg 提示信息
- */
- public function getBaseInfo() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
- $domain = new Domain_User();
- $info = $domain->getBaseInfo($uid);
- if(!$info){
- $rs['code'] = 700;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
- /* 个人中心菜单 */
- $list=array();
- $list1=array();
- $shelves=1;
-
- $list1[]=array('id'=>'3','name'=>'等级','thumb'=>get_upload_path("/static/appapi/images/personal/level.png") ,'href'=>get_upload_path("/Appapi/Level/index"));
- if($shelves){
- $list1[]=array('id'=>'1','name'=>'收益','thumb'=>get_upload_path("/static/appapi/images/personal/votes.png"),'href'=>'' );
- }
- $list1[]=array('id'=>'11','name'=>'认证','thumb'=>get_upload_path("/static/appapi/images/personal/auth.png") ,'href'=>get_upload_path("/Appapi/Auth/index"));
- $list1[]=array('id'=>'26','name'=>'设置','thumb'=>get_upload_path("/static/appapi/images/personal/set.png") ,'href'=>'');
-
-
-
- $list[0]['list']=$list1;
- $info['list']=$list;
- $rs['info'][0] = $info;
- return $rs;
- }
- /**
- * 头像上传
- * @desc 用于用户修改头像
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string list[0].avatar 用户主头像
- * @return string list[0].avatar_thumb 用户头像缩略图
- * @return string msg 提示信息
- */
- public function updateAvatar() {
- $rs = array('code' => 0 , 'msg' => '设置头像成功', 'info' => array());
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
- $avatar_str=checkNull($this->avatar);
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
- //APP原生上传存储到数据库start
- if(!$avatar_str){
- $rs['code'] = 1001;
- $rs['msg'] = '请上传头像';
- return $rs;
- }
- $configpri=getConfigPri();
- $cloudtype=$configpri['cloudtype'];
- if($cloudtype==1){ //七牛云存储
- $avatar= $avatar_str.'?imageView2/2/w/600/h/600'; //600 X 600
- $avatar_thumb= $avatar_str.'?imageView2/2/w/200/h/200'; // 200 X 200
-
- }else{ //亚马逊存储
- $avatar=$avatar_str;
- $avatar_thumb=$avatar_str;
- }
- $data=array(
- "avatar"=>get_upload_path($avatar),
- "avatar_thumb"=>get_upload_path($avatar_thumb),
- );
- $data2=array(
- "avatar"=>$avatar,
- "avatar_thumb"=>$avatar_thumb,
- );
-
- //接口获取文件上传 存储到数据库end
- // 清除缓存
- delCache("userinfo_".$uid);
-
- $domain = new Domain_User();
- $info = $domain->userUpdate($uid,$data2);
- $rs['info'][0] = $data;
- return $rs;
- }
-
- /**
- * 修改用户信息
- * @desc 用于修改用户信息
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string list[0].msg 修改成功提示信息
- * @return string msg 提示信息
- */
- public function updateFields() {
- $rs = array('code' => 0, 'msg' => '修改成功', 'info' => array());
-
- $checkToken=checkToken($this->uid,$this->token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
- $fields=json_decode($this->fields,true);
-
- $allow=['user_nicename','sex','signature','birthday','location'];
- $domain = new Domain_User();
- foreach($fields as $k=>$v){
- if(in_array($k,$allow)){
- $fields[$k]=checkNull($v);
- }else{
- unset($fields[$k]);
- }
-
- }
-
- if(array_key_exists('user_nicename', $fields)){
- if($fields['user_nicename']==''){
- $rs['code'] = 1002;
- $rs['msg'] = '昵称不能为空';
- return $rs;
- }
- $isexist = $domain->checkName($this->uid,$fields['user_nicename']);
- if(!$isexist){
- $rs['code'] = 1002;
- $rs['msg'] = '昵称重复,请修改';
- return $rs;
- }
- if(strstr($fields['user_nicename'], '已注销')!==false){ //昵称包含已注销三个字
- $rs['code'] = 10011;
- $rs['msg'] = '输入非法,请重新输入';
- return $rs;
- }
- if(mb_substr($fields['user_nicename'], 0,1)=='='){
- $rs['code'] = 10011;
- $rs['msg'] = '输入非法,请重新输入';
- return $rs;
- }
- $sensitivewords=sensitiveField($fields['user_nicename']);
- if($sensitivewords==1001){
- $rs['code'] = 10011;
- $rs['msg'] = '输入非法,请重新输入';
- return $rs;
- }
- }
- if(array_key_exists('signature', $fields)){
- $sensitivewords=sensitiveField($fields['signature']);
- if($sensitivewords==1001){
- $rs['code'] = 10011;
- $rs['msg'] = '输入非法,请重新输入';
- return $rs;
- }
- }
-
- if(array_key_exists('birthday', $fields)){
- $fields['birthday']=strtotime($fields['birthday']);
- }
-
- $info = $domain->userUpdate($this->uid,$fields);
-
- if($info===false){
- $rs['code'] = 1001;
- $rs['msg'] = '修改失败';
- return $rs;
- }
- /* 清除缓存 */
- delCache("userinfo_".$this->uid);
- $rs['info'][0]['msg']='修改成功';
- return $rs;
- }
- /**
- * 修改密码
- * @desc 用于修改用户密码
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string list[0].msg 修改成功提示信息
- * @return string msg 提示信息
- */
- public function updatePass() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
- $oldpass=checkNull($this->oldpass);
- $pass=checkNull($this->pass);
- $pass2=checkNull($this->pass2);
-
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
-
- if($pass != $pass2){
- $rs['code'] = 1002;
- $rs['msg'] = '两次新密码不一致';
- return $rs;
- }
-
- $check = passcheck($pass);
- if(!$check ){
- $rs['code'] = 1004;
- $rs['msg'] = '密码为6-20位字母数字组合';
- return $rs;
- }
-
- $domain = new Domain_User();
- $info = $domain->updatePass($uid,$oldpass,$pass);
-
- if($info==1003){
- $rs['code'] = 1003;
- $rs['msg'] = '旧密码错误';
- return $rs;
- }else if($info===false){
- $rs['code'] = 1001;
- $rs['msg'] = '修改失败';
- return $rs;
- }
- $rs['info'][0]['msg']='修改成功';
- return $rs;
- }
-
- /**
- * 我的钻石
- * @desc 用于获取用户余额,充值规则 支付方式信息
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string info[0].coin 用户钻石余额
- * @return array info[0].rules 充值规则
- * @return string info[0].rules[].id 充值规则
- * @return string info[0].rules[].coin 钻石
- * @return string info[0].rules[].money 价格
- * @return string info[0].rules[].give 赠送钻石,为0时不显示赠送
- * @return string info[0].aliapp_switch 支付宝开关,0表示关闭,1表示开启
- * @return string info[0].aliapp_partner 支付宝合作者身份ID
- * @return string info[0].aliapp_seller_id 支付宝帐号
- * @return string info[0].aliapp_key_android 支付宝安卓密钥
- * @return string info[0].wx_switch 微信支付开关,0表示关闭,1表示开启
- * @return string info[0].wx_appid 开放平台账号AppID
- * @return string info[0].wx_appsecret 微信应用appsecret
- * @return string info[0].wx_mchid 微信商户号mchid
- * @return string info[0].wx_key 微信密钥key
- * @return string msg 提示信息
- */
- public function getBalance() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
- $type=checkNull($this->type);
- $version_ios=checkNull($this->version_ios);
-
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
-
- $domain = new Domain_User();
- $info = $domain->getBalance($uid);
-
- $key='getChargeRules';
- $rules=getcaches($key);
- if(!$rules){
- $rules= $domain->getChargeRules();
- setcaches($key,$rules);
- }
- $info['rules'] =$rules;
-
- $configpub=getConfigPub();
- $configpri=getConfigPri();
-
- $aliapp_switch=$configpri['aliapp_switch'];
-
- $info['aliapp_switch']=$aliapp_switch;
- $info['aliapp_partner']=$aliapp_switch==1?$configpri['aliapp_partner']:'';
- $info['aliapp_seller_id']=$aliapp_switch==1?$configpri['aliapp_seller_id']:'';
- $info['aliapp_key_android']=$aliapp_switch==1?$configpri['aliapp_key_android']:'';
- $wx_switch=$configpri['wx_switch'];
- $info['wx_switch']=$wx_switch;
- $info['wx_appid']=$wx_switch==1?$configpri['wx_appid']:'';
- $info['wx_appsecret']=$wx_switch==1?$configpri['wx_appsecret']:'';
- $info['wx_mchid']=$wx_switch==1?$configpri['wx_mchid']:'';
- $info['wx_key']=$wx_switch==1?$configpri['wx_key']:'';
- /* 支付列表 */
-
- $paylist=[];
- if($aliapp_switch){
- $paylist[]=[
- 'id'=>'ali',
- 'name'=>'支付宝支付',
- 'thumb'=>get_upload_path("/static/app/pay/ali.png"),
- 'href'=>'',
- ];
- }
-
- if($wx_switch){
- $paylist[]=[
- 'id'=>'wx',
- 'name'=>'微信支付',
- 'thumb'=>get_upload_path("/static/app/pay/wx.png"),
- 'href'=>'',
- ];
- }
-
-
- $info['paylist'] =$paylist;
- $info['tip_t'] =$configpub['name_coin'].'/'.$configpub['name_score'].'说明:';
- $info['tip_d'] =$configpub['name_coin'].'可通过平台提供的支付方式进行充值获得,'.$configpub['name_coin'].'适用于平台内所有消费; '.$configpub['name_score'].'可通过直播间内游戏奖励获得,所得'.$configpub['name_score'].'可用于平台商城内兑换会员、坐 骑、靓号等服务,不可提现。';
-
-
-
- $rs['info'][0]=$info;
- return $rs;
- }
-
- /**
- * 我的收益
- * @desc 用于获取用户收益,包括可体现金额,今日可提现金额
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string info[0].votes 可提取映票数
- * @return string info[0].votestotal 总映票
- * @return string info[0].cash_rate 映票兑换比例
- * @return string info[0].total 可提现金额
- * @return string info[0].tips 温馨提示
- * @return string msg 提示信息
- */
- public function getProfit() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
-
- $domain = new Domain_User();
- $info = $domain->getProfit($uid);
-
- $rs['info'][0]=$info;
- return $rs;
- }
-
- /**
- * 用户提现
- * @desc 用于进行用户提现
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string info[0].msg 提现成功信息
- * @return string msg 提示信息
- */
- public function setCash() {
- $rs = array('code' => 0, 'msg' => '提现成功', 'info' => array());
-
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
- $accountid=checkNull($this->accountid);
- $cashvote=checkNull($this->cashvote);
-
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
-
- if(!$accountid){
- $rs['code'] = 1001;
- $rs['msg'] = '请选择提现账号';
- return $rs;
- }
-
- if(!$cashvote){
- $rs['code'] = 1002;
- $rs['msg'] = '请输入有效的提现票数';
- return $rs;
- }
-
- $data=array(
- 'uid'=>$uid,
- 'accountid'=>$accountid,
- 'cashvote'=>$cashvote,
- );
- $config=getConfigPri();
- $domain = new Domain_User();
- $info = $domain->setCash($data);
- if($info==1001){
- $rs['code'] = 1001;
- $rs['msg'] = '您输入的金额大于可提现金额';
- return $rs;
- }else if($info==1003){
- $rs['code'] = 1003;
- $rs['msg'] = '请先进行身份认证';
- return $rs;
- }else if($info==1004){
- $rs['code'] = 1004;
- $rs['msg'] = '提现最低额度为'.$config['cash_min'].'元';
- return $rs;
- }else if($info==1005){
- $rs['code'] = 1005;
- $rs['msg'] = '不在提现期限内,不能提现';
- return $rs;
- }else if($info==1006){
- $rs['code'] = 1006;
- $rs['msg'] = '每月只可提现'.$config['cash_max_times'].'次,已达上限';
- return $rs;
- }else if($info==1007){
- $rs['code'] = 1007;
- $rs['msg'] = '提现账号信息不正确';
- return $rs;
- }else if(!$info){
- $rs['code'] = 1002;
- $rs['msg'] = '提现失败,请重试';
- return $rs;
- }
-
- $rs['info'][0]['msg']='提现成功';
- return $rs;
- }
-
-
-
-
- /**
- * 获取找回密码短信验证码
- * @desc 用于找回密码获取短信验证码
- * @return int code 操作码,0表示成功,2发送失败
- * @return array info
- * @return array info[0]
- * @return string msg 提示信息
- */
-
- public function getBindCode() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $mobile = checkNull($this->mobile);
-
- $ismobile=checkMobile($mobile);
- if(!$ismobile){
- $rs['code']=1001;
- $rs['msg']='请输入正确的手机号';
- return $rs;
- }
- if($_SESSION['set_mobile']==$mobile && $_SESSION['set_mobile_expiretime']> time() ){
- $rs['code']=1002;
- $rs['msg']='验证码5分钟有效,请勿多次发送';
- return $rs;
- }
- $mobile_code = random(6,1);
-
- /* 发送验证码 */
- $result=sendCode($mobile,$mobile_code);
- if($result['code']===0){
- $_SESSION['set_mobile'] = $mobile;
- $_SESSION['set_mobile_code'] = $mobile_code;
- $_SESSION['set_mobile_expiretime'] = time() +60*5;
- }else if($result['code']==667){
- $_SESSION['set_mobile'] = $mobile;
- $_SESSION['set_mobile_code'] = $result['msg'];
- $_SESSION['set_mobile_expiretime'] = time() +60*5;
-
- $rs['code']=1002;
- $rs['msg']='验证码为:'.$result['msg'];
-
- }else{
- $rs['code']=1002;
- $rs['msg']=$result['msg'];
- }
-
- return $rs;
- }
-
-
-
-
- /**
- * 直播记录
- * @desc 用于获取用户的直播记录
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string info[].nums 观看人数
- * @return string info[].datestarttime 格式化的开播时间
- * @return string info[].dateendtime 格式化的结束时间
- * @return string info[].video_url 回放地址
- * @return string info[].file_id 回放标示
- * @return string msg 提示信息
- */
- public function getLiverecord() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $touid=checkNull($this->touid);
- $p=checkNull($this->p);
- $domain = new Domain_User();
- $info = $domain->getLiverecord($touid,$p);
-
- $rs['info']=$info;
- return $rs;
- }
- /**
- * 个人主页
- * @desc 用于获取个人主页数据
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string info[0].islive 是否正在直播,0表示未直播,1表示直播
- * @return string info[0].livenums 直播数
- * @return array info[0].liverecord 直播记录
- * @return string msg 提示信息
- */
- public function getUserHome() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $uid=checkNull($this->uid);
- $touid=checkNull($this->touid);
-
- $domain = new Domain_User();
- $info=$domain->getUserHome($uid,$touid);
-
- $rs['info'][0]=$info;
- return $rs;
- }
-
-
-
-
- /**
- * 获取个性设置列表
- * @desc 用于获取个性设置列表
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string msg 提示信息
- */
- public function getPerSetting() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
- $domain = new Domain_User();
- $info = $domain->getPerSetting();
- $info[]=array('id'=>'15','name'=>'修改密码','thumb'=>'' ,'href'=>'');
- $info[]=array('id'=>'18','name'=>'清除缓存','thumb'=>'' ,'href'=>'');
- $info[]=array('id'=>'16','name'=>'检查更新','thumb'=>'' ,'href'=>'');
-
- $rs['info']=$info;
- return $rs;
- }
- /**
- * 获取用户提现账号
- * @desc 用于获取用户提现账号
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string info[].id 账号ID
- * @return string info[].type 账号类型
- * @return string info[].account_bank 银行名称
- * @return string info[].account 账号
- * @return string info[].name 姓名
- * @return string msg 提示信息
- */
- public function getUserAccountList() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
-
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
-
- $domain = new Domain_User();
- $info = $domain->getUserAccountList($uid);
- $rs['info']=$info;
- return $rs;
- }
- /**
- * 添加提现账号
- * @desc 用于添加提现账号
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string msg 提示信息
- */
- public function setUserAccount() {
- $rs = array('code' => 0, 'msg' => '添加成功', 'info' => array());
-
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
-
- $type=checkNull($this->type);
- $account_bank=checkNull($this->account_bank);
- $account=checkNull($this->account);
- $name=checkNull($this->name);
- if($type==3){
- if($account_bank==''){
- $rs['code'] = 1001;
- $rs['msg'] = '银行名称不能为空';
- return $rs;
- }
- }
-
- if($account==''){
- $rs['code'] = 1002;
- $rs['msg'] = '账号不能为空';
- return $rs;
- }
-
-
- if(mb_strlen($account)>40){
- $rs['code'] = 1002;
- $rs['msg'] = '账号长度不能超过40个字符';
- return $rs;
- }
-
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
-
- $data=array(
- 'uid'=>$uid,
- 'type'=>$type,
- 'account_bank'=>$account_bank,
- 'account'=>$account,
- 'name'=>$name,
- 'addtime'=>time(),
- );
-
- $domain = new Domain_User();
- $where=[
- 'uid'=>$uid,
- 'type'=>$type,
- 'account_bank'=>$account_bank,
- 'account'=>$account,
- ];
- $isexist=$domain->getUserAccount($where);
- if($isexist){
- $rs['code'] = 1004;
- $rs['msg'] = '账号已存在';
- return $rs;
- }
-
- $result = $domain->setUserAccount($data);
- if(!$result){
- $rs['code'] = 1003;
- $rs['msg'] = '添加失败,请重试';
- return $rs;
- }
-
- $rs['info'][0]=$result;
- return $rs;
- }
- /**
- * 删除用户提现账号
- * @desc 用于删除用户提现账号
- * @return int code 操作码,0表示成功
- * @return array info
- * @return string msg 提示信息
- */
- public function delUserAccount() {
- $rs = array('code' => 0, 'msg' => '删除成功', 'info' => array());
-
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
-
- $id=checkNull($this->id);
-
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
-
- $data=array(
- 'uid'=>$uid,
- 'id'=>$id,
- );
-
- $domain = new Domain_User();
- $result = $domain->delUserAccount($data);
- if(!$result){
- $rs['code'] = 1003;
- $rs['msg'] = '删除失败,请重试';
- return $rs;
- }
- return $rs;
- }
- /**
- * 获取用户的认证信息
- * @desc 用于获取用户的认证信息
- * @return int code 状态码,0表示成功
- * @return string msg 提示信息
- * @return array info 返回信息
- */
- public function getAuthInfo(){
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $uid=checkNull($this->uid);
- $token=checkNull($this->token);
- $checkToken=checkToken($uid,$token);
- if($checkToken==700){
- $rs['code'] = $checkToken;
- $rs['msg'] = '您的登陆状态失效,请重新登陆!';
- return $rs;
- }
- $isauth=isAuth($uid);
- if(!$isauth){
- $rs['code']=1001;
- $rs['msg']='请先进行实名认证';
- return $rs;
- }
- $domain=new Domain_User();
- $res=$domain->getAuthInfo($uid);
- $rs['info'][0]=$res;
- return $rs;
- }
- /**
- * 获取七牛上传Token
- * @desc 用于获取七牛上传Token
- * @return int code 操作码,0表示成功
- * @return string msg 提示信息
- */
- public function getQiniuToken(){
- $rs = array('code' => 0, 'msg' => '', 'info' =>array());
- //获取后台配置的腾讯云存储信息
- $Qiniu=DI()->config->get('app.Qiniu');
-
- require_once API_ROOT.'/../sdk/qiniu/autoload.php';
-
- // 需要填写你的 Access Key 和 Secret Key
- // 需要填写你的 Access Key 和 Secret Key
- $accessKey =$Qiniu['accessKey'];// $configpri['qiniu_accesskey'];
-
- $secretKey = $Qiniu['secretKey'];//$configpri['qiniu_secretkey'];
- $bucket =$Qiniu['space_bucket'];// $configpri['qiniu_bucket'];
- $qiniu_domain_url = $Qiniu['space_host'];
- // 构建鉴权对象
- $auth = new Qiniu\Auth($accessKey, $secretKey);
- // 生成上传 Token
- $token = $auth->uploadToken($bucket);
- $rs['info'][0]['token']=$token ;
- return $rs;
-
- }
-
- }
|