123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Http\Controllers\FrontController;
- use App\Jobs\BarrageJob;
- use App\Jobs\MemberShareJob;
- use App\Jobs\SaveImGroup;
- use App\Models\Comment;
- use App\Models\Contract;
- use App\Models\Express;
- use App\Models\Goods;
- use App\Models\GoodsBrowse;
- use App\Models\GoodsCollect;
- use App\Models\Level;
- use App\Models\Member;
- use App\Models\MemberAddress;
- use App\Models\MemberClan;
- use App\Models\MemberCoins;
- use App\Models\MemberCoupon;
- use App\Models\MemberOpenId;
- use App\Models\Members;
- use App\Models\MoneyDetail;
- use App\Models\MoneyRecord;
- use App\Models\Order;
- use App\Models\RefundOrder;
- use App\Models\SeckillGoods;
- use App\Models\Shop;
- use App\Models\ShopCollect;
- use App\Models\ShopOrder;
- use App\Servers\AddressServer;
- use App\Servers\CommonServer;
- use App\Servers\ExpressServer;
- use App\Servers\GoodsServer;
- use App\Servers\Icon\Address;
- use App\Servers\ImgServer;
- use App\Servers\KdnServer;
- use App\Servers\MemberLogsServer;
- use App\Servers\MemberServer;
- use App\Servers\MergeServer;
- use App\Servers\MoneyDetailServer;
- use App\Servers\PassServer;
- use App\Servers\RedisDataServer;
- use App\Servers\SensitiveServer;
- use App\Servers\SmsServer;
- use App\Servers\WeixinServer;
- use App\Servers\WxTemplateServer;
- use Carbon\Carbon;
- use SimpleSoftwareIO\QrCode\Facades\QrCode;
- use SwooleTW\Http\Websocket\Facades\Websocket;
- class MemberController extends FrontController
- {
- public function __construct()
- {
- parent::__construct();
- }
- function index()
- {
- }
- /**
- * 会员注册
- * @return \Illuminate\Http\JsonResponse
- */
- function register()
- {
- $invite_code = request()->input('inviteCode', '');
- if (!empty($invite_code)) {
- $p_member = Member::where([['invite_code','=', $invite_code,'or'],['address','=', $invite_code,'or']])->select(['id', 'address'])->first();
- }
- if (empty($p_member)) {
- return $this->apiResponseError('member.no_invite');
- }
- $address = request()->input('address', '');
- if (empty($address)) {
- return $this->apiResponseError('地址信息异常');
- }
- $member = Member::where('address', $address)->where('status',1)->select(['id', 'token_str'])->first();
- if ($member) {
- $token_str = PassServer::creatServer()->getMemberToken($member->{'id'});
- Member::where('id', $member->{'id'})->update(['token_str' => $token_str]);
- return $this->apiResponseSuccess('登陆成功', [ 'token' => $token_str]);
- } else {
- $ret = MemberServer::creatServer()->register($address, $p_member->{'id'}, '', '');
- if (empty($ret)) {
- return $this->apiResponseError('注册失败');
- } else {
- return $this->apiResponseSuccess('注册成功', $ret);
- }
- }
- }
- /**
- * 会员登录
- * @return \Illuminate\Http\JsonResponse
- */
- function login()
- {
- $mobile = request()->input('address', '');
- if (empty($mobile)) {
- return $this->apiResponseError('地址信息错误');
- }
- $member = Member::where('address', $mobile)->select(['id', 'password', 'encrypt'])->first();
- if (empty($member)) {
- return $this->apiResponseError('当前账户未注册');
- }
- $token_str = PassServer::creatServer()->getMemberToken($member->{'id'});
- Member::where('id', $member->{'id'})->update(['token_str' => $token_str]);
- return $this->apiResponseSuccess('登陆成功', ['token' => $token_str]);
- }
- /**
- * 设置支付密码
- * @return \Illuminate\Http\JsonResponse
- */
- function setPayPass()
- {
- $password = request()->input('pay_pass', '123456');
- $password = str_replace(' ', '', $password);
- if (empty($password)) {
- return $this->apiResponseError('请设置登录密码');
- }
- $pass_two = request()->input('pass_two', '123456');
- if ($password != $pass_two) {
- return $this->apiResponseError('两次密码输入不一致');
- }
- if (!is_numeric($password) || strlen($password) != 6) {
- return $this->apiResponseError('支付密码必须为6为数字');
- }
- $member = Member::where('id', request()->member['id'])->where('status',1)->select(['id', 'password', 'encrypt', 'phone'])->first();
- $update=[];
- $code = request()->input('code', '1234');
- if (empty($code)) {
- return $this->apiResponseError('请输入验证码');
- }
- $ret = SmsServer::creatServer()->verifyCode($member->{'phone'}, $code, 'set_pay_pass');
- if (empty($ret)) {
- return $this->apiResponseError('验证码错误');
- }
- $pass_server = PassServer::creatServer($password, $member->{'encrypt'});
- $new_pass = $pass_server->creatPassword();
- $update['pay_pass']=$new_pass['password'];
- $update['encrypt']=$new_pass['encrypt'];
- $ret = $member->update($update);
- if (empty($ret)) {
- return $this->apiResponseError('支付密码修改失败');
- } else {
- MemberServer::creatServer()->delMemberCache($member->{'id'});
- return $this->apiResponseSuccess('支付密码修改成功');
- }
- }
- function getIconList(){
- $mId=request()->member['id'];
- $totalPrice=0;
- $totalUsdt=0;
- $usdtPrice=CommonServer::creatServer()->getConfigValue('usdt');
- $luckyPrice=CommonServer::creatServer()->getConfigValue('lucky');
- $list=MemberCoins::where('m_id',$mId)->select(['coin_name','coin_id','num','lock_num'])->get();
- foreach ($list as $value){
- if($value->{'coin_id'}==1){
- $value->{'price'}=round(($value->{'num'}+$value->{'lock_num'})*$usdtPrice*$luckyPrice,6);
- $value->{'totalUsdt'}=round(($value->{'num'}+$value->{'lock_num'})*$luckyPrice,6);
- }else{
- $value->{'price'}=round(($value->{'num'}+$value->{'lock_num'})*$usdtPrice,6);
- $value->{'totalUsdt'}=round($value->{'num'}+$value->{'lock_num'},6);
- }
- $totalPrice+=$value->{'price'};
- $totalUsdt+=$value->{'totalUsdt'};
- }
- return $this->apiResponseSuccess('获取信息成功',['totalPrice'=>$totalPrice,'totalUsdt'=>$totalUsdt,'list'=>$list]);
- }
- /**
- * 获取用户资产信息
- */
- function getMoneyInfo()
- {
- $member = Member::where('id', request()->member['id'])->where('status',1)->select(['id', 'money'])->first();
- return $this->apiResponseSuccess('获取成功', $member);
- }
- /**
- * 获取会员详情
- */
- function getMemberInfo()
- {
- $m_id = request()->member['id'];
- $member = RedisDataServer::creatServer()->getData('member_' . $m_id, 'json');
- if (empty($member) ) {
- $member = Member::where('id', $m_id)->select(['id', 'address', 'invite_code', 'level_id'])->first();
- if (empty($member)) {
- return $this->apiResponseError('账户信息错误', 401);
- }
- //获取推荐关联信息
- if($member->{'level_id'}<=0){
- $member->{'levelName'}='V0';
- }else{
- $member->{'levelName'}=Level::where('id',$member->{'level_id'})->value('name');
- }
- $member->{'recommendNum'}=Member::where('recom_id',$member->{'id'})->count();
- $teamIds=MemberClan::where('m_id',$member->{'id'})->value('m_ids');
- $teamIds=array_filter(explode(',',$teamIds));
- $member->{'teamNum'}=count($teamIds);
- $member->{'orderNum'}=Contract::where('m_id',$member->{'id'})->whereIn('status',[2,4])->count();
- RedisDataServer::creatServer()->setData('member_' . $m_id, $member, 'json', 30);
- }
- return $this->apiResponseSuccess('获取信息成功', $member);
- }
- /**
- * 获取推广团队基本信息
- * @return \Illuminate\Http\JsonResponse
- */
- function getTeamInfo()
- {
- $m_id = request()->member['id'];
- $member = Member::where('id', $m_id)->select(['id', 'address', 'level_id', 'recom_id'])->first();
- $member->{'team_num'} = MemberClan::from('member_clans as c')
- ->leftJoin('members as m', 'm.id', '=', 'c.m_id')
- ->where('c.one_m_id', $m_id)
- ->count();
- return $this->apiResponseSuccess('获取数据成功', $member);
- }
- /**
- * 获取团队列表
- * @return \Illuminate\Http\JsonResponse
- */
- function getTeamList()
- {
- $type = request()->input('type', '1');
- $m_id = request()->member['id'];
- $where = [];
- if ($type == 1) {
- $where[] = ['c.one_m_id', $m_id];
- } elseif ($type == 2) {
- $where[] = ['c.two_m_id', $m_id];
- } else {
- $where[] = ['c.one_m_id', '=', $m_id, 'or'];
- $where[] = ['c.two_m_id', '=', $m_id, 'or'];
- }
- $list = MemberClan::from('member_clans as c')
- ->leftJoin('members as m', 'm.id', '=', 'c.m_id')
- ->where($where)
- ->select(['m.id', 'm.address', 'level_id', 'm.created_at'])
- ->paginate(15);
- return $this->apiResponseSuccess('获取数据成功', ['total_num' => $list->total(), 'items' => $list->items()]);
- }
- }
|