User.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-02-17
  10. // +—————————————————————————————————————————————————————————————————————
  11. /**
  12. * 用户信息
  13. */
  14. if (!session_id()) session_start();
  15. class Api_User extends PhalApi_Api {
  16. public function getRules() {
  17. return array(
  18. 'iftoken' => array(
  19. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  20. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  21. ),
  22. 'getBaseInfo' => array(
  23. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  24. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  25. 'version_ios' => array('name' => 'version_ios', 'type' => 'string', 'desc' => 'IOS版本号'),
  26. ),
  27. 'updateAvatar' => array(
  28. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  29. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  30. 'avatar' => array('name' => 'avatar', 'type' => 'string', 'desc' => '用户头像地址'),
  31. ),
  32. 'updateFields' => array(
  33. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  34. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  35. 'fields' => array('name' => 'fields', 'type' => 'string', 'require' => true, 'desc' => '修改信息,json字符串'),
  36. ),
  37. 'updatePass' => array(
  38. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  39. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  40. 'oldpass' => array('name' => 'oldpass', 'type' => 'string', 'require' => true, 'desc' => '旧密码'),
  41. 'pass' => array('name' => 'pass', 'type' => 'string', 'require' => true, 'desc' => '新密码'),
  42. 'pass2' => array('name' => 'pass2', 'type' => 'string', 'require' => true, 'desc' => '确认密码'),
  43. ),
  44. 'getBalance' => array(
  45. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  46. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  47. 'type' => array('name' => 'type', 'type' => 'string', 'desc' => '设备类型,0android,1IOS'),
  48. 'version_ios' => array('name' => 'version_ios', 'type' => 'string', 'desc' => 'IOS版本号'),
  49. ),
  50. 'getProfit' => array(
  51. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  52. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  53. ),
  54. 'setCash' => array(
  55. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  56. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  57. 'accountid' => array('name' => 'accountid', 'type' => 'int', 'require' => true, 'desc' => '账号ID'),
  58. 'cashvote' => array('name' => 'cashvote', 'type' => 'int', 'require' => true, 'desc' => '提现的票数'),
  59. ),
  60. 'getBindCode' => array(
  61. 'mobile' => array('name' => 'mobile', 'type' => 'string', 'min' => 1, 'require' => true, 'desc' => '手机号'),
  62. ),
  63. 'getLiverecord' => array(
  64. 'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
  65. 'p' => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default'=>1,'desc' => '页数'),
  66. ),
  67. 'getUserHome' => array(
  68. 'uid' => array('name' => 'uid', 'type' => 'int', 'require' => true, 'desc' => '用户ID'),
  69. 'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
  70. ),
  71. 'getUserAccountList' => array(
  72. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  73. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  74. ),
  75. 'setUserAccount' => array(
  76. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  77. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  78. 'type' => array('name' => 'type', 'type' => 'int', 'require' => true, 'desc' => '账号类型,1表示支付宝,2表示微信,3表示银行卡'),
  79. 'account_bank' => array('name' => 'account_bank', 'type' => 'string', 'default' => '', 'desc' => '银行名称'),
  80. 'account' => array('name' => 'account', 'type' => 'string', 'require' => true, 'desc' => '账号'),
  81. 'name' => array('name' => 'name', 'type' => 'string', 'default' => '', 'desc' => '姓名'),
  82. ),
  83. 'delUserAccount' => array(
  84. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  85. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  86. 'id' => array('name' => 'id', 'type' => 'int', 'require' => true, 'desc' => '账号ID'),
  87. ),
  88. 'getAuthInfo'=>array(
  89. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  90. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  91. ),
  92. );
  93. }
  94. /**
  95. * 判断token
  96. * @desc 用于判断token
  97. * @return int code 操作码,0表示成功, 1表示用户不存在
  98. * @return array info
  99. * @return string msg 提示信息
  100. */
  101. public function iftoken() {
  102. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  103. $checkToken=checkToken($this->uid,$this->token);
  104. if($checkToken==700){
  105. $rs['code'] = $checkToken;
  106. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  107. return $rs;
  108. }
  109. return $rs;
  110. }
  111. /**
  112. * 获取用户信息
  113. * @desc 用于获取单个用户基本信息
  114. * @return int code 操作码,0表示成功, 1表示用户不存在
  115. * @return array info
  116. * @return array info[0] 用户信息
  117. * @return int info[0].id 用户ID
  118. * @return string info[0].level 等级
  119. * @return string info[0].lives 直播数量
  120. * @return string info[0].follows 关注数
  121. * @return string info[0].fans 粉丝数
  122. * @return string info[0].agent_switch 分销开关
  123. * @return string info[0].family_switch 家族开关
  124. * @return string msg 提示信息
  125. */
  126. public function getBaseInfo() {
  127. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  128. $uid=checkNull($this->uid);
  129. $token=checkNull($this->token);
  130. $checkToken=checkToken($uid,$token);
  131. if($checkToken==700){
  132. $rs['code'] = $checkToken;
  133. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  134. return $rs;
  135. }
  136. $domain = new Domain_User();
  137. $info = $domain->getBaseInfo($uid);
  138. if(!$info){
  139. $rs['code'] = 700;
  140. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  141. return $rs;
  142. }
  143. /* 个人中心菜单 */
  144. $list=array();
  145. $list1=array();
  146. $shelves=1;
  147. $list1[]=array('id'=>'3','name'=>'等级','thumb'=>get_upload_path("/static/appapi/images/personal/level.png") ,'href'=>get_upload_path("/Appapi/Level/index"));
  148. if($shelves){
  149. $list1[]=array('id'=>'1','name'=>'收益','thumb'=>get_upload_path("/static/appapi/images/personal/votes.png"),'href'=>'' );
  150. }
  151. $list1[]=array('id'=>'11','name'=>'认证','thumb'=>get_upload_path("/static/appapi/images/personal/auth.png") ,'href'=>get_upload_path("/Appapi/Auth/index"));
  152. $list1[]=array('id'=>'26','name'=>'设置','thumb'=>get_upload_path("/static/appapi/images/personal/set.png") ,'href'=>'');
  153. $list[0]['list']=$list1;
  154. $info['list']=$list;
  155. $rs['info'][0] = $info;
  156. return $rs;
  157. }
  158. /**
  159. * 头像上传
  160. * @desc 用于用户修改头像
  161. * @return int code 操作码,0表示成功
  162. * @return array info
  163. * @return string list[0].avatar 用户主头像
  164. * @return string list[0].avatar_thumb 用户头像缩略图
  165. * @return string msg 提示信息
  166. */
  167. public function updateAvatar() {
  168. $rs = array('code' => 0 , 'msg' => '设置头像成功', 'info' => array());
  169. $uid=checkNull($this->uid);
  170. $token=checkNull($this->token);
  171. $avatar_str=checkNull($this->avatar);
  172. $checkToken=checkToken($uid,$token);
  173. if($checkToken==700){
  174. $rs['code'] = $checkToken;
  175. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  176. return $rs;
  177. }
  178. //APP原生上传存储到数据库start
  179. if(!$avatar_str){
  180. $rs['code'] = 1001;
  181. $rs['msg'] = '请上传头像';
  182. return $rs;
  183. }
  184. $configpri=getConfigPri();
  185. $cloudtype=$configpri['cloudtype'];
  186. if($cloudtype==1){ //七牛云存储
  187. $avatar= $avatar_str.'?imageView2/2/w/600/h/600'; //600 X 600
  188. $avatar_thumb= $avatar_str.'?imageView2/2/w/200/h/200'; // 200 X 200
  189. }else{ //亚马逊存储
  190. $avatar=$avatar_str;
  191. $avatar_thumb=$avatar_str;
  192. }
  193. $data=array(
  194. "avatar"=>get_upload_path($avatar),
  195. "avatar_thumb"=>get_upload_path($avatar_thumb),
  196. );
  197. $data2=array(
  198. "avatar"=>$avatar,
  199. "avatar_thumb"=>$avatar_thumb,
  200. );
  201. //接口获取文件上传 存储到数据库end
  202. // 清除缓存
  203. delCache("userinfo_".$uid);
  204. $domain = new Domain_User();
  205. $info = $domain->userUpdate($uid,$data2);
  206. $rs['info'][0] = $data;
  207. return $rs;
  208. }
  209. /**
  210. * 修改用户信息
  211. * @desc 用于修改用户信息
  212. * @return int code 操作码,0表示成功
  213. * @return array info
  214. * @return string list[0].msg 修改成功提示信息
  215. * @return string msg 提示信息
  216. */
  217. public function updateFields() {
  218. $rs = array('code' => 0, 'msg' => '修改成功', 'info' => array());
  219. $checkToken=checkToken($this->uid,$this->token);
  220. if($checkToken==700){
  221. $rs['code'] = $checkToken;
  222. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  223. return $rs;
  224. }
  225. $fields=json_decode($this->fields,true);
  226. $allow=['user_nicename','sex','signature','birthday','location'];
  227. $domain = new Domain_User();
  228. foreach($fields as $k=>$v){
  229. if(in_array($k,$allow)){
  230. $fields[$k]=checkNull($v);
  231. }else{
  232. unset($fields[$k]);
  233. }
  234. }
  235. if(array_key_exists('user_nicename', $fields)){
  236. if($fields['user_nicename']==''){
  237. $rs['code'] = 1002;
  238. $rs['msg'] = '昵称不能为空';
  239. return $rs;
  240. }
  241. $isexist = $domain->checkName($this->uid,$fields['user_nicename']);
  242. if(!$isexist){
  243. $rs['code'] = 1002;
  244. $rs['msg'] = '昵称重复,请修改';
  245. return $rs;
  246. }
  247. if(strstr($fields['user_nicename'], '已注销')!==false){ //昵称包含已注销三个字
  248. $rs['code'] = 10011;
  249. $rs['msg'] = '输入非法,请重新输入';
  250. return $rs;
  251. }
  252. if(mb_substr($fields['user_nicename'], 0,1)=='='){
  253. $rs['code'] = 10011;
  254. $rs['msg'] = '输入非法,请重新输入';
  255. return $rs;
  256. }
  257. $sensitivewords=sensitiveField($fields['user_nicename']);
  258. if($sensitivewords==1001){
  259. $rs['code'] = 10011;
  260. $rs['msg'] = '输入非法,请重新输入';
  261. return $rs;
  262. }
  263. }
  264. if(array_key_exists('signature', $fields)){
  265. $sensitivewords=sensitiveField($fields['signature']);
  266. if($sensitivewords==1001){
  267. $rs['code'] = 10011;
  268. $rs['msg'] = '输入非法,请重新输入';
  269. return $rs;
  270. }
  271. }
  272. if(array_key_exists('birthday', $fields)){
  273. $fields['birthday']=strtotime($fields['birthday']);
  274. }
  275. $info = $domain->userUpdate($this->uid,$fields);
  276. if($info===false){
  277. $rs['code'] = 1001;
  278. $rs['msg'] = '修改失败';
  279. return $rs;
  280. }
  281. /* 清除缓存 */
  282. delCache("userinfo_".$this->uid);
  283. $rs['info'][0]['msg']='修改成功';
  284. return $rs;
  285. }
  286. /**
  287. * 修改密码
  288. * @desc 用于修改用户密码
  289. * @return int code 操作码,0表示成功
  290. * @return array info
  291. * @return string list[0].msg 修改成功提示信息
  292. * @return string msg 提示信息
  293. */
  294. public function updatePass() {
  295. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  296. $uid=checkNull($this->uid);
  297. $token=checkNull($this->token);
  298. $oldpass=checkNull($this->oldpass);
  299. $pass=checkNull($this->pass);
  300. $pass2=checkNull($this->pass2);
  301. $checkToken=checkToken($uid,$token);
  302. if($checkToken==700){
  303. $rs['code'] = $checkToken;
  304. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  305. return $rs;
  306. }
  307. if($pass != $pass2){
  308. $rs['code'] = 1002;
  309. $rs['msg'] = '两次新密码不一致';
  310. return $rs;
  311. }
  312. $check = passcheck($pass);
  313. if(!$check ){
  314. $rs['code'] = 1004;
  315. $rs['msg'] = '密码为6-20位字母数字组合';
  316. return $rs;
  317. }
  318. $domain = new Domain_User();
  319. $info = $domain->updatePass($uid,$oldpass,$pass);
  320. if($info==1003){
  321. $rs['code'] = 1003;
  322. $rs['msg'] = '旧密码错误';
  323. return $rs;
  324. }else if($info===false){
  325. $rs['code'] = 1001;
  326. $rs['msg'] = '修改失败';
  327. return $rs;
  328. }
  329. $rs['info'][0]['msg']='修改成功';
  330. return $rs;
  331. }
  332. /**
  333. * 我的钻石
  334. * @desc 用于获取用户余额,充值规则 支付方式信息
  335. * @return int code 操作码,0表示成功
  336. * @return array info
  337. * @return string info[0].coin 用户钻石余额
  338. * @return array info[0].rules 充值规则
  339. * @return string info[0].rules[].id 充值规则
  340. * @return string info[0].rules[].coin 钻石
  341. * @return string info[0].rules[].money 价格
  342. * @return string info[0].rules[].give 赠送钻石,为0时不显示赠送
  343. * @return string info[0].aliapp_switch 支付宝开关,0表示关闭,1表示开启
  344. * @return string info[0].aliapp_partner 支付宝合作者身份ID
  345. * @return string info[0].aliapp_seller_id 支付宝帐号
  346. * @return string info[0].aliapp_key_android 支付宝安卓密钥
  347. * @return string info[0].wx_switch 微信支付开关,0表示关闭,1表示开启
  348. * @return string info[0].wx_appid 开放平台账号AppID
  349. * @return string info[0].wx_appsecret 微信应用appsecret
  350. * @return string info[0].wx_mchid 微信商户号mchid
  351. * @return string info[0].wx_key 微信密钥key
  352. * @return string msg 提示信息
  353. */
  354. public function getBalance() {
  355. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  356. $uid=checkNull($this->uid);
  357. $token=checkNull($this->token);
  358. $type=checkNull($this->type);
  359. $version_ios=checkNull($this->version_ios);
  360. $checkToken=checkToken($uid,$token);
  361. if($checkToken==700){
  362. $rs['code'] = $checkToken;
  363. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  364. return $rs;
  365. }
  366. $domain = new Domain_User();
  367. $info = $domain->getBalance($uid);
  368. $key='getChargeRules';
  369. $rules=getcaches($key);
  370. if(!$rules){
  371. $rules= $domain->getChargeRules();
  372. setcaches($key,$rules);
  373. }
  374. $info['rules'] =$rules;
  375. $configpub=getConfigPub();
  376. $configpri=getConfigPri();
  377. $aliapp_switch=$configpri['aliapp_switch'];
  378. $info['aliapp_switch']=$aliapp_switch;
  379. $info['aliapp_partner']=$aliapp_switch==1?$configpri['aliapp_partner']:'';
  380. $info['aliapp_seller_id']=$aliapp_switch==1?$configpri['aliapp_seller_id']:'';
  381. $info['aliapp_key_android']=$aliapp_switch==1?$configpri['aliapp_key_android']:'';
  382. $wx_switch=$configpri['wx_switch'];
  383. $info['wx_switch']=$wx_switch;
  384. $info['wx_appid']=$wx_switch==1?$configpri['wx_appid']:'';
  385. $info['wx_appsecret']=$wx_switch==1?$configpri['wx_appsecret']:'';
  386. $info['wx_mchid']=$wx_switch==1?$configpri['wx_mchid']:'';
  387. $info['wx_key']=$wx_switch==1?$configpri['wx_key']:'';
  388. /* 支付列表 */
  389. $paylist=[];
  390. if($aliapp_switch){
  391. $paylist[]=[
  392. 'id'=>'ali',
  393. 'name'=>'支付宝支付',
  394. 'thumb'=>get_upload_path("/static/app/pay/ali.png"),
  395. 'href'=>'',
  396. ];
  397. }
  398. if($wx_switch){
  399. $paylist[]=[
  400. 'id'=>'wx',
  401. 'name'=>'微信支付',
  402. 'thumb'=>get_upload_path("/static/app/pay/wx.png"),
  403. 'href'=>'',
  404. ];
  405. }
  406. $info['paylist'] =$paylist;
  407. $info['tip_t'] =$configpub['name_coin'].'/'.$configpub['name_score'].'说明:';
  408. $info['tip_d'] =$configpub['name_coin'].'可通过平台提供的支付方式进行充值获得,'.$configpub['name_coin'].'适用于平台内所有消费; '.$configpub['name_score'].'可通过直播间内游戏奖励获得,所得'.$configpub['name_score'].'可用于平台商城内兑换会员、坐 骑、靓号等服务,不可提现。';
  409. $rs['info'][0]=$info;
  410. return $rs;
  411. }
  412. /**
  413. * 我的收益
  414. * @desc 用于获取用户收益,包括可体现金额,今日可提现金额
  415. * @return int code 操作码,0表示成功
  416. * @return array info
  417. * @return string info[0].votes 可提取映票数
  418. * @return string info[0].votestotal 总映票
  419. * @return string info[0].cash_rate 映票兑换比例
  420. * @return string info[0].total 可提现金额
  421. * @return string info[0].tips 温馨提示
  422. * @return string msg 提示信息
  423. */
  424. public function getProfit() {
  425. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  426. $uid=checkNull($this->uid);
  427. $token=checkNull($this->token);
  428. $checkToken=checkToken($uid,$token);
  429. if($checkToken==700){
  430. $rs['code'] = $checkToken;
  431. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  432. return $rs;
  433. }
  434. $domain = new Domain_User();
  435. $info = $domain->getProfit($uid);
  436. $rs['info'][0]=$info;
  437. return $rs;
  438. }
  439. /**
  440. * 用户提现
  441. * @desc 用于进行用户提现
  442. * @return int code 操作码,0表示成功
  443. * @return array info
  444. * @return string info[0].msg 提现成功信息
  445. * @return string msg 提示信息
  446. */
  447. public function setCash() {
  448. $rs = array('code' => 0, 'msg' => '提现成功', 'info' => array());
  449. $uid=checkNull($this->uid);
  450. $token=checkNull($this->token);
  451. $accountid=checkNull($this->accountid);
  452. $cashvote=checkNull($this->cashvote);
  453. $checkToken=checkToken($uid,$token);
  454. if($checkToken==700){
  455. $rs['code'] = $checkToken;
  456. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  457. return $rs;
  458. }
  459. if(!$accountid){
  460. $rs['code'] = 1001;
  461. $rs['msg'] = '请选择提现账号';
  462. return $rs;
  463. }
  464. if(!$cashvote){
  465. $rs['code'] = 1002;
  466. $rs['msg'] = '请输入有效的提现票数';
  467. return $rs;
  468. }
  469. $data=array(
  470. 'uid'=>$uid,
  471. 'accountid'=>$accountid,
  472. 'cashvote'=>$cashvote,
  473. );
  474. $config=getConfigPri();
  475. $domain = new Domain_User();
  476. $info = $domain->setCash($data);
  477. if($info==1001){
  478. $rs['code'] = 1001;
  479. $rs['msg'] = '您输入的金额大于可提现金额';
  480. return $rs;
  481. }else if($info==1003){
  482. $rs['code'] = 1003;
  483. $rs['msg'] = '请先进行身份认证';
  484. return $rs;
  485. }else if($info==1004){
  486. $rs['code'] = 1004;
  487. $rs['msg'] = '提现最低额度为'.$config['cash_min'].'元';
  488. return $rs;
  489. }else if($info==1005){
  490. $rs['code'] = 1005;
  491. $rs['msg'] = '不在提现期限内,不能提现';
  492. return $rs;
  493. }else if($info==1006){
  494. $rs['code'] = 1006;
  495. $rs['msg'] = '每月只可提现'.$config['cash_max_times'].'次,已达上限';
  496. return $rs;
  497. }else if($info==1007){
  498. $rs['code'] = 1007;
  499. $rs['msg'] = '提现账号信息不正确';
  500. return $rs;
  501. }else if(!$info){
  502. $rs['code'] = 1002;
  503. $rs['msg'] = '提现失败,请重试';
  504. return $rs;
  505. }
  506. $rs['info'][0]['msg']='提现成功';
  507. return $rs;
  508. }
  509. /**
  510. * 获取找回密码短信验证码
  511. * @desc 用于找回密码获取短信验证码
  512. * @return int code 操作码,0表示成功,2发送失败
  513. * @return array info
  514. * @return array info[0]
  515. * @return string msg 提示信息
  516. */
  517. public function getBindCode() {
  518. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  519. $mobile = checkNull($this->mobile);
  520. $ismobile=checkMobile($mobile);
  521. if(!$ismobile){
  522. $rs['code']=1001;
  523. $rs['msg']='请输入正确的手机号';
  524. return $rs;
  525. }
  526. if($_SESSION['set_mobile']==$mobile && $_SESSION['set_mobile_expiretime']> time() ){
  527. $rs['code']=1002;
  528. $rs['msg']='验证码5分钟有效,请勿多次发送';
  529. return $rs;
  530. }
  531. $mobile_code = random(6,1);
  532. /* 发送验证码 */
  533. $result=sendCode($mobile,$mobile_code);
  534. if($result['code']===0){
  535. $_SESSION['set_mobile'] = $mobile;
  536. $_SESSION['set_mobile_code'] = $mobile_code;
  537. $_SESSION['set_mobile_expiretime'] = time() +60*5;
  538. }else if($result['code']==667){
  539. $_SESSION['set_mobile'] = $mobile;
  540. $_SESSION['set_mobile_code'] = $result['msg'];
  541. $_SESSION['set_mobile_expiretime'] = time() +60*5;
  542. $rs['code']=1002;
  543. $rs['msg']='验证码为:'.$result['msg'];
  544. }else{
  545. $rs['code']=1002;
  546. $rs['msg']=$result['msg'];
  547. }
  548. return $rs;
  549. }
  550. /**
  551. * 直播记录
  552. * @desc 用于获取用户的直播记录
  553. * @return int code 操作码,0表示成功
  554. * @return array info
  555. * @return string info[].nums 观看人数
  556. * @return string info[].datestarttime 格式化的开播时间
  557. * @return string info[].dateendtime 格式化的结束时间
  558. * @return string info[].video_url 回放地址
  559. * @return string info[].file_id 回放标示
  560. * @return string msg 提示信息
  561. */
  562. public function getLiverecord() {
  563. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  564. $touid=checkNull($this->touid);
  565. $p=checkNull($this->p);
  566. $domain = new Domain_User();
  567. $info = $domain->getLiverecord($touid,$p);
  568. $rs['info']=$info;
  569. return $rs;
  570. }
  571. /**
  572. * 个人主页
  573. * @desc 用于获取个人主页数据
  574. * @return int code 操作码,0表示成功
  575. * @return array info
  576. * @return string info[0].islive 是否正在直播,0表示未直播,1表示直播
  577. * @return string info[0].livenums 直播数
  578. * @return array info[0].liverecord 直播记录
  579. * @return string msg 提示信息
  580. */
  581. public function getUserHome() {
  582. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  583. $uid=checkNull($this->uid);
  584. $touid=checkNull($this->touid);
  585. $domain = new Domain_User();
  586. $info=$domain->getUserHome($uid,$touid);
  587. $rs['info'][0]=$info;
  588. return $rs;
  589. }
  590. /**
  591. * 获取个性设置列表
  592. * @desc 用于获取个性设置列表
  593. * @return int code 操作码,0表示成功
  594. * @return array info
  595. * @return string msg 提示信息
  596. */
  597. public function getPerSetting() {
  598. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  599. $domain = new Domain_User();
  600. $info = $domain->getPerSetting();
  601. $info[]=array('id'=>'15','name'=>'修改密码','thumb'=>'' ,'href'=>'');
  602. $info[]=array('id'=>'18','name'=>'清除缓存','thumb'=>'' ,'href'=>'');
  603. $info[]=array('id'=>'16','name'=>'检查更新','thumb'=>'' ,'href'=>'');
  604. $rs['info']=$info;
  605. return $rs;
  606. }
  607. /**
  608. * 获取用户提现账号
  609. * @desc 用于获取用户提现账号
  610. * @return int code 操作码,0表示成功
  611. * @return array info
  612. * @return string info[].id 账号ID
  613. * @return string info[].type 账号类型
  614. * @return string info[].account_bank 银行名称
  615. * @return string info[].account 账号
  616. * @return string info[].name 姓名
  617. * @return string msg 提示信息
  618. */
  619. public function getUserAccountList() {
  620. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  621. $uid=checkNull($this->uid);
  622. $token=checkNull($this->token);
  623. $checkToken=checkToken($uid,$token);
  624. if($checkToken==700){
  625. $rs['code'] = $checkToken;
  626. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  627. return $rs;
  628. }
  629. $domain = new Domain_User();
  630. $info = $domain->getUserAccountList($uid);
  631. $rs['info']=$info;
  632. return $rs;
  633. }
  634. /**
  635. * 添加提现账号
  636. * @desc 用于添加提现账号
  637. * @return int code 操作码,0表示成功
  638. * @return array info
  639. * @return string msg 提示信息
  640. */
  641. public function setUserAccount() {
  642. $rs = array('code' => 0, 'msg' => '添加成功', 'info' => array());
  643. $uid=checkNull($this->uid);
  644. $token=checkNull($this->token);
  645. $type=checkNull($this->type);
  646. $account_bank=checkNull($this->account_bank);
  647. $account=checkNull($this->account);
  648. $name=checkNull($this->name);
  649. if($type==3){
  650. if($account_bank==''){
  651. $rs['code'] = 1001;
  652. $rs['msg'] = '银行名称不能为空';
  653. return $rs;
  654. }
  655. }
  656. if($account==''){
  657. $rs['code'] = 1002;
  658. $rs['msg'] = '账号不能为空';
  659. return $rs;
  660. }
  661. if(mb_strlen($account)>40){
  662. $rs['code'] = 1002;
  663. $rs['msg'] = '账号长度不能超过40个字符';
  664. return $rs;
  665. }
  666. $checkToken=checkToken($uid,$token);
  667. if($checkToken==700){
  668. $rs['code'] = $checkToken;
  669. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  670. return $rs;
  671. }
  672. $data=array(
  673. 'uid'=>$uid,
  674. 'type'=>$type,
  675. 'account_bank'=>$account_bank,
  676. 'account'=>$account,
  677. 'name'=>$name,
  678. 'addtime'=>time(),
  679. );
  680. $domain = new Domain_User();
  681. $where=[
  682. 'uid'=>$uid,
  683. 'type'=>$type,
  684. 'account_bank'=>$account_bank,
  685. 'account'=>$account,
  686. ];
  687. $isexist=$domain->getUserAccount($where);
  688. if($isexist){
  689. $rs['code'] = 1004;
  690. $rs['msg'] = '账号已存在';
  691. return $rs;
  692. }
  693. $result = $domain->setUserAccount($data);
  694. if(!$result){
  695. $rs['code'] = 1003;
  696. $rs['msg'] = '添加失败,请重试';
  697. return $rs;
  698. }
  699. $rs['info'][0]=$result;
  700. return $rs;
  701. }
  702. /**
  703. * 删除用户提现账号
  704. * @desc 用于删除用户提现账号
  705. * @return int code 操作码,0表示成功
  706. * @return array info
  707. * @return string msg 提示信息
  708. */
  709. public function delUserAccount() {
  710. $rs = array('code' => 0, 'msg' => '删除成功', 'info' => array());
  711. $uid=checkNull($this->uid);
  712. $token=checkNull($this->token);
  713. $id=checkNull($this->id);
  714. $checkToken=checkToken($uid,$token);
  715. if($checkToken==700){
  716. $rs['code'] = $checkToken;
  717. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  718. return $rs;
  719. }
  720. $data=array(
  721. 'uid'=>$uid,
  722. 'id'=>$id,
  723. );
  724. $domain = new Domain_User();
  725. $result = $domain->delUserAccount($data);
  726. if(!$result){
  727. $rs['code'] = 1003;
  728. $rs['msg'] = '删除失败,请重试';
  729. return $rs;
  730. }
  731. return $rs;
  732. }
  733. /**
  734. * 获取用户的认证信息
  735. * @desc 用于获取用户的认证信息
  736. * @return int code 状态码,0表示成功
  737. * @return string msg 提示信息
  738. * @return array info 返回信息
  739. */
  740. public function getAuthInfo(){
  741. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  742. $uid=checkNull($this->uid);
  743. $token=checkNull($this->token);
  744. $checkToken=checkToken($uid,$token);
  745. if($checkToken==700){
  746. $rs['code'] = $checkToken;
  747. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  748. return $rs;
  749. }
  750. $isauth=isAuth($uid);
  751. if(!$isauth){
  752. $rs['code']=1001;
  753. $rs['msg']='请先进行实名认证';
  754. return $rs;
  755. }
  756. $domain=new Domain_User();
  757. $res=$domain->getAuthInfo($uid);
  758. $rs['info'][0]=$res;
  759. return $rs;
  760. }
  761. /**
  762. * 获取七牛上传Token
  763. * @desc 用于获取七牛上传Token
  764. * @return int code 操作码,0表示成功
  765. * @return string msg 提示信息
  766. */
  767. public function getQiniuToken(){
  768. $rs = array('code' => 0, 'msg' => '', 'info' =>array());
  769. //获取后台配置的腾讯云存储信息
  770. $Qiniu=DI()->config->get('app.Qiniu');
  771. require_once API_ROOT.'/../sdk/qiniu/autoload.php';
  772. // 需要填写你的 Access Key 和 Secret Key
  773. // 需要填写你的 Access Key 和 Secret Key
  774. $accessKey =$Qiniu['accessKey'];// $configpri['qiniu_accesskey'];
  775. $secretKey = $Qiniu['secretKey'];//$configpri['qiniu_secretkey'];
  776. $bucket =$Qiniu['space_bucket'];// $configpri['qiniu_bucket'];
  777. $qiniu_domain_url = $Qiniu['space_host'];
  778. // 构建鉴权对象
  779. $auth = new Qiniu\Auth($accessKey, $secretKey);
  780. // 生成上传 Token
  781. $token = $auth->uploadToken($bucket);
  782. $rs['info'][0]['token']=$token ;
  783. return $rs;
  784. }
  785. }