wesmiler 1 năm trước cách đây
mục cha
commit
930b2a8fc8

+ 1 - 1
app/Console/Commands/WalletTask.php

@@ -224,7 +224,7 @@ class WalletTask extends Command
 
        \swoole_timer_tick(10000, function ($timer) use ($serv, &$time) { // 启用定时器,每10秒执行一次
             $date = date('Y-m-d H:i:s');
-            if($time>7200 && file_exists($this->options['log_file'])){
+            if($time>6*3600 && file_exists($this->options['log_file'])){
                 $time = 0;
                 file_put_contents($this->options['log_file'],"Task {$date}:清空日志\n");
             }

+ 2 - 0
app/Http/Controllers/Admin/AdController.php

@@ -34,4 +34,6 @@ class AdController extends Backend
         parent::__construct();
         $this->service = new AdService();
     }
+
+
 }

+ 3 - 0
app/Http/Controllers/Admin/Backend.php

@@ -14,6 +14,7 @@ namespace App\Http\Controllers\Admin;
 use App\Helpers\Jwt;
 use App\Http\Controllers\BaseController;
 use App\Models\UserModel;
+use App\Services\RedisService;
 
 /**
  * 后台控制器基类
@@ -43,6 +44,7 @@ class Backend extends BaseController
      */
     public function __construct()
     {
+
         parent::__construct();
         // 初始化配置
         $this->initConfig();
@@ -62,6 +64,7 @@ class Backend extends BaseController
             // 登录验证
             $this->initLogin($userId);
 
+            $request->headers->set('admin_id' , $userId);
             return $next($request);
         });
     }

+ 0 - 3
app/Http/Controllers/Admin/FinanceController.php

@@ -12,10 +12,7 @@
 namespace App\Http\Controllers\Admin;
 
 
-use App\Services\Common\DrawLogsService;
 use App\Services\Common\FinanceService;
-use App\Services\Common\MachineService;
-use App\Services\Common\WalletService;
 
 /**
  * 承兑商管理-控制器

+ 53 - 0
app/Http/Controllers/Admin/InstitutionalController.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+
+use App\Services\Common\InstitutionalService;
+
+/**
+ * 制度参数管理-控制器
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Http\Controllers
+ */
+class InstitutionalController extends Backend
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->service = new InstitutionalService();
+    }
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $pageSize = request()->get('limit', 15);
+        $list = $this->service->getDataList(request()->all(), $pageSize);
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => isset($list['list'])? $list['list']:[],
+            "count" => isset($list['total'])? $list['total']:0,
+        );
+        return $message;
+    }
+
+}

+ 13 - 0
app/Http/Controllers/Admin/MemberController.php

@@ -78,4 +78,17 @@ class MemberController extends Backend
         $result = $this->service->options();
         return message(1002,true, $result);
     }
+
+    /**
+     * 冻结解冻
+     * @return mixed
+     */
+    public function lock(){
+        $params = request()->post();
+        if($result = MemberService::make()->lock($params)){
+            return message(MemberService::make()->getError(),true, $result);
+        }else{
+            return message(MemberService::make()->getError(),false);
+        }
+    }
 }

+ 53 - 0
app/Http/Controllers/Admin/PledgeOrderController.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+
+use App\Services\Common\PriceLogService;
+
+/**
+ * 质押订单管理-控制器
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Http\Controllers
+ */
+class PledgeOrderController extends Backend
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->service = new PriceLogService();
+    }
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $pageSize = request()->get('limit', 15);
+        $list = $this->service->getDataList(request()->all(), $pageSize);
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => isset($list['list'])? $list['list']:[],
+            "count" => isset($list['total'])? $list['total']:0,
+        );
+        return $message;
+    }
+
+}

+ 53 - 0
app/Http/Controllers/Admin/PriceLogController.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+
+use App\Services\Common\PriceLogService;
+
+/**
+ * SBT价格记录管理-控制器
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Http\Controllers
+ */
+class PriceLogController extends Backend
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->service = new PriceLogService();
+    }
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $pageSize = request()->get('limit', 15);
+        $list = $this->service->getDataList(request()->all(), $pageSize);
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => isset($list['list'])? $list['list']:[],
+            "count" => isset($list['total'])? $list['total']:0,
+        );
+        return $message;
+    }
+
+}

+ 1 - 1
app/Http/Controllers/Admin/WalletController.php

@@ -15,7 +15,7 @@ namespace App\Http\Controllers\Admin;
 use App\Services\Common\WalletService;
 
 /**
- * 承兑商管理-控制器
+ * 平台钱包管理-控制器
  * @author laravel开发员
  * @since 2020/11/11
  * @package App\Http\Controllers

+ 53 - 0
app/Http/Controllers/Admin/WalletLogController.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+
+use App\Services\Common\WalletLogService;
+
+/**
+ * 钱包流水管理-控制器
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Http\Controllers
+ */
+class WalletLogController extends Backend
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->service = new WalletLogService();
+    }
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $pageSize = request()->get('limit', 15);
+        $list = $this->service->getDataList(request()->all(), $pageSize);
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => isset($list['list'])? $list['list']:[],
+            "count" => isset($list['total'])? $list['total']:0,
+        );
+        return $message;
+    }
+
+}

+ 4 - 11
app/Http/Controllers/Api/v1/IndexController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\v1;
 use App\Http\Controllers\Api\webApp;
 use App\Services\Api\PledgeOrderService;
 use App\Services\Api\PriceLogService;
+use App\Services\Common\AdService;
 use App\Services\ConfigService;
 use App\Services\RedisService;
 
