UserController.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * UserController.php UTF-8
  4. *
  5. *
  6. * @date : 2018/6/11 16:36
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\wapapp\controller\v8;
  13. use api\common\controller\V2ApiBaseController;
  14. use huo\controller\integral\MemIntegral;
  15. use huo\controller\member\Bind;
  16. use huo\controller\member\Member;
  17. use huo\controller\sign\Sign;
  18. use huoIdentify\controller\Identify;
  19. use huolib\constant\MemConst;
  20. use huolib\status\CommonStatus;
  21. use huolib\status\MemberStatus;
  22. use think\Lang;
  23. class UserController extends V2ApiBaseController {
  24. public function _initialize() {
  25. parent::_initialize();
  26. $langSet = $this->request->langset();
  27. Lang::load([APP_PATH.'wapapp'.DS.'lang'.DS.$langSet.DS.'user'.EXT,]);
  28. $this->checkLogin();
  29. }
  30. /**
  31. * 获取用户信息
  32. * http://doc.1tsdk.com/138?page_id=3131
  33. * 【域名】/user/detail
  34. */
  35. public function detail() {
  36. $_app_id = get_val($this->rq_data, 'app_id');
  37. $_rdata = (new Member())->getMemInfo($this->mem_id, $_app_id);
  38. if (isset($_rdata['status']) && $_rdata['status'] == MemConst::STATUS_FORBID) {
  39. $_code = MemberStatus::LOGIN_IS_OUT;
  40. $this->error(lang(MemberStatus::getMsg($_code)), [], $_code);
  41. }
  42. /* Modified by chenbingling BEGIN 2019/11/29 ISSUES:10837 实名认证新规调整 */
  43. $_game_rq = $this->setGameData();
  44. $_device_rq = $this->setDeviceData();
  45. $_auth_info = (new Identify())->getMemIdentifyInfo(
  46. $_game_rq->getHAppId(), $this->mem_id, $_device_rq->getDeviceId(), $this->token
  47. );
  48. $_rdata['url'] = get_val($_auth_info, 'url', '');
  49. $_rdata['auth_info'] = get_val($_auth_info, 'auth_info', null);
  50. $siteInfo = cmf_get_site_info();
  51. $_rdata['wap_app_down_url'] = get_val($siteInfo, 'wap_app_down_url', '');
  52. /* END 2019/11/29 ISSUES:10837 */
  53. $_code = MemberStatus::NO_ERROR;
  54. $this->success(MemberStatus::getMsg($_code), $_rdata);
  55. }
  56. /**
  57. * 修改昵称
  58. * http://doc.1tsdk.com/138?page_id=3367
  59. * 【域名】/user/nickname/update
  60. */
  61. public function updateNickname() {
  62. $_data = $this->request->param();
  63. $result = $this->validate($_data, [
  64. 'nickname' => 'require|chsDash|max:32',
  65. ],[
  66. 'nickname.require' => lang('nickname is null'),
  67. 'nickname.chsDash' => lang('nickname Invalid'),
  68. 'nickname.max' => lang('nickname Up to 32 characters'),
  69. ]);
  70. if (true !== $result) {
  71. $this->error($result, [], CommonStatus::INVALID_PARAMS);
  72. }
  73. $_nickname = get_val($_data, 'nickname');
  74. $_rs = (new Member())->updateNickname($this->mem_id, $_nickname);
  75. if (MemberStatus::NO_ERROR != $_rs['code']) {
  76. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  77. }
  78. $this->success($_rs['msg'], $_rs['data'], $_rs['code']);
  79. }
  80. /**
  81. * 修改密码
  82. * http://doc.1tsdk.com/138?page_id=3372
  83. * 【域名】/user/passwd/update
  84. */
  85. public function updatePwd() {
  86. $_data = $this->request->param();
  87. $result = $this->validate($_data, [
  88. 'oldpwd' => 'require',
  89. 'newpwd' => 'require|length:6,32',
  90. ],[
  91. 'oldpwd.require' => lang('oldpwd is null'),
  92. 'newpwd.require' => lang('newpwd is null'),
  93. 'newpwd.length' => lang('newpwd length is 6~32 characters'),
  94. ]);
  95. if (true !== $result) {
  96. $this->error($result, [], CommonStatus::INVALID_PARAMS);
  97. }
  98. $_oldpwd = get_val($_data, 'oldpwd');
  99. $_newpwd = get_val($_data, 'newpwd');
  100. $_mem_class = new Member();
  101. $_rs = $_mem_class->updatePwd($this->mem_id, $_oldpwd, $_newpwd);
  102. if (MemberStatus::NO_ERROR != $_rs['code']) {
  103. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  104. }
  105. $this->success($_rs['msg'], $_rs['data'], $_rs['code']);
  106. }
  107. /**
  108. * 签到
  109. * http://doc.1tsdk.com/138?page_id=3147
  110. * 【域名】/v8/user/signin
  111. */
  112. public function signin() {
  113. $_sign_class = new Sign();
  114. $_rs = $_sign_class->sign($this->getMemId());
  115. if (MemberStatus::NO_ERROR != $_rs['code']) {
  116. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  117. }
  118. $this->success($_rs['msg'], $_rs['data'], $_rs['code']);
  119. }
  120. /**
  121. * 积分记录列表
  122. * http://doc.1tsdk.com/138?page_id=3119
  123. * 【域名】/v8/score/record/list
  124. */
  125. public function scoreList() {
  126. $_mem_id = $this->getMemId();
  127. $_page = $this->request->param('page/d', 1);
  128. $_offset = $this->request->param('offset/d', 10);
  129. $_itg_type = $this->request->param('itg_type/d', 1);/* 记录类型:1 获得 2 消费 */
  130. $_page = $_page.','.$_offset;
  131. $_ml_class = new MemIntegral();
  132. $where['itg_type'] = $_itg_type;
  133. $_rdata = $_ml_class->getItgList($where, $_page, $_mem_id);
  134. $this->success($_rdata['msg'], $_rdata['data'], $_rdata['code']);
  135. }
  136. /**
  137. * 用户密保信息
  138. * http://doc.1tsdk.com/138?page_id=3398
  139. * 【域名】/user/bind/info
  140. */
  141. public function bindInfo() {
  142. $_mem_id = $this->getMemId();
  143. $_rdata = (new Bind())->getBindInfo($_mem_id);
  144. return $this->returnData($_rdata);
  145. }
  146. }