| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <?php
- namespace app\api\controller;
- use app\api\logic\OrderLogic;
- use app\api\logic\UserLogic;
- use app\common\controller\Api;
- use app\common\model\ProductOrder;
- use app\common\model\LedgerSmhChangeModel;
- use app\common\model\LedgerTokenChangeModel;
- use app\common\model\LedgerWalletModel;
- use app\common\model\ProductTransfer;
- use app\common\model\TeamLevelModel;
- use app\common\model\UserModel;
- use app\common\model\ProductBuying;
- use app\common\model\UserArea;
- use fast\Action;
- use fast\Asset;
- use fast\Random;
- use app\api\logic\UserInfoLogic;
- use think\Config;
- use think\Db;
- use think\Exception;
- /**
- * 会员接口
- */
- class User extends Api
- {
- protected string $lan = '';
- public function _initialize()
- {
- parent::_initialize();
- $this->lan = $this->request->getLan();
- }
- /**
- * 获取用户信息
- * @return void
- */
- public function userInfo(UserArea $userArea,UserModel $userModel, LedgerWalletModel $ledgerWalletModel)
- {
- $user = $this->auth->getUser();
- // if (empty($user['is_super'] ) && !empty($user['address_level'])) {
- // $user['address_level'] = $userModel::updateUserAddresLevel($user['id'], $user['parent_id']);
- // }
- $resp = [
- 'id' => $user['id'],
- 'nickname' => $user['nickname'],
- 'heading' => $user['heading'],
- 'address' => $user['address'],// 地址
- 'usdt' => '0', //USDT余额
- 'token' => '0', // 平台币余额
- 'name' => $user['name'], // 姓名
- 'phone' => $user['phone'], // 手机号
- 'rental_power' => '0', // 自己购买的算力
- 'team_power' => '0', // 团队总算里
- 'balance' => $ledgerWalletModel::getWalletChaBao($this->auth->id), // 余额
- 'rwa_num' => $user['rwa_num'], // 总茶权
- 'parent_id' => $user['parent_id'], // 上级ID
- 'is_super' => $user['is_super'], // 新人福利标识
- 'direct_super' => ['one'=>3, 'two'=>10,'direct_super'=>$user['direct_super'], 'address_level'=>$user['address_level']], // 推广新人福等级标识
- 'is_ecology' => $user['is_ecology'], // 生态标识
- 'avatar' => isHttpOrHttps($user['avatar'])? $user['avatar']: $this->request->domain().'/assets/img/logo.png', // 头像
- 'parent_address' => '', // 上级的地址
- 'team_level_id' => $user['team_level_id'], // 团队等级
- 'invite_link' => config('rental.invite_domain') . '/?inviteCode=' . $user['address'],
- 'take_address' => $userArea::getUserDefaultAdders($user['id']), // 用户地址
- 'create_time' => $user['create_time'], // 创建时间
- ];
- $this->success('', $resp);
- }
- /**
- * 获取我的查询列表
- * param int $type_id 0总览 1转让中 2已转让 3存储中 4已赠送 5已提货
- * @return void
- */
- public function getNftList(ProductOrder $productOrder, ProductTransfer $productTransfer, UserLogic $userLogic)
- {
- $typeId = $this->request->post('type_id/d', 0);
- $productId = $this->request->post('product_id/d', 0);
- //搜索条件
- $where = $userLogic::getNftWhere($typeId, $productId, $productOrder);
- //查询
- $list = $userLogic::getUserNftList($productOrder, $productTransfer, $this->lan, $this->auth->id, $this->pageSize, $where);
- $this->success('', $list);
- }
- /**
- * 获取我的查询详情
- * param int $type_id 0总览 1转让中 2已转让 3存储中 4已赠送 5已提货
- * @return void
- */
- public function getMyNftList(ProductOrder $productOrder, UserLogic $userLogic)
- {
- $typeId = $this->request->post('type_id/d', 0);
- //搜索条件
- $where = $userLogic::getNftWhere($typeId, 0, $productOrder);
- //查询
- $list = $userLogic::getMyUserNftList($productOrder, $this->auth->id, $this->lan, $where, $this->pageSize);
- $this->success('', $list);
- }
- /**
- * 余额记录信息
- * @return void
- */
- public function getUserBalanceLog(LedgerTokenChangeModel $ledgerTokenChangeModel, UserLogic $userLogic)
- {
- $list = $userLogic::getUserBalanceLog($ledgerTokenChangeModel, $this->auth->id, $this->pageSize);
- $this->success('', $list);
- }
- /**
- * 我的茶友
- * @return void
- */
- public function getChaList(UserModel $userModel, UserLogic $userLogic)
- {
- $list = $userLogic::getUserChaList($userModel, $this->auth->id, $this->pageSize);
- $this->success('', $list);
- }
- //求购列表
- public function getBuyingList(ProductBuying $productBuying)
- {
- $this->success('ok', $productBuying::getUserBuyingList($this->auth->id, $this->lan, $this->pageSize));
- }
- /**
- * 修改个人信息
- * @return void
- */
- public function setUserInfo(UserModel $userModel, UserArea $userArea)
- {
- // 启动事务
- Db::startTrans();
- try {
- $param = $this->request->post();
- $validate = \think\Loader::validate('User');
-
- if(!$validate->scene(key($param))->check($param) || count($param) > 2 || empty($param)) $this->error(__("Invalid parameters"));
- //手机号修改
- if(isset($param['phone']) && UserInfoLogic::checkUserByInfo('phone', $this->auth->id, $param['phone']) == false) $this->error(__("手机号已存在"));
- //地址时候去重
- if(isset($param['address']) && UserInfoLogic::checkUserByInfo('address', $this->auth->id, $param['address']) == false) $this->error(__("钱包地址已存在不能修改"));
- if(isset($param['area_code']) && isset($param['area_name'])){
- $resp = $userArea::setUserAddress($this->auth->id, $param['area_code'], $param['area_name']);
- }else{
- $resp = $userModel::where('id', $this->auth->id)->update($param);
- }
- // 提交事务
- Db::commit();
- } catch (Exception $e) {
- // 回滚事务
- Db::rollback();
- $this->error( $e->getMessage());
- }
- $this->success('', $resp);
- }
- /**
- * 获取操作信息 购买、赠送、提货、转让
- * @return void
- */
- public function getOperateLog(ProductOrder $productOrder, UserLogic $userLogic)
- {
- $typeId = $this->request->post('type_id/d', 0);
- $status = $this->request->post('status/d', 0);
- $areaId = $this->request->post('area_id/s', 0);
- //搜索条件
- $where = $userLogic::getOperateWhere($typeId, $status, $areaId);
- //查询
- $list = $userLogic::getUserOperateLog($productOrder, $this->lan, $this->auth->id, $this->pageSize, $where);
- $this->success('', $list);
- }
-
- //获取用户待支付订单数量
- public function getWaitPayOrderCount(OrderLogic $orderLogic)
- {
- $count = $orderLogic::getWaitPayOrderCount($this->auth->id, config('market_transfer.lock_time'));
- $this->success('', $count);
- }
- //获取用户待支付订单
- public function getWaitPayOrderList(OrderLogic $orderLogic)
- {
- $list = $orderLogic::getWaitPayOrderList($this->auth->id, config('market_transfer.lock_time'), $this->pageSize, $this->lan);
- $this->success('', $list);
- }
- //取消用户待支付订单
- public function setCancelWaitPayOrder(OrderLogic $orderLogic)
- {
- $transfer_id = $this->request->post('transfer_id/d', 0);
- if(empty($transfer_id)) $this->error(__('Invalid parameters'));
- $list = $orderLogic::setCancelWaitPayOrder($this->auth->id, $transfer_id);
- $this->success('ok', $list);
- }
-
-
- }
|