@@ -21,21 +22,13 @@ class IndexController extends webApp
     public function data()
     {
         $cacheKey = "caches:index:data";
-//        $data = RedisService::get($cacheKey);
-        $data = [];
+        $data = RedisService::get($cacheKey);
         if(empty($data)) {
-            $num = rand(1, 10);
             $data = [
                 'sbtData' => PriceLogService::make()->getCounts(1),
                 'banners' => [
-                    'zh' => [
-                        ['id' => 1, 'title' => '轮播', 'local' => 'zh', 'cover' => get_image_url('/images/ad/20210410/1.png'), 'url' => ''],
-                        ['id' => 2, 'title' => '轮播', 'local' => 'zh', 'cover' => get_image_url('/images/ad/20210410/1.png'), 'url' => ''],
-                    ],
-                    'en' => [
-                        ['id' => 3, 'title' => '轮播', 'local' => 'en', 'cover' => get_image_url('/images/ad/20210410/1.png'), 'url' => ''],
-                        ['id' => 4, 'title' => '轮播', 'local' => 'en', 'cover' => get_image_url('/images/ad/20210410/1.png'), 'url' => ''],
-                    ]
+                    'zh' =>  AdService::make()->getListByType(1,'zh',6),
+                    'en' => AdService::make()->getListByType(1,'en',6)
                 ],
                 'siteInfo' => [
                     'site_name' => ConfigService::make()->getConfigByCode('site_name', 'SBT'),

+ 0 - 1
app/Http/Middleware/UserLogin.php

@@ -34,7 +34,6 @@ class UserLogin extends Middleware
             // JWT解密token
             $jwt = new Jwt();
             $userId = $jwt->verifyToken($token);
-
         } else {
             $userId = 0;
         }

+ 4 - 3
app/Models/ActionLogModel.php

@@ -99,7 +99,7 @@ class ActionLogModel extends BaseModel
      * @author laravel开发员
      * @since 2020/11/10
      */
-    public static function record()
+    public static function record($userId=0)
     {
         if (!self::$title) {
             // 操作控制器名
@@ -118,7 +118,8 @@ class ActionLogModel extends BaseModel
         }
 
         // 登录用户ID
-        $userId = session('userId');
+        $adminId = request()->header('admin_id',0);
+        $userId = $userId? $userId : $adminId;
         $userModel = new UserModel();
         $userInfo = $userModel->getInfo($userId);
 
@@ -135,7 +136,7 @@ class ActionLogModel extends BaseModel
             'content' => self::$content,
             'ip' => request()->ip(),
             'user_agent' => request()->server('HTTP_USER_AGENT'),
-            'create_user' => empty(session('userId')) ? 0 : session('userId'),
+            'create_user' => $userId,
             'create_time' => time(),
         ];
         // 日志入库

+ 0 - 16
app/Models/AdModel.php

@@ -38,22 +38,6 @@ class AdModel extends BaseModel
             if ($info['cover']) {
                 $info['cover'] = get_image_url($info['cover']);
             }
-            // 开始时间
-            if ($info['start_time']) {
-                $info['start_time'] = datetime($info['start_time']);
-            }
-            // 结束时间
-            if ($info['end_time']) {
-                $info['end_time'] = datetime($info['end_time']);
-            }
-            // 广告位
-            if ($info['ad_sort_id']) {
-                $adSortModel = new AdSortModel();
-                $adSortInfo = $adSortModel->getInfo($info['ad_sort_id']);
-                if ($adSortInfo) {
-                    $info['ad_sort_name'] = $adSortInfo['description'] . ">>" . $adSortInfo['loc_id'];
-                }
-            }
         }
         return $info;
     }

+ 10 - 0
app/Models/FinanceModel.php

@@ -24,6 +24,16 @@ class FinanceModel extends BaseModel
     protected $table = 'finance';
 
     /**
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function member()
+    {
+        return $this->hasOne(MemberModel::class, 'id','user_id')
+            ->where(['mark'=>1])
+            ->select(['id','nickname','parent_id','usdt','wallet_url','status']);
+    }
+
+    /**
      * 获取信息
      * @param int $id
      * @return array|string

+ 11 - 0
app/Models/MemberModel.php

@@ -35,6 +35,17 @@ class MemberModel extends BaseModel
     }
 
     /**
+     * 等级
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function level()
+    {
+        return $this->hasOne(MemberLevelModel::class, 'id','member_level')
+            ->where(['mark'=>1])
+            ->select(['id','name','upgrade_usdt','bonus_rate','weighting_rate','status']);
+    }
+
+    /**
      * 获取会员信息
      * @param int $id 会员ID
      * @return array|string

+ 11 - 0
app/Models/PledgeOrderModel.php

@@ -22,4 +22,15 @@ class PledgeOrderModel extends BaseModel
     // 设置数据表
     protected $table = 'pledge_orders';
 
+
+    /**
+     * 用户
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function member()
+    {
+        return $this->hasOne(MemberModel::class, 'id','user_id')
+            ->where(['mark'=>1])
+            ->select(['id','nickname','usdt','wallet_url','sbt','profit','avatar','status']);
+    }
 }

+ 18 - 15
app/Services/Common/AccountLogService.php

@@ -51,6 +51,10 @@ class AccountLogService extends BaseService
         if ($list) {
             foreach ($list['data'] as &$item) {
                 $item['create_time'] = datetime($item['create_time'],'Y-m-d H:i:s');
+                if($item['user_type'] == 1){
+                    $item['uid'] = $item['user_id'];
+                    $item['account'] = isset($item['nickname'])&& $item['nickname']?$item['nickname']: $item['user_id'];
+                }
             }
         }
 
@@ -79,7 +83,8 @@ class AccountLogService extends BaseService
                 $kw = isset($params['keyword']) ? trim($params['keyword']) : '';
                 if ($kw) {
                     $query->where('b.nickname', 'like', "%{$params['keyword']}%")
-                        ->orWhere('c.id', '=', "{$params['keyword']}");
+                        ->orWhere('b.wallet_url', '=', trim($params['keyword']))
+                        ->orWhere('b.id', '=', $params['keyword']);
                 }
             })
             ->where(function ($query) use($params){
@@ -101,6 +106,11 @@ class AccountLogService extends BaseService
                     $query->where('a.order_no', 'like', "%{$orderNo}%");
                 }
 
+                $hash = isset($params['hash'])? trim($params['hash']) : '';
+                if($hash){
+                    $query->where('a.hash', '=', trim($hash));
+                }
+
                 $walletUrl = isset($params['wallet_url']) ? trim($params['wallet_url']) : '';
                 if ($walletUrl) {
                     $query->where('b.wallet_url', $walletUrl);
@@ -144,16 +154,15 @@ class AccountLogService extends BaseService
     {
         $query = $this->getQuery($params);
         $count = $query->count('a.id');
-        $total = $query->sum('a.money');
         $query1 = clone $query;
         $query2 = clone $query;
         $total1 = $query1->where('a.money','>',0)->sum('a.money');
         $total2 = $query2->where('a.money','<=',0)->sum('a.money');
         return [
             'count'  => $count,
-            'total1' => round($total1,2), // 进
-            'total2' => round($total2,2), // 出
-            'total' => round($total,2)
+            'total1' => round(abs($total1),2), // 进
+            'total2' => round(abs($total2),2), // 出
+            'total' => round(abs($total1)+abs($total2),2)
         ];
     }
 
@@ -181,11 +190,11 @@ class AccountLogService extends BaseService
             return false;
         }
 
-        $userTypes = [1=>'会员',2=>'商家',3=>'承兑商'];
-        $fields = [1=>'usdt',2=>'balance',3=>'power_num',4=>'score',5=>'wait_score',6=>'quota'];
-        $coinNames = [1=>'USDT余额',2=>'星豆余额',3=>'算力',4=>'积分',5=>'待返积分',6=>'交易额度'];
+        $userTypes = [1=>'会员'];
+        $fields = [1=>'usdt',2=>'sbt',3=>'profit'];
+        $coinNames = [1=>'USDT余额',2=>'SBT',3=>'收益/奖励'];
         $field = isset($fields[$coinType])? $fields[$coinType] : 'usdt';
-        $coinName = isset($coinNames[$coinType])? $coinNames[$coinType] : 'USDT 余额';
+        $coinName = isset($coinNames[$coinType])? $coinNames[$coinType] : 'USDT余额';
         $accountName = isset($userTypes[$userType])? $userTypes[$userType] : '会员';
         ActionLogModel::setTitle("{$accountName}[ID:{$accountId}]{$coinName}账户调整");
         ActionLogModel::record();
@@ -236,9 +245,6 @@ class AccountLogService extends BaseService
 
             DB::commit();
 
-            $dateTime = date('Y-m-d H:i:s');
-            $actionName = $type==1?"平台上分":"平台下分";
-            MessageService::make()->pushMessage($userId,$type==1?"平台上分成功通知":"平台下分成功通知","您在{$dateTime}(UTC+8)收到{$actionName}[{$amount}]{$coinName}账户调整成功,请及时查看对应账户进行查收",3);
             $this->error = 1002;
             return true;
 
@@ -288,9 +294,6 @@ class AccountLogService extends BaseService
 
             DB::commit();
 
-            $dateTime = date('Y-m-d H:i:s');
-            $actionName = $type==1?"平台上分":"平台下分";
-            MessageService::make()->pushMessage($userId,$type==1?"平台上分成功通知":"平台下分成功通知","您在{$dateTime}(UTC+8)收到{$actionName}[{$amount}]{$coinName}账户调整成功,请及时查看对应账户进行查收",3);
             $this->error = 1002;
             return true;
         }

+ 32 - 7
app/Services/Common/AdService.php

@@ -13,6 +13,7 @@ namespace App\Services\Common;
 
 use App\Models\AdModel;
 use App\Services\BaseService;
+use App\Services\RedisService;
 
 /**
  * 广告管理-服务类
@@ -50,15 +51,39 @@ class AdService extends BaseService
         } else {
             $data['cover'] = str_replace(IMG_URL, "", $data['cover']);
         }
-        // 开始时间
-        if ($data['start_time']) {
-            $data['start_time'] = strtotime($data['start_time']);
+
+
+        return parent::edit($data); // TODO: Change the autogenerated stub
+    }
+
+    /**
+     * 按未知获取广告
+     * @param $position 广告位
+     * @param $locale 语言:zh-中文,en-英文
+     * @param int $limit
+     * @return array|mixed
+     */
+    public function getListByType($position, $locale, $limit=6)
+    {
+        $cahceKey = "caches:adverts:{$position}_{$locale}_{$limit}";
+        $datas = RedisService::get($cahceKey);
+        if($datas){
+            return $datas;
         }
-        // 结束时间
-        if ($data['end_time']) {
-            $data['end_time'] = strtotime($data['end_time']);
+
+        $datas = $this->model->where(['position'=> $position,'locale'=> $locale,'status'=>1,'mark'=>1])
+            ->limit($limit? $limit : 6)
+            ->get();
+        $datas = $datas? $datas->toArray() : [];
+        if($datas){
+            foreach ($datas as &$item){
+                $item['cover'] = $item['cover']? get_image_url($item['cover']) : '';
+            }
+
+            RedisService::set($cahceKey, $datas, rand(3600, 7200));
         }
-        return parent::edit($data); // TODO: Change the autogenerated stub
+
+        return $datas;
     }
 
 }

+ 16 - 215
app/Services/Common/BalanceLogService.php

@@ -11,21 +11,18 @@
 
 namespace App\Services\Common;
 
-use App\Models\AcceptorModel;
 use App\Models\AccountLogModel;
 use App\Models\ActionLogModel;
 use App\Models\BalanceLogModel;
 use App\Models\MemberModel;
-use App\Models\MerchantModel;
 use App\Services\Api\FinanceService;
-use App\Services\Api\MessageService;
 use App\Services\BaseService;
 use App\Services\RedisService;
 use App\Services\WalletService;
 use Illuminate\Support\Facades\DB;
 
 /**
- * 承兑商管理-服务类
+ * 充值提现管理-服务类
  * @author laravel开发员
  * @since 2020/11/11
  * @package App\Services\Common
@@ -66,7 +63,7 @@ class BalanceLogService extends BaseService
     public function getDataList($params, $pageSize = 10, $field = [])
     {
         $query = $this->getQuery($params);
-        $list = $query->select($field ? $field : ['a.*', 'b.username','b.trc_url as user_trc_url', 'b.nickname','c.user_id as merchant_uid','d.user_id as acceptor_uid'])
+        $list = $query->select($field ? $field : ['a.*', 'b.nickname'])
             ->orderBy('a.status','asc')
             ->orderBy('a.create_time','desc')
             ->orderBy('a.pay_at','desc')
@@ -75,17 +72,9 @@ class BalanceLogService extends BaseService
         if ($list) {
             foreach ($list['data'] as &$item) {
                 $item['create_time'] = datetime($item['create_time'],'Y-m-d H:i:s');
-                $item['pay_img'] = isset($item['pay_img'])?get_image_url($item['pay_img']):'';
-                $item['trc_url'] = $item['trc_url']?$item['trc_url'] : $item['user_trc_url'];
                 if($item['user_type'] == 1){
                     $item['uid'] = $item['user_id'];
-                    $item['account'] = isset($item['nickname'])&& $item['nickname']?$item['nickname'].(isset($item['username'])?' '.$item['username']:'') : $item['user_id'];
-                }else if($item['user_type'] == 2){
-                    $item['uid'] = isset($item['merchant']['user_id'])&& $item['merchant']? $item['merchant']['user_id'] : 0;
-                    $item['account'] = isset($item['merchant']['nickname'])&& $item['merchant']?$item['merchant']['nickname'].(isset($item['merchant']['mobile'])?' '.$item['merchant']['mobile']:'')  : $item['merchant_uid'];
-                }else if($item['user_type'] == 3){
-                    $item['uid'] = isset($item['acceptor']['user_id'])&& $item['acceptor']? $item['acceptor']['user_id'] : 0;
-                    $item['account'] = isset($item['acceptor']['nickname'])&& $item['acceptor']?$item['acceptor']['nickname'].(isset($item['acceptor']['mobile'])?' '.$item['acceptor']['mobile']:'')  : $item['acceptor_uid'];
+                    $item['account'] = isset($item['nickname'])&& $item['nickname']? $item['nickname'] : $item['user_id'];
                 }
             }
         }
@@ -105,44 +94,18 @@ class BalanceLogService extends BaseService
     public function getQuery($params)
     {
         $where = ['a.mark' => 1];
-        return $this->model->with(['member','acceptor','merchant','payment'])
+        return $this->model->with(['member'])
             ->from('balance_logs as a')
             ->leftJoin('member as b', function($join) {
                 $join->on('b.id','=', 'a.user_id')->where('a.user_type',1);
             })
-            ->leftJoin('merchant as c', function($join) {
-                $join->on('c.id','=', 'a.user_id')->where('a.user_type',2);
-            })
-            ->leftJoin('acceptor as d', function($join) {
-                $join->on('d.id','=', 'a.user_id')->where('a.user_type',3);
-            })
             ->where($where)
             ->where(function ($query) use ($params) {
-                $userType = isset($params['user_type'])? intval($params['user_type']) : 1;
                 $kw = isset($params['keyword']) ? trim($params['keyword']) : '';
 
                 if ($kw) {
-                    if($userType == 3){
-                        $query->where('d.user_id', '=', "{$params['keyword']}")
-                            ->orWhere('d.name', 'like', "%{$params['keyword']}%")
-                            ->orWhere('d.mobile', 'like', "%{$params['keyword']}%");
-                    }else if($userType == 2){
-                        $query->where('c.user_id', '=', "{$params['keyword']}")
-                            ->orWhere('c.name', 'like', "%{$params['keyword']}%")
-                            ->orWhere('c.mobile', 'like', "%{$params['keyword']}%");
-                    }else if($userType == 1){
-                        $query->where('b.id', '=', "{$params['keyword']}")
-                            ->orWhere('b.nickname', 'like', "%{$params['keyword']}%")
-                            ->orWhere('b.username', 'like', "%{$params['keyword']}%");
-                    }else{
-                        $query->where('a.user_id', '=', "{$params['keyword']}")
-                            ->orWhere('b.nickname', 'like', "%{$params['keyword']}%")
-                            ->orWhere('b.username', 'like', "%{$params['keyword']}%")
-                            ->orWhere('c.name', 'like', "%{$params['keyword']}%")
-                            ->orWhere('c.mobile', 'like', "%{$params['keyword']}%")
-                            ->orWhere('d.name', 'like', "%{$params['keyword']}%")
-                            ->orWhere('d.mobile', 'like', "%{$params['keyword']}%");
-                    }
+                    $query->where('b.id', '=', $params['keyword'])
+                        ->orWhere('b.nickname', 'like', "%{$params['keyword']}%");
                 }
             })
             ->where(function ($query) use($params){
@@ -163,19 +126,19 @@ class BalanceLogService extends BaseService
                     $query->where('a.order_no', 'like', "%{$orderNo}%");
                 }
 
-                $trcUrl = isset($params['trc_url'])? trim($params['trc_url']) : '';
-                if($trcUrl){
-                    $query->where('a.trc_url', '=', $trcUrl);
+                $walletUrl = isset($params['wallet_url'])? trim($params['wallet_url']) : '';
+                if($walletUrl){
+                    $query->where('a.wallet_url', '=', $walletUrl);
                 }
 
-                $hash = isset($params['hash'])? trim($params['hash']) : '';
-                if($hash){
-                    $query->where('a.trc_url', '=', $hash);
+                $ptWalletUrl = isset($params['pt_wallet_url'])? trim($params['pt_wallet_url']) : '';
+                if($ptWalletUrl){
+                    $query->where('a.pt_wallet_url', '=', $ptWalletUrl);
                 }
 
-                $orderNo = isset($params['order_no'])? trim($params['order_no']) : '';
-                if($orderNo){
-                    $query->where('a.order_no', 'like', "%{$orderNo}%");
+                $hash = isset($params['hash'])? trim($params['hash']) : '';
+                if($hash){
+                    $query->where('a.hash', '=', $hash);
                 }
 
                 $userType = isset($params['user_type'])? $params['user_type'] : 0;
@@ -225,7 +188,7 @@ class BalanceLogService extends BaseService
     {
         $query = $this->getQuery($params);
         $count = $query->count('a.id');
-        $total = $query->sum('a.actual_money');
+        $total = $query->sum('a.money');
         return [
             'count'  => $count,
             'total' => $total
@@ -233,168 +196,6 @@ class BalanceLogService extends BaseService
     }
 
     /**
-     * 充值审核
-     * @param $params
-     * @return bool
-     */
-    public function rechargeAuth($params)
-    {
-        $id = isset($params['id'])? $params['id'] : 0;
-        $checkStatus = isset($params['status'])? $params['status'] : 0;
-        $remark = isset($params['audit_remark'])? trim($params['audit_remark']) : '';
-        $payImg = isset($params['pay_img'])? trim($params['pay_img']) : '';
-        if(!in_array($checkStatus,[2,3])){
-            $this->error = 1073;
-            return false;
-        }
-
-        $info = $this->model->with(['member','merchant','acceptor'])->where(['id'=> $id,'mark'=>1])->first();
-        $type = isset($info['type'])? $info['type'] : 0;
-        $userType = isset($info['user_type'])? $info['user_type'] : 0;
-        $coinType = isset($info['coin_type'])? $info['coin_type'] : 0;
-        $payType = isset($info['pay_type'])? $info['pay_type'] : 0;
-        $accountId = isset($info['user_id'])? $info['user_id'] : 0;
-        $money = isset($info['money'])? $info['money'] : 0;
-        $actualMoney = isset($info['actual_money'])? $info['actual_money'] : 0;
-        $status = isset($info['status'])? $info['status'] : 0;
-        if($id<=0 || empty($info) || $accountId<=0){
-            $this->error = 4001;
-            return false;
-        }
-
-        if($status != 1){
-            $this->error = 4002;
-            return false;
-        }
-
-        if($type != 1){
-            $this->error = 1031;
-            return false;
-        }
-        $cacheKey ="caches:recharge:lock_{$id}";
-        if(RedisService::get($cacheKey)){
-            $this->error = 1034;
-//            return false;
-        }
-
-        // 绑定的用户ID
-        $userId = $accountId;
-        $userInfo = isset($info['member'])? $info['member'] : [];
-        $balance = isset($userInfo['usdt'])? $userInfo['usdt'] : 0;
-        if($userType == 2){
-            $userInfo = isset($info['merchant'])? $info['merchant'] : [];
-            $userId = isset($userInfo['user_id'])? $userInfo['user_id'] : 0;
-            $balance = isset($userInfo['usdt'])? $userInfo['usdt'] : 0;
-        }else if($userType == 3){
-            $userInfo = isset($info['acceptor'])? $info['acceptor'] : [];
-            $userId = isset($userInfo['user_id'])? $userInfo['user_id'] : 0;
-            $balance = isset($userInfo['quota'])? $userInfo['quota'] : 0;
-        }
-
-        if(empty($userInfo)){
-            $this->error = 4004;
-            return false;
-        }
-
-        // 审核处理
-        RedisService::set($cacheKey, true, rand(2,3));
-        $updateData = ['status'=> $checkStatus,'audit_remark'=> $remark,'update_time'=> time()];
-        DB::beginTransaction();
-        if(!$this->model->where(['id'=> $id])->update($updateData)){
-            DB::rollBack();
-            $this->error = 1072;
-            RedisService::clear($cacheKey);
-            return false;
-        }
-
-        // 审核通过到账处理
-        $dateTime = date('Y-m-d H:i:s');
-        $coinTypes = [1=>'USDT余额',2=>'星豆余额',6=>'交易额度'];
-        $accountTypes = [1=>'会员账户',2=>'商家账户',3=>'承兑商账户'];
-        $coinName = isset($coinTypes[$coinType])? $coinTypes[$coinType] : '账户';
-        $accountName = isset($accountTypes[$userType])? $accountTypes[$userType] : '会员账户';
-        if($checkStatus == 2) {
-            // 线下交易
-            if($payType == 30){
-                if(!in_array($userType,[1,3]) && !in_array($coinType,[1,6])){
-                    DB::rollBack();
-                    $this->error = 1021;
-                    RedisService::clear($cacheKey);
-                    return false;
-                }
-
-                // USDT入账
-                if($userType == 1 && $coinType == 1){
-                    $updateData = ['usdt' => DB::raw("usdt + {$actualMoney}"),'update_time'=>time()];
-                    if (!MemberModel::where(['id' => $accountId])->update($updateData)){
-                        DB::rollBack();
-                        $this->error = 1072;
-                        RedisService::clear($cacheKey);
-                        return false;
-                    }
-                }
-                // 交易额度入账
-                else if($userType == 3 && $coinType == 6){
-                    $updateData = ['quota' => DB::raw("quota + {$actualMoney}"),'update_time'=>time()];
-                    if (!AcceptorModel::where(['id' => $accountId])->update($updateData)){
-                        DB::rollBack();
-                        $this->error = 1072;
-                        RedisService::clear($cacheKey);
-                        return false;
-                    }
-                }
-
-                // 账户明细
-                $log = [
-                    'user_id' => $accountId,
-                    'source_id' => 0,
-                    'source_order_no' => $info['order_no'],
-                    'type' => 5,
-                    'coin_type' => $coinType,
-                    'user_type'=> $userType,
-                    'money' => $money,
-                    'actual_money' => $actualMoney,
-                    'balance' => $balance,
-                    'create_time' => time(),
-                    'update_time' => time(),
-                    'remark' => "{$coinName}充值",
-                    'status' => 1,
-                    'mark' => 1,
-                ];
-                if(!AccountLogModel::insertGetId($log)){
-                    DB::rollBack();
-                    $this->error = 2029;
-                    RedisService::clear($cacheKey);
-                    return false;
-                }
-
-            }else{
-                DB::rollBack();
-                $this->error = 1021;
-                RedisService::clear($cacheKey);
-                return false;
-            }
-
-            $title = "{$coinName}充值审核成功通知";
-            $message = "您的充值申请在{$dateTime}UTC+8审核成功,明细如下:\n单号:{$info['order_no']}\n账户:{$accountName}\n金额:{$money}\n到账:{$actualMoney}\n审核状态:成功\n审核说明:{$remark}";
-
-        }else{
-            $title = "{$coinName}充值审核失败通知";
-            $message = "您的充值申请在{$dateTime}UTC+8审核失败,明细如下:\n单号:{$info['order_no']}\n账户:{$accountName}\n金额:{$money}\n到账:{$actualMoney}\n审核状态:未通过\n审核说明:{$remark}";
-        }
-
-        // 消息通知
-        MessageService::make()->pushMessage($userId, $title, $message, 3);
-
-        DB::commit();
-        $this->error = 1071;
-        RedisService::clear($cacheKey);
-        ActionLogModel::setTitle("充值审核");
-        ActionLogModel::record();
-        return true;
-    }
-
-    /**
      * 提现审核
      * @param $params
      * @return bool

+ 21 - 5
app/Services/Common/FinanceService.php

@@ -11,13 +11,11 @@
 
 namespace App\Services\Common;
 
-use App\Models\AcceptorModel;
-use App\Models\BalanceLogModel;
 use App\Models\FinanceModel;
 use App\Services\BaseService;
 
 /**
- * 承兑商管理-服务类
+ * 财务管理-服务类
  * @author laravel开发员
  * @since 2020/11/11
  * @package App\Services\Common
@@ -53,11 +51,25 @@ class FinanceService extends BaseService
             $query->where(function ($query) use ($params) {
                 $kw = isset($params['keyword']) ? trim($params['keyword']) : '';
                 if ($kw) {
-                    $query->where('b.nickname', 'like', "%{$params['keyword']}%")->orWhere('b.realname', 'like', "%{$params['keyword']}%")->orWhere('b.username', 'like', "%{$params['keyword']}%");
+                    $query->where('b.nickname', 'like', "%{$params['keyword']}%");
                 }
             });
         }
 
+        // 日期
+        if (isset($params['date']) && $params['date'] != '') {
+            $date = isset($params['date']) ? $params['date'] : [];
+            $start = isset($date[0]) ? $date[0] : '';
+            $end = isset($date[1]) ? $date[1] : '';
+            $end = $start > $end ? '' : $end;
+            if ($start) {
+                $query->where('a.date', '>=', $start);
+            }
+            if ($end) {
+                $query->where('a.date', '<=', $end);
+            }
+        }
+
         if (isset($params['type'])) {
             if (is_array($params['type'])) {
                 $query->whereIn('a.type', $params['type']);
@@ -78,7 +90,7 @@ class FinanceService extends BaseService
             }
         }
 
-        if (isset($params['status'])) {
+        if (isset($params['status']) && $params['status']>0) {
             if (is_array($params['status'])) {
                 $query->whereIn('a.status', $params['status']);
             } else {
@@ -104,6 +116,10 @@ class FinanceService extends BaseService
         ];
     }
 
+    /**
+     * 统计
+     * @return array
+     */
     public function getCount()
     {
         $expenses = FinanceModel::where(['user_id' => 0])->sum('expend');

+ 107 - 0
app/Services/Common/InstitutionalService.php

@@ -0,0 +1,107 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\InstitutionalModel;
+use App\Services\BaseService;
+
+/**
+ * 制度参数管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Services\Common
+ */
+class InstitutionalService extends BaseService
+{
+    // 静态对象
+    protected static $instance = null;
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        $this->model = new InstitutionalModel();
+    }
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = (new static());
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 获取列表
+     * @param $params 参数
+     * @param int $pageSize 分页大小:默认 15
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 10, $field = [])
+    {
+        $query = $this->getQuery($params);
+        $list = $query->select($field ? $field : ['a.*'])
+            ->orderBy('a.id','desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item) {
+                $item['create_time'] = datetime($item['create_time'],'Y-m-d H:i:s');
+            }
+        }
+
+        return [
+            'pageSize' => $pageSize,
+            'total'    => isset($list['total']) ? $list['total'] : 0,
+            'list'     => isset($list['data']) ? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 查询构造
+     * @param $params
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function getQuery($params)
+    {
+        $where = ['a.mark' => 1];
+        return $this->model->from('institutional as a')
+            ->where($where)
+            ->where(function ($query) use ($params) {
+                $kw = isset($params['keyword']) ? trim($params['keyword']) : '';
+                if ($kw) {
+                    $query->where('a.name', 'like', "%{$params['keyword']}%");
+                }
+            })
+            ->where(function ($query) use($params){
+                $type = isset($params['type'])? $params['type'] : 0;
+                if ($type) {
+                    $query->where('a.type', $type);
+                }
+
+                $status = isset($params['status'])? $params['status'] : 0;
+                if (is_array($status)) {
+                    $query->whereIn('a.status', $status);
+                } else if($status){
+                    $query->where('a.status', $status);
+                }
+            });
+    }
+
+}

+ 85 - 96
app/Services/Common/MemberService.php

@@ -15,6 +15,7 @@ use App\Models\ActionLogModel;
 use App\Models\MemberModel;
 use App\Services\BaseService;
 use App\Services\RedisService;
+use Illuminate\Support\Facades\DB;
 
 /**
  * 会员管理-服务类
@@ -49,19 +50,19 @@ class MemberService extends BaseService
         if($status>0){
             $where['a.status'] = $status;
         }
-        $list = $this->model->with(['level','parent','point'])
+        $list = $this->model->with(['level','parent'])
             ->from('member as a')
             ->leftJoin('member as b','b.id','a.parent_id')
             ->where($where)
             ->where(function($query) use($params){
-                $trcUrl = isset($params['trc_url'])? trim($params['trc_url']) : '';
-                if($trcUrl){
-                    $query->where('a.trc_url','like',"%{$trcUrl}%");
+                $walletUrl = isset($params['wallet_url'])? trim($params['wallet_url']) : '';
+                if($walletUrl){
+                    $query->where('a.wallet_url','like',"%{$walletUrl}%");
                 }
 
-                $parentUrl = isset($params['parent_trc_url'])? trim($params['parent_trc_url']) : '';
+                $parentUrl = isset($params['parent_url'])? trim($params['parent_url']) : '';
                 if($parentUrl){
-                    $query->where('b.trc_url','like',"%{$parentUrl}%");
+                    $query->where('b.wallet_url','like',"%{$parentUrl}%");
                 }
 
                 $parentId = isset($params['parent_id'])? intval($params['parent_id']) : 0;
@@ -69,27 +70,26 @@ class MemberService extends BaseService
                     $query->where('a.parent_id',$parentId);
                 }
 
-                $pointId = isset($params['point_id'])? intval($params['point_id']) : 0;
-                if($pointId){
-                    $query->where('a.point_id',$pointId);
+                $teamId = isset($params['team_id'])? intval($params['team_id']) : 0;
+                if($teamId){
+                    $query->whereRaw("FIND_IN_SET({$teamId},lev_a.parent_ids)");
                 }
+
             })
             ->where(function($query) use($params){
                 $account = isset($params['account'])? trim($params['account']) : '';
                 if($account){
-                    $query->where('a.username','like',"%{$account}%")->orWhere('a.nickname','like',"%{$account}%");
+                    $query->where('a.nickname','like',"%{$account}%")->orWhere('a.id','=', intval($account));
                 }
             })
-            ->select($field? $field : ['a.*','b.trc_url as parent_trc_url'])
+            ->select($field? $field : ['a.*','b.wallet_url as parent_url'])
             ->paginate($pageSize > 0 ? $pageSize : 9999999);
         $list = $list? $list->toArray() :[];
         if($list){
             foreach($list['data'] as &$item){
-                $item['create_time_text'] = $item['create_time']? datetime($item['create_time']):'';
-                $item['avatar'] = $item['avatar']? get_image_url($item['avatar']): get_image_url('/images/member/logo.png');
+                $item['create_time_text'] = $item['create_time']? datetime($item['create_time'],'Y.m.d H:i:s'):'';
                 $item['invite_num'] = $this->model->where(['parent_id'=> $item['id'],'mark'=>1])->count('id');
-                $item['team_num'] = $this->model->where(['mark'=>1])->whereRaw('FIND_IN_SET(?,parents)', $item['id'])->count('id');
-                $item['point_num'] = $this->model->where(['point_id'=>$item['id'],'mark'=>1])->count('id');
+                $item['team_num'] = $this->model->where(['mark'=>1])->whereRaw('FIND_IN_SET(?,parent_ids)', $item['id'])->count('id');
             }
         }
 
@@ -112,35 +112,42 @@ class MemberService extends BaseService
         // 请求参数
         $data = request()->all();
         // 头像处理
-        $avatar = trim($data['avatar']);
-        if (strpos($avatar, "temp")) {
-            $data['avatar'] = save_image($avatar, 'member');
-        } else {
-            $data['avatar'] = str_replace(IMG_URL, "", $data['avatar']);
-        }
-        // 出生日期
-        if ($data['birthday']) {
-            $data['birthday'] = strtotime($data['birthday']);
-        }
-        // 城市处理
-        $city = isset($data['city']) ? $data['city'] : [3];
-        if (!empty($data['city'])) {
-            // 省份
-            $data['province_id'] = $city[0];
-            // 城市
-            $data['city_id'] = $city[1];
-            // 县区
-            $data['district_id'] = $city[2];
+        if($data['avatar']){
+            $avatar = trim($data['avatar']);
+            if (strpos($avatar, "temp")) {
+                $data['avatar'] = save_image($avatar, 'member');
+            } else {
+                $data['avatar'] = str_replace(IMG_URL, "", $data['avatar']);
+            }
         }
+
+
         if(isset($data['password']) && $data['password']){
             $data['password'] = get_password(trim($data['password']));
         }
-        unset($data['city']);
-        ActionLogModel::setTitle("修改会员信息");
-        ActionLogModel::record();
 
+        DB::beginTransaction();
+        try {
+            // 判断团队分红比例
+
+
+            $result = parent::edit($data);
+            $success = isset($result['success']) ? $result['success'] : false;
+            if(!$success){
+                DB::rollBack();
+                return $result;
+            }
+
+            // 判断是否修改了上级
 
-        return parent::edit($data); // TODO: Change the autogenerated stub
+            ActionLogModel::setTitle("修改会员信息");
+            ActionLogModel::record();
+
+            DB::commit();
+            return $result;
+        } catch (\Exception $exception){
+            return message(1003, false, ['error'=> $exception->getMessage()]);
+        }
     }
 
     /**
@@ -156,26 +163,40 @@ class MemberService extends BaseService
         $parentId = getter($param, "parent_id");
         $userId = getter($param, "user_id");
         $datas = $this->model->where(function($query) use($parentId){
-            if($parentId){
-                $query->where(['id'=> $parentId,'mark'=>1]);
-            }else{
-                $query->where(['status'=> 1,'mark'=>1]);
-            }
-        })
+                if($parentId){
+                    $query->where(['id'=> $parentId,'mark'=>1]);
+                }else{
+                    $query->where(['status'=> 1,'mark'=>1]);
+                }
+            })
             ->where(function($query) use($userId){
                 if($userId){
                     $query->whereNotIn('id', [$userId]);
+                    $query->whereRaw("NOT FIND_IN_SET({$userId},parent_ids)");
                 }
             })
             ->where(function($query) use($keyword){
                 if($keyword){
-                    $query->where('username','like',"{$keyword}%")->orWhere('mobile','like',"{$keyword}%");
+                    $query->where('nickname','like',"{$keyword}%")->orWhere('wallet_url','like',"{$keyword}%");
                 }
             })
-            ->select(['id','username','mobile','code','nickname','status'])
+            ->select(['id','wallet_url','code','nickname','status'])
             ->get();
+        $datas = $datas? $datas->toArray() : [];
+        if($datas){
+            foreach ($datas as &$item){
+                $labels = ['ID:'.$item['id']];
+                if($item['nickname']){
+                    $labels[] = $item['nickname'];
+                }
+                if($item['wallet_url']){
+                    $labels[] = format_str($item['wallet_url'], 6,6);
+                }
+                $item['label'] = implode(' ', $labels);
+            }
+        }
 
-        return $datas? $datas->toArray() : [];
+        return $datas;
     }
 
     /**
@@ -204,69 +225,37 @@ class MemberService extends BaseService
             })
             ->where(function($query) use($keyword){
                 if($keyword){
-                    $query->where('nickname','like',"%{$keyword}%")->orWhere('username','like',"%{$keyword}%");
+                    $query->where('nickname','like',"%{$keyword}%")->orWhere('wallet_url','like',"%{$keyword}%");
                 }
             })
-            ->select(['id','username','mobile','code','nickname','status'])
+            ->select(['id','code','nickname','wallet_url','status'])
             ->get();
 
         return $datas? $datas->toArray() : [];
     }
 
     /**
-     * 推荐树
-     * @return array|false|mixed
+     * 批量冻结解冻
+     * @param $params 参数:user_id-用户ID,type-(1-冻结,2-解冻)
+     * @return bool
      */
-    public function getTree()
+    public function lock($params)
     {
-        // 请求参数
-        $keyword = request()->post('keyword','');
-        $cacheKey = "caches:member:trees:".md5('t'.$keyword);
-        $datas =  RedisService::get($cacheKey);
-        if($datas){
-            return $datas;
+        $type = isset($params['type'])? intval($params['type']) : 0;
+        $userId = isset($params['user_id'])? intval($params['user_id']) : 0;
+        if($userId<=0){
+            $this->error = 2014;
+            return false;
         }
 
-        $datas = $this->model->where(['status'=>1,'mark'=>1])
-            ->select(['id','username','nickname','mobile','parent_id','trc_url','point_id','status'])
-            ->get()
-            ->keyBy('id');
-        $datas =  $datas? $datas->toArray() : [];
-
-        $pid = 0;
-        if($keyword){
-            $data = $this->model->where(function($query) use($keyword){
-                $query->where('id','=', $keyword)
-                    ->orWhere('nickname','like',"%{$keyword}%")
-                    ->orWhere('username','like',"%{$keyword}%")
-                    ->orWhere('trc_url','=',trim($keyword));
-            })
-                ->where(['status'=>1,'mark'=>1])
-                ->orderBy('parent_id','asc')
-                ->select(['id','parent_id','nickname','trc_url','username'])
-                ->first();
-            $id = isset($data['id'])? $data['id'] : 0;
-            $nickname = isset($data['nickname'])? $data['nickname'] : '';
-            $username = isset($data['username'])? $data['username'] : '';
-            $trcUrl = isset($data['trc_url']) && $data['trc_url']? format_mobile($data['trc_url']) : '';
-            if($data){
-                $pid = isset($data['id'])? $data['id'] : 0;
-                $data['label'] = $nickname."(ID:{$id} {$trcUrl})";
-                unset($data['nickname']);
-                unset($data['username']);
-            }
+        $status = $type==1? 2 : 1;
+        if(!$this->model->whereRaw("FIND_IN_SET({$userId},parent_ids)")->where(['status'=>$status==1?2:1,'mark'=>1])->update(['status'=>$status,'update_time'=>time()])){
+            $this->error = 1003;
+            return false;
         }
 
-        $datas = get_tree($datas, $pid);
-        if($datas){
-            if($pid){
-                $data['children'] = $datas;
-                $newDatas[0] = $data;
-                $datas = $newDatas;
-            }
-            RedisService::set($cacheKey, $datas, rand(3,5));
-        }
-        return $datas;
+        $this->error = 1002;
+        return true;
     }
 
 }

+ 149 - 0
app/Services/Common/PledgeOrderService.php

@@ -0,0 +1,149 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\PledgeOrderModel;
+use App\Services\BaseService;
+
+/**
+ * 质押订单管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Services\Common
+ */
+class PledgeOrderService extends BaseService
+{
+    // 静态对象
+    protected static $instance = null;
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        $this->model = new PledgeOrderModel();
+    }
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = (new static());
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 获取列表
+     * @param $params 参数
+     * @param int $pageSize 分页大小:默认 15
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 10, $field = [])
+    {
+        $query = $this->getQuery($params);
+        $list = $query->select($field ? $field : ['a.*', 'b.nickname','b.wallet_url'])
+            ->orderBy('a.create_time','desc')
+            ->orderBy('a.id','desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item) {
+                $item['create_time'] = datetime($item['create_time'],'Y-m-d H:i:s');
+                if($item['user_type'] == 1){
+                    $item['uid'] = $item['user_id'];
+                    $item['account'] = isset($item['nickname'])&& $item['nickname']? $item['nickname'] : $item['user_id'];
+                }
+            }
+        }
+
+        return [
+            'pageSize' => $pageSize,
+            'total'    => isset($list['total']) ? $list['total'] : 0,
+            'list'     => isset($list['data']) ? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 查询构造
+     * @param $params
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function getQuery($params)
+    {
+        $where = ['a.mark' => 1];
+        return $this->model->with(['member'])
+            ->from('pledge_orders as a')
+            ->leftJoin('member as b', function($join) {
+                $join->on('b.id','=', 'a.user_id');
+            })
+            ->where($where)
+            ->where(function ($query) use ($params) {
+                $kw = isset($params['keyword']) ? trim($params['keyword']) : '';
+
+                if ($kw) {
+                    $query->where('b.id', '=', $params['keyword'])
+                        ->orWhere('b.nickname', 'like', "%{$params['keyword']}%")
+                        ->orWhere('b.wallet_url', '=', trim($params['keyword']));
+                }
+            })
+            ->where(function ($query) use($params){
+                // 日期
+                $date = isset($params['date']) ? $params['date'] : [];
+                $start = isset($date[0])? $date[0] : '';
+                $end = isset($date[1])? $date[1] : '';
+                $end = $start>$end? '' : $end;
+                if ($start) {
+                    $query->where('a.create_time','>=', strtotime($start));
+                }
+                if($end){
+                    $query->where('a.create_time','<=', strtotime($end));
+                }
+
+                $orderNo = isset($params['order_no'])? trim($params['order_no']) : '';
+                if($orderNo){
+                    $query->where('a.order_no', 'like', "%{$orderNo}%");
+                }
+
+                $status = isset($params['status'])? $params['status'] : 0;
+                if (is_array($status)) {
+                    $query->whereIn('a.status', $status);
+                } else if($status){
+                    $query->where('a.status', $status);
+                }
+            });
+    }
+
+    /**
+     * 统计
+     * @param $params
+     * @return array
+     */
+    public function count($params)
+    {
+        $query = $this->getQuery($params);
+        $count = $query->count('a.id');
+        $total = $query->sum('a.money');
+        $profit = $query->sum('a.profit');
+        return [
+            'count'  => $count,
+            'total' => $total,
+            'profit' => $profit,
+        ];
+    }
+
+}

+ 109 - 0
app/Services/Common/PriceLogService.php

@@ -0,0 +1,109 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\PriceLogModel;
+use App\Services\BaseService;
+
+/**
+ * SBT价格记录管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Services\Common
+ */
+class PriceLogService extends BaseService
+{
+    // 静态对象
+    protected static $instance = null;
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        $this->model = new PriceLogModel();
+    }
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = (new static());
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 获取列表
+     * @param $params 参数
+     * @param int $pageSize 分页大小:默认 15
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 10, $field = [])
+    {
+        $query = $this->getQuery($params);
+        $list = $query->select($field ? $field : ['a.*'])
+            ->orderBy('a.date','desc')
+            ->orderBy('a.id','desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item) {
+                $item['create_time'] = datetime($item['create_time'],'Y-m-d H:i:s');
+            }
+        }
+
+        return [
+            'pageSize' => $pageSize,
+            'total'    => isset($list['total']) ? $list['total'] : 0,
+            'list'     => isset($list['data']) ? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 查询构造
+     * @param $params
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function getQuery($params)
+    {
+        $where = ['a.mark' => 1];
+        return $this->model->from('price_logs as a')
+            ->where($where)
+            ->where(function ($query) use($params){
+                // 日期
+                $date = isset($params['date']) ? $params['date'] : [];
+                $start = isset($date[0])? $date[0] : '';
+                $end = isset($date[1])? $date[1] : '';
+                $end = $start>$end? '' : $end;
+                if ($start) {
+                    $query->where('a.date','>=', $start);
+                }
+                if($end){
+                    $query->where('a.date','<=', $end);
+                }
+
+                $status = isset($params['status'])? $params['status'] : 0;
+                if ($status && is_array($status)) {
+                    $query->whereIn('a.status', $status);
+                } else if($status>0){
+                    $query->where('a.status', $status);
+                }
+            });
+    }
+
+}

