MemberController.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <?php
  2. /**
  3. * MemberController.php UTF-8
  4. * 浮点获取玩家信息
  5. *
  6. * @date : 2018/5/3 11:10
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\float\controller;
  13. use api\common\controller\FloatBaseController;
  14. use cmf\lib\Upload;
  15. use huo\controller\address\Address;
  16. use huo\controller\member\Member;
  17. use huo\controller\member\MemCache;
  18. use huoIdentify\controller\Identify;
  19. use huolib\status\CommonStatus;
  20. use huolib\status\IdentifyStatus;
  21. use huolib\status\MemberStatus;
  22. use huolib\tool\StrUtils;
  23. class MemberController extends FloatBaseController {
  24. public function _initialize() {
  25. parent::_initialize();
  26. $this->checkLogin();
  27. }
  28. /**
  29. * H5浮点获取用户信息
  30. * http://doc.1tsdk.com/138?page_id=3207
  31. * 【域名】/float/user/detail
  32. */
  33. public function index() {
  34. $_mem_id = $this->mem_id;
  35. $_rdata = (new Member())->getMemInfo($_mem_id);
  36. /* Modified by chenbingling BEGIN 2019/11/29 ISSUES:10837 实名认证新规调整 */
  37. $_game_rq = $this->setGameData();
  38. $_device_rq = $this->setDeviceData();
  39. $_auth_info = (new Identify())->getMemIdentifyInfo(
  40. $_game_rq->getHAppId(), $this->mem_id, $_device_rq->getDeviceId()
  41. );
  42. $_rdata['url'] = get_val($_auth_info, 'url', '');
  43. $_session_id = session_id();
  44. if (empty($_session_id)) {
  45. $_rdata['url'] = '';
  46. }
  47. $_rdata['auth_info'] = get_val($_auth_info, 'auth_info', null);
  48. $siteInfo = cmf_get_site_info();
  49. $_rdata['wap_app_down_url'] = get_val($siteInfo, 'wap_app_down_url', '');
  50. /* END 2019/11/29 ISSUES:10837 */
  51. $_code = MemberStatus::NO_ERROR;
  52. // \think\Log::error(array('huoquyonghuxinxi',$_rdata));
  53. $this->success(MemberStatus::getMsg($_code), $_rdata);
  54. }
  55. /**
  56. * 获取地址信息
  57. */
  58. public function address() {
  59. $_list = (new Address())->getMemAddress($this->mem_id);
  60. $_code = MemberStatus::NO_ERROR;
  61. $this->success(MemberStatus::getMsg($_code), $_list['list']);
  62. }
  63. /**
  64. * 获取玩家支付宝信息
  65. */
  66. public function getAliInfo() {
  67. $_mem_data = MemCache::ins()->getInfoById($this->mem_id);
  68. $_real_name = get_val($_mem_data, 'real_name', '');
  69. $_id_card = get_val($_mem_data, 'id_card', '');
  70. $_mobile = get_val($_mem_data, 'mobile', '');
  71. $_alipay_account = get_val($_mem_data, 'alipay_account', '');
  72. $_data = [
  73. 'real_name' => StrUtils::encryptName($_real_name),
  74. 'id_card' => StrUtils::encryptIdCard($_id_card),
  75. 'mobile' => StrUtils::encryptPhone($_mobile),
  76. 'real_mobile' => $_mobile,
  77. 'alipay_account' => StrUtils::encryptIdCard($_alipay_account),
  78. ];
  79. $_code = MemberStatus::NO_ERROR;
  80. $this->success(MemberStatus::getMsg($_code), $_data);
  81. }
  82. public function addAddressPost() {
  83. $address['mem_id'] = $this->mem_id;
  84. $address['consignee'] = $this->request->param('consignee/s', '');
  85. $address['mobile'] = $this->request->param('mobile/s', '');
  86. $address['country'] = $this->request->param('country/d', 0);
  87. $address['province'] = $this->request->param('province/d', 0);
  88. $address['city'] = $this->request->param('city/d', 0);
  89. $address['district'] = $this->request->param('district/d', 0);
  90. $address['town'] = $this->request->param('town/d', 0);
  91. $address['address'] = $this->request->param('address/s', '');
  92. $address['zipcode'] = $this->request->param('zipcode/s', '');
  93. $address['is_default'] = $this->request->param('is_default/s', '');
  94. $_res = (new Address())->addAddress($address);
  95. if (!$_res) {
  96. $_rdata = [
  97. 'code' => CommonStatus::INNER_ERROR,
  98. 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR),
  99. 'data' => [],
  100. ];
  101. } else {
  102. $_rdata = [
  103. 'code' => CommonStatus::NO_ERROR,
  104. 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR),
  105. 'data' => [],
  106. ];
  107. }
  108. $this->returnData($_rdata);
  109. }
  110. public function editAddressPost() {
  111. $address['mem_id'] = $this->mem_id;
  112. $id = $this->request->param('id/s', '');
  113. $address['consignee'] = $this->request->param('consignee/s', '');
  114. $address['mobile'] = $this->request->param('mobile/s', '');
  115. $address['country'] = $this->request->param('country/d', 0);
  116. $address['province'] = $this->request->param('province/d', 0);
  117. $address['city'] = $this->request->param('city/d', 0);
  118. $address['district'] = $this->request->param('district/d', 0);
  119. $address['town'] = $this->request->param('town/d', 0);
  120. $address['address'] = $this->request->param('address/s', '');
  121. $address['zipcode'] = $this->request->param('zipcode/s', '');
  122. $address['is_default'] = $this->request->param('is_default/s', '');
  123. $_res = (new Address())->editMemAddress($id, $address);
  124. if (!$_res) {
  125. $_rdata = [
  126. 'code' => CommonStatus::INNER_ERROR,
  127. 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR),
  128. 'data' => [],
  129. ];
  130. } else {
  131. $_rdata = [
  132. 'code' => CommonStatus::NO_ERROR,
  133. 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR),
  134. 'data' => [],
  135. ];
  136. }
  137. $this->returnData($_rdata);
  138. }
  139. public function deleteAddress() {
  140. $id = $this->request->param('id/s', '');
  141. $_res = (new Address())->deleteAddress($id);
  142. if (!$_res) {
  143. $_rdata = [
  144. 'code' => CommonStatus::INNER_ERROR,
  145. 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR),
  146. 'data' => [],
  147. ];
  148. } else {
  149. $_rdata = [
  150. 'code' => CommonStatus::NO_ERROR,
  151. 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR),
  152. 'data' => [],
  153. ];
  154. }
  155. $this->returnData($_rdata);
  156. }
  157. /**
  158. * 绑定支付宝提交页面
  159. */
  160. public function bindAlipayPost() {
  161. $_param = $this->request->param();
  162. $_alipay_account = get_val($_param, 'alipay_account', '');
  163. if (empty($_alipay_account)) {
  164. $_code = MemberStatus::INVALID_PARAMS;
  165. $this->error(IdentifyStatus::getMsg($_code), [], $_code);
  166. }
  167. /* 检查支付宝是否绑定别的玩家 */
  168. $_id = (new Member())->getMemIdByAlipayAccount($_alipay_account);
  169. if (!empty($_id) && $_id != $this->mem_id) {
  170. $_code = MemberStatus::ALIPAY_IS_BIND;
  171. $this->error(MemberStatus::getMsg($_code), [], $_code);
  172. }
  173. // $_mobile = get_val($_param, 'mobile', '');
  174. // $_sms_code = get_val($_param, 'sms_code', '');
  175. // $_mem_data = MemCache::ins()->getInfoById($this->mem_id);
  176. // /* 校验手机验证码 */
  177. // if (empty($_mem_data['mobile']) && empty($_mobile)) {
  178. // $_code = MemberStatus::PHONE_EMPTY;
  179. // $this->error(IdentifyStatus::getMsg($_code), [], $_code);
  180. // }
  181. // /* 校验短信是否正确 */
  182. // $_sms_rs = (new Sms())->check($_mobile, $_sms_code, SmsType::SMS_ID_VERIFY);
  183. // if (MemberStatus::NO_ERROR != $_sms_rs['code']) {
  184. // $this->error($_sms_rs['code'], [], $_sms_rs['msg']);
  185. // }
  186. // $_real_name = get_val($_param, 'real_name', '');
  187. // $_id_card = get_val($_param, 'id_card', '');
  188. // /* 未实名则需要校验 校验证件号是否输入 */
  189. // if (empty($_mem_data['real_name'])) {
  190. // if (empty($_real_name) || empty($_id_card)) {
  191. // $_code = IdentifyStatus::IDENTIFY_INFO_ERROR;
  192. // $this->error(IdentifyStatus::getMsg($_code), [], $_code);
  193. // }
  194. // $_rs = (new \huoIdentify\controller\Identify())->updateIdentify($this->mem_id, 1, $_real_name, $_id_card);
  195. // if (IdentifyStatus::NO_ERROR != $_rs['code']) {
  196. // $this->returnData($_rs);
  197. // }
  198. // }
  199. $_mem_data['alipay_account'] = $_alipay_account;
  200. if (empty($_mem_data['mobile'])) {
  201. // $_mem_data['mobile'] = $_mobile;
  202. }
  203. $_rs = MemCache::ins()->updateMem($this->mem_id, $_mem_data);
  204. if (false === $_rs) {
  205. $_code = IdentifyStatus::INNER_ERROR;
  206. $this->error(IdentifyStatus::getMsg($_code), [], $_code);
  207. }
  208. $_code = IdentifyStatus::NO_ERROR;
  209. $this->success(IdentifyStatus::getMsg($_code), [], $_code);
  210. }
  211. /**
  212. * 修改用户头像
  213. * http://doc.1tsdk.com/138?page_id=3541
  214. * 【域名】/user/avatar/update
  215. */
  216. public function updateAvatar() {
  217. $_avatar = $this->request->param('avatar/s', '');
  218. if (empty($_avatar)) {
  219. $_code = CommonStatus::INVALID_PARAMS;
  220. $this->error(CommonStatus::getMsg($_code), [], $_code);
  221. }
  222. $_rdata = (new Member())->updateAvatar($this->mem_id, $_avatar);
  223. return $this->returnData($_rdata);
  224. }
  225. public function getAddressDetail() {
  226. $id = $this->request->param('id/s', '');
  227. $_detail = (new Address())->getAddressDetail($id);
  228. $_rdata = [
  229. 'code' => CommonStatus::NO_ERROR,
  230. 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR),
  231. 'data' => $_detail,
  232. ];
  233. $this->returnData($_rdata);
  234. }
  235. /**
  236. * 上传文件
  237. * 【域名】/user/asset/upload
  238. */
  239. public function upload() {
  240. $_up_class = new Upload();
  241. $_rs = $_up_class->upload();
  242. if (false === $_rs) {
  243. $this->error($_up_class->getError());
  244. } else {
  245. $_code = CommonStatus::NO_ERROR;
  246. $this->success(CommonStatus::getMsg($_code), $_rs, $_code);
  247. }
  248. }
  249. }