* @version : HUOSDK 8.0 */ namespace api\float\controller; use api\common\controller\FloatBaseController; use cmf\lib\Upload; use huo\controller\address\Address; use huo\controller\member\Member; use huo\controller\member\MemCache; use huoIdentify\controller\Identify; use huolib\status\CommonStatus; use huolib\status\IdentifyStatus; use huolib\status\MemberStatus; use huolib\tool\StrUtils; class MemberController extends FloatBaseController { public function _initialize() { parent::_initialize(); $this->checkLogin(); } /** * H5浮点获取用户信息 * http://doc.1tsdk.com/138?page_id=3207 * 【域名】/float/user/detail */ public function index() { $_mem_id = $this->mem_id; $_rdata = (new Member())->getMemInfo($_mem_id); /* Modified by chenbingling BEGIN 2019/11/29 ISSUES:10837 实名认证新规调整 */ $_game_rq = $this->setGameData(); $_device_rq = $this->setDeviceData(); $_auth_info = (new Identify())->getMemIdentifyInfo( $_game_rq->getHAppId(), $this->mem_id, $_device_rq->getDeviceId() ); $_rdata['url'] = get_val($_auth_info, 'url', ''); $_session_id = session_id(); if (empty($_session_id)) { $_rdata['url'] = ''; } $_rdata['auth_info'] = get_val($_auth_info, 'auth_info', null); $siteInfo = cmf_get_site_info(); $_rdata['wap_app_down_url'] = get_val($siteInfo, 'wap_app_down_url', ''); /* END 2019/11/29 ISSUES:10837 */ $_code = MemberStatus::NO_ERROR; // \think\Log::error(array('huoquyonghuxinxi',$_rdata)); $this->success(MemberStatus::getMsg($_code), $_rdata); } /** * 获取地址信息 */ public function address() { $_list = (new Address())->getMemAddress($this->mem_id); $_code = MemberStatus::NO_ERROR; $this->success(MemberStatus::getMsg($_code), $_list['list']); } /** * 获取玩家支付宝信息 */ public function getAliInfo() { $_mem_data = MemCache::ins()->getInfoById($this->mem_id); $_real_name = get_val($_mem_data, 'real_name', ''); $_id_card = get_val($_mem_data, 'id_card', ''); $_mobile = get_val($_mem_data, 'mobile', ''); $_alipay_account = get_val($_mem_data, 'alipay_account', ''); $_data = [ 'real_name' => StrUtils::encryptName($_real_name), 'id_card' => StrUtils::encryptIdCard($_id_card), 'mobile' => StrUtils::encryptPhone($_mobile), 'real_mobile' => $_mobile, 'alipay_account' => StrUtils::encryptIdCard($_alipay_account), ]; $_code = MemberStatus::NO_ERROR; $this->success(MemberStatus::getMsg($_code), $_data); } public function addAddressPost() { $address['mem_id'] = $this->mem_id; $address['consignee'] = $this->request->param('consignee/s', ''); $address['mobile'] = $this->request->param('mobile/s', ''); $address['country'] = $this->request->param('country/d', 0); $address['province'] = $this->request->param('province/d', 0); $address['city'] = $this->request->param('city/d', 0); $address['district'] = $this->request->param('district/d', 0); $address['town'] = $this->request->param('town/d', 0); $address['address'] = $this->request->param('address/s', ''); $address['zipcode'] = $this->request->param('zipcode/s', ''); $address['is_default'] = $this->request->param('is_default/s', ''); $_res = (new Address())->addAddress($address); if (!$_res) { $_rdata = [ 'code' => CommonStatus::INNER_ERROR, 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR), 'data' => [], ]; } else { $_rdata = [ 'code' => CommonStatus::NO_ERROR, 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR), 'data' => [], ]; } $this->returnData($_rdata); } public function editAddressPost() { $address['mem_id'] = $this->mem_id; $id = $this->request->param('id/s', ''); $address['consignee'] = $this->request->param('consignee/s', ''); $address['mobile'] = $this->request->param('mobile/s', ''); $address['country'] = $this->request->param('country/d', 0); $address['province'] = $this->request->param('province/d', 0); $address['city'] = $this->request->param('city/d', 0); $address['district'] = $this->request->param('district/d', 0); $address['town'] = $this->request->param('town/d', 0); $address['address'] = $this->request->param('address/s', ''); $address['zipcode'] = $this->request->param('zipcode/s', ''); $address['is_default'] = $this->request->param('is_default/s', ''); $_res = (new Address())->editMemAddress($id, $address); if (!$_res) { $_rdata = [ 'code' => CommonStatus::INNER_ERROR, 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR), 'data' => [], ]; } else { $_rdata = [ 'code' => CommonStatus::NO_ERROR, 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR), 'data' => [], ]; } $this->returnData($_rdata); } public function deleteAddress() { $id = $this->request->param('id/s', ''); $_res = (new Address())->deleteAddress($id); if (!$_res) { $_rdata = [ 'code' => CommonStatus::INNER_ERROR, 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR), 'data' => [], ]; } else { $_rdata = [ 'code' => CommonStatus::NO_ERROR, 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR), 'data' => [], ]; } $this->returnData($_rdata); } /** * 绑定支付宝提交页面 */ public function bindAlipayPost() { $_param = $this->request->param(); $_alipay_account = get_val($_param, 'alipay_account', ''); if (empty($_alipay_account)) { $_code = MemberStatus::INVALID_PARAMS; $this->error(IdentifyStatus::getMsg($_code), [], $_code); } /* 检查支付宝是否绑定别的玩家 */ $_id = (new Member())->getMemIdByAlipayAccount($_alipay_account); if (!empty($_id) && $_id != $this->mem_id) { $_code = MemberStatus::ALIPAY_IS_BIND; $this->error(MemberStatus::getMsg($_code), [], $_code); } // $_mobile = get_val($_param, 'mobile', ''); // $_sms_code = get_val($_param, 'sms_code', ''); // $_mem_data = MemCache::ins()->getInfoById($this->mem_id); // /* 校验手机验证码 */ // if (empty($_mem_data['mobile']) && empty($_mobile)) { // $_code = MemberStatus::PHONE_EMPTY; // $this->error(IdentifyStatus::getMsg($_code), [], $_code); // } // /* 校验短信是否正确 */ // $_sms_rs = (new Sms())->check($_mobile, $_sms_code, SmsType::SMS_ID_VERIFY); // if (MemberStatus::NO_ERROR != $_sms_rs['code']) { // $this->error($_sms_rs['code'], [], $_sms_rs['msg']); // } // $_real_name = get_val($_param, 'real_name', ''); // $_id_card = get_val($_param, 'id_card', ''); // /* 未实名则需要校验 校验证件号是否输入 */ // if (empty($_mem_data['real_name'])) { // if (empty($_real_name) || empty($_id_card)) { // $_code = IdentifyStatus::IDENTIFY_INFO_ERROR; // $this->error(IdentifyStatus::getMsg($_code), [], $_code); // } // $_rs = (new \huoIdentify\controller\Identify())->updateIdentify($this->mem_id, 1, $_real_name, $_id_card); // if (IdentifyStatus::NO_ERROR != $_rs['code']) { // $this->returnData($_rs); // } // } $_mem_data['alipay_account'] = $_alipay_account; if (empty($_mem_data['mobile'])) { // $_mem_data['mobile'] = $_mobile; } $_rs = MemCache::ins()->updateMem($this->mem_id, $_mem_data); if (false === $_rs) { $_code = IdentifyStatus::INNER_ERROR; $this->error(IdentifyStatus::getMsg($_code), [], $_code); } $_code = IdentifyStatus::NO_ERROR; $this->success(IdentifyStatus::getMsg($_code), [], $_code); } /** * 修改用户头像 * http://doc.1tsdk.com/138?page_id=3541 * 【域名】/user/avatar/update */ public function updateAvatar() { $_avatar = $this->request->param('avatar/s', ''); if (empty($_avatar)) { $_code = CommonStatus::INVALID_PARAMS; $this->error(CommonStatus::getMsg($_code), [], $_code); } $_rdata = (new Member())->updateAvatar($this->mem_id, $_avatar); return $this->returnData($_rdata); } public function getAddressDetail() { $id = $this->request->param('id/s', ''); $_detail = (new Address())->getAddressDetail($id); $_rdata = [ 'code' => CommonStatus::NO_ERROR, 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR), 'data' => $_detail, ]; $this->returnData($_rdata); } /** * 上传文件 * 【域名】/user/asset/upload */ public function upload() { $_up_class = new Upload(); $_rs = $_up_class->upload(); if (false === $_rs) { $this->error($_up_class->getError()); } else { $_code = CommonStatus::NO_ERROR; $this->success(CommonStatus::getMsg($_code), $_rs, $_code); } } }