+ 91 - 0
app/Services/Common/WalletLogService.php

@@ -0,0 +1,91 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\ActionLogModel;
+use App\Models\WalletLogModel;
+use App\Services\BaseService;
+
+/**
+ * 承兑商管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Services\Common
+ */
+class WalletLogService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        $this->model = new WalletLogModel();
+    }
+
+
+    /**
+     * 获取列表
+     * @param $params 参数
+     * @param int $pageSize 分页大小:默认 15
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 10, $field = [])
+    {
+        $where = ['a.mark' => 1];
+        if (!empty($params['token_type']) && $params['token_type']) {
+            $where['a.token_type'] = intval($params['token_type']);
+        }
+        if (isset($params['status']) && $params['status'] != '') {
+            $where['a.status'] = $params['status'];
+        }
+        if(isset($params['owner_address']) && $params['owner_address']){
+            $where['owner_address'] = trim($params['owner_address']);
+        }
+        if(isset($params['to_address']) && $params['to_address']){
+            $where['to_address'] = trim($params['to_address']);
+        }
+        if(isset($params['hash']) && $params['hash']){
+            $where['hash'] = trim($params['hash']);
+        }
+        $list = $this->model
+            ->from('wallet_log as a')
+            ->where($where)
+            ->select($field ? $field : ['a.*'])
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item){
+                $item['create_time'] = $item['create_time']?datetime($item['create_time'],'Y-m-d H:i:s'):'';
+            }
+        }
+
+        return [
+            'pageSize' => $pageSize,
+            'total'    => isset($list['total']) ? $list['total'] : 0,
+            'list'     => isset($list['data']) ? $list['data'] : []
+        ];
+    }
+
+    /**
+     * @return array
+     */
+    public function delete()
+    {
+        ActionLogModel::setTitle("删除钱包交易记录");
+        ActionLogModel::record();
+        $this->model->where('create_time','<=', time() - 7 * 86400)->where(['mark'=>0])->delete();
+        return parent::delete(); // TODO: Change the autogenerated stub
+    }
+
+}

