123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- <?php
- 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();
- }
-
- public function index() {
- $_mem_id = $this->mem_id;
- $_rdata = (new Member())->getMemInfo($_mem_id);
-
- $_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', '');
-
- $_code = MemberStatus::NO_ERROR;
- $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);
- }
- $_mem_data['alipay_account'] = $_alipay_account;
- if (empty($_mem_data['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);
- }
-
- 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);
- }
-
- 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);
- }
- }
- }
|