+ 3 - 7
app/Services/Common/WalletService.php

@@ -11,14 +11,10 @@
 
 namespace App\Services\Common;
 
-use App\Models\AcceptorModel;
 use App\Models\ActionLogModel;
-use App\Models\LiveGiftModel;
-use App\Models\TaskModel;
-use App\Models\TradeModel;
 use App\Models\WalletModel;
 use App\Services\BaseService;
-use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Auth;
 
 /**
  * 承兑商管理-服务类
@@ -63,7 +59,8 @@ class WalletService extends BaseService
         if ($list) {
             foreach ($list['data'] as &$item){
                 $item['balance'] = \App\Services\WalletService::make()->getBalance($item['address']);
-                $item['usdt'] = \App\Services\WalletService::make()->getUsdtBalance($item['address']);
+                $usdtData = \App\Services\WalletService::make()->getUsdtBalance($item['address']);
+                $item['usdt'] = isset($usdtData['amount'])? $usdtData['amount'] : '0.00';
             }
         }
 
@@ -82,7 +79,6 @@ class WalletService extends BaseService
      */
     public function edit()
     {
-
         // 请求参数
         $data = request()->all();
 

+ 24 - 12
app/Services/WalletService.php

@@ -134,19 +134,25 @@ class WalletService extends BaseService
      */
     public function getWalletList()
     {
-        $cacheKey = "caches:wallet:platform:all";
-        $wallets = RedisService::get($cacheKey);
-        if ($wallets) {
-            return $wallets;
-        }
+        try {
 
-        $wallets = WalletModel::where(['status' => 1, 'mark' => 1])->select(['id', 'address', 'type'])->get();
-        $wallets = $wallets ? $wallets->toArray() : [];
-        if ($wallets) {
-            RedisService::set($cacheKey, $wallets, rand(300, 600));
-        }
+            $cacheKey = "caches:wallet:platform:all";
+            $wallets = RedisService::get($cacheKey);
+            if ($wallets) {
+                return $wallets;
+            }
+
+            $wallets = WalletModel::where(['status' => 1, 'mark' => 1])->select(['id', 'address', 'type'])->get();
+            $wallets = $wallets ? $wallets->toArray() : [];
+            if ($wallets) {
+                RedisService::set($cacheKey, $wallets, rand(300, 600));
+            }
 
-        return $wallets;
+            return $wallets;
+        } catch (\Exception $exception){
+            $this->error = $exception->getMessage();
+            return false;
+        }
     }
 
     /**
@@ -368,8 +374,14 @@ class WalletService extends BaseService
                         $coinName = 'USDT';
                     }
 
+                    if($amount<=0){
+                        echo "【{$dateTime} wallet】账户[{$ownerAddress}]到钱包[{$toAddress}]记录[{$txid}]金额[{$amount}]{$coinName},金额较小不处理\n";
+                        RedisService::set($cacheKey . "{$txid}:error", ['error' => '金额较小不处理', 'data' => $v], 7200);
+                        continue;
+                    }
+
                     // 处理交易记录
-                    if (!WalletLogModel::checkExists($txid) && $amount) {
+                    if (!WalletLogModel::checkExists($txid)) {
                         $log = [
                             'owner_address' => $ownerAddress,
                             'to_address' => $toAddress,

+ 64 - 5
routes/web.php

@@ -130,6 +130,8 @@ Route::get('/member/info', [MemberController::class, 'info']);
 Route::post('/member/edit', [MemberController::class, 'edit']);
 Route::post('/member/delete', [MemberController::class, 'delete']);
 Route::post('/member/status', [MemberController::class, 'status']);
+Route::get('/member/parents', [MemberController::class, 'parents']);
+Route::post('/member/lock', [MemberController::class, 'lock']);
 
 // 登录日志
 Route::get('/loginlog/index', [LoginLogController::class, 'index']);
@@ -164,8 +166,65 @@ Route::post('/wallet/delete', [\App\Http\Controllers\Admin\WalletController::cla
 Route::post('/wallet/status', [\App\Http\Controllers\Admin\WalletController::class, 'status']);
 
 // 平台钱包交易
-Route::get('/walletLog/index', [\App\Http\Controllers\Admin\WalletController::class, 'index']);
-Route::get('/walletLog/info', [\App\Http\Controllers\Admin\WalletController::class, 'info']);
-Route::post('/walletLog/edit', [\App\Http\Controllers\Admin\WalletController::class, 'edit']);
-Route::post('/walletLog/delete', [\App\Http\Controllers\Admin\WalletController::class, 'delete']);
-Route::post('/walletLog/status', [\App\Http\Controllers\Admin\WalletController::class, 'status']);
+Route::get('/walletLog/index', [\App\Http\Controllers\Admin\WalletLogController::class, 'index']);
+Route::get('/walletLog/info', [\App\Http\Controllers\Admin\WalletLogController::class, 'info']);
+Route::post('/walletLog/edit', [\App\Http\Controllers\Admin\WalletLogController::class, 'edit']);
+Route::post('/walletLog/delete', [\App\Http\Controllers\Admin\WalletLogController::class, 'delete']);
+Route::post('/walletLog/status', [\App\Http\Controllers\Admin\WalletLogController::class, 'status']);
+
+// 平台财务
+Route::get('/finance/index', [\App\Http\Controllers\Admin\FinanceController::class, 'index']);
+Route::get('/finance/info', [\App\Http\Controllers\Admin\FinanceController::class, 'info']);
+Route::post('/finance/edit', [\App\Http\Controllers\Admin\FinanceController::class, 'edit']);
+Route::post('/finance/delete', [\App\Http\Controllers\Admin\FinanceController::class, 'delete']);
+Route::post('/finance/status', [\App\Http\Controllers\Admin\FinanceController::class, 'status']);
+Route::post('/finance/count', [\App\Http\Controllers\Admin\FinanceController::class, 'count']);
+
+
+// 提现记录
+Route::get('/withdraw/index', [\App\Http\Controllers\Admin\WithdrawController::class, 'index']);
+Route::post('/withdraw/count', [\App\Http\Controllers\Admin\WithdrawController::class, 'count']);
+Route::post('/withdraw/edit', [\App\Http\Controllers\Admin\WithdrawController::class, 'edit']);
+Route::post('/withdraw/auth', [\App\Http\Controllers\Admin\WithdrawController::class, 'auth']);
+Route::post('/withdraw/options', [\App\Http\Controllers\Admin\WithdrawController::class, 'options']);
+Route::post('/withdraw/status', [\App\Http\Controllers\Admin\WithdrawController::class, 'status']);
+Route::post('/withdraw/delete', [\App\Http\Controllers\Admin\WithdrawController::class, 'delete']);
+
+
+// 充值记录
+Route::get('/recharge/index', [\App\Http\Controllers\Admin\RechargeController::class, 'index']);
+Route::post('/recharge/count', [\App\Http\Controllers\Admin\RechargeController::class, 'count']);
+Route::post('/recharge/edit', [\App\Http\Controllers\Admin\RechargeController::class, 'edit']);
+Route::post('/recharge/auth', [\App\Http\Controllers\Admin\RechargeController::class, 'auth']);
+Route::post('/recharge/options', [\App\Http\Controllers\Admin\RechargeController::class, 'options']);
+Route::post('/recharge/status', [\App\Http\Controllers\Admin\RechargeController::class, 'status']);
+Route::post('/recharge/delete', [\App\Http\Controllers\Admin\RechargeController::class, 'delete']);
+
+// 文章资讯
+Route::get('/article/index', [\App\Http\Controllers\Admin\ArticleController::class, 'index']);
+Route::get('/article/info', [\App\Http\Controllers\Admin\ArticleController::class, 'info']);
+Route::post('/article/edit', [\App\Http\Controllers\Admin\ArticleController::class, 'edit']);
+Route::post('/article/delete', [\App\Http\Controllers\Admin\ArticleController::class, 'delete']);
+Route::post('/article/status', [\App\Http\Controllers\Admin\ArticleController::class, 'status']);
+
+// 质押订单
+Route::get('/pledge/index', [\App\Http\Controllers\Admin\WalletLogController::class, 'index']);
+Route::get('/pledge/info', [\App\Http\Controllers\Admin\WalletLogController::class, 'info']);
+Route::post('/pledge/edit', [\App\Http\Controllers\Admin\WalletLogController::class, 'edit']);
+Route::post('/pledge/delete', [\App\Http\Controllers\Admin\WalletLogController::class, 'delete']);
+Route::post('/pledge/status', [\App\Http\Controllers\Admin\WalletLogController::class, 'status']);
+
+// SBT价格
+Route::get('/priceLog/index', [\App\Http\Controllers\Admin\PriceLogController::class, 'index']);
+Route::get('/priceLog/info', [\App\Http\Controllers\Admin\PriceLogController::class, 'info']);
+Route::post('/priceLog/edit', [\App\Http\Controllers\Admin\PriceLogController::class, 'edit']);
+Route::post('/priceLog/delete', [\App\Http\Controllers\Admin\PriceLogController::class, 'delete']);
+Route::post('/priceLog/status', [\App\Http\Controllers\Admin\PriceLogController::class, 'status']);
+
+
+// 制度参数
+Route::get('/institutional/index', [\App\Http\Controllers\Admin\InstitutionalController::class, 'index']);
+Route::get('/institutional/info', [\App\Http\Controllers\Admin\InstitutionalController::class, 'info']);
+Route::post('/institutional/edit', [\App\Http\Controllers\Admin\InstitutionalController::class, 'edit']);
+Route::post('/institutional/delete', [\App\Http\Controllers\Admin\InstitutionalController::class, 'delete']);
+Route::post('/institutional/status', [\App\Http\Controllers\Admin\InstitutionalController::class, 'status']);