commit fe2d9c186836469c5d6f2d1319699c74b8b578aa Author: Your Name Date: Mon Jan 19 14:19:22 2026 +0800 first commit diff --git a/.example.env b/.example.env new file mode 100644 index 0000000..8b88998 --- /dev/null +++ b/.example.env @@ -0,0 +1 @@ +APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = test USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8 DEBUG = true PREFIX = la_ [LANG] default_lang = zh-cn [PROJECT] UNIQUE_IDENTIFICATION = likeadmin # 演示环境 DEMO_ENV = false \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..858dd88 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.idea +/.vscode +*.log +/.env +/runtime/* +/config/install.lock \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36f7b6f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +sudo: false + +language: php + +branches: + only: + - stable + +cache: + directories: + - $HOME/.composer/cache + +before_install: + - composer self-update + +install: + - composer install --no-dev --no-interaction --ignore-platform-reqs + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip . + - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0" + - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0" + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip . + +script: + - php think unit + +deploy: + provider: releases + api_key: + secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw= + file: + - ThinkPHP_Core.zip + - ThinkPHP_Full.zip + skip_cleanup: true + on: + tags: true diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..574a39c --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,32 @@ + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 +版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn) +All rights reserved。 +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +Apache Licence是著名的非盈利开源组织Apache采用的协议。 +该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, +允许代码修改,再作为开源或商业软件发布。需要满足 +的条件: +1. 需要给代码的用户一份Apache Licence ; +2. 如果你修改了代码,需要在被修改的文件中说明; +3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 +带有原来代码中的协议,商标,专利声明和其他原来作者规 +定需要包含的说明; +4. 如果再发布的产品中包含一个Notice文件,则在Notice文 +件中需要带有本协议内容。你可以在Notice中增加自己的 +许可,但不可以表现为对Apache Licence构成更改。 +具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2929dad --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +ThinkPHP 6.0 +=============== + +> 运行环境要求PHP7.1+,兼容PHP8.0。 + +[官方应用服务市场](https://market.topthink.com) | [`ThinkAPI`——官方统一API服务](https://docs.topthink.com/think-api) + +ThinkPHPV6.0版本由[亿速云](https://www.yisu.com/)独家赞助发布。 + +## 主要新特性 + +* 采用`PHP7`强类型(严格模式) +* 支持更多的`PSR`规范 +* 原生多应用支持 +* 更强大和易用的查询 +* 全新的事件系统 +* 模型事件和数据库事件统一纳入事件系统 +* 模板引擎分离出核心 +* 内部功能中间件化 +* SESSION/Cookie机制改进 +* 对Swoole以及协程支持改进 +* 对IDE更加友好 +* 统一和精简大量用法 + +## 安装 + +~~~ +composer create-project topthink/think tp 6.0.* +~~~ + +如果需要更新框架使用 +~~~ +composer update topthink/framework +~~~ + +## 文档 + +[完全开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content) + +## 参与开发 + +请参阅 [ThinkPHP 核心框架包](https://github.com/top-think/framework)。 + +## 版权信息 + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 + +本项目包含的第三方源码和二进制文件之版权信息另行标注。 + +版权所有Copyright © 2006-2020 by ThinkPHP (http://thinkphp.cn) + +All rights reserved。 + +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +更多细节参阅 [LICENSE.txt](LICENSE.txt) diff --git a/app/.htaccess b/app/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/app/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/app/AppService.php b/app/AppService.php new file mode 100644 index 0000000..96556e8 --- /dev/null +++ b/app/AppService.php @@ -0,0 +1,22 @@ +app = $app; + $this->request = $this->app->request; + + // 控制器初始化 + $this->initialize(); + } + + // 初始化 + protected function initialize() + {} + + /** + * 验证数据 + * @access protected + * @param array $data 数据 + * @param string|array $validate 验证器名或者验证规则数组 + * @param array $message 提示信息 + * @param bool $batch 是否批量验证 + * @return array|string|true + * @throws ValidateException + */ + protected function validate(array $data, $validate, array $message = [], bool $batch = false) + { + if (is_array($validate)) { + $v = new Validate(); + $v->rule($validate); + } else { + if (strpos($validate, '.')) { + // 支持场景 + [$validate, $scene] = explode('.', $validate); + } + $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); + $v = new $class(); + if (!empty($scene)) { + $v->scene($scene); + } + } + + $v->message($message); + + // 是否批量验证 + if ($batch || $this->batchValidate) { + $v->batch(true); + } + + return $v->failException(true)->check($data); + } + + +} diff --git a/app/ExceptionHandle.php b/app/ExceptionHandle.php new file mode 100644 index 0000000..453d126 --- /dev/null +++ b/app/ExceptionHandle.php @@ -0,0 +1,58 @@ + [ + // 初始化 + app\adminapi\http\middleware\InitMiddleware::class, + // 登录验证 + app\adminapi\http\middleware\LoginMiddleware::class, + // 权限认证 + app\adminapi\http\middleware\AuthMiddleware::class, + // 演示模式 - 禁止提交数据 + app\adminapi\http\middleware\CheckDemoMiddleware::class, + // 演示模式 - 不返回敏感数据 + app\adminapi\http\middleware\EncryDemoDataMiddleware::class, + ], +]; diff --git a/app/adminapi/controller/BaseAdminController.php b/app/adminapi/controller/BaseAdminController.php new file mode 100644 index 0000000..66e8cce --- /dev/null +++ b/app/adminapi/controller/BaseAdminController.php @@ -0,0 +1,40 @@ +request->adminInfo) && $this->request->adminInfo) { + $this->adminInfo = $this->request->adminInfo; + $this->adminId = $this->request->adminInfo['admin_id']; + } + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/ConfigController.php b/app/adminapi/controller/ConfigController.php new file mode 100644 index 0000000..5104bbc --- /dev/null +++ b/app/adminapi/controller/ConfigController.php @@ -0,0 +1,73 @@ +data($data); + } + + /** + * @notes 代理基础配置 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/31 11:01 + */ + public function getAgentConfig() + { + $data = ConfigLogic::getAgentConfig(); + return $this->data($data); + } + + + /** + * @notes 根据类型获取字典数据 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/27 19:10 + */ + public function dict() + { + $type = $this->request->get('type', ''); + $data = ConfigLogic::getDictByType($type); + return $this->data($data); + } + + + +} \ No newline at end of file diff --git a/app/adminapi/controller/DownloadController.php b/app/adminapi/controller/DownloadController.php new file mode 100644 index 0000000..b61e81c --- /dev/null +++ b/app/adminapi/controller/DownloadController.php @@ -0,0 +1,50 @@ +get('file'); + + //通过文件缓存的key获取文件储存的路径 + $exportCache = new ExportCache(); + $fileInfo = $exportCache->getFile($fileKey); + + if (empty($fileInfo)) { + return JsonService::fail('下载文件不存在'); + } + + //下载前删除缓存 + $exportCache->delete($fileKey); + + return download($fileInfo['src'] . $fileInfo['name'], $fileInfo['name']); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/FileController.php b/app/adminapi/controller/FileController.php new file mode 100644 index 0000000..830bef1 --- /dev/null +++ b/app/adminapi/controller/FileController.php @@ -0,0 +1,137 @@ +dataLists(new FileLists()); + } + + + /** + * @notes 文件移动成功 + * @return Json + * @author 段誉 + * @date 2021/12/29 14:30 + */ + public function move() + { + $params = (new FileValidate())->post()->goCheck('move'); + FileLogic::move($params); + return $this->success('移动成功', [], 1, 1); + } + + + /** + * @notes 重命名文件 + * @return Json + * @author 段誉 + * @date 2021/12/29 14:31 + */ + public function rename() + { + $params = (new FileValidate())->post()->goCheck('rename'); + FileLogic::rename($params); + return $this->success('重命名成功', [], 1, 1); + } + + + /** + * @notes 删除文件 + * @return Json + * @author 段誉 + * @date 2021/12/29 14:31 + */ + public function delete() + { + $params = (new FileValidate())->post()->goCheck('delete'); + FileLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 分类列表 + * @return Json + * @author 段誉 + * @date 2021/12/29 14:31 + */ + public function listCate() + { + return $this->dataLists(new FileCateLists()); + } + + + /** + * @notes 添加文件分类 + * @return Json + * @author 段誉 + * @date 2021/12/29 14:31 + */ + public function addCate() + { + $params = (new FileValidate())->post()->goCheck('addCate'); + FileLogic::addCate($params); + return $this->success('添加成功', [], 1, 1); + } + + + /** + * @notes 编辑文件分类 + * @return Json + * @author 段誉 + * @date 2021/12/29 14:31 + */ + public function editCate() + { + $params = (new FileValidate())->post()->goCheck('editCate'); + FileLogic::editCate($params); + return $this->success('编辑成功', [], 1, 1); + } + + + /** + * @notes 删除文件分类 + * @return Json + * @author 段誉 + * @date 2021/12/29 14:32 + */ + public function delCate() + { + $params = (new FileValidate())->post()->goCheck('id'); + FileLogic::delCate($params); + return $this->success('删除成功', [], 1, 1); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/LoginController.php b/app/adminapi/controller/LoginController.php new file mode 100644 index 0000000..1a6196b --- /dev/null +++ b/app/adminapi/controller/LoginController.php @@ -0,0 +1,61 @@ +post()->goCheck(); + return $this->data((new LoginLogic())->login($params)); + } + + /** + * @notes 代理账号登录 + * @date 2021/6/30 17:01 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 令狐冲 + */ + public function agentAccount() + { + $params = (new LoginAgentValidate())->post()->goCheck(); + return $this->data((new LoginLogic())->loginAgent($params)); + } + + /** + * @notes 退出登录 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 令狐冲 + * @date 2021/7/8 00:36 + */ + public function logout() + { + //退出登录情况特殊,只有成功的情况,也不需要token验证 + (new LoginLogic())->logout($this->adminInfo); + return $this->success(); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/NotifyController.php b/app/adminapi/controller/NotifyController.php new file mode 100644 index 0000000..892eb9c --- /dev/null +++ b/app/adminapi/controller/NotifyController.php @@ -0,0 +1,480 @@ +toArray(); + // foreach ($withdrawWallets as &$withdrawWallet) { + // WithdrawWallet::destroy($withdrawWallet['id'],true); + // } + + // //用户提现记录 + // $withdrawRecords = WithdrawRecord::select()->toArray(); + // foreach ($withdrawRecords as &$withdrawRecord) { + // WithdrawRecord::destroy($withdrawRecord['id'],true); + // } + + // //用户Udun + // $userUduns = UserUdun::select()->toArray(); + // foreach ($userUduns as &$userUdun) { + // UserUdun::destroy($userUdun['id'],true); + // } + + // //用户波场钱包 + // $userTrons = UserTron::select()->toArray(); + // foreach ($userTrons as &$userTron) { + // UserTron::destroy($userTron['id'],true); + // } + + // //资金明细 + // $userFinances = UserFinance::select()->toArray(); + // foreach ($userFinances as &$userFinance) { + // UserFinance::destroy($userFinance['id'],true); + // } + + // //用户 + // $users = User::select()->toArray(); + // foreach ($users as &$user) { + // User::destroy($user['id'],true); + // } + + // //角色 + // $systemRoles = SystemRole::where('id <> 6')->select()->toArray(); + // foreach ($systemRoles as &$systemRole) { + // SystemRole::destroy($systemRole['id'],true); + // } + + // //短信记录 + // $smsLogs = SmsLog::select()->toArray(); + // foreach ($smsLogs as &$smsLog) { + // SmsLog::destroy($smsLog['id'],true); + // } + + // //充值记录 + // $rechargeRecords = RechargeRecord::select()->toArray(); + // foreach ($rechargeRecords as &$rechargeRecord) { + // RechargeRecord::destroy($rechargeRecord['id'],true); + // } + + // //通知记录 + // $noticeRecords = NoticeRecord::select()->toArray(); + // foreach ($noticeRecords as &$noticeRecord) { + // NoticeRecord::destroy($noticeRecord['id'],true); + // } + + // //量化记录 + // $lhRecords = LhRecord::select()->toArray(); + // foreach ($lhRecords as &$lhRecord) { + // LhRecord::destroy($lhRecord['id'],true); + // } + + // // //管理员 + // // $admins = Admin::select()->toArray(); + // // foreach ($admins as &$admin) { + // // Admin::destroy($admin['id'],true); + // // } + // //用户转账记录 + // UserTransferRecord::where('1 = 1')->delete(); + // //用户签到 + // UserSigninRecord::where('1 = 1')->delete(); + // //用户会话 + // UserSession::where('1 = 1')->delete(); + // //奖励活动记录 + // UserRewardRecord::where('1 = 1')->delete(); + // //用户关系 + // UserRelation::where('1 = 1')->delete(); + // //用户代理关系 + // UserRelationAgent::where('1 = 1')->delete(); + // //用户消息 + // UserNotice::where('1 = 1')->delete(); + // //挖矿记录 + // UserMineRecord::where('1 = 1')->delete(); + // //会员记录 + // UserMemberRecord::where('1 = 1')->delete(); + // //用户操作 + // UserLog::where('1 = 1')->delete(); + // //卡单规则 + // UserKadan::where('1 = 1')->delete(); + // //用户信息 + // UserInfo::where('1 = 1')->delete(); + // //用户分组记录 + // UserGroupRecord::where('1 = 1')->delete(); + // //角色菜单关系 + // SystemRoleMenu::where('role_id <> 6')->delete(); + // //清空日志 + // OperationLog::where('1 = 1')->delete(); + // //奖品记录 + // MallGoodsRecord::where('1 = 1')->delete(); + // //抢单记录 + // GoodsRecord::where('1 = 1')->delete(); + // //项目记录 + // ItemRecord::where('1 = 1')->delete(); + // //意见反馈记录 + // FeedbackRecord::where('1 = 1')->delete(); + // //邮件发送记录 + // EmailRecord::where('1 = 1')->delete(); + // //管理员会话 + // AdminSession::where('1 = 1')->delete(); + // //角色关联 + // AdminRole::where('role_id <> 0')->delete(); + // //岗位关联 + // AdminJobs::where('1 = 1')->delete(); + // // //部门关联 + // AdminDept::where('1 = 1')->delete(); + + // //波场配置 + // ConfigService::set('website', 'tron', ['api_key'=>'','url'=>'']); + // //翻译配置 + // $translation = ConfigService::get('website', 'translation'); + // $translation['app_key'] = ''; + // $translation['sec_key'] = ''; + // ConfigService::set('website', 'translation', $translation); + // //短信宝配置 + // $smsbao = ConfigService::get('sms', 'smsbao'); + // $smsbao['sign'] = ''; + // $smsbao['username'] = ''; + // $smsbao['api_key'] = ''; + // ConfigService::set('sms', 'smsbao', $smsbao); + // //邮箱配置 + // ConfigService::set('website', 'email', ['host'=>'','port'=>'','smtp'=>'','charset'=>'','nickname'=>'','username'=>'','password'=>'']); + // //优盾配置 + // ConfigService::set('website', 'udun', ['merchant_no'=>'','api_key'=>'','gateway_address'=>'','callUrl'=>'接口域名/adminapi/notify/notify','debug'=>'0','is_open_df'=>'0','pay_min'=>'10','pay_min'=>'10','pay_max'=>'100']); + // //前台链接 + // ConfigService::set('website', 'front_link', ''); + + // Db::commit(); + // return '清理成功'; + // } catch (\Exception $e) { + // Db::rollback(); + // print_r($e->getMessage()); + // self::$error = $e->getMessage(); + // return '清理失败,请查看日志'; + // } + // } + + /** + * @notes 更新行情数据 + * @return string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/04/13 10:54 + */ + public function market() + { + Db::startTrans(); + try { + $marketData = UtilsService::curl_request('https://api.huobi.pro/market/tickers',[],'GET'); + $marketData = json_decode($marketData,true); + + if('ok' != $marketData['status']){ + throw new \Exception('获取API失败'); + + } + $marketData = $marketData['data']; + + //实时行情 + $market = ConfigService::get('website', 'market'); + + //挖矿货币 + $mine = ConfigService::get('website', 'mine'); + + //充值方式 + $rechargeMethods = RechargeMethod::where(['is_show' => 1]) + ->where(" symbol_rate != '' AND type IN (1,5,7) ") + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + //提现方式 + $withdrawMethods = WithdrawMethod::where(['is_show' => 1]) + ->where(" symbol_rate != '' AND type IN (1) ") + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + foreach ($marketData as $market_data) { + + foreach ($market as &$item) { + if($item['symbol'] == $market_data['symbol']){ + $item['price'] = $market_data['close']; + $item['rise'] = round((($market_data['close']) - ($market_data['open']))/($market_data['open']) *100,2); + } + } + + foreach ($rechargeMethods as &$rechargeMethod) { + if($rechargeMethod['symbol_rate'] == $market_data['symbol']){ + RechargeMethod::update([ + 'id' => $rechargeMethod['id'], + 'rate' => 1/$market_data['close'], + ]); + } + } + + foreach ($withdrawMethods as &$withdrawMethod) { + if($withdrawMethod['symbol_rate'] == $market_data['symbol']){ + WithdrawMethod::update([ + 'id' => $withdrawMethod['id'], + 'rate' => 1/$market_data['close'], + ]); + } + } + + if($mine['symbol_rate'] != '' & $mine['symbol_rate'] == $market_data['symbol']){ + $mine['rate'] = 1/$market_data['close']; + } + } + ConfigService::set('website', 'market', $market); + + if($mine['symbol_rate'] != '') ConfigService::set('website', 'mine', $mine); + + Db::commit(); + return 'success'; + } catch (\Exception $e) { + Db::rollback(); + return $e; + } + } + + + /** + * @notes 优盾钱包交易回调 + * @return string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/04/13 10:54 + */ + public function notify(){ + Db::startTrans(); + try { + $body = $_POST['body']; + $nonce = $_POST['nonce']; + $timestamp = $_POST['timestamp']; + $sign = $_POST['sign']; + //验证签名 + $signCheck = UtilsService::udun_signature($body,$timestamp,$nonce); + if ($sign != $signCheck) { + throw new \Exception('签名错误'); + return ; + } + $body = json_decode($body); + //$this->printLog("回调接收内容(tradeType):".$body->tradeType); + //$body->tradeType 1充币回调 2提币回调 + if ($body->tradeType == 1) { + + //$body->status 0待审核 1审核成功 2审核驳回 3交易成功 4交易失败 + if($body->status == 3){ + + //业务处理 + //查询钱包地址 + $userUdun = UserUdun::where([ + 'address' => $body->address, + 'main_coin_type' => $body->mainCoinType, + 'coin_type' => $body->coinType + ]) + ->findOrEmpty(); + + if ($userUdun->isEmpty()) { + throw new \Exception('地址不存在'); + return ; + } + + $method = RechargeMethod::where(['id' => $userUdun['method_id']])->findOrEmpty(); + if ($method->isEmpty()) { + throw new \Exception('充值方式不存在'); + return ; + } + + $user = User::where(['id' => $userUdun['user_id']])->findOrEmpty(); + if ($user->isEmpty()) { + throw new \Exception('用户不存在'); + return ; + } + + $money = ($body->amount) / pow(10,($body->decimals)); + + $order_amount_act = round($money / $method['rate'] , 2); + + + //判断最低充值金额 + $config = ConfigService::get('website', 'trade'); + if($order_amount_act < $config['recharge_min']){ + return "success"; + } + + $data = [ + 'sn' => generate_sn(RechargeRecord::class, 'sn'), + 'user_id' => $userUdun['user_id'], + 'method_id' => $method['id'], + 'amount' => $order_amount_act, + 'amount_act' => round($money , $method['precision']), + 'rate' => $method['rate'], + 'symbol' => $method['symbol'], + 'status' => 1, + ]; + + $record = RechargeRecord::create($data); + + //记录日志 + UtilsService::user_finance_add( + $data['user_id'], + 1, + 1, + $data['amount'], + $data['sn'], + '', + 1//冻结 + ); + + //用户资金修改 + UtilsService::user_money_change($data['user_id'], 1, $data['amount'],'user_money'); + + //充值金额增加 + UtilsService::user_money_change($data['user_id'], 1, $data['amount'],'total_recharge'); + + //团队充值奖励 + // UtilsService::team_reward_add($data['user_id'],$data['amount'],1); + + //充值活动奖励 + UtilsService::activity_reward_add($data['user_id'],$data['amount']); + + //更新充值记录用户余额 + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + if ($user->isEmpty()) { + throw new \Exception('用户不存在'); + } + + //充值次数+1 + User::update([ + 'id' => $user['id'], + 'recharge_num' => $user['recharge_num'] + 1 + ]); + + RechargeRecord::update([ + 'id' => $record['id'], + 'user_money' => $user['user_money'] + ]); + + Db::commit(); + + } + //无论业务方处理成功与否(success,failed),回调都认为成功 + return "success"; + } + elseif ($body->tradeType == 2) { + + //$body->status 0待审核 1审核成功 2审核驳回 3交易成功 4交易失败 + if($body->status == 0){ + //业务处理 + } + else if($body->status == 1){ + //业务处理 + } + else if($body->status == 3){ + $record = WithdrawRecord::where(['account' => $body->address,'status' => 0,'status2' => 1,'sn' => $body->businessId])->findOrEmpty(); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + return; + } + + WithdrawRecord::update([ + 'id' => $record['id'], + 'status' => 1 + ]); + //更新充值记录用户余额 + $user = User::where(['id' => $record['user_id']])->findOrEmpty(); + if (!$user->isEmpty()) { + //提现次数+1 + User::update([ + 'id' => $user['id'], + 'withdraw_num' => $user['withdraw_num'] + 1 + ]); + + WithdrawRecord::update([ + 'id' => $record['id'], + 'user_money' => $user['user_money'], + 'remark_df' => '', + ]); + } + + Db::commit(); + + } + else if($body->status == 2 || $body->status == 4){ + $record = WithdrawRecord::where(['account' => $body->address,'status' => 0,'status2' => 1,'sn' => $body->businessId])->findOrEmpty(); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + return; + } + WithdrawRecord::update([ + 'id' => $record['id'], + 'status2' => 0, + 'remark_df' => 'udun代付失败', + ]); + + Db::commit(); + } + //无论业务方处理成功与否(success,failed),回调都认为成功 + return "success"; + } + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + public function test(){ + + + } +} \ No newline at end of file diff --git a/app/adminapi/controller/UploadController.php b/app/adminapi/controller/UploadController.php new file mode 100644 index 0000000..1bee7dd --- /dev/null +++ b/app/adminapi/controller/UploadController.php @@ -0,0 +1,63 @@ +request->post('cid', 0); + $result = UploadService::image($cid); + return $this->success('上传成功', $result); + } catch (Exception $e) { + return $this->fail($e->getMessage()); + } + } + + /** + * @notes 上传视频 + * @return Json + * @author 段誉 + * @date 2021/12/29 16:27 + */ + public function video() + { + try { + $cid = $this->request->post('cid', 0); + $result = UploadService::video($cid); + return $this->success('上传成功', $result); + } catch (Exception $e) { + return $this->fail($e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/WorkbenchController.php b/app/adminapi/controller/WorkbenchController.php new file mode 100644 index 0000000..167c9c5 --- /dev/null +++ b/app/adminapi/controller/WorkbenchController.php @@ -0,0 +1,52 @@ +data($result); + } + + /** + * @notes 代理工作台 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 17:01 + */ + public function agent() + { + $params = $this->request->get(); + $params['admin_id'] = $this->adminId; + $result = WorkbenchLogic::agent($params); + return $this->data($result); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/article/ArticleCateController.php b/app/adminapi/controller/article/ArticleCateController.php new file mode 100644 index 0000000..89d7c83 --- /dev/null +++ b/app/adminapi/controller/article/ArticleCateController.php @@ -0,0 +1,134 @@ +dataLists(new ArticleCateLists()); + } + + + /** + * @notes 添加资讯分类 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/21 17:31 + */ + public function add() + { + $params = (new ArticleCateValidate())->post()->goCheck('add'); + ArticleCateLogic::add($params); + return $this->success('添加成功', [], 1, 1); + } + + + /** + * @notes 编辑资讯分类 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/21 17:49 + */ + public function edit() + { + $params = (new ArticleCateValidate())->post()->goCheck('edit'); + $result = ArticleCateLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ArticleCateLogic::getError()); + } + + + /** + * @notes 删除资讯分类 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/21 17:52 + */ + public function delete() + { + $params = (new ArticleCateValidate())->post()->goCheck('delete'); + ArticleCateLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 资讯分类详情 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/21 17:54 + */ + public function detail() + { + $params = (new ArticleCateValidate())->goCheck('detail'); + $result = ArticleCateLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 更改资讯分类状态 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/21 10:15 + */ + public function updateStatus() + { + $params = (new ArticleCateValidate())->post()->goCheck('status'); + $result = ArticleCateLogic::updateStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(ArticleCateLogic::getError()); + } + + + /** + * @notes 获取文章分类 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:54 + */ + public function all() + { + $result = ArticleCateLogic::getAllData(); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/article/ArticleController.php b/app/adminapi/controller/article/ArticleController.php new file mode 100644 index 0000000..de73fc6 --- /dev/null +++ b/app/adminapi/controller/article/ArticleController.php @@ -0,0 +1,126 @@ +dataLists(new ArticleLists()); + } + + /** + * @notes 添加资讯 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/22 9:57 + */ + public function add() + { + $params = (new ArticleValidate())->post()->goCheck('add'); + ArticleLogic::add($params); + return $this->success('添加成功', [], 1, 1); + } + + /** + * @notes 编辑资讯 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/22 10:12 + */ + public function edit() + { + $params = (new ArticleValidate())->post()->goCheck('edit'); + $result = ArticleLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ArticleLogic::getError()); + } + + /** + * @notes 删除资讯 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/22 10:17 + */ + public function delete() + { + $params = (new ArticleValidate())->post()->goCheck('delete'); + ArticleLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + /** + * @notes 资讯详情 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/22 10:15 + */ + public function detail() + { + $params = (new ArticleValidate())->goCheck('detail'); + $result = ArticleLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 更改资讯状态 + * @return \think\response\Json + * @author heshihu + * @date 2022/2/22 10:18 + */ + public function updateStatus() + { + $params = (new ArticleValidate())->post()->goCheck('status'); + $result = ArticleLogic::updateStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(ArticleLogic::getError()); + } + + /** + * @notes 资讯列表 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 17:01 + */ + public function all() + { + $params = $this->request->get(); + $result = ArticleLogic::all($params); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/auth/AdminController.php b/app/adminapi/controller/auth/AdminController.php new file mode 100644 index 0000000..ab3bd78 --- /dev/null +++ b/app/adminapi/controller/auth/AdminController.php @@ -0,0 +1,163 @@ +dataLists(new AdminLists()); + } + + + /** + * @notes 添加管理员 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 10:21 + */ + public function add() + { + $params = (new AdminValidate())->post()->goCheck('add'); + $result = AdminLogic::add($params); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(AdminLogic::getError()); + } + + + /** + * @notes 编辑管理员 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 11:03 + */ + public function edit() + { + $params = (new AdminValidate())->post()->goCheck('edit'); + $result = AdminLogic::edit($params); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(AdminLogic::getError()); + } + + + /** + * @notes 删除管理员 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 11:03 + */ + public function delete() + { + $params = (new AdminValidate())->post()->goCheck('delete'); + $result = AdminLogic::delete($params); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(AdminLogic::getError()); + } + + + /** + * @notes 查看管理员详情 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 11:07 + */ + public function detail() + { + $params = (new AdminValidate())->goCheck('detail'); + $result = AdminLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 获取当前管理员信息 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/31 10:53 + */ + public function mySelf() + { + $result = AdminLogic::detail(['id' => $this->adminId], 'auth'); + return $this->data($result); + } + + + /** + * @notes 编辑超级管理员信息 + * @return \think\response\Json + * @author 段誉 + * @date 2022/4/8 17:54 + */ + public function editSelf() + { + $params = (new editSelfValidate())->post()->goCheck('', ['admin_id' => $this->adminId]); + $result = AdminLogic::editSelf($params); + return $this->success('操作成功', [], 1, 1); + } + + /** + * @notes 获取谷歌验证 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 11:07 + */ + public function google() + { + $params['id'] = $this->adminId; + $result = AdminLogic::google($params); + return $this->data($result); + } + + /** + * @notes 重置谷歌验证 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 11:07 + */ + public function resetGoogle() + { + $params = $this->request->post(); + $result = AdminLogic::resetGoogle($params); + if (true === $result) { + return $this->success('重置成功', [], 1, 1); + } + return $this->fail(AdminLogic::getError()); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/auth/MenuController.php b/app/adminapi/controller/auth/MenuController.php new file mode 100644 index 0000000..ba5a4be --- /dev/null +++ b/app/adminapi/controller/auth/MenuController.php @@ -0,0 +1,143 @@ +adminId); + return $this->data($result); + } + + + /** + * @notes 获取菜单列表 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/29 17:23 + */ + public function lists() + { + return $this->dataLists(new MenuLists()); + } + + + /** + * @notes 菜单详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/30 10:07 + */ + public function detail() + { + $params = (new MenuValidate())->goCheck('detail'); + return $this->data(MenuLogic::detail($params)); + } + + + /** + * @notes 添加菜单 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/30 10:07 + */ + public function add() + { + $params = (new MenuValidate())->post()->goCheck('add'); + MenuLogic::add($params); + return $this->success('操作成功', [], 1, 1); + } + + + /** + * @notes 编辑菜单 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/30 10:07 + */ + public function edit() + { + $params = (new MenuValidate())->post()->goCheck('edit'); + MenuLogic::edit($params); + return $this->success('操作成功', [], 1, 1); + } + + + /** + * @notes 删除菜单 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/30 10:07 + */ + public function delete() + { + $params = (new MenuValidate())->post()->goCheck('delete'); + MenuLogic::delete($params); + return $this->success('操作成功', [], 1, 1); + } + + + /** + * @notes 更新状态 + * @return \think\response\Json + * @author 段誉 + * @date 2022/7/6 17:04 + */ + public function updateStatus() + { + $params = (new MenuValidate())->post()->goCheck('status'); + MenuLogic::updateStatus($params); + return $this->success('操作成功', [], 1, 1); + } + + /** + * @notes 更新排序 + * @return \think\response\Json + * @author 段誉 + * @date 2022/7/6 17:04 + */ + public function updateSort() + { + $params = (new MenuValidate())->post()->goCheck('sort'); + MenuLogic::updateSort($params); + return $this->success('操作成功', [], 1, 1); + } + + + /** + * @notes 获取菜单数据 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 11:03 + */ + public function all() + { + $result = MenuLogic::getAllData(); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/auth/RoleController.php b/app/adminapi/controller/auth/RoleController.php new file mode 100644 index 0000000..706c41d --- /dev/null +++ b/app/adminapi/controller/auth/RoleController.php @@ -0,0 +1,124 @@ +dataLists(new RoleLists()); + } + + + /** + * @notes 添加权限 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 11:49 + */ + public function add() + { + $params = (new RoleValidate())->post()->goCheck('add'); + $res = RoleLogic::add($params); + if (true === $res) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(RoleLogic::getError()); + } + + + /** + * @notes 编辑角色 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 14:18 + */ + public function edit() + { + $params = (new RoleValidate())->post()->goCheck('edit'); + $res = RoleLogic::edit($params); + if (true === $res) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(RoleLogic::getError()); + } + + + /** + * @notes 删除角色 + * @return \think\response\Json + * @author 段誉 + * @date 2021/12/29 14:18 + */ + public function delete() + { + $params = (new RoleValidate())->post()->goCheck('del'); + RoleLogic::delete($params['id']); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 查看角色详情 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2021/12/29 14:18 + */ + public function detail() + { + $params = (new RoleValidate())->goCheck('detail'); + $detail = RoleLogic::detail($params['id']); + return $this->data($detail); + } + + + /** + * @notes 获取角色数据 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:39 + */ + public function all() + { + $result = RoleLogic::getAllData(); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/crontab/CrontabController.php b/app/adminapi/controller/crontab/CrontabController.php new file mode 100644 index 0000000..a2ad7ff --- /dev/null +++ b/app/adminapi/controller/crontab/CrontabController.php @@ -0,0 +1,135 @@ +dataLists(new CrontabLists()); + } + + + /** + * @notes 添加定时任务 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 14:27 + */ + public function add() + { + $params = (new CrontabValidate())->post()->goCheck('add'); + $result = CrontabLogic::add($params); + if($result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(CrontabLogic::getError()); + } + + + /** + * @notes 查看定时任务详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 14:27 + */ + public function detail() + { + $params = (new CrontabValidate())->goCheck('detail'); + $result = CrontabLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 编辑定时任务 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 14:27 + */ + public function edit() + { + $params = (new CrontabValidate())->post()->goCheck('edit'); + $result = CrontabLogic::edit($params); + if($result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(CrontabLogic::getError()); + } + + + /** + * @notes 删除定时任务 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 14:27 + */ + public function delete() + { + $params = (new CrontabValidate())->post()->goCheck('delete'); + $result = CrontabLogic::delete($params); + if($result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail('删除失败'); + } + + + /** + * @notes 操作定时任务 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 14:28 + */ + public function operate() + { + $params = (new CrontabValidate())->post()->goCheck('operate'); + $result = CrontabLogic::operate($params); + if($result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(CrontabLogic::getError()); + } + + + /** + * @notes 获取规则执行时间 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 14:28 + */ + public function expression() + { + $params = (new CrontabValidate())->goCheck('expression'); + $result = CrontabLogic::expression($params); + return $this->data($result); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/decorate/DecorateHintController.php b/app/adminapi/controller/decorate/DecorateHintController.php new file mode 100644 index 0000000..e0dad56 --- /dev/null +++ b/app/adminapi/controller/decorate/DecorateHintController.php @@ -0,0 +1,120 @@ +dataLists(new DecorateHintLists()); + } + + + /** + * @notes 添加提示内容 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 17:01 + */ + public function add() + { + $params = (new DecorateHintValidate())->post()->goCheck('add'); + $result = DecorateHintLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(DecorateHintLogic::getError()); + } + + + /** + * @notes 编辑提示内容 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 17:01 + */ + public function edit() + { + $params = (new DecorateHintValidate())->post()->goCheck('edit'); + $result = DecorateHintLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(DecorateHintLogic::getError()); + } + + + /** + * @notes 删除提示内容 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 17:01 + */ + public function delete() + { + $params = (new DecorateHintValidate())->post()->goCheck('delete'); + DecorateHintLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取提示内容详情 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 17:01 + */ + public function detail() + { + $params = (new DecorateHintValidate())->goCheck('detail'); + $result = DecorateHintLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 消息列表 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 17:01 + */ + public function allByType() + { + $params = $this->request->get(); + $result = DecorateHintLogic::allByType($params); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/decorate/DecorateNavController.php b/app/adminapi/controller/decorate/DecorateNavController.php new file mode 100644 index 0000000..813f2fc --- /dev/null +++ b/app/adminapi/controller/decorate/DecorateNavController.php @@ -0,0 +1,108 @@ +dataLists(new DecorateNavLists()); + } + + + /** + * @notes 添加菜单按钮 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 16:41 + */ + public function add() + { + $params = (new DecorateNavValidate())->post()->goCheck('add'); + $result = DecorateNavLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(DecorateNavLogic::getError()); + } + + + /** + * @notes 编辑菜单按钮 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 16:41 + */ + public function edit() + { + $params = (new DecorateNavValidate())->post()->goCheck('edit'); + $result = DecorateNavLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(DecorateNavLogic::getError()); + } + + + /** + * @notes 删除菜单按钮 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 16:41 + */ + public function delete() + { + $params = (new DecorateNavValidate())->post()->goCheck('delete'); + DecorateNavLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取菜单按钮详情 + * @return \think\response\Json + * @author BD + * @date 2024/03/17 16:41 + */ + public function detail() + { + $params = (new DecorateNavValidate())->goCheck('detail'); + $result = DecorateNavLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/decorate/DecorateSwiperController.php b/app/adminapi/controller/decorate/DecorateSwiperController.php new file mode 100644 index 0000000..8fa7d0a --- /dev/null +++ b/app/adminapi/controller/decorate/DecorateSwiperController.php @@ -0,0 +1,108 @@ +dataLists(new DecorateSwiperLists()); + } + + + /** + * @notes 添加轮播图 + * @return \think\response\Json + * @author BD + * @date 2024/03/16 17:34 + */ + public function add() + { + $params = (new DecorateSwiperValidate())->post()->goCheck('add'); + $result = DecorateSwiperLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(DecorateSwiperLogic::getError()); + } + + + /** + * @notes 编辑轮播图 + * @return \think\response\Json + * @author BD + * @date 2024/03/16 17:34 + */ + public function edit() + { + $params = (new DecorateSwiperValidate())->post()->goCheck('edit'); + $result = DecorateSwiperLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(DecorateSwiperLogic::getError()); + } + + + /** + * @notes 删除轮播图 + * @return \think\response\Json + * @author BD + * @date 2024/03/16 17:34 + */ + public function delete() + { + $params = (new DecorateSwiperValidate())->post()->goCheck('delete'); + DecorateSwiperLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取轮播图详情 + * @return \think\response\Json + * @author BD + * @date 2024/03/16 17:34 + */ + public function detail() + { + $params = (new DecorateSwiperValidate())->goCheck('detail'); + $result = DecorateSwiperLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/dept/DeptController.php b/app/adminapi/controller/dept/DeptController.php new file mode 100644 index 0000000..e0dcf84 --- /dev/null +++ b/app/adminapi/controller/dept/DeptController.php @@ -0,0 +1,134 @@ +request->get(); + $result = DeptLogic::lists($params); + return $this->success('',$result); + } + + + /** + * @notes 上级部门 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/5/26 18:36 + */ + public function leaderDept() + { + $result = DeptLogic::leaderDept(); + return $this->success('',$result); + } + + + /** + * @notes 添加部门 + * @return \think\response\Json + * @author 段誉 + * @date 2022/5/25 18:40 + */ + public function add() + { + $params = (new DeptValidate())->post()->goCheck('add'); + DeptLogic::add($params); + return $this->success('添加成功', [], 1, 1); + } + + + /** + * @notes 编辑部门 + * @return \think\response\Json + * @author 段誉 + * @date 2022/5/25 18:41 + */ + public function edit() + { + $params = (new DeptValidate())->post()->goCheck('edit'); + $result = DeptLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(DeptLogic::getError()); + } + + + /** + * @notes 删除部门 + * @return \think\response\Json + * @author 段誉 + * @date 2022/5/25 18:41 + */ + public function delete() + { + $params = (new DeptValidate())->post()->goCheck('delete'); + DeptLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取部门详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/5/25 18:41 + */ + public function detail() + { + $params = (new DeptValidate())->goCheck('detail'); + $result = DeptLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 获取部门数据 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:28 + */ + public function all() + { + $result = DeptLogic::getAllData(); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/dept/JobsController.php b/app/adminapi/controller/dept/JobsController.php new file mode 100644 index 0000000..0f8b622 --- /dev/null +++ b/app/adminapi/controller/dept/JobsController.php @@ -0,0 +1,118 @@ +dataLists(new JobsLists()); + } + + + /** + * @notes 添加岗位 + * @return \think\response\Json + * @author 段誉 + * @date 2022/5/25 18:40 + */ + public function add() + { + $params = (new JobsValidate())->post()->goCheck('add'); + JobsLogic::add($params); + return $this->success('添加成功', [], 1, 1); + } + + + /** + * @notes 编辑岗位 + * @return \think\response\Json + * @author 段誉 + * @date 2022/5/25 18:41 + */ + public function edit() + { + $params = (new JobsValidate())->post()->goCheck('edit'); + $result = JobsLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(JobsLogic::getError()); + } + + + /** + * @notes 删除岗位 + * @return \think\response\Json + * @author 段誉 + * @date 2022/5/25 18:41 + */ + public function delete() + { + $params = (new JobsValidate())->post()->goCheck('delete'); + JobsLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取岗位详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/5/25 18:41 + */ + public function detail() + { + $params = (new JobsValidate())->goCheck('detail'); + $result = JobsLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 获取岗位数据 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:31 + */ + public function all() + { + $result = JobsLogic::getAllData(); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/feedback/FeedbackCateController.php b/app/adminapi/controller/feedback/FeedbackCateController.php new file mode 100644 index 0000000..7fa277f --- /dev/null +++ b/app/adminapi/controller/feedback/FeedbackCateController.php @@ -0,0 +1,94 @@ +dataLists(new FeedbackCateLists()); + } + + + /** + * @notes 添加意见反馈类型 + * @return \think\response\Json + * @author BD + * @date 2024/06/06 00:12 + */ + public function add() + { + $params = (new FeedbackCateValidate())->post()->goCheck('add'); + $result = FeedbackCateLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(FeedbackCateLogic::getError()); + } + + + /** + * @notes 编辑意见反馈类型 + * @return \think\response\Json + * @author BD + * @date 2024/06/06 00:12 + */ + public function edit() + { + $params = (new FeedbackCateValidate())->post()->goCheck('edit'); + $result = FeedbackCateLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(FeedbackCateLogic::getError()); + } + + + /** + * @notes 删除意见反馈类型 + * @return \think\response\Json + * @author BD + * @date 2024/06/06 00:12 + */ + public function delete() + { + $params = (new FeedbackCateValidate())->post()->goCheck('delete'); + FeedbackCateLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取意见反馈类型详情 + * @return \think\response\Json + * @author BD + * @date 2024/06/06 00:12 + */ + public function detail() + { + $params = (new FeedbackCateValidate())->goCheck('detail'); + $result = FeedbackCateLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/feedback/FeedbackRecordController.php b/app/adminapi/controller/feedback/FeedbackRecordController.php new file mode 100644 index 0000000..02c4b35 --- /dev/null +++ b/app/adminapi/controller/feedback/FeedbackRecordController.php @@ -0,0 +1,94 @@ +dataLists(new FeedbackRecordLists()); + } + + + /** + * @notes 添加意见反馈记录 + * @return \think\response\Json + * @author BD + * @date 2024/06/06 01:11 + */ + public function add() + { + $params = (new FeedbackRecordValidate())->post()->goCheck('add'); + $result = FeedbackRecordLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(FeedbackRecordLogic::getError()); + } + + + /** + * @notes 编辑意见反馈记录 + * @return \think\response\Json + * @author BD + * @date 2024/06/06 01:11 + */ + public function edit() + { + $params = (new FeedbackRecordValidate())->post()->goCheck('edit'); + $result = FeedbackRecordLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(FeedbackRecordLogic::getError()); + } + + + /** + * @notes 删除意见反馈记录 + * @return \think\response\Json + * @author BD + * @date 2024/06/06 01:11 + */ + public function delete() + { + $params = (new FeedbackRecordValidate())->post()->goCheck('delete'); + FeedbackRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取意见反馈记录详情 + * @return \think\response\Json + * @author BD + * @date 2024/06/06 01:11 + */ + public function detail() + { + $params = (new FeedbackRecordValidate())->goCheck('detail'); + $result = FeedbackRecordLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/finance/RechargeRecordController.php b/app/adminapi/controller/finance/RechargeRecordController.php new file mode 100644 index 0000000..c404a12 --- /dev/null +++ b/app/adminapi/controller/finance/RechargeRecordController.php @@ -0,0 +1,163 @@ +dataLists(new RechargeRecordLists()); + } + + /** + * @notes 获取代理充值记录列表 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function agentLists() + { + return $this->dataLists(new AgentRechargeRecordLists()); + } + + /** + * @notes 删除充值记录 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function delete() + { + $params = (new RechargeRecordValidate())->post()->goCheck('delete'); + RechargeRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 同意充值 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function agree() + { + $params = (new RechargeRecordValidate())->post()->goCheck('agree'); + $result = RechargeRecordLogic::agree($params['id']); + if (true === $result) { + return $this->success('同意成功', [], 1, 1); + } + return $this->fail(RechargeRecordLogic::getError()); + } + + /** + * @notes 拒绝充值 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function refuse() + { + $params = (new RechargeRecordValidate())->post()->goCheck('refuse'); + $result = RechargeRecordLogic::refuse($params['id']); + if (true === $result) { + return $this->success('拒绝成功', [], 1, 1); + } + return $this->fail(RechargeRecordLogic::getError()); + } + + /** + * @notes 备注 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function remark() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + $result = RechargeRecordLogic::remark($params); + if (true === $result) { + return $this->success('备注成功', [], 1, 1); + } + return $this->fail(RechargeRecordLogic::getError()); + } + + /** + * @notes 修改充值金额 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function changeAmount() + { + $params = $this->request->post(); + $result = RechargeRecordLogic::changeAmount($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(RechargeRecordLogic::getError()); + } + + /** + * @notes 新充值提现条数 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function warmCount() + { + $result = RechargeRecordLogic::warmCount(); + return $this->success('', $result); + } + + /** + * @notes 充值统计 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author bd + * @date 2024/01/31 14:07 + */ + public function stat() + { + $result = RechargeRecordLogic::stat(); + return $this->success('', $result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/finance/UserFinanceController.php b/app/adminapi/controller/finance/UserFinanceController.php new file mode 100644 index 0000000..1de2a0b --- /dev/null +++ b/app/adminapi/controller/finance/UserFinanceController.php @@ -0,0 +1,85 @@ +dataLists(new UserFinanceLists()); + } + + /** + * @notes 获取代理资金明细列表 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function agentLists() + { + return $this->dataLists(new AgentUserFinanceLists()); + } + + + /** + * @notes 删除资金明细 + * @return \think\response\Json + * @author BD + * @date 2024/03/07 13:10 + */ + public function delete() + { + $params = (new UserFinanceValidate())->post()->goCheck('delete'); + UserFinanceLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + /** + * @notes 解冻 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function unfrozen() + { + $params = (new UserFinanceValidate())->post()->goCheck('unfrozen'); + $result = UserFinanceLogic::unfrozen($params); + if (true === $result) { + return $this->success('解冻成功', [], 1, 1); + } + return $this->fail(UserFinanceLogic::getError()); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/finance/WithdrawRecordController.php b/app/adminapi/controller/finance/WithdrawRecordController.php new file mode 100644 index 0000000..349244a --- /dev/null +++ b/app/adminapi/controller/finance/WithdrawRecordController.php @@ -0,0 +1,199 @@ +dataLists(new WithdrawRecordLists()); + } + + /** + * @notes 获取代理提现记录列表 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function agentLists() + { + return $this->dataLists(new AgentWithdrawRecordLists()); + } + + /** + * @notes 添加提现记录 + * @return \think\response\Json + * @author BD + * @date 2024/02/25 12:35 + */ + public function add() + { + $params = (new WithdrawRecordValidate())->post()->goCheck('add'); + $result = WithdrawRecordLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(WithdrawRecordLogic::getError()); + } + + + /** + * @notes 编辑提现记录 + * @return \think\response\Json + * @author BD + * @date 2024/02/25 12:35 + */ + public function edit() + { + $params = (new WithdrawRecordValidate())->post()->goCheck('edit'); + $result = WithdrawRecordLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(WithdrawRecordLogic::getError()); + } + + + /** + * @notes 删除提现记录 + * @return \think\response\Json + * @author BD + * @date 2024/02/25 12:35 + */ + public function delete() + { + $params = (new WithdrawRecordValidate())->post()->goCheck('delete'); + WithdrawRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取提现记录详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/25 12:35 + */ + public function detail() + { + $params = (new WithdrawRecordValidate())->goCheck('detail'); + $result = WithdrawRecordLogic::detail($params); + return $this->data($result); + } + + /** + * @notes udun代付 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function udunPay() + { + $params = (new WithdrawRecordValidate())->post()->goCheck('udunPay'); + $result = WithdrawRecordLogic::udunPay($params); + if ('success' === $result) { + return $this->success('发起成功', [], 1, 1); + } + + return $this->fail(WithdrawRecordLogic::getError()); + } + + /** + * @notes 同意提现 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function agree() + { + $params = (new WithdrawRecordValidate())->post()->goCheck('agree'); + $result = WithdrawRecordLogic::agree($params); + if (true === $result) { + return $this->success('同意成功', [], 1, 1); + } + return $this->fail(WithdrawRecordLogic::getError()); + } + + /** + * @notes 拒绝提现 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function refuse() + { + $params = (new WithdrawRecordValidate())->post()->goCheck('refuse'); + $result = WithdrawRecordLogic::refuse($params); + if (true === $result) { + return $this->success('拒绝成功', [], 1, 1); + } + return $this->fail(WithdrawRecordLogic::getError()); + } + + /** + * @notes 备注 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function remark() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + $result = WithdrawRecordLogic::remark($params); + if (true === $result) { + return $this->success('备注成功', [], 1, 1); + } + return $this->fail(WithdrawRecordLogic::getError()); + } + + /** + * @notes 提现统计 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author bd + * @date 2024/01/31 14:07 + */ + public function stat() + { + $result = WithdrawRecordLogic::stat(); + return $this->success('', $result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/goods/GoodsCateController.php b/app/adminapi/controller/goods/GoodsCateController.php new file mode 100644 index 0000000..228b2ea --- /dev/null +++ b/app/adminapi/controller/goods/GoodsCateController.php @@ -0,0 +1,123 @@ +dataLists(new GoodsCateLists()); + } + + + /** + * @notes 添加商品分类 + * @return \think\response\Json + * @author BD + * @date 2024/03/11 01:58 + */ + public function add() + { + $params = (new GoodsCateValidate())->post()->goCheck('add'); + $result = GoodsCateLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(GoodsCateLogic::getError()); + } + + + /** + * @notes 编辑商品分类 + * @return \think\response\Json + * @author BD + * @date 2024/03/11 01:58 + */ + public function edit() + { + $params = (new GoodsCateValidate())->post()->goCheck('edit'); + $result = GoodsCateLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(GoodsCateLogic::getError()); + } + + + /** + * @notes 删除商品分类 + * @return \think\response\Json + * @author BD + * @date 2024/03/11 01:58 + */ + public function delete() + { + $params = (new GoodsCateValidate())->post()->goCheck('delete'); + GoodsCateLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取商品分类详情 + * @return \think\response\Json + * @author BD + * @date 2024/03/11 01:58 + */ + public function detail() + { + $params = (new GoodsCateValidate())->goCheck('detail'); + $result = GoodsCateLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 获取商品分类 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/11 01:58 + */ + public function all() + { + $result = GoodsCateLogic::getAllData(); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/goods/GoodsController.php b/app/adminapi/controller/goods/GoodsController.php new file mode 100644 index 0000000..99fc97d --- /dev/null +++ b/app/adminapi/controller/goods/GoodsController.php @@ -0,0 +1,108 @@ +dataLists(new GoodsLists()); + } + + + /** + * @notes 添加商品 + * @return \think\response\Json + * @author BD + * @date 2024/03/11 01:58 + */ + public function add() + { + $params = (new GoodsValidate())->post()->goCheck('add'); + $result = GoodsLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(GoodsLogic::getError()); + } + + + /** + * @notes 编辑商品 + * @return \think\response\Json + * @author BD + * @date 2024/03/11 01:58 + */ + public function edit() + { + $params = (new GoodsValidate())->post()->goCheck('edit'); + $result = GoodsLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(GoodsLogic::getError()); + } + + + /** + * @notes 删除商品 + * @return \think\response\Json + * @author BD + * @date 2024/03/11 01:58 + */ + public function delete() + { + $params = (new GoodsValidate())->post()->goCheck('delete'); + GoodsLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取商品详情 + * @return \think\response\Json + * @author BD + * @date 2024/03/11 01:58 + */ + public function detail() + { + $params = (new GoodsValidate())->goCheck('detail'); + $result = GoodsLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/goods/GoodsRecordController.php b/app/adminapi/controller/goods/GoodsRecordController.php new file mode 100644 index 0000000..943be31 --- /dev/null +++ b/app/adminapi/controller/goods/GoodsRecordController.php @@ -0,0 +1,76 @@ +dataLists(new GoodsRecordLists()); + } + + + /** + * @notes 删除抢单记录 + * @return \think\response\Json + * @author BD + * @date 2024/03/19 02:29 + */ + public function delete() + { + $params = (new GoodsRecordValidate())->post()->goCheck('delete'); + GoodsRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + /** + * @notes 派单 + * @return \think\response\Json + * @author BD + * @date 2024/03/19 02:29 + */ + public function dispatch() + { + $params = (new GoodsRecordValidate())->post()->goCheck('dispatch'); + $result = GoodsRecordLogic::dispatch($params); + if (true === $result) { + return $this->success('派单成功', [], 1, 1); + } + return $this->fail(GoodsRecordLogic::getError()); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/item/ItemCateController.php b/app/adminapi/controller/item/ItemCateController.php new file mode 100644 index 0000000..49fbe14 --- /dev/null +++ b/app/adminapi/controller/item/ItemCateController.php @@ -0,0 +1,138 @@ +dataLists(new ItemCateLists()); + } + + + /** + * @notes 添加项目分类 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function add() + { + $params = (new ItemCateValidate())->post()->goCheck('add'); + $result = ItemCateLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(ItemCateLogic::getError()); + } + + + /** + * @notes 编辑项目分类 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function edit() + { + $params = (new ItemCateValidate())->post()->goCheck('edit'); + $result = ItemCateLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ItemCateLogic::getError()); + } + + + /** + * @notes 删除项目分类 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function delete() + { + $params = (new ItemCateValidate())->post()->goCheck('delete'); + ItemCateLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取项目分类详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function detail() + { + $params = (new ItemCateValidate())->goCheck('detail'); + $result = ItemCateLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 更改项目分类状态 + * @return \think\response\Json + * @author likeadmin + * @date 2022/2/21 10:15 + */ + public function updateStatus() + { + $params = (new ItemCateValidate())->post()->goCheck('status'); + $result = ItemCateLogic::updateStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(ItemCateLogic::getError()); + } + + /** + * @notes 获取项目分类 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:54 + */ + public function all() + { + $result = ItemCateLogic::getAllData(); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/item/ItemController.php b/app/adminapi/controller/item/ItemController.php new file mode 100644 index 0000000..45d2fe7 --- /dev/null +++ b/app/adminapi/controller/item/ItemController.php @@ -0,0 +1,124 @@ +dataLists(new ItemLists()); + } + + + /** + * @notes 添加项目 + * @return \think\response\Json + * @author BD + * @date 2024/01/16 13:23 + */ + public function add() + { + $params = (new ItemValidate())->post()->goCheck('add'); + $result = ItemLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(ItemLogic::getError()); + } + + + /** + * @notes 编辑项目 + * @return \think\response\Json + * @author BD + * @date 2024/01/16 13:23 + */ + public function edit() + { + $params = (new ItemValidate())->post()->goCheck('edit'); + $result = ItemLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ItemLogic::getError()); + } + + + /** + * @notes 删除项目 + * @return \think\response\Json + * @author BD + * @date 2024/01/16 13:23 + */ + public function delete() + { + $params = (new ItemValidate())->post()->goCheck('delete'); + ItemLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取项目详情 + * @return \think\response\Json + * @author BD + * @date 2024/01/16 13:23 + */ + public function detail() + { + $params = (new ItemValidate())->goCheck('detail'); + $result = ItemLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function updateIndexStatus() + { + $params = $this->request->post(); + $result = ItemLogic::updateIndexStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/item/ItemRecordController.php b/app/adminapi/controller/item/ItemRecordController.php new file mode 100644 index 0000000..0dfeda5 --- /dev/null +++ b/app/adminapi/controller/item/ItemRecordController.php @@ -0,0 +1,94 @@ +dataLists(new ItemRecordLists()); + } + + + /** + * @notes 添加项目记录 + * @return \think\response\Json + * @author BD + * @date 2024/08/07 15:42 + */ + public function add() + { + $params = (new ItemRecordValidate())->post()->goCheck('add'); + $result = ItemRecordLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(ItemRecordLogic::getError()); + } + + + /** + * @notes 编辑项目记录 + * @return \think\response\Json + * @author BD + * @date 2024/08/07 15:42 + */ + public function edit() + { + $params = (new ItemRecordValidate())->post()->goCheck('edit'); + $result = ItemRecordLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ItemRecordLogic::getError()); + } + + + /** + * @notes 删除项目记录 + * @return \think\response\Json + * @author BD + * @date 2024/08/07 15:42 + */ + public function delete() + { + $params = (new ItemRecordValidate())->post()->goCheck('delete'); + ItemRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取项目记录详情 + * @return \think\response\Json + * @author BD + * @date 2024/08/07 15:42 + */ + public function detail() + { + $params = (new ItemRecordValidate())->goCheck('detail'); + $result = ItemRecordLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/lh/LhCoinController.php b/app/adminapi/controller/lh/LhCoinController.php new file mode 100644 index 0000000..cbdda55 --- /dev/null +++ b/app/adminapi/controller/lh/LhCoinController.php @@ -0,0 +1,94 @@ +dataLists(new LhCoinLists()); + } + + + /** + * @notes 添加量化货币 + * @return \think\response\Json + * @author BD + * @date 2024/05/19 21:13 + */ + public function add() + { + $params = (new LhCoinValidate())->post()->goCheck('add'); + $result = LhCoinLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(LhCoinLogic::getError()); + } + + + /** + * @notes 编辑量化货币 + * @return \think\response\Json + * @author BD + * @date 2024/05/19 21:13 + */ + public function edit() + { + $params = (new LhCoinValidate())->post()->goCheck('edit'); + $result = LhCoinLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(LhCoinLogic::getError()); + } + + + /** + * @notes 删除量化货币 + * @return \think\response\Json + * @author BD + * @date 2024/05/19 21:13 + */ + public function delete() + { + $params = (new LhCoinValidate())->post()->goCheck('delete'); + LhCoinLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取量化货币详情 + * @return \think\response\Json + * @author BD + * @date 2024/05/19 21:13 + */ + public function detail() + { + $params = (new LhCoinValidate())->goCheck('detail'); + $result = LhCoinLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/lh/LhRecordController.php b/app/adminapi/controller/lh/LhRecordController.php new file mode 100644 index 0000000..cbd6d30 --- /dev/null +++ b/app/adminapi/controller/lh/LhRecordController.php @@ -0,0 +1,94 @@ +dataLists(new LhRecordLists()); + } + + + /** + * @notes 添加量化记录 + * @return \think\response\Json + * @author BD + * @date 2024/05/19 21:13 + */ + public function add() + { + $params = (new LhRecordValidate())->post()->goCheck('add'); + $result = LhRecordLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(LhRecordLogic::getError()); + } + + + /** + * @notes 编辑量化记录 + * @return \think\response\Json + * @author BD + * @date 2024/05/19 21:13 + */ + public function edit() + { + $params = (new LhRecordValidate())->post()->goCheck('edit'); + $result = LhRecordLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(LhRecordLogic::getError()); + } + + + /** + * @notes 删除量化记录 + * @return \think\response\Json + * @author BD + * @date 2024/05/19 21:13 + */ + public function delete() + { + $params = (new LhRecordValidate())->post()->goCheck('delete'); + LhRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取量化记录详情 + * @return \think\response\Json + * @author BD + * @date 2024/05/19 21:13 + */ + public function detail() + { + $params = (new LhRecordValidate())->goCheck('detail'); + $result = LhRecordLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/mall/MallGoodsController.php b/app/adminapi/controller/mall/MallGoodsController.php new file mode 100644 index 0000000..2609d81 --- /dev/null +++ b/app/adminapi/controller/mall/MallGoodsController.php @@ -0,0 +1,94 @@ +dataLists(new MallGoodsLists()); + } + + + /** + * @notes 添加积分、抽奖奖品 + * @return \think\response\Json + * @author BD + * @date 2024/10/14 23:57 + */ + public function add() + { + $params = (new MallGoodsValidate())->post()->goCheck('add'); + $result = MallGoodsLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(MallGoodsLogic::getError()); + } + + + /** + * @notes 编辑积分、抽奖奖品 + * @return \think\response\Json + * @author BD + * @date 2024/10/14 23:57 + */ + public function edit() + { + $params = (new MallGoodsValidate())->post()->goCheck('edit'); + $result = MallGoodsLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(MallGoodsLogic::getError()); + } + + + /** + * @notes 删除积分、抽奖奖品 + * @return \think\response\Json + * @author BD + * @date 2024/10/14 23:57 + */ + public function delete() + { + $params = (new MallGoodsValidate())->post()->goCheck('delete'); + MallGoodsLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取积分、抽奖奖品详情 + * @return \think\response\Json + * @author BD + * @date 2024/10/14 23:57 + */ + public function detail() + { + $params = (new MallGoodsValidate())->goCheck('detail'); + $result = MallGoodsLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/mall/MallGoodsRecordController.php b/app/adminapi/controller/mall/MallGoodsRecordController.php new file mode 100644 index 0000000..3b3651d --- /dev/null +++ b/app/adminapi/controller/mall/MallGoodsRecordController.php @@ -0,0 +1,94 @@ +dataLists(new MallGoodsRecordLists()); + } + + + /** + * @notes 添加奖品记录 + * @return \think\response\Json + * @author BD + * @date 2024/10/15 14:00 + */ + public function add() + { + $params = (new MallGoodsRecordValidate())->post()->goCheck('add'); + $result = MallGoodsRecordLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(MallGoodsRecordLogic::getError()); + } + + + /** + * @notes 编辑奖品记录 + * @return \think\response\Json + * @author BD + * @date 2024/10/15 14:00 + */ + public function edit() + { + $params = (new MallGoodsRecordValidate())->post()->goCheck('edit'); + $result = MallGoodsRecordLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(MallGoodsRecordLogic::getError()); + } + + + /** + * @notes 删除奖品记录 + * @return \think\response\Json + * @author BD + * @date 2024/10/15 14:00 + */ + public function delete() + { + $params = (new MallGoodsRecordValidate())->post()->goCheck('delete'); + MallGoodsRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取奖品记录详情 + * @return \think\response\Json + * @author BD + * @date 2024/10/15 14:00 + */ + public function detail() + { + $params = (new MallGoodsRecordValidate())->goCheck('detail'); + $result = MallGoodsRecordLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/member/UserMemberController.php b/app/adminapi/controller/member/UserMemberController.php new file mode 100644 index 0000000..d69d6c7 --- /dev/null +++ b/app/adminapi/controller/member/UserMemberController.php @@ -0,0 +1,138 @@ +dataLists(new UserMemberLists()); + } + + + /** + * @notes 添加会员等级 + * @return \think\response\Json + * @author BD + * @date 2024/03/14 00:28 + */ + public function add() + { + $params = (new UserMemberValidate())->post()->goCheck('add'); + $result = UserMemberLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserMemberLogic::getError()); + } + + + /** + * @notes 编辑会员等级 + * @return \think\response\Json + * @author BD + * @date 2024/03/14 00:28 + */ + public function edit() + { + $params = (new UserMemberValidate())->post()->goCheck('edit'); + $result = UserMemberLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserMemberLogic::getError()); + } + + + /** + * @notes 删除会员等级 + * @return \think\response\Json + * @author BD + * @date 2024/03/14 00:28 + */ + public function delete() + { + $params = (new UserMemberValidate())->post()->goCheck('delete'); + UserMemberLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取会员等级详情 + * @return \think\response\Json + * @author BD + * @date 2024/03/14 00:28 + */ + public function detail() + { + $params = (new UserMemberValidate())->goCheck('detail'); + $result = UserMemberLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 设置用户会员等级 + * @return \think\response\Json + * @author BD + * @date 2024/03/19 02:29 + */ + public function setUserMember() + { + $params = $this->request->post(); + $result = UserMemberLogic::setUserMember($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(UserMemberLogic::getError()); + } + + /** + * @notes 获取会员等级 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/11 01:58 + */ + public function all() + { + $result = UserMemberLogic::getAllData(); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/notice/NoticeController.php b/app/adminapi/controller/notice/NoticeController.php new file mode 100644 index 0000000..48f2707 --- /dev/null +++ b/app/adminapi/controller/notice/NoticeController.php @@ -0,0 +1,70 @@ +dataLists(new NoticeSettingLists()); + } + + + /** + * @notes 查看通知设置详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 11:18 + */ + public function detail() + { + $params = (new NoticeValidate())->goCheck('detail'); + $result = NoticeLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 通知设置 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 11:18 + */ + public function set() + { + $params = $this->request->post(); + $result = NoticeLogic::set($params); + if ($result) { + return $this->success('设置成功'); + } + return $this->fail(NoticeLogic::getError()); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/notice/SmsConfigController.php b/app/adminapi/controller/notice/SmsConfigController.php new file mode 100644 index 0000000..86516c3 --- /dev/null +++ b/app/adminapi/controller/notice/SmsConfigController.php @@ -0,0 +1,69 @@ +data($result); + } + + + /** + * @notes 短信配置 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 11:36 + */ + public function setConfig() + { + $params = (new SmsConfigValidate())->post()->goCheck('setConfig'); + SmsConfigLogic::setConfig($params); + return $this->success('操作成功',[],1,1); + } + + + /** + * @notes 查看短信配置详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/3/29 11:36 + */ + public function detail() + { + $params = (new SmsConfigValidate())->goCheck('detail'); + $result = SmsConfigLogic::detail($params); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/CustomerServiceController.php b/app/adminapi/controller/setting/CustomerServiceController.php new file mode 100644 index 0000000..3ad8523 --- /dev/null +++ b/app/adminapi/controller/setting/CustomerServiceController.php @@ -0,0 +1,38 @@ +data($result); + } + + /** + * @notes 设置客服设置 + * @return \think\response\Json + * @author BD + * @date 2024/2/15 12:11 下午 + */ + public function setConfig() + { + $params = $this->request->post(); + CustomerServiceLogic::setConfig($params); + return $this->success('设置成功', [], 1, 1); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/LanguageController.php b/app/adminapi/controller/setting/LanguageController.php new file mode 100644 index 0000000..f187944 --- /dev/null +++ b/app/adminapi/controller/setting/LanguageController.php @@ -0,0 +1,124 @@ +dataLists(new LanguageLists()); + } + + + /** + * @notes 添加语言包 + * @return \think\response\Json + * @author BD + * @date 2023/11/30 13:59 + */ + public function add() + { + $params = (new LanguageValidate())->post()->goCheck('add'); + $result = LanguageLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(LanguageLogic::getError()); + } + + + /** + * @notes 编辑语言包 + * @return \think\response\Json + * @author BD + * @date 2023/11/30 13:59 + */ + public function edit() + { + $params = (new LanguageValidate())->post()->goCheck('edit'); + $result = LanguageLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(LanguageLogic::getError()); + } + + + /** + * @notes 删除语言包 + * @return \think\response\Json + * @author BD + * @date 2023/11/30 13:59 + */ + public function delete() + { + $params = (new LanguageValidate())->post()->goCheck('delete'); + LanguageLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取语言详情 + * @return \think\response\Json + * @author BD + * @date 2023/11/30 13:59 + */ + public function detail() + { + $params = (new LanguageValidate())->goCheck('detail'); + $result = LanguageLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2024/2/22 10:18 + */ + public function updateStatus() + { + $params = (new LanguageValidate())->post()->goCheck('status'); + $result = LanguageLogic::updateStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(LanguageLogic::getError()); + } + + /** + * @notes 获取所有语言 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/10/13 10:54 + */ + public function all() + { + $result = LanguageLogic::getAllData(); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/LanguagePagController.php b/app/adminapi/controller/setting/LanguagePagController.php new file mode 100644 index 0000000..1bbbb50 --- /dev/null +++ b/app/adminapi/controller/setting/LanguagePagController.php @@ -0,0 +1,122 @@ +dataLists(new LanguagePagLists()); + } + + + /** + * @notes 添加语言包 + * @return \think\response\Json + * @author BD + * @date 2024/01/14 13:50 + */ + public function add() + { + $params = (new LanguagePagValidate())->post()->goCheck('add'); + $result = LanguagePagLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(LanguagePagLogic::getError()); + } + + + /** + * @notes 编辑语言包 + * @return \think\response\Json + * @author BD + * @date 2024/01/14 13:50 + */ + public function edit() + { + $params = (new LanguagePagValidate())->post()->goCheck('edit'); + $result = LanguagePagLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(LanguagePagLogic::getError()); + } + + + /** + * @notes 删除语言包 + * @return \think\response\Json + * @author BD + * @date 2024/01/14 13:50 + */ + public function delete() + { + $params = (new LanguagePagValidate())->post()->goCheck('delete'); + LanguagePagLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取语言包详情 + * @return \think\response\Json + * @author BD + * @date 2024/01/14 13:50 + */ + public function detail() + { + $params = (new LanguagePagValidate())->goCheck('detail'); + $result = LanguagePagLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 同步语言包 + * @return \think\response\Json + * @author BD + * @date 2024/01/14 13:50 + */ + public function sync() + { + $params = $this->request->post(); + LanguagePagLogic::sync($params); + return $this->success('同步成功', [], 1, 1); + } + + /** + * @notes 翻译语言包 + * @return \think\response\Json + * @author BD + * @date 2024/01/14 13:50 + */ + public function trans() + { + $params = $this->request->post(); + $result = LanguagePagLogic::trans($params); + if (true === $result) { + return $this->success('翻译成功', [], 1, 1); + } + return $this->fail(LanguagePagLogic::getError()); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/RechargeMethodController.php b/app/adminapi/controller/setting/RechargeMethodController.php new file mode 100644 index 0000000..2d53969 --- /dev/null +++ b/app/adminapi/controller/setting/RechargeMethodController.php @@ -0,0 +1,125 @@ +dataLists(new RechargeMethodLists()); + } + + + /** + * @notes 添加充值方式 + * @return \think\response\Json + * @author BD + * @date 2023/11/30 15:22 + */ + public function add() + { + $params = (new RechargeMethodValidate())->post()->goCheck('add'); + $result = RechargeMethodLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(RechargeMethodLogic::getError()); + } + + + /** + * @notes 编辑充值方式 + * @return \think\response\Json + * @author BD + * @date 2023/11/30 15:22 + */ + public function edit() + { + $params = (new RechargeMethodValidate())->post()->goCheck('edit'); + $result = RechargeMethodLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(RechargeMethodLogic::getError()); + } + + + /** + * @notes 删除充值方式 + * @return \think\response\Json + * @author BD + * @date 2023/11/30 15:22 + */ + public function delete() + { + $params = (new RechargeMethodValidate())->post()->goCheck('delete'); + RechargeMethodLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取充值方式详情 + * @return \think\response\Json + * @author BD + * @date 2023/11/30 15:22 + */ + public function detail() + { + $params = (new RechargeMethodValidate())->goCheck('detail'); + $result = RechargeMethodLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function updateStatus() + { + $params = (new RechargeMethodValidate())->post()->goCheck('status'); + $result = RechargeMethodLogic::updateStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(RechargeMethodLogic::getError()); + } + + /** + * @notes 获取全部充值方式 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2323/10/13 10:54 + */ + public function all() + { + $result = RechargeMethodLogic::getAllData(); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/StorageController.php b/app/adminapi/controller/setting/StorageController.php new file mode 100644 index 0000000..690a3e7 --- /dev/null +++ b/app/adminapi/controller/setting/StorageController.php @@ -0,0 +1,73 @@ +success('获取成功', StorageLogic::lists()); + } + + + /** + * @notes 存储配置信息 + * @return Json + * @author BD + * @date 2023/4/20 16:19 + */ + public function detail() + { + $param = (new StorageValidate())->get()->goCheck('detail'); + return $this->success('获取成功', StorageLogic::detail($param)); + } + + + /** + * @notes 设置存储参数 + * @return Json + * @author BD + * @date 2023/4/20 16:19 + */ + public function setup() + { + $params = (new StorageValidate())->post()->goCheck('setup'); + $result = StorageLogic::setup($params); + if (true === $result) { + return $this->success('配置成功', [], 1, 1); + } + return $this->success($result, [], 1, 1); + } + + + /** + * @notes 切换存储引擎 + * @return Json + * @author BD + * @date 2023/4/20 16:19 + */ + public function change() + { + $params = (new StorageValidate())->post()->goCheck('change'); + StorageLogic::change($params); + return $this->success('切换成功', [], 1, 1); + } +} diff --git a/app/adminapi/controller/setting/TransactionSettingsController.php b/app/adminapi/controller/setting/TransactionSettingsController.php new file mode 100644 index 0000000..05be4a3 --- /dev/null +++ b/app/adminapi/controller/setting/TransactionSettingsController.php @@ -0,0 +1,40 @@ +data($result); + } + + /** + * @notes 设置交易设置 + * @return \think\response\Json + * @author BD + * @date 2023/2/15 11:50 上午 + */ + public function setConfig() + { + $params = (new TransactionSettingsValidate())->post()->goCheck('setConfig'); + TransactionSettingsLogic::setConfig($params); + return $this->success('操作成功',[],1,1); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/dict/DictDataController.php b/app/adminapi/controller/setting/dict/DictDataController.php new file mode 100644 index 0000000..c9d1285 --- /dev/null +++ b/app/adminapi/controller/setting/dict/DictDataController.php @@ -0,0 +1,99 @@ +dataLists(new DictDataLists()); + } + + + /** + * @notes 添加字典数据 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/20 17:13 + */ + public function add() + { + $params = (new DictDataValidate())->post()->goCheck('add'); + DictDataLogic::save($params); + return $this->success('添加成功', [], 1, 1); + } + + + /** + * @notes 编辑字典数据 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/20 17:13 + */ + public function edit() + { + $params = (new DictDataValidate())->post()->goCheck('edit'); + DictDataLogic::save($params); + return $this->success('编辑成功', [], 1, 1); + } + + + /** + * @notes 删除字典数据 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/20 17:13 + */ + public function delete() + { + $params = (new DictDataValidate())->post()->goCheck('id'); + DictDataLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取字典详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/20 17:14 + */ + public function detail() + { + $params = (new DictDataValidate())->goCheck('id'); + $result = DictDataLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/dict/DictTypeController.php b/app/adminapi/controller/setting/dict/DictTypeController.php new file mode 100644 index 0000000..18efbf8 --- /dev/null +++ b/app/adminapi/controller/setting/dict/DictTypeController.php @@ -0,0 +1,116 @@ +dataLists(new DictTypeLists()); + } + + + /** + * @notes 添加字典类型 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/20 16:24 + */ + public function add() + { + $params = (new DictTypeValidate())->post()->goCheck('add'); + DictTypeLogic::add($params); + return $this->success('添加成功', [], 1, 1); + } + + + /** + * @notes 编辑字典类型 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/20 16:25 + */ + public function edit() + { + $params = (new DictTypeValidate())->post()->goCheck('edit'); + DictTypeLogic::edit($params); + return $this->success('编辑成功', [], 1, 1); + } + + + /** + * @notes 删除字典类型 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/20 16:25 + */ + public function delete() + { + $params = (new DictTypeValidate())->post()->goCheck('delete'); + DictTypeLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取字典详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/20 16:25 + */ + public function detail() + { + $params = (new DictTypeValidate())->goCheck('detail'); + $result = DictTypeLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 获取字典类型数据 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:46 + */ + public function all() + { + $result = DictTypeLogic::getAllData(); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/system/CacheController.php b/app/adminapi/controller/setting/system/CacheController.php new file mode 100644 index 0000000..b4a83f9 --- /dev/null +++ b/app/adminapi/controller/setting/system/CacheController.php @@ -0,0 +1,39 @@ +success('清除成功', [], 1, 1); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/system/LogController.php b/app/adminapi/controller/setting/system/LogController.php new file mode 100644 index 0000000..c3ea02e --- /dev/null +++ b/app/adminapi/controller/setting/system/LogController.php @@ -0,0 +1,69 @@ +dataLists(new LogLists()); + } + /** + * @notes 删除已选择的系统日志 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/15 19:00 + */ + public function delete() + { + $params = (new OperationLogValidate())->post()->goCheck('id'); + $result = OperationLogLogic::deleteTable($params); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(OperationLogLogic::getError()); + } + /** + * @notes 删除系统日志 + * @return \think\response\Json + * @author 段誉 + * @date 2022/6/15 19:00 + */ + public function deleteAll() + { + $result = OperationLogLogic::deleteAll(); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(OperationLogLogic::getError()); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/system/SystemController.php b/app/adminapi/controller/setting/system/SystemController.php new file mode 100644 index 0000000..dbe5bc5 --- /dev/null +++ b/app/adminapi/controller/setting/system/SystemController.php @@ -0,0 +1,42 @@ +data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/user/UserController.php b/app/adminapi/controller/setting/user/UserController.php new file mode 100644 index 0000000..65a2420 --- /dev/null +++ b/app/adminapi/controller/setting/user/UserController.php @@ -0,0 +1,72 @@ +getConfig(); + return $this->data($result); + } + + + /** + * @notes 设置用户设置 + * @return \think\response\Json + * @author BD + * @date 2024/3/29 10:08 + */ + public function setConfig() + { + $params = (new UserConfigValidate())->post()->goCheck('user'); + (new UserLogic())->setConfig($params); + return $this->success('操作成功', [], 1, 1); + } + + + /** + * @notes 获取注册配置 + * @return \think\response\Json + * @author BD + * @date 2024/3/29 10:08 + */ + public function getRegisterConfig() + { + $result = (new UserLogic())->getRegisterConfig(); + return $this->data($result); + } + + + /** + * @notes 设置注册配置 + * @return \think\response\Json + * @author BD + * @date 2024/3/29 10:08 + */ + public function setRegisterConfig() + { + $params = (new UserConfigValidate())->post()->goCheck('register'); + (new UserLogic())->setRegisterConfig($params); + return $this->success('操作成功', [], 1, 1); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/setting/web/WebSettingController.php b/app/adminapi/controller/setting/web/WebSettingController.php new file mode 100644 index 0000000..a498f20 --- /dev/null +++ b/app/adminapi/controller/setting/web/WebSettingController.php @@ -0,0 +1,142 @@ +data($result); + } + + /** + * @notes 设置网站信息 + * @return \think\response\Json + * @author BD + * @date 2023/12/28 15:45 + */ + public function setWebsite() + { + $params = (new WebSettingValidate())->post()->goCheck('website'); + WebSettingLogic::setWebsiteInfo($params); + return $this->success('设置成功', [], 1, 1); + } + + /** + * @notes 获取网站配置 + * @return \think\response\Json + * @author BD + * @date 2023/12/28 15:44 + */ + public function getWebsiteProject() + { + $params = $this->request->get(); + $result = WebSettingLogic::getWebsiteProject($params); + if ($result === false) { + return $this->fail(WebSettingLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 设置网站配置 + * @return \think\response\Json + * @author BD + * @date 2023/12/28 15:45 + */ + public function setWebsiteProject() + { + $params = $this->request->post(); + $result = WebSettingLogic::setWebsiteProject($params); + if (false === $result) { + return $this->fail(WebSettingLogic::getError() ?: '操作失败'); + } + return $this->success('设置成功', [], 1, 1); + } + + /** + * @notes 获取国际区号 + * @return \think\response\Json + * @author BD + * @date 2023/12/28 16:10 + */ + public function getRegioncodeAll() + { + $result = WebSettingLogic::getRegioncodeAll(); + return $this->data($result); + } + + + + /** + * @notes 获取备案信息 + * @return \think\response\Json + * @author BD + * @date 2023/12/28 16:10 + */ + public function getCopyright() + { + $result = WebSettingLogic::getCopyright(); + return $this->data($result); + } + + + /** + * @notes 设置备案信息 + * @return \think\response\Json + * @author BD + * @date 2023/12/28 16:10 + */ + public function setCopyright() + { + $params = $this->request->post(); + $result = WebSettingLogic::setCopyright($params); + if (false === $result) { + return $this->fail(WebSettingLogic::getError() ?: '操作失败'); + } + return $this->success('设置成功', [], 1, 1); + } + + + /** + * @notes 设置政策协议 + * @return \think\response\Json + * @author BD + * @date 2023/2/15 11:00 上午 + */ + public function setAgreement() + { + $params = $this->request->post(); + WebSettingLogic::setAgreement($params); + return $this->success('设置成功', [], 1, 1); + } + + + /** + * @notes 获取政策协议 + * @return \think\response\Json + * @author BD + * @date 2023/2/15 11:16 上午 + */ + public function getAgreement() + { + $result = WebSettingLogic::getAgreement(); + return $this->data($result); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/tools/GeneratorController.php b/app/adminapi/controller/tools/GeneratorController.php new file mode 100644 index 0000000..6287889 --- /dev/null +++ b/app/adminapi/controller/tools/GeneratorController.php @@ -0,0 +1,193 @@ +dataLists(new DataTableLists()); + } + + + /** + * @notes 获取已选择的数据表 + * @return \think\response\Json + * @author BD + * @date 2023/6/14 10:57 + */ + public function generateTable() + { + return $this->dataLists(new GenerateTableLists()); + } + + + /** + * @notes 选择数据表 + * @return \think\response\Json + * @author BD + * @date 2023/6/15 10:09 + */ + public function selectTable() + { + $params = (new GenerateTableValidate())->post()->goCheck('select'); + $result = GeneratorLogic::selectTable($params, $this->adminId); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(GeneratorLogic::getError()); + } + + + /** + * @notes 生成代码 + * @return \think\response\Json + * @author BD + * @date 2023/6/23 19:08 + */ + public function generate() + { + $params = (new GenerateTableValidate())->post()->goCheck('id'); + $result = GeneratorLogic::generate($params); + if (false === $result) { + return $this->fail(GeneratorLogic::getError()); + } + return $this->success('操作成功', $result, 1, 1); + } + + + /** + * @notes 下载文件 + * @return \think\response\File|\think\response\Json + * @author BD + * @date 2023/6/24 9:51 + */ + public function download() + { + $params = (new GenerateTableValidate())->goCheck('download'); + $result = GeneratorLogic::download($params['file']); + if (false === $result) { + return $this->fail(GeneratorLogic::getError() ?: '下载失败'); + } + return download($result, 'likeadmin-curd.zip'); + } + + + /** + * @notes 预览代码 + * @return \think\response\Json + * @author BD + * @date 2023/6/23 19:07 + */ + public function preview() + { + $params = (new GenerateTableValidate())->post()->goCheck('id'); + $result = GeneratorLogic::preview($params); + if (false === $result) { + return $this->fail(GeneratorLogic::getError()); + } + return $this->data($result); + } + + + /** + * @notes 同步字段 + * @return \think\response\Json + * @author BD + * @date 2023/6/17 15:22 + */ + public function syncColumn() + { + $params = (new GenerateTableValidate())->post()->goCheck('id'); + $result = GeneratorLogic::syncColumn($params); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(GeneratorLogic::getError()); + } + + + /** + * @notes 编辑表信息 + * @return \think\response\Json + * @author BD + * @date 2023/6/20 10:44 + */ + public function edit() + { + $params = (new EditTableValidate())->post()->goCheck(); + $result = GeneratorLogic::editTable($params); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(GeneratorLogic::getError()); + } + + + /** + * @notes 获取已选择的数据表详情 + * @return \think\response\Json + * @author BD + * @date 2023/6/15 19:00 + */ + public function detail() + { + $params = (new GenerateTableValidate())->goCheck('id'); + $result = GeneratorLogic::getTableDetail($params); + return $this->success('', $result); + } + + + /** + * @notes 删除已选择的数据表信息 + * @return \think\response\Json + * @author BD + * @date 2023/6/15 19:00 + */ + public function delete() + { + $params = (new GenerateTableValidate())->post()->goCheck('id'); + $result = GeneratorLogic::deleteTable($params); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(GeneratorLogic::getError()); + } + + + /** + * @notes 获取模型 + * @return \think\response\Json + * @author BD + * @date 2023/12/14 11:07 + */ + public function getModels() + { + $result = GeneratorLogic::getAllModels(); + return $this->success('', $result, 1, 1); + } + +} + diff --git a/app/adminapi/controller/translation/TranslationController.php b/app/adminapi/controller/translation/TranslationController.php new file mode 100644 index 0000000..4f78dff --- /dev/null +++ b/app/adminapi/controller/translation/TranslationController.php @@ -0,0 +1,45 @@ +request->post(); + $result = TranslationLogic::translation($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserController.php b/app/adminapi/controller/user/UserController.php new file mode 100644 index 0000000..b1e8d83 --- /dev/null +++ b/app/adminapi/controller/user/UserController.php @@ -0,0 +1,298 @@ +dataLists(new UserLists()); + } + + /** + * @notes 代理用户列表 + * @return \think\response\Json + * @author BD + * @date 2023/9/22 16:16 + */ + public function agentLists() + { + return $this->dataLists(new UserAgentLists()); + } + + /** + * @notes 添加用户 + * @return \think\response\Json + * @author BD + * @date 2023/9/22 16:34 + */ + public function add() + { + $params = (new AddUserValidate())->post()->goCheck('add'); + $res = UserLogic::add($params); + if (true === $res) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail($res); + } + + + /** + * @notes 修改用户密码 + * @return \think\response\Json + * @author BD + * @date 2023/9/22 16:34 + */ + public function changePwd() + { + $params = (new UserValidate())->post()->goCheck('changePwd'); + UserLogic::changePwd($params); + return $this->success('操作成功', [], 1, 1); + } + + /** + * @notes 重置支付密码 + * @return \think\response\Json + * @author BD + * @date 2023/9/22 16:34 + */ + public function resetPayPwd() + { + $params = $this->request->post(); + UserLogic::resetPayPwd($params); + return $this->success('操作成功', [], 1, 1); + } + + /** + * @notes 修改邮箱 + * @return \think\response\Json + * @author BD + * @date 2023/9/22 16:34 + */ + public function changeEmail() + { + $params = (new UserValidate())->post()->goCheck('changeEmail'); + UserLogic::changeEmail($params); + return $this->success('操作成功', [], 1, 1); + } + + /** + * @notes 重置邮箱验证 + * @return \think\response\Json + * @author BD + * @date 2023/9/22 16:34 + */ + public function resetEmail() + { + $params = $this->request->post(); + UserLogic::resetEmail($params); + return $this->success('操作成功', [], 1, 1); + } + + /** + * @notes 重置谷歌验证 + * @return \think\response\Json + * @author BD + * @date 2023/9/22 16:34 + */ + public function resetGoogle() + { + $params = $this->request->post(); + UserLogic::resetGoogle($params); + return $this->success('操作成功', [], 1, 1); + } + + /** + * @notes 调整用户余额 + * @return \think\response\Json + * @author BD + * @date 2023/2/23 14:33 + */ + public function adjustMoney() + { + $params = (new AdjustUserMoney())->post()->goCheck(); + $res = UserLogic::adjustUserMoney($params); + if (true === $res) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail($res); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function updateMemberStatus() + { + $params = $this->request->post(); + $result = UserLogic::updateMemberStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function updateLhStatus() + { + $params = $this->request->post(); + $result = UserLogic::updateLhStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function updateTransferStatus() + { + $params = $this->request->post(); + $result = UserLogic::updateTransferStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function updateSnStatus() + { + $params = $this->request->post(); + $result = UserLogic::updateSnStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function updateOpenStatus() + { + $params = $this->request->post(); + $result = UserLogic::updateOpenStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 更改状态 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function updateAgentStatus() + { + $params = $this->request->post(); + $result = UserLogic::updateAgentStatus($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail($result); + } + + /** + * @notes 修改代理名称 + * @return \think\response\Json + * @author BD + * @date 2023/9/22 16:34 + */ + public function changeAgentName() + { + $params = $this->request->post(); + $result = UserLogic::changeAgentName($params); + if (true === $result) { + return $this->success('修改成功', [], 1, 1); + } + return $this->fail($result); + } + + /** + * @notes 发送站内信 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function sendNotice() + { + $params = $this->request->post(); + $res = UserLogic::sendNotice($params); + if (true === $res) { + return $this->success('发送成功', [], 1, 1); + } + return $this->fail($res); + } + + /** + * @notes 彩金赠送 + * @return \think\response\Json + * @author BD + * @date 2323/2/22 10:18 + */ + public function caijin() + { + $params = $this->request->post(); + $res = UserLogic::caijin($params); + if (true === $res) { + return $this->success('赠送成功', [], 1, 1); + } + return $this->fail($res); + } + + /** + * @notes 备注 + * @return \think\response\Json + * @author bd + * @date 2024/01/31 14:07 + */ + public function remark() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + $result = UserLogic::remark($params); + if (true === $result) { + return $this->success('备注成功', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserGroupController.php b/app/adminapi/controller/user/UserGroupController.php new file mode 100644 index 0000000..0584a9b --- /dev/null +++ b/app/adminapi/controller/user/UserGroupController.php @@ -0,0 +1,110 @@ +dataLists(new UserGroupLists()); + } + + + /** + * @notes 添加用户分组 + * @return \think\response\Json + * @author BD + * @date 2024/04/25 01:04 + */ + public function add() + { + $params = (new UserGroupValidate())->post()->goCheck('add'); + $result = UserGroupLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserGroupLogic::getError()); + } + + + /** + * @notes 编辑用户分组 + * @return \think\response\Json + * @author BD + * @date 2024/04/25 01:04 + */ + public function edit() + { + $params = (new UserGroupValidate())->post()->goCheck('edit'); + $result = UserGroupLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserGroupLogic::getError()); + } + + + /** + * @notes 删除用户分组 + * @return \think\response\Json + * @author BD + * @date 2024/04/25 01:04 + */ + public function delete() + { + $params = (new UserGroupValidate())->post()->goCheck('delete'); + UserGroupLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取用户分组详情 + * @return \think\response\Json + * @author BD + * @date 2024/04/25 01:04 + */ + public function detail() + { + $params = (new UserGroupValidate())->goCheck('detail'); + $result = UserGroupLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 用户分组 + * @return \think\response\Json + * @author BD + * @date 2024/03/19 02:29 + */ + public function setUserGroup() + { + $params = $this->request->post(); + $result = UserGroupLogic::setUserGroup($params); + if (true === $result) { + return $this->success('分组成功', [], 1, 1); + } + return $this->fail(UserGroupLogic::getError()); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserGroupRuleController.php b/app/adminapi/controller/user/UserGroupRuleController.php new file mode 100644 index 0000000..5fe9e9d --- /dev/null +++ b/app/adminapi/controller/user/UserGroupRuleController.php @@ -0,0 +1,94 @@ +dataLists(new UserGroupRuleLists()); + } + + + /** + * @notes 添加分组规则 + * @return \think\response\Json + * @author BD + * @date 2024/04/25 01:30 + */ + public function add() + { + $params = (new UserGroupRuleValidate())->post()->goCheck('add'); + $result = UserGroupRuleLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserGroupRuleLogic::getError()); + } + + + /** + * @notes 编辑分组规则 + * @return \think\response\Json + * @author BD + * @date 2024/04/25 01:30 + */ + public function edit() + { + $params = (new UserGroupRuleValidate())->post()->goCheck('edit'); + $result = UserGroupRuleLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserGroupRuleLogic::getError()); + } + + + /** + * @notes 删除分组规则 + * @return \think\response\Json + * @author BD + * @date 2024/04/25 01:30 + */ + public function delete() + { + $params = (new UserGroupRuleValidate())->post()->goCheck('delete'); + UserGroupRuleLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取分组规则详情 + * @return \think\response\Json + * @author BD + * @date 2024/04/25 01:30 + */ + public function detail() + { + $params = (new UserGroupRuleValidate())->goCheck('detail'); + $result = UserGroupRuleLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserInfoController.php b/app/adminapi/controller/user/UserInfoController.php new file mode 100644 index 0000000..a67c60f --- /dev/null +++ b/app/adminapi/controller/user/UserInfoController.php @@ -0,0 +1,62 @@ +dataLists(new UserInfoLists()); + } + + /** + * @notes 同意实名 + * @return \think\response\Json + * @author BD + * @date 2024/06/08 17:51 + */ + public function agree() + { + $params = $this->request->post(); + $result = UserInfoLogic::agree($params); + if (true === $result) { + return $this->success('同意成功', [], 1, 1); + } + return $this->fail(UserInfoLogic::getError()); + } + + /** + * @notes 拒绝实名 + * @return \think\response\Json + * @author BD + * @date 2024/06/08 17:51 + */ + public function refuse() + { + $params = $this->request->post(); + $result = UserInfoLogic::refuse($params); + if (true === $result) { + return $this->success('拒绝成功', [], 1, 1); + } + return $this->fail(UserInfoLogic::getError()); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserKadanController.php b/app/adminapi/controller/user/UserKadanController.php new file mode 100644 index 0000000..ed7995b --- /dev/null +++ b/app/adminapi/controller/user/UserKadanController.php @@ -0,0 +1,94 @@ +dataLists(new UserKadanLists()); + } + + + /** + * @notes 添加卡单规则 + * @return \think\response\Json + * @author BD + * @date 2024/04/24 17:00 + */ + public function add() + { + $params = (new UserKadanValidate())->post()->goCheck('add'); + $result = UserKadanLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserKadanLogic::getError()); + } + + + /** + * @notes 编辑卡单规则 + * @return \think\response\Json + * @author BD + * @date 2024/04/24 17:00 + */ + public function edit() + { + $params = (new UserKadanValidate())->post()->goCheck('edit'); + $result = UserKadanLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserKadanLogic::getError()); + } + + + /** + * @notes 删除卡单规则 + * @return \think\response\Json + * @author BD + * @date 2024/04/24 17:00 + */ + public function delete() + { + $params = (new UserKadanValidate())->post()->goCheck('delete'); + UserKadanLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取卡单规则详情 + * @return \think\response\Json + * @author BD + * @date 2024/04/24 17:00 + */ + public function detail() + { + $params = (new UserKadanValidate())->goCheck('detail'); + $result = UserKadanLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserMineRecordController.php b/app/adminapi/controller/user/UserMineRecordController.php new file mode 100644 index 0000000..0f6ee31 --- /dev/null +++ b/app/adminapi/controller/user/UserMineRecordController.php @@ -0,0 +1,94 @@ +dataLists(new UserMineRecordLists()); + } + + + /** + * @notes 添加挖矿记录 + * @return \think\response\Json + * @author BD + * @date 2025/01/01 15:47 + */ + public function add() + { + $params = (new UserMineRecordValidate())->post()->goCheck('add'); + $result = UserMineRecordLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserMineRecordLogic::getError()); + } + + + /** + * @notes 编辑挖矿记录 + * @return \think\response\Json + * @author BD + * @date 2025/01/01 15:47 + */ + public function edit() + { + $params = (new UserMineRecordValidate())->post()->goCheck('edit'); + $result = UserMineRecordLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserMineRecordLogic::getError()); + } + + + /** + * @notes 删除挖矿记录 + * @return \think\response\Json + * @author BD + * @date 2025/01/01 15:47 + */ + public function delete() + { + $params = (new UserMineRecordValidate())->post()->goCheck('delete'); + UserMineRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取挖矿记录详情 + * @return \think\response\Json + * @author BD + * @date 2025/01/01 15:47 + */ + public function detail() + { + $params = (new UserMineRecordValidate())->goCheck('detail'); + $result = UserMineRecordLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserNoticeController.php b/app/adminapi/controller/user/UserNoticeController.php new file mode 100644 index 0000000..c462bd4 --- /dev/null +++ b/app/adminapi/controller/user/UserNoticeController.php @@ -0,0 +1,94 @@ +dataLists(new UserNoticeLists()); + } + + + /** + * @notes 添加用户消息 + * @return \think\response\Json + * @author BD + * @date 2024/05/26 00:36 + */ + public function add() + { + $params = (new UserNoticeValidate())->post()->goCheck('add'); + $result = UserNoticeLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserNoticeLogic::getError()); + } + + + /** + * @notes 编辑用户消息 + * @return \think\response\Json + * @author BD + * @date 2024/05/26 00:36 + */ + public function edit() + { + $params = (new UserNoticeValidate())->post()->goCheck('edit'); + $result = UserNoticeLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserNoticeLogic::getError()); + } + + + /** + * @notes 删除用户消息 + * @return \think\response\Json + * @author BD + * @date 2024/05/26 00:36 + */ + public function delete() + { + $params = (new UserNoticeValidate())->post()->goCheck('delete'); + UserNoticeLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取用户消息详情 + * @return \think\response\Json + * @author BD + * @date 2024/05/26 00:36 + */ + public function detail() + { + $params = (new UserNoticeValidate())->goCheck('detail'); + $result = UserNoticeLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserRelationController.php b/app/adminapi/controller/user/UserRelationController.php new file mode 100644 index 0000000..0fca218 --- /dev/null +++ b/app/adminapi/controller/user/UserRelationController.php @@ -0,0 +1,30 @@ +dataLists(new UserRelationLists()); + } +} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserTronController.php b/app/adminapi/controller/user/UserTronController.php new file mode 100644 index 0000000..a21849c --- /dev/null +++ b/app/adminapi/controller/user/UserTronController.php @@ -0,0 +1,150 @@ +dataLists(new UserTronLists()); + } + + + /** + * @notes 创建波场钱包 + * @return \think\response\Json + * @author BD + * @date 2024/05/04 23:38 + */ + public function add() + { + $result = UserTronLogic::add(); + if (true === $result) { + return $this->success('创建成功', [], 1, 1); + } + return $this->fail(UserTronLogic::getError()); + } + + + /** + * @notes 编辑波场钱包 + * @return \think\response\Json + * @author BD + * @date 2024/05/04 23:38 + */ + public function edit() + { + $params = (new UserTronValidate())->post()->goCheck('edit'); + $result = UserTronLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserTronLogic::getError()); + } + + + /** + * @notes 删除波场钱包 + * @return \think\response\Json + * @author BD + * @date 2024/05/04 23:38 + */ + public function delete() + { + $params = (new UserTronValidate())->post()->goCheck('delete'); + UserTronLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取波场钱包详情 + * @return \think\response\Json + * @author BD + * @date 2024/05/04 23:38 + */ + public function detail() + { + $params = (new UserTronValidate())->goCheck('detail'); + $result = UserTronLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 更新排序 + * @return \think\response\Json + * @author BD + * @date 2024/05/04 23:38 + */ + public function updateSort() + { + $params = $this->request->post(); + UserTronLogic::updateSort($params); + return $this->success('更新成功', [], 1, 1); + } + + /** + * @notes 更新金额 + * @return \think\response\Json + * @author BD + * @date 2024/05/04 23:38 + */ + public function updateMoney() + { + $params = $this->request->post(); + UserTronLogic::updateMoney($params); + return $this->success('更新成功', [], 1, 1); + } + + /** + * @notes 转账 + * @return \think\response\Json + * @author BD + * @date 2024/05/04 23:38 + */ + public function tran() + { + $params = (new UserTronValidate())->post()->goCheck('tran'); + $res = UserTronLogic::tran($params); + if (true === $res) { + return $this->success('转账成功', [], 1, 1); + } + return $this->fail($res); + } + + /** + * @notes 资金归集 + * @return \think\response\Json + * @author BD + * @date 2024/05/04 23:38 + */ + public function tranAll() + { + $params = (new UserTronValidate())->post()->goCheck('tranAll'); + $res = UserTronLogic::tranAll($params); + if (true === $res) { + return $this->success('归集完成', [], 1, 1); + } + return $this->fail($res); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/withdraw/WithdrawBankController.php b/app/adminapi/controller/withdraw/WithdrawBankController.php new file mode 100644 index 0000000..648f4de --- /dev/null +++ b/app/adminapi/controller/withdraw/WithdrawBankController.php @@ -0,0 +1,110 @@ +dataLists(new WithdrawBankLists()); + } + + + /** + * @notes 添加可提现银行 + * @return \think\response\Json + * @author BD + * @date 2024/02/25 12:19 + */ + public function add() + { + $params = (new WithdrawBankValidate())->post()->goCheck('add'); + $result = WithdrawBankLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(WithdrawBankLogic::getError()); + } + + + /** + * @notes 编辑可提现银行 + * @return \think\response\Json + * @author BD + * @date 2024/02/25 12:19 + */ + public function edit() + { + $params = (new WithdrawBankValidate())->post()->goCheck('edit'); + $result = WithdrawBankLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(WithdrawBankLogic::getError()); + } + + + /** + * @notes 删除可提现银行 + * @return \think\response\Json + * @author BD + * @date 2024/02/25 12:19 + */ + public function delete() + { + $params = (new WithdrawBankValidate())->post()->goCheck('delete'); + WithdrawBankLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取可提现银行详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/25 12:19 + */ + public function detail() + { + $params = (new WithdrawBankValidate())->goCheck('detail'); + $result = WithdrawBankLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 获取所有银行 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/25 12:19 + */ + public function allByLang() + { + $params = (new WithdrawBankValidate())->goCheck('allByLang'); + $result = WithdrawBankLogic::allByLang($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/withdraw/WithdrawMethodController.php b/app/adminapi/controller/withdraw/WithdrawMethodController.php new file mode 100644 index 0000000..1519b70 --- /dev/null +++ b/app/adminapi/controller/withdraw/WithdrawMethodController.php @@ -0,0 +1,108 @@ +dataLists(new WithdrawMethodLists()); + } + + + /** + * @notes 添加提现方式 + * @return \think\response\Json + * @author BD + * @date 2024/02/23 14:34 + */ + public function add() + { + $params = (new WithdrawMethodValidate())->post()->goCheck('add'); + $result = WithdrawMethodLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(WithdrawMethodLogic::getError()); + } + + + /** + * @notes 编辑提现方式 + * @return \think\response\Json + * @author BD + * @date 2024/02/23 14:34 + */ + public function edit() + { + $params = (new WithdrawMethodValidate())->post()->goCheck('edit'); + $result = WithdrawMethodLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(WithdrawMethodLogic::getError()); + } + + + /** + * @notes 删除提现方式 + * @return \think\response\Json + * @author BD + * @date 2024/02/23 14:34 + */ + public function delete() + { + $params = (new WithdrawMethodValidate())->post()->goCheck('delete'); + WithdrawMethodLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取提现方式详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/23 14:34 + */ + public function detail() + { + $params = (new WithdrawMethodValidate())->goCheck('detail'); + $result = WithdrawMethodLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 获取全部提现方式 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/23 14:34 + */ + public function all() + { + $result = WithdrawMethodLogic::getAllData(); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/adminapi/controller/withdraw/WithdrawWalletController.php b/app/adminapi/controller/withdraw/WithdrawWalletController.php new file mode 100644 index 0000000..647b0a0 --- /dev/null +++ b/app/adminapi/controller/withdraw/WithdrawWalletController.php @@ -0,0 +1,64 @@ +dataLists(new WithdrawWalletLists()); + } + + + /** + * @notes 编辑用户提现钱包 + * @return \think\response\Json + * @author BD + * @date 2024/02/26 13:32 + */ + public function edit() + { + $params = (new WithdrawWalletValidate())->post()->goCheck('edit'); + $result = WithdrawWalletLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(WithdrawWalletLogic::getError()); + } + + + /** + * @notes 删除用户提现钱包 + * @return \think\response\Json + * @author BD + * @date 2024/02/26 13:32 + */ + public function delete() + { + $params = (new WithdrawWalletValidate())->post()->goCheck('delete'); + WithdrawWalletLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + +} \ No newline at end of file diff --git a/app/adminapi/event.php b/app/adminapi/event.php new file mode 100644 index 0000000..02a6f2b --- /dev/null +++ b/app/adminapi/event.php @@ -0,0 +1,23 @@ + [ + 'AppInit' => [], + 'HttpRun' => [], + 'HttpEnd' => ['app\adminapi\listener\OperationLog'], + 'LogLevel' => [], + 'LogWrite' => [], + ] +]; \ No newline at end of file diff --git a/app/adminapi/http/middleware/AuthMiddleware.php b/app/adminapi/http/middleware/AuthMiddleware.php new file mode 100644 index 0000000..95df4b3 --- /dev/null +++ b/app/adminapi/http/middleware/AuthMiddleware.php @@ -0,0 +1,89 @@ +controllerObject->isNotNeedLogin()) { + return $next($request); + } + + //系统默认超级管理员,无需权限验证 + if (1 === $request->adminInfo['root']) { + return $next($request); + } + + $adminAuthCache = new AdminAuthCache($request->adminInfo['admin_id']); + + // 当前访问路径 + $accessUri = strtolower($request->controller() . '/' . $request->action()); + // 全部路由 + $allUri = $this->formatUrl($adminAuthCache->getAllUri()); + + // 判断该当前访问的uri是否存在,不存在无需验证 + if (!in_array($accessUri, $allUri)) { + return $next($request); + } + + // 当前管理员拥有的路由权限 + $AdminUris = $adminAuthCache->getAdminUri() ?? []; + $AdminUris = $this->formatUrl($AdminUris); + + if (in_array($accessUri, $AdminUris)) { + return $next($request); + } + return JsonService::fail('权限不足,无法访问或操作'); + } + + + /** + * @notes 格式化URL + * @param array $data + * @return array|string[] + * @author 段誉 + * @date 2022/7/7 15:39 + */ + public function formatUrl(array $data) + { + return array_map(function ($item) { + return strtolower(Str::camel($item)); + }, $data); + } + +} \ No newline at end of file diff --git a/app/adminapi/http/middleware/CheckDemoMiddleware.php b/app/adminapi/http/middleware/CheckDemoMiddleware.php new file mode 100644 index 0000000..e6f652c --- /dev/null +++ b/app/adminapi/http/middleware/CheckDemoMiddleware.php @@ -0,0 +1,50 @@ +method() != 'POST') { + return $next($request); + } + + $accessUri = strtolower($request->controller() . '/' . $request->action()); + if (!in_array($accessUri, $this->ablePost) && env('project.demo_env')) { + return JsonService::fail('演示环境不支持修改数据,请下载源码本地部署体验'); + } + + return $next($request); + } + +} \ No newline at end of file diff --git a/app/adminapi/http/middleware/EncryDemoDataMiddleware.php b/app/adminapi/http/middleware/EncryDemoDataMiddleware.php new file mode 100644 index 0000000..96c626e --- /dev/null +++ b/app/adminapi/http/middleware/EncryDemoDataMiddleware.php @@ -0,0 +1,114 @@ +controller() . '/' . $request->action()); + if (!in_array($accessUri, lower_uri($this->needCheck)) || !env('project.demo_env')) { + return $response; + } + + // 非json数据 + if (!method_exists($response, 'header') || !in_array('application/json; charset=utf-8', $response->getHeader())) { + return $response; + } + + $data = $response->getData(); + if (!is_array($data) || empty($data)) { + return $response; + } + + foreach ($data['data'] as $key => $item) { + // 字符串 + if (is_string($item)) { + $data['data'][$key] = $this->getEncryData($key, $item); + continue; + } + // 数组 + if (is_array($item)) { + foreach ($item as $itemKey => $itemValue) { + $data['data'][$key][$itemKey] = $this->getEncryData($itemKey, $itemValue); + } + } + } + + return $response->data($data); + } + + + /** + * @notes 加密配置 + * @param $key + * @param $value + * @return mixed|string + * @author 段誉 + * @date 2023/3/6 11:49 + */ + protected function getEncryData($key, $value) + { + // 非隐藏字段 + if (in_array($key, $this->excludeParams)) { + return $value; + } + + // 隐藏字段 + if (is_string($value)) { + return '******'; + } + return $value; + } + +} \ No newline at end of file diff --git a/app/adminapi/http/middleware/InitMiddleware.php b/app/adminapi/http/middleware/InitMiddleware.php new file mode 100644 index 0000000..a4cf6d1 --- /dev/null +++ b/app/adminapi/http/middleware/InitMiddleware.php @@ -0,0 +1,57 @@ +controller()); + $controller = '\\app\\adminapi\\controller\\' . $controller . 'Controller'; + $controllerClass = invoke($controller); + if (($controllerClass instanceof BaseAdminController) === false) { + throw new ControllerExtendException($controller, '404'); + } + } catch (ClassNotFoundException $e) { + throw new HttpException(404, 'controller not exists:' . $e->getClass()); + } + + //创建控制器对象 + $request->controllerObject = invoke($controller); + + return $next($request); + } +} \ No newline at end of file diff --git a/app/adminapi/http/middleware/LoginMiddleware.php b/app/adminapi/http/middleware/LoginMiddleware.php new file mode 100644 index 0000000..0a09cef --- /dev/null +++ b/app/adminapi/http/middleware/LoginMiddleware.php @@ -0,0 +1,78 @@ +header('token'); + //判断接口是否免登录 + $isNotNeedLogin = $request->controllerObject->isNotNeedLogin(); + + //不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问 + if (empty($token) && !$isNotNeedLogin) { + //没有token并且该地址需要登录才能访问 + return JsonService::fail('请求参数缺token', [], 0, 0); + } + + $adminInfo = (new AdminTokenCache())->getAdminInfo($token); + if (empty($adminInfo) && !$isNotNeedLogin) { + //token过期无效并且该地址需要登录才能访问 + return JsonService::fail('登录超时,请重新登录', [], -1); + } + + //token临近过期,自动续期 + if ($adminInfo) { + //获取临近过期自动续期时长 + $beExpireDuration = Config::get('project.admin_token.be_expire_duration'); + //token续期 + if (time() > ($adminInfo['expire_time'] - $beExpireDuration)) { + $result = AdminTokenService::overtimeToken($token); + //续期失败(数据表被删除导致) + if (empty($result)) { + return JsonService::fail('登录过期', [], -1); + } + } + } + + //给request赋值,用于控制器 + $request->adminInfo = $adminInfo; + $request->adminId = $adminInfo['admin_id'] ?? 0; + + return $next($request); + } + +} \ No newline at end of file diff --git a/app/adminapi/listener/OperationLog.php b/app/adminapi/listener/OperationLog.php new file mode 100644 index 0000000..9649cce --- /dev/null +++ b/app/adminapi/listener/OperationLog.php @@ -0,0 +1,89 @@ +isGet() ? 1 : 2; + $log_way = ConfigService::get('website', 'log_way'); + if (!in_array($request_type, $log_way)) { + return; + } + + //需要登录的接口,无效访问时不记录 + if (!$request->controllerObject->isNotNeedLogin() && empty($request->adminInfo)) { + return; + } + + //不记录日志操作 + if (strtolower(str_replace('.', '\\', $request->controller())) === 'setting\system\log') { + return; + } + + //获取操作注解 + $notes = ''; + try { + $re = new ReflectionClass($request->controllerObject); + $doc = $re->getMethod($request->action())->getDocComment(); + if (empty($doc)) { + throw new Exception('请给控制器方法注释'); + } + preg_match('/\s(\w+)/u', $re->getMethod($request->action())->getDocComment(), $values); + $notes = $values[0]; + } catch (Exception $e) { + $notes = $notes ?: '无法获取操作名称,请给控制器方法注释'; + } + + $params = $request->param(); + + //过滤密码参数 + if (isset($params['password'])) { + $params['password'] = "******"; + } + //过滤密码参数 + if (isset($params['password_pay'])) { + $params['password_pay'] = "******"; + } + //过滤密钥参数 + if(isset($params['app_secret'])){ + $params['app_secret'] = "******"; + } + + //导出数据操作进行记录 + if (isset($params['export']) && $params['export'] == 2) { + $notes .= '-数据导出'; + } + + //记录日志 + $systemLog = new \app\common\model\OperationLog(); + $systemLog->admin_id = $request->adminInfo['admin_id'] ?? 0; + $systemLog->admin_name = $request->adminInfo['name'] ?? ''; + $systemLog->action = $notes; + $systemLog->account = $request->adminInfo['account'] ?? ''; + $systemLog->url = $request->url(true); + $systemLog->type = $request->isGet() ? 'GET' : 'POST'; + $systemLog->params = json_encode($params, true); + $systemLog->ip = $request->ip(); + $systemLog->result = $response->getContent(); + return $systemLog->save(); + } +} \ No newline at end of file diff --git a/app/adminapi/lists/BaseAdminDataLists.php b/app/adminapi/lists/BaseAdminDataLists.php new file mode 100644 index 0000000..bf5b1b0 --- /dev/null +++ b/app/adminapi/lists/BaseAdminDataLists.php @@ -0,0 +1,39 @@ +adminInfo = $this->request->adminInfo; + $this->adminId = $this->request->adminId; + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/article/ArticleCateLists.php b/app/adminapi/lists/article/ArticleCateLists.php new file mode 100644 index 0000000..d6907a1 --- /dev/null +++ b/app/adminapi/lists/article/ArticleCateLists.php @@ -0,0 +1,98 @@ + 'create_time', 'id' => 'id']; + } + + /** + * @notes 设置默认排序 + * @return array + * @author heshihu + * @date 2022/2/9 15:08 + */ + public function setDefaultOrder(): array + { + return ['sort' => 'desc','id' => 'desc']; + } + + /** + * @notes 获取管理列表 + * @return array + * @author heshihu + * @date 2022/2/21 17:11 + */ + public function lists(): array + { + $ArticleCateLists = ArticleCate::where($this->searchWhere) + ->append(['is_show_desc']) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->append(['article_count']) + ->select() + ->toArray(); + + return $ArticleCateLists; + } + + /** + * @notes 获取数量 + * @return int + * @author heshihu + * @date 2022/2/9 15:12 + */ + public function count(): int + { + return ArticleCate::where($this->searchWhere)->count(); + } + + public function extend() + { + return []; + } +} \ No newline at end of file diff --git a/app/adminapi/lists/article/ArticleLists.php b/app/adminapi/lists/article/ArticleLists.php new file mode 100644 index 0000000..9c91a17 --- /dev/null +++ b/app/adminapi/lists/article/ArticleLists.php @@ -0,0 +1,99 @@ + ['title'], + '=' => ['cid', 'is_show'] + ]; + } + + /** + * @notes 设置支持排序字段 + * @return array + * @author heshihu + * @date 2022/2/9 15:11 + */ + public function setSortFields(): array + { + return ['create_time' => 'create_time', 'id' => 'id']; + } + + /** + * @notes 设置默认排序 + * @return array + * @author heshihu + * @date 2022/2/9 15:08 + */ + public function setDefaultOrder(): array + { + return ['sort' => 'desc', 'id' => 'desc']; + } + + /** + * @notes 获取管理列表 + * @return array + * @author heshihu + * @date 2022/2/21 17:11 + */ + public function lists(): array + { + $ArticleLists = Article::where($this->searchWhere) + ->append(['cate_name', 'click']) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select() + ->toArray(); + + return $ArticleLists; + } + + /** + * @notes 获取数量 + * @return int + * @author heshihu + * @date 2022/2/9 15:12 + */ + public function count(): int + { + return Article::where($this->searchWhere)->count(); + } + + public function extend() + { + return []; + } +} \ No newline at end of file diff --git a/app/adminapi/lists/auth/AdminLists.php b/app/adminapi/lists/auth/AdminLists.php new file mode 100644 index 0000000..64a764f --- /dev/null +++ b/app/adminapi/lists/auth/AdminLists.php @@ -0,0 +1,208 @@ + '账号', + 'name' => '名称', + 'role_name' => '角色', + 'dept_name' => '部门', + 'create_time' => '创建时间', + 'login_time' => '最近登录时间', + 'login_ip' => '最近登录IP', + 'disable_desc' => '状态', + ]; + } + + + /** + * @notes 设置导出文件名 + * @return string + * @author 段誉 + * @date 2021/12/29 10:08 + */ + public function setFileName(): string + { + return '管理员列表'; + } + + + /** + * @notes 设置搜索条件 + * @return \string[][] + * @author 段誉 + * @date 2021/12/29 10:07 + */ + public function setSearch(): array + { + return [ + '%like%' => ['name', 'account'], + ]; + } + + + /** + * @notes 设置支持排序字段 + * @return string[] + * @author 段誉 + * @date 2021/12/29 10:07 + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return ['create_time' => 'create_time', 'id' => 'id']; + } + + + /** + * @notes 设置默认排序 + * @return string[] + * @author 段誉 + * @date 2021/12/29 10:06 + */ + public function setDefaultOrder(): array + { + return ['id' => 'desc']; + } + + /** + * @notes 查询条件 + * @return array + * @author 段誉 + * @date 2022/11/29 11:33 + */ + public function queryWhere() + { + $where = []; + if (isset($this->params['role_id']) && $this->params['role_id'] != '') { + $adminIds = AdminRole::where('role_id', $this->params['role_id'])->column('admin_id'); + if (!empty($adminIds)) { + $where[] = ['id', 'in', $adminIds]; + } + } + return $where; + } + + + /** + * @notes 获取管理列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2021/12/29 10:05 + */ + public function lists(): array + { + $field = [ + 'id', 'name', 'account', 'create_time', 'disable', 'root', 'google_key', 'google_qrcode', + 'login_time', 'login_ip', 'multipoint_login', 'avatar' + ]; + + $adminLists = Admin::field($field) + ->where(['is_agent' => 0]) + ->where($this->searchWhere) + ->where($this->queryWhere()) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->append(['role_id', 'dept_id', 'jobs_id', 'disable_desc']) + ->select() + ->toArray(); + + // 角色数组('角色id'=>'角色名称') + $roleLists = SystemRole::column('name', 'id'); + // 部门列表 + $deptLists = Dept::column('name', 'id'); + // 岗位列表 + $jobsLists = Jobs::column('name', 'id'); + + //管理员列表增加角色名称 + foreach ($adminLists as $k => $v) { + $roleName = ''; + if ($v['root'] == 1) { + $roleName = '系统管理员'; + } else { + foreach ($v['role_id'] as $roleId) { + $roleName .= $roleLists[$roleId] ?? ''; + $roleName .= '/'; + } + } + + $deptName = ''; + foreach ($v['dept_id'] as $deptId) { + $deptName .= $deptLists[$deptId] ?? ''; + $deptName .= '/'; + } + + $jobsName = ''; + foreach ($v['jobs_id'] as $jobsId) { + $jobsName .= $jobsLists[$jobsId] ?? ''; + $jobsName .= '/'; + } + + $adminLists[$k]['role_name'] = trim($roleName, '/'); + $adminLists[$k]['dept_name'] = trim($deptName, '/'); + $adminLists[$k]['jobs_name'] = trim($jobsName, '/'); + } + + return $adminLists; + } + + /** + * @notes 获取数量 + * @return int + * @author 令狐冲 + * @date 2021/7/13 00:52 + */ + public function count(): int + { + return Admin::where(['is_agent' => 0]) + ->where($this->searchWhere) + ->where($this->queryWhere()) + ->count(); + } + + public function extend() + { + return []; + } +} \ No newline at end of file diff --git a/app/adminapi/lists/auth/MenuLists.php b/app/adminapi/lists/auth/MenuLists.php new file mode 100644 index 0000000..d622e5a --- /dev/null +++ b/app/adminapi/lists/auth/MenuLists.php @@ -0,0 +1,58 @@ + 'desc', 'id' => 'asc']) + ->select() + ->toArray(); + return linear_to_tree($lists, 'children'); + } + + + /** + * @notes 获取菜单数量 + * @return int + * @author 段誉 + * @date 2022/6/29 16:41 + */ + public function count(): int + { + return SystemMenu::count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/auth/RoleLists.php b/app/adminapi/lists/auth/RoleLists.php new file mode 100644 index 0000000..34dbba6 --- /dev/null +++ b/app/adminapi/lists/auth/RoleLists.php @@ -0,0 +1,94 @@ + '角色名称', + 'desc' => '备注', + 'create_time' => '创建时间' + ]; + } + + /** + * @notes 导出表名 + * @return string + * @author Tab + * @date 2021/9/22 18:52 + */ + public function setFileName(): string + { + return '角色表'; + } + + /** + * @notes 角色列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author cjhao + * @date 2021/8/25 18:00 + */ + public function lists(): array + { + $lists = SystemRole::with(['role_menu_index']) + ->field('id,name,desc,sort,create_time') + ->where("id <> 6") + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + foreach ($lists as $key => $role) { + //使用角色的人数 + $lists[$key]['num'] = AdminRole::where('role_id', $role['id'])->count(); + $menuId = array_column($role['role_menu_index'], 'menu_id'); + $lists[$key]['menu_id'] = $menuId; + unset($lists[$key]['role_menu_index']); + } + + return $lists; + } + + /** + * @notes 总记录数 + * @return int + * @author Tab + * @date 2021/7/13 11:26 + */ + public function count(): int + { + return SystemRole::where("id <> 6")->count(); + } +} \ No newline at end of file diff --git a/app/adminapi/lists/crontab/CrontabLists.php b/app/adminapi/lists/crontab/CrontabLists.php new file mode 100644 index 0000000..5c5c8f1 --- /dev/null +++ b/app/adminapi/lists/crontab/CrontabLists.php @@ -0,0 +1,61 @@ +limit($this->limitOffset, $this->limitLength) + ->order('id', 'desc') + ->select() + ->toArray(); + + return $lists; + } + + + /** + * @notes 定时任务数量 + * @return int + * @author 段誉 + * @date 2022/3/29 14:38 + */ + public function count(): int + { + return Crontab::count(); + } +} \ No newline at end of file diff --git a/app/adminapi/lists/decorate/DecorateHintLists.php b/app/adminapi/lists/decorate/DecorateHintLists.php new file mode 100644 index 0000000..285e0f0 --- /dev/null +++ b/app/adminapi/lists/decorate/DecorateHintLists.php @@ -0,0 +1,95 @@ +searchWhere) + ->field(['id', 'cid', 'title', 'text', 'content', 'is_show', 'sort', 'image', 'contract_y_logo', 'contract_b_logo', 'langs', 'create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc','cid' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + foreach ($items as &$item) { + $item['langs'] = json_decode($item['langs'], JSON_UNESCAPED_UNICODE); + foreach ($item['langs'] as &$content_lang) { + if(isset($content_lang['image'])){ + $content_lang['image'] = FileService::getFileUrl($content_lang['image']); + } + + $content_lang['content'] = get_file_domain($content_lang['content']); + } + + if($item['id'] == 23){ + $item['contract_y_logo'] = FileService::getFileUrl($item['contract_y_logo']); + $item['contract_b_logo'] = FileService::getFileUrl($item['contract_b_logo']); + } + } + + return $items; + } + + + /** + * @notes 获取提示内容数量 + * @return int + * @author BD + * @date 2024/03/17 17:01 + */ + public function count(): int + { + return DecorateHint::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/decorate/DecorateNavLists.php b/app/adminapi/lists/decorate/DecorateNavLists.php new file mode 100644 index 0000000..05b2b74 --- /dev/null +++ b/app/adminapi/lists/decorate/DecorateNavLists.php @@ -0,0 +1,83 @@ +searchWhere) + ->field(['id', 'name', 'image', 'image_ext', 'link', 'loca', 'is_show', 'sort', 'langs']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + foreach ($items as &$item) { + $item['langs'] = json_decode($item['langs'], JSON_UNESCAPED_UNICODE); + } + + return $items; + } + + + /** + * @notes 获取菜单按钮数量 + * @return int + * @author BD + * @date 2024/03/17 16:41 + */ + public function count(): int + { + return DecorateNav::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/decorate/DecorateSwiperLists.php b/app/adminapi/lists/decorate/DecorateSwiperLists.php new file mode 100644 index 0000000..cf3f6d0 --- /dev/null +++ b/app/adminapi/lists/decorate/DecorateSwiperLists.php @@ -0,0 +1,88 @@ +searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + foreach ($DecorateSwipers as &$item) { + $item['langs'] = json_decode($item['langs'], JSON_UNESCAPED_UNICODE); + + foreach ($item['langs'] as &$content_lang) { + $content_lang['image'] = FileService::getFileUrl($content_lang['image']); + // if(!isset($content_lang['image_ext'])) $content_lang['image_ext'] = ''; + } + } + + return $DecorateSwipers; + } + + + /** + * @notes 获取轮播图数量 + * @return int + * @author BD + * @date 2024/03/16 17:34 + */ + public function count(): int + { + return DecorateSwiper::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/dept/JobsLists.php b/app/adminapi/lists/dept/JobsLists.php new file mode 100644 index 0000000..c33533d --- /dev/null +++ b/app/adminapi/lists/dept/JobsLists.php @@ -0,0 +1,105 @@ + ['name'], + '=' => ['code', 'status'] + ]; + } + + + /** + * @notes 获取管理列表 + * @return array + * @author heshihu + * @date 2022/2/21 17:11 + */ + public function lists(): array + { + $lists = Jobs::where($this->searchWhere) + ->append(['status_desc']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + return $lists; + } + + + /** + * @notes 获取数量 + * @return int + * @author 段誉 + * @date 2022/5/26 9:48 + */ + public function count(): int + { + return Jobs::where($this->searchWhere)->count(); + } + + + /** + * @notes 导出文件名 + * @return string + * @author 段誉 + * @date 2022/11/24 16:17 + */ + public function setFileName(): string + { + return '岗位列表'; + } + + + /** + * @notes 导出字段 + * @return string[] + * @author 段誉 + * @date 2022/11/24 16:17 + */ + public function setExcelFields(): array + { + return [ + 'code' => '岗位编码', + 'name' => '岗位名称', + 'remark' => '备注', + 'status_desc' => '状态', + 'create_time' => '添加时间', + ]; + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/feedback/FeedbackCateLists.php b/app/adminapi/lists/feedback/FeedbackCateLists.php new file mode 100644 index 0000000..afeae77 --- /dev/null +++ b/app/adminapi/lists/feedback/FeedbackCateLists.php @@ -0,0 +1,70 @@ + ['name', 'sort', 'is_show'], + ]; + } + + + /** + * @notes 获取意见反馈类型列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/06/06 00:12 + */ + public function lists(): array + { + $cates = FeedbackCate::where($this->searchWhere) + ->field(['id', 'name', 'sort', 'is_show', 'langs']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + foreach ($cates as $k => $v) { + $cates[$k]['langs'] = json_decode($v['langs'], JSON_UNESCAPED_UNICODE); + } + + return $cates; + } + + + /** + * @notes 获取意见反馈类型数量 + * @return int + * @author BD + * @date 2024/06/06 00:12 + */ + public function count(): int + { + return FeedbackCate::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/feedback/FeedbackRecordLists.php b/app/adminapi/lists/feedback/FeedbackRecordLists.php new file mode 100644 index 0000000..387d0bb --- /dev/null +++ b/app/adminapi/lists/feedback/FeedbackRecordLists.php @@ -0,0 +1,74 @@ +field($field) + ->join('user u', 'u.id = fr.user_id') + ->append(['cate_name']) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取意见反馈记录数量 + * @return int + * @author BD + * @date 2024/06/06 01:11 + */ + public function count(): int + { + + return FeedbackRecord::alias('fr') + ->join('user u', 'u.id = fr.user_id') + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/file/FileCateLists.php b/app/adminapi/lists/file/FileCateLists.php new file mode 100644 index 0000000..df73b03 --- /dev/null +++ b/app/adminapi/lists/file/FileCateLists.php @@ -0,0 +1,73 @@ + ['type'] + ]; + } + + + /** + * @notes 获取文件分类列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2021/12/29 14:24 + */ + public function lists(): array + { + $lists = (new FileCate())->field(['id,pid,type,name']) + ->where($this->searchWhere) + ->select()->toArray(); + + return linear_to_tree($lists, 'children'); + } + + + /** + * @notes 获取文件分类数量 + * @return int + * @author 段誉 + * @date 2021/12/29 14:24 + */ + public function count(): int + { + return (new FileCate())->where($this->searchWhere)->count(); + } +} \ No newline at end of file diff --git a/app/adminapi/lists/file/FileLists.php b/app/adminapi/lists/file/FileLists.php new file mode 100644 index 0000000..31d0c96 --- /dev/null +++ b/app/adminapi/lists/file/FileLists.php @@ -0,0 +1,86 @@ + ['type', 'cid'], + '%like%' => ['name'] + ]; + } + + + /** + * @notes 获取文件列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2021/12/29 14:27 + */ + public function lists(): array + { + $lists = (new File())->field(['id,cid,type,name,uri,create_time']) + ->order('id', 'desc') + ->where($this->searchWhere) + ->where('source', FileEnum::SOURCE_ADMIN) + ->limit($this->limitOffset, $this->limitLength) + ->select() + ->toArray(); + + foreach ($lists as &$item) { + $item['url'] = $item['uri']; + $item['uri'] = FileService::getFileUrl($item['uri']); + } + + return $lists; + } + + + /** + * @notes 获取文件数量 + * @return int + * @author 段誉 + * @date 2021/12/29 14:29 + */ + public function count(): int + { + return (new File())->where($this->searchWhere) + ->where('source', FileEnum::SOURCE_ADMIN) + ->count(); + } +} \ No newline at end of file diff --git a/app/adminapi/lists/finance/AgentRechargeRecordLists.php b/app/adminapi/lists/finance/AgentRechargeRecordLists.php new file mode 100644 index 0000000..21ebd0e --- /dev/null +++ b/app/adminapi/lists/finance/AgentRechargeRecordLists.php @@ -0,0 +1,276 @@ + [ 'rr.sn', 'rr.method_id', 'rr.status'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 用户编号 + if (!empty($this->params['u_sn'])) { + $where[] = ['u.sn', '=', $this->params['u_sn']]; + } + + // 所在代数 + if (!empty($this->params['level'])) { + $where[] = ['ur.level', '=', $this->params['level']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['rr.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取充值记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author bd + * @date 2024/01/31 14:07 + */ + public function lists(): array + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND rr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND rr.amount <= $money_max "; + } + + $field = 'rr.id,rr.sn,rr.user_id,rr.method_id,rr.amount,rr.amount_act,rr.account as method_account,rr.voucher,rr.rate,rr.symbol,rr.status,rr.user_money,rr.remark,rr.remark2,rr.create_time,rr.update_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile,u.country_code,u.recharge_num,u.withdraw_num'; + $field .= ',ur.level'; + + + return RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join('user_relation_agent ur', 'rr.user_id = ur.user_id') + ->field($field) + ->append(['method','status_text','team_top']) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['rr.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取充值记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND rr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND rr.amount <= $money_max "; + } + + return RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join('user_relation_agent ur', 'rr.user_id = ur.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + + public function extend(): array + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND rr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND rr.amount <= $money_max "; + } + + $total = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join('user_relation_agent ur', 'rr.user_id = ur.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + $ing = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join('user_relation_agent ur', 'rr.user_id = ur.user_id') + ->where($where) + ->where(['status' => 0]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + $success = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join('user_relation_agent ur', 'rr.user_id = ur.user_id') + ->where($where) + ->where(['status' => 1]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + + $success_count = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join('user_relation_agent ur', 'rr.user_id = ur.user_id') + ->where($where) + ->where(['status' => 1]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + + $error = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join('user_relation_agent ur', 'rr.user_id = ur.user_id') + ->where($where) + ->where(['status' => 2]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + + return [ + 'total' => round($total, 2), + 'ing' => round($ing, 2), + 'success' => round($success, 2), + 'success_count' => $success_count, + 'error' => round($error, 2), + ]; + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/finance/AgentUserFinanceLists.php b/app/adminapi/lists/finance/AgentUserFinanceLists.php new file mode 100644 index 0000000..b7b90ad --- /dev/null +++ b/app/adminapi/lists/finance/AgentUserFinanceLists.php @@ -0,0 +1,160 @@ + [ 'uf.sn', 'uf.change_type'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 所在代数 + if (!empty($this->params['level'])) { + $where[] = ['ur.level', '=', $this->params['level']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['uf.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取资金明细列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/07 13:10 + */ + public function lists(): array + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + $field = 'uf.id,uf.sn,uf.user_id,uf.change_type,uf.action,uf.change_amount,uf.left_amount,uf.source_sn,uf.remark,uf.create_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile,u.country_code'; + $field .= ',ur.level'; + + return UserFinance::alias('uf') + ->join('user u', 'u.id = uf.user_id') + ->join('user_relation_agent ur', 'uf.user_id = ur.user_id') + ->field($field) + ->append(['team_top']) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['uf.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取资金明细数量 + * @return int + * @author BD + * @date 2024/03/07 13:10 + */ + public function count(): int + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + return UserFinance::alias('uf') + ->join('user u', 'u.id = uf.user_id') + ->join('user_relation_agent ur', 'uf.user_id = ur.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/finance/AgentWithdrawRecordLists.php b/app/adminapi/lists/finance/AgentWithdrawRecordLists.php new file mode 100644 index 0000000..e1a8c80 --- /dev/null +++ b/app/adminapi/lists/finance/AgentWithdrawRecordLists.php @@ -0,0 +1,280 @@ + [ 'wr.sn', 'wr.method_id', 'wr.status'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 用户编号 + if (!empty($this->params['u_sn'])) { + $where[] = ['u.sn', '=', $this->params['u_sn']]; + } + + // 所在代数 + if (!empty($this->params['level'])) { + $where[] = ['ur.level', '=', $this->params['level']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['wr.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取提现记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/25 12:35 + */ + public function lists(): array + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND wr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND wr.amount <= $money_max "; + } + + $field = 'wr.id,wr.sn,wr.user_id,wr.method_id,wr.wallet_id,wr.amount,wr.amount_act,wr.rate,wr.symbol,wr.status,wr.status2,wr.charge,wr.remark,wr.user_money,wr.create_time,wr.update_time'; + + $field .= ',wr.type,wr.name,wr.bank_name,wr.account,wr.img'; + $field .= ',u.account as u_account,u.sn as u_sn,u.mobile,u.country_code,u.recharge_num,u.withdraw_num,u.remark2'; + $field .= ',ur.level'; + + $lists = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join('user_relation_agent ur', 'wr.user_id = ur.user_id') + ->field($field) + ->append(['method_name','status_text','act_amount','team_top']) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['wr.id' => 'desc']) + ->select() + ->toArray(); + + return $lists; + } + + + /** + * @notes 获取提现记录数量 + * @return int + * @author BD + * @date 2024/02/25 12:35 + */ + public function count(): int + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND wr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND wr.amount <= $money_max "; + } + + return WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join('user_relation_agent ur', 'wr.user_id = ur.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + + public function extend(): array + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND wr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND wr.amount <= $money_max "; + } + + $total = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join('user_relation_agent ur', 'wr.user_id = ur.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + $ing = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join('user_relation_agent ur', 'wr.user_id = ur.user_id') + ->where($where) + ->where(['status' => 0]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + $success = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join('user_relation_agent ur', 'wr.user_id = ur.user_id') + ->where($where) + ->where(['status' => 1]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + + $success_count = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join('user_relation_agent ur', 'wr.user_id = ur.user_id') + ->where($where) + ->where(['status' => 1]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + + $error = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join('user_relation_agent ur', 'wr.user_id = ur.user_id') + ->where($where) + ->where(['status' => 2]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + + return [ + 'total' => round($total, 2), + 'ing' => round($ing, 2), + 'success' => round($success, 2), + 'success_count' => $success_count, + 'error' => round($error, 2), + ]; + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/finance/RechargeRecordLists.php b/app/adminapi/lists/finance/RechargeRecordLists.php new file mode 100644 index 0000000..4bf10a4 --- /dev/null +++ b/app/adminapi/lists/finance/RechargeRecordLists.php @@ -0,0 +1,310 @@ + [ 'rr.sn', 'rr.method_id', 'rr.status'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 用户编号 + if (!empty($this->params['u_sn'])) { + $where[] = ['u.sn', '=', $this->params['u_sn']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['rr.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取充值记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author bd + * @date 2024/01/31 14:07 + */ + public function lists(): array + { + $where = " 1 = 1 "; + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND rr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND rr.amount <= $money_max "; + } + + $field = 'rr.id,rr.sn,rr.user_id,rr.method_id,rr.amount,rr.amount_act,rr.account as method_account,rr.voucher,rr.rate,rr.symbol,rr.status,rr.user_money,rr.remark,rr.remark2,rr.create_time,rr.update_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile,u.country_code,u.recharge_num,u.withdraw_num'; + + + $join_table = "user t"; + $join_require = 't.id = rr.user_id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'rr.user_id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + $field .= ',ur.level'; + } + + $lists = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join($join_table, $join_require) + ->field($field) + ->append(['method','status_text','team_top']) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['rr.id' => 'desc']) + ->select() + ->toArray(); + + foreach ($lists as &$item) { + if(isset($item['level']) && isset($item['team_top']['level'])){ + $item['team_top']['level'] = $item['level']; + } + } + + return $lists; + } + + + /** + * @notes 获取充值记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + $where = " 1 = 1 "; + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND rr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND rr.amount <= $money_max "; + } + + $join_table = "user t"; + $join_require = 't.id = rr.user_id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'rr.user_id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + } + + return RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + + public function extend(): array + { + $where = " 1 = 1 "; + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND rr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND rr.amount <= $money_max "; + } + + $join_table = "user t"; + $join_require = 't.id = rr.user_id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'rr.user_id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + } + + $total = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + $ing = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where(['status' => 0]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + $success = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where(['status' => 1]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + + $success_count = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where(['status' => 1]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + + $error = RechargeRecord::alias('rr') + ->join('user u', 'u.id = rr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where(['status' => 2]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + + return [ + 'total' => round($total, 2), + 'ing' => round($ing, 2), + 'success' => round($success, 2), + 'success_count' => $success_count, + 'error' => round($error, 2), + ]; + } + + /** + * @notes 导出文件名 + * @return string + * @author bd + * @date 2024/01/31 14:07 + */ + public function setFileName(): string + { + return '充值记录'; + } + + + /** + * @notes 导出字段 + * @return string[] + * @author bd + * @date 2024/01/31 14:07 + */ + public function setExcelFields(): array + { + return [ + 'account' => '用户账号', + 'sn' => '订单编号', + 'method_name' => '充值方式', + 'amount' => '充值金额', + 'status_text' => '状态', + 'create_time' => '下单时间', + ]; + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/finance/UserFinanceLists.php b/app/adminapi/lists/finance/UserFinanceLists.php new file mode 100644 index 0000000..80d9003 --- /dev/null +++ b/app/adminapi/lists/finance/UserFinanceLists.php @@ -0,0 +1,161 @@ + [ 'uf.sn', 'uf.frozen', 'uf.change_type'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['uf.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取资金明细列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/07 13:10 + */ + public function lists(): array + { + $field = 'uf.id,uf.sn,uf.user_id,uf.change_type,uf.action,uf.change_amount,uf.left_amount,uf.source_sn,uf.remark,uf.create_time,uf.thaw_time,uf.frozen'; + $field .= ',u.account,u.sn as u_sn,u.mobile,u.country_code'; + + $where = " 1 = 1 "; + $join_table = "user t"; + $join_require = 't.id = uf.user_id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'uf.user_id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + $field .= ',ur.level'; + } + + $lists = UserFinance::alias('uf') + ->join('user u', 'u.id = uf.user_id') + ->join($join_table, $join_require) + ->field($field) + ->append(['team_top']) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['uf.id' => 'desc']) + ->select() + ->toArray(); + + foreach ($lists as &$item) { + if(isset($item['level']) && isset($item['team_top']['level'])){ + $item['team_top']['level'] = $item['level']; + } + } + + return $lists; + } + + + /** + * @notes 获取资金明细数量 + * @return int + * @author BD + * @date 2024/03/07 13:10 + */ + public function count(): int + { + $where = " 1 = 1 "; + $join_table = "user t"; + $join_require = 't.id = uf.user_id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'uf.user_id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + } + + return UserFinance::alias('uf') + ->join('user u', 'u.id = uf.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/finance/WithdrawRecordLists.php b/app/adminapi/lists/finance/WithdrawRecordLists.php new file mode 100644 index 0000000..78ab098 --- /dev/null +++ b/app/adminapi/lists/finance/WithdrawRecordLists.php @@ -0,0 +1,313 @@ + [ 'wr.sn', 'wr.method_id', 'wr.status'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 用户编号 + if (!empty($this->params['u_sn'])) { + $where[] = ['u.sn', '=', $this->params['u_sn']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['wr.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取提现记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/25 12:35 + */ + public function lists(): array + { + $where = " 1 = 1 "; + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND wr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND wr.amount <= $money_max "; + } + + $field = 'wr.id,wr.sn,wr.user_id,wr.method_id,wr.wallet_id,wr.amount,wr.amount_act,wr.rate,wr.symbol,wr.status,wr.status2,wr.charge,wr.remark,wr.remark_df,wr.user_money,wr.create_time,wr.update_time'; + + $field .= ',wr.type,wr.name,wr.bank_name,wr.account,wr.img'; + $field .= ',u.account as u_account,u.sn as u_sn,u.mobile,u.country_code,u.recharge_num,u.withdraw_num,u.remark2'; + + $join_table = "user t"; + $join_require = 't.id = wr.user_id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'wr.user_id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + + $field .= ',ur.level'; + } + + $lists = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join($join_table, $join_require) + ->field($field) + ->append(['method_name','status_text','act_amount','team_top']) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['wr.id' => 'desc']) + ->select() + ->toArray(); + + foreach ($lists as &$item) { + if(isset($item['level']) && isset($item['team_top']['level'])){ + $item['team_top']['level'] = $item['level']; + } + } + return $lists; + } + + + /** + * @notes 获取提现记录数量 + * @return int + * @author BD + * @date 2024/02/25 12:35 + */ + public function count(): int + { + $where = " 1 = 1 "; + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND wr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND wr.amount <= $money_max "; + } + + $join_table = "user t"; + $join_require = 't.id = wr.user_id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'wr.user_id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + } + + return WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + + public function extend(): array + { + $where = " 1 = 1 "; + + // 金额范围 + if (!empty($this->params['money_min'])) { + $money_min = $this->params['money_min']; + $where .= " AND wr.amount >= $money_min "; + } + + // 金额范围 + if (!empty($this->params['money_max'])) { + $money_max = $this->params['money_max']; + $where .= " AND wr.amount <= $money_max "; + } + + $join_table = "user t"; + $join_require = 't.id = wr.user_id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'wr.user_id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + } + + $total = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + $ing = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where(['status' => 0]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + $success = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where(['status' => 1]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + + $success_count = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where(['status' => 1]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + + $error = WithdrawRecord::alias('wr') + ->join('user u', 'u.id = wr.user_id') + ->join($join_table, $join_require) + ->where($where) + ->where(['status' => 2]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + + return [ + 'total' => round($total, 2), + 'ing' => round($ing, 2), + 'success' => round($success, 2), + 'success_count' => $success_count, + 'error' => round($error, 2), + ]; + } + + /** + * @notes 导出文件名 + * @return string + * @author bd + * @date 2024/01/31 14:07 + */ + public function setFileName(): string + { + return '提现记录'; + } + + + /** + * @notes 导出字段 + * @return string[] + * @author bd + * @date 2024/01/31 14:07 + */ + public function setExcelFields(): array + { + return [ + 'account' => '用户账号', + 'sn' => '订单编号', + 'method_name' => '提现方式', + 'amount' => '提现金额', + 'charge' => '手续费', + 'status_text' => '状态', + 'create_time' => '下单时间', + ]; + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/goods/GoodsCateLists.php b/app/adminapi/lists/goods/GoodsCateLists.php new file mode 100644 index 0000000..e9a5846 --- /dev/null +++ b/app/adminapi/lists/goods/GoodsCateLists.php @@ -0,0 +1,83 @@ + ['name', 'is_show'], + ]; + } + + + /** + * @notes 获取商品分类列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/11 01:58 + */ + public function lists(): array + { + $cates = GoodsCate::where($this->searchWhere) + ->field(['id', 'name', 'sort', 'is_show', 'langs']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + + foreach ($cates as $k => $v) { + $cates[$k]['langs'] = json_decode($v['langs'], JSON_UNESCAPED_UNICODE); + } + + return $cates; + } + + + /** + * @notes 获取商品分类数量 + * @return int + * @author BD + * @date 2024/03/11 01:58 + */ + public function count(): int + { + return GoodsCate::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/goods/GoodsLists.php b/app/adminapi/lists/goods/GoodsLists.php new file mode 100644 index 0000000..018231c --- /dev/null +++ b/app/adminapi/lists/goods/GoodsLists.php @@ -0,0 +1,88 @@ + ['cid', 'title', 'is_show'], + ]; + } + + + /** + * @notes 获取商品列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/11 01:58 + */ + public function lists(): array + { + $goods = Goods::where($this->searchWhere) + ->append(['cate_name']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + + foreach ($goods as &$item) { + $item['num'] = 1; + $item['langs'] = json_decode($item['langs'], JSON_UNESCAPED_UNICODE); + // foreach ($item['langs'] as &$content_lang) { + // $content_lang['image'] = FileService::getFileUrl($content_lang['image']); + // } + } + + return $goods; + } + + + /** + * @notes 获取商品数量 + * @return int + * @author BD + * @date 2024/03/11 01:58 + */ + public function count(): int + { + return Goods::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/goods/GoodsRecordLists.php b/app/adminapi/lists/goods/GoodsRecordLists.php new file mode 100644 index 0000000..f0a8bb9 --- /dev/null +++ b/app/adminapi/lists/goods/GoodsRecordLists.php @@ -0,0 +1,108 @@ + ['gr.sn', 'gr.status', 'gr.type'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['gr.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取抢单记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/19 02:29 + */ + public function lists(): array + { + $field = 'gr.id,gr.sn,gr.user_id,gr.goods_title,gr.goods_image,gr.money,gr.commission,gr.status,gr.type,gr.create_time,gr.pay_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile'; + return GoodsRecord::alias('gr') + ->join('user u', 'u.id = gr.user_id') + ->field($field) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['gr.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取抢单记录数量 + * @return int + * @author BD + * @date 2024/03/19 02:29 + */ + public function count(): int + { + return GoodsRecord::alias('gr') + ->join('user u', 'u.id = gr.user_id') + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/item/ItemCateLists.php b/app/adminapi/lists/item/ItemCateLists.php new file mode 100644 index 0000000..8bff4ef --- /dev/null +++ b/app/adminapi/lists/item/ItemCateLists.php @@ -0,0 +1,83 @@ +searchWhere) + ->field(['id', 'name', 'sort', 'is_show', 'langs']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + + foreach ($itemCate as $k => $v) { + $itemCate[$k]['langs'] = json_decode($v['langs'], JSON_UNESCAPED_UNICODE); + } + + return $itemCate; + } + + + /** + * @notes 获取项目分类数量 + * @return int + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function count(): int + { + return ItemCate::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/item/ItemLists.php b/app/adminapi/lists/item/ItemLists.php new file mode 100644 index 0000000..ac38a7a --- /dev/null +++ b/app/adminapi/lists/item/ItemLists.php @@ -0,0 +1,90 @@ + ['type', 'is_show'], + '%like%' => ['title'], + ]; + } + + + /** + * @notes 获取项目列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/01/16 13:23 + */ + public function lists(): array + { + $items = Item::where($this->searchWhere) + ->append(['vip_name']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + + foreach ($items as &$item) { + $item['langs'] = json_decode($item['langs'], JSON_UNESCAPED_UNICODE); + foreach ($item['langs'] as &$content_lang) { + $content_lang['image'] = FileService::getFileUrl($content_lang['image']); + $content_lang['content'] = get_file_domain($content_lang['content']); + } + } + + return $items; + + } + + + /** + * @notes 获取项目数量 + * @return int + * @author BD + * @date 2024/01/16 13:23 + */ + public function count(): int + { + return Item::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/item/ItemRecordLists.php b/app/adminapi/lists/item/ItemRecordLists.php new file mode 100644 index 0000000..160c68f --- /dev/null +++ b/app/adminapi/lists/item/ItemRecordLists.php @@ -0,0 +1,101 @@ + ['ir.sn', 'ir.contract_no', 'ir.type', 'ir.status'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 下单时间 + if (!empty($this->params['start_time_create']) && !empty($this->params['end_time_create'])) { + $time = [strtotime($this->params['start_time_create']), strtotime($this->params['end_time_create'])]; + $where[] = ['ir.create_time', 'between', $time]; + } + + // 到期时间 + if (!empty($this->params['start_time_end']) && !empty($this->params['end_time_end'])) { + $time = [strtotime($this->params['start_time_end']), strtotime($this->params['end_time_end'])]; + $where[] = ['ir.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取项目记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/08/07 15:42 + */ + public function lists(): array + { + $field = 'ir.id,ir.sn,ir.contract_no,ir.user_id,ir.item_id,ir.item_title,ir.item_image,ir.item_langs,ir.money,ir.point,ir.rate,ir.cycle,ir.total_num,ir.wait_num,ir.total_income,ir.type,ir.status,ir.remark,ir.end_time,ir.create_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile'; + return ItemRecord::alias('ir') + ->join('user u', 'u.id = ir.user_id') + ->field($field) + ->append(['team_top']) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['ir.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取项目记录数量 + * @return int + * @author BD + * @date 2024/08/07 15:42 + */ + public function count(): int + { + return ItemRecord::alias('ir') + ->join('user u', 'u.id = ir.user_id') + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/lh/LhCoinLists.php b/app/adminapi/lists/lh/LhCoinLists.php new file mode 100644 index 0000000..bae6e02 --- /dev/null +++ b/app/adminapi/lists/lh/LhCoinLists.php @@ -0,0 +1,64 @@ +searchWhere) + ->field(['id', 'name', 'logo', 'symbol', 'symbol_market', 'price', 'buy_name', 'sale_name', 'is_show', 'sort']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取量化货币数量 + * @return int + * @author BD + * @date 2024/05/19 21:13 + */ + public function count(): int + { + return LhCoin::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/lh/LhRecordLists.php b/app/adminapi/lists/lh/LhRecordLists.php new file mode 100644 index 0000000..b228cbf --- /dev/null +++ b/app/adminapi/lists/lh/LhRecordLists.php @@ -0,0 +1,96 @@ + [ 'lr.sn', 'lr.coin_name'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['lr.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取量化记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/05/19 21:13 + */ + public function lists(): array + { + $field = 'lr.id,lr.sn,lr.user_id,lr.coin_name,lr.coin_logo,lr.coin_symbol,lr.coin_buy_name,lr.coin_sale_name,lr.money,lr.income,lr.money_buy,lr.money_sale,lr.create_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile'; + $record = LhRecord::alias('lr') + ->join('user u', 'u.id = lr.user_id') + ->field($field) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + return $record; + } + + + /** + * @notes 获取量化记录数量 + * @return int + * @author BD + * @date 2024/05/19 21:13 + */ + public function count(): int + { + return LhRecord::alias('lr') + ->join('user u', 'u.id = lr.user_id') + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/mall/MallGoodsLists.php b/app/adminapi/lists/mall/MallGoodsLists.php new file mode 100644 index 0000000..e82550f --- /dev/null +++ b/app/adminapi/lists/mall/MallGoodsLists.php @@ -0,0 +1,69 @@ + ['title', 'type', 'type2', 'is_show', 'create_time'], + ]; + } + + + /** + * @notes 获取积分、抽奖奖品列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/10/14 23:57 + */ + public function lists(): array + { + $items = MallGoods::where($this->searchWhere) + ->field(['id', 'title', 'image', 'price', 'content', 'money', 'point', 'win_rate', 'num', 'type', 'type2', 'is_show', 'sort', 'langs', 'create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['type' => 'desc','sort' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + foreach ($items as &$item) { + $item['langs'] = json_decode($item['langs'], JSON_UNESCAPED_UNICODE); + } + return $items; + } + + + /** + * @notes 获取积分、抽奖奖品数量 + * @return int + * @author BD + * @date 2024/10/14 23:57 + */ + public function count(): int + { + return MallGoods::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/mall/MallGoodsRecordLists.php b/app/adminapi/lists/mall/MallGoodsRecordLists.php new file mode 100644 index 0000000..65c339c --- /dev/null +++ b/app/adminapi/lists/mall/MallGoodsRecordLists.php @@ -0,0 +1,94 @@ + ['mgr.sn', 'mgr.type2', 'mgr.type'], + ]; + } + + /** + * @notes 搜索条件 + * @author BD + * @date 2024/03/19 02:29 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['mgr.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取奖品记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/10/15 14:00 + */ + public function lists(): array + { + $field = 'mgr.id,mgr.sn,mgr.user_id,mgr.m_goods_title,mgr.m_goods_image,mgr.price,mgr.type,mgr.type2,mgr.remark,mgr.create_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile'; + return MallGoodsRecord::alias('mgr') + ->join('user u', 'u.id = mgr.user_id') + ->field($field) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['mgr.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取奖品记录数量 + * @return int + * @author BD + * @date 2024/10/15 14:00 + */ + public function count(): int + { + return MallGoodsRecord::alias('mgr') + ->join('user u', 'u.id = mgr.user_id') + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/member/UserMemberLists.php b/app/adminapi/lists/member/UserMemberLists.php new file mode 100644 index 0000000..055bc72 --- /dev/null +++ b/app/adminapi/lists/member/UserMemberLists.php @@ -0,0 +1,82 @@ +searchWhere) + ->field(['id', 'name', 'logo', 'bg_img', 'text_color', 'money', 'level1_num', 'level1_vip_id', 'item_num', 'item_add_rate', 'mine_speed', 'is_show']) + ->append(['vip_name']) + // ->where(['is_show' => 1]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['money' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + return $member; + } + + + /** + * @notes 获取会员等级数量 + * @return int + * @author BD + * @date 2024/03/14 00:28 + */ + public function count(): int + { + return UserMember::where($this->searchWhere)->where(['is_show' => 1])->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/notice/NoticeSettingLists.php b/app/adminapi/lists/notice/NoticeSettingLists.php new file mode 100644 index 0000000..5d975d5 --- /dev/null +++ b/app/adminapi/lists/notice/NoticeSettingLists.php @@ -0,0 +1,71 @@ + ['recipient', 'type'] + ]; + } + + /** + * @notes 通知设置列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author ljj + * @date 2022/2/16 3:18 下午 + */ + public function lists(): array + { + $lists = (new NoticeSetting())->field('id,scene_name,sms_notice,type') + ->append(['sms_status_desc','type_desc']) + ->where($this->searchWhere) + ->select() + ->toArray(); + + return $lists; + } + + /** + * @notes 通知设置数量 + * @return int + * @author ljj + * @date 2022/2/16 3:18 下午 + */ + public function count(): int + { + return (new NoticeSetting())->where($this->searchWhere)->count(); + } +} \ No newline at end of file diff --git a/app/adminapi/lists/setting/LanguageLists.php b/app/adminapi/lists/setting/LanguageLists.php new file mode 100644 index 0000000..7ee0543 --- /dev/null +++ b/app/adminapi/lists/setting/LanguageLists.php @@ -0,0 +1,100 @@ + ['name', 'is_show'], + ]; + } + + /** + * @notes 设置支持排序字段 + * @return array + * @author heshihu + * @date 2022/2/9 15:11 + */ + public function setSortFields(): array + { + return ['create_time' => 'create_time', 'id' => 'id']; + } + + /** + * @notes 设置默认排序 + * @return array + * @author heshihu + * @date 2022/2/9 15:08 + */ + public function setDefaultOrder(): array + { + return ['sort' => 'desc', 'id' => 'desc']; + } + + + /** + * @notes 获取语言包列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public function lists(): array + { + return Language::where($this->searchWhere) + ->field(['id', 'name', 'name_loc','symbol','trans_symbol' , 'logo', 'precision', 'time_format', 'is_show', 'sort']) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select() + ->toArray(); + } + + + /** + * @notes 获取语言包数量 + * @return int + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public function count(): int + { + return Language::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/setting/LanguagePagLists.php b/app/adminapi/lists/setting/LanguagePagLists.php new file mode 100644 index 0000000..4049252 --- /dev/null +++ b/app/adminapi/lists/setting/LanguagePagLists.php @@ -0,0 +1,78 @@ + ['type', 'name', 'value','lang'], + ]; + } + + + /** + * @notes 获取语言包列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public function lists(): array + { + return LanguagePag::where($this->searchWhere) + ->field(['id', 'type', 'name', 'value','lang']) + ->append(['from_value']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['type' => 'asc','name' => 'asc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取语言包数量 + * @return int + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public function count(): int + { + return LanguagePag::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/setting/RechargeMethodLists.php b/app/adminapi/lists/setting/RechargeMethodLists.php new file mode 100644 index 0000000..61da843 --- /dev/null +++ b/app/adminapi/lists/setting/RechargeMethodLists.php @@ -0,0 +1,87 @@ + ['lang_id', 'type', 'name', 'is_show'], + ]; + } + + + /** + * @notes 设置支持排序字段 + * @return array + * @author BD + * @date 2022/2/9 15:11 + */ + public function setSortFields(): array + { + return ['create_time' => 'create_time', 'id' => 'id']; + } + + /** + * @notes 设置默认排序 + * @return array + * @author BD + * @date 2022/2/9 15:08 + */ + public function setDefaultOrder(): array + { + return ['sort' => 'desc', 'id' => 'desc']; + } + + + /** + * @notes 获取充值方式列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2023/11/30 15:22 + */ + public function lists(): array + { + return RechargeMethod::where($this->searchWhere) + ->append(['lang_name','vip_name']) + ->field(['id', 'lang_id', 'type', 'name', 'logo', 'account', 'img', 'bank_name', 'bank_username', 'main_coin_type', 'coin_type', 'protocol', 'address', 'member_id', 'avail_num', 'rate', 'symbol_rate','precision', 'symbol' ,'is_show' ,'is_voucher', 'sort']) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select() + ->toArray(); + } + + + /** + * @notes 获取充值方式数量 + * @return int + * @author BD + * @date 2023/11/30 15:22 + */ + public function count(): int + { + return RechargeMethod::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/setting/dict/DictDataLists.php b/app/adminapi/lists/setting/dict/DictDataLists.php new file mode 100644 index 0000000..0c6843d --- /dev/null +++ b/app/adminapi/lists/setting/dict/DictDataLists.php @@ -0,0 +1,76 @@ + ['name', 'type_value'], + '=' => ['status', 'type_id'] + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/6/20 16:35 + */ + public function lists(): array + { + return DictData::where($this->searchWhere) + ->append(['status_desc']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author 段誉 + * @date 2022/6/20 16:35 + */ + public function count(): int + { + return DictData::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/setting/dict/DictTypeLists.php b/app/adminapi/lists/setting/dict/DictTypeLists.php new file mode 100644 index 0000000..dbc13e9 --- /dev/null +++ b/app/adminapi/lists/setting/dict/DictTypeLists.php @@ -0,0 +1,76 @@ + ['name', 'type'], + '=' => ['status'] + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/6/20 15:54 + */ + public function lists(): array + { + return DictType::where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->append(['status_desc']) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author 段誉 + * @date 2022/6/20 15:54 + */ + public function count(): int + { + return DictType::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/setting/pay/PayConfigLists.php b/app/adminapi/lists/setting/pay/PayConfigLists.php new file mode 100644 index 0000000..6dcca67 --- /dev/null +++ b/app/adminapi/lists/setting/pay/PayConfigLists.php @@ -0,0 +1,62 @@ +append(['pay_way_name']) + ->order('sort','asc') + ->select() + ->toArray(); + + return $lists; + } + + + /** + * @notes 获取数量 + * @return int + * @author 段誉 + * @date 2023/2/23 16:15 + */ + public function count(): int + { + return PayConfig::count(); + } + + + +} \ No newline at end of file diff --git a/app/adminapi/lists/setting/system/LogLists.php b/app/adminapi/lists/setting/system/LogLists.php new file mode 100644 index 0000000..7257595 --- /dev/null +++ b/app/adminapi/lists/setting/system/LogLists.php @@ -0,0 +1,108 @@ + ['admin_name','url','ip','type'], + 'between_time' => 'create_time', + ]; + } + + /** + * @notes 查看系统日志列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author ljj + * @date 2021/8/3 4:21 下午 + */ + public function lists(): array + { + $lists = OperationLog::field('id,action,admin_name,admin_id,url,type,params,ip,create_time') + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order('id','desc') + ->select() + ->toArray(); + + return $lists; + } + + /** + * @notes 查看系统日志总数 + * @return int + * @author ljj + * @date 2021/8/3 4:23 下午 + */ + public function count(): int + { + return OperationLog::where($this->searchWhere)->count(); + } + + /** + * @notes 设置导出字段 + * @return string[] + * @author ljj + * @date 2021/8/3 4:48 下午 + */ + public function setExcelFields(): array + { + return [ + // '数据库字段名(支持别名) => 'Excel表字段名' + 'id' => '记录ID', + 'action' => '操作', + 'admin_name' => '管理员', + 'admin_id' => '管理员ID', + 'url' => '访问链接', + 'type' => '访问方式', + 'params' => '访问参数', + 'ip' => '来源IP', + 'create_time' => '日志时间', + ]; + } + + /** + * @notes 设置默认表名 + * @return string + * @author ljj + * @date 2021/8/3 4:48 下午 + */ + public function setFileName(): string + { + return '系统日志'; + } +} \ No newline at end of file diff --git a/app/adminapi/lists/tools/DataTableLists.php b/app/adminapi/lists/tools/DataTableLists.php new file mode 100644 index 0000000..d6ff732 --- /dev/null +++ b/app/adminapi/lists/tools/DataTableLists.php @@ -0,0 +1,74 @@ +params['name'])) { + $sql .= "AND name LIKE '%" . $this->params['name'] . "%'"; + } + if (!empty($this->params['comment'])) { + $sql .= "AND comment LIKE '%" . $this->params['comment'] . "%'"; + } + return Db::query($sql); + } + + + /** + * @notes 处理列表 + * @return array + * @author 段誉 + * @date 2022/6/13 18:54 + */ + public function lists(): array + { + $lists = array_map("array_change_key_case", $this->queryResult()); + $offset = max(0, ($this->pageNo - 1) * $this->pageSize); + $lists = array_slice($lists, $offset, $this->pageSize, true); + return array_values($lists); + } + + + /** + * @notes 获取数量 + * @return int + * @author 段誉 + * @date 2022/6/13 18:54 + */ + public function count(): int + { + return count($this->queryResult()); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/tools/GenerateTableLists.php b/app/adminapi/lists/tools/GenerateTableLists.php new file mode 100644 index 0000000..d9d1b46 --- /dev/null +++ b/app/adminapi/lists/tools/GenerateTableLists.php @@ -0,0 +1,75 @@ + ['table_name', 'table_comment'] + ]; + } + + + /** + * @notes 查询列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/6/14 10:55 + */ + public function lists(): array + { + return GenerateTable::where($this->searchWhere) + ->order(['id' => 'desc']) + ->append(['template_type_desc']) + ->limit($this->limitOffset, $this->limitLength) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author 段誉 + * @date 2022/6/14 10:55 + */ + public function count(): int + { + return GenerateTable::count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserAgentLists.php b/app/adminapi/lists/user/UserAgentLists.php new file mode 100644 index 0000000..bf68e20 --- /dev/null +++ b/app/adminapi/lists/user/UserAgentLists.php @@ -0,0 +1,299 @@ + ['u.sn','u.is_open','u.is_agent','u.country_code','u.register_ip','u.login_ip'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 会员等级 + if (!empty($this->params['member_id'])) { + $where[] = ['umr.member_id', '=', $this->params['member_id']]; + } + + // 邮箱地址 + if (!empty($this->params['email'])) { + $where[] = ['ui.email', '=', $this->params['email']]; + } + + // 邮箱认证 + if (!empty($this->params['auth_email'])) { + $where[] = ['ui.auth_email', '=', $this->params['auth_email']]; + } + + // 所在代数 + if (!empty($this->params['level'])) { + $where[] = ['ur.level', '=', $this->params['level']]; + } + + // 下单时间 + if (!empty($this->params['create_time_start']) && !empty($this->params['create_time_end'])) { + $time = [strtotime($this->params['create_time_start']), strtotime($this->params['create_time_end'])]; + $where[] = ['u.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取用户列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/22 15:50 + */ + public function lists(): array + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_min'])) { + $recharge_withdraw_min = $this->params['recharge_withdraw_min']; + $where .= " AND u.total_recharge - u.total_withdraw >= $recharge_withdraw_min "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_max'])) { + $recharge_withdraw_max = $this->params['recharge_withdraw_max']; + $where .= " AND u.total_recharge - u.total_withdraw <= $recharge_withdraw_max "; + } + + $field = "u.id,u.sn,u.nickname,u.sex,u.avatar,u.account,u.mobile,u.country_code,u.auto_member,u.is_lh,u.is_sn,u.is_open,u.is_agent,u.channel,u.user_money,u.user_point,u.total_recharge,u.total_withdraw,u.total_income,u.total_income_invest,u.total_invest,u.create_time,u.register_ip,u.register_isp,u.remark2,u.login_ip,u.login_time"; + $field .= ',ui.email,ui.auth_email'; + $field .= ',ur.level'; + + $lists = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join('user_relation_agent ur', 'u.id = ur.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->field($field) + ->append(['team_num','team_recharge','team_withdraw','item_num','today_item_num','vip_name','unused_money','team_report','agent_team_top','register_ip_num','login_ip_num','mine']) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order('u.id desc') + ->select() + ->toArray(); + + // foreach ($lists as &$item) { + // $item['total_recharge_ing'] = round(RechargeRecord::where(['status' => 0,'user_id' => $item['id']])->sum('amount'), 2); + // $item['total_withdraw_ing'] = round(WithdrawRecord::where(['status' => 0,'user_id' => $item['id']])->sum('amount'), 2); + // } + + return $lists; + } + + + /** + * @notes 获取数量 + * @return int + * @author 段誉 + * @date 2022/9/22 15:51 + */ + public function count(): int + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_min'])) { + $recharge_withdraw_min = $this->params['recharge_withdraw_min']; + $where .= " AND u.total_recharge - u.total_withdraw >= $recharge_withdraw_min "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_max'])) { + $recharge_withdraw_max = $this->params['recharge_withdraw_max']; + $where .= " AND u.total_recharge - u.total_withdraw <= $recharge_withdraw_max "; + } + + + return User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join('user_relation_agent ur', 'u.id = ur.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + + public function extend(): array + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $this->adminId])->findOrEmpty(); + + $where = " 1 = 1 "; + + if (!$user->isEmpty()) { + $top_id = $user['id']; + $parent_id = $user['id']; + //查询伞下用户 + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $userParent = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + if (!$userParent->isEmpty()){ + $parent_id = $userParent['id']; + } + } + $where .= " AND ur.top_id = $top_id AND ur.parent_id = $parent_id "; + }else{ + $where .= " AND 1 = 2 "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_min'])) { + $recharge_withdraw_min = $this->params['recharge_withdraw_min']; + $where .= " AND u.total_recharge - u.total_withdraw >= $recharge_withdraw_min "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_max'])) { + $recharge_withdraw_max = $this->params['recharge_withdraw_max']; + $where .= " AND u.total_recharge - u.total_withdraw <= $recharge_withdraw_max "; + } + + $total_recharge = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join('user_relation_agent ur', 'u.id = ur.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('u.total_recharge'); + + $total_withdraw = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join('user_relation_agent ur', 'u.id = ur.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('u.total_withdraw'); + + $total_money = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join('user_relation_agent ur', 'u.id = ur.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('u.user_money'); + + $recharge_ing = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join('user_relation_agent ur', 'u.id = ur.user_id') + ->join('recharge_record rr', 'u.id = rr.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where(['rr.status' => 0]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + + $withdraw_ing = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join('user_relation_agent ur', 'u.id = ur.user_id') + ->join('withdraw_record wr', 'u.id = wr.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where(['wr.status' => 0]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + + return [ + 'total_money' => round($total_money, 2), + 'total_recharge' => round($total_recharge, 2), + 'total_withdraw' => round($total_withdraw, 2), + 'recharge_withdraw' => round($total_recharge - $total_withdraw, 2), + 'recharge_ing' => round($recharge_ing, 2), + 'withdraw_ing' => round($withdraw_ing, 2), + ]; + } +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserGroupLists.php b/app/adminapi/lists/user/UserGroupLists.php new file mode 100644 index 0000000..fdfe189 --- /dev/null +++ b/app/adminapi/lists/user/UserGroupLists.php @@ -0,0 +1,65 @@ + ['name'], + ]; + } + + + /** + * @notes 获取用户分组列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/04/25 01:04 + */ + public function lists(): array + { + return UserGroup::where($this->searchWhere) + ->field(['id', 'name']) + ->append(['rule_num','user_num']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取用户分组数量 + * @return int + * @author BD + * @date 2024/04/25 01:04 + */ + public function count(): int + { + return UserGroup::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserGroupRuleLists.php b/app/adminapi/lists/user/UserGroupRuleLists.php new file mode 100644 index 0000000..1058b7d --- /dev/null +++ b/app/adminapi/lists/user/UserGroupRuleLists.php @@ -0,0 +1,64 @@ + ['group_id'], + ]; + } + + + /** + * @notes 获取分组规则列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/04/25 01:30 + */ + public function lists(): array + { + return UserGroupRule::where($this->searchWhere) + ->field(['id', 'group_id', 'num', 'money_type', 'money', 'money_percentage', 'commission_type', 'commission', 'commission_percentage']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取分组规则数量 + * @return int + * @author BD + * @date 2024/04/25 01:30 + */ + public function count(): int + { + return UserGroupRule::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserInfoLists.php b/app/adminapi/lists/user/UserInfoLists.php new file mode 100644 index 0000000..4b840b5 --- /dev/null +++ b/app/adminapi/lists/user/UserInfoLists.php @@ -0,0 +1,98 @@ + ['ui.user_id', 'ui.email', 'ui.google_key', 'ui.card_name', 'ui.card_num', 'ui.auth_email', 'ui.auth_google', 'ui.auth_card', 'ui.create_time'], + ]; + } + + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['ui.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取用户信息列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/06/08 17:51 + */ + public function lists(): array + { + $field = 'ui.id,ui.user_id,ui.email,ui.google_key,ui.google_qrcode,ui.card_name,ui.card_num,ui.card_img1,ui.card_img2,ui.card_img3,ui.auth_email,ui.auth_google,ui.auth_card,ui.create_time,ui.card_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile'; + return UserInfo::alias('ui') + ->join('user u', 'u.id = ui.user_id') + ->field($field) + ->where("auth_card != 0") + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['ui.card_time' => 'desc' ,'ui.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取用户信息数量 + * @return int + * @author BD + * @date 2024/06/08 17:51 + */ + public function count(): int + { + return UserInfo::alias('ui') + ->join('user u', 'u.id = ui.user_id') + ->where("auth_card != 0") + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserKadanLists.php b/app/adminapi/lists/user/UserKadanLists.php new file mode 100644 index 0000000..a2732f2 --- /dev/null +++ b/app/adminapi/lists/user/UserKadanLists.php @@ -0,0 +1,64 @@ + [ 'user_id'], + ]; + } + + + /** + * @notes 获取卡单规则列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/04/24 17:00 + */ + public function lists(): array + { + return UserKadan::where($this->searchWhere) + ->field(['id', 'user_id', 'sn', 'num', 'money', 'commission', 'status', 'create_time', 'finish_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取卡单规则数量 + * @return int + * @author BD + * @date 2024/04/24 17:00 + */ + public function count(): int + { + return UserKadan::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserLists.php b/app/adminapi/lists/user/UserLists.php new file mode 100644 index 0000000..6b97ee4 --- /dev/null +++ b/app/adminapi/lists/user/UserLists.php @@ -0,0 +1,341 @@ + ['u.sn','u.is_open','u.is_agent','u.country_code','u.register_ip','u.login_ip'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 会员等级 + if (!empty($this->params['member_id'])) { + $where[] = ['umr.member_id', '=', $this->params['member_id']]; + } + + // 邮箱地址 + if (!empty($this->params['email'])) { + $where[] = ['ui.email', '=', $this->params['email']]; + } + + // 邮箱认证 + if (!empty($this->params['auth_email'])) { + $where[] = ['ui.auth_email', '=', $this->params['auth_email']]; + } + + // 下单时间 + if (!empty($this->params['create_time_start']) && !empty($this->params['create_time_end'])) { + $time = [strtotime($this->params['create_time_start']), strtotime($this->params['create_time_end'])]; + $where[] = ['u.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取用户列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/22 15:50 + */ + public function lists(): array + { + $where = " 1 = 1 "; + + + // 金额范围 + if (!empty($this->params['recharge_withdraw_min'])) { + $recharge_withdraw_min = $this->params['recharge_withdraw_min']; + $where .= " AND u.total_recharge - u.total_withdraw >= $recharge_withdraw_min "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_max'])) { + $recharge_withdraw_max = $this->params['recharge_withdraw_max']; + $where .= " AND u.total_recharge - u.total_withdraw <= $recharge_withdraw_max "; + } + + $field = "u.id,u.sn,u.nickname,u.sex,u.avatar,u.account,u.mobile,u.country_code,u.auto_member,u.is_lh,u.is_transfer,u.is_sn,u.is_open,u.is_agent,u.agent_name,u.channel,u.user_money,u.user_point,u.total_recharge,u.total_withdraw,u.total_income_invest,u.total_invest,u.total_income_mine,u.create_time,u.register_ip,u.register_isp,u.remark2,u.login_ip,u.login_time"; + $field .= ',ui.email,ui.auth_email'; + + $join_table = "user_info t"; + $join_require = 't.user_id = u.id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'u.id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + $field .= ',ur.level'; + } + $lists = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join($join_table, $join_require) + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->field($field) + ->append(['team_num','team_recharge','team_withdraw','item_num','today_item_num','vip_name','unused_money','team_report','team_top','register_ip_num','login_ip_num','register_country','mine']) + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order('u.id desc') + ->select() + ->toArray(); + + foreach ($lists as &$item) { + $item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']); + + $item['recharge_withdraw'] = round($item['total_recharge'] - $item['total_withdraw'], 2); + + if(isset($item['level']) && isset($item['team_top']['level'])){ + $item['team_top']['level'] = $item['level']; + } + } + + return $lists; + } + + + /** + * @notes 获取数量 + * @return int + * @author 段誉 + * @date 2022/9/22 15:51 + */ + public function count(): int + { + $where = " 1 = 1 "; + + // 金额范围 + if (!empty($this->params['recharge_withdraw_min'])) { + $recharge_withdraw_min = $this->params['recharge_withdraw_min']; + $where .= " AND u.total_recharge - u.total_withdraw >= $recharge_withdraw_min "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_max'])) { + $recharge_withdraw_max = $this->params['recharge_withdraw_max']; + $where .= " AND u.total_recharge - u.total_withdraw <= $recharge_withdraw_max "; + } + + $join_table = "user_info t"; + $join_require = 't.user_id = u.id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'u.id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + } + + + return User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join($join_table, $join_require) + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + + public function extend(): array + { + $where = " 1 = 1 "; + + // 金额范围 + if (!empty($this->params['recharge_withdraw_min'])) { + $recharge_withdraw_min = $this->params['recharge_withdraw_min']; + $where .= " AND u.total_recharge - u.total_withdraw >= $recharge_withdraw_min "; + } + + // 金额范围 + if (!empty($this->params['recharge_withdraw_max'])) { + $recharge_withdraw_max = $this->params['recharge_withdraw_max']; + $where .= " AND u.total_recharge - u.total_withdraw <= $recharge_withdraw_max "; + } + + $join_table = "user_info t"; + $join_require = 't.user_id = u.id'; + if(isset($this->params['parent_sn']) && $this->params['parent_sn'] !=""){ + $join_table = "user_relation_agent ur"; + $join_require = 'u.id = ur.user_id'; + + $user = User::where(['sn' => $this->params['parent_sn']]) -> findOrEmpty(); + $parent_id = 0; + if (!$user->isEmpty()) $parent_id = $user['id']; + + $where .= " AND ur.parent_id = $parent_id "; + + if(isset($this->params['level']) && $this->params['level'] !=""){ + $level = $this->params['level']; + $where .= " AND ur.level = $level "; + } + } + + $total_recharge = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join($join_table, $join_require) + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('u.total_recharge'); + + $total_withdraw = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join($join_table, $join_require) + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('u.total_withdraw'); + + $total_money = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join($join_table, $join_require) + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('u.user_money'); + + $recharge_ing = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join($join_table, $join_require) + ->join('recharge_record rr', 'u.id = rr.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where(['rr.status' => 0]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('rr.amount'); + + $withdraw_ing = User::alias('u') + ->join('user_info ui', 'u.id = ui.user_id') + ->join($join_table, $join_require) + ->join('withdraw_record wr', 'u.id = wr.user_id') + ->leftjoin('user_member_record umr', 'u.id = umr.user_id') + ->where($where) + ->where(['wr.status' => 0]) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->sum('wr.amount'); + + return [ + 'total_money' => round($total_money, 2), + 'total_recharge' => round($total_recharge, 2), + 'total_withdraw' => round($total_withdraw, 2), + 'recharge_withdraw' => round($total_recharge - $total_withdraw, 2), + 'recharge_ing' => round($recharge_ing, 2), + 'withdraw_ing' => round($withdraw_ing, 2), + ]; + } + + /** + * @notes 导出文件名 + * @return string + * @author 段誉 + * @date 2022/11/24 16:17 + */ + public function setFileName(): string + { + return '用户列表'; + } + + + /** + * @notes 导出字段 + * @return string[] + * @author 段誉 + * @date 2022/11/24 16:17 + */ + public function setExcelFields(): array + { + return [ + 'sn' => '用户ID', + 'country_code' => '国家区号', + 'account' => '手机号', + 'sn' => '邀请码', + 'email' => '邮箱', + 'vip_name' => '会员等级', + 'level_top_account' => '一代', + 'level_level' => '用户层级', + 'team_level1' => '推广情况(1级)', + 'team_level2' => '推广情况(2级)', + 'team_level3' => '推广情况(3级)', + 'total_recharge' => '总充值', + 'total_withdraw' => '总提现', + 'recharge_withdraw' => '充提差', + 'channel' => '注册来源', + 'create_time' => '注册时间', + ]; + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserMineRecordLists.php b/app/adminapi/lists/user/UserMineRecordLists.php new file mode 100644 index 0000000..fd52bf2 --- /dev/null +++ b/app/adminapi/lists/user/UserMineRecordLists.php @@ -0,0 +1,97 @@ + ['umr.sn'], + ]; + } + + /** + * @notes 搜索条件 + * @author BD + * @date 2024/03/19 02:29 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['umr.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取挖矿记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2025/01/01 15:47 + */ + public function lists(): array + { + $field = 'umr.*'; + $field .= ',u.account,u.sn as u_sn,u.mobile'; + $records = UserMineRecord::alias('umr') + ->join('user u', 'u.id = umr.user_id') + ->field($field) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['umr.id' => 'desc']) + ->select() + ->toArray(); + + return $records; + } + + + /** + * @notes 获取挖矿记录数量 + * @return int + * @author BD + * @date 2025/01/01 15:47 + */ + public function count(): int + { + return UserMineRecord::alias('umr') + ->join('user u', 'u.id = umr.user_id') + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserNoticeLists.php b/app/adminapi/lists/user/UserNoticeLists.php new file mode 100644 index 0000000..2965f68 --- /dev/null +++ b/app/adminapi/lists/user/UserNoticeLists.php @@ -0,0 +1,96 @@ + ['un.title', 'un.read', 'un.notice_type'], + ]; + } + + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 创建时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['un.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取用户消息列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/05/26 00:36 + */ + public function lists(): array + { + $field = 'un.id,un.user_id,un.title,un.content,un.read,un.notice_type,un.create_time'; + $field .= ',u.account,u.sn as u_sn,u.mobile'; + return UserNotice::alias('un') + ->join('user u', 'u.id = un.user_id') + ->field($field) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['un.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取用户消息数量 + * @return int + * @author BD + * @date 2024/05/26 00:36 + */ + public function count(): int + { + return UserNotice::alias('un') + ->join('user u', 'u.id = un.user_id') + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserRelationLists.php b/app/adminapi/lists/user/UserRelationLists.php new file mode 100644 index 0000000..9bded7f --- /dev/null +++ b/app/adminapi/lists/user/UserRelationLists.php @@ -0,0 +1,109 @@ + ['a1.level'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 15:26 + */ + public function queryWhere() + { + $where = []; + + if (!empty($this->params['user_info'])) { + $where[] = ['u1.sn|u1.account|u1.mobile', '=', $this->params['user_info']]; + } + + if (!empty($this->params['parent_info'])) { + $where[] = ['u2.sn|u2.account|u2.mobile', '=', $this->params['parent_info']]; + } + + return $where; + } + + /** + * @notes 获取用户关系列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/01/12 17:21 + */ + public function lists(): array + { + + $field = 'a1.id,a1.user_id,a1.parent_id,a1.level,a1.create_time,u1.sn as u1_sn,u1.account as u1_account,u1.mobile as u1_mobile,u1.user_money as u1_user_money,u1.total_recharge as u1_total_recharge,u1.total_withdraw u1_total_withdraw,u2.sn as u2_sn,u2.account as u2_account,u2.mobile as u2_mobile'; + + return UserRelationAgent::alias('a1') + ->join('user u1', 'u1.id = a1.user_id') + ->join('user u2', 'u2.id = a1.parent_id') + ->field($field) + ->append(['team_top']) + ->where($this->searchWhere) + ->where($this->queryWhere()) + ->limit($this->limitOffset, $this->limitLength) + ->order(['a1.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取用户关系数量 + * @return int + * @author BD + * @date 2024/01/12 17:21 + */ + public function count(): int + { + return UserRelationAgent::alias('a1') + ->join('user u1', 'u1.id = a1.user_id') + ->join('user u2', 'u2.id = a1.parent_id') + ->where($this->searchWhere) + ->where($this->queryWhere()) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/user/UserTronLists.php b/app/adminapi/lists/user/UserTronLists.php new file mode 100644 index 0000000..3a266d8 --- /dev/null +++ b/app/adminapi/lists/user/UserTronLists.php @@ -0,0 +1,65 @@ + ['type'], + ]; + } + + + /** + * @notes 获取波场钱包列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/05/04 23:38 + */ + public function lists(): array + { + return UserTron::where($this->searchWhere) + ->field(['id', 'user_id', 'address', 'key', 'qrcode', 'money_trx', 'money_usdt', 'sort', 'type', 'create_time']) + ->append(['user_info']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取波场钱包数量 + * @return int + * @author BD + * @date 2024/05/04 23:38 + */ + public function count(): int + { + return UserTron::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/withdraw/WithdrawBankLists.php b/app/adminapi/lists/withdraw/WithdrawBankLists.php new file mode 100644 index 0000000..efd2f68 --- /dev/null +++ b/app/adminapi/lists/withdraw/WithdrawBankLists.php @@ -0,0 +1,78 @@ + ['lang_id', 'name', 'is_show'], + ]; + } + + + /** + * @notes 获取可提现银行列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/25 12:19 + */ + public function lists(): array + { + return WithdrawBank::where($this->searchWhere) + ->append(['lang_name']) + ->field(['id', 'lang_id', 'name', 'code', 'logo', 'is_show', 'sort']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取可提现银行数量 + * @return int + * @author BD + * @date 2024/02/25 12:19 + */ + public function count(): int + { + return WithdrawBank::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/withdraw/WithdrawMethodLists.php b/app/adminapi/lists/withdraw/WithdrawMethodLists.php new file mode 100644 index 0000000..9d108f2 --- /dev/null +++ b/app/adminapi/lists/withdraw/WithdrawMethodLists.php @@ -0,0 +1,78 @@ + ['lang_id', 'type', 'name', 'is_show'], + ]; + } + + + /** + * @notes 获取提现方式列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public function lists(): array + { + return WithdrawMethod::where($this->searchWhere) + ->append(['lang_name']) + ->field(['id', 'lang_id', 'type', 'name', 'logo', 'symbol', 'rate','symbol_rate', 'precision', 'charge', 'is_qrcode', 'is_show', 'sort']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取提现方式数量 + * @return int + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public function count(): int + { + return WithdrawMethod::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/withdraw/WithdrawWalletLists.php b/app/adminapi/lists/withdraw/WithdrawWalletLists.php new file mode 100644 index 0000000..09e9c27 --- /dev/null +++ b/app/adminapi/lists/withdraw/WithdrawWalletLists.php @@ -0,0 +1,108 @@ + [ 'ww.lang_id', 'ww.method_id', 'ww.type', 'ww.is_disable'], + ]; + } + + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + // 用户编号 + if (!empty($this->params['user_info'])) { + $where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']]; + } + + // 下单时间 + if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { + $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; + $where[] = ['ww.create_time', 'between', $time]; + } + + return $where; + } + + + /** + * @notes 获取用户提现钱包列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/26 13:32 + */ + public function lists(): array + { + $field = 'ww.id,ww.lang_id,ww.user_id,ww.method_id,ww.bank_id,ww.type,ww.name,ww.account,ww.img,ww.is_disable,ww.create_time,ww.update_time'; + $field .= ',u.account as u_account,u.sn as u_sn,u.mobile'; + return WithdrawWallet::alias('ww') + ->join('user u', 'u.id = ww.user_id') + ->field($field) + ->append(['lang_name','method_name','bank_name','status_text']) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['ww.id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取用户提现钱包数量 + * @return int + * @author BD + * @date 2024/02/26 13:32 + */ + public function count(): int + { + return WithdrawWallet::alias('ww') + ->join('user u', 'u.id = ww.user_id') + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/ConfigLogic.php b/app/adminapi/logic/ConfigLogic.php new file mode 100644 index 0000000..3ba18a0 --- /dev/null +++ b/app/adminapi/logic/ConfigLogic.php @@ -0,0 +1,140 @@ + FileService::getFileUrl(), + // 网站名称 + 'web_name' => ConfigService::get('website', 'name'), + // 网站图标 + 'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')), + // 网站logo + 'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')), + // 登录页 + 'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')), + // 版权信息 + 'copyright_config' => ConfigService::get('copyright', 'config', []), + // 订单提醒 + 'warm' => ConfigService::get('website', 'warm'), + // 自动翻译 + 'trans_auto' => $translation['auto'], + // 谷歌验证 + 'google_auth' => ConfigService::get('website', 'google_auth'), + // 服务器时间 + 'server_date' => date('Y/m/d H:i:s'), + ]; + return $config; + } + + /** + * @notes 获取代理配置 + * @return array + * @author 段誉 + * @date 2021/12/31 11:03 + */ + public static function getAgentConfig(): array + { + + $config = [ + // 文件域名 + 'oss_domain' => FileService::getFileUrl(), + // 网站名称 + 'web_name' => ConfigService::get('website', 'agent_name'), + // 网站图标 + 'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'agent_web_favicon')), + // 网站logo + 'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'agent_web_logo')), + // 登录页 + 'login_image' => FileService::getFileUrl(ConfigService::get('website', 'agent_login_image')), + //国家区号 + 'region_codes' => ConfigService::get('website', 'regioncode'), + // 谷歌验证 + 'agent_google_auth' => ConfigService::get('website', 'agent_google_auth'), + ]; + return $config; + } + + + /** + * @notes 根据类型获取字典类型 + * @param $type + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/27 19:09 + */ + public static function getDictByType($type) + { + if (!is_string($type)) { + return []; + } + + $type = explode(',', $type); + $lists = DictData::whereIn('type_value', $type)->where(['status'=>1])->order(['sort' => 'desc'])->select()->toArray(); + + if (empty($lists)) { + return []; + } + + $result = []; + foreach ($type as $item) { + foreach ($lists as $dict) { + if ($dict['type_value'] == $item) { + $result[$item][] = $dict; + } + } + } + return $result; + } + + + +} \ No newline at end of file diff --git a/app/adminapi/logic/FileLogic.php b/app/adminapi/logic/FileLogic.php new file mode 100644 index 0000000..95060af --- /dev/null +++ b/app/adminapi/logic/FileLogic.php @@ -0,0 +1,119 @@ +whereIn('id', $params['ids']) + ->update([ + 'cid' => $params['cid'], + 'update_time' => time() + ]); + } + + /** + * @notes 重命名文件 + * @param $params + * @author 张无忌 + * @date 2021/7/29 17:16 + */ + public static function rename($params) + { + (new File())->where('id', $params['id']) + ->update([ + 'name' => $params['name'], + 'update_time' => time() + ]); + } + + /** + * @notes 批量删除文件 + * @param $params + * @author 张无忌 + * @date 2021/7/28 15:41 + */ + public static function delete($params) + { + $result = File::whereIn('id', $params['ids'])->select(); + $StorageDriver = new StorageDriver([ + 'default' => ConfigService::get('storage', 'default', 'local'), + 'engine' => ConfigService::get('storage') ?? ['local'=>[]], + ]); + foreach ($result as $item) { + $StorageDriver->delete($item['uri']); + } + File::destroy($params['ids']); + } + + /** + * @notes 添加文件分类 + * @param $params + * @author 张无忌 + * @date 2021/7/28 11:32 + */ + public static function addCate($params) + { + FileCate::create([ + 'type' => $params['type'], + 'pid' => $params['pid'], + 'name' => $params['name'] + ]); + } + + /** + * @notes 编辑文件分类 + * @param $params + * @author 张无忌 + * @date 2021/7/28 14:03 + */ + public static function editCate($params) + { + FileCate::update([ + 'name' => $params['name'], + 'update_time' => time() + ], ['id' => $params['id']]); + } + + /** + * @notes 删除文件分类 + * @param $params + * @author 张无忌 + * @date 2021/7/28 14:21 + */ + public static function delCate($params) + { + FileCate::destroy($params['id']); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/LoginLogic.php b/app/adminapi/logic/LoginLogic.php new file mode 100644 index 0000000..0acaaeb --- /dev/null +++ b/app/adminapi/logic/LoginLogic.php @@ -0,0 +1,116 @@ +find(); + + //用户表登录信息更新 + $admin->login_time = $time; + $admin->login_ip = request()->ip(); + $admin->save(); + + //设置token + $adminInfo = AdminTokenService::setToken($admin->id, $params['terminal'], $admin->multipoint_login); + + //返回登录信息 + $avatar = $admin->avatar ? $admin->avatar : Config::get('project.default_image.admin_avatar'); + $avatar = FileService::getFileUrl($avatar); + return [ + 'name' => $adminInfo['name'], + 'avatar' => $avatar, + 'role_name' => $adminInfo['role_name'], + 'token' => $adminInfo['token'], + ]; + } + + /** + * @notes 代理登录 + * @param $params + * @return false|mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 令狐冲 + * @date 2021/6/30 17:00 + */ + public function loginAgent($params) + { + $time = time(); + $user = User::where('account', '=', $params['account'])->find(); + //查询关联管理员 + $admin = Admin::where('id', '=', $user['agent_id'])->find(); + + //设置token + $adminInfo = AdminTokenService::setToken($admin->id, $params['terminal'], $admin->multipoint_login); + + //返回登录信息 + $avatar = $admin->avatar ? $admin->avatar : Config::get('project.default_image.admin_avatar'); + $avatar = FileService::getFileUrl($avatar); + return [ + 'name' => $adminInfo['name'], + 'avatar' => $avatar, + 'role_name' => $adminInfo['role_name'], + 'token' => $adminInfo['token'], + ]; + } + + + /** + * @notes 退出登录 + * @param $adminInfo + * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 令狐冲 + * @date 2021/7/5 14:34 + */ + public function logout($adminInfo) + { + //token不存在,不注销 + if (!isset($adminInfo['token'])) { + return false; + } + //设置token过期 + return AdminTokenService::expireToken($adminInfo['token']); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/WorkbenchLogic.php b/app/adminapi/logic/WorkbenchLogic.php new file mode 100644 index 0000000..f3f3445 --- /dev/null +++ b/app/adminapi/logic/WorkbenchLogic.php @@ -0,0 +1,410 @@ + self::report(), + // 常用功能 + 'menu' => self::menu(), + // 近15日注册量 + 'visitor' => self::visitor(), + ]; + } + + /** + * @notes 代理工作台 + * @param $params + * @return array + * @author 段誉 + * @date 2021/12/29 15:58 + */ + public static function agent($params) + { + return [ + // 今日数据 + 'report' => self::agentReport($params), + ]; + } + + + /** + * @notes 常用功能 + * @return array[] + * @author 段誉 + * @date 2021/12/29 16:40 + */ + public static function menu(): array + { + return [ + [ + 'name' => '用户管理', + 'image' => FileService::getFileUrl(config('project.default_image.menu_role')), + 'url' => '/consumer/lists' + ], + [ + 'name' => '用户关系', + 'image' => FileService::getFileUrl(config('project.default_image.menu_dept')), + 'url' => '/consumer/user_relation' + ], + [ + 'name' => '资金明细', + 'image' => FileService::getFileUrl(config('project.default_image.menu_dict')), + 'url' => '/finance/user_finance' + ], + [ + 'name' => '素材中心', + 'image' => FileService::getFileUrl(config('project.default_image.menu_generator')), + 'url' => '/material/index' + ], + [ + 'name' => '文章资讯', + 'image' => FileService::getFileUrl(config('project.default_image.menu_file')), + 'url' => '/article/lists' + ], + [ + 'name' => '网站配置', + 'image' => FileService::getFileUrl(config('project.default_image.menu_web')), + 'url' => '/app/information' + ], + [ + 'name' => '管理员', + 'image' => FileService::getFileUrl(config('project.default_image.menu_admin')), + 'url' => '/permission/admin' + ], + ]; + } + + + /** + * @notes 今日数据 + * @return int[] + * @author 段誉 + * @date 2021/12/29 16:15 + */ + public static function report(): array + { + $time = time(); + $start_time = strtotime(date('Y-m-d 00:00:00', time()));//0点 + $end_time = strtotime(date('Y-m-d 23:59:59', time()));//24点 + + //昨日 + $start_time_yes = strtotime("yesterday");//昨日0点 + $end_time_yes = strtotime("today") - 1;//昨日24点 + + return [ + 'time' => date('Y-m-d H:i:s'), + + 'totoal' => WorkbenchLogic::reportData(0,$end_time), + + 'today' => WorkbenchLogic::reportData($start_time,$end_time), + + 'yes' => WorkbenchLogic::reportData($start_time_yes,$end_time_yes), + + ]; + } + + /** + * @notes 访问数据 + * @return array + * @author 段誉 + * @date 2021/12/29 16:57 + */ + public static function reportData($start_time,$end_time): array + { + $time = time(); + + $online_time = $time - 60*60; + + $user_money_sum = User::where(" user_money > 0 ")->sum('user_money'); + + $user_money_frozen_sum = UserFinance::where(" change_amount > 0 ")->where(['frozen' => 1])->sum('change_amount'); + + $user_online_count= User::where("last_time >= $online_time")->count(); + + $user_count= User::where("create_time >= $start_time AND create_time <= $end_time")->count(); + //活跃人数 + $user_active_count= UserLog::where("create_time >= $start_time AND create_time <= $end_time")->where(['type' => 1])->group("user_id")->count(); + + $recharge_sum= RechargeRecord::where("status = 1 AND create_time >= $start_time AND create_time <= $end_time")->sum('amount'); + + $recharge_count= RechargeRecord::where("status = 1 AND create_time >= $start_time AND create_time <= $end_time")->count(); + + $recharge_first_num= RechargeRecord::where("status = 1 AND create_time >= $start_time AND create_time <= $end_time")->group("user_id")->having(1)->count(); + + $recharge_num= RechargeRecord::where("status = 1 AND create_time >= $start_time AND create_time <= $end_time")->group("user_id")->count(); + + $recharge_first_num= RechargeRecord::where("status = 1 AND create_time >= $start_time AND create_time <= $end_time")->group("user_id")->having('count(*) = 1')->count(); + + $withdraw_sum= WithdrawRecord::where("status = 1 AND create_time >= $start_time AND create_time <= $end_time")->sum('amount'); + + $withdraw_count= WithdrawRecord::where("status = 1 AND create_time >= $start_time AND create_time <= $end_time")->count(); + + $withdraw_num= WithdrawRecord::where("status = 1 AND create_time >= $start_time AND create_time <= $end_time")->group("user_id")->count(); + + $user_reward_sum = UserFinance::where(" change_amount > 0 AND change_type IN (4,14,15) AND create_time >= $start_time AND create_time <= $end_time")->sum('change_amount'); + + // $order_sum= LhRecord::where("create_time >= $start_time AND create_time <= $end_time")->sum('money'); + + // $order_num= LhRecord::where("create_time >= $start_time AND create_time <= $end_time")->group("user_id")->count(); + + // $order_com_sum= LhRecord::where("create_time >= $start_time AND create_time <= $end_time")->sum('income'); + + $order_sum= ItemRecord::where("create_time >= $start_time AND create_time <= $end_time")->sum('money'); + + $order_ing_sum = ItemRecord::where(['status' => 1])->where(" create_time >= $start_time AND create_time <= $end_time ")->sum('money'); + + $order_num= ItemRecord::where("create_time >= $start_time AND create_time <= $end_time")->group("user_id")->count(); + + $order_com_sum= ItemRecord::where("create_time >= $start_time AND create_time <= $end_time")->sum('total_income'); + + $mine_com_sum = UserMineRecord::where(" create_time >= $start_time AND create_time <= $end_time ")->sum('amount'); + + $mine_num= UserMineRecord::where("create_time >= $start_time AND create_time <= $end_time")->group("user_id")->count(); + + + return [ + 'user_money_sum' => $user_money_sum, + + 'user_money_frozen_sum' => $user_money_frozen_sum, + + 'user_online_count' => $user_online_count, + + 'user_count' => $user_count, + + 'user_active_count' => $user_active_count, + + 'recharge_count' => $recharge_count, + + 'recharge_num' => $recharge_num, + + 'recharge_first_num' => $recharge_first_num, + + 'recharge_sum' => round($recharge_sum, 2), + + 'withdraw_sum' => round($withdraw_sum, 2), + + 'withdraw_count' => $withdraw_count, + + 'withdraw_num' => $withdraw_num, + + 'user_reward_sum' => $user_reward_sum, + + 'order_sum' => round($order_sum, 2), + + 'order_ing_sum' => round($order_ing_sum, 2), + + 'order_num' => $order_num, + + 'order_com_sum' => round($order_com_sum, 2), + + 'mine_com_sum' => round($mine_com_sum, 2), + + 'mine_num' => $mine_num, + + ]; + } + + /** + * @notes 今日数据 + * @return int[] + * @author 段誉 + * @date 2021/12/29 16:15 + */ + public static function agentReport($params): array + { + $time = time(); + $start_time = strtotime(date('Y-m-d 00:00:00', time()));//0点 + $end_time = strtotime(date('Y-m-d 23:59:59', time()));//24点 + + //昨日 + $start_time_yes = strtotime("yesterday");//昨日0点 + $end_time_yes = strtotime("today") - 1;//昨日24点 + + return [ + 'time' => date('Y-m-d H:i:s'), + + 'totoal' => WorkbenchLogic::agentReportData(0,$end_time,$params), + + 'today' => WorkbenchLogic::agentReportData($start_time,$end_time,$params), + + 'yes' => WorkbenchLogic::agentReportData($start_time_yes,$end_time_yes,$params), + + ]; + } + + /** + * @notes 访问数据 + * @return array + * @author 段誉 + * @date 2021/12/29 16:57 + */ + public static function agentReportData($start_time,$end_time,$params): array + { + //根据管理员ID获取代理 + $user = User::where(['agent_id' => $params['admin_id']])->findOrEmpty(); + + $where = " 1 = 2 "; + if (!$user->isEmpty()) { + $user_id = $user['id']; + $where = " ur.parent_id = $user_id "; + } + + + $time = time(); + + $online_time = $time - 60*60; + + $user_money_sum = User::alias('u')->join('user_relation_agent ur', 'u.id = ur.user_id')->where($where)->where(" u.user_money > 0 ")->sum('u.user_money'); + + $user_money_frozen_sum = UserFinance::alias('uf')->join('user_relation_agent ur', 'uf.user_id = ur.user_id')->where($where)->where(" uf.change_amount > 0 ")->where(['uf.frozen' => 1])->sum('uf.change_amount'); + + $user_online_count= User::alias('u')->join('user_relation_agent ur', 'u.id = ur.user_id')->where($where)->where("u.last_time >= $online_time")->count(); + + $user_count= User::alias('u')->join('user_relation_agent ur', 'u.id = ur.user_id')->where($where)->where("u.create_time >= $start_time AND u.create_time <= $end_time")->count(); + //活跃人数 + $user_active_count= UserLog::alias('ul')->join('user_relation_agent ur', 'ul.user_id = ur.user_id')->where($where)->where("ul.create_time >= $start_time AND ul.create_time <= $end_time")->where(['ul.type' => 1])->group("ul.user_id")->count(); + + $recharge_sum= RechargeRecord::alias('rr')->join('user_relation_agent ur', 'rr.user_id = ur.user_id')->where($where)->where("rr.status = 1 AND rr.create_time >= $start_time AND rr.create_time <= $end_time")->sum('rr.amount'); + + $recharge_count= RechargeRecord::alias('rr')->join('user_relation_agent ur', 'rr.user_id = ur.user_id')->where($where)->where("rr.status = 1 AND rr.create_time >= $start_time AND rr.create_time <= $end_time")->count(); + + $recharge_first_num= RechargeRecord::alias('rr')->join('user_relation_agent ur', 'rr.user_id = ur.user_id')->where($where)->where("rr.status = 1 AND rr.create_time >= $start_time AND rr.create_time <= $end_time")->group("rr.user_id")->having(1)->count(); + + $recharge_num= RechargeRecord::alias('rr')->join('user_relation_agent ur', 'rr.user_id = ur.user_id')->where($where)->where("rr.status = 1 AND rr.create_time >= $start_time AND rr.create_time <= $end_time")->group("rr.user_id")->count(); + + $recharge_first_num= RechargeRecord::alias('rr')->join('user_relation_agent ur', 'rr.user_id = ur.user_id')->where($where)->where("rr.status = 1 AND rr.create_time >= $start_time AND rr.create_time <= $end_time")->group("rr.user_id")->having('count(*) = 1')->count(); + + $withdraw_sum= WithdrawRecord::alias('wr')->join('user_relation_agent ur', 'wr.user_id = ur.user_id')->where($where)->where("wr.status = 1 AND wr.create_time >= $start_time AND wr.create_time <= $end_time")->sum('wr.amount'); + + $withdraw_count= WithdrawRecord::alias('wr')->join('user_relation_agent ur', 'wr.user_id = ur.user_id')->where($where)->where("wr.status = 1 AND wr.create_time >= $start_time AND wr.create_time <= $end_time")->count(); + + $withdraw_num= WithdrawRecord::alias('wr')->join('user_relation_agent ur', 'wr.user_id = ur.user_id')->where($where)->where("wr.status = 1 AND wr.create_time >= $start_time AND wr.create_time <= $end_time")->group("wr.user_id")->count(); + + $user_reward_sum = UserFinance::alias('uf')->join('user_relation_agent ur', 'uf.user_id = ur.user_id')->where($where)->where(" uf.change_amount > 0 AND uf.change_type IN (4,14,15) AND uf.create_time >= $start_time AND uf.create_time <= $end_time")->sum('uf.change_amount'); + + // $order_sum= LhRecord::alias('lr')->join('user_relation_agent ur', 'lr.user_id = ur.user_id')->where($where)->where("lr.create_time >= $start_time AND lr.create_time <= $end_time")->sum('lr.money'); + + // $order_num= LhRecord::alias('lr')->join('user_relation_agent ur', 'lr.user_id = ur.user_id')->where("lr.create_time >= $start_time AND lr.create_time <= $end_time")->group("lr.user_id")->count(); + + // $order_com_sum= LhRecord::alias('lr')->join('user_relation_agent ur', 'lr.user_id = ur.user_id')->where("lr.create_time >= $start_time AND lr.create_time <= $end_time")->sum('lr.income'); + + $order_sum= ItemRecord::alias('ir')->join('user_relation_agent ur', 'ir.user_id = ur.user_id')->where($where)->where("ir.create_time >= $start_time AND ir.create_time <= $end_time")->sum('ir.money'); + + $order_num= ItemRecord::alias('ir')->join('user_relation_agent ur', 'ir.user_id = ur.user_id')->where($where)->where("ir.create_time >= $start_time AND ir.create_time <= $end_time")->group("ir.user_id")->count(); + + $order_com_sum= ItemRecord::alias('ir')->join('user_relation_agent ur', 'ir.user_id = ur.user_id')->where($where)->where("ir.create_time >= $start_time AND ir.create_time <= $end_time")->sum('ir.total_income'); + + $mine_com_sum = UserMineRecord::alias('umr')->join('user_relation_agent ur', 'umr.user_id = ur.user_id')->where($where)->where("umr.create_time >= $start_time AND umr.create_time <= $end_time")->sum('umr.amount'); + + $mine_num= UserMineRecord::alias('umr')->join('user_relation_agent ur', 'umr.user_id = ur.user_id')->where($where)->where("umr.create_time >= $start_time AND umr.create_time <= $end_time")->group("umr.user_id")->count(); + + + return [ + 'user_money_sum' => $user_money_sum, + + 'user_money_frozen_sum' => $user_money_frozen_sum, + + 'user_online_count' => $user_online_count, + + 'user_count' => $user_count, + + 'user_active_count' => $user_active_count, + + 'recharge_count' => $recharge_count, + + 'recharge_num' => $recharge_num, + + 'recharge_first_num' => $recharge_first_num, + + 'recharge_sum' => round($recharge_sum, 2), + + 'withdraw_sum' => round($withdraw_sum, 2), + + 'withdraw_count' => $withdraw_count, + + 'withdraw_num' => $withdraw_num, + + 'user_reward_sum' => $user_reward_sum, + + 'order_sum' => round($order_sum, 2), + + 'order_num' => $order_num, + + 'order_com_sum' => round($order_com_sum, 2), + + 'mine_com_sum' => round($mine_com_sum, 2), + + 'mine_num' => $mine_num, + + ]; + } + + + /** + * @notes 访问数 + * @return array + * @author 段誉 + * @date 2021/12/29 16:57 + */ + public static function visitor(): array + { + $num = []; + $date = []; + for ($i = 0; $i < 30; $i++) { + $where_start = strtotime("- " . $i . "day"); + $date[] = date('Y/m/d', $where_start); + $start_time = strtotime(date('Y-m-d 00:00:00', strtotime(date('Y-m-d', $where_start))));//0点 + $end_time = strtotime(date('Y-m-d 23:59:59', strtotime(date('Y-m-d', $where_start))));//12点 + $num[] = User::where("create_time >= $start_time AND create_time <= $end_time")->count(); + } + + return [ + 'date' => $date, + 'list' => [ + ['name' => '注册数', 'data' => array_reverse($num)] + ] + ]; + } + + +} \ No newline at end of file diff --git a/app/adminapi/logic/article/ArticleCateLogic.php b/app/adminapi/logic/article/ArticleCateLogic.php new file mode 100644 index 0000000..1d9afe3 --- /dev/null +++ b/app/adminapi/logic/article/ArticleCateLogic.php @@ -0,0 +1,137 @@ + $params['name'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] ?? 0, + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + } + + + /** + * @notes 编辑资讯分类 + * @param array $params + * @return bool + * @author heshihu + * @date 2022/2/21 17:50 + */ + public static function edit(array $params) : bool + { + try { + ArticleCate::update([ + 'id' => $params['id'], + 'name' => $params['name'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] ?? 0, + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除资讯分类 + * @param array $params + * @author heshihu + * @date 2022/2/21 17:52 + */ + public static function delete(array $params) + { + ArticleCate::destroy($params['id']); + } + + /** + * @notes 查看资讯分类详情 + * @param $params + * @return array + * @author heshihu + * @date 2022/2/21 17:54 + */ + public static function detail($params) : array + { + + $articleCate = ArticleCate::findOrEmpty($params['id'])->toArray(); + + $langs = json_decode($articleCate['langs'], true); + if(empty($langs)){ + $langs = []; + } + $articleCate['langs'] = $langs; + return $articleCate; + } + + /** + * @notes 更改资讯分类状态 + * @param array $params + * @return bool + * @author heshihu + * @date 2022/2/21 18:04 + */ + public static function updateStatus(array $params) + { + ArticleCate::update([ + 'id' => $params['id'], + 'is_show' => $params['is_show'] + ]); + return true; + } + + + /** + * @notes 文章分类数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:53 + */ + public static function getAllData() + { + return ArticleCate::where(['is_show' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/article/ArticleLogic.php b/app/adminapi/logic/article/ArticleLogic.php new file mode 100644 index 0000000..7fa36f0 --- /dev/null +++ b/app/adminapi/logic/article/ArticleLogic.php @@ -0,0 +1,201 @@ + $params['title'], + 'desc' => $params['desc'] ?? '', + 'author' => $params['author'] ?? '', //作者 + 'sort' => $params['sort'] ?? 0, // 排序 + 'abstract' => $params['abstract'], // 文章摘要 + 'click_virtual' => $params['click_virtual'] ?? 0, + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'cid' => $params['cid'], + 'is_show' => $params['is_show'], + 'is_popup' => $params['is_popup'], + 'is_notice' => $params['is_notice'], + 'is_sys_notice' => $params['is_sys_notice'], + 'content' => $params['content'] ?? '', + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + if($params['is_sys_notice'] == 1){ + $users = User::select()->toArray(); + foreach ($users as &$user) { + UserNotice::create([ + 'user_id' => $user['id'], + 'article_id' => $article['id'], + 'title' => $article['title'], + 'content' => $article['content'] ?? '', + 'langs' => $article['langs'], + ]); + } + } + + } + + + /** + * @notes 编辑资讯 + * @param array $params + * @return bool + * @author heshihu + * @date 2022/2/22 10:12 + */ + public static function edit(array $params) : bool + { + try { + $langs = $params['langs']; + + foreach ($langs as &$content_lang) { + $content_lang['image'] = FileService::setFileUrl($content_lang['image']); + $content_lang['content'] = clear_file_domain($content_lang['content']); + } + $article = Article::update([ + 'id' => $params['id'], + 'title' => $params['title'], + 'desc' => $params['desc'] ?? '', // 简介 + 'author' => $params['author'] ?? '', //作者 + 'sort' => $params['sort'] ?? 0, // 排序 + 'abstract' => $params['abstract'], // 文章摘要 + 'click_virtual' => $params['click_virtual'] ?? 0, + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'cid' => $params['cid'], + 'is_show' => $params['is_show'], + 'is_popup' => $params['is_popup'], + 'is_notice' => $params['is_notice'], + 'is_sys_notice' => $params['is_sys_notice'], + 'content' => $params['content'] ?? '', + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + if($params['is_sys_notice'] == 1){ + $notices = UserNotice::where(['article_id' => $params['id']])->select()->toArray(); + foreach ($notices as &$notice) { + UserNotice::update([ + 'id' => $notice['id'], + 'title' => $article['title'], + 'content' => $article['content'] ?? '', + 'langs' => $article['langs'], + ]); + } + } + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除资讯 + * @param array $params + * @author heshihu + * @date 2022/2/22 10:17 + */ + public static function delete(array $params) + { + Article::destroy($params['id']); + } + + /** + * @notes 查看资讯详情 + * @param $params + * @return array + * @author heshihu + * @date 2022/2/22 10:15 + */ + public static function detail($params) : array + { + $article = Article::findOrEmpty($params['id'])->toArray(); + + $langs = json_decode($article['langs'], true); + + if(!empty($langs)){ + foreach ($langs as &$content_lang) { + $content_lang['image'] = FileService::getFileUrl($content_lang['image']); + $content_lang['content'] = get_file_domain($content_lang['content']); + } + }else{ + $langs = []; + } + $article['langs'] = $langs; + return $article; + } + + /** + * @notes 更改资讯状态 + * @param array $params + * @return bool + * @author heshihu + * @date 2022/2/22 10:18 + */ + public static function updateStatus(array $params) + { + Article::update([ + 'id' => $params['id'], + 'is_show' => $params['is_show'] + ]); + return true; + } + + /** + * @notes 资讯列表 + * @param $params + * @return array + * @author BD + * @date 2024/03/17 17:01 + */ + public static function all($params) : array + { + $field = ['id', 'title']; + $articles = Article::field($field) + ->where(['cid' => $params['cid'],'is_show' => 1]) + ->order(['sort' => 'desc','id' => 'desc']) + ->select()->toArray(); + return $articles; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/auth/AdminLogic.php b/app/adminapi/logic/auth/AdminLogic.php new file mode 100644 index 0000000..c573568 --- /dev/null +++ b/app/adminapi/logic/auth/AdminLogic.php @@ -0,0 +1,411 @@ + $params['name'], + 'account' => $params['account'], + 'avatar' => $avatar, + 'password' => $password, + 'create_time' => time(), + 'disable' => $params['disable'], + 'multipoint_login' => $params['multipoint_login'], + ]); + + // 角色 + self::insertRole($admin['id'], $params['role_id'] ?? []); + // 部门 + self::insertDept($admin['id'], $params['dept_id'] ?? []); + // 岗位 + self::insertJobs($admin['id'], $params['jobs_id'] ?? []); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑管理员 + * @param array $params + * @return bool + * @author 段誉 + * @date 2021/12/29 10:43 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + // 基础信息 + $data = [ + 'id' => $params['id'], + 'name' => $params['name'], + 'account' => $params['account'], + 'disable' => $params['disable'], + 'multipoint_login' => $params['multipoint_login'] + ]; + + // 头像 + $data['avatar'] = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : ''; + + // 密码 + if (!empty($params['password'])) { + $passwordSalt = Config::get('project.unique_identification'); + $data['password'] = create_password($params['password'], $passwordSalt); + } + + // 禁用或更换角色后.设置token过期 + $roleId = AdminRole::where('admin_id', $params['id'])->column('role_id'); + $editRole = false; + if (!empty(array_diff_assoc($roleId, $params['role_id']))) { + $editRole = true; + } + + if ($params['disable'] == 1 || $editRole) { + $tokenArr = AdminSession::where('admin_id', $params['id'])->select()->toArray(); + foreach ($tokenArr as $token) { + self::expireToken($token['token']); + } + } + + Admin::update($data); + (new AdminAuthCache($params['id']))->clearAuthCache(); + + // 删除旧的关联信息 + AdminRole::delByUserId($params['id']); + AdminDept::delByUserId($params['id']); + AdminJobs::delByUserId($params['id']); + // 角色 + self::insertRole($params['id'], $params['role_id']); + // 部门 + self::insertDept($params['id'], $params['dept_id'] ?? []); + // 岗位 + self::insertJobs($params['id'], $params['jobs_id'] ?? []); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除管理员 + * @param array $params + * @return bool + * @author 段誉 + * @date 2021/12/29 10:45 + */ + public static function delete(array $params): bool + { + Db::startTrans(); + try { + $admin = Admin::findOrEmpty($params['id']); + if ($admin->root == YesNoEnum::YES) { + throw new \Exception("超级管理员不允许被删除"); + } + Admin::destroy($params['id']); + + //设置token过期 + $tokenArr = AdminSession::where('admin_id', $params['id'])->select()->toArray(); + foreach ($tokenArr as $token) { + self::expireToken($token['token']); + } + (new AdminAuthCache($params['id']))->clearAuthCache(); + + // 删除旧的关联信息 + AdminRole::delByUserId($params['id']); + AdminDept::delByUserId($params['id']); + AdminJobs::delByUserId($params['id']); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 过期token + * @param $token + * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2021/12/29 10:46 + */ + public static function expireToken($token): bool + { + $adminSession = AdminSession::where('token', '=', $token) + ->with('admin') + ->find(); + + if (empty($adminSession)) { + return false; + } + + $time = time(); + $adminSession->expire_time = $time; + $adminSession->update_time = $time; + $adminSession->save(); + + return (new AdminTokenCache())->deleteAdminInfo($token); + } + + + /** + * @notes 查看管理员详情 + * @param $params + * @return array + * @author 段誉 + * @date 2021/12/29 11:07 + */ + public static function detail($params, $action = 'detail'): array + { + $admin = Admin::field([ + 'id', 'account', 'name', 'disable', 'root', + 'multipoint_login', 'avatar', + ])->findOrEmpty($params['id'])->toArray(); + + if ($action == 'detail') { + return $admin; + } + + //代理登录,则用户名替换为代理账户 + $user = User::where(['agent_id' => $admin['id']])->findOrEmpty(); + + if (!$user->isEmpty()) { + $admin['account'] = $user['account']; + $admin['name'] = $user['account']; + } + + $result['user'] = $admin; + // 当前管理员角色拥有的菜单 + $result['menu'] = MenuLogic::getMenuByAdminId($params['id']); + // 当前管理员橘色拥有的按钮权限 + $result['permissions'] = AuthLogic::getBtnAuthByRoleId($admin); + return $result; + } + + + /** + * @notes 编辑超级管理员 + * @param $params + * @return Admin + * @author 段誉 + * @date 2022/4/8 17:54 + */ + public static function editSelf($params) + { + $data = [ + 'id' => $params['admin_id'], + 'name' => $params['name'], + 'avatar' => FileService::setFileUrl($params['avatar']), + ]; + + if (!empty($params['password'])) { + $passwordSalt = Config::get('project.unique_identification'); + $data['password'] = create_password($params['password'], $passwordSalt); + } + + return Admin::update($data); + } + + + /** + * @notes 新增角色 + * @param $adminId + * @param $roleIds + * @throws \Exception + * @author 段誉 + * @date 2022/11/25 14:23 + */ + public static function insertRole($adminId, $roleIds) + { + if (!empty($roleIds)) { + // 角色 + $roleData = []; + foreach ($roleIds as $roleId) { + $roleData[] = [ + 'admin_id' => $adminId, + 'role_id' => $roleId, + ]; + } + (new AdminRole())->saveAll($roleData); + } + } + + + /** + * @notes 新增部门 + * @param $adminId + * @param $deptIds + * @throws \Exception + * @author 段誉 + * @date 2022/11/25 14:22 + */ + public static function insertDept($adminId, $deptIds) + { + // 部门 + if (!empty($deptIds)) { + $deptData = []; + foreach ($deptIds as $deptId) { + $deptData[] = [ + 'admin_id' => $adminId, + 'dept_id' => $deptId + ]; + } + (new AdminDept())->saveAll($deptData); + } + } + + + /** + * @notes 新增岗位 + * @param $adminId + * @param $jobsIds + * @throws \Exception + * @author 段誉 + * @date 2022/11/25 14:22 + */ + public static function insertJobs($adminId, $jobsIds) + { + // 岗位 + if (!empty($jobsIds)) { + $jobsData = []; + foreach ($jobsIds as $jobsId) { + $jobsData[] = [ + 'admin_id' => $adminId, + 'jobs_id' => $jobsId + ]; + } + (new AdminJobs())->saveAll($jobsData); + } + } + + /** + * @notes 编辑超级管理员 + * @param $params + * @return Admin + * @author 段誉 + * @date 2022/4/8 17:54 + */ + public static function google($params) + { + $admin = Admin::findOrEmpty($params['id'])->toArray(); + $show_google = false; + + $google_auth = ConfigService::get('website', 'google_auth'); + + //代理登录 + $user = User::where(['agent_id' => $admin['id']])->findOrEmpty(); + if (!$user->isEmpty()) { + $google_auth = ConfigService::get('website', 'agent_google_auth'); + } + + if($google_auth == 0){ + $show_google = false; + }else{ + if(!$admin['google_key']){ + $show_google = true; + $secretKey = UtilsService::get_google_secretKey(); + Admin::update([ + 'id' => $admin['id'], + 'google_key' => $secretKey, + 'google_qrcode' => UtilsService::get_google_qrcode($admin['account'],'',$secretKey), + ]); + $admin = Admin::findOrEmpty($params['id'])->toArray(); + } + } + + return [ + "show_google" => $show_google, + "key" => $admin['google_key'], + "qrcode" => $admin['google_qrcode'], + ]; + } + + /** + * @notes 重置谷歌验证 + * @param $params + * @return bool + * @author 段誉 + * @date 2021/12/29 11:07 + */ + public static function resetGoogle($params) + { + $admin = Admin::where(['id' => ($params['id'])])->findOrEmpty(); + + if ($admin->isEmpty()) { + throw new \Exception("用户不存在"); + } + + Admin::update([ + 'id' => $admin['id'], + 'google_key' => "", + 'google_qrcode' => "", + ]); + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/auth/AuthLogic.php b/app/adminapi/logic/auth/AuthLogic.php new file mode 100644 index 0000000..9b17c75 --- /dev/null +++ b/app/adminapi/logic/auth/AuthLogic.php @@ -0,0 +1,105 @@ +where([ + ['is_disable', '=', 0], + ['perms', '<>', ''] + ]) + ->column('perms'); + } + + + /** + * @notes 获取当前管理员角色按钮权限 + * @param $roleId + * @return mixed + * @author 段誉 + * @date 2022/7/1 16:10 + */ + public static function getBtnAuthByRoleId($admin) + { + if ($admin['root']) { + return ['*']; + } + + $menuId = SystemRoleMenu::whereIn('role_id', $admin['role_id']) + ->column('menu_id'); + + $where[] = ['is_disable', '=', 0]; + $where[] = ['perms', '<>', '']; + + $roleAuth = SystemMenu::distinct(true) + ->where('id', 'in', $menuId) + ->where($where) + ->column('perms'); + + $allAuth = SystemMenu::distinct(true) + ->where($where) + ->column('perms'); + + $hasAllAuth = array_diff($allAuth, $roleAuth); + if (empty($hasAllAuth)) { + return ['*']; + } + + return $roleAuth; + } + + + /** + * @notes 获取管理员角色关联的菜单id(菜单,权限) + * @param int $adminId + * @return array + * @author 段誉 + * @date 2022/7/1 15:56 + */ + public static function getAuthByAdminId(int $adminId): array + { + $roleIds = AdminRole::where('admin_id', $adminId)->column('role_id'); + $menuId = SystemRoleMenu::whereIn('role_id', $roleIds)->column('menu_id'); + + return SystemMenu::distinct(true) + ->where([ + ['is_disable', '=', 0], + ['perms', '<>', ''], + ['id', 'in', array_unique($menuId)], + ]) + ->column('perms'); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/auth/MenuLogic.php b/app/adminapi/logic/auth/MenuLogic.php new file mode 100644 index 0000000..1ca711c --- /dev/null +++ b/app/adminapi/logic/auth/MenuLogic.php @@ -0,0 +1,199 @@ +column('menu_id'); + $where[] = ['id', 'in', $roleMenu]; + } + + $menu = SystemMenu::where($where) + ->order(['sort' => 'desc', 'id' => 'asc']) + ->select(); + + return linear_to_tree($menu, 'children'); + } + + + /** + * @notes 添加菜单 + * @param array $params + * @return SystemMenu|\think\Model + * @author 段誉 + * @date 2022/6/30 10:06 + */ + public static function add(array $params) + { + return SystemMenu::create([ + 'pid' => $params['pid'], + 'type' => $params['type'], + 'name' => $params['name'], + 'icon' => $params['icon'] ?? '', + 'sort' => $params['sort'], + 'perms' => $params['perms'] ?? '', + 'paths' => $params['paths'] ?? '', + 'component' => $params['component'] ?? '', + 'selected' => $params['selected'] ?? '', + 'params' => $params['params'] ?? '', + 'is_cache' => $params['is_cache'], + 'is_show' => $params['is_show'], + 'is_disable' => $params['is_disable'], + ]); + } + + + /** + * @notes 编辑菜单 + * @param array $params + * @return SystemMenu + * @author 段誉 + * @date 2022/6/30 10:07 + */ + public static function edit(array $params) + { + return SystemMenu::update([ + 'id' => $params['id'], + 'pid' => $params['pid'], + 'type' => $params['type'], + 'name' => $params['name'], + 'icon' => $params['icon'] ?? '', + 'sort' => $params['sort'], + 'perms' => $params['perms'] ?? '', + 'paths' => $params['paths'] ?? '', + 'component' => $params['component'] ?? '', + 'selected' => $params['selected'] ?? '', + 'params' => $params['params'] ?? '', + 'is_cache' => $params['is_cache'], + 'is_show' => $params['is_show'], + 'is_disable' => $params['is_disable'], + ]); + } + + + /** + * @notes 详情 + * @param $params + * @return array + * @author 段誉 + * @date 2022/6/30 9:54 + */ + public static function detail($params) + { + return SystemMenu::findOrEmpty($params['id'])->toArray(); + } + + + /** + * @notes 删除菜单 + * @param $params + * @author 段誉 + * @date 2022/6/30 9:47 + */ + public static function delete($params) + { + // 删除菜单 + SystemMenu::destroy($params['id']); + // 删除角色-菜单表中 与该菜单关联的记录 + SystemRoleMenu::where(['menu_id' => $params['id']])->delete(); + } + + + /** + * @notes 更新状态 + * @param array $params + * @return SystemMenu + * @author 段誉 + * @date 2022/7/6 17:02 + */ + public static function updateStatus(array $params) + { + return SystemMenu::update([ + 'id' => $params['id'], + 'is_disable' => $params['is_disable'] + ]); + } + + /** + * @notes 更新排序 + * @param array $params + * @return SystemMenu + * @author 段誉 + * @date 2022/7/6 17:02 + */ + public static function updateSort(array $params) + { + return SystemMenu::update([ + 'id' => $params['id'], + 'sort' => $params['sort'] + ]); + } + + + /** + * @notes 全部数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 11:03 + */ + public static function getAllData() + { + $data = SystemMenu::where(['is_disable' => YesNoEnum::NO]) + ->field('id,pid,name') + ->order(['sort' => 'desc', 'id' => 'asc']) + ->select() + ->toArray(); + + return linear_to_tree($data, 'children'); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/auth/RoleLogic.php b/app/adminapi/logic/auth/RoleLogic.php new file mode 100644 index 0000000..80c3b91 --- /dev/null +++ b/app/adminapi/logic/auth/RoleLogic.php @@ -0,0 +1,171 @@ + $params['name'], + 'desc' => $params['desc'] ?? '', + 'sort' => $params['sort'] ?? 0, + ]); + + $data = []; + foreach ($menuId as $item) { + if (empty($item)) { + continue; + } + $data[] = [ + 'role_id' => $role['id'], + 'menu_id' => $item, + ]; + } + (new SystemRoleMenu)->insertAll($data); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } + + + /** + * @notes 编辑角色 + * @param array $params + * @return bool + * @author 段誉 + * @date 2021/12/29 14:16 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + $menuId = !empty($params['menu_id']) ? $params['menu_id'] : []; + + SystemRole::update([ + 'id' => $params['id'], + 'name' => $params['name'], + 'desc' => $params['desc'] ?? '', + 'sort' => $params['sort'] ?? 0, + ]); + + if (!empty($menuId)) { + SystemRoleMenu::where(['role_id' => $params['id']])->delete(); + $data = []; + foreach ($menuId as $item) { + $data[] = [ + 'role_id' => $params['id'], + 'menu_id' => $item, + ]; + } + (new SystemRoleMenu)->insertAll($data); + } + + (new AdminAuthCache())->deleteTag(); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } + + /** + * @notes 删除角色 + * @param int $id + * @return bool + * @author 段誉 + * @date 2021/12/29 14:16 + */ + public static function delete(int $id) + { + SystemRole::destroy(['id' => $id]); + (new AdminAuthCache())->deleteTag(); + return true; + } + + + /** + * @notes 角色详情 + * @param int $id + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2021/12/29 14:17 + */ + public static function detail(int $id): array + { + $detail = SystemRole::field('id,name,desc,sort')->find($id); + $authList = $detail->roleMenuIndex()->select()->toArray(); + $menuId = array_column($authList, 'menu_id'); + $detail['menu_id'] = $menuId; + return $detail->toArray(); + } + + + /** + * @notes 角色数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:39 + */ + public static function getAllData() + { + return SystemRole::order(['sort' => 'desc', 'id' => 'desc']) + ->where(' id <> 6') + ->select() + ->toArray(); + } + + +} \ No newline at end of file diff --git a/app/adminapi/logic/crontab/CrontabLogic.php b/app/adminapi/logic/crontab/CrontabLogic.php new file mode 100644 index 0000000..2786ae8 --- /dev/null +++ b/app/adminapi/logic/crontab/CrontabLogic.php @@ -0,0 +1,169 @@ +getMessage()); + return false; + } + } + + + /** + * @notes 查看定时任务详情 + * @param $params + * @return array + * @author 段誉 + * @date 2022/3/29 14:41 + */ + public static function detail($params) + { + $field = 'id,name,type,type as type_desc,command,params,status,status as status_desc,expression,remark'; + $crontab = Crontab::field($field)->findOrEmpty($params['id']); + if ($crontab->isEmpty()) { + return []; + } + return $crontab->toArray(); + } + + + /** + * @notes 编辑定时任务 + * @param $params + * @return bool + * @author 段誉 + * @date 2022/3/29 14:42 + */ + public static function edit($params) + { + try { + $params['remark'] = $params['remark'] ?? ''; + $params['params'] = $params['params'] ?? ''; + + Crontab::update($params); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除定时任务 + * @param $params + * @return bool + * @author 段誉 + * @date 2022/3/29 14:42 + */ + public static function delete($params) + { + try { + Crontab::destroy($params['id']); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 操作定时任务 + * @param $params + * @return bool + * @author 段誉 + * @date 2022/3/29 14:42 + */ + public static function operate($params) + { + try { + $crontab = Crontab::findOrEmpty($params['id']); + if ($crontab->isEmpty()) { + throw new \Exception('定时任务不存在'); + } + switch ($params['operate']) { + case 'start'; + $crontab->status = CrontabEnum::START; + break; + case 'stop': + $crontab->status = CrontabEnum::STOP; + break; + } + $crontab->save(); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 获取规则执行时间 + * @param $params + * @return array|string + * @author 段誉 + * @date 2022/3/29 14:42 + */ + public static function expression($params) + { + try { + $cron = new CronExpression($params['expression']); + $result = $cron->getMultipleRunDates(5); + $result = json_decode(json_encode($result), true); + $lists = []; + foreach ($result as $k => $v) { + $lists[$k]['time'] = $k + 1; + $lists[$k]['date'] = str_replace('.000000', '', $v['date']); + } + $lists[] = ['time' => 'x', 'date' => '……']; + return $lists; + } catch (\Exception $e) { + return $e->getMessage(); + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/decorate/DecorateHintLogic.php b/app/adminapi/logic/decorate/DecorateHintLogic.php new file mode 100644 index 0000000..ce565d2 --- /dev/null +++ b/app/adminapi/logic/decorate/DecorateHintLogic.php @@ -0,0 +1,193 @@ + $params['cid'], + 'title' => $params['title'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'contract_y_logo' => $params['contract_y_logo'] ? FileService::setFileUrl($params['contract_y_logo']) : '', + 'contract_b_logo' => $params['contract_b_logo'] ? FileService::setFileUrl($params['contract_b_logo']) : '', + 'text' => $params['text'], + 'content' => $params['content'] ?? '', + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + // //系统消息则创建用户消息记录 + // if($params['cid'] == 5){ + // $users = User::select()->toArray(); + // foreach ($users as &$user) { + // UserNotice::create([ + // 'user_id' => $user['id'], + // 'hint_id' => $hint['id'], + // 'title' => $params['text'], + // 'content' => $params['content'] ?? '', + // 'notice_type' => 3, + // 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + // ]); + // } + // } + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑提示内容 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/17 17:01 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + $langs = $params['langs']; + + foreach ($langs as &$content_lang) { + if(!empty($content_lang['image'])){ + $content_lang['image'] = FileService::setFileUrl($content_lang['image']); + } + if(!empty($content_lang['content'])){ + $content_lang['content'] = clear_file_domain($content_lang['content']); + } + } + + DecorateHint::update([ + 'id' => $params['id'], + 'title' => $params['title'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'contract_y_logo' => $params['contract_y_logo'] ? FileService::setFileUrl($params['contract_y_logo']) : '', + 'contract_b_logo' => $params['contract_b_logo'] ? FileService::setFileUrl($params['contract_b_logo']) : '', + 'text' => $params['text'], + 'content' => $params['content'] ?? '', + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + // $hint = DecorateHint::where(['id' => $params['id']])->findOrEmpty(); + // //系统消息则创建用户消息记录 + // $cidArr = array(5,6,7); + // if(in_array($hint['cid'], $cidArr)){ + // $notices = UserNotice::where(['hint_id' => $params['id']])->select()->toArray(); + // foreach ($notices as &$notice) { + // UserNotice::update([ + // 'id' => $notice['id'], + // 'title' => $params['text'], + // 'content' => $params['content'] ?? '', + // 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + // ]); + // } + // } + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除提示内容 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/17 17:01 + */ + public static function delete(array $params): bool + { + return DecorateHint::destroy($params['id']); + } + + + /** + * @notes 获取提示内容详情 + * @param $params + * @return array + * @author BD + * @date 2024/03/17 17:01 + */ + public static function detail($params): array + { + return DecorateHint::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 消息列表 + * @param $params + * @return array + * @author BD + * @date 2024/03/17 17:01 + */ + public static function allByType($params) : array + { + $field = ['id', 'text']; + $notices = DecorateHint::field($field) + ->where(['cid' => $params['cid'],'is_show' => 1]) + ->order(['sort' => 'desc','id' => 'desc']) + ->select()->toArray(); + return $notices; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/decorate/DecorateNavLogic.php b/app/adminapi/logic/decorate/DecorateNavLogic.php new file mode 100644 index 0000000..ebdb594 --- /dev/null +++ b/app/adminapi/logic/decorate/DecorateNavLogic.php @@ -0,0 +1,121 @@ + $params['name'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'image_ext' => $params['image_ext'], + 'link' => $params['link'], + 'loca' => $params['loca'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑菜单按钮 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/17 16:41 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + DecorateNav::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'image_ext' => $params['image_ext'], + 'link' => $params['link'], + 'loca' => $params['loca'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除菜单按钮 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/17 16:41 + */ + public static function delete(array $params): bool + { + return DecorateNav::destroy($params['id']); + } + + + /** + * @notes 获取菜单按钮详情 + * @param $params + * @return array + * @author BD + * @date 2024/03/17 16:41 + */ + public static function detail($params): array + { + return DecorateNav::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/decorate/DecorateSwiperLogic.php b/app/adminapi/logic/decorate/DecorateSwiperLogic.php new file mode 100644 index 0000000..221571b --- /dev/null +++ b/app/adminapi/logic/decorate/DecorateSwiperLogic.php @@ -0,0 +1,135 @@ + $params['name'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'image_ext' => $params['image_ext'], + 'link' => $params['link'], + 'loca' => $params['loca'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑轮播图 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/16 17:34 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + + $langs = $params['langs']; + + foreach ($langs as &$content_lang) { + $content_lang['image'] = FileService::setFileUrl($content_lang['image']); + } + + DecorateSwiper::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'image_ext' => $params['image_ext'], + 'link' => $params['link'], + 'loca' => $params['loca'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除轮播图 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/16 17:34 + */ + public static function delete(array $params): bool + { + return DecorateSwiper::destroy($params['id']); + } + + + /** + * @notes 获取轮播图详情 + * @param $params + * @return array + * @author BD + * @date 2024/03/16 17:34 + */ + public static function detail($params): array + { + return DecorateSwiper::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/dept/DeptLogic.php b/app/adminapi/logic/dept/DeptLogic.php new file mode 100644 index 0000000..c39bd65 --- /dev/null +++ b/app/adminapi/logic/dept/DeptLogic.php @@ -0,0 +1,202 @@ +append(['status_desc']) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + $pid = 0; + if (!empty($lists)) { + $pid = min(array_column($lists, 'pid')); + } + return self::getTree($lists, $pid); + } + + + /** + * @notes 列表树状结构 + * @param $array + * @param int $pid + * @param int $level + * @return array + * @author 段誉 + * @date 2022/5/30 15:44 + */ + public static function getTree($array, $pid = 0, $level = 0) + { + $list = []; + foreach ($array as $key => $item) { + if ($item['pid'] == $pid) { + $item['level'] = $level; + $item['children'] = self::getTree($array, $item['id'], $level + 1); + $list[] = $item; + } + } + return $list; + } + + + /** + * @notes 上级部门 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/5/26 18:36 + */ + public static function leaderDept() + { + $lists = Dept::field(['id', 'name'])->where(['status' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + return $lists; + } + + + /** + * @notes 添加部门 + * @param array $params + * @author 段誉 + * @date 2022/5/25 18:20 + */ + public static function add(array $params) + { + Dept::create([ + 'pid' => $params['pid'], + 'name' => $params['name'], + 'leader' => $params['leader'] ?? '', + 'mobile' => $params['mobile'] ?? '', + 'status' => $params['status'], + 'sort' => $params['sort'] ?? 0 + ]); + } + + + /** + * @notes 编辑部门 + * @param array $params + * @return bool + * @author 段誉 + * @date 2022/5/25 18:39 + */ + public static function edit(array $params): bool + { + try { + $pid = $params['pid']; + $oldDeptData = Dept::findOrEmpty($params['id']); + if ($oldDeptData['pid'] == 0) { + $pid = 0; + } + + Dept::update([ + 'id' => $params['id'], + 'pid' => $pid, + 'name' => $params['name'], + 'leader' => $params['leader'] ?? '', + 'mobile' => $params['mobile'] ?? '', + 'status' => $params['status'], + 'sort' => $params['sort'] ?? 0 + ]); + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除部门 + * @param array $params + * @author 段誉 + * @date 2022/5/25 18:40 + */ + public static function delete(array $params) + { + Dept::destroy($params['id']); + } + + + /** + * @notes 获取部门详情 + * @param $params + * @return array + * @author 段誉 + * @date 2022/5/25 18:40 + */ + public static function detail($params): array + { + return Dept::findOrEmpty($params['id'])->toArray(); + } + + + /** + * @notes 部门数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:19 + */ + public static function getAllData() + { + $data = Dept::where(['status' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + $pid = min(array_column($data, 'pid')); + return self::getTree($data, $pid); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/dept/JobsLogic.php b/app/adminapi/logic/dept/JobsLogic.php new file mode 100644 index 0000000..925ea55 --- /dev/null +++ b/app/adminapi/logic/dept/JobsLogic.php @@ -0,0 +1,119 @@ + $params['name'], + 'code' => $params['code'], + 'sort' => $params['sort'] ?? 0, + 'status' => $params['status'], + 'remark' => $params['remark'] ?? '', + ]); + } + + + /** + * @notes 编辑岗位 + * @param array $params + * @return bool + * @author 段誉 + * @date 2022/5/26 9:58 + */ + public static function edit(array $params) : bool + { + try { + Jobs::update([ + 'id' => $params['id'], + 'name' => $params['name'], + 'code' => $params['code'], + 'sort' => $params['sort'] ?? 0, + 'status' => $params['status'], + 'remark' => $params['remark'] ?? '', + ]); + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除岗位 + * @param array $params + * @author 段誉 + * @date 2022/5/26 9:59 + */ + public static function delete(array $params) + { + Jobs::destroy($params['id']); + } + + + /** + * @notes 获取岗位详情 + * @param $params + * @return array + * @author 段誉 + * @date 2022/5/26 9:59 + */ + public static function detail($params) : array + { + return Jobs::findOrEmpty($params['id'])->toArray(); + } + + + /** + * @notes 岗位数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:30 + */ + public static function getAllData() + { + return Jobs::where(['status' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/feedback/FeedbackCateLogic.php b/app/adminapi/logic/feedback/FeedbackCateLogic.php new file mode 100644 index 0000000..d3f55a9 --- /dev/null +++ b/app/adminapi/logic/feedback/FeedbackCateLogic.php @@ -0,0 +1,99 @@ + $params['name'], + 'sort' => $params['sort'], + 'is_show' => $params['is_show'], + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑意见反馈类型 + * @param array $params + * @return bool + * @author BD + * @date 2024/06/06 00:12 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + FeedbackCate::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'sort' => $params['sort'], + 'is_show' => $params['is_show'], + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除意见反馈类型 + * @param array $params + * @return bool + * @author BD + * @date 2024/06/06 00:12 + */ + public static function delete(array $params): bool + { + return FeedbackCate::destroy($params['id']); + } + + + /** + * @notes 获取意见反馈类型详情 + * @param $params + * @return array + * @author BD + * @date 2024/06/06 00:12 + */ + public static function detail($params): array + { + return FeedbackCate::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/feedback/FeedbackRecordLogic.php b/app/adminapi/logic/feedback/FeedbackRecordLogic.php new file mode 100644 index 0000000..3ed382a --- /dev/null +++ b/app/adminapi/logic/feedback/FeedbackRecordLogic.php @@ -0,0 +1,93 @@ +getMessage()); + return false; + } + } + + + /** + * @notes 编辑意见反馈记录 + * @param array $params + * @return bool + * @author BD + * @date 2024/06/06 01:11 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + FeedbackRecord::where('id', $params['id'])->update([ + + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除意见反馈记录 + * @param array $params + * @return bool + * @author BD + * @date 2024/06/06 01:11 + */ + public static function delete(array $params): bool + { + return FeedbackRecord::destroy($params['id']); + } + + + /** + * @notes 获取意见反馈记录详情 + * @param $params + * @return array + * @author BD + * @date 2024/06/06 01:11 + */ + public static function detail($params): array + { + return FeedbackRecord::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/finance/RechargeRecordLogic.php b/app/adminapi/logic/finance/RechargeRecordLogic.php new file mode 100644 index 0000000..044db58 --- /dev/null +++ b/app/adminapi/logic/finance/RechargeRecordLogic.php @@ -0,0 +1,279 @@ +isEmpty()) { + throw new \Exception('记录不存在'); + } + if ($record['status']!=0) { + throw new \Exception('状态异常'); + } + + $user = User::where(['id' => $record['user_id']])->findOrEmpty(); + if ($record->isEmpty()) { + throw new \Exception('用户不存在'); + } + + RechargeRecord::update([ + 'id' => $params['id'], + 'status' => 1 + ]); + + //记录日志 + UtilsService::user_finance_add( + $record['user_id'], + 1, + 1, + $record['amount'], + $record['sn'], + '', + 1//冻结 + ); + + //用户资金修改 + UtilsService::user_money_change($record['user_id'], 1, $record['amount'],'user_money'); + + //充值金额增加 + UtilsService::user_money_change($record['user_id'], 1, $record['amount'],'total_recharge'); + + //团队充值奖励 + // UtilsService::team_reward_add($record['user_id'],$record['amount'],1); + + //充值活动奖励 + UtilsService::activity_reward_add($record['user_id'],$record['amount']); + + //更新充值记录用户余额 + $user = User::where(['id' => $record['user_id']])->findOrEmpty(); + if ($user->isEmpty()) { + throw new \Exception('用户不存在'); + } + + //充值次数+1 + User::update([ + 'id' => $user['id'], + 'recharge_num' => $user['recharge_num'] + 1 + ]); + + RechargeRecord::update([ + 'id' => $params['id'], + 'user_money' => $user['user_money'] + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 拒绝充值 + * @param array $params + * @return bool + * @author bd + * @date 2024/01/31 14:07 + */ + public static function refuse(array $params): bool + { + Db::startTrans(); + try { + $record = RechargeRecord::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + if ($record['status']!=0) { + throw new \Exception('状态异常'); + } + RechargeRecord::update([ + 'id' => $params['id'], + 'status' => 2 + ]); + + //更新充值记录用户余额 + $user = User::where(['id' => $record['user_id']])->findOrEmpty(); + if ($user->isEmpty()) { + throw new \Exception('用户不存在'); + } + RechargeRecord::update([ + 'id' => $params['id'], + 'user_money' => $user['user_money'] + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 充值记录备注 + * @param array $params + * @return bool + * @author bd + * @date 2024/01/31 14:07 + */ + public static function remark(array $params): bool + { + Db::startTrans(); + try { + $record = RechargeRecord::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + //代理操作需查询是否有权限 + $user = User::where(['agent_id' => $params['admin_id']])->findOrEmpty(); + if (!$user->isEmpty()) { + $userRelation = UserRelationAgent::where(['user_id' => $record['user_id'],'parent_id' => $user['id']])->findOrEmpty(); + if ($userRelation->isEmpty()) { + throw new \Exception('参数异常'); + } + } + + RechargeRecord::update([ + 'id' => $params['id'], + 'remark2' => $params['content'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 修改充值金额 + * @param array $params + * @return bool + * @author bd + * @date 2024/01/31 14:07 + */ + public static function changeAmount(array $params): bool + { + Db::startTrans(); + try { + $record = RechargeRecord::where(['status' => 0])->find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + + if($params['amount'] <= 0){ + throw new \Exception('请输入正确的金额'); + } + + $precision = 2; + $method = RechargeMethod::find($record['method_id']); + if (!$method->isEmpty()) { + $precision = $method['precision']; + } + + $amount_act = round($params['amount'] * $method['rate'] , $precision); + + RechargeRecord::update([ + 'id' => $params['id'], + 'amount' => $params['amount'], + 'amount_act' => $amount_act, + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 新充值提现条数 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author bd + * @date 2024/01/31 14:07 + */ + public static function warmCount() + { + $rechargeCount = RechargeRecord::where(['status' => 0])->count(); + $withdrawCount = WithdrawRecord::where(['status' => 0])->count(); + // $orderCount = GoodsRecord::where(['status' => 5])->count(); + + return [ + 'recharge' => $rechargeCount, + 'withdraw' => $withdrawCount, + // 'order' => $orderCount + ]; + } + + /** + * @notes 充值统计 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author bd + * @date 2024/01/31 14:07 + */ + public static function stat() + { + $total = RechargeRecord::sum('amount'); + $ing = RechargeRecord::where(['status' => 0])->sum('amount'); + $success = RechargeRecord::where(['status' => 1])->sum('amount'); + $error = RechargeRecord::where(['status' => 2])->sum('amount'); + + return [ + 'total' => round($total, 2), + 'ing' => round($ing, 2), + 'success' => round($success, 2), + 'error' => round($error, 2), + ]; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/finance/UserFinanceLogic.php b/app/adminapi/logic/finance/UserFinanceLogic.php new file mode 100644 index 0000000..c8df5f2 --- /dev/null +++ b/app/adminapi/logic/finance/UserFinanceLogic.php @@ -0,0 +1,157 @@ + $params['sn'], + 'user_id' => $params['user_id'], + 'change_object' => $params['change_object'], + 'change_type' => $params['change_type'], + 'action' => $params['action'], + 'change_amount' => $params['change_amount'], + 'left_amount' => $params['left_amount'], + 'source_sn' => $params['source_sn'], + 'remark' => $params['remark'], + 'extra' => $params['extra'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑资金明细 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/07 13:10 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserFinance::where('id', $params['id'])->update([ + 'sn' => $params['sn'], + 'user_id' => $params['user_id'], + 'change_object' => $params['change_object'], + 'change_type' => $params['change_type'], + 'action' => $params['action'], + 'change_amount' => $params['change_amount'], + 'left_amount' => $params['left_amount'], + 'source_sn' => $params['source_sn'], + 'remark' => $params['remark'], + 'extra' => $params['extra'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除资金明细 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/07 13:10 + */ + public static function delete(array $params): bool + { + return UserFinance::destroy($params['id']); + } + + + /** + * @notes 获取资金明细详情 + * @param $params + * @return array + * @author BD + * @date 2024/03/07 13:10 + */ + public static function detail($params): array + { + return UserFinance::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 解冻 + * @param array $params + * @return bool + * @author bd + * @date 2024/01/31 14:07 + */ + public static function unfrozen(array $params): bool + { + Db::startTrans(); + try { + $record = UserFinance::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + if ($record['frozen']!=1) { + throw new \Exception('状态异常'); + } + UserFinance::update([ + 'id' => $params['id'], + 'frozen' => 0, + 'thaw_time' => time(), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/finance/WithdrawRecordLogic.php b/app/adminapi/logic/finance/WithdrawRecordLogic.php new file mode 100644 index 0000000..d32efac --- /dev/null +++ b/app/adminapi/logic/finance/WithdrawRecordLogic.php @@ -0,0 +1,292 @@ +isEmpty()) { + throw new \Exception('记录不存在'); + } + if ($record['status']!=0) { + throw new \Exception('状态异常'); + } + + //重新发起代付需修改订单号 + if($record['remark_df'] != ''){ + $record['sn'] = generate_sn(WithdrawRecord::class, 'sn'); + } + + $udun = ConfigService::get('website', 'udun'); + + if($udun['is_open_df'] == 0){ + throw new \Exception('请先开启代付'); + } + + $method = WithdrawMethod::where(['id' => $record['method_id']])->findOrEmpty(); + if ($method->isEmpty()) { + throw new \Exception('提现方式不存在'); + } + + if ($method['is_open_df'] == 0) { + throw new \Exception('该记录提现方式未开启代付'); + } + + $main_coin_type = $method['main_coin_type']; + $coin_type = $method['coin_type']; + + $udunDispatch = UtilsService::get_udunDispatch(); + //验证地址合法性 + $result1 = $udunDispatch->checkAddress($main_coin_type,$record['account']); + + if($result1['code'] == 200){ + + //申请提币 + $amount_df = round($record['amount']- $record['charge'],2); + $result2 = $udunDispatch->withdraw($record['sn'],$main_coin_type,$coin_type,$record['account'],$amount_df); + if($result2['code'] == 200){ + WithdrawRecord::update([ + 'id' => $record['id'], + 'status2' => 1, + 'remark_df' => '', + 'sn' => $record['sn'] + ]); + } + } + + + Db::commit(); + return 'success'; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return 'fail'; + } + } + + + /** + * @notes 同意提现 + * @param array $params + * @return bool + * @author bd + * @date 2024/01/31 14:07 + */ + public static function agree(array $params): bool + { + Db::startTrans(); + try { + $record = WithdrawRecord::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + if ($record['status']!=0) { + throw new \Exception('状态异常'); + } + WithdrawRecord::update([ + 'id' => $params['id'], + 'status' => 1, + 'status2' => 0, + 'remark_df' => '', + ]); + + //更新充值记录用户余额 + $user = User::where(['id' => $record['user_id']])->findOrEmpty(); + if ($user->isEmpty()) { + throw new \Exception('用户不存在'); + } + + //提现次数+1 + User::update([ + 'id' => $user['id'], + 'withdraw_num' => $user['withdraw_num'] + 1 + ]); + + WithdrawRecord::update([ + 'id' => $params['id'], + 'user_money' => $user['user_money'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 拒绝提现 + * @param array $params + * @return bool + * @author bd + * @date 2024/01/31 14:07 + */ + public static function refuse(array $params): bool + { + Db::startTrans(); + try { + $record = WithdrawRecord::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + if ($record['status']!=0) { + throw new \Exception('状态异常'); + } + WithdrawRecord::update([ + 'id' => $params['id'], + 'status' => 2, + 'remark' => $params['remark'], + 'status2' => 0, + 'remark_df' => '', + ]); + + //返还提现金额 + //记录日志 + UtilsService::user_finance_add( + $record['user_id'], + 3, + 1, + $record['amount'], + $record['sn'], + $params['remark'] + ); + + //用户资金修改 + UtilsService::user_money_change($record['user_id'], 1, $record['amount'],'user_money'); + //提现金额修改 + UtilsService::user_money_change($record['user_id'], 2, $record['amount'],'total_withdraw'); + + //更新充值记录用户余额 + $user = User::where(['id' => $record['user_id']])->findOrEmpty(); + if ($user->isEmpty()) { + throw new \Exception('用户不存在'); + } + WithdrawRecord::update([ + 'id' => $params['id'], + 'user_money' => $user['user_money'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 提现记录备注 + * @param array $params + * @return bool + * @author bd + * @date 2024/01/31 14:07 + */ + public static function remark(array $params): bool + { + Db::startTrans(); + try { + $record = WithdrawRecord::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + + //代理操作需查询是否有权限 + $user = User::where(['agent_id' => $params['admin_id']])->findOrEmpty(); + if (!$user->isEmpty()) { + $userRelation = UserRelationAgent::where(['user_id' => $record['user_id'],'parent_id' => $user['id']])->findOrEmpty(); + if ($userRelation->isEmpty()) { + throw new \Exception('参数异常'); + } + } + + WithdrawRecord::update([ + 'id' => $params['id'], + 'remark2' => $params['content'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 提现统计 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author bd + * @date 2024/01/31 14:07 + */ + public static function stat() + { + $total = WithdrawRecord::sum('amount'); + $ing = WithdrawRecord::where(['status' => 0])->sum('amount'); + $success = WithdrawRecord::where(['status' => 1])->sum('amount'); + $error = WithdrawRecord::where(['status' => 2])->sum('amount'); + + return [ + 'total' => round($total, 2), + 'ing' => round($ing, 2), + 'success' => round($success, 2), + 'error' => round($error, 2), + ]; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/goods/GoodsCateLogic.php b/app/adminapi/logic/goods/GoodsCateLogic.php new file mode 100644 index 0000000..0b2ce9c --- /dev/null +++ b/app/adminapi/logic/goods/GoodsCateLogic.php @@ -0,0 +1,129 @@ + $params['name'], + 'sort' => $params['sort'], + 'is_show' => $params['is_show'], + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑商品分类 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/11 01:58 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + GoodsCate::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'sort' => $params['sort'], + 'is_show' => $params['is_show'], + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除商品分类 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/11 01:58 + */ + public static function delete(array $params): bool + { + return GoodsCate::destroy($params['id']); + } + + + /** + * @notes 获取商品分类详情 + * @param $params + * @return array + * @author BD + * @date 2024/03/11 01:58 + */ + public static function detail($params): array + { + return GoodsCate::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 商品分类数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/11 01:58 + */ + public static function getAllData() + { + return GoodsCate::where(['is_show' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/goods/GoodsLogic.php b/app/adminapi/logic/goods/GoodsLogic.php new file mode 100644 index 0000000..845b664 --- /dev/null +++ b/app/adminapi/logic/goods/GoodsLogic.php @@ -0,0 +1,132 @@ + $params['cid'], + 'title' => $params['title'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'money' => $params['money'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑商品 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/11 01:58 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + $langs = $params['langs']; + + // foreach ($langs as &$content_lang) { + // $content_lang['image'] = FileService::setFileUrl($content_lang['image']); + // } + + Goods::where('id', $params['id'])->update([ + 'cid' => $params['cid'], + 'title' => $params['title'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'money' => $params['money'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除商品 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/11 01:58 + */ + public static function delete(array $params): bool + { + return Goods::destroy($params['id']); + } + + + /** + * @notes 获取商品详情 + * @param $params + * @return array + * @author BD + * @date 2024/03/11 01:58 + */ + public static function detail($params): array + { + return Goods::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/goods/GoodsRecordLogic.php b/app/adminapi/logic/goods/GoodsRecordLogic.php new file mode 100644 index 0000000..26a8c36 --- /dev/null +++ b/app/adminapi/logic/goods/GoodsRecordLogic.php @@ -0,0 +1,101 @@ + $params['id']])->findOrEmpty(); + + if ($order->isEmpty()) { + throw new \Exception('订单不存在'); + } + $goods = Goods::where(['id' => $params['goods_id']])->findOrEmpty(); + if ($goods->isEmpty()) { + throw new \Exception('商品不存在'); + } + //多语言替换 + $data = UtilsService::get_langs_data($goods['langs'],$order['lang']); + $goods['title'] = $data['title']; + + //查询会员等级 + //查询会员等级 + $member_id = UtilsService::get_user_member_id($order['user_id']); + $member = UserMember::where(['id' => $member_id])->findOrEmpty(); + + //数量 + $num = $params['num']; + + //计算佣金 + $commission = round($goods['money'] * $num * $member['commission']/100,2); + + GoodsRecord::update([ + 'id' => $params['id'], + 'goods_id' => $goods['id'], + 'goods_title' => $goods['title'], + 'goods_image' => FileService::setFileUrl($goods['image']) , + 'unit_price' => $goods['money'], + 'num' => $num, + 'money' => $goods['money'] * $num, + 'commission' => $commission, + 'status' => 4 + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/item/ItemCateLogic.php b/app/adminapi/logic/item/ItemCateLogic.php new file mode 100644 index 0000000..eac2dd8 --- /dev/null +++ b/app/adminapi/logic/item/ItemCateLogic.php @@ -0,0 +1,152 @@ + $params['name'], + 'sort' => $params['sort'], + 'is_show' => $params['is_show'], + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑项目分类 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + ItemCate::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'sort' => $params['sort'], + 'is_show' => $params['is_show'], + 'langs' => json_encode($params['langs'], JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除项目分类 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public static function delete(array $params): bool + { + return ItemCate::destroy($params['id']); + } + + + /** + * @notes 获取项目分类详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public static function detail($params): array + { + $itemCate = ItemCate::findOrEmpty($params['id'])->toArray(); + + $langs = json_decode($articleCate['langs'], true); + if(empty($langs)){ + $langs = []; + } + $itemCate['langs'] = $langs; + return $itemCate; + } + + /** + * @notes 更改项目分类状态 + * @param array $params + * @return bool + * @author heshihu + * @date 2022/2/21 18:04 + */ + public static function updateStatus(array $params) + { + ItemCate::update([ + 'id' => $params['id'], + 'is_show' => $params['is_show'] + ]); + return true; + } + + /** + * @notes 项目分类数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:53 + */ + public static function getAllData() + { + return ItemCate::where(['is_show' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/item/ItemLogic.php b/app/adminapi/logic/item/ItemLogic.php new file mode 100644 index 0000000..ec1390b --- /dev/null +++ b/app/adminapi/logic/item/ItemLogic.php @@ -0,0 +1,173 @@ + $params['cid'], + 'type' => $params['type'], + 'title' => $params['title'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'content' => $params['content'], + 'min_money' => $params['min_money'], + 'max_money' => $params['max_money'], + 'rate' => $params['rate'], + 'cycle' => $params['cycle'], + 'point' => $params['point'], + 'member_id' => $params['member_id'], + 'progress' => $params['progress'], + 'progress_auto' => $params['progress_auto'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑项目 + * @param array $params + * @return bool + * @author BD + * @date 2024/01/16 13:23 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + $langs = $params['langs']; + + foreach ($langs as &$content_lang) { + $content_lang['image'] = FileService::setFileUrl($content_lang['image']); + $content_lang['content'] = clear_file_domain($content_lang['content']); + } + Item::update([ + 'id' => $params['id'], + 'cid' => $params['cid'], + 'type' => $params['type'], + 'title' => $params['title'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'content' => $params['content'], + 'min_money' => $params['min_money'], + 'max_money' => $params['max_money'], + 'rate' => $params['rate'], + 'cycle' => $params['cycle'], + 'point' => $params['point'], + 'member_id' => $params['member_id'], + 'progress' => $params['progress'], + 'progress_auto' => $params['progress_auto'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除项目 + * @param array $params + * @return bool + * @author BD + * @date 2024/01/16 13:23 + */ + public static function delete(array $params): bool + { + return Item::destroy($params['id']); + } + + + /** + * @notes 获取项目详情 + * @param $params + * @return array + * @author BD + * @date 2024/01/16 13:23 + */ + public static function detail($params): array + { + $item = Item::findOrEmpty($params['id'])->toArray(); + $langs = json_decode($item['langs'], true); + if(empty($langs)){ + $langs = []; + } + $item['langs'] = $langs; + return $item; + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author BD + * @date 2023/9/22 16:38 + */ + public static function updateIndexStatus(array $params) + { + Item::update([ + 'id' => $params['id'], + 'is_index' => $params['is_index'] + ]); + return true; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/item/ItemRecordLogic.php b/app/adminapi/logic/item/ItemRecordLogic.php new file mode 100644 index 0000000..3c7a30a --- /dev/null +++ b/app/adminapi/logic/item/ItemRecordLogic.php @@ -0,0 +1,121 @@ + $params['sn'], + 'contract_no' => $params['contract_no'], + 'user_id' => $params['user_id'], + 'item_id' => $params['item_id'], + 'item_title' => $params['item_title'], + 'item_image' => $params['item_image'], + 'money' => $params['money'], + 'rate' => $params['rate'], + 'cycle' => $params['cycle'], + 'total_num' => $params['total_num'], + 'wait_num' => $params['wait_num'], + 'type' => $params['type'], + 'status' => $params['status'], + 'remark' => $params['remark'], + 'end_time' => strtotime($params['end_time']) + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑项目记录 + * @param array $params + * @return bool + * @author BD + * @date 2024/08/07 15:42 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + ItemRecord::where('id', $params['id'])->update([ + 'sn' => $params['sn'], + 'contract_no' => $params['contract_no'], + 'user_id' => $params['user_id'], + 'item_id' => $params['item_id'], + 'item_title' => $params['item_title'], + 'item_image' => $params['item_image'], + 'money' => $params['money'], + 'rate' => $params['rate'], + 'cycle' => $params['cycle'], + 'total_num' => $params['total_num'], + 'wait_num' => $params['wait_num'], + 'type' => $params['type'], + 'status' => $params['status'], + 'remark' => $params['remark'], + 'end_time' => strtotime($params['end_time']) + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除项目记录 + * @param array $params + * @return bool + * @author BD + * @date 2024/08/07 15:42 + */ + public static function delete(array $params): bool + { + return ItemRecord::destroy($params['id']); + } + + + /** + * @notes 获取项目记录详情 + * @param $params + * @return array + * @author BD + * @date 2024/08/07 15:42 + */ + public static function detail($params): array + { + return ItemRecord::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/lh/LhCoinLogic.php b/app/adminapi/logic/lh/LhCoinLogic.php new file mode 100644 index 0000000..94c3350 --- /dev/null +++ b/app/adminapi/logic/lh/LhCoinLogic.php @@ -0,0 +1,110 @@ + $params['name'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'symbol' => $params['symbol'], + 'symbol_market' => $params['symbol_market'], + 'price' => $params['price'], + 'buy_name' => $params['buy_name'], + 'sale_name' => $params['sale_name'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑量化货币 + * @param array $params + * @return bool + * @author BD + * @date 2024/05/19 21:13 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + LhCoin::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'symbol' => $params['symbol'], + 'symbol_market' => $params['symbol_market'], + 'price' => $params['price'], + 'buy_name' => $params['buy_name'], + 'sale_name' => $params['sale_name'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除量化货币 + * @param array $params + * @return bool + * @author BD + * @date 2024/05/19 21:13 + */ + public static function delete(array $params): bool + { + return LhCoin::destroy($params['id']); + } + + + /** + * @notes 获取量化货币详情 + * @param $params + * @return array + * @author BD + * @date 2024/05/19 21:13 + */ + public static function detail($params): array + { + return LhCoin::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/lh/LhRecordLogic.php b/app/adminapi/logic/lh/LhRecordLogic.php new file mode 100644 index 0000000..3cd2a04 --- /dev/null +++ b/app/adminapi/logic/lh/LhRecordLogic.php @@ -0,0 +1,93 @@ +getMessage()); + return false; + } + } + + + /** + * @notes 编辑量化记录 + * @param array $params + * @return bool + * @author BD + * @date 2024/05/19 21:13 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + LhRecord::where('id', $params['id'])->update([ + + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除量化记录 + * @param array $params + * @return bool + * @author BD + * @date 2024/05/19 21:13 + */ + public static function delete(array $params): bool + { + return LhRecord::destroy($params['id']); + } + + + /** + * @notes 获取量化记录详情 + * @param $params + * @return array + * @author BD + * @date 2024/05/19 21:13 + */ + public static function detail($params): array + { + return LhRecord::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/mall/MallGoodsLogic.php b/app/adminapi/logic/mall/MallGoodsLogic.php new file mode 100644 index 0000000..704a21c --- /dev/null +++ b/app/adminapi/logic/mall/MallGoodsLogic.php @@ -0,0 +1,119 @@ + $params['title'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'price' => $params['price'], + 'money' => $params['money'], + 'point' => $params['point'], + 'win_rate' => $params['win_rate'], + 'num' => $params['num'], + 'type' => $params['type'], + 'type2' => $params['type2'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑积分、抽奖奖品 + * @param array $params + * @return bool + * @author BD + * @date 2024/10/14 23:57 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + $langs = $params['langs']; + + MallGoods::where('id', $params['id'])->update([ + 'title' => $params['title'], + 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', + 'price' => $params['price'], + 'money' => $params['money'], + 'point' => $params['point'], + 'win_rate' => $params['win_rate'], + 'num' => $params['num'], + 'type' => $params['type'], + 'type2' => $params['type2'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'], + 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除积分、抽奖奖品 + * @param array $params + * @return bool + * @author BD + * @date 2024/10/14 23:57 + */ + public static function delete(array $params): bool + { + return MallGoods::destroy($params['id']); + } + + + /** + * @notes 获取积分、抽奖奖品详情 + * @param $params + * @return array + * @author BD + * @date 2024/10/14 23:57 + */ + public static function detail($params): array + { + return MallGoods::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/mall/MallGoodsRecordLogic.php b/app/adminapi/logic/mall/MallGoodsRecordLogic.php new file mode 100644 index 0000000..b0e2b85 --- /dev/null +++ b/app/adminapi/logic/mall/MallGoodsRecordLogic.php @@ -0,0 +1,115 @@ + $params['sn'], + 'user_id' => $params['user_id'], + 'm_goods_id' => $params['m_goods_id'], + 'm_goods_title' => $params['m_goods_title'], + 'm_goods_image' => $params['m_goods_image'], + 'm_goods_langs' => $params['m_goods_langs'], + 'price' => $params['price'], + 'money' => $params['money'], + 'point' => $params['point'], + 'status' => $params['status'], + 'type' => $params['type'], + 'type2' => $params['type2'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑奖品记录 + * @param array $params + * @return bool + * @author BD + * @date 2024/10/15 14:00 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + MallGoodsRecord::where('id', $params['id'])->update([ + 'sn' => $params['sn'], + 'user_id' => $params['user_id'], + 'm_goods_id' => $params['m_goods_id'], + 'm_goods_title' => $params['m_goods_title'], + 'm_goods_image' => $params['m_goods_image'], + 'm_goods_langs' => $params['m_goods_langs'], + 'price' => $params['price'], + 'money' => $params['money'], + 'point' => $params['point'], + 'status' => $params['status'], + 'type' => $params['type'], + 'type2' => $params['type2'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除奖品记录 + * @param array $params + * @return bool + * @author BD + * @date 2024/10/15 14:00 + */ + public static function delete(array $params): bool + { + return MallGoodsRecord::destroy($params['id']); + } + + + /** + * @notes 获取奖品记录详情 + * @param $params + * @return array + * @author BD + * @date 2024/10/15 14:00 + */ + public static function detail($params): array + { + return MallGoodsRecord::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/member/UserMemberLogic.php b/app/adminapi/logic/member/UserMemberLogic.php new file mode 100644 index 0000000..8f27660 --- /dev/null +++ b/app/adminapi/logic/member/UserMemberLogic.php @@ -0,0 +1,209 @@ + $params['name'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'bg_img' => $params['bg_img'] ? FileService::setFileUrl($params['bg_img']) : '', + 'text_color' => $params['text_color'], + 'money' => $params['money'], + 'level1_num' => $params['level1_num'], + 'level1_vip_id' => $params['level1_vip_id'], + 'lh_min' => $params['lh_min'], + 'lh_max' => $params['lh_max'], + 'rate_min' => $params['rate_min'], + 'rate_max' => $params['rate_max'], + 'item_add_rate' => $params['item_add_rate'], + 'lh_num' => $params['lh_num'], + 'item_num' => $params['item_num'], + 'is_show' => $params['is_show'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑会员等级 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/14 00:28 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + //会员次数 + if($params['is_show'] == 0){ + $count = UserMemberRecord::where(['member_id' => $params['id']])->count(); + if($count > 0){ + throw new \Exception('该会员等级下存在用户,不可隐藏'); + } + } + + UserMember::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'bg_img' => $params['bg_img'] ? FileService::setFileUrl($params['bg_img']) : '', + 'text_color' => $params['text_color'], + 'money' => $params['money'], + 'level1_num' => $params['level1_num'], + 'level1_vip_id' => $params['level1_vip_id'], + 'lh_min' => $params['lh_min'], + 'lh_max' => $params['lh_max'], + 'rate_min' => $params['rate_min'], + 'rate_max' => $params['rate_max'], + 'item_add_rate' => $params['item_add_rate'], + 'lh_num' => $params['lh_num'], + 'item_num' => $params['item_num'], + 'is_show' => $params['is_show'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除会员等级 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/14 00:28 + */ + public static function delete(array $params): bool + { + return UserMember::destroy($params['id']); + } + + + /** + * @notes 获取会员等级详情 + * @param $params + * @return array + * @author BD + * @date 2024/03/14 00:28 + */ + public static function detail($params): array + { + return UserMember::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 设置用户会员等级 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/19 02:29 + */ + public static function setUserMember(array $params): bool + { + Db::startTrans(); + try { + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + + if ($user->isEmpty()) { + throw new \Exception('用户不存在'); + } + $member = UserMember::where(['id' => $params['member_id']])->findOrEmpty(); + if ($member->isEmpty()) { + throw new \Exception('会员等级不存在'); + } + $data = [ + 'user_id' => $params['user_id'], + 'member_id' => $params['member_id'], + ]; + + //查询用户会员等级 + $record = UserMemberRecord::where(['user_id' => $params['user_id']])->findOrEmpty(); + + if ($record->isEmpty()) { + UserMemberRecord::create($data); + }else{ + $data['id'] = $record['id']; + UserMemberRecord::update($data); + } + + User::where('id',$params['user_id'])->update(['auto_member' => 0]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 会员等级数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/03/11 01:58 + */ + public static function getAllData() + { + return UserMember::field(['id', 'name', 'logo', 'bg_img', 'text_color', 'money', 'level1_num', 'level1_vip_id', 'item_num', 'item_add_rate']) + ->append(['vip_name']) + ->where(['is_show' => 1]) + ->order(['money' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/notice/NoticeLogic.php b/app/adminapi/logic/notice/NoticeLogic.php new file mode 100644 index 0000000..97a010a --- /dev/null +++ b/app/adminapi/logic/notice/NoticeLogic.php @@ -0,0 +1,226 @@ +findOrEmpty($params['id'])->toArray(); + if (empty($noticeSetting)) { + return []; + } + if (empty($noticeSetting['system_notice'])) { + $noticeSetting['system_notice'] = [ + 'title' => '', + 'content' => '', + 'status' => 0, + ]; + } + $noticeSetting['system_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::SYSTEM, $noticeSetting['scene_id']); + if (empty($noticeSetting['sms_notice'])) { + $noticeSetting['sms_notice'] = [ + 'template_id' => '', + 'content' => '', + 'content_en' => '', + 'status' => 0, + ]; + } + $noticeSetting['sms_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::SMS, $noticeSetting['scene_id']); + if (empty($noticeSetting['oa_notice'])) { + $noticeSetting['oa_notice'] = [ + 'template_id' => '', + 'template_sn' => '', + 'name' => '', + 'first' => '', + 'remark' => '', + 'tpl' => [], + 'status' => 0, + ]; + } + $noticeSetting['oa_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::MNP, $noticeSetting['scene_id']); + if (empty($noticeSetting['mnp_notice'])) { + $noticeSetting['mnp_notice'] = [ + 'template_id' => '', + 'template_sn' => '', + 'name' => '', + 'tpl' => [], + 'status' => 0, + ]; + } + $noticeSetting['mnp_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::MNP, $noticeSetting['scene_id']); + $noticeSetting['system_notice']['is_show'] = in_array(NoticeEnum::SYSTEM, explode(',', $noticeSetting['support'])); + $noticeSetting['sms_notice']['is_show'] = in_array(NoticeEnum::SMS, explode(',', $noticeSetting['support'])); + $noticeSetting['oa_notice']['is_show'] = in_array(NoticeEnum::OA, explode(',', $noticeSetting['support'])); + $noticeSetting['mnp_notice']['is_show'] = in_array(NoticeEnum::MNP, explode(',', $noticeSetting['support'])); + $noticeSetting['default'] = ''; + $noticeSetting['type'] = NoticeEnum::getTypeDesc($noticeSetting['type']); + return $noticeSetting; + } + + + /** + * @notes 通知设置 + * @param $params + * @return bool + * @author 段誉 + * @date 2022/3/29 11:34 + */ + public static function set($params) + { + try { + // 校验参数 + self::checkSet($params); + // 拼装更新数据 + $updateData = []; + foreach ($params['template'] as $item) { + $updateData[$item['type'] . '_notice'] = json_encode($item, JSON_UNESCAPED_UNICODE); + } + // 更新通知设置 + NoticeSetting::where('id', $params['id'])->update($updateData); + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 校验参数 + * @param $params + * @throws \Exception + * @author 段誉 + * @date 2022/3/29 11:35 + */ + public static function checkSet($params) + { + $noticeSetting = NoticeSetting::findOrEmpty($params['id'] ?? 0); + + if ($noticeSetting->isEmpty()) { + throw new \Exception('通知配置不存在'); + } + + if (!isset($params['template']) || !is_array($params['template']) || count($params['template']) == 0) { + throw new \Exception('模板配置不存在或格式错误'); + } + + // 通知类型 + $noticeType = ['system', 'sms', 'oa', 'mnp']; + + foreach ($params['template'] as $item) { + if (!is_array($item)) { + throw new \Exception('模板项格式错误'); + } + + if (!isset($item['type']) || !in_array($item['type'], $noticeType)) { + throw new \Exception('模板项缺少模板类型或模板类型有误'); + } + + switch ($item['type']) { + case "system"; + self::checkSystem($item); + break; + case "sms"; + self::checkSms($item); + break; + case "oa"; + self::checkOa($item); + break; + case "mnp"; + self::checkMnp($item); + break; + } + } + } + + + /** + * @notes 校验系统通知参数 + * @param $item + * @throws \Exception + * @author 段誉 + * @date 2022/3/29 11:35 + */ + public static function checkSystem($item) + { + if (!isset($item['title']) || !isset($item['content']) || !isset($item['status'])) { + throw new \Exception('系统通知必填参数:title、content、status'); + } + } + + + /** + * @notes 校验短信通知必填参数 + * @param $item + * @throws \Exception + * @author 段誉 + * @date 2022/3/29 11:35 + */ + public static function checkSms($item) + { + if (!isset($item['template_id']) || !isset($item['content']) || !isset($item['status'])) { + throw new \Exception('短信通知必填参数:template_id、content、status'); + } + } + + + /** + * @notes 校验微信模板消息参数 + * @param $item + * @throws \Exception + * @author 段誉 + * @date 2022/3/29 11:35 + */ + public static function checkOa($item) + { + if (!isset($item['template_id']) || !isset($item['template_sn']) || !isset($item['name']) || !isset($item['first']) || !isset($item['remark']) || !isset($item['tpl']) || !isset($item['status'])) { + throw new \Exception('微信模板消息必填参数:template_id、template_sn、name、first、remark、tpl、status'); + } + } + + + /** + * @notes 校验微信小程序提醒必填参数 + * @param $item + * @throws \Exception + * @author 段誉 + * @date 2022/3/29 11:35 + */ + public static function checkMnp($item) + { + if (!isset($item['template_id']) || !isset($item['template_sn']) || !isset($item['name']) || !isset($item['tpl']) || !isset($item['status'])) { + throw new \Exception('微信模板消息必填参数:template_id、template_sn、name、tpl、status'); + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/notice/SmsConfigLogic.php b/app/adminapi/logic/notice/SmsConfigLogic.php new file mode 100644 index 0000000..aa91041 --- /dev/null +++ b/app/adminapi/logic/notice/SmsConfigLogic.php @@ -0,0 +1,140 @@ + 'ali', 'name' => '阿里云短信', 'status' => 1]), + // ConfigService::get('sms', 'tencent', ['type' => 'tencent', 'name' => '腾讯云短信', 'status' => 0]), + ConfigService::get('sms', 'smsbao', ['type' => 'smsbao', 'name' => '短信宝短信', 'status' => 0]), + ]; + return $config; + } + + + /** + * @notes 短信配置 + * @param $params + * @return bool|void + * @author 段誉 + * @date 2022/3/29 11:37 + */ + public static function setConfig($params) + { + $type = $params['type']; + $params['name'] = self::getNameDesc(strtoupper($type)); + ConfigService::set('sms', $type, $params); + $default = ConfigService::get('sms', 'engine', false); + if ($params['status'] == 1 && $default === false) { + // 启用当前短信配置 并 设置当前短信配置为默认 + ConfigService::set('sms', 'engine', strtoupper($type)); + return true; + } + if ($params['status'] == 1 && $default != strtoupper($type)) { + // 找到默认短信配置 + $defaultConfig = ConfigService::get('sms', strtolower($default)); + // 状态置为禁用 并 更新 + $defaultConfig['status'] = 0; + ConfigService::set('sms', strtolower($default), $defaultConfig); + // 设置当前短信配置为默认 + ConfigService::set('sms', 'engine', strtoupper($type)); + return true; + } + } + + + /** + * @notes 查看短信配置详情 + * @param $params + * @return array|int|mixed|string|null + * @author 段誉 + * @date 2022/3/29 11:37 + */ + public static function detail($params) + { + $default = []; + switch ($params['type']) { + case 'ali': + $default = [ + 'sign' => '', + 'app_key' => '', + 'secret_key' => '', + 'status' => 1, + 'name' => '阿里云短信', + ]; + break; + case 'tencent': + $default = [ + 'sign' => '', + 'app_id' => '', + 'secret_key' => '', + 'status' => 0, + 'secret_id' => '', + 'name' => '腾讯云短信', + ]; + break; + case 'smsbao': + $default = [ + 'sign' => '', + 'username' => '', + 'url_cn' => '', + 'url_go' => '', + 'status' => 0, + 'api_key' => '', + 'name' => '短信宝短信', + ]; + break; + } + $result = ConfigService::get('sms', $params['type'], $default); + $result['status'] = intval($result['status'] ?? 0); + return $result; + } + + + /** + * @notes 获取短信平台名称 + * @param $value + * @return string + * @author 段誉 + * @date 2022/3/29 11:37 + */ + public static function getNameDesc($value) + { + $desc = [ + 'ALI' => '阿里云短信', + 'TENCENT' => '腾讯云短信', + 'SMSBAO' => '短信宝短信', + ]; + return $desc[$value] ?? ''; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/CustomerServiceLogic.php b/app/adminapi/logic/setting/CustomerServiceLogic.php new file mode 100644 index 0000000..48e3d84 --- /dev/null +++ b/app/adminapi/logic/setting/CustomerServiceLogic.php @@ -0,0 +1,65 @@ + $qrCode, + 'wechat' => ConfigService::get('customer_service', 'wechat', ''), + 'phone' => ConfigService::get('customer_service', 'phone', ''), + 'service_time' => ConfigService::get('customer_service', 'service_time', ''), + ]; + return $config; + } + + /** + * @notes 设置客服设置 + * @param $params + * @author ljj + * @date 2022/2/15 12:11 下午 + */ + public static function setConfig($params) + { + $allowField = ['qr_code','wechat','phone','service_time']; + foreach($params as $key => $value) { + if(in_array($key, $allowField)) { + if ($key == 'qr_code') { + $value = FileService::setFileUrl($value); + } + ConfigService::set('customer_service', $key, $value); + } + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/LanguageLogic.php b/app/adminapi/logic/setting/LanguageLogic.php new file mode 100644 index 0000000..9b20910 --- /dev/null +++ b/app/adminapi/logic/setting/LanguageLogic.php @@ -0,0 +1,157 @@ + $params['name'], + 'name_loc' => $params['name_loc'], + 'symbol' => $params['symbol'], + 'trans_symbol' => $params['trans_symbol'], + 'logo' => $params['logo'], + 'precision' => $params['precision'], + 'time_format' => $params['time_format'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑语言包 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + Language::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'name_loc' => $params['name_loc'], + 'symbol' => $params['symbol'], + 'trans_symbol' => $params['trans_symbol'], + 'logo' => $params['logo'], + 'precision' => $params['precision'], + 'time_format' => $params['time_format'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除语言包 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public static function delete(array $params): bool + { + return Language::destroy($params['id']); + } + + + /** + * @notes 获取语言包详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public static function detail($params): array + { + return Language::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author heshihu + * @date 2022/2/22 10:18 + */ + public static function updateStatus(array $params) + { + Language::update([ + 'id' => $params['id'], + 'is_show' => $params['is_show'] + ]); + return true; + } + + + /** + * @notes 语言包数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:53 + */ + public static function getAllData() + { + return Language::where(['is_show' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/LanguagePagLogic.php b/app/adminapi/logic/setting/LanguagePagLogic.php new file mode 100644 index 0000000..a2034df --- /dev/null +++ b/app/adminapi/logic/setting/LanguagePagLogic.php @@ -0,0 +1,236 @@ + $params['lang'],'type' => $params['type'],'name' => $params['name']])->findOrEmpty(); + if (!$pag->isEmpty()) { + throw new \Exception('语言包已存在'); + } + + LanguagePag::create([ + 'lang' => $params['lang'], + 'type' => $params['type'], + 'name' => $params['name'], + 'value' => $params['value'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑语言包 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + LanguagePag::where('id', $params['id'])->update([ + 'lang' => $params['lang'], + 'type' => $params['type'], + 'name' => $params['name'], + 'value' => $params['value'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除语言包 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public static function delete(array $params): bool + { + return LanguagePag::destroy($params['id']); + } + + + /** + * @notes 获取语言包详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public static function detail($params): array + { + return LanguagePag::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 同步语言包 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public static function sync(array $params): bool + { + Db::startTrans(); + try { + //获取源语言 + $from = Language::find($params['from_id']); + if ($from->isEmpty()) { + throw new \Exception('源语言不存在'); + } + + //获取目标语言 + $to = Language::find($params['to_id']); + if ($to->isEmpty()) { + throw new \Exception('目标语言不存在'); + } + + //获取源语言 + $pags = LanguagePag::where(['lang' => $from['symbol']]) + ->order(['type' => 'desc','name' => 'desc']) + ->select() + ->toArray(); + + foreach ($pags as &$pag) { + //查询是否存在 + $to_pag = LanguagePag::where(['lang' => $to['symbol'],'type' => $pag['type'],'name' => $pag['name']])->findOrEmpty(); + if ($to_pag->isEmpty()) { + LanguagePag::create([ + 'lang' => $to['symbol'], + 'type' => $pag['type'], + 'name' => $pag['name'], + ]); + } + } + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 翻译语言包 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public static function trans(array $params): bool + { + Db::startTrans(); + try { + //获取源语言 + $from = Language::find($params['from_id']); + if ($from->isEmpty()) { + throw new \Exception('源语言不存在'); + } + + //获取目标语言 + $to = Language::find($params['to_id']); + if ($to->isEmpty()) { + throw new \Exception('目标语言不存在'); + } + + + //获取待翻译目标语言 + $pags = LanguagePag::where(['lang' => $to['symbol']]) + ->where(" value IS NULL OR value='' ") + ->order(['type' => 'desc','name' => 'desc']) + ->select() + ->toArray(); + + $qArray = array(); + + $idArray = array(); + foreach ($pags as &$pag) { + //查询源语言 + $from_pag = LanguagePag::where(['lang' => $from['symbol'],'type' => $pag['type'],'name' => $pag['name']])->where(" value IS NOT NULL OR value='' ")->findOrEmpty(); + if($from_pag->isEmpty()){ + continue; + }else{ + array_push($qArray, $from_pag['value']); + array_push($idArray, $pag['id']); + } + } + + if(count($qArray) == 0) throw new \Exception('不存在待翻译的内容'); + + $ret = UtilsService::do_translate($qArray,$from['trans_symbol'],$to['trans_symbol']); + $ret = json_decode($ret, true); + if($ret['errorCode'] != 0){ + throw new \Exception('错误代码:'.$ret['errorCode'].',请核对错误代码列表'); + } + foreach ($idArray as $key=>$id) { + LanguagePag::update([ + 'id' => $id, + 'value' => $ret['translateResults'][$key]['translation'], + ]); + } + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/RechargeMethodLogic.php b/app/adminapi/logic/setting/RechargeMethodLogic.php new file mode 100644 index 0000000..f3472fb --- /dev/null +++ b/app/adminapi/logic/setting/RechargeMethodLogic.php @@ -0,0 +1,184 @@ + $params['lang_id'], + 'type' => $params['type'], + 'name' => $params['name'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'account' => $params['account'], + 'img' => $params['img'] ? FileService::setFileUrl($params['img']) : '', + 'bank_name' => $params['bank_name'], + 'bank_username' => $params['bank_username'], + 'main_coin_type' => $params['main_coin_type'], + 'coin_type' => $params['coin_type'], + 'protocol' => $params['protocol'], + 'address' => $params['address'], + 'member_id' => $params['member_id'], + 'avail_num' => $params['avail_num'], + 'rate' => $params['rate'], + 'symbol_rate' => $params['symbol_rate'], + 'precision' => $params['precision'], + 'symbol' => $params['symbol'], + 'is_show' => $params['is_show'], + 'is_voucher' => $params['is_voucher'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑充值方式 + * @param array $params + * @return bool + * @author BD + * @date 2023/11/30 15:22 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + RechargeMethod::where('id', $params['id'])->update([ + 'lang_id' => $params['lang_id'], + 'type' => $params['type'], + 'name' => $params['name'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'account' => $params['account'], + 'img' => $params['img'] ? FileService::setFileUrl($params['img']) : '', + 'bank_name' => $params['bank_name'], + 'bank_username' => $params['bank_username'], + 'main_coin_type' => $params['main_coin_type'], + 'coin_type' => $params['coin_type'], + 'protocol' => $params['protocol'], + 'address' => $params['address'], + 'member_id' => $params['member_id'], + 'avail_num' => $params['avail_num'], + 'rate' => $params['rate'], + 'symbol_rate' => $params['symbol_rate'], + 'precision' => $params['precision'], + 'symbol' => $params['symbol'], + 'is_show' => $params['is_show'], + 'is_voucher' => $params['is_voucher'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除充值方式 + * @param array $params + * @return bool + * @author BD + * @date 2023/11/30 15:22 + */ + public static function delete(array $params): bool + { + return RechargeMethod::destroy($params['id']); + } + + + /** + * @notes 获取充值方式详情 + * @param $params + * @return array + * @author BD + * @date 2023/11/30 15:22 + */ + public static function detail($params): array + { + $method = RechargeMethod::findOrEmpty($params['id'])->toArray(); + $method['logo'] = FileService::getFileUrl($method['logo']); + $method['img'] = FileService::getFileUrl($method['img']); + return $method; + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author heshihu + * @date 2022/2/22 10:18 + */ + public static function updateStatus(array $params) + { + RechargeMethod::update([ + 'id' => $params['id'], + 'is_show' => $params['is_show'] + ]); + return true; + } + + /** + * @notes 充值方式数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:53 + */ + public static function getAllData() + { + $field = 'id,name,lang_id'; + + $methods = RechargeMethod::field($field) + ->where(['is_show' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + foreach ($methods as &$method) { + $method['lang_name'] = '通用'; + if($method['lang_id'] != 0){ + $language = Language::where(['id' => $method['lang_id']])->findOrEmpty(); + if(!$language->isEmpty()){ + $method['lang_name'] = $language['name']; + } + } + } + return $methods; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/StorageLogic.php b/app/adminapi/logic/setting/StorageLogic.php new file mode 100644 index 0000000..60f0338 --- /dev/null +++ b/app/adminapi/logic/setting/StorageLogic.php @@ -0,0 +1,203 @@ + '本地存储', + 'path' => '存储在本地服务器', + 'engine' => 'local', + 'status' => $default == 'local' ? 1 : 0 + ], + [ + 'name' => '七牛云存储', + 'path' => '存储在七牛云,请前往七牛云开通存储服务', + 'engine' => 'qiniu', + 'status' => $default == 'qiniu' ? 1 : 0 + ], + [ + 'name' => '阿里云OSS', + 'path' => '存储在阿里云,请前往阿里云开通存储服务', + 'engine' => 'aliyun', + 'status' => $default == 'aliyun' ? 1 : 0 + ], + [ + 'name' => '腾讯云COS', + 'path' => '存储在腾讯云,请前往腾讯云开通存储服务', + 'engine' => 'qcloud', + 'status' => $default == 'qcloud' ? 1 : 0 + ] + ]; + return $data; + } + + + /** + * @notes 存储设置详情 + * @param $param + * @return mixed + * @author 段誉 + * @date 2022/4/20 16:15 + */ + public static function detail($param) + { + + $default = ConfigService::get('storage', 'default', ''); + + // 本地存储 + $local = ['status' => $default == 'local' ? 1 : 0]; + // 七牛云存储 + $qiniu = ConfigService::get('storage', 'qiniu', [ + 'bucket' => '', + 'access_key' => '', + 'secret_key' => '', + 'domain' => '', + 'status' => $default == 'qiniu' ? 1 : 0 + ]); + + // 阿里云存储 + $aliyun = ConfigService::get('storage', 'aliyun', [ + 'bucket' => '', + 'access_key' => '', + 'secret_key' => '', + 'domain' => '', + 'status' => $default == 'aliyun' ? 1 : 0 + ]); + + // 腾讯云存储 + $qcloud = ConfigService::get('storage', 'qcloud', [ + 'bucket' => '', + 'region' => '', + 'access_key' => '', + 'secret_key' => '', + 'domain' => '', + 'status' => $default == 'qcloud' ? 1 : 0 + ]); + + $data = [ + 'local' => $local, + 'qiniu' => $qiniu, + 'aliyun' => $aliyun, + 'qcloud' => $qcloud + ]; + $result = $data[$param['engine']]; + if ($param['engine'] == $default) { + $result['status'] = 1; + } else { + $result['status'] = 0; + } + return $result; + } + + + /** + * @notes 设置存储参数 + * @param $params + * @return bool|string + * @author 段誉 + * @date 2022/4/20 16:16 + */ + public static function setup($params) + { + if ($params['status'] == 1) { //状态为开启 + ConfigService::set('storage', 'default', $params['engine']); + } else { + ConfigService::set('storage', 'default', 'local'); + } + + switch ($params['engine']) { + case 'local': + ConfigService::set('storage', 'local', []); + break; + case 'qiniu': + ConfigService::set('storage', 'qiniu', [ + 'bucket' => $params['bucket'] ?? '', + 'access_key' => $params['access_key'] ?? '', + 'secret_key' => $params['secret_key'] ?? '', + 'domain' => $params['domain'] ?? '' + ]); + break; + case 'aliyun': + ConfigService::set('storage', 'aliyun', [ + 'bucket' => $params['bucket'] ?? '', + 'access_key' => $params['access_key'] ?? '', + 'secret_key' => $params['secret_key'] ?? '', + 'domain' => $params['domain'] ?? '' + ]); + break; + case 'qcloud': + ConfigService::set('storage', 'qcloud', [ + 'bucket' => $params['bucket'] ?? '', + 'region' => $params['region'] ?? '', + 'access_key' => $params['access_key'] ?? '', + 'secret_key' => $params['secret_key'] ?? '', + 'domain' => $params['domain'] ?? '', + ]); + break; + } + + Cache::delete('STORAGE_DEFAULT'); + Cache::delete('STORAGE_ENGINE'); + if ($params['engine'] == 'local' && $params['status'] == 0) { + return '默认开启本地存储'; + } else { + return true; + } + } + + + /** + * @notes 切换状态 + * @param $params + * @author 段誉 + * @date 2022/4/20 16:17 + */ + public static function change($params) + { + $default = ConfigService::get('storage', 'default', ''); + if ($default == $params['engine']) { + ConfigService::set('storage', 'default', 'local'); + } else { + ConfigService::set('storage', 'default', $params['engine']); + } + Cache::delete('STORAGE_DEFAULT'); + Cache::delete('STORAGE_ENGINE'); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/TransactionSettingsLogic.php b/app/adminapi/logic/setting/TransactionSettingsLogic.php new file mode 100644 index 0000000..87b9b4a --- /dev/null +++ b/app/adminapi/logic/setting/TransactionSettingsLogic.php @@ -0,0 +1,64 @@ + ConfigService::get('transaction', 'cancel_unpaid_orders', 1), + 'cancel_unpaid_orders_times' => ConfigService::get('transaction', 'cancel_unpaid_orders_times', 30), + 'verification_orders' => ConfigService::get('transaction', 'verification_orders', 1), + 'verification_orders_times' => ConfigService::get('transaction', 'verification_orders_times', 24), + ]; + + return $config; + } + + /** + * @notes 设置交易设置 + * @param $params + * @author ljj + * @date 2022/2/15 11:49 上午 + */ + public static function setConfig($params) + { + ConfigService::set('transaction', 'cancel_unpaid_orders', $params['cancel_unpaid_orders']); + ConfigService::set('transaction', 'verification_orders', $params['verification_orders']); + + if (isset($params['cancel_unpaid_orders_times'])) { + ConfigService::set('transaction', 'cancel_unpaid_orders_times', $params['cancel_unpaid_orders_times']); + } + + if (isset($params['verification_orders_times'])) { + ConfigService::set('transaction', 'verification_orders_times', $params['verification_orders_times']); + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/dict/DictDataLogic.php b/app/adminapi/logic/setting/dict/DictDataLogic.php new file mode 100644 index 0000000..8ea5d93 --- /dev/null +++ b/app/adminapi/logic/setting/dict/DictDataLogic.php @@ -0,0 +1,84 @@ + $params['name'], + 'value' => $params['value'], + 'sort' => $params['sort'] ?? 0, + 'status' => $params['status'], + 'remark' => $params['remark'] ?? '', + ]; + + if (!empty($params['id'])) { + return DictData::where(['id' => $params['id']])->update($data); + } else { + $dictType = DictType::findOrEmpty($params['type_id']); + $data['type_id'] = $params['type_id']; + $data['type_value'] = $dictType['type']; + return DictData::create($data); + } + } + + + /** + * @notes 删除字典数据 + * @param array $params + * @return bool + * @author 段誉 + * @date 2022/6/20 17:01 + */ + public static function delete(array $params) + { + return DictData::destroy($params['id']); + } + + + /** + * @notes 获取字典数据详情 + * @param $params + * @return array + * @author 段誉 + * @date 2022/6/20 17:01 + */ + public static function detail($params): array + { + return DictData::findOrEmpty($params['id'])->toArray(); + } + + +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/dict/DictTypeLogic.php b/app/adminapi/logic/setting/dict/DictTypeLogic.php new file mode 100644 index 0000000..f423cf5 --- /dev/null +++ b/app/adminapi/logic/setting/dict/DictTypeLogic.php @@ -0,0 +1,111 @@ + $params['name'], + 'type' => $params['type'], + 'status' => $params['status'], + 'remark' => $params['remark'] ?? '', + ]); + } + + + /** + * @notes 编辑字典类型 + * @param array $params + * @author 段誉 + * @date 2022/6/20 16:10 + */ + public static function edit(array $params) + { + DictType::update([ + 'id' => $params['id'], + 'name' => $params['name'], + 'type' => $params['type'], + 'status' => $params['status'], + 'remark' => $params['remark'] ?? '', + ]); + + DictData::where(['type_id' => $params['id']]) + ->update(['type_value' => $params['type']]); + } + + + /** + * @notes 删除字典类型 + * @param array $params + * @author 段誉 + * @date 2022/6/20 16:23 + */ + public static function delete(array $params) + { + DictType::destroy($params['id']); + } + + + /** + * @notes 获取字典详情 + * @param $params + * @return array + * @author 段誉 + * @date 2022/6/20 16:23 + */ + public static function detail($params): array + { + return DictType::findOrEmpty($params['id'])->toArray(); + } + + + /** + * @notes 角色数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:44 + */ + public static function getAllData() + { + return DictType::where(['status' => YesNoEnum::YES]) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/system/CacheLogic.php b/app/adminapi/logic/setting/system/CacheLogic.php new file mode 100644 index 0000000..294fd15 --- /dev/null +++ b/app/adminapi/logic/setting/system/CacheLogic.php @@ -0,0 +1,37 @@ +getRootPath().'runtime/file',true); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/system/OperationLogLogic.php b/app/adminapi/logic/setting/system/OperationLogLogic.php new file mode 100644 index 0000000..9bd081e --- /dev/null +++ b/app/adminapi/logic/setting/system/OperationLogLogic.php @@ -0,0 +1,71 @@ +delete(); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } + + /** + * @notes 删除日志 + * @param $params + * @return bool + * @author 段誉 + * @date 2022/6/16 9:30 + */ + public static function deleteAll() + { + Db::startTrans(); + try { + OperationLog::where('create_time > 0')->delete(); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/system/SystemLogic.php b/app/adminapi/logic/setting/system/SystemLogic.php new file mode 100644 index 0000000..3efca96 --- /dev/null +++ b/app/adminapi/logic/setting/system/SystemLogic.php @@ -0,0 +1,65 @@ + '服务器操作系统', 'value' => PHP_OS], + ['param' => 'web服务器环境', 'value' => $_SERVER['SERVER_SOFTWARE']], + ['param' => 'PHP版本', 'value' => PHP_VERSION], + ]; + + $env = [ + [ 'option' => 'PHP版本', + 'require' => '8.0版本以上', + 'status' => (int)compare_php('8.0.0'), + 'remark' => '' + ] + ]; + + $auth = [ + [ + 'dir' => '/runtime', + 'require' => 'runtime目录可写', + 'status' => (int)check_dir_write('runtime'), + 'remark' => '' + ], + ]; + + return [ + 'server' => $server, + 'env' => $env, + 'auth' => $auth, + ]; + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/user/UserLogic.php b/app/adminapi/logic/setting/user/UserLogic.php new file mode 100644 index 0000000..b98b641 --- /dev/null +++ b/app/adminapi/logic/setting/user/UserLogic.php @@ -0,0 +1,120 @@ + FileService::getFileUrl(ConfigService::get('default_image', 'user_avatar', $defaultAvatar)), + ]; + return $config; + } + + + /** + * @notes 设置用户设置 + * @param array $params + * @return bool + * @author 段誉 + * @date 2022/3/29 10:09 + */ + public function setConfig(array $params): bool + { + $avatar = FileService::setFileUrl($params['default_avatar']); + ConfigService::set('default_image', 'user_avatar', $avatar); + return true; + } + + + /** + * @notes 获取注册配置 + * @return array + * @author 段誉 + * @date 2022/3/29 10:10 + */ + public function getRegisterConfig(): array + { + $config = [ + // 登录方式 + 'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')), + // 注册强制绑定手机 + 'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')), + // 政策协议 + 'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')), + // 第三方登录 开关 + 'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')), + // 微信授权登录 + 'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')), + // qq授权登录 + 'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')), + // 国家区号 + 'country_code' => ConfigService::get('login', 'country_code', config('project.login.country_code')), + // 初始支付密码 + 'password_pay' => ConfigService::get('login', 'password_pay', config('project.login.password_pay')), + // 邀请码 + 'invite_code' => ConfigService::get('login', 'invite_code', config('project.login.invite_code')), + ]; + return $config; + } + + + /** + * @notes 设置登录注册 + * @param array $params + * @return bool + * @author 段誉 + * @date 2022/3/29 10:10 + */ + public static function setRegisterConfig(array $params): bool + { + // 登录方式:1-账号密码登录;2-手机短信验证码登录 + ConfigService::set('login', 'login_way', $params['login_way']); + // 注册强制绑定手机 + ConfigService::set('login', 'coerce_mobile', $params['coerce_mobile']); + // 政策协议 + ConfigService::set('login', 'login_agreement', $params['login_agreement']); + // 第三方授权登录 + ConfigService::set('login', 'third_auth', $params['third_auth']); + // 微信授权登录 + ConfigService::set('login', 'wechat_auth', $params['wechat_auth']); + // qq登录 + ConfigService::set('login', 'qq_auth', $params['qq_auth']); + // 国家区号 + ConfigService::set('login', 'country_code', $params['country_code']); + // 初始支付密码 + ConfigService::set('login', 'password_pay', $params['password_pay']); + // 邀请码 + ConfigService::set('login', 'invite_code', $params['invite_code']); + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/setting/web/WebSettingLogic.php b/app/adminapi/logic/setting/web/WebSettingLogic.php new file mode 100644 index 0000000..e87b714 --- /dev/null +++ b/app/adminapi/logic/setting/web/WebSettingLogic.php @@ -0,0 +1,357 @@ + ConfigService::get('website', 'name'), + 'log_way' => ConfigService::get('website', 'log_way'), + 'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')), + 'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')), + 'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')), + // 订单提醒 + 'warm' => ConfigService::get('website', 'warm', config('project.website.warm')), + 'shop_name' => ConfigService::get('website', 'shop_name'), + 'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')), + 'shop_logo2' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo2')), + 'google_auth' => ConfigService::get('website', 'google_auth'), + + 'pc_logo' => FileService::getFileUrl(ConfigService::get('website', 'pc_logo')), + 'pc_title' => ConfigService::get('website', 'pc_title', ''), + 'pc_ico' => FileService::getFileUrl(ConfigService::get('website', 'pc_ico')), + 'pc_desc' => ConfigService::get('website', 'pc_desc', ''), + 'pc_keywords' => ConfigService::get('website', 'pc_keywords', ''), + + 'currency' => ConfigService::get('website', 'currency', ''), + 'currency2' => ConfigService::get('website', 'currency2', ''), + 'precision' => ConfigService::get('website', 'precision', ''), + //默认头像 + 'default_avatar' => FileService::getFileUrl(ConfigService::get('default_image', 'user_avatar', $defaultAvatar)), + // 登录方式 + 'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')), + // 注册强制绑定手机 + 'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')), + // 国家区号 + // 'country_code' => ConfigService::get('login', 'country_code', config('project.login.country_code')), + // 初始支付密码 + 'password_pay' => ConfigService::get('login', 'password_pay', config('project.login.password_pay')), + // 邀请码 + 'invite_code' => ConfigService::get('login', 'invite_code', config('project.login.invite_code')), + // 多处登录 + 'multipoint_login' => ConfigService::get('login', 'multipoint_login', config('project.login.multipoint_login')), + // app下载地址 + 'down_link' => ConfigService::get('website', 'down_link'), + // app下载状态 + 'is_down' => ConfigService::get('website', 'is_down'), + // IP可注册数量 + 'ip_num' => ConfigService::get('login', 'ip_num'), + // 前台链接 + 'front_link' => ConfigService::get('website', 'front_link'), + + 'agent_name' => ConfigService::get('website', 'agent_name'), + 'agent_web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'agent_web_favicon')), + 'agent_web_logo' => FileService::getFileUrl(ConfigService::get('website', 'agent_web_logo')), + 'agent_login_image' => FileService::getFileUrl(ConfigService::get('website', 'agent_login_image')), + 'agent_google_auth' => ConfigService::get('website', 'agent_google_auth'), + + 'kefu_logo' => FileService::getFileUrl(ConfigService::get('website', 'kefu_logo')), + 'show_kefu' => ConfigService::get('website', 'show_kefu'), + 'kefu_link' => ConfigService::get('website', 'kefu_link'), + + 'contract_y_logo' => FileService::getFileUrl(ConfigService::get('contract', 'contract_y_logo')), + 'contract_b_logo' => FileService::getFileUrl(ConfigService::get('contract', 'contract_b_logo')), + ]; + } + + + /** + * @notes 设置网站信息 + * @param array $params + * @author BD + * @date 2023/12/28 15:43 + */ + public static function setWebsiteInfo(array $params) + { + $favicon = FileService::setFileUrl($params['web_favicon']); + $logo = FileService::setFileUrl($params['web_logo']); + $login = FileService::setFileUrl($params['login_image']); + $shopLogo = FileService::setFileUrl($params['shop_logo']); + $shopLogo2 = FileService::setFileUrl($params['shop_logo2']); + $pcLogo = FileService::setFileUrl($params['pc_logo']); + $pcIco = FileService::setFileUrl($params['pc_ico'] ?? ''); + $avatar = FileService::setFileUrl($params['default_avatar']); + + ConfigService::set('website', 'name', $params['name']); + ConfigService::set('website', 'log_way', $params['log_way']); + ConfigService::set('website', 'web_favicon', $favicon); + ConfigService::set('website', 'web_logo', $logo); + ConfigService::set('website', 'login_image', $login); + ConfigService::set('website', 'shop_name', $params['shop_name']); + ConfigService::set('website', 'shop_logo', $shopLogo); + ConfigService::set('website', 'shop_logo2', $shopLogo2); + // 订单提醒 + ConfigService::set('website', 'warm', $params['warm']); + ConfigService::set('website', 'google_auth', $params['google_auth']); + + ConfigService::set('website', 'pc_logo', $pcLogo); + ConfigService::set('website', 'pc_title', $params['pc_title']); + ConfigService::set('website', 'pc_ico', $pcIco); + ConfigService::set('website', 'pc_desc', $params['pc_desc'] ?? ''); + ConfigService::set('website', 'pc_keywords', $params['pc_keywords'] ?? ''); + + ConfigService::set('website', 'currency', $params['currency'] ?? ''); + ConfigService::set('website', 'currency2', $params['currency2'] ?? ''); + ConfigService::set('website', 'precision', $params['precision'] ?? ''); + + ConfigService::set('default_image', 'user_avatar', $avatar); + + // 登录方式:1-账号密码登录;2-手机短信验证码登录 + ConfigService::set('login', 'login_way', $params['login_way']); + // 注册强制绑定手机 + ConfigService::set('login', 'coerce_mobile', $params['coerce_mobile']); + // 国家区号 + // ConfigService::set('login', 'country_code', $params['country_code']); + // 初始支付密码 + ConfigService::set('login', 'password_pay', $params['password_pay']); + // 邀请码 + ConfigService::set('login', 'invite_code', $params['invite_code']); + // 多处登录 + ConfigService::set('login', 'multipoint_login', $params['multipoint_login']); + // app下载地址 + ConfigService::set('website', 'down_link', $params['down_link']); + // app下载状态 + ConfigService::set('website', 'is_down', $params['is_down']); + // IP可注册数量 + ConfigService::set('login', 'ip_num', $params['ip_num']); + // 前台链接 + ConfigService::set('website', 'front_link', $params['front_link']); + + ConfigService::set('website', 'agent_name', $params['agent_name']); + ConfigService::set('website', 'agent_web_favicon', FileService::setFileUrl($params['agent_web_favicon'])); + ConfigService::set('website', 'agent_web_logo', FileService::setFileUrl($params['agent_web_logo'])); + ConfigService::set('website', 'agent_login_image', FileService::setFileUrl($params['agent_login_image'])); + ConfigService::set('website', 'agent_google_auth', $params['agent_google_auth']); + + ConfigService::set('website', 'kefu_logo', FileService::setFileUrl($params['kefu_logo'])); + ConfigService::set('website', 'show_kefu', $params['show_kefu']); + ConfigService::set('website', 'kefu_link', $params['kefu_link']); + + ConfigService::set('contract', 'contract_y_logo', FileService::setFileUrl($params['contract_y_logo'])); + ConfigService::set('contract', 'contract_b_logo', FileService::setFileUrl($params['contract_b_logo'])); + } + + /** + * @notes 获取网站配置 + * @param array $params + * @return array + * @author BD + * @date 2023/12/28 15:43 + */ + public static function getWebsiteProject(array $params) + { + try { + $element = $params['name']; + $array = ['distribute','reward','udun','email','trade','market','translation','kefu','tron','regioncode','mine']; + if (!in_array($element, $array)) { + throw new \Exception('参数异常'); + } + $data = ConfigService::get('website', $params['name']); + //有logo,替换域名 + if($element == 'market' || $element == 'kefu' || $element == 'regioncode'){ + if(!empty($data)){ + foreach ($data as &$item) { + $item['logo'] = FileService::getFileUrl($item['logo']); + } + } + } + + //Udun提现方式 + if($element == 'udun'){ + $field = 'id,name,is_open_df,main_coin_type,coin_type'; + + $methods = WithdrawMethod::field($field) + ->where(['is_show' => 1,'type' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + $data['methods'] = $methods; + + } + + return ['data' => $data]; + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + /** + * @notes 设置网站配置 + * @param array $params + * @author BD + * @date 2023/12/28 15:43 + */ + public static function setWebsiteProject(array $params) + { + try { + $element = $params['name']; + $array = ['distribute','reward','udun','email','trade','market','translation','kefu','tron','regioncode','mine']; + + if (!in_array($element, $array)) { + throw new \Exception('参数异常'); + } + $content = $params['content']; + + //有logo,替换域名 + if($element == 'market' || $element == 'kefu' || $element == 'regioncode'){ + foreach ($content as &$item) { + $item['logo'] = FileService::setFileUrl($item['logo']); + } + } + + //Udun提现方式 + if($element == 'udun'){ + + $methods = $content['methods']; + foreach ($methods as &$method) { + WithdrawMethod::update([ + 'id' => $method['id'], + 'is_open_df' => $method['is_open_df'], + 'main_coin_type' => $method['main_coin_type'], + 'coin_type' => $method['coin_type'], + ]); + } + + unset($content['methods']); + } + + ConfigService::set('website', $params['name'], $content); + return true; + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + + } + + /** + * @notes 获取国际区号 + * @return array + * @author BD + * @date 2023/12/28 16:09 + */ + public static function getRegioncodeAll() : array + { + return ConfigService::get('website', 'regioncode'); + } + + /** + * @notes 获取版权备案 + * @return array + * @author BD + * @date 2023/12/28 16:09 + */ + public static function getCopyright() : array + { + return ConfigService::get('copyright', 'config', []); + } + + + /** + * @notes 设置版权备案 + * @param array $params + * @return bool + * @author BD + * @date 2022/8/8 16:33 + */ + public static function setCopyright(array $params) + { + try { + if (!is_array($params['config'])) { + throw new \Exception('参数异常'); + } + ConfigService::set('copyright', 'config', $params['config'] ?? []); + return true; + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + + /** + * @notes 设置政策协议 + * @param array $params + * @author ljj + * @date 2022/2/15 10:59 上午 + */ + public static function setAgreement(array $params) + { + $serviceContent = clear_file_domain($params['service_content'] ?? ''); + $privacyContent = clear_file_domain($params['privacy_content'] ?? ''); + ConfigService::set('agreement', 'service_title', $params['service_title'] ?? ''); + ConfigService::set('agreement', 'service_content', $serviceContent); + ConfigService::set('agreement', 'privacy_title', $params['privacy_title'] ?? ''); + ConfigService::set('agreement', 'privacy_content', $privacyContent); + } + + + /** + * @notes 获取政策协议 + * @return array + * @author ljj + * @date 2022/2/15 11:15 上午 + */ + public static function getAgreement() : array + { + $config = [ + 'service_title' => ConfigService::get('agreement', 'service_title'), + 'service_content' => ConfigService::get('agreement', 'service_content'), + 'privacy_title' => ConfigService::get('agreement', 'privacy_title'), + 'privacy_content' => ConfigService::get('agreement', 'privacy_content'), + ]; + + $config['service_content'] = get_file_domain($config['service_content']); + $config['privacy_content'] = get_file_domain($config['privacy_content']); + + return $config; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/tools/GeneratorLogic.php b/app/adminapi/logic/tools/GeneratorLogic.php new file mode 100644 index 0000000..f97da98 --- /dev/null +++ b/app/adminapi/logic/tools/GeneratorLogic.php @@ -0,0 +1,505 @@ +findOrEmpty((int)$params['id']) + ->toArray(); + + $options = self::formatConfigByTableData($detail); + $detail['menu'] = $options['menu']; + $detail['delete'] = $options['delete']; + $detail['tree'] = $options['tree']; + $detail['relations'] = $options['relations']; + return $detail; + } + + + /** + * @notes 选择数据表 + * @param $params + * @param $adminId + * @return bool + * @author 段誉 + * @date 2022/6/20 10:44 + */ + public static function selectTable($params, $adminId) + { + Db::startTrans(); + try { + foreach ($params['table'] as $item) { + // 添加主表基础信息 + $generateTable = self::initTable($item, $adminId); + // 获取数据表字段信息 + $column = self::getTableColumn($item['name']); + // 添加表字段信息 + self::initTableColumn($column, $generateTable['id']); + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } + + + /** + * @notes 编辑表信息 + * @param $params + * @return bool + * @author 段誉 + * @date 2022/6/20 10:44 + */ + public static function editTable($params) + { + Db::startTrans(); + try { + // 格式化配置 + $options = self::formatConfigByTableData($params); + // 更新主表-数据表信息 + GenerateTable::update([ + 'id' => $params['id'], + 'table_name' => $params['table_name'], + 'table_comment' => $params['table_comment'], + 'template_type' => $params['template_type'], + 'author' => $params['author'] ?? '', + 'remark' => $params['remark'] ?? '', + 'generate_type' => $params['generate_type'], + 'module_name' => $params['module_name'], + 'class_dir' => $params['class_dir'] ?? '', + 'class_comment' => $params['class_comment'] ?? '', + 'menu' => $options['menu'], + 'delete' => $options['delete'], + 'tree' => $options['tree'], + 'relations' => $options['relations'], + ]); + + // 更新从表-数据表字段信息 + foreach ($params['table_column'] as $item) { + GenerateColumn::update([ + 'id' => $item['id'], + 'column_comment' => $item['column_comment'] ?? '', + 'is_required' => $item['is_required'] ?? 0, + 'is_insert' => $item['is_insert'] ?? 0, + 'is_update' => $item['is_update'] ?? 0, + 'is_lists' => $item['is_lists'] ?? 0, + 'is_query' => $item['is_query'] ?? 0, + 'query_type' => $item['query_type'], + 'view_type' => $item['view_type'], + 'dict_type' => $item['dict_type'] ?? '', + ]); + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } + + + /** + * @notes 删除表相关信息 + * @param $params + * @return bool + * @author 段誉 + * @date 2022/6/16 9:30 + */ + public static function deleteTable($params) + { + Db::startTrans(); + try { + GenerateTable::whereIn('id', $params['id'])->delete(); + GenerateColumn::whereIn('table_id', $params['id'])->delete(); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } + + + /** + * @notes 同步表字段 + * @param $params + * @return bool + * @author 段誉 + * @date 2022/6/23 16:28 + */ + public static function syncColumn($params) + { + Db::startTrans(); + try { + // table 信息 + $table = GenerateTable::findOrEmpty($params['id']); + // 删除旧字段 + GenerateColumn::whereIn('table_id', $table['id'])->delete(); + // 获取当前数据表字段信息 + $column = self::getTableColumn($table['table_name']); + // 创建新字段数据 + self::initTableColumn($column, $table['id']); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } + + + /** + * @notes 生成代码 + * @param $params + * @return false|int[] + * @author 段誉 + * @date 2022/6/24 9:43 + */ + public static function generate($params) + { + try { + // 获取数据表信息 + $tables = GenerateTable::with(['table_column']) + ->whereIn('id', $params['id']) + ->select()->toArray(); + + $generator = app()->make(GenerateService::class); + $generator->delGenerateDirContent(); + $flag = array_unique(array_column($tables, 'table_name')); + $flag = implode(',', $flag); + $generator->setGenerateFlag(md5($flag . time()), false); + + // 循环生成 + foreach ($tables as $table) { + $generator->generate($table); + } + + $zipFile = ''; + // 生成压缩包 + if ($generator->getGenerateFlag()) { + $generator->zipFile(); + $generator->delGenerateFlag(); + $zipFile = $generator->getDownloadUrl(); + } + + return ['file' => $zipFile]; + + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + + /** + * @notes 预览 + * @param $params + * @return false + * @author 段誉 + * @date 2022/6/23 16:27 + */ + public static function preview($params) + { + try { + // 获取数据表信息 + $table = GenerateTable::with(['table_column']) + ->whereIn('id', $params['id']) + ->findOrEmpty()->toArray(); + + return app()->make(GenerateService::class)->preview($table); + + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + + /** + * @notes 获取表字段信息 + * @param $tableName + * @return array + * @author 段誉 + * @date 2022/6/23 16:28 + */ + public static function getTableColumn($tableName) + { + $tableName = get_no_prefix_table_name($tableName); + return Db::name($tableName)->getFields(); + } + + + /** + * @notes 初始化代码生成数据表信息 + * @param $tableData + * @param $adminId + * @return GenerateTable|\think\Model + * @author 段誉 + * @date 2022/6/23 16:28 + */ + public static function initTable($tableData, $adminId) + { + return GenerateTable::create([ + 'table_name' => $tableData['name'], + 'table_comment' => $tableData['comment'], + 'template_type' => GeneratorEnum::TEMPLATE_TYPE_SINGLE, + 'generate_type' => GeneratorEnum::GENERATE_TYPE_ZIP, + 'module_name' => 'adminapi', + 'admin_id' => $adminId, + // 菜单配置 + 'menu' => [ + 'pid' => 0, // 父级菜单id + 'type' => GeneratorEnum::GEN_SELF, // 构建方式 0-手动添加 1-自动构建 + 'name' => $tableData['comment'], // 菜单名称 + ], + // 删除配置 + 'delete' => [ + 'type' => GeneratorEnum::DELETE_TRUE, // 删除类型 + 'name' => GeneratorEnum::DELETE_NAME, // 默认删除字段名 + ], + // 关联配置 + 'relations' => [], + // 树形crud + 'tree' => [] + ]); + } + + + /** + * @notes 初始化代码生成字段信息 + * @param $column + * @param $tableId + * @throws \Exception + * @author 段誉 + * @date 2022/6/23 16:28 + */ + public static function initTableColumn($column, $tableId) + { + $defaultColumn = ['id', 'create_time', 'update_time', 'delete_time']; + + $insertColumn = []; + foreach ($column as $value) { + $required = 0; + if ($value['notnull'] && !$value['primary'] && !in_array($value['name'], $defaultColumn)) { + $required = 1; + } + + $columnData = [ + 'table_id' => $tableId, + 'column_name' => $value['name'], + 'column_comment' => $value['comment'], + 'column_type' => self::getDbFieldType($value['type']), + 'is_required' => $required, + 'is_pk' => $value['primary'] ? 1 : 0, + ]; + + if (!in_array($value['name'], $defaultColumn)) { + $columnData['is_insert'] = 1; + $columnData['is_update'] = 1; + $columnData['is_lists'] = 1; + $columnData['is_query'] = 1; + } + $insertColumn[] = $columnData; + } + + (new GenerateColumn())->saveAll($insertColumn); + } + + + /** + * @notes 下载文件 + * @param $fileName + * @return false|string + * @author 段誉 + * @date 2022/6/24 9:51 + */ + public static function download(string $fileName) + { + $cacheFileName = cache('curd_file_name' . $fileName); + if (empty($cacheFileName)) { + self::$error = '请重新生成代码'; + return false; + } + + $path = root_path() . 'runtime/generate/' . $fileName; + if (!file_exists($path)) { + self::$error = '下载失败'; + return false; + } + + cache('curd_file_name' . $fileName, null); + return $path; + } + + + /** + * @notes 获取数据表字段类型 + * @param string $type + * @return string + * @author 段誉 + * @date 2022/6/15 10:11 + */ + public static function getDbFieldType(string $type): string + { + if (0 === strpos($type, 'set') || 0 === strpos($type, 'enum')) { + $result = 'string'; + } elseif (preg_match('/(double|float|decimal|real|numeric)/is', $type)) { + $result = 'float'; + } elseif (preg_match('/(int|serial|bit)/is', $type)) { + $result = 'int'; + } elseif (preg_match('/bool/is', $type)) { + $result = 'bool'; + } elseif (0 === strpos($type, 'timestamp')) { + $result = 'timestamp'; + } elseif (0 === strpos($type, 'datetime')) { + $result = 'datetime'; + } elseif (0 === strpos($type, 'date')) { + $result = 'date'; + } else { + $result = 'string'; + } + return $result; + } + + + /** + * @notes + * @param $options + * @param $tableComment + * @return array + * @author 段誉 + * @date 2022/12/13 18:23 + */ + public static function formatConfigByTableData($options) + { + // 菜单配置 + $menuConfig = $options['menu'] ?? []; + // 删除配置 + $deleteConfig = $options['delete'] ?? []; + // 关联配置 + $relationsConfig = $options['relations'] ?? []; + // 树表crud配置 + $treeConfig = $options['tree'] ?? []; + + $relations = []; + foreach ($relationsConfig as $relation) { + $relations[] = [ + 'name' => $relation['name'] ?? '', + 'model' => $relation['model'] ?? '', + 'type' => $relation['type'] ?? GeneratorEnum::RELATION_HAS_ONE, + 'local_key' => $relation['local_key'] ?? 'id', + 'foreign_key' => $relation['foreign_key'] ?? 'id', + ]; + } + + $options['menu'] = [ + 'pid' => intval($menuConfig['pid'] ?? 0), + 'type' => intval($menuConfig['type'] ?? GeneratorEnum::GEN_SELF), + 'name' => !empty($menuConfig['name']) ? $menuConfig['name'] : $options['table_comment'], + ]; + $options['delete'] = [ + 'type' => intval($deleteConfig['type'] ?? GeneratorEnum::DELETE_TRUE), + 'name' => !empty($deleteConfig['name']) ? $deleteConfig['name'] : GeneratorEnum::DELETE_NAME, + ]; + $options['relations'] = $relations; + $options['tree'] = [ + 'tree_id' => $treeConfig['tree_id'] ?? "", + 'tree_pid' =>$treeConfig['tree_pid'] ?? "", + 'tree_name' => $treeConfig['tree_name'] ?? '', + ]; + + return $options; + } + + + /** + * @notes 获取所有模型 + * @param string $module + * @return array + * @author 段誉 + * @date 2022/12/14 11:04 + */ + public static function getAllModels($module = 'common') + { + if(empty($module)) { + return []; + } + $modulePath = base_path() . $module . '/model/'; + if(!is_dir($modulePath)) { + return []; + } + + $modulefiles = glob($modulePath . '*'); + $targetFiles = []; + foreach ($modulefiles as $file) { + $fileBaseName = basename($file, '.php'); + if (is_dir($file)) { + $file = glob($file . '/*'); + foreach ($file as $item) { + if (is_dir($item)) { + continue; + } + $targetFiles[] = sprintf( + "\\app\\" . $module . "\\model\\%s\\%s", + $fileBaseName, + basename($item, '.php') + ); + } + } else { + if ($fileBaseName == 'BaseModel') { + continue; + } + $targetFiles[] = sprintf( + "\\app\\" . $module . "\\model\\%s", + basename($file, '.php') + ); + } + } + + return $targetFiles; + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/translation/TranslationLogic.php b/app/adminapi/logic/translation/TranslationLogic.php new file mode 100644 index 0000000..445acf6 --- /dev/null +++ b/app/adminapi/logic/translation/TranslationLogic.php @@ -0,0 +1,38 @@ + $ret['translateResults']]; + } +} \ No newline at end of file diff --git a/app/adminapi/logic/user/UserGroupLogic.php b/app/adminapi/logic/user/UserGroupLogic.php new file mode 100644 index 0000000..f047bf8 --- /dev/null +++ b/app/adminapi/logic/user/UserGroupLogic.php @@ -0,0 +1,141 @@ + $params['name'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑用户分组 + * @param array $params + * @return bool + * @author BD + * @date 2024/04/25 01:04 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserGroup::where('id', $params['id'])->update([ + 'name' => $params['name'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除用户分组 + * @param array $params + * @return bool + * @author BD + * @date 2024/04/25 01:04 + */ + public static function delete(array $params): bool + { + return UserGroup::destroy($params['id']); + } + + + /** + * @notes 获取用户分组详情 + * @param $params + * @return array + * @author BD + * @date 2024/04/25 01:04 + */ + public static function detail($params): array + { + return UserGroup::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 用户分组 + * @param array $params + * @return bool + * @author BD + * @date 2024/03/19 02:29 + */ + public static function setUserGroup(array $params): bool + { + Db::startTrans(); + try { + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + + if ($user->isEmpty()) { + throw new \Exception('用户不存在'); + } + $group = UserGroup::where(['id' => $params['group_id']])->findOrEmpty(); + if ($group->isEmpty() && $params['group_id'] != 0) { + throw new \Exception('分组不存在'); + } + $data = [ + 'user_id' => $params['user_id'], + 'group_id' => $params['group_id'], + ]; + + //查询用户分组 + $record = UserGroupRecord::where(['user_id' => $params['user_id']])->findOrEmpty(); + if($params['group_id'] != 0){ + + if ($record->isEmpty()) { + UserGroupRecord::create($data); + }else{ + $data['id'] = $record['id']; + UserGroupRecord::update($data); + } + }else{ + UserGroupRecord::destroy($record['id']); + } + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/user/UserGroupRuleLogic.php b/app/adminapi/logic/user/UserGroupRuleLogic.php new file mode 100644 index 0000000..ca278d7 --- /dev/null +++ b/app/adminapi/logic/user/UserGroupRuleLogic.php @@ -0,0 +1,107 @@ + $params['group_id'], + 'num' => $params['num'], + 'money_type' => $params['money_type'], + 'money' => $params['money'], + 'money_percentage' => $params['money_percentage'], + 'commission_type' => $params['commission_type'], + 'commission' => $params['commission'], + 'commission_percentage' => $params['commission_percentage'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑分组规则 + * @param array $params + * @return bool + * @author BD + * @date 2024/04/25 01:30 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserGroupRule::where('id', $params['id'])->update([ + 'group_id' => $params['group_id'], + 'num' => $params['num'], + 'money_type' => $params['money_type'], + 'money' => $params['money'], + 'money_percentage' => $params['money_percentage'], + 'commission_type' => $params['commission_type'], + 'commission' => $params['commission'], + 'commission_percentage' => $params['commission_percentage'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除分组规则 + * @param array $params + * @return bool + * @author BD + * @date 2024/04/25 01:30 + */ + public static function delete(array $params): bool + { + return UserGroupRule::destroy($params['id']); + } + + + /** + * @notes 获取分组规则详情 + * @param $params + * @return array + * @author BD + * @date 2024/04/25 01:30 + */ + public static function detail($params): array + { + return UserGroupRule::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/user/UserInfoLogic.php b/app/adminapi/logic/user/UserInfoLogic.php new file mode 100644 index 0000000..d95233f --- /dev/null +++ b/app/adminapi/logic/user/UserInfoLogic.php @@ -0,0 +1,85 @@ +isEmpty()) { + throw new \Exception('记录不存在'); + } + if ($record['auth_card']!=2) { + throw new \Exception('状态异常'); + } + UserInfo::update([ + 'id' => $params['id'], + 'auth_card' => 1 + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 拒绝实名 + * @param array $params + * @return bool + * @author BD + * @date 2024/06/08 17:51 + */ + public static function refuse(array $params): bool + { + Db::startTrans(); + try { + $record = UserInfo::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + if ($record['auth_card']!=2) { + throw new \Exception('状态异常'); + } + UserInfo::update([ + 'id' => $params['id'], + 'auth_card' => 3, + 'card_remark' => $params['remark'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/user/UserKadanLogic.php b/app/adminapi/logic/user/UserKadanLogic.php new file mode 100644 index 0000000..058545d --- /dev/null +++ b/app/adminapi/logic/user/UserKadanLogic.php @@ -0,0 +1,99 @@ + $params['user_id'], + 'sn' => generate_sn(UserKadan::class, 'sn'), + 'num' => $params['num'], + 'money' => $params['money'], + 'commission' => $params['commission'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑卡单规则 + * @param array $params + * @return bool + * @author BD + * @date 2024/04/24 17:00 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserKadan::where('id', $params['id'])->update([ + 'num' => $params['num'], + 'money' => $params['money'], + 'commission' => $params['commission'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除卡单规则 + * @param array $params + * @return bool + * @author BD + * @date 2024/04/24 17:00 + */ + public static function delete(array $params): bool + { + return UserKadan::destroy($params['id']); + } + + + /** + * @notes 获取卡单规则详情 + * @param $params + * @return array + * @author BD + * @date 2024/04/24 17:00 + */ + public static function detail($params): array + { + return UserKadan::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/user/UserLogic.php b/app/adminapi/logic/user/UserLogic.php new file mode 100644 index 0000000..9608fbd --- /dev/null +++ b/app/adminapi/logic/user/UserLogic.php @@ -0,0 +1,601 @@ + $top_sn,'is_sn' => 1])->findOrEmpty(); + + if(isset($params['invite_code']) && $params['invite_code'] != ''){ + if ($top_User->isEmpty()) { + throw new \Exception('邀请码不存在,请重新输入'); + } + } + + $mobile = $params['account']; + if($params['login_way'] == 1){ + $mobile = $params['country_code'] . ' ' .$params['account']; + } + + $is_transfer = 0; + $trade = ConfigService::get('website', 'trade'); + if($trade['is_transfer'] != 0) $is_transfer = 1; + + $user = User::create([ + 'sn' => $userSn, + 'avatar' => $avatar, + 'nickname' => '' . $userSn, + 'account' => $params['account'], + 'mobile' => $mobile, + 'country_code' => $params['country_code'], + 'password' => $password, + 'password_pay' => $password_pay, + 'channel' => $params['channel'], + 'is_transfer' => $is_transfer, + 'act_time' => time() + ]); + + //创建用户关系 + if (!$top_User->isEmpty()) { + UtilsService::create_user_relation($user['id'],$top_User['id'],UtilsService::get_distribute_level()); + } + + //创建系统消息记录 + UtilsService::create_user_notice($user['id']); + + //创建初始会员等级 + UtilsService::set_user_member($user['id']); + + //创建用户信息 + UserInfo::create(['user_id' => $user['id']]); + + Db::commit(); + return true; + + } catch (\Exception $e) { + Db::rollback(); + return $e->getMessage(); + } + } + + + /** + * @notes 调整用户余额 + * @param array $params + * @return bool|string + * @author BD + * @date 2023/2/23 14:25 + */ + public static function adjustUserMoney(array $params) + { + Db::startTrans(); + try { + $user = User::find($params['user_id']); + $action = $params['action'];//1增加余额2扣减余额3手动充值 + + $finance_action = 1;//1增加2减少 + $change_type = 0;//变动类型 + + $params['num'] = floatval($params['num']); + + if (1 == $action) { + //调整可用余额 + $user->save(); + $finance_action = 1; + $change_type = 5; + }elseif (2 == $action) { + //调整可用余额 + $user->save(); + $finance_action = 2; + $change_type = 6; + }elseif (3 == $action){ + $user->save(); + $finance_action = 1; + $change_type = 1; + } + + //记录日志 + UtilsService::user_finance_add( + $user['id'], + $change_type, + $finance_action, + $params['num'], + '', + $params['remark'], + 1 //冻结 + ); + + //用户资金修改 + UtilsService::user_money_change($params['user_id'], $finance_action, $params['num'],'user_money'); + + //手动充值 + if($action == 3){ + $method = RechargeMethod::where(['id' => $params['method_id']])->findOrEmpty(); + if($method->isEmpty()){ + throw new \Exception('充值方式不存在'); + } + + $order_amount_act = round($params['num'] * $method['rate'] , $method['precision']); + //判断充值金额 + $config = ConfigService::get('website', 'trade'); + + if ($params['num'] < $config['recharge_min']) { + throw new \Exception('该充值方式最小充值金额:' . $config['recharge_min']); + } + + $data = [ + 'sn' => generate_sn(RechargeRecord::class, 'sn'), + 'user_id' => $user['id'], + 'method_id' => $params['method_id'], + 'amount' => $params['num'], + 'amount_act' => $order_amount_act, + 'account' => $method['account'], + 'rate' => $method['rate'], + 'symbol' => $method['symbol'], + 'status' => 1, + ]; + + $record = RechargeRecord::create($data); + + //充值金额增加 + UtilsService::user_money_change($params['user_id'], $finance_action, $params['num'],'total_recharge'); + + //充值活动奖励 + UtilsService::activity_reward_add($params['user_id'],$params['num']); + + //更新充值记录用户余额 + $user = User::where(['id' => $record['user_id']])->findOrEmpty(); + if (!$user->isEmpty()) { + RechargeRecord::update([ + 'id' => $record['id'], + 'user_money' => $user['user_money'] + ]); + + //充值次数+1 + User::update([ + 'id' => $user['id'], + 'recharge_num' => $user['recharge_num'] + 1 + ]); + } + } + + Db::commit(); + return true; + + } catch (\Exception $e) { + Db::rollback(); + return $e->getMessage(); + } + } + + /** + * @notes 修改密码 + * @param array $params + * @return User + * @author BD + * @date 2023/9/22 16:38 + */ + public static function changePwd(array $params) + { + $passwordSalt = Config::get('project.unique_identification'); + $password = create_password($params['pwd'], $passwordSalt); + + return User::update([ + 'id' => $params['id'], + 'password' => $password + ]); + } + + /** + * @notes 重置支付密码 + * @param array $params + * @return User + * @author BD + * @date 2023/9/22 16:38 + */ + public static function resetPayPwd(array $params) + { + $passwordSalt = Config::get('project.unique_identification'); + + $password_pay_ = ConfigService::get('login', 'password_pay'); + $password_pay = create_password($password_pay_, $passwordSalt); + + return User::update([ + 'id' => $params['id'], + 'password_pay' => $password_pay + ]); + } + + /** + * @notes 修改邮箱 + * @param array $params + * @return User + * @author BD + * @date 2023/9/22 16:38 + */ + public static function changeEmail(array $params) + { + $userInfo = UserInfo::where(['user_id' => $params['id']])->findOrEmpty(); + + return UserInfo::update([ + 'id' => $userInfo['id'], + 'email' => $params['email'], + 'auth_email' => 1 + ]); + } + + /** + * @notes 重置邮箱验证 + * @param array $params + * @return User + * @author BD + * @date 2023/9/22 16:38 + */ + public static function resetEmail(array $params) + { + $userInfo = UserInfo::where(['user_id' => $params['id']])->findOrEmpty(); + + return UserInfo::update([ + 'id' => $userInfo['id'], + 'email' => "", + 'auth_email' => 0 + ]); + } + + /** + * @notes 重置谷歌验证 + * @param array $params + * @return User + * @author BD + * @date 2023/9/22 16:38 + */ + public static function resetGoogle(array $params) + { + $userInfo = UserInfo::where(['user_id' => $params['id']])->findOrEmpty(); + + return UserInfo::update([ + 'id' => $userInfo['id'], + 'google_key' => "", + 'google_qrcode' => "", + 'auth_google' => 0 + ]); + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author BD + * @date 2023/9/22 16:38 + */ + public static function updateMemberStatus(array $params) + { + User::update([ + 'id' => $params['id'], + 'auto_member' => $params['auto_member'] + ]); + return true; + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author BD + * @date 2023/9/22 16:38 + */ + public static function updateLhStatus(array $params) + { + User::update([ + 'id' => $params['id'], + 'is_lh' => $params['is_lh'] + ]); + return true; + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author BD + * @date 2023/9/22 16:38 + */ + public static function updateTransferStatus(array $params) + { + User::update([ + 'id' => $params['id'], + 'is_transfer' => $params['is_transfer'] + ]); + return true; + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author BD + * @date 2023/9/22 16:38 + */ + public static function updateSnStatus(array $params) + { + User::update([ + 'id' => $params['id'], + 'is_sn' => $params['is_sn'] + ]); + return true; + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author BD + * @date 2023/9/22 16:38 + */ + public static function updateOpenStatus(array $params) + { + User::update([ + 'id' => $params['id'], + 'is_open' => $params['is_open'] + ]); + return true; + } + + /** + * @notes 更改状态 + * @param array $params + * @return bool + * @author BD + * @date 2023/9/22 16:38 + */ + public static function updateAgentStatus(array $params) + { + try { + if($params['is_agent'] == 1){ + $top_relation = UserRelation::where(['user_id' => $params['id']])->order('level desc')->findOrEmpty(); + if (!$top_relation->isEmpty()) { + throw new \Exception('顶级用户才可设置为代理'); + } + } + + $user = User::where(['id' => $params['id']])->findOrEmpty(); + + if($user['agent_id'] == 0){ + $passwordSalt = Config::get('project.unique_identification'); + $password = create_password($user['sn'].mt_rand(10, 100), $passwordSalt); + + $admin = Admin::create([ + 'name' => 'agent_'.$user['sn'], + 'account' => 'agent_'.$user['sn'], + 'password' => $password, + 'is_agent' => 1, + 'multipoint_login' => 1, + ]); + + AdminRole::create([ + 'admin_id' => $admin['id'], + 'role_id' => 6, + ]); + + User::update([ + 'id' => $params['id'], + 'agent_id' => $admin['id'] + ]); + } + + + User::update([ + 'id' => $params['id'], + 'is_agent' => $params['is_agent'] + ]); + + return true; + + } catch (\Exception $e) { + Db::rollback(); + return $e->getMessage(); + } + } + + /** + * @notes 修改代理名称 + * @param array $params + * @return User + * @author BD + * @date 2023/9/22 16:38 + */ + public static function changeAgentName(array $params) + { + try { + $user = User::where(['id' => $params['id']])->findOrEmpty(); + + if($user['is_agent'] != 1){ + throw new \Exception('代理才可设置代理名称'); + } + User::update([ + 'id' => $params['id'], + 'agent_name' => $params['name'] + ]); + + return true; + + } catch (\Exception $e) { + return $e->getMessage(); + } + } + + /** + * @notes 发送站内信 + * @param array $params + * @return bool|string + * @author BD + * @date 2023/9/22 16:38 + */ + public static function sendNotice(array $params) + { + Db::startTrans(); + try { + $article= Article::where(['id' => $params['article_id']])->findOrEmpty(); + if ($article->isEmpty()) { + throw new \Exception('发送内容不存在'); + } + + $accounts = $substr = explode(",", $params['accounts']); + foreach ($accounts as $account) { + $user = User::where(['account' => $account])->findOrEmpty(); + if ($user->isEmpty()) { + continue; + } + UserNotice::create([ + 'user_id' => $user['id'], + 'article_id' => $article['id'], + 'title' => $article['title'], + 'content' => $article['content'], + 'langs' => $article['langs'], + ]); + } + + Db::commit(); + return true; + + } catch (\Exception $e) { + Db::rollback(); + return $e->getMessage(); + } + } + + /** + * @notes 彩金赠送 + * @param array $params + * @return bool|string + * @author BD + * @date 2023/9/22 16:38 + */ + public static function caijin(array $params) + { + Db::startTrans(); + try { + $accounts = $substr = explode(",", $params['accounts']); + $money = $params['money']; + if($money <= 0){ + throw new \Exception('请输入正确的金额'); + } + + + foreach ($accounts as $account) { + $user = User::where(['account' => $account])->findOrEmpty(); + if ($user->isEmpty()) { + continue; + } + //记录日志 + UtilsService::user_finance_add( + $user['id'], + 4, + 1, + $money, + '', + $params['remark'], + 1 //冻结 + ); + + //用户资金修改 + UtilsService::user_money_change($user['id'], 1, $money,'user_money'); + } + + Db::commit(); + return true; + + } catch (\Exception $e) { + Db::rollback(); + return $e->getMessage(); + } + } + + /** + * @notes 备注 + * @param array $params + * @return bool + * @author bd + * @date 2024/01/31 14:07 + */ + public static function remark(array $params): bool + { + Db::startTrans(); + try { + $record = User::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('用户不存在'); + } + //代理操作需查询是否有权限 + $user = User::where(['agent_id' => $params['admin_id']])->findOrEmpty(); + if (!$user->isEmpty()) { + $userRelation = UserRelationAgent::where(['user_id' => $record['id'],'parent_id' => $user['id']])->findOrEmpty(); + if ($userRelation->isEmpty()) { + throw new \Exception('参数异常'); + } + } + + User::update([ + 'id' => $params['id'], + 'remark2' => $params['content'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/user/UserMineRecordLogic.php b/app/adminapi/logic/user/UserMineRecordLogic.php new file mode 100644 index 0000000..86c8de8 --- /dev/null +++ b/app/adminapi/logic/user/UserMineRecordLogic.php @@ -0,0 +1,93 @@ +getMessage()); + return false; + } + } + + + /** + * @notes 编辑挖矿记录 + * @param array $params + * @return bool + * @author BD + * @date 2025/01/01 15:47 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserMineRecord::where('id', $params['id'])->update([ + + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除挖矿记录 + * @param array $params + * @return bool + * @author BD + * @date 2025/01/01 15:47 + */ + public static function delete(array $params): bool + { + return UserMineRecord::destroy($params['id']); + } + + + /** + * @notes 获取挖矿记录详情 + * @param $params + * @return array + * @author BD + * @date 2025/01/01 15:47 + */ + public static function detail($params): array + { + return UserMineRecord::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/user/UserNoticeLogic.php b/app/adminapi/logic/user/UserNoticeLogic.php new file mode 100644 index 0000000..121f972 --- /dev/null +++ b/app/adminapi/logic/user/UserNoticeLogic.php @@ -0,0 +1,96 @@ + $params['user_id'], + 'title' => $params['title'], + 'content' => $params['content'], + 'notice_type' => $params['notice_type'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑用户消息 + * @param array $params + * @return bool + * @author BD + * @date 2024/05/26 00:36 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserNotice::where('id', $params['id'])->update([ + + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除用户消息 + * @param array $params + * @return bool + * @author BD + * @date 2024/05/26 00:36 + */ + public static function delete(array $params): bool + { + return UserNotice::destroy($params['id']); + } + + + /** + * @notes 获取用户消息详情 + * @param $params + * @return array + * @author BD + * @date 2024/05/26 00:36 + */ + public static function detail($params): array + { + return UserNotice::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/user/UserRelationLogic.php b/app/adminapi/logic/user/UserRelationLogic.php new file mode 100644 index 0000000..d48d77a --- /dev/null +++ b/app/adminapi/logic/user/UserRelationLogic.php @@ -0,0 +1,30 @@ + 'reg' + ]; + + $response = UtilsService::usdt_request($tronData, 'POST'); + $response = json_decode($response, true); + + if($response['code'] == 200){ + $data['type'] = 2; + $data['address'] = $response['data']['addr']; + $data['qrcode'] = UtilsService::get_qrcode($data['address']); + $data['key'] = $response['data']['key']; + UserTron::create($data); + }else{ + throw new \Exception('创建失败'); + } + + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑波场钱包 + * @param array $params + * @return bool + * @author BD + * @date 2024/05/04 23:38 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserTron::where('id', $params['id'])->update([ + 'address' => $params['address'], + 'key' => $params['key'], + 'qrcode' => $params['qrcode'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除波场钱包 + * @param array $params + * @return bool + * @author BD + * @date 2024/05/04 23:38 + */ + public static function delete(array $params): bool + { + return UserTron::destroy($params['id']); + } + + + /** + * @notes 获取波场钱包详情 + * @param $params + * @return array + * @author BD + * @date 2024/05/04 23:38 + */ + public static function detail($params): array + { + return UserTron::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 更新状态 + * @param array $params + * @return array + * @author BD + * @date 2024/05/04 23:38 + */ + public static function updateSort(array $params) + { + return UserTron::update([ + 'id' => $params['id'], + 'sort' => $params['sort'] + ]); + } + + /** + * @notes 更新金额 + * @param array $params + * @return array + * @author BD + * @date 2024/05/04 23:38 + */ + public static function updateMoney(array $params) + { + $record = UserTron::find($params['id']); + if ($record->isEmpty()) { + throw new \Exception('记录不存在'); + } + //查询余额 + $data = [ + 'action' => 'info', + 'addr' => $record['address'] + ]; + + $response = UtilsService::usdt_request($data, 'POST'); + + $response = json_decode($response, true); + + if($response['code'] == 200){ + return UserTron::update([ + 'id' => $params['id'], + 'money_trx' => $response['data']['trx'], + 'money_usdt' => $response['data']['usdt'], + ]); + }else{ + throw new \Exception('更新失败'); + } + } + + /** + * @notes 转账 + * @param array $params + * @return bool|string + * @author BD + * @date 2024/05/04 23:38 + */ + public static function tran(array $params) + { + Db::startTrans(); + try { + $userTron = UserTron::find($params['id']); + //发起转账 + $data = [ + 'action' => 'pay', + 'out_addr' => $userTron['address'], + 'out_key' => $userTron['key'], + 'out_money' => $params['num'], + 'in_addr' => $params['in_addr'], + 'type' => 'usdt',//usdt trx + ]; + + $response = UtilsService::usdt_request($data, 'POST'); + + $response = json_decode($response, true); + + if($response['code'] == 200){ + UserTron::update([ + 'id' => $params['id'], + 'money_usdt' => $userTron['money_usdt'] - $params['num'], + ]); + + $inUserTron = UserTron::where(['address' => $params['in_addr']])->findOrEmpty(); + + if(!$inUserTron->isEmpty()){ + UserTron::update([ + 'id' => $inUserTron['id'], + 'money_usdt' => $inUserTron['money_usdt'] + $params['num'], + ]); + } + }else{ + throw new \Exception('转账失败'); + } + + Db::commit(); + return true; + + } catch (\Exception $e) { + Db::rollback(); + return $e->getMessage(); + } + } + + /** + * @notes 归集 + * @param array $params + * @return bool|string + * @author BD + * @date 2024/05/04 23:38 + */ + public static function tranAll(array $params) + { + Db::startTrans(); + try { + $min_money = $params['min_money']; + + $userTrons = UserTron::where("money_usdt >= $min_money") + ->order(['id' => 'desc']) + ->select() + ->toArray(); + + foreach ($userTrons as &$userTron) { + $out_money = $userTron['money_usdt'] - $params['rem_money']; + if($out_money <= 0) continue; + + //发起转账 + $data = [ + 'action' => 'pay', + 'out_addr' => $userTron['address'], + 'out_key' => $userTron['key'], + 'out_money' => $out_money, + 'in_addr' => $params['in_addr'], + 'type' => 'usdt',//usdt trx + ]; + $response = UtilsService::usdt_request($data, 'POST'); + + $response = json_decode($response, true); + + if($response['code'] == 200){ + UserTron::update([ + 'id' => $userTron['id'], + 'money_usdt' => $params['rem_money'], + ]); + + $inUserTron = UserTron::where(['address' => $params['in_addr']])->findOrEmpty(); + if(!$inUserTron->isEmpty()){ + UserTron::update([ + 'id' => $inUserTron['id'], + 'money_usdt' => $inUserTron['money_usdt'] + $out_money, + ]); + } + } + } + Db::commit(); + return true; + + } catch (\Exception $e) { + Db::rollback(); + return $e->getMessage(); + } + } +} \ No newline at end of file diff --git a/app/adminapi/logic/withdraw/WithdrawBankLogic.php b/app/adminapi/logic/withdraw/WithdrawBankLogic.php new file mode 100644 index 0000000..c78d1e0 --- /dev/null +++ b/app/adminapi/logic/withdraw/WithdrawBankLogic.php @@ -0,0 +1,135 @@ + $params['lang_id'], + 'name' => $params['name'], + 'code' => $params['code'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑可提现银行 + * @param array $params + * @return bool + * @author BD + * @date 2024/02/25 12:19 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + WithdrawBank::where('id', $params['id'])->update([ + 'lang_id' => $params['lang_id'], + 'name' => $params['name'], + 'code' => $params['code'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除可提现银行 + * @param array $params + * @return bool + * @author BD + * @date 2024/02/25 12:19 + */ + public static function delete(array $params): bool + { + return WithdrawBank::destroy($params['id']); + } + + + /** + * @notes 获取可提现银行详情 + * @param $params + * @return array + * @author BD + * @date 2024/02/25 12:19 + */ + public static function detail($params): array + { + return WithdrawBank::findOrEmpty($params['id'])->toArray(); + } + /** + * @notes 提现银行数据 + * @param $params + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/25 12:19 + */ + public static function allByLang($params) + { + return WithdrawBank::where(['is_show' => YesNoEnum::YES,'lang_id' => $params['lang_id']]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/withdraw/WithdrawMethodLogic.php b/app/adminapi/logic/withdraw/WithdrawMethodLogic.php new file mode 100644 index 0000000..394dde9 --- /dev/null +++ b/app/adminapi/logic/withdraw/WithdrawMethodLogic.php @@ -0,0 +1,162 @@ + $params['lang_id'], + 'type' => $params['type'], + 'name' => $params['name'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'symbol' => $params['symbol'], + 'rate' => $params['rate'], + 'symbol_rate' => $params['symbol_rate'], + 'precision' => $params['precision'], + 'charge' => $params['charge'], + 'is_show' => $params['is_show'], + 'is_qrcode' => $params['is_qrcode'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑提现方式 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + $method = WithdrawMethod::find($params['id']); + if ($method->isEmpty()) { + throw new \Exception('提现方式不存在'); + } + + WithdrawWallet::where('method_id', $method['id'])->update([ + 'lang_id' => $params['lang_id'], + ]); + + WithdrawMethod::where('id', $params['id'])->update([ + 'lang_id' => $params['lang_id'], + 'type' => $params['type'], + 'name' => $params['name'], + 'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '', + 'symbol' => $params['symbol'], + 'rate' => $params['rate'], + 'symbol_rate' => $params['symbol_rate'], + 'precision' => $params['precision'], + 'charge' => $params['charge'], + 'is_qrcode' => $params['is_qrcode'], + 'is_show' => $params['is_show'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除提现方式 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public static function delete(array $params): bool + { + return WithdrawMethod::destroy($params['id']); + } + + + /** + * @notes 获取提现方式详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public static function detail($params): array + { + return WithdrawMethod::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 提现方式数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:53 + */ + public static function getAllData() + { + $field = 'wm.id,wm.name,wm.lang_id'; + $field .= ',l.name as lang_name'; + + return WithdrawMethod::alias('wm') + ->join('language l', 'l.id = wm.lang_id') + ->field($field) + ->where(['wm.is_show' => YesNoEnum::YES]) + ->order(['wm.sort' => 'desc', 'wm.id' => 'desc']) + ->select() + ->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/withdraw/WithdrawWalletLogic.php b/app/adminapi/logic/withdraw/WithdrawWalletLogic.php new file mode 100644 index 0000000..e7ccb35 --- /dev/null +++ b/app/adminapi/logic/withdraw/WithdrawWalletLogic.php @@ -0,0 +1,75 @@ +update([ + 'bank_id' => $params['bank_id'], + 'name' => $params['name'], + 'account' => $params['account'], + 'img' => $params['img'] ? FileService::setFileUrl($params['img']) : '', + 'is_disable' => $params['is_disable'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除用户提现钱包 + * @param array $params + * @return bool + * @author BD + * @date 2024/02/26 13:32 + */ + public static function delete(array $params): bool + { + return WithdrawWallet::destroy($params['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/service/AdminTokenService.php b/app/adminapi/service/AdminTokenService.php new file mode 100644 index 0000000..df7fd4e --- /dev/null +++ b/app/adminapi/service/AdminTokenService.php @@ -0,0 +1,132 @@ +find(); + + //获取token延长过期的时间 + $expireTime = $time + Config::get('project.admin_token.expire_duration'); + $adminTokenCache = new AdminTokenCache(); + + //token处理 + if ($adminSession) { + if ($adminSession->expire_time < $time || $multipointLogin === 0) { + //清空缓存 + $adminTokenCache->deleteAdminInfo($adminSession->token); + //如果token过期或账号设置不支持多处登录,更新token + $adminSession->token = create_token($adminId); + } + $adminSession->expire_time = $expireTime; + $adminSession->update_time = $time; + + $adminSession->save(); + } else { + //找不到在该终端的token记录,创建token记录 + $adminSession = AdminSession::create([ + 'admin_id' => $adminId, + 'terminal' => $terminal, + 'token' => create_token($adminId), + 'expire_time' => $expireTime + ]); + } + + return $adminTokenCache->setAdminInfo($adminSession->token); + } + + /** + * @notes 延长token过期时间 + * @param $token + * @return array|false|mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 令狐冲 + * @date 2021/7/5 14:25 + */ + public static function overtimeToken($token) + { + $time = time(); + $adminSession = AdminSession::where('token', '=', $token)->findOrEmpty(); + if ($adminSession->isEmpty()) { + return false; + } + //延长token过期时间 + $adminSession->expire_time = $time + Config::get('project.admin_token.expire_duration'); + $adminSession->update_time = $time; + $adminSession->save(); + return (new AdminTokenCache())->setAdminInfo($adminSession->token); + } + + /** + * @notes 设置token为过期 + * @param $token + * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 令狐冲 + * @date 2021/7/5 14:31 + */ + public static function expireToken($token) + { + $adminSession = AdminSession::where('token', '=', $token) + ->with('admin') + ->findOrEmpty(); + + if ($adminSession->isEmpty()) { + return false; + } + + //当支持多处登录的时候,服务端不注销 + if ($adminSession->admin->multipoint_login === 1) { + return false; + } + + $time = time(); + $adminSession->expire_time = $time; + $adminSession->update_time = $time; + $adminSession->save(); + + return (new AdminTokenCache())->deleteAdminInfo($token); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/FileValidate.php b/app/adminapi/validate/FileValidate.php new file mode 100644 index 0000000..062d748 --- /dev/null +++ b/app/adminapi/validate/FileValidate.php @@ -0,0 +1,117 @@ + 'require|number', + 'cid' => 'require|number', + 'ids' => 'require|array', + 'type' => 'require|in:10,20,30', + 'pid' => 'require|number', + 'name' => 'require|max:20' + ]; + + protected $message = [ + 'id.require' => '缺少id参数', + 'cid.require' => '缺少cid参数', + 'ids.require' => '缺少ids参数', + 'type.require' => '缺少type参数', + 'pid.require' => '缺少pid参数', + 'name.require' => '请填写分组名称', + 'name.max' => '分组名称长度须为20字符内', + ]; + + + /** + * @notes id验证场景 + * @return FileValidate + * @author 段誉 + * @date 2021/12/29 14:32 + */ + public function sceneId() + { + return $this->only(['id']); + } + + + /** + * @notes 重命名文件场景 + * @return FileValidate + * @author 段誉 + * @date 2021/12/29 14:32 + */ + public function sceneRename() + { + return $this->only(['id', 'name']); + } + + + /** + * @notes 新增分类场景 + * @return FileValidate + * @author 段誉 + * @date 2021/12/29 14:33 + */ + public function sceneAddCate() + { + return $this->only(['type', 'pid', 'name']); + } + + + /** + * @notes 编辑分类场景 + * @return FileValidate + * @author 段誉 + * @date 2021/12/29 14:33 + */ + public function sceneEditCate() + { + return $this->only(['id', 'name']); + } + + + /** + * @notes 移动场景 + * @return FileValidate + * @author 段誉 + * @date 2021/12/29 14:33 + */ + public function sceneMove() + { + return $this->only(['ids', 'cid']); + } + + + /** + * @notes 删除场景 + * @return FileValidate + * @author 段誉 + * @date 2021/12/29 14:35 + */ + public function sceneDelete() + { + return $this->only(['ids']); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/LoginAgentValidate.php b/app/adminapi/validate/LoginAgentValidate.php new file mode 100644 index 0000000..307177c --- /dev/null +++ b/app/adminapi/validate/LoginAgentValidate.php @@ -0,0 +1,142 @@ + 'require|in:' . AdminTerminalEnum::PC . ',' . AdminTerminalEnum::MOBILE, + 'account' => 'require', + 'password' => 'require|password', + ]; + + protected $message = [ + 'account.require' => '请输入账号', + 'password.require' => '请输入密码' + ]; + + /** + * @notes @notes 密码验证 + * @param $password + * @param $other + * @param $data + * @return bool|string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 令狐冲 + * @date 2021/7/2 14:00 + */ + public function password($password, $other, $data) + { + // 登录限制 + $config = [ + 'login_restrictions' => ConfigService::get('admin_login', 'login_restrictions'), + 'password_error_times' => ConfigService::get('admin_login', 'password_error_times'), + 'limit_login_time' => ConfigService::get('admin_login', 'limit_login_time'), + 'google_auth' => ConfigService::get('website', 'agent_google_auth'), + ]; + + $adminAccountSafeCache = new AdminAccountSafeCache(); + if ($config['login_restrictions'] == 1) { + $adminAccountSafeCache->count = $config['password_error_times']; + $adminAccountSafeCache->minute = $config['limit_login_time']; + } + + //后台账号安全机制,连续输错后锁定,防止账号密码暴力破解 + if ($config['login_restrictions'] == 1 && !$adminAccountSafeCache->isSafe()) { + return '密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试'; + } + + $where = []; + + $login_way = $data['login_way'];//0邮箱1手机号 + if($login_way == 1){ + $where = ['country_code' => $data['country_code']]; + } + + + $userInfo = User::where($where) + ->where(['account|mobile' => $data['account'],'is_agent' => 1]) + ->field(['id,password,is_disable,is_open,agent_id']) + ->findOrEmpty(); + + if ($userInfo->isEmpty()) { + return '用户不存在';//用户不存在 + } + + if ($userInfo['is_open'] === YesNoEnum::NO) { + return '用户未启用';//用户未启用 + } + + if ($userInfo['is_disable'] === YesNoEnum::YES) { + return '用户已禁用';//用户已禁用 + } + + $user_info = UserInfo::where(['user_id' => $userInfo['id']])->findOrEmpty(); + + if($config['google_auth'] == 1){ + if(!$user_info->isEmpty() && $user_info['google_key']){ + if(!$data['code']){ + $adminAccountSafeCache->record(); + return '请输入谷歌验证码'; + } + + $valid = UtilsService::get_google_verify($user_info['google_key'],$data['code']); + if(!$valid) { + $adminAccountSafeCache->record(); + return '验证码错误'; + } + }else{ + $adminAccountSafeCache->record(); + return '验证码错误'; + } + } + + $passwordSalt = Config::get('project.unique_identification'); + if ($userInfo['password'] !== create_password($password, $passwordSalt)) { + $adminAccountSafeCache->record(); + return '密码错误';//密码错误 + } + + $adminInfo = Admin::where('id', '=', $userInfo['agent_id']) + ->where(['is_agent' => 1]) + ->findOrEmpty(); + + if ($adminInfo->isEmpty()) { + return '参数异常';//参数异常 + } + + $adminAccountSafeCache->relieve(); + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/LoginValidate.php b/app/adminapi/validate/LoginValidate.php new file mode 100644 index 0000000..41cafa5 --- /dev/null +++ b/app/adminapi/validate/LoginValidate.php @@ -0,0 +1,120 @@ + 'require|in:' . AdminTerminalEnum::PC . ',' . AdminTerminalEnum::MOBILE, + 'account' => 'require', + 'password' => 'require|password', + ]; + + protected $message = [ + 'account.require' => '请输入账号', + 'password.require' => '请输入密码' + ]; + + /** + * @notes @notes 密码验证 + * @param $password + * @param $other + * @param $data + * @return bool|string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 令狐冲 + * @date 2021/7/2 14:00 + */ + public function password($password, $other, $data) + { + // 登录限制 + $config = [ + 'login_restrictions' => ConfigService::get('admin_login', 'login_restrictions'), + 'password_error_times' => ConfigService::get('admin_login', 'password_error_times'), + 'limit_login_time' => ConfigService::get('admin_login', 'limit_login_time'), + 'google_auth' => ConfigService::get('website', 'google_auth'), + ]; + + $adminAccountSafeCache = new AdminAccountSafeCache(); + if ($config['login_restrictions'] == 1) { + $adminAccountSafeCache->count = $config['password_error_times']; + $adminAccountSafeCache->minute = $config['limit_login_time']; + } + + //后台账号安全机制,连续输错后锁定,防止账号密码暴力破解 + if ($config['login_restrictions'] == 1 && !$adminAccountSafeCache->isSafe()) { + return '密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试'; + } + + $adminInfo = Admin::where('account', '=', $data['account']) + ->where(['is_agent' => 0]) + ->field(['password,disable,google_key']) + ->findOrEmpty(); + + if ($adminInfo->isEmpty()) { + return '账号不存在'; + } + + if ($adminInfo['disable'] === 1) { + return '账号已禁用'; + } + + if (empty($adminInfo['password'])) { + $adminAccountSafeCache->record(); + return '账号不存在'; + } + + if($config['google_auth'] == 1){ + if($adminInfo['google_key']){ + if(!$data['code']){ + $adminAccountSafeCache->record(); + return '请输入谷歌验证码'; + } + $valid = UtilsService::get_google_verify($adminInfo['google_key'],$data['code']); + if(!$valid) { + $adminAccountSafeCache->record(); + return '验证码错误'; + } + } + } + + $passwordSalt = Config::get('project.unique_identification'); + + if ($adminInfo['password'] !== create_password($password, $passwordSalt)) { + $adminAccountSafeCache->record(); + return '密码错误'; + } + + $adminAccountSafeCache->relieve(); + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/article/ArticleCateValidate.php b/app/adminapi/validate/article/ArticleCateValidate.php new file mode 100644 index 0000000..90c3f30 --- /dev/null +++ b/app/adminapi/validate/article/ArticleCateValidate.php @@ -0,0 +1,136 @@ + 'require|checkArticleCate', + 'name' => 'require|length:1,90', + 'is_show' => 'require|in:0,1', + 'sort' => 'egt:0', + ]; + + protected $message = [ + 'id.require' => '资讯分类id不能为空', + 'name.require' => '资讯分类不能为空', + 'name.length' => '资讯分类长度须在1-90位字符', + 'sort.egt' => '排序值不正确', + ]; + + /** + * @notes 添加场景 + * @return ArticleCateValidate + * @author heshihu + * @date 2022/2/10 15:11 + */ + public function sceneAdd() + { + return $this->remove(['id']) + ->remove('id', 'require|checkArticleCate'); + } + + /** + * @notes 详情场景 + * @return ArticleCateValidate + * @author heshihu + * @date 2022/2/21 17:55 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 更改状态场景 + * @return ArticleCateValidate + * @author heshihu + * @date 2022/2/21 18:02 + */ + public function sceneStatus() + { + return $this->only(['id', 'is_show']); + } + + public function sceneEdit() + { + } + + /** + * @notes 获取所有资讯分类场景 + * @return ArticleCateValidate + * @author heshihu + * @date 2022/2/15 10:05 + */ + public function sceneSelect() + { + return $this->only(['type']); + } + + + /** + * @notes 删除场景 + * @return ArticleCateValidate + * @author heshihu + * @date 2022/2/21 17:52 + */ + public function sceneDelete() + { + return $this->only(['id']) + ->append('id', 'checkDeleteArticleCate'); + } + + /** + * @notes 检查指定资讯分类是否存在 + * @param $value + * @return bool|string + * @author heshihu + * @date 2022/2/10 15:10 + */ + public function checkArticleCate($value) + { + $article_category = ArticleCate::findOrEmpty($value); + if ($article_category->isEmpty()) { + return '资讯分类不存在'; + } + return true; + } + + /** + * @notes 删除时验证该资讯分类是否已使用 + * @param $value + * @return bool|string + * @author heshihu + * @date 2022/2/22 14:45 + */ + public function checkDeleteArticleCate($value) + { + $article = Article::where('cid', $value)->findOrEmpty(); + if (!$article->isEmpty()) { + return '资讯分类已使用,请先删除绑定该资讯分类的资讯'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/article/ArticleValidate.php b/app/adminapi/validate/article/ArticleValidate.php new file mode 100644 index 0000000..7fc896e --- /dev/null +++ b/app/adminapi/validate/article/ArticleValidate.php @@ -0,0 +1,108 @@ + 'require|checkArticle', + 'title' => 'require|length:1,255', +// 'image' => 'require', + 'cid' => 'require', + 'is_show' => 'require|in:0,1', + ]; + + protected $message = [ + 'id.require' => '资讯id不能为空', + 'title.require' => '标题不能为空', + 'title.length' => '标题长度须在1-255位字符', +// 'image.require' => '封面图必须存在', + 'cid.require' => '所属栏目必须存在', + ]; + + /** + * @notes 添加场景 + * @return ArticleValidate + * @author heshihu + * @date 2022/2/22 9:57 + */ + public function sceneAdd() + { + return $this->remove(['id']) + ->remove('id','require|checkArticle'); + } + + /** + * @notes 详情场景 + * @return ArticleValidate + * @author heshihu + * @date 2022/2/22 10:15 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 更改状态场景 + * @return ArticleValidate + * @author heshihu + * @date 2022/2/22 10:18 + */ + public function sceneStatus() + { + return $this->only(['id', 'is_show']); + } + + public function sceneEdit() + { + } + + /** + * @notes 删除场景 + * @return ArticleValidate + * @author heshihu + * @date 2022/2/22 10:17 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + /** + * @notes 检查指定资讯是否存在 + * @param $value + * @return bool|string + * @author heshihu + * @date 2022/2/22 10:11 + */ + public function checkArticle($value) + { + $article = Article::findOrEmpty($value); + if ($article->isEmpty()) { + return '资讯不存在'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/auth/AdminValidate.php b/app/adminapi/validate/auth/AdminValidate.php new file mode 100644 index 0000000..ad0deea --- /dev/null +++ b/app/adminapi/validate/auth/AdminValidate.php @@ -0,0 +1,168 @@ + 'require|checkAdmin', + 'account' => 'require|length:1,32|unique:'.Admin::class, + 'name' => 'require|length:1,16|unique:'.Admin::class, + 'password' => 'require|length:6,32|edit', + 'password_confirm' => 'requireWith:password|confirm', + 'role_id' => 'require', + 'disable' => 'require|in:0,1|checkAbleDisable', + 'multipoint_login' => 'require|in:0,1', + ]; + + protected $message = [ + 'id.require' => '管理员id不能为空', + 'account.require' => '账号不能为空', + 'account.length' => '账号长度须在1-32位字符', + 'account.unique' => '账号已存在', + 'password.require' => '密码不能为空', + 'password.length' => '密码长度须在6-32位字符', + 'password_confirm.requireWith' => '确认密码不能为空', + 'password_confirm.confirm' => '两次输入的密码不一致', + 'name.require' => '名称不能为空', + 'name.length' => '名称须在1-16位字符', + 'name.unique' => '名称已存在', + 'role_id.require' => '请选择角色', + 'disable.require' => '请选择状态', + 'disable.in' => '状态值错误', + 'multipoint_login.require' => '请选择是否支持多处登录', + 'multipoint_login.in' => '多处登录状态值为误', + ]; + + /** + * @notes 添加场景 + * @return AdminValidate + * @author 段誉 + * @date 2021/12/29 15:46 + */ + public function sceneAdd() + { + return $this->remove(['password', 'edit']) + ->remove('id', 'require|checkAdmin') + ->remove('disable', 'checkAbleDisable'); + } + + /** + * @notes 详情场景 + * @return AdminValidate + * @author 段誉 + * @date 2021/12/29 15:46 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 编辑场景 + * @return AdminValidate + * @author 段誉 + * @date 2021/12/29 15:47 + */ + public function sceneEdit() + { + return $this->remove('password', 'require|length') + ->append('id', 'require|checkAdmin'); + } + + + /** + * @notes 删除场景 + * @return AdminValidate + * @author 段誉 + * @date 2021/12/29 15:47 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + + /** + * @notes 编辑情况下,检查是否填密码 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2021/12/29 10:19 + */ + public function edit($value, $rule, $data) + { + if (empty($data['password']) && empty($data['password_confirm'])) { + return true; + } + $len = strlen($value); + if ($len < 6 || $len > 32) { + return '密码长度须在6-32位字符'; + } + return true; + } + + + /** + * @notes 检查指定管理员是否存在 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2021/12/29 10:19 + */ + public function checkAdmin($value) + { + $admin = Admin::findOrEmpty($value); + if ($admin->isEmpty()) { + return '管理员不存在'; + } + return true; + } + + + /** + * @notes 禁用校验 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/8/11 9:59 + */ + public function checkAbleDisable($value, $rule, $data) + { + $admin = Admin::findOrEmpty($data['id']); + if ($admin->isEmpty()) { + return '管理员不存在'; + } + + if ($value && $admin['root']) { + return '超级管理员不允许被禁用'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/auth/MenuValidate.php b/app/adminapi/validate/auth/MenuValidate.php new file mode 100644 index 0000000..4312fa1 --- /dev/null +++ b/app/adminapi/validate/auth/MenuValidate.php @@ -0,0 +1,206 @@ + 'require', + 'pid' => 'require|checkPid', + 'type' => 'require|in:M,C,A', + 'name' => 'require|length:1,30|checkUniqueName', + 'icon' => 'max:100', + 'sort' => 'require|egt:0', + 'perms' => 'max:100', + 'paths' => 'max:200', + 'component' => 'max:200', + 'selected' => 'max:200', + 'params' => 'max:200', + 'is_cache' => 'require|in:0,1', + 'is_show' => 'require|in:0,1', + 'is_disable' => 'require|in:0,1', + ]; + + + protected $message = [ + 'id.require' => '参数缺失', + 'pid.require' => '请选择上级菜单', + 'type.require' => '请选择菜单类型', + 'type.in' => '菜单类型参数值错误', + 'name.require' => '请填写菜单名称', + 'name.length' => '菜单名称长度需为1~30个字符', + 'icon.max' => '图标名称不能超过100个字符', + 'sort.require' => '请填写排序', + 'sort.egt' => '排序值需大于或等于0', + 'perms.max' => '权限字符不能超过100个字符', + 'paths.max' => '路由地址不能超过200个字符', + 'component.max' => '组件路径不能超过200个字符', + 'selected.max' => '选中菜单路径不能超过200个字符', + 'params.max' => '路由参数不能超过200个字符', + 'is_cache.require' => '请选择缓存状态', + 'is_cache.in' => '缓存状态参数值错误', + 'is_show.require' => '请选择显示状态', + 'is_show.in' => '显示状态参数值错误', + 'is_disable.require' => '请选择菜单状态', + 'is_disable.in' => '菜单状态参数值错误', + ]; + + + /** + * @notes 添加场景 + * @return MenuValidate + * @author 段誉 + * @date 2022/6/29 18:26 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 详情场景 + * @return MenuValidate + * @author 段誉 + * @date 2022/6/29 18:27 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return MenuValidate + * @author 段誉 + * @date 2022/6/29 18:27 + */ + public function sceneDelete() + { + return $this->only(['id']) + ->append('id', 'checkAbleDelete'); + } + + + /** + * @notes 更新状态场景 + * @return MenuValidate + * @author 段誉 + * @date 2022/7/6 17:04 + */ + public function sceneStatus() + { + return $this->only(['id', 'is_disable']); + } + + /** + * @notes 更新排序场景 + * @return MenuValidate + * @author 段誉 + * @date 2022/7/6 17:04 + */ + public function sceneSort() + { + return $this->only(['id', 'sort']); + } + + + /** + * @notes 校验菜单名称是否已存在 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/6/29 18:24 + */ + protected function checkUniqueName($value, $rule, $data) + { + if ($data['type'] != 'M') { + return true; + } + $where[] = ['type', '=', $data['type']]; + $where[] = ['name', '=', $data['name']]; + + if (!empty($data['id'])) { + $where[] = ['id', '<>', $data['id']]; + } + + $check = SystemMenu::where($where)->findOrEmpty(); + + if (!$check->isEmpty()) { + return '菜单名称已存在'; + } + + return true; + } + + + /** + * @notes 是否有子级菜单 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/6/30 9:40 + */ + protected function checkAbleDelete($value, $rule, $data) + { + $hasChild = SystemMenu::where(['pid' => $value])->findOrEmpty(); + if (!$hasChild->isEmpty()) { + return '存在子菜单,不允许删除'; + } + + // 已绑定角色菜单不可以删除 + $isBindRole = SystemRole::hasWhere('roleMenuIndex', ['menu_id' => $value])->findOrEmpty(); + if (!$isBindRole->isEmpty()) { + return '已分配菜单不可删除'; + } + + return true; + } + + + /** + * @notes 校验上级 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/6/30 9:51 + */ + protected function checkPid($value, $rule, $data) + { + if (!empty($data['id']) && $data['id'] == $value) { + return '上级菜单不能选择自己'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/auth/RoleValidate.php b/app/adminapi/validate/auth/RoleValidate.php new file mode 100644 index 0000000..9f2f32d --- /dev/null +++ b/app/adminapi/validate/auth/RoleValidate.php @@ -0,0 +1,119 @@ + 'require|checkRole', + 'name' => 'require|max:64|unique:' . SystemRole::class . ',name', + 'menu_id' => 'array', + ]; + + protected $message = [ + 'id.require' => '请选择角色', + 'name.require' => '请输入角色名称', + 'name.max' => '角色名称最长为16个字符', + 'name.unique' => '角色名称已存在', + 'menu_id.array' => '权限格式错误' + ]; + + /** + * @notes 添加场景 + * @return RoleValidate + * @author 段誉 + * @date 2021/12/29 15:47 + */ + public function sceneAdd() + { + return $this->only(['name', 'menu_id']); + } + + /** + * @notes 详情场景 + * @return RoleValidate + * @author 段誉 + * @date 2021/12/29 15:47 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 删除场景 + * @return RoleValidate + * @author 段誉 + * @date 2021/12/29 15:48 + */ + public function sceneDel() + { + return $this->only(['id']) + ->append('id', 'checkAdmin'); + } + + + /** + * @notes 验证角色是否存在 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2021/12/29 15:48 + */ + public function checkRole($value, $rule, $data) + { + if (!SystemRole::find($value)) { + return '角色不存在'; + } + return true; + } + + + + /** + * @notes 验证角色是否被使用 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2021/12/29 15:49 + */ + public function checkAdmin($value, $rule, $data) + { + if (AdminRole::where(['role_id' => $value])->find()) { + return '有管理员在使用该角色,不允许删除'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/auth/editSelfValidate.php b/app/adminapi/validate/auth/editSelfValidate.php new file mode 100644 index 0000000..3d7726f --- /dev/null +++ b/app/adminapi/validate/auth/editSelfValidate.php @@ -0,0 +1,74 @@ + 'require|length:1,16', + 'avatar' => 'require', + 'password_old' => 'length:6,32', + 'password' => 'length:6,32|checkPassword', + 'password_confirm' => 'requireWith:password|confirm', + ]; + + + protected $message = [ + 'name.require' => '请填写名称', + 'name.length' => '名称须在1-16位字符', + 'avatar.require' => '请选择头像', + 'password_now.length' => '密码长度须在6-32位字符', + 'password_confirm.requireWith' => '确认密码不能为空', + 'password_confirm.confirm' => '两次输入的密码不一致', + ]; + + + /** + * @notes 校验密码 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/4/8 17:40 + */ + public function checkPassword($value, $rule, $data) + { + if (empty($data['password_old'])) { + return '请填写当前密码'; + } + + $admin = Admin::findOrEmpty($data['admin_id']); + $passwordSalt = Config::get('project.unique_identification'); + $oldPassword = create_password($data['password_old'], $passwordSalt); + + if ($admin['password'] != $oldPassword) { + return '当前密码错误'; + } + + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/crontab/CrontabValidate.php b/app/adminapi/validate/crontab/CrontabValidate.php new file mode 100644 index 0000000..e622ef2 --- /dev/null +++ b/app/adminapi/validate/crontab/CrontabValidate.php @@ -0,0 +1,138 @@ + 'require', + 'type' => 'require|in:1', + 'command' => 'require', + 'status' => 'require|in:1,2,3', + 'expression' => 'require|checkExpression', + 'id' => 'require', + 'operate' => 'require' + ]; + + protected $message = [ + 'name.require' => '请输入定时任务名称', + 'type.require' => '请选择类型', + 'type.in' => '类型值错误', + 'command.require' => '请输入命令', + 'status.require' => '请选择状态', + 'status.in' => '状态值错误', + 'expression.require' => '请输入运行规则', + 'id.require' => '参数缺失', + 'operate.require' => '请选择操作', + ]; + + + /** + * @notes 添加定时任务场景 + * @return CrontabValidate + * @author 段誉 + * @date 2022/3/29 14:39 + */ + public function sceneAdd() + { + return $this->remove('id', 'require')->remove('operate', 'require'); + } + + + /** + * @notes 查看定时任务详情场景 + * @return CrontabValidate + * @author 段誉 + * @date 2022/3/29 14:39 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + + /** + * @notes 编辑定时任务 + * @return CrontabValidate + * @author 段誉 + * @date 2022/3/29 14:39 + */ + public function sceneEdit() + { + return $this->remove('operate', 'require'); + } + + + /** + * @notes 删除定时任务场景 + * @return CrontabValidate + * @author 段誉 + * @date 2022/3/29 14:40 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes CrontabValidate + * @return CrontabValidate + * @author 段誉 + * @date 2022/3/29 14:40 + */ + public function sceneOperate() + { + return $this->only(['id', 'operate']); + } + + + /** + * @notes 获取规则执行时间场景 + * @return CrontabValidate + * @author 段誉 + * @date 2022/3/29 14:40 + */ + public function sceneExpression() + { + return $this->only(['expression']); + } + + + /** + * @notes 校验运行规则 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/3/29 14:40 + */ + public function checkExpression($value, $rule, $data) + { + if (CronExpression::isValidExpression($value) === false) { + return '定时任务运行规则错误'; + } + return true; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/decorate/DecorateHintValidate.php b/app/adminapi/validate/decorate/DecorateHintValidate.php new file mode 100644 index 0000000..f19efdb --- /dev/null +++ b/app/adminapi/validate/decorate/DecorateHintValidate.php @@ -0,0 +1,96 @@ + 'require', + 'title' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'title' => '标题', + ]; + + + /** + * @notes 添加场景 + * @return DecorateHintValidate + * @author BD + * @date 2024/03/17 17:01 + */ + public function sceneAdd() + { + return $this->only(['title']); + } + + + /** + * @notes 编辑场景 + * @return DecorateHintValidate + * @author BD + * @date 2024/03/17 17:01 + */ + public function sceneEdit() + { + return $this->only(['id','title']); + } + + + /** + * @notes 删除场景 + * @return DecorateHintValidate + * @author BD + * @date 2024/03/17 17:01 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return DecorateHintValidate + * @author BD + * @date 2024/03/17 17:01 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/decorate/DecorateNavValidate.php b/app/adminapi/validate/decorate/DecorateNavValidate.php new file mode 100644 index 0000000..7e2f334 --- /dev/null +++ b/app/adminapi/validate/decorate/DecorateNavValidate.php @@ -0,0 +1,104 @@ + 'require', + 'name' => 'require', + 'link' => 'require', + 'loca' => 'require', + 'is_show' => 'require', + 'sort' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '菜单名称', + 'link' => '菜单链接', + 'loca' => '菜单位置', + 'is_show' => '显示状态', + 'sort' => '排序', + ]; + + + /** + * @notes 添加场景 + * @return DecorateNavValidate + * @author BD + * @date 2024/03/17 16:41 + */ + public function sceneAdd() + { + return $this->only(['name','link','loca','is_show','sort']); + } + + + /** + * @notes 编辑场景 + * @return DecorateNavValidate + * @author BD + * @date 2024/03/17 16:41 + */ + public function sceneEdit() + { + return $this->only(['id','name','link','loca','is_show','sort']); + } + + + /** + * @notes 删除场景 + * @return DecorateNavValidate + * @author BD + * @date 2024/03/17 16:41 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return DecorateNavValidate + * @author BD + * @date 2024/03/17 16:41 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/decorate/DecorateSwiperValidate.php b/app/adminapi/validate/decorate/DecorateSwiperValidate.php new file mode 100644 index 0000000..bb85b9f --- /dev/null +++ b/app/adminapi/validate/decorate/DecorateSwiperValidate.php @@ -0,0 +1,98 @@ + 'require', + 'loca' => 'require', + 'is_show' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'loca' => '位置', + 'is_show' => '显示状态', + ]; + + + /** + * @notes 添加场景 + * @return DecorateSwiperValidate + * @author BD + * @date 2024/03/16 17:34 + */ + public function sceneAdd() + { + return $this->only(['loca','is_show']); + } + + + /** + * @notes 编辑场景 + * @return DecorateSwiperValidate + * @author BD + * @date 2024/03/16 17:34 + */ + public function sceneEdit() + { + return $this->only(['id','loca','is_show']); + } + + + /** + * @notes 删除场景 + * @return DecorateSwiperValidate + * @author BD + * @date 2024/03/16 17:34 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return DecorateSwiperValidate + * @author BD + * @date 2024/03/16 17:34 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/dept/DeptValidate.php b/app/adminapi/validate/dept/DeptValidate.php new file mode 100644 index 0000000..26aa0ad --- /dev/null +++ b/app/adminapi/validate/dept/DeptValidate.php @@ -0,0 +1,179 @@ + 'require|checkDept', + 'pid' => 'require|integer', + 'name' => 'require|unique:'.Dept::class.'|length:1,30', + 'status' => 'require|in:0,1', + 'sort' => 'egt:0', + ]; + + + protected $message = [ + 'id.require' => '参数缺失', + 'name.require' => '请填写部门名称', + 'name.length' => '部门名称长度须在1-30位字符', + 'name.unique' => '部门名称已存在', + 'sort.egt' => '排序值不正确', + 'pid.require' => '请选择上级部门', + 'pid.integer' => '上级部门参数错误', + 'status.require' => '请选择部门状态', + ]; + + + /** + * @notes 添加场景 + * @return DeptValidate + * @author 段誉 + * @date 2022/5/25 18:16 + */ + public function sceneAdd() + { + return $this->remove('id', true)->append('pid', 'checkDept'); + } + + + /** + * @notes 详情场景 + * @return DeptValidate + * @author 段誉 + * @date 2022/5/25 18:16 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + + /** + * @notes 编辑场景 + * @return DeptValidate + * @author 段誉 + * @date 2022/5/26 18:42 + */ + public function sceneEdit() + { + return $this->append('pid', 'checkPid'); + } + + + /** + * @notes 删除场景 + * @return DeptValidate + * @author 段誉 + * @date 2022/5/25 18:16 + */ + public function sceneDelete() + { + return $this->only(['id'])->append('id', 'checkAbleDetele'); + } + + + /** + * @notes 校验部门 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2022/5/25 18:17 + */ + public function checkDept($value) + { + $dept = Dept::findOrEmpty($value); + if ($dept->isEmpty()) { + return '部门不存在'; + } + return true; + } + + + /** + * @notes 校验能否删除 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2022/5/26 14:22 + */ + public function checkAbleDetele($value) + { + $hasLower = Dept::where(['pid' => $value])->findOrEmpty(); + if (!$hasLower->isEmpty()) { + return '已关联下级部门,暂不可删除'; + } + + $check = AdminDept::where(['dept_id' => $value])->findOrEmpty(); + if (!$check->isEmpty()) { + return '已关联管理员,暂不可删除'; + } + + $dept = Dept::findOrEmpty($value); + if ($dept['pid'] == 0) { + return '顶级部门不可删除'; + } + + return true; + } + + /** + * @notes 校验部门 + * @param $value + * @param $rule + * @param array $data + * @return bool|string + * @author 段誉 + * @date 2022/5/26 18:41 + */ + public function checkPid($value, $rule, $data = []) + { + // 当前编辑的部门id信息是否存在 + $dept = Dept::findOrEmpty($data['id']); + if ($dept->isEmpty()) { + return '当前部门信息缺失'; + } + + // 顶级部门不校验上级部门id + if ($dept['pid'] == 0) { + return true; + } + + if ($data['id'] == $value) { + return '上级部门不可是当前部门'; + } + + $leaderDept = Dept::findOrEmpty($value); + if ($leaderDept->isEmpty()) { + return '部门不存在'; + } + + return true; + } + + +} \ No newline at end of file diff --git a/app/adminapi/validate/dept/JobsValidate.php b/app/adminapi/validate/dept/JobsValidate.php new file mode 100644 index 0000000..96c61fd --- /dev/null +++ b/app/adminapi/validate/dept/JobsValidate.php @@ -0,0 +1,127 @@ + 'require|checkJobs', + 'name' => 'require|unique:'.Jobs::class.'|length:1,50', + 'code' => 'require|unique:'.Jobs::class, + 'status' => 'require|in:0,1', + 'sort' => 'egt:0', + ]; + + protected $message = [ + 'id.require' => '参数缺失', + 'name.require' => '请填写岗位名称', + 'name.length' => '岗位名称长度须在1-50位字符', + 'name.unique' => '岗位名称已存在', + 'code.require' => '请填写岗位编码', + 'code.unique' => '岗位编码已存在', + 'sort.egt' => '排序值不正确', + 'status.require' => '请选择岗位状态', + 'status.in' => '岗位状态值错误', + ]; + + + /** + * @notes 添加场景 + * @return JobsValidate + * @author 段誉 + * @date 2022/5/26 9:53 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 详情场景 + * @return JobsValidate + * @author 段誉 + * @date 2022/5/26 9:53 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + + public function sceneEdit() + { + } + + + /** + * @notes 删除场景 + * @return JobsValidate + * @author 段誉 + * @date 2022/5/26 9:54 + */ + public function sceneDelete() + { + return $this->only(['id'])->append('id', 'checkAbleDetele'); + } + + + /** + * @notes 校验岗位 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2022/5/26 9:55 + */ + public function checkJobs($value) + { + $jobs = Jobs::findOrEmpty($value); + if ($jobs->isEmpty()) { + return '岗位不存在'; + } + return true; + } + + + /** + * @notes 校验能否删除 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2022/5/26 14:22 + */ + public function checkAbleDetele($value) + { + $check = AdminJobs::where(['jobs_id' => $value])->findOrEmpty(); + if (!$check->isEmpty()) { + return '已关联管理员,暂不可删除'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/dict/DictDataValidate.php b/app/adminapi/validate/dict/DictDataValidate.php new file mode 100644 index 0000000..b867516 --- /dev/null +++ b/app/adminapi/validate/dict/DictDataValidate.php @@ -0,0 +1,119 @@ + 'require|checkDictData', + 'name' => 'require|length:1,255', + 'value' => 'require', + 'type_id' => 'require|checkDictType', + 'status' => 'require|in:0,1', + ]; + + + protected $message = [ + 'id.require' => '参数缺失', + 'name.require' => '请填写字典数据名称', + 'name.length' => '字典数据名称长度须在1-255位字符', + 'value.require' => '请填写字典数据值', + 'type_id.require' => '字典类型缺失', + 'status.require' => '请选择字典数据状态', + 'status.in' => '字典数据状态参数错误', + ]; + + + /** + * @notes 添加场景 + * @return DictDataValidate + * @author 段誉 + * @date 2022/6/20 16:54 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes ID场景 + * @return DictDataValidate + * @author 段誉 + * @date 2022/6/20 16:54 + */ + public function sceneId() + { + return $this->only(['id']); + } + + + /** + * @notes 编辑场景 + * @return DictDataValidate + * @author 段誉 + * @date 2022/6/20 18:36 + */ + public function sceneEdit() + { + return $this->remove('type_id', true); + } + + + /** + * @notes 校验字典数据 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2022/6/20 16:55 + */ + protected function checkDictData($value) + { + $article = DictData::findOrEmpty($value); + if ($article->isEmpty()) { + return '字典数据不存在'; + } + return true; + } + + + /** + * @notes 校验字典类型 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2022/6/20 17:03 + */ + protected function checkDictType($value) + { + $type = DictType::findOrEmpty($value); + if ($type->isEmpty()) { + return '字典类型不存在'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/dict/DictTypeValidate.php b/app/adminapi/validate/dict/DictTypeValidate.php new file mode 100644 index 0000000..6751da1 --- /dev/null +++ b/app/adminapi/validate/dict/DictTypeValidate.php @@ -0,0 +1,133 @@ + 'require|checkDictType', + 'name' => 'require|length:1,255', + 'type' => 'require|unique:' . DictType::class, + 'status' => 'require|in:0,1', + 'remark' => 'max:200', + ]; + + + protected $message = [ + 'id.require' => '参数缺失', + 'name.require' => '请填写字典名称', + 'name.length' => '字典名称长度须在1~255位字符', + 'type.require' => '请填写字典类型', + 'type.unique' => '字典类型已存在', + 'status.require' => '请选择状态', + 'remark.max' => '备注长度不能超过200', + ]; + + + /** + * @notes 添加场景 + * @return DictTypeValidate + * @author 段誉 + * @date 2022/6/20 16:00 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 详情场景 + * @return DictTypeValidate + * @author 段誉 + * @date 2022/6/20 16:00 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + + public function sceneEdit() + { + } + + + /** + * @notes 删除场景 + * @return DictTypeValidate + * @author 段誉 + * @date 2022/6/20 16:03 + */ + public function sceneDelete() + { + return $this->only(['id']) + ->append('id', 'checkAbleDelete'); + } + + + + /** + * @notes 检查字典类型是否存在 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2022/6/20 16:04 + */ + protected function checkDictType($value) + { + $dictType = DictType::findOrEmpty($value); + if ($dictType->isEmpty()) { + return '字典类型不存在'; + } + return true; + } + + + + /** + * @notes 验证是否可删除 + * @param $value + * @return bool|string + * @author 段誉 + * @date 2022/6/20 16:04 + */ + protected function checkAbleDelete($value) + { + $dictData = DictData::whereIn('type_id', $value)->select(); + + foreach ($dictData as $item) { + if (!empty($item)) { + return '字典类型已被使用,请先删除绑定该字典类型的数据'; + } + } + + return true; + } + + + +} \ No newline at end of file diff --git a/app/adminapi/validate/feedback/FeedbackCateValidate.php b/app/adminapi/validate/feedback/FeedbackCateValidate.php new file mode 100644 index 0000000..2e1015a --- /dev/null +++ b/app/adminapi/validate/feedback/FeedbackCateValidate.php @@ -0,0 +1,87 @@ + 'require', + 'name' => 'require', + 'sort' => 'require', + 'is_show' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '分类名称', + 'sort' => '排序', + 'is_show' => '显示状态', + ]; + + + /** + * @notes 添加场景 + * @return FeedbackCateValidate + * @author BD + * @date 2024/06/06 00:12 + */ + public function sceneAdd() + { + return $this->only(['name','sort','is_show']); + } + + + /** + * @notes 编辑场景 + * @return FeedbackCateValidate + * @author BD + * @date 2024/06/06 00:12 + */ + public function sceneEdit() + { + return $this->only(['id','name','sort','is_show']); + } + + + /** + * @notes 删除场景 + * @return FeedbackCateValidate + * @author BD + * @date 2024/06/06 00:12 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return FeedbackCateValidate + * @author BD + * @date 2024/06/06 00:12 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/feedback/FeedbackRecordValidate.php b/app/adminapi/validate/feedback/FeedbackRecordValidate.php new file mode 100644 index 0000000..8ce64c7 --- /dev/null +++ b/app/adminapi/validate/feedback/FeedbackRecordValidate.php @@ -0,0 +1,87 @@ + 'require', + 'user_id' => 'require', + 'cid' => 'require', + 'content' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'user_id' => '用户id', + 'cid' => '类型id', + 'content' => '反馈内容', + ]; + + + /** + * @notes 添加场景 + * @return FeedbackRecordValidate + * @author BD + * @date 2024/06/06 01:11 + */ + public function sceneAdd() + { + return $this->only(['user_id','cid','content']); + } + + + /** + * @notes 编辑场景 + * @return FeedbackRecordValidate + * @author BD + * @date 2024/06/06 01:11 + */ + public function sceneEdit() + { + return $this->only(['id','user_id','cid','content']); + } + + + /** + * @notes 删除场景 + * @return FeedbackRecordValidate + * @author BD + * @date 2024/06/06 01:11 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return FeedbackRecordValidate + * @author BD + * @date 2024/06/06 01:11 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/finance/RechargeRecordValidate.php b/app/adminapi/validate/finance/RechargeRecordValidate.php new file mode 100644 index 0000000..d1232e0 --- /dev/null +++ b/app/adminapi/validate/finance/RechargeRecordValidate.php @@ -0,0 +1,81 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 删除场景 + * @return RechargeRecordValidate + * @author bd + * @date 2024/01/31 14:07 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 同意场景 + * @return RechargeRecordValidate + * @author bd + * @date 2024/01/31 14:07 + */ + public function sceneAgree() + { + return $this->only(['id']); + } + + /** + * @notes 拒绝场景 + * @return RechargeRecordValidate + * @author bd + * @date 2024/01/31 14:07 + */ + public function sceneRefuse() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/finance/UserFinanceValidate.php b/app/adminapi/validate/finance/UserFinanceValidate.php new file mode 100644 index 0000000..7688359 --- /dev/null +++ b/app/adminapi/validate/finance/UserFinanceValidate.php @@ -0,0 +1,68 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + /** + * @notes 删除场景 + * @return UserFinanceValidate + * @author BD + * @date 2024/03/07 13:10 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + /** + * @notes 解冻场景 + * @return UserFinanceValidate + * @author BD + * @date 2024/03/07 13:10 + */ + public function sceneUnfrozen() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/finance/WithdrawRecordValidate.php b/app/adminapi/validate/finance/WithdrawRecordValidate.php new file mode 100644 index 0000000..da17c97 --- /dev/null +++ b/app/adminapi/validate/finance/WithdrawRecordValidate.php @@ -0,0 +1,91 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 删除场景 + * @return WithdrawRecordValidate + * @author BD + * @date 2024/02/25 12:35 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + /** + * @notes udun代付场景 + * @return RechargeRecordValidate + * @author bd + * @date 2024/01/31 14:07 + */ + public function sceneUdunPay() + { + return $this->only(['id']); + } + + /** + * @notes 同意场景 + * @return RechargeRecordValidate + * @author bd + * @date 2024/01/31 14:07 + */ + public function sceneAgree() + { + return $this->only(['id']); + } + + /** + * @notes 拒绝场景 + * @return RechargeRecordValidate + * @author bd + * @date 2024/01/31 14:07 + */ + public function sceneRefuse() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/goods/GoodsCateValidate.php b/app/adminapi/validate/goods/GoodsCateValidate.php new file mode 100644 index 0000000..13380c1 --- /dev/null +++ b/app/adminapi/validate/goods/GoodsCateValidate.php @@ -0,0 +1,96 @@ + 'require', + 'name' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '分类名称', + ]; + + + /** + * @notes 添加场景 + * @return GoodsCateValidate + * @author BD + * @date 2024/03/11 01:58 + */ + public function sceneAdd() + { + return $this->only(['name']); + } + + + /** + * @notes 编辑场景 + * @return GoodsCateValidate + * @author BD + * @date 2024/03/11 01:58 + */ + public function sceneEdit() + { + return $this->only(['id','name']); + } + + + /** + * @notes 删除场景 + * @return GoodsCateValidate + * @author BD + * @date 2024/03/11 01:58 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return GoodsCateValidate + * @author BD + * @date 2024/03/11 01:58 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/goods/GoodsRecordValidate.php b/app/adminapi/validate/goods/GoodsRecordValidate.php new file mode 100644 index 0000000..309ce28 --- /dev/null +++ b/app/adminapi/validate/goods/GoodsRecordValidate.php @@ -0,0 +1,88 @@ + 'require', + 'goods_id' => 'require', + 'sn' => 'require', + 'user_id' => 'require', + 'goods_title' => 'require', + 'goods_image' => 'require', + 'money' => 'require', + 'commission' => 'require', + 'status' => 'require', + 'type' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'goods_id' => '商品', + 'sn' => '订单编号', + 'user_id' => '用户id', + 'goods_title' => '商品标题', + 'goods_image' => '商品图片', + 'money' => '订单金额', + 'commission' => '佣金', + 'status' => '订单状态', + 'type' => '订单类型', + ]; + + + /** + * @notes 删除场景 + * @return GoodsRecordValidate + * @author BD + * @date 2024/03/19 02:29 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 派单场景 + * @return GoodsRecordValidate + * @author BD + * @date 2024/03/19 02:29 + */ + public function sceneDispatch() + { + return $this->only(['id','goods_id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/goods/GoodsValidate.php b/app/adminapi/validate/goods/GoodsValidate.php new file mode 100644 index 0000000..9a74817 --- /dev/null +++ b/app/adminapi/validate/goods/GoodsValidate.php @@ -0,0 +1,106 @@ + 'require', + 'cid' => 'require', + 'title' => 'require', + 'image' => 'require', + 'money' => 'require', + 'is_show' => 'require', + 'sort' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'cid' => '商品分类', + 'title' => '标题', + 'image' => '图片', + 'money' => '金额', + 'is_show' => '显示状态', + 'sort' => '排序', + ]; + + + /** + * @notes 添加场景 + * @return GoodsValidate + * @author BD + * @date 2024/03/11 01:58 + */ + public function sceneAdd() + { + return $this->only(['cid','title','image','money','is_show','sort']); + } + + + /** + * @notes 编辑场景 + * @return GoodsValidate + * @author BD + * @date 2024/03/11 01:58 + */ + public function sceneEdit() + { + return $this->only(['id','cid','title','image','money','is_show','sort']); + } + + + /** + * @notes 删除场景 + * @return GoodsValidate + * @author BD + * @date 2024/03/11 01:58 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return GoodsValidate + * @author BD + * @date 2024/03/11 01:58 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/item/ItemCateValidate.php b/app/adminapi/validate/item/ItemCateValidate.php new file mode 100644 index 0000000..f556b9e --- /dev/null +++ b/app/adminapi/validate/item/ItemCateValidate.php @@ -0,0 +1,111 @@ + 'require', + 'name' => 'require', + 'sort' => 'require', + 'is_show' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '分类名称', + 'sort' => '排序', + 'is_show' => '是否显示', + ]; + + + /** + * @notes 添加场景 + * @return ItemCateValidate + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function sceneAdd() + { + return $this->only(['name','sort','is_show']); + } + + + /** + * @notes 编辑场景 + * @return ItemCateValidate + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function sceneEdit() + { + return $this->only(['id','name','sort','is_show']); + } + + + /** + * @notes 删除场景 + * @return ItemCateValidate + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return ItemCateValidate + * @author likeadmin + * @date 2024/01/16 13:23 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 更改状态场景 + * @return ArticleCateValidate + * @author heshihu + * @date 2022/2/21 18:02 + */ + public function sceneStatus() + { + return $this->only(['id', 'is_show']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/item/ItemRecordValidate.php b/app/adminapi/validate/item/ItemRecordValidate.php new file mode 100644 index 0000000..b8f9bba --- /dev/null +++ b/app/adminapi/validate/item/ItemRecordValidate.php @@ -0,0 +1,103 @@ + 'require', + 'sn' => 'require', + 'contract_no' => 'require', + 'user_id' => 'require', + 'item_id' => 'require', + 'money' => 'require', + 'rate' => 'require', + 'cycle' => 'require', + 'total_num' => 'require', + 'wait_num' => 'require', + 'type' => 'require', + 'status' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'sn' => '订单编号', + 'contract_no' => '合同编号', + 'user_id' => '用户id', + 'item_id' => '项目id', + 'money' => '订单金额', + 'rate' => '利率', + 'cycle' => '周期', + 'total_num' => '总期数', + 'wait_num' => '剩余期数', + 'type' => '投资类型', + 'status' => '状态', + ]; + + + /** + * @notes 添加场景 + * @return ItemRecordValidate + * @author BD + * @date 2024/08/07 15:42 + */ + public function sceneAdd() + { + return $this->only(['sn','contract_no','user_id','item_id','money','rate','cycle','total_num','wait_num','type','status']); + } + + + /** + * @notes 编辑场景 + * @return ItemRecordValidate + * @author BD + * @date 2024/08/07 15:42 + */ + public function sceneEdit() + { + return $this->only(['id','sn','contract_no','user_id','item_id','money','rate','cycle','total_num','wait_num','type','status']); + } + + + /** + * @notes 删除场景 + * @return ItemRecordValidate + * @author BD + * @date 2024/08/07 15:42 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return ItemRecordValidate + * @author BD + * @date 2024/08/07 15:42 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/item/ItemValidate.php b/app/adminapi/validate/item/ItemValidate.php new file mode 100644 index 0000000..1de0ba6 --- /dev/null +++ b/app/adminapi/validate/item/ItemValidate.php @@ -0,0 +1,114 @@ + 'require', + 'cid' => 'require', + 'type' => 'require', + 'title' => 'require', + 'min_money' => 'require', + 'max_money' => 'require', + 'rate' => 'require', + 'cycle' => 'require', + 'progress' => 'require', + 'progress_auto' => 'require', + 'is_show' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'cid' => '项目分类', + 'type' => '投资类型', + 'title' => '项目标题', + 'min_money' => '最小投资额', + 'max_money' => '最大投资额', + 'rate' => '利率', + 'cycle' => '周期', + 'progress' => '项目进度', + 'progress_auto' => '自增进度', + 'is_show' => '是否显示', + ]; + + + /** + * @notes 添加场景 + * @return ItemValidate + * @author BD + * @date 2024/01/16 13:23 + */ + public function sceneAdd() + { + return $this->only(['cid','type','title','min_money','max_money','rate','cycle','progress','progress_auto','is_show']); + } + + + /** + * @notes 编辑场景 + * @return ItemValidate + * @author BD + * @date 2024/01/16 13:23 + */ + public function sceneEdit() + { + return $this->only(['id','cid','type','title','min_money','max_money','rate','cycle','progress','progress_auto','is_show']); + } + + + /** + * @notes 删除场景 + * @return ItemValidate + * @author BD + * @date 2024/01/16 13:23 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return ItemValidate + * @author BD + * @date 2024/01/16 13:23 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/lh/LhCoinValidate.php b/app/adminapi/validate/lh/LhCoinValidate.php new file mode 100644 index 0000000..57de326 --- /dev/null +++ b/app/adminapi/validate/lh/LhCoinValidate.php @@ -0,0 +1,97 @@ + 'require', + 'name' => 'require', + 'logo' => 'require', + 'symbol' => 'require', + 'symbol_market' => 'require', + 'price' => 'require', + 'buy_name' => 'require', + 'sale_name' => 'require', + 'is_show' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '货币名称', + 'logo' => 'Logo', + 'symbol' => '货币符号', + 'symbol_market' => '货币标识', + 'price' => '价格', + 'buy_name' => '买入平台', + 'sale_name' => '卖出平台', + 'is_show' => '显示状态', + ]; + + + /** + * @notes 添加场景 + * @return LhCoinValidate + * @author BD + * @date 2024/05/19 21:13 + */ + public function sceneAdd() + { + return $this->only(['name','logo','symbol','buy_name','sale_name','is_show']); + } + + + /** + * @notes 编辑场景 + * @return LhCoinValidate + * @author BD + * @date 2024/05/19 21:13 + */ + public function sceneEdit() + { + return $this->only(['id','name','logo','symbol','buy_name','sale_name','is_show']); + } + + + /** + * @notes 删除场景 + * @return LhCoinValidate + * @author BD + * @date 2024/05/19 21:13 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return LhCoinValidate + * @author BD + * @date 2024/05/19 21:13 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/lh/LhRecordValidate.php b/app/adminapi/validate/lh/LhRecordValidate.php new file mode 100644 index 0000000..2cab893 --- /dev/null +++ b/app/adminapi/validate/lh/LhRecordValidate.php @@ -0,0 +1,105 @@ + 'require', + 'sn' => 'require', + 'user_id' => 'require', + 'coin_id' => 'require', + 'coin_name' => 'require', + 'coin_logo' => 'require', + 'coin_symbol' => 'require', + 'coin_buy_name' => 'require', + 'coin_sale_name' => 'require', + 'money' => 'require', + 'income' => 'require', + 'money_buy' => 'require', + 'money_sale' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'sn' => '订单编号', + 'user_id' => '用户id', + 'coin_id' => '货币id', + 'coin_name' => '货币名称', + 'coin_logo' => 'Logo', + 'coin_symbol' => '货币符号', + 'coin_buy_name' => '买入平台', + 'coin_sale_name' => '卖出平台', + 'money' => '投资金额', + 'income' => '利润', + 'money_buy' => '买入金额', + 'money_sale' => '卖出金额', + ]; + + + /** + * @notes 添加场景 + * @return LhRecordValidate + * @author BD + * @date 2024/05/19 21:13 + */ + public function sceneAdd() + { + return $this->only(['sn','user_id','coin_id','coin_name','coin_logo','coin_symbol','coin_buy_name','coin_sale_name','money','income','money_buy','money_sale']); + } + + + /** + * @notes 编辑场景 + * @return LhRecordValidate + * @author BD + * @date 2024/05/19 21:13 + */ + public function sceneEdit() + { + return $this->only(['id','sn','user_id','coin_id','coin_name','coin_logo','coin_symbol','coin_buy_name','coin_sale_name','money','income','money_buy','money_sale']); + } + + + /** + * @notes 删除场景 + * @return LhRecordValidate + * @author BD + * @date 2024/05/19 21:13 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return LhRecordValidate + * @author BD + * @date 2024/05/19 21:13 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/mall/MallGoodsRecordValidate.php b/app/adminapi/validate/mall/MallGoodsRecordValidate.php new file mode 100644 index 0000000..37c3e5e --- /dev/null +++ b/app/adminapi/validate/mall/MallGoodsRecordValidate.php @@ -0,0 +1,97 @@ + 'require', + 'sn' => 'require', + 'user_id' => 'require', + 'm_goods_id' => 'require', + 'm_goods_title' => 'require', + 'm_goods_image' => 'require', + 'status' => 'require', + 'type' => 'require', + 'type2' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'sn' => '订单编号', + 'user_id' => '用户id', + 'm_goods_id' => '商品id', + 'm_goods_title' => '商品标题', + 'm_goods_image' => '商品图片', + 'status' => '状态', + 'type' => '奖品分类', + 'type2' => '奖品类型', + ]; + + + /** + * @notes 添加场景 + * @return MallGoodsRecordValidate + * @author BD + * @date 2024/10/15 14:00 + */ + public function sceneAdd() + { + return $this->only(['sn','user_id','m_goods_id','m_goods_title','m_goods_image','status','type','type2']); + } + + + /** + * @notes 编辑场景 + * @return MallGoodsRecordValidate + * @author BD + * @date 2024/10/15 14:00 + */ + public function sceneEdit() + { + return $this->only(['id','sn','user_id','m_goods_id','m_goods_title','m_goods_image','status','type','type2']); + } + + + /** + * @notes 删除场景 + * @return MallGoodsRecordValidate + * @author BD + * @date 2024/10/15 14:00 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return MallGoodsRecordValidate + * @author BD + * @date 2024/10/15 14:00 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/mall/MallGoodsValidate.php b/app/adminapi/validate/mall/MallGoodsValidate.php new file mode 100644 index 0000000..65bedc9 --- /dev/null +++ b/app/adminapi/validate/mall/MallGoodsValidate.php @@ -0,0 +1,97 @@ + 'require', + 'title' => 'require', + 'price' => 'require', + 'money' => 'require', + 'point' => 'require', + 'type' => 'require', + 'type2' => 'require', + 'is_show' => 'require', + 'sort' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'title' => '奖品标题', + 'price' => '所需积分', + 'money' => '现金金额', + 'point' => '奖品积分', + 'type' => '奖品分类', + 'type2' => '奖品类型', + 'is_show' => '显示状态', + 'sort' => '排序', + ]; + + + /** + * @notes 添加场景 + * @return MallGoodsValidate + * @author BD + * @date 2024/10/14 23:57 + */ + public function sceneAdd() + { + return $this->only(['title','price','money','point','type','type2','is_show','sort']); + } + + + /** + * @notes 编辑场景 + * @return MallGoodsValidate + * @author BD + * @date 2024/10/14 23:57 + */ + public function sceneEdit() + { + return $this->only(['id','title','price','money','point','type','type2','is_show','sort']); + } + + + /** + * @notes 删除场景 + * @return MallGoodsValidate + * @author BD + * @date 2024/10/14 23:57 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return MallGoodsValidate + * @author BD + * @date 2024/10/14 23:57 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/member/UserMemberValidate.php b/app/adminapi/validate/member/UserMemberValidate.php new file mode 100644 index 0000000..24e819c --- /dev/null +++ b/app/adminapi/validate/member/UserMemberValidate.php @@ -0,0 +1,116 @@ + 'require', + 'name' => 'require', + 'logo' => 'require', + 'bg_img' => 'require', + 'text_color' => 'require', + 'money' => 'require', + 'level1_num' => 'require', + // 'lh_min' => 'require', + // 'lh_max' => 'require', + // 'rate_min' => 'require', + // 'rate_max' => 'require', + // 'lh_num' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '等级名称', + 'logo' => 'LOGO', + 'bg_img' => '背景图', + 'text_color' => '文字颜色', + 'money' => '有效金额', + 'level1_num' => '1代有效人数', + // 'lh_min' => '量化最低金额', + // 'lh_max' => '量化最高金额', + // 'rate_min' => '最小收益率', + // 'rate_max' => '最大收益率', + // 'lh_num' => '每日量化次数', + ]; + + + /** + * @notes 添加场景 + * @return UserMemberValidate + * @author BD + * @date 2024/03/14 00:28 + */ + public function sceneAdd() + { + return $this->only(['name','logo','bg_img','text_color','money','level1_num']); + } + + + /** + * @notes 编辑场景 + * @return UserMemberValidate + * @author BD + * @date 2024/03/14 00:28 + */ + public function sceneEdit() + { + return $this->only(['name','logo','bg_img','text_color','money','level1_num']); + } + + + /** + * @notes 删除场景 + * @return UserMemberValidate + * @author BD + * @date 2024/03/14 00:28 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserMemberValidate + * @author BD + * @date 2024/03/14 00:28 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/notice/NoticeValidate.php b/app/adminapi/validate/notice/NoticeValidate.php new file mode 100644 index 0000000..ae0b4d7 --- /dev/null +++ b/app/adminapi/validate/notice/NoticeValidate.php @@ -0,0 +1,39 @@ + 'require', + ]; + + protected $message = [ + 'id.require' => '参数缺失', + ]; + + protected function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/notice/SmsConfigValidate.php b/app/adminapi/validate/notice/SmsConfigValidate.php new file mode 100644 index 0000000..f92a864 --- /dev/null +++ b/app/adminapi/validate/notice/SmsConfigValidate.php @@ -0,0 +1,59 @@ + 'require', + 'sign' => 'require', + 'app_id' => 'requireIf:type,tencent', + 'app_key' => 'requireIf:type,ali', + 'secret_id' => 'requireIf:type,tencent', + 'secret_key' => 'requireIf:type,tencent|requireIf:type,ali', + 'status' => 'require', + 'username' => 'requireIf:type,smsbao', + 'url_cn' => 'requireIf:type,smsbao', + 'url_go' => 'requireIf:type,smsbao', + 'api_key' => 'requireIf:type,smsbao', + ]; + + protected $message = [ + 'type.require' => '请选择类型', + 'sign.require' => '请输入签名', + 'app_id.requireIf' => '请输入app_id', + 'app_key.requireIf' => '请输入app_key', + 'secret_id.requireIf' => '请输入secret_id', + 'secret_key.requireIf' => '请输入secret_key', + 'status.require' => '请选择状态', + 'username.requireIf' => '请输入用户名', + 'url_cn.requireIf' => '请输入接口域名(国内)', + 'url_go.requireIf' => '请输入接口域名(国际)', + 'api_key.requireIf' => '请输入API Key', + ]; + + + protected function sceneDetail() + { + return $this->only(['type']); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/setting/LanguagePagValidate.php b/app/adminapi/validate/setting/LanguagePagValidate.php new file mode 100644 index 0000000..0d6bfd8 --- /dev/null +++ b/app/adminapi/validate/setting/LanguagePagValidate.php @@ -0,0 +1,100 @@ + 'require', + 'type' => 'require', + 'name' => 'require', + 'value' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'type' => '类型', + 'name' => '名称', + 'value' => '值', + ]; + + + /** + * @notes 添加场景 + * @return LanguagePagValidate + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public function sceneAdd() + { + return $this->only(['type','name']); + } + + + /** + * @notes 编辑场景 + * @return LanguagePagValidate + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public function sceneEdit() + { + return $this->only(['id','type','name']); + } + + + /** + * @notes 删除场景 + * @return LanguagePagValidate + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return LanguagePagValidate + * @author likeadmin + * @date 2024/01/14 13:50 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/setting/LanguageValidate.php b/app/adminapi/validate/setting/LanguageValidate.php new file mode 100644 index 0000000..297bcef --- /dev/null +++ b/app/adminapi/validate/setting/LanguageValidate.php @@ -0,0 +1,115 @@ + 'require', + 'name' => 'require', + 'name_loc' => 'require', + 'symbol' => 'require', + 'precision' => 'require', + 'is_show' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '语言名称', + 'name_loc' => '语言名称', + 'symbol' => '语言标识', + 'precision' => '显示精度', + 'is_show' => '是否显示', + ]; + + + /** + * @notes 添加场景 + * @return LanguageValidate + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public function sceneAdd() + { + return $this->only(['name','name_loc','symbol','precision','is_show']); + } + + + /** + * @notes 编辑场景 + * @return LanguageValidate + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public function sceneEdit() + { + return $this->only(['id','name','name_loc','symbol','precision','is_show']); + } + + + /** + * @notes 删除场景 + * @return LanguageValidate + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return LanguageValidate + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 更改状态场景 + * @return ArticleValidate + * @author heshihu + * @date 2022/2/22 10:18 + */ + public function sceneStatus() + { + return $this->only(['id', 'is_show']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/setting/OperationLogValidate.php b/app/adminapi/validate/setting/OperationLogValidate.php new file mode 100644 index 0000000..25f836f --- /dev/null +++ b/app/adminapi/validate/setting/OperationLogValidate.php @@ -0,0 +1,38 @@ + 'require', + ]; + + protected $message = [ + 'id.require' => '参数缺失', + ]; + +} \ No newline at end of file diff --git a/app/adminapi/validate/setting/RechargeMethodValidate.php b/app/adminapi/validate/setting/RechargeMethodValidate.php new file mode 100644 index 0000000..f1c241b --- /dev/null +++ b/app/adminapi/validate/setting/RechargeMethodValidate.php @@ -0,0 +1,130 @@ + 'require', + 'lang_id' => 'require', + 'type' => 'require', + 'name' => 'require', + 'rate' => 'require', + 'is_show' => 'require', + + 'money' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'lang_id' => '所属语言ID', + 'type' => '类型1USDT2扫码3银行卡4在线', + 'name' => '名称', + 'rate' => '汇率', + 'is_show' => '是否显示:1-是.0-否', + + 'money' => '请输入常用金额', + ]; + + + /** + * @notes 添加场景 + * @return RechargeMethodValidate + * @author likeadmin + * @date 2023/11/30 15:22 + */ + public function sceneAdd() + { + return $this->only(['lang_id','type','name','rate','is_show']); + } + + + /** + * @notes 编辑场景 + * @return RechargeMethodValidate + * @author likeadmin + * @date 2023/11/30 15:22 + */ + public function sceneEdit() + { + return $this->only(['id','lang_id','type','name','rate','is_show']); + } + + + /** + * @notes 删除场景 + * @return RechargeMethodValidate + * @author likeadmin + * @date 2023/11/30 15:22 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return RechargeMethodValidate + * @author likeadmin + * @date 2023/11/30 15:22 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 更改状态场景 + * @return ArticleValidate + * @author heshihu + * @date 2022/2/22 10:18 + */ + public function sceneStatus() + { + return $this->only(['id', 'is_show']); + } + + /** + * @notes 常用金额场景 + * @return RechargeMethodValidate + * @author likeadmin + * @date 2023/11/30 15:22 + */ + public function sceneMoney() + { + return $this->only(['money']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/setting/StorageValidate.php b/app/adminapi/validate/setting/StorageValidate.php new file mode 100644 index 0000000..92a358e --- /dev/null +++ b/app/adminapi/validate/setting/StorageValidate.php @@ -0,0 +1,70 @@ + 'require', + 'status' => 'require', + ]; + + + + /** + * @notes 设置存储引擎参数场景 + * @return StorageValidate + * @author 段誉 + * @date 2022/4/20 16:18 + */ + public function sceneSetup() + { + return $this->only(['engine', 'status']); + } + + + /** + * @notes 获取配置参数信息场景 + * @return StorageValidate + * @author 段誉 + * @date 2022/4/20 16:18 + */ + public function sceneDetail() + { + return $this->only(['engine']); + } + + + /** + * @notes 切换存储引擎场景 + * @return StorageValidate + * @author 段誉 + * @date 2022/4/20 16:18 + */ + public function sceneChange() + { + return $this->only(['engine']); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/setting/TransactionSettingsValidate.php b/app/adminapi/validate/setting/TransactionSettingsValidate.php new file mode 100644 index 0000000..5c75062 --- /dev/null +++ b/app/adminapi/validate/setting/TransactionSettingsValidate.php @@ -0,0 +1,51 @@ + 'require|in:0,1', + 'cancel_unpaid_orders_times' => 'requireIf:cancel_unpaid_orders,1|integer|gt:0', + 'verification_orders' => 'require|in:0,1', + 'verification_orders_times' => 'requireIf:verification_orders,1|integer|gt:0', + ]; + + protected $message = [ + 'cancel_unpaid_orders.require' => '请选择系统取消待付款订单方式', + 'cancel_unpaid_orders.in' => '系统取消待付款订单状态值有误', + 'cancel_unpaid_orders_times.requireIf' => '系统取消待付款订单时间未填写', + 'cancel_unpaid_orders_times.integer' => '系统取消待付款订单时间须为整型', + 'cancel_unpaid_orders_times.gt' => '系统取消待付款订单时间须大于0', + + 'verification_orders.require' => '请选择系统自动核销订单方式', + 'verification_orders.in' => '系统自动核销订单状态值有误', + 'verification_orders_times.requireIf' => '系统自动核销订单时间未填写', + 'verification_orders_times.integer' => '系统自动核销订单时间须为整型', + 'verification_orders_times.gt' => '系统自动核销订单时间须大于0', + ]; + + public function sceneSetConfig() + { + return $this->only(['cancel_unpaid_orders','cancel_unpaid_orders_times','verification_orders','verification_orders_times']); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/setting/UserConfigValidate.php b/app/adminapi/validate/setting/UserConfigValidate.php new file mode 100644 index 0000000..d0bd678 --- /dev/null +++ b/app/adminapi/validate/setting/UserConfigValidate.php @@ -0,0 +1,62 @@ + 'requireIf:scene,register|array', + 'coerce_mobile' => 'requireIf:scene,register|in:0,1', + 'login_agreement' => 'in:0,1', + 'third_auth' => 'in:0,1', + 'wechat_auth' => 'in:0,1', + 'default_avatar' => 'require', + 'password_pay' => 'require|length:6|integer', + ]; + + + protected $message = [ + 'default_avatar.require' => '请上传用户默认头像', + 'login_way.requireIf' => '请选择登录方式', + 'login_way.array' => '登录方式值错误', + 'coerce_mobile.requireIf' => '请选择注册强制绑定手机', + 'coerce_mobile.in' => '注册强制绑定手机值错误', + 'wechat_auth.in' => '公众号微信授权登录值错误', + 'third_auth.in' => '第三方登录值错误', + 'login_agreement.in' => '政策协议值错误', + 'password_pay.require' => '请输入初始支付密码', + 'password_pay.length' => '初始支付密码为6位数字', + 'password_pay.integer' => '初始支付密码为6位数字', + ]; + + //用户设置验证 + public function sceneUser() + { + return $this->only(['default_avatar']); + } + + //注册验证 + public function sceneRegister() + { + return $this->only(['login_way', 'coerce_mobile', 'login_agreement', 'third_auth', 'wechat_auth', 'password_pay']); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/setting/WebSettingValidate.php b/app/adminapi/validate/setting/WebSettingValidate.php new file mode 100644 index 0000000..359ad61 --- /dev/null +++ b/app/adminapi/validate/setting/WebSettingValidate.php @@ -0,0 +1,50 @@ + 'require|max:30', + 'web_favicon' => 'require', + 'web_logo' => 'require', + 'login_image' => 'require', + 'shop_name' => 'require', + 'shop_logo' => 'require', + 'pc_logo' => 'require', + ]; + + protected $message = [ + 'name.require' => '请填写网站名称', + 'name.max' => '网站名称最长为12个字符', + 'web_favicon.require' => '请上传网站图标', + 'web_logo.require' => '请上传网站logo', + 'login_image.require' => '请上传登录页广告图', + 'shop_name.require' => '请填写前台名称', + 'shop_logo.require' => '请上传前台logo', + 'pc_logo.require' => '请上传PC端logo', + ]; + + protected $scene = [ + 'website' => ['name', 'web_favicon', 'web_logo', 'login_image', 'shop_name', 'shop_logo', 'pc_logo'], + ]; +} \ No newline at end of file diff --git a/app/adminapi/validate/tools/EditTableValidate.php b/app/adminapi/validate/tools/EditTableValidate.php new file mode 100644 index 0000000..a3b3ae0 --- /dev/null +++ b/app/adminapi/validate/tools/EditTableValidate.php @@ -0,0 +1,98 @@ + 'require|checkTableData', + 'table_name' => 'require', + 'table_comment' => 'require', + 'template_type' => 'require|in:0,1', + 'generate_type' => 'require|in:0,1', + 'module_name' => 'require', + 'table_column' => 'require|array|checkColumn', + ]; + + protected $message = [ + 'id.require' => '表id缺失', + 'table_name.require' => '请填写表名称', + 'table_comment.require' => '请填写表描述', + 'template_type.require' => '请选择模板类型', + 'template_type.in' => '模板类型参数错误', + 'generate_type.require' => '请选择生成方式', + 'generate_type.in' => '生成方式类型错误', + 'module_name.require' => '请填写模块名称', + 'table_column.require' => '表字段信息缺失', + 'table_column.array' => '表字段信息类型错误', + ]; + + + /** + * @notes 校验当前数据表是否存在 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/6/15 18:58 + */ + protected function checkTableData($value, $rule, $data) + { + $table = GenerateTable::findOrEmpty($value); + if ($table->isEmpty()) { + return '信息不存在'; + } + return true; + } + + + /** + * @notes 校验表字段参数 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/6/20 10:42 + */ + protected function checkColumn($value, $rule, $data) + { + foreach ($value as $item) { + if (!isset($item['id'])) { + return '表字段id参数缺失'; + } + if (!isset($item['query_type'])) { + return '请选择查询方式'; + } + if (!isset($item['view_type'])) { + return '请选择显示类型'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/tools/GenerateTableValidate.php b/app/adminapi/validate/tools/GenerateTableValidate.php new file mode 100644 index 0000000..be5674c --- /dev/null +++ b/app/adminapi/validate/tools/GenerateTableValidate.php @@ -0,0 +1,131 @@ + 'require|checkTableData', + 'table' => 'require|array|checkTable', + 'file' => 'require' + ]; + + protected $message = [ + 'id.require' => '参数缺失', + 'table.require' => '参数缺失', + 'table.array' => '参数类型错误', + 'file.require' => '下载失败', + ]; + + + /** + * @notes 选择数据表场景 + * @return GenerateTableValidate + * @author 段誉 + * @date 2022/6/15 18:58 + */ + public function sceneSelect() + { + return $this->only(['table']); + } + + + /** + * @notes 需要校验id的场景 + * @return GenerateTableValidate + * @author 段誉 + * @date 2022/6/15 18:58 + */ + public function sceneId() + { + return $this->only(['id']); + } + + + /** + * @notes 下载场景 + * @return GenerateTableValidate + * @author 段誉 + * @date 2022/6/24 10:02 + */ + public function sceneDownload() + { + return $this->only(['file']); + } + + + /** + * @notes 校验选择的数据表信息 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/6/15 18:58 + */ + protected function checkTable($value, $rule, $data) + { + foreach ($value as $item) { + if (!isset($item['name']) || !isset($item['comment'])) { + return '参数缺失'; + } + $exist = Db::query("SHOW TABLES LIKE'" . $item['name'] . "'"); + if (empty($exist)) { + return '当前数据库不存在' . $item['name'] . '表'; + } + } + return true; + } + + + /** + * @notes 校验当前数据表是否存在 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/6/15 18:58 + */ + protected function checkTableData($value, $rule, $data) + { + if (!is_array($value)) { + $value = [$value]; + } + + foreach ($value as $item) { + $table = GenerateTable::findOrEmpty($item); + if ($table->isEmpty()) { + return '信息不存在'; + } + } + + return true; + } + + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/AddUserValidate.php b/app/adminapi/validate/user/AddUserValidate.php new file mode 100644 index 0000000..46d5054 --- /dev/null +++ b/app/adminapi/validate/user/AddUserValidate.php @@ -0,0 +1,79 @@ + '^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]+$', + 'password' => '/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){6,20}$/' + ]; + + protected $rule = [ + 'channel' => 'require', + 'account' => 'require|unique:' . User::class . '|checkAccount', + 'password' => 'require|length:6,20|regex:password', + ]; + + protected $message = [ + 'channel.require' => '注册来源参数缺失',//注册来源参数缺失 + 'account.require' => '请输入账号',//请输入账号 + 'account.unique' => '账号已存在',//账号已存在 + 'password.require' => '请输入密码',//请输入密码 + 'password.length' => '密码须在6-20位之间',//密码须在6-20位之间 + 'password.regex' => '密码须为字母数字组合',//密码须为字母数字组合 + ]; + + /** + * @notes 校验注册 + * @param $buy + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/02/22 10:54 + */ + protected function checkAccount($account, $rule, $data) + { + $login_way = $data['login_way'];//0邮箱1手机号 + + $mobile_pattern = '/^\d{6,20}$/'; + + if($login_way == 0){ + if(!filter_var($data['account'], FILTER_VALIDATE_EMAIL)){ + return '请输入正确的邮箱地址'; + } + }elseif($login_way == 1){ + if(!preg_match($mobile_pattern, $data['account'])){ + return '请输入正确的手机号'; + } + }else{ + return '参数异常'; + } + + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/AdjustUserMoney.php b/app/adminapi/validate/user/AdjustUserMoney.php new file mode 100644 index 0000000..67087ce --- /dev/null +++ b/app/adminapi/validate/user/AdjustUserMoney.php @@ -0,0 +1,65 @@ + 'require', + 'action' => 'require|in:1,2,3', + 'num' => 'require|gt:0|checkMoney', + 'remark' => 'max:128', + ]; + + protected $message = [ + 'id.require' => '请选择用户', + 'action.require' => '请选择调整类型', + 'action.in' => '调整类型错误', + 'num.require' => '请输入调整数量', + 'num.gt' => '调整余额必须大于零', + 'remark' => '备注不可超过128个符号', + ]; + + + protected function checkMoney($vaule, $rule, $data) + { + $user = User::find($data['user_id']); + if (empty($user)) { + return '用户不存在'; + } + + if (1 == $data['action'] || 3 == $data['action']) { + return true; + } + + $surplusMoeny = $user->user_money - floatval($vaule); + if ($surplusMoeny < 0) { + return '用户可用余额仅剩' . $user->user_money; + } + + return true; + } + + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserGroupRuleValidate.php b/app/adminapi/validate/user/UserGroupRuleValidate.php new file mode 100644 index 0000000..d0f03c0 --- /dev/null +++ b/app/adminapi/validate/user/UserGroupRuleValidate.php @@ -0,0 +1,89 @@ + 'require', + 'group_id' => 'require', + 'num' => 'require', + 'money_type' => 'require', + 'commission_type' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'group_id' => '分组', + 'num' => '第几单', + 'money_type' => '金额类型1固定值2百分比', + 'commission_type' => '佣金类型1固定值2百分比', + ]; + + + /** + * @notes 添加场景 + * @return UserGroupRuleValidate + * @author BD + * @date 2024/04/25 01:30 + */ + public function sceneAdd() + { + return $this->only(['num','money_type','commission_type']); + } + + + /** + * @notes 编辑场景 + * @return UserGroupRuleValidate + * @author BD + * @date 2024/04/25 01:30 + */ + public function sceneEdit() + { + return $this->only(['id','num','money_type','commission_type']); + } + + + /** + * @notes 删除场景 + * @return UserGroupRuleValidate + * @author BD + * @date 2024/04/25 01:30 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserGroupRuleValidate + * @author BD + * @date 2024/04/25 01:30 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserGroupValidate.php b/app/adminapi/validate/user/UserGroupValidate.php new file mode 100644 index 0000000..7456684 --- /dev/null +++ b/app/adminapi/validate/user/UserGroupValidate.php @@ -0,0 +1,83 @@ + 'require', + 'name' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '分组名称', + ]; + + + /** + * @notes 添加场景 + * @return UserGroupValidate + * @author BD + * @date 2024/04/25 01:04 + */ + public function sceneAdd() + { + return $this->only(['name']); + } + + + /** + * @notes 编辑场景 + * @return UserGroupValidate + * @author BD + * @date 2024/04/25 01:04 + */ + public function sceneEdit() + { + return $this->only(['id','name']); + } + + + /** + * @notes 删除场景 + * @return UserGroupValidate + * @author BD + * @date 2024/04/25 01:04 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserGroupValidate + * @author BD + * @date 2024/04/25 01:04 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserInfoValidate.php b/app/adminapi/validate/user/UserInfoValidate.php new file mode 100644 index 0000000..79693f2 --- /dev/null +++ b/app/adminapi/validate/user/UserInfoValidate.php @@ -0,0 +1,83 @@ + 'require', + 'user_id' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'user_id' => '用户id', + ]; + + + /** + * @notes 添加场景 + * @return UserInfoValidate + * @author BD + * @date 2024/06/08 17:51 + */ + public function sceneAdd() + { + return $this->only(['user_id']); + } + + + /** + * @notes 编辑场景 + * @return UserInfoValidate + * @author BD + * @date 2024/06/08 17:51 + */ + public function sceneEdit() + { + return $this->only(['id','user_id']); + } + + + /** + * @notes 删除场景 + * @return UserInfoValidate + * @author BD + * @date 2024/06/08 17:51 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserInfoValidate + * @author BD + * @date 2024/06/08 17:51 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserKadanValidate.php b/app/adminapi/validate/user/UserKadanValidate.php new file mode 100644 index 0000000..9e58057 --- /dev/null +++ b/app/adminapi/validate/user/UserKadanValidate.php @@ -0,0 +1,89 @@ + 'require', + 'user_id' => 'require', + 'num' => 'require', + 'money' => 'require', + 'commission' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'user_id' => '用户', + 'num' => '第几单', + 'money' => '订单金额', + 'commission' => '佣金', + ]; + + + /** + * @notes 添加场景 + * @return UserKadanValidate + * @author BD + * @date 2024/04/24 17:00 + */ + public function sceneAdd() + { + return $this->only(['user_id','num','money','commission']); + } + + + /** + * @notes 编辑场景 + * @return UserKadanValidate + * @author BD + * @date 2024/04/24 17:00 + */ + public function sceneEdit() + { + return $this->only(['id','user_id','num','money','commission']); + } + + + /** + * @notes 删除场景 + * @return UserKadanValidate + * @author BD + * @date 2024/04/24 17:00 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserKadanValidate + * @author BD + * @date 2024/04/24 17:00 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserMineRecordValidate.php b/app/adminapi/validate/user/UserMineRecordValidate.php new file mode 100644 index 0000000..76b3060 --- /dev/null +++ b/app/adminapi/validate/user/UserMineRecordValidate.php @@ -0,0 +1,81 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return UserMineRecordValidate + * @author BD + * @date 2025/01/01 15:47 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return UserMineRecordValidate + * @author BD + * @date 2025/01/01 15:47 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return UserMineRecordValidate + * @author BD + * @date 2025/01/01 15:47 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserMineRecordValidate + * @author BD + * @date 2025/01/01 15:47 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserNoticeValidate.php b/app/adminapi/validate/user/UserNoticeValidate.php new file mode 100644 index 0000000..c5b3c89 --- /dev/null +++ b/app/adminapi/validate/user/UserNoticeValidate.php @@ -0,0 +1,91 @@ + 'require', + 'user_id' => 'require', + 'title' => 'require', + 'content' => 'require', + 'notice_type' => 'require', + 'langs' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'user_id' => '用户id', + 'title' => '标题', + 'content' => '内容', + 'notice_type' => '消息类型', + 'langs' => '多语言存储', + ]; + + + /** + * @notes 添加场景 + * @return UserNoticeValidate + * @author BD + * @date 2024/05/26 00:36 + */ + public function sceneAdd() + { + return $this->only(['user_id','title','content','read','notice_type','langs']); + } + + + /** + * @notes 编辑场景 + * @return UserNoticeValidate + * @author BD + * @date 2024/05/26 00:36 + */ + public function sceneEdit() + { + return $this->only(['id','user_id','title','content','read','notice_type','langs']); + } + + + /** + * @notes 删除场景 + * @return UserNoticeValidate + * @author BD + * @date 2024/05/26 00:36 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserNoticeValidate + * @author BD + * @date 2024/05/26 00:36 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserRelationValidate.php b/app/adminapi/validate/user/UserRelationValidate.php new file mode 100644 index 0000000..2d426a8 --- /dev/null +++ b/app/adminapi/validate/user/UserRelationValidate.php @@ -0,0 +1,53 @@ + 'require', + 'user_id' => 'require', + 'parent_id' => 'require', + 'level' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'user_id' => '用户id', + 'parent_id' => '上级id', + 'level' => 'level', + ]; + + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserTronValidate.php b/app/adminapi/validate/user/UserTronValidate.php new file mode 100644 index 0000000..be1fd7c --- /dev/null +++ b/app/adminapi/validate/user/UserTronValidate.php @@ -0,0 +1,126 @@ + 'require', + 'address' => 'require', + 'key' => 'require', + 'qrcode' => 'require', + 'sort' => 'require', + 'in_addr' => 'require', + 'num' => 'require|gt:0|checkMoney', + 'rem_money' => 'require', + 'min_money' => 'require|gt:0', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'address' => '地址', + 'key' => '私钥', + 'qrcode' => '二维码', + 'sort' => '排序', + 'in_addr' => '转入地址', + 'num.require' => '请输入转账金额', + 'num.gt' => '转账金额必须大于零', + 'rem_money.require' => '请输入钱包留取金额', + 'min_money.require' => '请输入最低归集金额', + 'min_money.gt' => '最低归集金额必须大于零', + ]; + + + /** + * @notes 添加场景 + * @return UserTronValidate + * @author BD + * @date 2024/05/04 23:38 + */ + public function sceneAdd() + { + return $this->only(['address','key','qrcode','sort']); + } + + + /** + * @notes 编辑场景 + * @return UserTronValidate + * @author BD + * @date 2024/05/04 23:38 + */ + public function sceneEdit() + { + return $this->only(['id','address','key','qrcode','sort']); + } + + + /** + * @notes 删除场景 + * @return UserTronValidate + * @author BD + * @date 2024/05/04 23:38 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 转账场景 + * @return UserTronValidate + * @author BD + * @date 2024/05/04 23:38 + */ + public function sceneTran() + { + return $this->only(['num','in_addr']); + } + + /** + * @notes 归集场景 + * @return UserTronValidate + * @author BD + * @date 2024/05/04 23:38 + */ + public function sceneTranAll() + { + return $this->only(['rem_money','min_money','in_addr']); + } + + protected function checkMoney($vaule, $rule, $data) + { + $userTran = UserTron::find($data['id']); + if (empty($userTran)) { + return '钱包不存在'; + } + + + $surplusMoeny = $userTran['money_usdt'] - $data['num']; + if ($surplusMoeny < 0) { + return '钱包余额不足'; + } + + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/user/UserValidate.php b/app/adminapi/validate/user/UserValidate.php new file mode 100644 index 0000000..8ccc152 --- /dev/null +++ b/app/adminapi/validate/user/UserValidate.php @@ -0,0 +1,136 @@ + '/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){6,20}$/', + 'email' => '/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/' + ]; + + protected $rule = [ + 'id' => 'require|checkUser', + 'field' => 'require|checkField', + 'value' => 'require', + 'pwd' => 'require|length:6,20|regex:pwd', + 'email' => 'require|regex:email', + ]; + + protected $message = [ + 'id.require' => '请选择用户', + 'field.require' => '请选择操作', + 'value.require' => '请输入内容', + 'pwd.require' => '请输入密码',//请输入密码 + 'pwd.length' => '密码须在6-20位之间',//密码须在6-20位之间 + 'pwd.regex' => '密码须为字母数字组合',//密码须为字母数字组合 + 'email.require' => '请输入邮箱',//请输入邮箱 + 'email.regex' => '请输入正确的邮箱地址',//请输入正确的邮箱地址 + ]; + + + /** + * @notes 用户信息校验 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2023/9/22 17:03 + */ + public function checkUser($value, $rule, $data) + { + $userIds = is_array($value) ? $value : [$value]; + + foreach ($userIds as $item) { + if (!User::find($item)) { + return '用户不存在!'; + } + } + return true; + } + + + /** + * @notes 校验是否可更新信息 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2023/9/22 16:37 + */ + public function checkField($value, $rule, $data) + { + $allowField = ['account', 'sex', 'mobile', 'real_name']; + + if (!in_array($value, $allowField)) { + return '用户信息不允许更新'; + } + + switch ($value) { + case 'account': + //验证手机号码是否存在 + $account = User::where([ + ['id', '<>', $data['id']], + ['account', '=', $data['value']] + ])->findOrEmpty(); + + if (!$account->isEmpty()) { + return '账号已被使用'; + } + break; + + case 'mobile': + if (false == $this->validate($data['value'], 'mobile', $data)) { + return '手机号码格式错误'; + } + + //验证手机号码是否存在 + $mobile = User::where([ + ['id', '<>', $data['id']], + ['mobile', '=', $data['value']] + ])->findOrEmpty(); + + if (!$mobile->isEmpty()) { + return '手机号码已存在'; + } + break; + } + return true; + } + + /** + * @notes 修改密码场景 + * @return UserValidate + * @author BD + * @date 2023/9/22 16:35 + */ + public function sceneChangePwd() + { + return $this->only(['pwd']); + } + + /** + * @notes 修改邮箱场景 + * @return UserValidate + * @author BD + * @date 2023/9/22 16:35 + */ + public function sceneChangeEmail() + { + return $this->only(['email']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/withdraw/WithdrawBankValidate.php b/app/adminapi/validate/withdraw/WithdrawBankValidate.php new file mode 100644 index 0000000..d806c0f --- /dev/null +++ b/app/adminapi/validate/withdraw/WithdrawBankValidate.php @@ -0,0 +1,113 @@ + 'require', + 'lang_id' => 'require', + 'name' => 'require', + 'is_show' => 'require', + 'sort' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'lang_id' => '所属语言', + 'name' => '银行名称', + 'is_show' => '是否显示', + 'sort' => '排序', + ]; + + + /** + * @notes 添加场景 + * @return WithdrawBankValidate + * @author BD + * @date 2024/02/25 12:19 + */ + public function sceneAdd() + { + return $this->only(['lang_id','name','is_show','sort']); + } + + + /** + * @notes 编辑场景 + * @return WithdrawBankValidate + * @author BD + * @date 2024/02/25 12:19 + */ + public function sceneEdit() + { + return $this->only(['id','lang_id','name','is_show','sort']); + } + + + /** + * @notes 删除场景 + * @return WithdrawBankValidate + * @author BD + * @date 2024/02/25 12:19 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return WithdrawBankValidate + * @author BD + * @date 2024/02/25 12:19 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 所有银行场景 + * @return WithdrawBankValidate + * @author BD + * @date 2024/02/25 12:19 + */ + public function sceneAllByLang() + { + return $this->only(['lang_id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/withdraw/WithdrawMethodValidate.php b/app/adminapi/validate/withdraw/WithdrawMethodValidate.php new file mode 100644 index 0000000..ecb5b1c --- /dev/null +++ b/app/adminapi/validate/withdraw/WithdrawMethodValidate.php @@ -0,0 +1,112 @@ + 'require', + 'lang_id' => 'require', + 'type' => 'require', + 'name' => 'require', + 'symbol' => 'require', + 'rate' => 'require', + 'precision' => 'require', + 'charge' => 'require', + 'is_show' => 'require', + 'sort' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'lang_id' => '所属语言', + 'type' => '类型', + 'name' => '名称', + 'symbol' => '货币符号', + 'rate' => '汇率', + 'precision' => '显示精度', + 'charge' => '手续费', + 'is_show' => '显示状态', + 'sort' => '排序', + ]; + + + /** + * @notes 添加场景 + * @return WithdrawMethodValidate + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public function sceneAdd() + { + return $this->only(['lang_id','type','name','symbol','rate','precision','charge','is_show','sort']); + } + + + /** + * @notes 编辑场景 + * @return WithdrawMethodValidate + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public function sceneEdit() + { + return $this->only(['id','lang_id','type','name','symbol','rate','precision','charge','is_show','sort']); + } + + + /** + * @notes 删除场景 + * @return WithdrawMethodValidate + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return WithdrawMethodValidate + * @author likeadmin + * @date 2024/02/23 14:34 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/withdraw/WithdrawWalletValidate.php b/app/adminapi/validate/withdraw/WithdrawWalletValidate.php new file mode 100644 index 0000000..1ea92d6 --- /dev/null +++ b/app/adminapi/validate/withdraw/WithdrawWalletValidate.php @@ -0,0 +1,82 @@ + 'require', + 'lang_id' => 'require', + 'user_id' => 'require', + 'method_id' => 'require', + 'type' => 'require', + 'account' => 'require', + 'is_disable' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'lang_id' => '所属语言', + 'user_id' => '用户id', + 'method_id' => '提现方式id', + 'type' => '类型', + 'account' => '账号', + 'is_disable' => '是否禁用', + ]; + + + /** + * @notes 编辑场景 + * @return WithdrawWalletValidate + * @author BD + * @date 2024/02/26 13:32 + */ + public function sceneEdit() + { + return $this->only(['id','account','is_disable']); + } + + + /** + * @notes 删除场景 + * @return WithdrawWalletValidate + * @author BD + * @date 2024/02/26 13:32 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/api/config/route.php b/app/api/config/route.php new file mode 100644 index 0000000..e6a2642 --- /dev/null +++ b/app/api/config/route.php @@ -0,0 +1,19 @@ + [ + app\api\http\middleware\InitMiddleware::class, // 初始化 + app\api\http\middleware\LoginMiddleware::class, // 登录验证 + ], +]; diff --git a/app/api/controller/ArticleController.php b/app/api/controller/ArticleController.php new file mode 100644 index 0000000..9080b0d --- /dev/null +++ b/app/api/controller/ArticleController.php @@ -0,0 +1,124 @@ +dataLists(new ArticleLists()); + } + + + /** + * @notes 文章分类列表 + * @return \think\response\Json + * @author 段誉 + * @date 2022/9/20 15:30 + */ + public function cate() + { + return $this->data(ArticleLogic::cate()); + } + + + /** + * @notes 收藏列表 + * @return \think\response\Json + * @author 段誉 + * @date 2022/9/20 16:31 + */ + public function collect() + { + return $this->dataLists(new ArticleCollectLists()); + } + + + /** + * @notes 提示内容详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/9/20 17:09 + */ + public function hintDetail() + { + $params = $this->request->get(); + $result = ArticleLogic::hintDetail($params); + return $this->data($result); + } + + /** + * @notes 文章详情 + * @return \think\response\Json + * @author 段誉 + * @date 2022/9/20 17:09 + */ + public function detail() + { + $params = $this->request->get(); + $result = ArticleLogic::detail($params); + return $this->data($result); + } + + + /** + * @notes 加入收藏 + * @return \think\response\Json + * @author 段誉 + * @date 2022/9/20 17:01 + */ + public function addCollect() + { + $articleId = $this->request->post('id/d'); + ArticleLogic::addCollect($articleId, $this->userId); + return $this->success('操作成功'); + } + + + /** + * @notes 取消收藏 + * @return \think\response\Json + * @author 段誉 + * @date 2022/9/20 17:01 + */ + public function cancelCollect() + { + $articleId = $this->request->post('id/d'); + ArticleLogic::cancelCollect($articleId, $this->userId); + return $this->success('操作成功'); + } + + +} \ No newline at end of file diff --git a/app/api/controller/BaseApiController.php b/app/api/controller/BaseApiController.php new file mode 100644 index 0000000..b734cab --- /dev/null +++ b/app/api/controller/BaseApiController.php @@ -0,0 +1,46 @@ +request->userInfo) && $this->request->userInfo) { + $this->userInfo = $this->request->userInfo; + $this->userId = $this->request->userInfo['user_id']; + + //更新最后操作时间,大于5分钟才更新 + $online_time = time() - 5*60; + User::where(['id' => $this->userId])->where("last_time <= $online_time")->update(['last_time' => time()]); + + // //更新用户操作记录 (统计活跃人数) + // $start_time = strtotime(date('Y-m-d 00:00:00', time()));//0点 + // $userLog = UserLog::where("create_time >= $start_time")->where(['user_id' => $this->userId,'type' => 1])->findOrEmpty(); + // if ($userLog->isEmpty()) { + // UserLog::create([ + // 'user_id' => $this->userId, + // 'type' => 1 + // ]); + // } + } + } +} \ No newline at end of file diff --git a/app/api/controller/FinanceController.php b/app/api/controller/FinanceController.php new file mode 100644 index 0000000..5b28b14 --- /dev/null +++ b/app/api/controller/FinanceController.php @@ -0,0 +1,261 @@ +request->get(); + $params['user_id'] = $this->userId; + $result = FinanceLogic::getIndexData($params); + return $this->data($result); + } + /** + * @notes 获取资金明细 + * @return \think\response\Json + * @author BD + * @date 2024/2/23 18:55 + */ + public function lists() + { + return $this->dataLists(new UserFinanceLists()); + } + + /** + * @notes 资金记录详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function detail() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = FinanceLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 获取提现方式 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function withdrawMethod() + { + $lang = $this->request->get('lang/s'); + $result = FinanceLogic::withdrawMethod($lang); + if ($result === false) { + return $this->fail(FinanceLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 获取提现钱包 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function withdrawWallet() + { + $lang = $this->request->get('lang/s'); + $result = FinanceLogic::withdrawWallet($lang, $this->userId); + if ($result === false) { + return $this->fail(FinanceLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 获取提现银行 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function withdrawBanks() + { + $lang = $this->request->get('lang/s'); + $result = FinanceLogic::withdrawBanks($lang); + if ($result === false) { + return $this->fail(FinanceLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 绑定提现钱包 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function withdrawWalletAdd() + { + $params = (new FinanceValidate())->post()->goCheck('walletAdd', [ + 'user_id' => $this->userId + ]); + $result = FinanceLogic::withdrawWalletAdd($params); + if (false === $result) { + return $this->fail(FinanceLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 提现配置 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function withdrawConfig() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = FinanceLogic::withdrawConfig($params); + return $this->data($result); + } + + /** + * @notes 提现 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function withdraw() + { + $params = (new FinanceValidate())->post()->goCheck('withdraw', [ + 'user_id' => $this->userId, + ]); + $result = FinanceLogic::withdraw($params); + if (false === $result) { + return $this->fail(FinanceLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 提现记录 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function withdrawRecordLists() + { + return $this->dataLists(new WithdrawRecordLists()); + } + + /** + * @notes 提现记录详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function withdrawRecordDetail() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = FinanceLogic::withdrawRecordDetail($params); + return $this->data($result); + } + + /** + * @notes 充值记录 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function rechargeRecordLists() + { + return $this->dataLists(new RechargeRecordLists()); + } + + /** + * @notes 充值记录详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function rechargeRecordDetail() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = FinanceLogic::rechargeRecordDetail($params); + return $this->data($result); + } + + /** + * @notes 用户转账数据 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/9/21 19:15 + */ + public function transferIndex() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = FinanceLogic::transferIndex($params); + return $this->data($result); + } + + /** + * @notes 转账 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function transfer() + { + $params = (new FinanceValidate())->post()->goCheck('transfer', [ + 'user_id' => $this->userId, + ]); + $result = FinanceLogic::transfer($params); + if (false === $result) { + return $this->fail(FinanceLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 转账记录 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function transferRecordLists() + { + return $this->dataLists(new UserTransferRecordLists()); + } + +} \ No newline at end of file diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php new file mode 100644 index 0000000..0ccbc3b --- /dev/null +++ b/app/api/controller/IndexController.php @@ -0,0 +1,125 @@ +request->get(); + $params['user_id'] = $this->userId; + $result = IndexLogic::getIndexData($params); + return $this->data($result); + } + + + /** + * @notes 全局配置 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2023/9/21 19:41 + */ + public function config() + { + $lang = $this->request->get('lang/s'); + $result = IndexLogic::getConfigData($lang); + return $this->data($result); + } + + /** + * @notes 国家区号 + * @return Json + * @author BD + * @date 2023/9/21 18:37 + */ + public function countryCode() + { + $result = IndexLogic::getCountryCode(); + return $this->data($result); + } + + /** + * @notes 装修信息 + * @return Json + * @author BD + * @date 2023/9/21 18:37 + */ + public function decorate() + { + $id = $this->request->get('id/d'); + $result = IndexLogic::getDecorate($id); + return $this->data($result); + } + + /** + * @notes 获取所有语言 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2023/10/13 10:54 + */ + public function getKefuLists() + { + $params = $this->request->get(); + $result = IndexLogic::getKefuLists($params); + return $this->data($result); + } + + // /** + // * @notes 政策协议 + // * @return Json + // * @author BD + // * @date 2023/9/20 20:00 + // */ + // public function policy() + // { + // $type = $this->request->get('type/s', ''); + // $result = IndexLogic::getPolicyByType($type); + // return $this->data($result); + // } + + /** + * @notes 行情数据 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2023/10/13 10:54 + */ + public function market() + { + $result = IndexLogic::getMarketData(); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/api/controller/ItemController.php b/app/api/controller/ItemController.php new file mode 100644 index 0000000..8abf53f --- /dev/null +++ b/app/api/controller/ItemController.php @@ -0,0 +1,98 @@ +request->get(); + $params['user_id'] = $this->userId; + $result = ItemLogic::getIndexData($params); + return $this->data($result); + } + + /** + * @notes 项目详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function detail() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = ItemLogic::detail($params); + if (false === $result) { + return $this->fail(ItemLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 合同详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function contract() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = ItemLogic::contract($params); + if (false === $result) { + return $this->fail(ItemLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 投资 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function invest() + { + $params = (new ItemValidate())->post()->goCheck('invest', [ + 'user_id' => $this->userId, + ]); + $result = ItemLogic::invest($params); + if (false === $result) { + return $this->fail(ItemLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 投资记录 + * @return \think\response\Json + * @author BD + * @date 2024/2/23 18:55 + */ + public function recordLists() + { + return $this->dataLists(new ItemRecordLists()); + } + +} \ No newline at end of file diff --git a/app/api/controller/LanguageController.php b/app/api/controller/LanguageController.php new file mode 100644 index 0000000..9c1979c --- /dev/null +++ b/app/api/controller/LanguageController.php @@ -0,0 +1,77 @@ +goCheck('detail'); + $result = LanguageLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 获取所有语言 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:54 + */ + public function all() + { + $result = LanguageLogic::getAllData(); + return $this->data($result); + } + + /** + * @notes 获取语言包数据 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:54 + */ + public function pagAll() + { + $params = (new LanguagePagValidate())->goCheck('all'); + $result = LanguageLogic::getPagAllData($params); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/api/controller/LoginController.php b/app/api/controller/LoginController.php new file mode 100644 index 0000000..33612e5 --- /dev/null +++ b/app/api/controller/LoginController.php @@ -0,0 +1,94 @@ +post()->goCheck('register'); + $result = LoginLogic::register($params); + if (false === $result) { + return $this->fail(LoginLogic::getError()); + } + return $this->data($result); + } + + + /** + * @notes 账号密码/手机号密码/手机号验证码登录 + * @return \think\response\Json + * @author 段誉 + * @date 2022/9/16 10:42 + */ + public function account() + { + $params = (new LoginAccountValidate())->post()->goCheck(); + $result = LoginLogic::login($params); + if (false === $result) { + return $this->fail(LoginLogic::getError()); + } + return $this->data($result); + } + + + /** + * @notes 退出登录 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/16 10:42 + */ + public function logout() + { + LoginLogic::logout($this->userInfo); + return $this->success(); + } + + + /** + * @notes 更新用户头像昵称 + * @return \think\response\Json + * @author 段誉 + * @date 2023/2/22 11:15 + */ + public function updateUser() + { + $params = (new WechatLoginValidate())->post()->goCheck("updateUser"); + LoginLogic::updateUser($params, $this->userId); + return $this->success('操作成功', [], 1, 1); + } + +} \ No newline at end of file diff --git a/app/api/controller/MallController.php b/app/api/controller/MallController.php new file mode 100644 index 0000000..b60faf6 --- /dev/null +++ b/app/api/controller/MallController.php @@ -0,0 +1,97 @@ +request->get(); + $params['user_id'] = $this->userId; + $result = MallLogic::index($params); + return $this->data($result); + } + + /** + * @notes 兑换 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function buy() + { + $params = (new MallValidate())->post()->goCheck('buy', [ + 'user_id' => $this->userId, + ]); + $result = MallLogic::buy($params); + if (false === $result) { + return $this->fail(MallLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 抽奖数据 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function drawIndex() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = MallLogic::drawIndex($params); + return $this->data($result); + } + + /** + * @notes 抽奖 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function draw() + { + $params = (new MallValidate())->post()->goCheck('draw', [ + 'user_id' => $this->userId, + ]); + $result = MallLogic::draw($params); + if (false === $result) { + return $this->fail(MallLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 抽奖记录 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function drawLists() + { + return $this->dataLists(new MallGoodsRecordLists()); + } +} \ No newline at end of file diff --git a/app/api/controller/PcController.php b/app/api/controller/PcController.php new file mode 100644 index 0000000..e43453a --- /dev/null +++ b/app/api/controller/PcController.php @@ -0,0 +1,95 @@ +data($result); + } + + + /** + * @notes 全局配置 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/21 19:41 + */ + public function config() + { + $result = PcLogic::getConfigData(); + return $this->data($result); + } + + + /** + * @notes 资讯中心 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/19 16:55 + */ + public function infoCenter() + { + $result = PcLogic::getInfoCenter(); + return $this->data($result); + } + + + /** + * @notes 获取文章详情 + * @return Json + * @author 段誉 + * @date 2022/10/20 15:18 + */ + public function articleDetail() + { + $id = $this->request->get('id/d', 0); + $source = $this->request->get('source/s', 'default'); + $result = PcLogic::getArticleDetail($this->userId, $id, $source); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/api/controller/RechargeController.php b/app/api/controller/RechargeController.php new file mode 100644 index 0000000..ba9e986 --- /dev/null +++ b/app/api/controller/RechargeController.php @@ -0,0 +1,164 @@ +dataLists(new RechargeLists()); + } + + + /** + * @notes 充值 + * @return \think\response\Json + * @author BD + * @date 2024/2/23 18:56 + */ + public function recharge() + { + $params = (new RechargeValidate())->post()->goCheck('recharge', [ + 'user_id' => $this->userId, + 'terminal' => $this->userInfo['terminal'], + ]); + $result = RechargeLogic::recharge($params); + if (false === $result) { + return $this->fail(RechargeLogic::getError()); + } + return $this->data($result); + } + + + /** + * @notes 充值配置 + * @return \think\response\Json + * @author BD + * @date 2024/2/24 16:56 + */ + public function config() + { + return $this->data(RechargeLogic::config($this->userId)); + } + + /** + * @notes 获取充值方式 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/4/13 10:54 + */ + public function method() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = RechargeLogic::getAllMethod($params); + if ($result === false) { + return $this->fail(RechargeLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 充值方式详情 + * @return \think\response\Json + * @author BD + * @date 2024/4/20 17:09 + */ + public function methodDetail() + { + $id = $this->request->get('id/d'); + $lang = $this->request->get('lang/s'); + $result = RechargeLogic::methodDetail($id,$lang); + if ($result === false) { + return $this->fail(RechargeLogic::getError()); + } + return $this->data($result); + } + /** + * @notes 充值方式详情-优盾 + * @return \think\response\Json + * @author BD + * @date 2024/4/20 17:09 + */ + public function methodDetailUdun() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = RechargeLogic::methodDetailUdun($params); + if ($result === false) { + return $this->fail(RechargeLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 充值方式详情-波场 + * @return \think\response\Json + * @author BD + * @date 2024/4/20 17:09 + */ + public function methodDetailTron() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = RechargeLogic::methodDetailTron($params); + if ($result === false) { + return $this->fail(RechargeLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 充值方式详情-自定义地址 + * @return \think\response\Json + * @author BD + * @date 2024/4/20 17:09 + */ + public function methodDetailAddress() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = RechargeLogic::methodDetailAddress($params); + if ($result === false) { + return $this->fail(RechargeLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 获取常用充值金额 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/4/13 10:54 + */ + public function commonMoney() + { + $lang = $this->request->get('lang/s'); + $result = RechargeLogic::getCommonMoney($lang); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/api/controller/RobotController.php b/app/api/controller/RobotController.php new file mode 100644 index 0000000..ac80972 --- /dev/null +++ b/app/api/controller/RobotController.php @@ -0,0 +1,122 @@ +request->get(); + $params['user_id'] = $this->userId; + $result = RobotLogic::getIndexData($params); + return $this->data($result); + } + + /** + * @notes 量化 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function buy() + { + $params = (new RobotValidate())->post()->goCheck('buy', [ + 'user_id' => $this->userId, + ]); + $result = RobotLogic::buy($params); + if (false === $result) { + return $this->fail(RobotLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 抢单记录 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function recordLists() + { + return $this->dataLists(new LhRecordLists()); + } + + + + + /** + * @notes 抢单 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function grab() + { + $params = $this->request->post(); + $params['user_id'] = $this->userId; + $result = RobotLogic::grab($params); + if (false === $result) { + return $this->fail(RobotLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 获取进行中订单 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function grabIngRecord() + { + $result = RobotLogic::grabIngRecord([ + 'user_id' => $this->userId + ]); + if (false === $result) { + return $this->fail(RobotLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 订单支付 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function grabPay() + { + $params = (new RobotValidate())->post()->goCheck('grabPay', [ + 'user_id' => $this->userId, + ]); + $result = RobotLogic::grabPay($params); + if (false === $result) { + return $this->fail(RobotLogic::getError()); + } + return $this->data($result); + } + + + +} \ No newline at end of file diff --git a/app/api/controller/SmsController.php b/app/api/controller/SmsController.php new file mode 100644 index 0000000..4ea2c68 --- /dev/null +++ b/app/api/controller/SmsController.php @@ -0,0 +1,70 @@ +post()->goCheck(); + $result = SmsLogic::sendCode($params); + if (true === $result) { + return $this->success('captcha.sendSuccessfully');//发送成功 + } + return $this->fail(SmsLogic::getError()); + } + + /** + * @notes 发送邮件 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function sendEmail() + { + $params = $this->request->post(); + $params['user_id'] = $this->userId; + $result = SmsLogic::sendEmail($params); + if (true === $result) { + return $this->success('captcha.sendSuccessfully');//发送成功 + } + return $this->fail(SmsLogic::getError()); + } + + /** + * @notes 发送邮件 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function sendEmailNoLogin() + { + $params = $this->request->post(); + $result = SmsLogic::sendEmailNoLogin($params); + if (true === $result) { + return $this->success('captcha.sendSuccessfully');//发送成功 + } + return $this->fail(SmsLogic::getError()); + } + +} \ No newline at end of file diff --git a/app/api/controller/TeamController.php b/app/api/controller/TeamController.php new file mode 100644 index 0000000..66800d8 --- /dev/null +++ b/app/api/controller/TeamController.php @@ -0,0 +1,61 @@ +dataLists(new TeamUserLists()); + } + + /** + * @notes 团队首页数据 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function index() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $params['host'] = Request::header('origin'); + $result = TeamLogic::getIndexData($params); + return $this->data($result); + } + + /** + * @notes 团队首页数据2 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function indexReport() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = TeamLogic::getIndexReport($params); + return $this->data($result); + } +} \ No newline at end of file diff --git a/app/api/controller/UploadController.php b/app/api/controller/UploadController.php new file mode 100644 index 0000000..ea2a315 --- /dev/null +++ b/app/api/controller/UploadController.php @@ -0,0 +1,48 @@ +userId,FileEnum::SOURCE_USER); + return $this->success('上传成功', $result); + } catch (Exception $e) { + return $this->fail($e->getMessage()); + } + } + + + +} \ No newline at end of file diff --git a/app/api/controller/UserController.php b/app/api/controller/UserController.php new file mode 100644 index 0000000..a74a470 --- /dev/null +++ b/app/api/controller/UserController.php @@ -0,0 +1,454 @@ +request->get('lang/s'); + $result = UserLogic::getIndexData([ + 'lang' => $lang, + 'user_id' => $this->userId + ]); + return $this->data($result); + } + + /** + * @notes 分享 首页数据 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/9/21 19:15 + */ + public function shareIndex() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + // $params['host'] = Request::header('origin'); + $result = UserLogic::getShareIndexData($params); + return $this->data($result); + } + + /** + * @notes 获取个人中心 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/9/16 18:19 + */ + public function center() + { + $data = UserLogic::center($this->userInfo); + return $this->success('', $data); + } + + + /** + * @notes 获取个人信息 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:46 + */ + public function info() + { + $params = $this->request->get(); + $params['host'] = Request::header('origin'); + $params['user_id'] = $this->userId; + $result = UserLogic::info($params); + return $this->data($result); + } + + + /** + * @notes 重置密码 + * @return \think\response\Json + * @author BD + * @date 2024/9/16 18:06 + */ + public function resetPassword() + { + $params = (new PasswordValidate())->post()->goCheck('resetPassword'); + $result = UserLogic::resetPassword($params); + if (true === $result) { + return $this->success('network.modifySuccessfully', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + + /** + * @notes 修改密码 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:16 + */ + public function changePassword() + { + $params = (new PasswordValidate())->post()->goCheck('changePassword'); + $result = UserLogic::changePassword($params, $this->userId); + if (true === $result) { + return $this->success('network.modifySuccessfully', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 修改支付密码 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:16 + */ + public function changePayPassword() + { + $params = (new PasswordValidate())->post()->goCheck('changePayPassword'); + $result = UserLogic::changePayPassword($params, $this->userId); + if (true === $result) { + return $this->success('network.modifySuccessfully', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 设置支付密码 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:16 + */ + public function setPayPwd() + { + $params = (new PasswordValidate())->post()->goCheck('setPayPassword'); + $result = UserLogic::setPayPassword($params, $this->userId); + if (true === $result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 编辑用户信息 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:01 + */ + public function setInfo() + { + $params = (new SetUserInfoValidate())->post()->goCheck(null, ['id' => $this->userId]); + $result = UserLogic::setInfo($this->userId, $params); + if (false === $result) { + return $this->fail(UserLogic::getError()); + } + return $this->success('network.modifySuccessfully', [], 1, 1); + } + + + /** + * @notes 绑定/变更 手机号 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function bindMobile() + { + $params = (new UserValidate())->post()->goCheck('bindMobile'); + $params['user_id'] = $this->userId; + $result = UserLogic::bindMobile($params); + if($result) { + return $this->success('network.modifySuccessfully', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 获取用户消息 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:46 + */ + public function notice() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = UserLogic::notice($params); + return $this->data($result); + } + + /** + * @notes 用户消息列表 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function noticeLists() + { + return $this->dataLists(new UserNoticeLists()); + } + + /** + * @notes 用户消息详情 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function noticeDetail() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = UserLogic::noticeDetail($params); + if ($result === false) { + return $this->fail(UserLogic::getError()); + } + return $this->data($result); + } + + /** + * @notes 奖励活动数据 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:46 + */ + public function activityIndex() + { + $params['user_id'] = $this->userId; + $result = UserLogic::activityIndex($params); + return $this->data($result); + } + + /** + * @notes 任务中心数据 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:46 + */ + public function missionIndex() + { + $params['user_id'] = $this->userId; + $result = UserLogic::missionIndex($params); + return $this->data($result); + } + + /** + * @notes 领取任务奖励 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:16 + */ + public function missionReward() + { + $params = $this->request->post(); + $params['user_id'] = $this->userId; + $result = UserLogic::missionReward($params); + if($result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 意见反馈类型 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:46 + */ + public function feedbackCate() + { + $params = $this->request->get(); + $result = UserLogic::feedbackCate($params); + return $this->data($result); + } + + /** + * @notes 意见反馈 + * @return \think\response\Json + * @author BD + * @date 2024/9/20 19:16 + */ + public function feedback() + { + $params = $this->request->post(); + $params['user_id'] = $this->userId; + $result = UserLogic::feedback($params); + if($result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes Google Authenticator校验 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function verifyGoogle() + { + $params = (new UserValidate())->post()->goCheck('verifyGoogle'); + $params['user_id'] = $this->userId; + $result = UserLogic::verifyGoogle($params); + if($result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 邮箱校验 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function verifyEmail() + { + $params = (new UserValidate())->post()->goCheck('verifyEmail'); + $params['user_id'] = $this->userId; + $result = UserLogic::verifyEmail($params); + if($result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 实名认证 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function verifyRealname() + { + $params = (new UserValidate())->post()->goCheck('verifyRealname', [ + 'user_id' => $this->userId + ]); + $result = UserLogic::verifyRealname($params); + if($result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 签到数据 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function signinConfig() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = UserLogic::signinConfig($params); + return $this->data($result); + } + + /** + * @notes 签到 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function signin() + { + $params = (new UserValidate())->post()->goCheck('signin', [ + 'user_id' => $this->userId + ]); + $result = UserLogic::signin($params); + if($result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 挖矿 首页数据 + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public function mineIndex() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = UserLogic::getMineIndexData($params); + return $this->data($result); + } + + /** + * @notes 挖矿记录列表 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function mineLists() + { + return $this->dataLists(new UserMineRecordLists()); + } + + /** + * @notes 矿机 启动 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function mineStart() + { + $params = (new UserValidate())->post()->goCheck('mineStart', [ + 'user_id' => $this->userId + ]); + $result = UserLogic::mineStart($params); + if($result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } + + /** + * @notes 矿机 收益 + * @return \think\response\Json + * @author BD + * @date 2024/9/21 17:29 + */ + public function mineReceive() + { + $params = (new UserValidate())->post()->goCheck('mineReceive', [ + 'user_id' => $this->userId + ]); + $result = UserLogic::mineReceive($params); + if($result) { + return $this->success('', [], 1, 1); + } + return $this->fail(UserLogic::getError()); + } +} \ No newline at end of file diff --git a/app/api/controller/UserMemberController.php b/app/api/controller/UserMemberController.php new file mode 100644 index 0000000..1803157 --- /dev/null +++ b/app/api/controller/UserMemberController.php @@ -0,0 +1,74 @@ +request->get(); + $params['user_id'] = $this->userId; + $result = UserMemberLogic::getIndexData($params); + return $this->data($result); + } + + /** + * @notes 会员列表 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + public function all() + { + $params = $this->request->get(); + $params['user_id'] = $this->userId; + $result = UserMemberLogic::getAllData($params); + return $this->data($result); + } + + /** + * @notes 加入会员 + * @return \think\response\Json + * @author BD + * @date 2024/02/22 10:54 + */ + // public function join(){ + // $params = (new UserMemberValidate())->post()->goCheck('join', [ + // 'user_id' => $this->userId, + // ]); + // $result = UserMemberLogic::join($params); + // if (false === $result) { + // return $this->fail(UserMemberLogic::getError()); + // } + // return $this->data($result); + // } + +} \ No newline at end of file diff --git a/app/api/http/middleware/InitMiddleware.php b/app/api/http/middleware/InitMiddleware.php new file mode 100644 index 0000000..f49d22f --- /dev/null +++ b/app/api/http/middleware/InitMiddleware.php @@ -0,0 +1,56 @@ +controller()); + $controller = '\\app\\api\\controller\\' . $controller . 'Controller'; + $controllerClass = invoke($controller); + if (($controllerClass instanceof BaseApiController) === false) { + throw new ControllerExtendException($controller, '404'); + } + } catch (ClassNotFoundException $e) { + throw new HttpException(404, 'controller not exists:' . $e->getClass()); + } + //创建控制器对象 + $request->controllerObject = invoke($controller); + + return $next($request); + } + +} \ No newline at end of file diff --git a/app/api/http/middleware/LoginMiddleware.php b/app/api/http/middleware/LoginMiddleware.php new file mode 100644 index 0000000..b219803 --- /dev/null +++ b/app/api/http/middleware/LoginMiddleware.php @@ -0,0 +1,80 @@ +header('token'); + //判断接口是否免登录 + $isNotNeedLogin = $request->controllerObject->isNotNeedLogin(); + + //不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问 + if (empty($token) && !$isNotNeedLogin) { + //没有token并且该地址需要登录才能访问, 指定show为0,前端不弹出此报错 + return JsonService::fail('network.parameterAbnormality', [], 0, 0);//请求参数缺token + } + + $userInfo = (new UserTokenCache())->getUserInfo($token); + + if (empty($userInfo) && !$isNotNeedLogin) { + //token过期无效并且该地址需要登录才能访问 + return JsonService::fail('network.loginTimeout', [], -1, 0);//登录超时,请重新登录 + } + + //token临近过期,自动续期 + if ($userInfo) { + //判断是否启用 + $user = User::where(['id' => $userInfo['user_id']])->findOrEmpty(); + if (!$user->isEmpty() && $user['is_open'] == 0) { + return JsonService::fail('network.loginExpire', [], -1);//登录过期 + } + //获取临近过期自动续期时长 + $beExpireDuration = Config::get('project.user_token.be_expire_duration'); + //token续期 + if (time() > ($userInfo['expire_time'] - $beExpireDuration)) { + $result = UserTokenService::overtimeToken($token); + //续期失败(数据表被删除导致) + if (empty($result)) { + return JsonService::fail('network.loginExpire', [], -1);//登录过期 + } + } + } + + //给request赋值,用于控制器 + $request->userInfo = $userInfo; + $request->userId = $userInfo['user_id'] ?? 0; + + return $next($request); + } + +} \ No newline at end of file diff --git a/app/api/lists/BaseApiDataLists.php b/app/api/lists/BaseApiDataLists.php new file mode 100644 index 0000000..ff76991 --- /dev/null +++ b/app/api/lists/BaseApiDataLists.php @@ -0,0 +1,37 @@ +request->userInfo) && $this->request->userInfo) { + $this->userInfo = $this->request->userInfo; + $this->userId = $this->request->userId; + } + $this->export = $this->request->get('export', ''); + } + + +} \ No newline at end of file diff --git a/app/api/lists/article/ArticleCollectLists.php b/app/api/lists/article/ArticleCollectLists.php new file mode 100644 index 0000000..87fe5b2 --- /dev/null +++ b/app/api/lists/article/ArticleCollectLists.php @@ -0,0 +1,79 @@ +alias('a') + ->join('article_collect c', 'c.article_id = a.id') + ->field($field) + ->where([ + 'c.user_id' => $this->userId, + 'c.status' => YesNoEnum::YES, + 'a.is_show' => YesNoEnum::YES, + ]) + ->order(['sort' => 'desc', 'c.id' => 'desc']) + ->limit($this->limitOffset, $this->limitLength) + ->append(['click']) + ->hidden(['click_virtual', 'click_actual']) + ->select()->toArray(); + + foreach ($lists as &$item) { + $item['collect_time'] = date('Y-m-d H:i', $item['collect_time']); + } + + return $lists; + } + + + /** + * @notes 获取收藏数量 + * @return int + * @author 段誉 + * @date 2022/9/20 16:29 + */ + public function count(): int + { + return (new Article())->alias('a') + ->join('article_collect c', 'c.article_id = a.id') + ->where([ + 'c.user_id' => $this->userId, + 'c.status' => YesNoEnum::YES, + 'a.is_show' => YesNoEnum::YES, + ]) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/article/ArticleLists.php b/app/api/lists/article/ArticleLists.php new file mode 100644 index 0000000..5e183f7 --- /dev/null +++ b/app/api/lists/article/ArticleLists.php @@ -0,0 +1,107 @@ + ['cid'] + ]; + } + + + /** + * @notes 自定查询条件 + * @return array + * @author 段誉 + * @date 2022/10/25 16:53 + */ + public function queryWhere() + { + $where[] = ['is_show', '=', 1]; + return $where; + } + + + /** + * @notes 获取文章列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/16 18:55 + */ + public function lists(): array + { + $lang = $this->params['lang']; + + $field = 'id,title,image,langs'; + $result = Article::field($field) + ->where($this->queryWhere()) + ->where($this->searchWhere) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->limit($this->limitOffset, $this->limitLength) + ->select()->toArray(); + + foreach ($result as &$article) { + //多语言替换 + $data = UtilsService::get_langs_data($article['langs'],$lang); + $data_title = ''; + if(count($data) > 0){ + $data_title = $data['title']; + } + $article['title'] = $data_title; + unset($article['langs']); + } + + return $result; + } + + + /** + * @notes 获取文章数量 + * @return int + * @author 段誉 + * @date 2022/9/16 18:55 + */ + public function count(): int + { + return Article::where($this->searchWhere) + ->where($this->queryWhere()) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/finance/RechargeRecordLists.php b/app/api/lists/finance/RechargeRecordLists.php new file mode 100644 index 0000000..e8f6547 --- /dev/null +++ b/app/api/lists/finance/RechargeRecordLists.php @@ -0,0 +1,78 @@ +append(['method_name']) + ->where([ + 'user_id' => $this->userId, + ]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + } + + return $lists; + } + + + /** + * @notes 获取充值记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + return RechargeRecord::where([ + 'user_id' => $this->userId, + ]) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/finance/UserFinanceLists.php b/app/api/lists/finance/UserFinanceLists.php new file mode 100644 index 0000000..fdebaf7 --- /dev/null +++ b/app/api/lists/finance/UserFinanceLists.php @@ -0,0 +1,89 @@ +params['action'] == 1){ + $where = ' action = 1 '; + }else if( $this->params['action'] == 2){ + $where = ' action = 2 '; + } + + if( $this->params['frozen'] == 1){ + $where .= ' AND frozen = 1 '; + } + + $field = 'id,sn,change_type as type,change_amount as amount,remark,action,create_time'; + $lists = UserFinance::field($field) + ->where($where) + ->where([ + 'user_id' => $this->userId, + ]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + } + + return $lists; + } + + + /** + * @notes 获取充值记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + return UserFinance::where([ + 'user_id' => $this->userId, + ]) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/finance/UserTransferRecordLists.php b/app/api/lists/finance/UserTransferRecordLists.php new file mode 100644 index 0000000..78ccb6f --- /dev/null +++ b/app/api/lists/finance/UserTransferRecordLists.php @@ -0,0 +1,74 @@ +append(['users_info']) + ->where(['user_id' => $this->userId]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + } + + return $lists; + } + + + /** + * @notes 获取转账记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + return UserTransferRecord::where(['user_id' => $this->userId])->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/finance/WithdrawRecordLists.php b/app/api/lists/finance/WithdrawRecordLists.php new file mode 100644 index 0000000..8731083 --- /dev/null +++ b/app/api/lists/finance/WithdrawRecordLists.php @@ -0,0 +1,84 @@ +append(['method_name']) + ->where([ + 'user_id' => $this->userId, + ]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + + if($item['type'] == 2){ + $item['account'] = substr($item['account'],0,3).'******'.substr($item['account'],strlen($item['account'])-3,strlen($item['account'])); + $item['account'] = $item['method_name'].'('.$item['account'].')'; + }else{ + $item['account'] = substr($item['account'],0,4).'******'.substr($item['account'],strlen($item['account'])-4,strlen($item['account'])); + $item['account'] = $item['method_name'].'('.$item['account'].')'; + } + } + + return $lists; + } + + + /** + * @notes 获取提现记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + return WithdrawRecord::where([ + 'user_id' => $this->userId, + ]) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/goods/GoodsRecordLists.php b/app/api/lists/goods/GoodsRecordLists.php new file mode 100644 index 0000000..f764c89 --- /dev/null +++ b/app/api/lists/goods/GoodsRecordLists.php @@ -0,0 +1,82 @@ +params['date']) - time(); + + $where = '1 = 1'; + + if( $this->params['status'] != 0){ + $status = $this->params['status'] ; + $where = " status = $status "; + } + + $field = 'id,sn,goods_title as title,goods_image as image,money,commission,status,pay_time,create_time'; + $lists = GoodsRecord::field($field) + ->where($where) + ->where([ + 'user_id' => $this->userId, + ]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['create_time'] = date($timeFormat, strtotime($item['create_time']) + $time); + if($item['pay_time']) $item['pay_time'] = date($timeFormat, $item['pay_time'] + $time); + } + + return $lists; + } + + + /** + * @notes 获取抢单记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + $where = '1 = 1'; + + if( $this->params['status'] != 0){ + $status = $this->params['status'] ; + $where = " status = $status "; + } + + return GoodsRecord::where([ + 'user_id' => $this->userId, + ]) + ->where($where) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/item/ItemRecordLists.php b/app/api/lists/item/ItemRecordLists.php new file mode 100644 index 0000000..7741cd7 --- /dev/null +++ b/app/api/lists/item/ItemRecordLists.php @@ -0,0 +1,88 @@ +where(['user_id' => $this->userId]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + //多语言替换 + $data = UtilsService::get_langs_data($item['item_langs'], $this->params['lang']); + $data_title = ''; + $data_image = ''; + + if(count($data) > 0){ + $data_title = $data['title']; + $data_image = $data['image']; + } + + $item['item_title'] = $data_title; + $item['item_image'] = FileService::getFileUrl($data_image); + unset($item['item_langs']); + + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + $item['end_time'] = date($timeFormat, $item['end_time']); + } + + return $lists; + } + + + /** + * @notes 获取投资记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + return ItemRecord::where(['user_id' => $this->userId])->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/lh/LhRecordLists.php b/app/api/lists/lh/LhRecordLists.php new file mode 100644 index 0000000..065e9b2 --- /dev/null +++ b/app/api/lists/lh/LhRecordLists.php @@ -0,0 +1,70 @@ +where(['user_id' => $this->userId]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + } + + return $lists; + } + + + /** + * @notes 获取量化记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + $where = '1 = 1'; + + if( $this->params['status'] != 0){ + $status = $this->params['status'] ; + $where = " status = $status "; + } + + return LhRecord::where([ + 'user_id' => $this->userId, + ]) + ->where($where) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/mall/MallGoodsRecordLists.php b/app/api/lists/mall/MallGoodsRecordLists.php new file mode 100644 index 0000000..57993b7 --- /dev/null +++ b/app/api/lists/mall/MallGoodsRecordLists.php @@ -0,0 +1,89 @@ +params['type'] != 1){ + $type = $this->params['type'] ; + $where = " type = $type "; + } + + $field = 'id,sn,m_goods_title as title,m_goods_image as image,m_goods_langs,price,type,type2,create_time'; + $lists = MallGoodsRecord::field($field) + ->where($where) + ->where([ + 'user_id' => $this->userId, + ]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + //多语言替换 + $data = UtilsService::get_langs_data($item['m_goods_langs'], $this->params['lang']); + $data_title = ''; + if(count($data) > 0){ + $data_title = $data['title']; + } + $item['title'] = $data_title; + unset($item['m_goods_langs']); + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + } + + return $lists; + } + + + /** + * @notes 获取奖品记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + $where = ' type = 1 '; + + if( $this->params['type'] != 1){ + $type = $this->params['type'] ; + $where = " type = $type "; + } + + return MallGoodsRecord::where([ + 'user_id' => $this->userId, + ]) + ->where($where) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/team/TeamUserLists.php b/app/api/lists/team/TeamUserLists.php new file mode 100644 index 0000000..39d6223 --- /dev/null +++ b/app/api/lists/team/TeamUserLists.php @@ -0,0 +1,90 @@ +params['level'] ; + $where = " ur.level = $level "; + + $field = 'ur.id as ur_id,ur.level,ur.create_time'; + $field .= ',u.id,u.sn,u.mobile,u.total_income_invest,u.total_recharge,u.total_withdraw'; + $lists = User::alias('u') + ->join('user_relation ur', 'u.id = ur.user_id') + ->field($field) + ->append(['team_num','item_num']) + ->where($where) + ->where([ + 'ur.parent_id' => $this->userId, + ]) + ->where(" level <= $distributeLevel ") + ->limit($this->limitOffset, $this->limitLength) + ->order(['ur.create_time' => 'desc','ur.id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + if($level != 1){ + $item['mobile'] = substr_replace($item['mobile'], str_repeat('*', 4), 2, 4); + } + + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + } + + return $lists; + } + + + /** + * @notes 获取抢单记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + $distributeLevel = UtilsService::get_distribute_level(); + + $where = '1 = 1'; + + if( $this->params['level'] != 0){ + $level = $this->params['level'] ; + $where = " ur.level = $level "; + } + + return User::alias('u') + ->join('user_relation ur', 'u.id = ur.user_id') + ->where($where) + ->where([ + 'ur.parent_id' => $this->userId, + ]) + ->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/user/UserMineRecordLists.php b/app/api/lists/user/UserMineRecordLists.php new file mode 100644 index 0000000..5baea96 --- /dev/null +++ b/app/api/lists/user/UserMineRecordLists.php @@ -0,0 +1,61 @@ +where(['user_id' => $this->userId]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['start_time'] = date($timeFormat, $item['start_time']); + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + } + + return $lists; + } + + + /** + * @notes 获取挖矿记录数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + return UserMineRecord::where(['user_id' => $this->userId])->count(); + } +} \ No newline at end of file diff --git a/app/api/lists/user/UserNoticeLists.php b/app/api/lists/user/UserNoticeLists.php new file mode 100644 index 0000000..0f6ca95 --- /dev/null +++ b/app/api/lists/user/UserNoticeLists.php @@ -0,0 +1,73 @@ +where(['user_id' => $this->userId]) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc','id' => 'desc']) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $this->params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + //多语言替换 + $data = UtilsService::get_langs_data($item['langs'],$this->params['lang']); + $data_title = ''; + $data_content = ''; + + if(count($data) > 0){ + $data_title = $data['title']; + $data_content = $data['content']; + } + + $item['title'] = get_file_domain($data_title); + $item['content'] = get_file_domain($data_content); + unset($item['langs']); + } + + return $lists; + } + + + /** + * @notes 获取用户消息数量 + * @return int + * @author bd + * @date 2024/01/31 14:07 + */ + public function count(): int + { + return UserNotice::where(['user_id' => $this->userId])->count(); + } +} \ No newline at end of file diff --git a/app/api/logic/ArticleLogic.php b/app/api/logic/ArticleLogic.php new file mode 100644 index 0000000..8203aca --- /dev/null +++ b/app/api/logic/ArticleLogic.php @@ -0,0 +1,156 @@ + 0){ + $data_title = $data['title']; + $data_content = $data['content']; + } + + $article['content'] = get_file_domain($data_content); + $article['title'] = $data_title; + unset($article['langs']); + + return $article; + } + + /** + * @notes 提示内容详情 + * @param $params + * @return array + * @author 段誉 + * @date 2022/9/20 17:09 + */ + public static function hintDetail($params) + { + //未传语言,则默认使用首个语言 + if($params['lang'] == ''){ + $first_lang = UtilsService::get_first_lang(); + $params['lang'] = $first_lang['symbol']; + } + $hint = DecorateHint::field(['content','langs'])->findOrEmpty($params['id'])->toArray(); + //多语言替换 + $data = UtilsService::get_langs_data($hint['langs'],$params['lang']); + $data_content = ''; + + if(count($data) > 0){ + $data_content = $data['content']; + } + $hint['content'] = get_file_domain($data_content); + unset($hint['langs']); + + return $hint; + } + + + /** + * @notes 加入收藏 + * @param $userId + * @param $articleId + * @author 段誉 + * @date 2022/9/20 16:52 + */ + public static function addCollect($articleId, $userId) + { + $where = ['user_id' => $userId, 'article_id' => $articleId]; + $collect = ArticleCollect::where($where)->findOrEmpty(); + if ($collect->isEmpty()) { + ArticleCollect::create([ + 'user_id' => $userId, + 'article_id' => $articleId, + 'status' => YesNoEnum::YES + ]); + } else { + ArticleCollect::update([ + 'id' => $collect['id'], + 'status' => YesNoEnum::YES + ]); + } + } + + + /** + * @notes 取消收藏 + * @param $articleId + * @param $userId + * @author 段誉 + * @date 2022/9/20 16:59 + */ + public static function cancelCollect($articleId, $userId) + { + ArticleCollect::update(['status' => YesNoEnum::NO], [ + 'user_id' => $userId, + 'article_id' => $articleId, + 'status' => YesNoEnum::YES + ]); + } + + + /** + * @notes 文章分类 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/23 14:11 + */ + public static function cate() + { + return ArticleCate::field('id,name') + ->where('is_show', '=', 1) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select()->toArray(); + } + +} \ No newline at end of file diff --git a/app/api/logic/FinanceLogic.php b/app/api/logic/FinanceLogic.php new file mode 100644 index 0000000..b6d254a --- /dev/null +++ b/app/api/logic/FinanceLogic.php @@ -0,0 +1,605 @@ + $params['user_id']])->findOrEmpty(); + + $field = 'id,sn,change_type as type,change_amount as amount,remark,action,create_time'; + $lists = UserFinance::field($field) + ->where([ + 'user_id' => $params['user_id'], + ]) + ->order(['create_time' => 'desc','id' => 'desc']) + ->limit(5) + ->select() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + foreach ($lists as &$item) { + $item['create_time'] = date($timeFormat, strtotime($item['create_time'])); + } + + $report['user_money'] = $user['user_money']; + $report['user_point'] = $user['user_point']; + // $report['used_money'] = UtilsService::get_used_money($params['user_id']); + // if($report['used_money'] < 0) $report['used_money'] = 0; + // $report['noused_money'] = UserFinance::where(['user_id' => $params['user_id'],'frozen' => 1])->sum('change_amount'); + // $report['exp_money'] = 0; + + return [ + 'fund_list' => $lists, + 'report' => $report + ]; + } + + /** + * @notes 资金明细详情 + * @param $params + * @return array + * @author BD + * @date 2024/9/20 17:09 + */ + public static function detail(array $params) + { + $field = 'id,sn,change_type as type,change_amount as amount,remark,action,create_time'; + $record = UserFinance::field($field) + ->where(['id' => $params['id'],'user_id' => $params['user_id']]) + ->findOrEmpty() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + $record['create_time'] = date($timeFormat, strtotime($record['create_time'])); + + return $record; + } + + /** + * @notes 提现方式 + * @param $lang + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public static function withdrawMethod($lang) + { + try { + //查询语言 + $language = Language::where(['symbol' => $lang])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + $field = 'id,type,name as text,is_qrcode,symbol,rate,precision,charge'; + $methods = WithdrawMethod::field($field) + ->where(['is_show' => YesNoEnum::YES]) + ->whereIn('lang_id', [0,$language['id']]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + return $methods; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + /** + * @notes 提现钱包 + * @param $lang + * @param $userId + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public static function withdrawWallet($lang, $userId) + { + try { + //查询语言 + $language = Language::where(['symbol' => $lang])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + $field = 'ww.id,ww.method_id,ww.account,ww.type'; + $field .= ',wm.name as method_name,wm.charge as method_charge,wm.rate as method_rate,wm.symbol as method_symbol,wm.precision as method_precision'; + $wallets = WithdrawWallet::alias('ww') + ->join('withdraw_method wm', 'wm.id = ww.method_id') + ->field($field) + ->where(['ww.user_id' => $userId]) + ->whereIn('ww.lang_id', [0,$language['id']]) + ->order(['wm.sort' => 'desc']) + ->select() + ->toArray(); + + foreach ($wallets as &$wallet) { + if($wallet['type'] == 2){ + $wallet['account'] = substr($wallet['account'],0,3).'******'.substr($wallet['account'],strlen($wallet['account'])-3,strlen($wallet['account'])); + $wallet['text'] = $wallet['method_name'].'('.$wallet['account'].')'; + }else{ + $wallet['account'] = substr($wallet['account'],0,4).'******'.substr($wallet['account'],strlen($wallet['account'])-4,strlen($wallet['account'])); + $wallet['text'] = $wallet['method_name'].'('.$wallet['account'].')'; + } + + } + + return $wallets; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 提现银行 + * @param $lang + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public static function withdrawBanks($lang) + { + try { + //查询语言 + $language = Language::where(['symbol' => $lang])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + $field = ['id','name']; + $methods = WithdrawBank::field($field) + ->where(['is_show' => YesNoEnum::YES]) + ->where(['lang_id' => $language['id']]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + return $methods; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 绑定提现钱包 + * @param array $params + * @return bool + * @author BD + * @date 2024/02/22 10:54 + */ + public static function withdrawWalletAdd(array $params) + { + try { + + //查询语言 + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + $method = WithdrawMethod::where(['id' => $params['method_id']])->findOrEmpty(); + + $bank_name = ''; + $bank_id = ''; + if($method['type'] == 3){ + $bank = WithdrawBank::where(['id' => $params['bank_id']])->findOrEmpty(); + $bank_name = $bank['name']; + $bank_id = $bank['id']; + } + + + $wallet = WithdrawWallet::create([ + 'lang_id' => $method['lang_id'], + 'user_id' => $params['user_id'], + 'method_id' => $params['method_id'], + 'bank_id' => $bank_id, + 'type' => $method['type'], + 'name' => isset($params['name'])?$params['name']:'', + 'account' => $params['account'], + 'img' => isset($params['img'])?$params['img']:'', + 'bank_name' => $bank_name, + ]); + + return [ + 'from' => 'walletAdd' + ]; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 提现配置 + * @param $params + * @return array + * @author BD + * @date 2024/02/22 10:54 + */ + public static function withdrawConfig(array $params) + { + $config = ConfigService::get('website', 'trade'); + + $user = User::where(['id' => $params['user_id']]) -> findOrEmpty(); + + $is_withdraw = true; + + // //判断提现次数(每24小时可提现n次) + // $time24Hours = time() - 24 * 60 * 60; + + //判断提现次数(每天可提现n次) + $time24Hours = strtotime("today midnight"); + + $withdraw_num = WithdrawRecord::where(['user_id' => $params['user_id']]) + ->where('status in (0,1)') + ->where("create_time > $time24Hours") + ->count(); + if($config['withdraw_num'] <= $withdraw_num){ + $is_withdraw = false; + } + + //查询实名认证状态 + $need_realname = 0; + $userInfo = UserInfo::where(['user_id' => $params['user_id']]) -> findOrEmpty(); + if (!$userInfo->isEmpty() && $config['need_realname'] == 1) { + if($userInfo['auth_card'] != 1) $need_realname = 1; + } + + //查询初始交易密码 + $need_set_pwd = 0; + $pwd_pay = ConfigService::get('login', 'password_pay'); + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] == create_password($pwd_pay, $passwordSalt)) { + $need_set_pwd = 1; + } + + $balance = UtilsService::get_used_money($params['user_id']); + if($balance < 0) $balance = 0; + + $noused_money = $user['user_money'] - $balance; + + //预输入上一次提现方式和提现地址 + $ahead['method_id'] = 0; + $ahead['address'] = ''; + $withdrawRecord = WithdrawRecord::where(['user_id' => $params['user_id']]) + ->order(['create_time' => 'desc', 'id' => 'desc']) + ->findOrEmpty(); + if(!$withdrawRecord->isEmpty()){ + $ahead['method_id'] = $withdrawRecord['method_id']; + $ahead['address'] = $withdrawRecord['account']; + } + + return [ + 'min' => $config['withdraw_min'], + 'max' => $config['withdraw_max'], + 'num' => $config['withdraw_num'], + 'is_withdraw' => $is_withdraw, + 'balance' => $balance, + 'noused_money' => $noused_money, + 'need_realname' => $need_realname, + 'need_set_pwd' => $need_set_pwd, + 'ahead' => $ahead, + ]; + } + + /** + * @notes 提现 + * @param array $params + * @return array|false + * @author BD + * @date 2024/02/22 10:54 + */ + public static function withdraw(array $params) + { + Db::startTrans(); + try { + + $method = WithdrawMethod::where(['id' => $params['method_id']])->findOrEmpty(); + + $order_amount_act = round($params['money'] * $method['rate'] , $method['precision']); + + //手续费 + $charge = 0; + if($method['charge'] > 0){ + $charge = round($params['money'] * $method['charge']/100,2); + if($charge <= 0.01) $charge = 0; + } + + $data = [ + 'sn' => generate_sn(WithdrawRecord::class, 'sn'), + 'user_id' => $params['user_id'], + 'method_id' => $method['id'], + 'amount' => $params['money'], + 'amount_act' => $order_amount_act, + 'rate' => $method['rate'], + 'symbol' => $method['symbol'], + 'charge' => $charge,//手续费 + 'type' => $method['type'], + 'account' => $params['address'], + ]; + $order = WithdrawRecord::create($data); + + //USDT发起 优盾代付 + if($method['type'] == 1){ + $udun = ConfigService::get('website', 'udun'); + + if($udun['is_open_df'] == 1 && $method['is_open_df'] == 1 && $order['amount'] - $udun['pay_min'] >= 0 && $order['amount'] - $udun['pay_max'] <= 0){ + $udunDispatch = UtilsService::get_udunDispatch(); + + $main_coin_type = $method['main_coin_type']; + $coin_type = $method['coin_type']; + + //验证地址合法性 + $result1 = $udunDispatch->checkAddress($main_coin_type,$order['account']); + + if($result1['code'] == 200){ + //申请提币 + //提币金额 = (金额 - 手续费) x 汇率 + $amount_df = round(($order['amount']- $order['charge']) * $method['rate'] , $method['precision']); + $result2 = $udunDispatch->withdraw($order['sn'],$main_coin_type,$coin_type,$order['account'],$amount_df); + if($result2['code'] == 200){ + WithdrawRecord::update([ + 'id' => $order['id'], + 'status2' => 1 + ]); + } + } + } + } + + //记录日志 + UtilsService::user_finance_add( + $data['user_id'], + 2, + 2, + $data['amount'], + $data['sn'] + ); + + //用户资金修改 + UtilsService::user_money_change($data['user_id'], 2, $data['amount'],'user_money'); + + //提现金额增加 + UtilsService::user_money_change($data['user_id'], 1, $data['amount'],'total_withdraw'); + + Db::commit(); + return [ + 'order_id' => (int)$order['id'], + 'from' => 'withdraw' + ]; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 提现记录详情 + * @param $params + * @return array + * @author BD + * @date 2024/02/22 10:54 + */ + public static function withdrawRecordDetail($params) + { + $field = 'id,method_id,sn,amount,amount_act,rate,charge,symbol,account,status,type,create_time,remark'; + $record = WithdrawRecord::field($field) + ->append(['method_name']) + ->where(['id' => $params['id'],'user_id' => $params['user_id']]) + ->findOrEmpty() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + $record['create_time'] = date($timeFormat, strtotime($record['create_time'])); + + if($record['type'] == 2){ + $record['account'] = substr($record['account'],0,3).'******'.substr($record['account'],strlen($record['account'])-3,strlen($record['account'])); + $record['account'] = $record['method_name'].'('.$record['account'].')'; + }else{ + $record['account'] = substr($record['account'],0,4).'******'.substr($record['account'],strlen($record['account'])-4,strlen($record['account'])); + $record['account'] = $record['method_name'].'('.$record['account'].')'; + } + + return $record; + } + + /** + * @notes 充值记录详情 + * @param $params + * @return array + * @author BD + * @date 2024/02/22 10:54 + */ + public static function rechargeRecordDetail($params) + { + $field = 'id,method_id,sn,amount,amount_act,rate,symbol,status,create_time'; + $record = RechargeRecord::field($field) + ->append(['method_name']) + ->where(['id' => $params['id'],'user_id' => $params['user_id']]) + ->findOrEmpty() + ->toArray(); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + $record['create_time'] = date($timeFormat, strtotime($record['create_time'])); + + return $record; + } + + /** + * @notes 用户转账数据 + * @param $params + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbExceptionlimit + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/3/21 19:15 + */ + public static function transferIndex(array $params) + { + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + + $resUser['balance'] = UtilsService::get_used_money($params['user_id']); + if($resUser['balance'] < 0) $resUser['balance'] = 0; + + //查询初始交易密码 + $need_set_pwd = 0; + $pwd_pay = ConfigService::get('login', 'password_pay'); + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] == create_password($pwd_pay, $passwordSalt)) { + $need_set_pwd = 1; + } + + $config = ConfigService::get('website', 'trade'); + $config['min'] = $config['transfer_min']; + $config['max'] = $config['transfer_max']; + + $config['need_set_pwd'] = $need_set_pwd; + + return [ + 'config' => $config, + 'user' => $resUser + ]; + } + + /** + * @notes 转账 + * @param array $params + * @return array|false + * @author BD + * @date 2024/02/22 10:54 + */ + public static function transfer(array $params) + { + Db::startTrans(); + try { + //转出用户 + $userFrom = User::where(['id' => $params['user_id']])->findOrEmpty(); + + //转入用户 + $userTo = User::where(['account' => $params['account']])->findOrEmpty(); + + //转出用户记录 + $data = [ + 'sn' => generate_sn(UserTransferRecord::class, 'sn'), + 'user_id' => $userFrom['id'], + 'user_id_from' => $userFrom['id'], + 'user_id_to' => $userTo['id'], + 'amount' => $params['money'], + 'type' => 2, + ]; + $orderFrom = UserTransferRecord::create($data); + + //记录日志 + UtilsService::user_finance_add( + $data['user_id'], + 19, + 2, + $data['amount'], + $data['sn'] + ); + + //用户资金修改 + UtilsService::user_money_change($data['user_id'], 2, $data['amount'],'user_money'); + + //转入用户记录 + $data = [ + 'sn' => generate_sn(UserTransferRecord::class, 'sn'), + 'user_id' => $userTo['id'], + 'user_id_from' => $userFrom['id'], + 'user_id_to' => $userTo['id'], + 'amount' => $params['money'], + 'type' => 1, + ]; + $orderTo = UserTransferRecord::create($data); + + //记录日志 + UtilsService::user_finance_add( + $data['user_id'], + 20, + 1, + $data['amount'], + $data['sn'] + ); + + //用户资金修改 + UtilsService::user_money_change($data['user_id'], 1, $data['amount'],'user_money'); + + Db::commit(); + return [ + 'from' => 'transfer' + ]; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + +} \ No newline at end of file diff --git a/app/api/logic/IndexLogic.php b/app/api/logic/IndexLogic.php new file mode 100644 index 0000000..15e7fe1 --- /dev/null +++ b/app/api/logic/IndexLogic.php @@ -0,0 +1,350 @@ +where(['is_show' => 1,'loca' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($swipers as &$swiper) { + //多语言替换 + $data = UtilsService::get_langs_data($swiper['langs'],$params['lang']); + $data_image = ''; + + if(count($data) > 0){ + $data_image = $data['image']; + } + + if($swiper['image_ext'] != ''){ + $swiper['image'] =$swiper['image_ext']; + }else{ + $swiper['image'] = FileService::getFileUrl($data_image); + } + unset($swiper['langs']); + } + + //菜单按钮 + $field2 = ['name','image','link','langs','image_ext']; + $navs = DecorateNav::field($field2) + ->where(['is_show' => 1,'loca' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($navs as &$nav) { + //多语言替换 + $data = UtilsService::get_langs_data($nav['langs'],$params['lang']); + $data_name = ''; + + if(count($data) > 0){ + $data_name = $data['name']; + } + + $nav['name'] = $data_name; + if($nav['image_ext'] != ''){ + $nav['image'] = $nav['image_ext']; + } + unset($nav['langs']); + } + + //滚动通知 + $field3 = ['id','langs']; + $notice = Article::field($field3) + ->where(['is_show' => 1,'is_notice' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->findOrEmpty(); + + if(!$notice->isEmpty()){ + $notice['is_show'] = true; + //多语言替换 + $data = UtilsService::get_langs_data($notice['langs'],$params['lang']); + $data_text = ''; + + if(count($data) > 0){ + $data_text = $data['content']; + } + $notice['text'] = strip_tags(html_entity_decode($data_text)); + unset($notice['langs']); + + }else{ + $notice['is_show'] = false; + } + + + + //合作伙伴 + $field4 = ['is_show','content','langs']; + $partner = DecorateHint::field($field4) + ->findOrEmpty(4)->toArray(); + + if($partner['is_show']){ + //多语言替换 + $data = UtilsService::get_langs_data($partner['langs'],$params['lang']); + $data_content = ''; + + if(count($data) > 0){ + $data_content = $data['content']; + } + $partner['content'] = get_file_domain($data_content); + } + unset($partner['langs']); + + + //首页视频 + $field7 = ['is_show','content','image','langs']; + $video = DecorateHint::field($field7) + ->findOrEmpty(6)->toArray(); + + if($video['is_show']){ + //多语言替换 + $data = UtilsService::get_langs_data($video['langs'],$params['lang']); + $data_content = ''; + $data_image = ''; + + if(count($data) > 0){ + $data_content = $data['content']; + $data_image = $data['image']; + } + + preg_match_all("/]*src=[\"]([^\"]+)[\"][^<>]*>/im",get_file_domain($data_content),$matches); + + $video['url'] = count($matches[1]) > 0?$matches[1][0]:''; + $video['image'] = FileService::getFileUrl($data_image); + + unset($video['content']); + unset($video['langs']); + } + + //弹窗内容 + $field8 = ['id','langs']; + $popup = Article::field($field8) + ->where(['is_show' => 1,'is_popup' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->findOrEmpty(); + + if(!$popup->isEmpty()){ + $popup['is_show'] = true; + + //多语言替换 + $data = UtilsService::get_langs_data($popup['langs'],$params['lang']); + $data_content = ''; + + if(count($data) > 0){ + $data_content = $data['content']; + } + $popup['content'] = get_file_domain($data_content); + unset($popup['langs']); + }else{ + $popup['is_show'] = false; + } + + //实时行情 + $markets = ConfigService::get('website', 'market'); + foreach ($markets as &$market) { + //图片域名格式化 + $market['logo'] = FileService::getFileUrl($market['logo']); + } + + $unread_notice = 0; + + if($params['user_id']!=0){ + $unread_notice = UserNotice::where(['user_id' => $params['user_id']]) + ->where(['read' => 0]) + ->count(); + } + + //推荐项目 + $field_item = ['id','title','image','rate','cycle','progress','type','member_id','langs']; + $items = Item::field($field_item) + ->append(['vip_name']) + ->where(['is_show' => 1,'is_index' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($items as &$item) { + $item['progress'] = round($item['progress'],2); + //多语言替换 + $data = UtilsService::get_langs_data($item['langs'],$params['lang']); + $data_title = ''; + $data_image = ''; + + if(count($data) > 0){ + $data_title = $data['title']; + $data_image = $data['image']; + } + + $item['title'] = $data_title; + $item['image'] = FileService::getFileUrl($data_image); + unset($item['langs']); + } + + return [ + // 'article' => $article, + 'banner' => $swipers, + 'navs' => $navs, + 'notice' => $notice, + 'partner' => $partner, + // 'articleCate' => $articleCate, + // 'articles' => $articles, + 'video' => $video, + 'popup' => $popup, + 'market' => $markets, + 'unreadNotice' => $unread_notice, + 'kefu_logo' => FileService::getFileUrl(ConfigService::get('website', 'kefu_logo')), + 'show_kefu' => ConfigService::get('website', 'show_kefu'), + 'kefu_link' => ConfigService::get('website', 'kefu_link'), + 'items' => $items, + ]; + } + + /** + * @notes 获取配置 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2023/9/21 19:38 + */ + public static function getConfigData($lang="") + { + $codeStr = ConfigService::get('login', 'country_code'); + $region_codes = ConfigService::get('website', 'regioncode'); + foreach ($region_codes as &$region_code) { + //图片域名格式化 + $region_code['logo'] = FileService::getFileUrl($region_code['logo']); + } + // 登录配置 + $loginConfig = [ + // 登录方式 + 'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')), + // 注册强制绑定手机 + 'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')), + // 邀请码 + 'invite_code' => ConfigService::get('login', 'invite_code', config('project.login.invite_code')), + // 国家区号 + 'region_code' => $region_codes, + ]; + // 网址信息 + $website = [ + 'shop_name' => ConfigService::get('website', 'shop_name'), + 'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')), + 'shop_logo2' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo2')), + 'currency' => ConfigService::get('website', 'currency'), + 'currency2' => ConfigService::get('website', 'currency2'), + 'precision' => ConfigService::get('website', 'precision'), + 'down_link' => ConfigService::get('website', 'down_link'), + 'is_down' => ConfigService::get('website', 'is_down'), + ]; + + if($lang == ''){ + //查询首个语言 + $first_lang = UtilsService::get_first_lang(); + $website['lang'] = $first_lang['symbol']; + $website['formatTime'] = $first_lang['time_format']; + }else{ + $language = Language::where(['symbol' => $lang,'is_show' => 1])->findOrEmpty(); + $website['lang'] = $lang; + $website['formatTime'] = $language['time_format']; + } + + + return [ + 'domain' => FileService::getFileUrl(), + 'login' => $loginConfig, + 'website' => $website, + 'version'=> config('project.version') + ]; + } + + /** + * @notes 国家区号 + * @return array + * @author BD + * @date 2023/9/21 18:37 + */ + public static function getCountryCode() + { + $region_codes = ConfigService::get('website', 'regioncode'); + foreach ($region_codes as &$region_code) { + //图片域名格式化 + $region_code['logo'] = FileService::getFileUrl($region_code['logo']); + } + return $region_codes; + } + + /** + * @notes 语言数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2023/10/13 10:53 + */ + public static function getKefuLists() + { + $lists = ConfigService::get('website', 'kefu'); + foreach ($lists as &$list) { + $list['logo'] = FileService::getFileUrl($list['logo']); + } + return $lists; + } + + /** + * @notes 行情数据 + * @return array + * @author BD + * @date 2023/10/13 10:53 + */ + public static function getMarketData() + { + //实时行情 + $markets = ConfigService::get('website', 'market'); + foreach ($markets as &$market) { + //图片域名格式化 + $market['logo'] = FileService::getFileUrl($market['logo']); + } + return $markets; + } + +} \ No newline at end of file diff --git a/app/api/logic/ItemLogic.php b/app/api/logic/ItemLogic.php new file mode 100644 index 0000000..e6e0345 --- /dev/null +++ b/app/api/logic/ItemLogic.php @@ -0,0 +1,324 @@ +append(['vip_name']) + ->where(['is_show' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($items as &$item) { + $item['progress'] = round($item['progress'],2); + //多语言替换 + $data = UtilsService::get_langs_data($item['langs'],$params['lang']); + $data_title = ''; + $data_image = ''; + + if(count($data) > 0){ + $data_title = $data['title']; + $data_image = $data['image']; + } + + $item['title'] = $data_title; + $item['image'] = FileService::getFileUrl($data_image); + unset($item['langs']); + } + + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id]) + ->field('id, name, logo, bg_img, text_color, money, level1_num, lh_min, lh_max, lh_num') + ->findOrEmpty(); + + $user_res['member'] = $userMember; + $user_res['balance'] = $user['user_money']; + $user_res['totalMoney'] = ItemRecord::where(['user_id' => $params['user_id'],'status' => 1])->sum('money'); + $user_res['todayIncome'] = UserFinance::where(['user_id' => $params['user_id'],'change_type' => 17])->where("create_time > $todayStart")->sum('change_amount'); + $user_res['totalIncome'] = $user['total_income_invest']; + + return [ + 'items' => $items, + 'user' => $user_res, + // 服务器时间 + 'server_date' => date('Y/m/d H:i:s'), + ]; + } + + /** + * @notes 项目详情 + * @param $params + * @return array + * @author BD + * @date 2024/02/22 10:54 + */ + public static function detail($params) + { + try { + // 获取今天0点的时间戳 + $todayStart = strtotime(date('Y-m-d 00:00:00')); + + $item = Item::field("id,type,title,image,content,min_money,max_money,point,rate,cycle,progress,langs,member_id")->append(['vip_name'])->where(['is_show' => 1])->findOrEmpty($params['id']); + if($item->isEmpty()){ + throw new \Exception('network.parameterAbnormality'); + } + $item['progress'] = round($item['progress'],2); + + //多语言替换 + $data = UtilsService::get_langs_data($item['langs'],$params['lang']); + $data_title = ''; + $data_image = ''; + $data_content = ''; + + if(count($data) > 0){ + $data_title = $data['title']; + $data_image = $data['image']; + $data_content = $data['content']; + } + + $item['title'] = $data_title; + $item['image'] = FileService::getFileUrl($data_image); + $item['content'] = get_file_domain($data_content); + unset($item['langs']); + + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + //查询初始交易密码 + $need_set_pwd = 0; + $pwd_pay = ConfigService::get('login', 'password_pay'); + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] == create_password($pwd_pay, $passwordSalt)) { + $need_set_pwd = 1; + } + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id]) + ->field('id,item_num,item_add_rate') + ->findOrEmpty(); + + $user_res['member'] = $userMember; + $user_res['balance'] = $user['user_money']; + + //今日投资次数 + $user_res['today_order'] = ItemRecord::where("create_time > $todayStart") + ->where(['user_id' => $params['user_id']]) + ->count(); + + return [ + 'item' => $item, + 'user' => $user_res, + 'need_set_pwd' => $need_set_pwd, + ]; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 合同详情 + * @param $params + * @return array + * @author BD + * @date 2024/02/22 10:54 + */ + public static function contract($params) + { + try { + $itemRecord = ItemRecord::where(['id' => $params['id']])->findOrEmpty(); + if($itemRecord->isEmpty()){ + throw new \Exception('network.parameterAbnormality'); + } + + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + + //合同内容 + $contract = DecorateHint::findOrEmpty(23)->toArray(); + + $end_time = date('Y-m-d', $itemRecord['end_time']); + $date = date('Y-m-d', strtotime($itemRecord['create_time'])); + + //多语言替换 + $data = UtilsService::get_langs_data($contract['langs'],$params['lang']); + $content = get_file_domain($data['content']); + + $content = str_replace('{sn}', $itemRecord['contract_no'], $content); + $content = str_replace('{username}', $user['country_code'].' '.$user['account'], $content); + $content = str_replace('{money}', $itemRecord['money'], $content); + $content = str_replace('{rate}', $itemRecord['rate'], $content); + $content = str_replace('{total_income}', $itemRecord['total_income'], $content); + $content = str_replace('{date_e}', $end_time, $content); + $content = str_replace('{date}', $date, $content); + + return [ + 'content' => $content, + 'type' => $itemRecord['type'], + 'cycle' => $itemRecord['cycle'], + 'contract_y_logo' => FileService::getFileUrl($contract['contract_y_logo']), + 'contract_b_logo' => FileService::getFileUrl($contract['contract_b_logo']), + + ]; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 投资 + * @param array $params + * @return array|false + * @author BD + * @date 2024/02/22 10:54 + */ + public static function invest(array $params) + { + Db::startTrans(); + try { + // 获取今天0点的时间戳 + // $todayStart = strtotime(date('Y-m-d 00:00:00')); + + $user = User::where(['id' => $params['user_id']]) -> findOrEmpty(); + + $item = Item::where(['is_show' => 1])->findOrEmpty($params['id']); + //多语言替换 + $data = UtilsService::get_langs_data($item['langs'],$params['lang']); + $data_title = ''; + $data_image = ''; + $data_content = ''; + + if(count($data) > 0){ + $data_title = $data['title']; + $data_image = $data['image']; + $data_content = $data['content']; + } + + $item['title'] = $data_title; + $item['image'] = $data_image; + $item['content'] = $data_content; + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id])->findOrEmpty(); + + //判断加息率 + if($userMember['item_add_rate'] > 0) $item['rate'] = round($item['rate'] + $userMember['item_add_rate'],2); + + //投资类型 + // 1每日付息到期还本 + // 2到期还本付息(日) + // 3到期还本付息(时) + // 4每时付息到期还本 + $end_time = time() + ($item['cycle'] * 24 * 60 * 60);//到期时间(天) + $total_num = $item['cycle']; + $wait_num = $item['cycle']; + $total_income = round($params['money'] * $item['rate'] * $item['cycle'] / 100,2);//总收益(每日/时) + + switch($item['type']){ + case 1: + + break; + case 2: + $wait_num = 1; + $total_income = round($params['money'] * $item['rate'] / 100,2); + break; + case 3: + $wait_num = 1; + $total_income = round($params['money'] * $item['rate'] / 100,2); + $end_time = time() + ($item['cycle'] * 60 * 60);//到期时间(时) + break; + case 4: + $end_time = time() + ($item['cycle'] * 60 * 60);//到期时间(时) + break; + } + + + $data = [ + 'sn' => generate_sn(ItemRecord::class, 'sn'), + 'contract_no' => generate_sn(ItemRecord::class, 'contract_no'), + 'user_id' => $params['user_id'], + 'item_id' => $item['id'], + 'item_title' => $item['title'], + 'item_image' => FileService::setFileUrl($item['image']), + 'item_langs' => $item['langs'], + 'money' => $params['money'], + 'point' => $item['point'], + 'rate' => $item['rate'], + 'cycle' => $item['cycle'], + 'total_num' => $total_num, + 'wait_num' => $wait_num, + 'total_income' => $total_income, + 'type' => $item['type'], + 'status' => 1,//状态1进行中2已结束 + 'end_time' => $end_time,//到期时间 + ]; + $order = ItemRecord::create($data); + + //记录日志 + UtilsService::user_finance_add( + $data['user_id'], + 16, + 2, + $data['money'], + $data['sn'] + ); + + //用户资金修改 + UtilsService::user_money_change($data['user_id'], 2, $data['money'],'user_money'); + //累积投资金额 + UtilsService::user_money_change($data['user_id'], 1, $data['money'],'total_invest'); + + //赠送积分 + if($item['point'] > 0){ + UtilsService::user_money_change($data['user_id'], 1, $item['point'],'user_point'); + } + + //更新会员等级 + UtilsService::set_user_member($params['user_id']); + + Db::commit(); + return []; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + +} \ No newline at end of file diff --git a/app/api/logic/LanguageLogic.php b/app/api/logic/LanguageLogic.php new file mode 100644 index 0000000..049e78c --- /dev/null +++ b/app/api/logic/LanguageLogic.php @@ -0,0 +1,100 @@ + $params['name']]; + $language = Language::field($field) + ->where($where) + ->findOrEmpty() + ->toArray(); + + return $language; + } + + + /** + * @notes 语言数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:53 + */ + public static function getAllData() + { + $field = ['id','name_loc as name','symbol','precision','time_format']; + $langs = Language::field($field) + ->where(['is_show' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + return $langs; + } + + /** + * @notes 语言包数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/13 10:53 + */ + public static function getPagAllData($params) + { + //查询语言 + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + $field = ['type','name','value']; + $pags = LanguagePag::field($field) + ->where(['lang' => $params['lang']]) + ->order(['type' => 'asc','name' => 'asc', 'value' => 'asc']) + ->select() + ->toArray(); + + return $pags; + } + +} \ No newline at end of file diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php new file mode 100644 index 0000000..c35cd53 --- /dev/null +++ b/app/api/logic/LoginLogic.php @@ -0,0 +1,507 @@ + request()->ip()])->count(); + if ($config_ip_num <= $count_ip) { + throw new \Exception('login.ipExisted'); + } + + $regioncodes = ConfigService::get('website', 'regioncode'); + $country_code = $params['country_code']; + + $found = array_filter($regioncodes, function($object) use ($country_code) { + return strpos($object['code'], $country_code) !== false; + }); + if ($found === false) { + throw new \Exception('network.parameterAbnormality'); + } + $userSn = User::createUserSn(); + $passwordSalt = Config::get('project.unique_identification'); + $password = create_password($params['password'], $passwordSalt); + $password_pay_ = ConfigService::get('login', 'password_pay'); + $password_pay = create_password($password_pay_, $passwordSalt); + $avatar = ConfigService::get('default_image', 'user_avatar'); + + + //判断上级 + //邀请码 + $top_sn = $params['invite_code']; + + //判断邀请码是否填写 + $is_invite_code = ConfigService::get('login', 'invite_code'); + if($is_invite_code && $top_sn == '') throw new \Exception('login.inviteCodeEmpty');//请输入邀请码 + + $top_User = ''; + + if(isset($top_sn) && $top_sn != ''){ + if(!preg_match("/^-?\d+$/",$top_sn)) throw new \Exception('login.inviteCodeNoExist');//邀请码不存在 + + $top_User = User::where(['sn' => $top_sn,'is_sn' => 1])->findOrEmpty(); + if ($top_User->isEmpty()) { + throw new \Exception('login.inviteCodeNoExist');//邀请码不存在 + } + } + + $mobile = $params['account']; + if($params['login_way'] == 1){ + $mobile = $params['country_code'] . ' ' .$params['account']; + } + + $is_transfer = 0; + $trade = ConfigService::get('website', 'trade'); + if($trade['is_transfer'] != 0) $is_transfer = 1; + + $user = User::create([ + 'sn' => $userSn, + 'avatar' => $avatar, + 'nickname' => '' . $userSn, + 'account' => $params['account'], + 'password' => $password, + 'password_pay' => $password_pay, + 'mobile' => $mobile, + 'country_code' => $params['country_code'], + 'channel' => $params['channel'], + 'is_transfer' => $is_transfer, + 'login_ip' => request()->ip(), + 'register_ip' => request()->ip(), + 'login_time' => time(), + ]); + + //创建用户关系 + if ($top_User != "") { + UtilsService::create_user_relation($user['id'],$top_User['id'],UtilsService::get_distribute_level()); + } + + //创建系统消息记录 + UtilsService::create_user_notice($user['id']); + + //创建初始会员等级 + UtilsService::set_user_member($user['id']); + + //创建用户信息 + UserInfo::create(['user_id' => $user['id']]); + + //设置token + $userInfo = UserTokenService::setToken($user['id'], $params['channel']); + Db::commit(); + + return [ + 'token' => $userInfo['token'], + ]; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 账号/手机号登录,手机号验证码 + * @param $params + * @return array|false + * @author 段誉 + * @date 2022/9/6 19:26 + */ + public static function login($params) + { + try { + + $user = User::where(['account' => $params['account']])->findOrEmpty(); + + //更新登录信息 + $user->login_time = time(); + $user->login_ip = request()->ip(); + $user->save(); + + //设置token + $userInfo = UserTokenService::setToken($user->id, $params['terminal']); + + //返回登录信息 + $avatar = $user->avatar ?: Config::get('project.default_image.user_avatar'); + $avatar = FileService::getFileUrl($avatar); + + return [ + 'nickname' => $userInfo['nickname'], + 'sn' => $userInfo['sn'], + 'mobile' => $userInfo['mobile'], + 'avatar' => $avatar, + 'token' => $userInfo['token'], + ]; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 退出登录 + * @param $userInfo + * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/16 17:56 + */ + public static function logout($userInfo) + { + //token不存在,不注销 + if (!isset($userInfo['token'])) { + return false; + } + + //设置token过期 + return UserTokenService::expireToken($userInfo['token']); + } + + + /** + * @notes 更新用户信息 + * @param $params + * @param $userId + * @return User + * @author 段誉 + * @date 2023/2/22 11:19 + */ + public static function updateUser($params, $userId) + { + return User::where(['id' => $userId])->update([ + 'nickname' => $params['nickname'], + 'avatar' => FileService::setFileUrl($params['avatar']), + 'is_new_user' => YesNoEnum::NO + ]); + } + + + /** + * @notes 更新登录信息 + * @param $userId + * @throws \Exception + * @author 段誉 + * @date 2022/9/20 19:46 + */ + public static function updateLoginInfo($userId) + { + $user = User::findOrEmpty($userId); + if ($user->isEmpty()) { + throw new \Exception('network.parameterAbnormality'); + } + + $time = time(); + $user->login_time = $time; + $user->login_ip = request()->ip(); + $user->update_time = $time; + $user->save(); + } + + // /** + // * @notes 获取微信请求code的链接 + // * @param string $url + // * @return string + // * @author 段誉 + // * @date 2022/9/20 19:47 + // */ + // public static function codeUrl(string $url) + // { + // return (new WeChatOaService())->getCodeUrl($url); + // } + + + // /** + // * @notes 公众号登录 + // * @param array $params + // * @return array|false + // * @throws \GuzzleHttp\Exception\GuzzleException + // * @author 段誉 + // * @date 2022/9/20 19:47 + // */ + // public static function oaLogin(array $params) + // { + // Db::startTrans(); + // try { + // //通过code获取微信 openid + // $response = (new WeChatOaService())->getOaResByCode($params['code']); + // $userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_OA); + // $userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo(); + + // // 更新登录信息 + // self::updateLoginInfo($userInfo['id']); + + // Db::commit(); + // return $userInfo; + + // } catch (\Exception $e) { + // Db::rollback(); + // self::$error = $e->getMessage(); + // return false; + // } + // } + + + // /** + // * @notes 小程序-静默登录 + // * @param array $params + // * @return array|false + // * @author 段誉 + // * @date 2022/9/20 19:47 + // */ + // public static function silentLogin(array $params) + // { + // try { + // //通过code获取微信 openid + // $response = (new WeChatMnpService())->getMnpResByCode($params['code']); + // $userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_MMP); + // $userInfo = $userServer->getResopnseByUserInfo('silent')->getUserInfo(); + + // if (!empty($userInfo)) { + // // 更新登录信息 + // self::updateLoginInfo($userInfo['id']); + // } + + // return $userInfo; + // } catch (\Exception $e) { + // self::$error = $e->getMessage(); + // return false; + // } + // } + + + // /** + // * @notes 小程序-授权登录 + // * @param array $params + // * @return array|false + // * @author 段誉 + // * @date 2022/9/20 19:47 + // */ + // public static function mnpLogin(array $params) + // { + // Db::startTrans(); + // try { + // //通过code获取微信 openid + // $response = (new WeChatMnpService())->getMnpResByCode($params['code']); + // $userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_MMP); + // $userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo(); + + // // 更新登录信息 + // self::updateLoginInfo($userInfo['id']); + + // Db::commit(); + // return $userInfo; + // } catch (\Exception $e) { + // Db::rollback(); + // self::$error = $e->getMessage(); + // return false; + // } + // } + + + + + + // /** + // * @notes 小程序端绑定微信 + // * @param array $params + // * @return bool + // * @author 段誉 + // * @date 2022/9/20 19:46 + // */ + // public static function mnpAuthLogin(array $params) + // { + // try { + // //通过code获取微信openid + // $response = (new WeChatMnpService())->getMnpResByCode($params['code']); + // $response['user_id'] = $params['user_id']; + // $response['terminal'] = UserTerminalEnum::WECHAT_MMP; + + // return self::createAuth($response); + + // } catch (\Exception $e) { + // self::$error = $e->getMessage(); + // return false; + // } + // } + + + // /** + // * @notes 公众号端绑定微信 + // * @param array $params + // * @return bool + // * @throws \GuzzleHttp\Exception\GuzzleException + // * @author 段誉 + // * @date 2022/9/16 10:43 + // */ + // public static function oaAuthLogin(array $params) + // { + // try { + // //通过code获取微信openid + // $response = (new WeChatOaService())->getOaResByCode($params['code']); + // $response['user_id'] = $params['user_id']; + // $response['terminal'] = UserTerminalEnum::WECHAT_OA; + + // return self::createAuth($response); + + // } catch (\Exception $e) { + // self::$error = $e->getMessage(); + // return false; + // } + // } + + + // /** + // * @notes 生成授权记录 + // * @param $response + // * @return bool + // * @throws \Exception + // * @author 段誉 + // * @date 2022/9/16 10:43 + // */ + // public static function createAuth($response) + // { + // //先检查openid是否有记录 + // $isAuth = UserAuth::where('openid', '=', $response['openid'])->findOrEmpty(); + // if (!$isAuth->isEmpty()) { + // throw new \Exception('该微信已被绑定'); + // } + + // if (isset($response['unionid']) && !empty($response['unionid'])) { + // //在用unionid找记录,防止生成两个账号,同个unionid的问题 + // $userAuth = UserAuth::where(['unionid' => $response['unionid']]) + // ->findOrEmpty(); + // if (!$userAuth->isEmpty() && $userAuth->user_id != $response['user_id']) { + // throw new \Exception('该微信已被绑定'); + // } + // } + + // //如果没有授权,直接生成一条微信授权记录 + // UserAuth::create([ + // 'user_id' => $response['user_id'], + // 'openid' => $response['openid'], + // 'unionid' => $response['unionid'] ?? '', + // 'terminal' => $response['terminal'], + // ]); + // return true; + // } + + + // /** + // * @notes 获取扫码登录地址 + // * @return array|false + // * @author 段誉 + // * @date 2022/10/20 18:23 + // */ + // public static function getScanCode($redirectUri) + // { + // try { + // $config = WeChatConfigService::getOpConfig(); + // $appId = $config['app_id']; + // $redirectUri = UrlEncode($redirectUri); + + // // 设置有效时间标记状态, 超时扫码不可登录 + // $state = MD5(time().rand(10000, 99999)); + // (new WebScanLoginCache())->setScanLoginState($state); + + // // 扫码地址 + // $url = WeChatRequestService::getScanCodeUrl($appId, $redirectUri, $state); + // return ['url' => $url]; + + // } catch (\Exception $e) { + // self::$error = $e->getMessage(); + // return false; + // } + // } + + + // /** + // * @notes 网站扫码登录 + // * @param $params + // * @return array|false + // * @author 段誉 + // * @date 2022/10/21 10:28 + // */ + // public static function scanLogin($params) + // { + // Db::startTrans(); + // try { + // // 通过code 获取 access_token,openid,unionid等信息 + // $userAuth = WeChatRequestService::getUserAuthByCode($params['code']); + + // if (empty($userAuth['openid']) || empty($userAuth['access_token'])) { + // throw new \Exception('获取用户授权信息失败'); + // } + + // // 获取微信用户信息 + // $response = WeChatRequestService::getUserInfoByAuth($userAuth['access_token'], $userAuth['openid']); + + // // 生成用户或更新用户信息 + // $userServer = new WechatUserService($response, UserTerminalEnum::PC); + // $userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo(); + + // // 更新登录信息 + // self::updateLoginInfo($userInfo['id']); + + // Db::commit(); + // return $userInfo; + + // } catch (\Exception $e) { + // Db::rollback(); + // self::$error = $e->getMessage(); + // return false; + // } + // } + + + +} \ No newline at end of file diff --git a/app/api/logic/MallLogic.php b/app/api/logic/MallLogic.php new file mode 100644 index 0000000..856adea --- /dev/null +++ b/app/api/logic/MallLogic.php @@ -0,0 +1,235 @@ + $params['user_id']])->findOrEmpty(); + $user_res['point'] = $user['user_point']; + + $goods_lists = MallGoods::field('id,title,image,price,num,langs') + ->where(['is_show' => 1,'type' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($goods_lists as &$goods) { + //多语言替换 + $data = UtilsService::get_langs_data($goods['langs'],$params['lang']); + $data_title = ''; + + if(count($data) > 0){ + $data_title = $data['title']; + } + + $goods['title'] = $data_title; + $goods['image'] = FileService::getFileUrl($goods['image']); + unset($goods['langs']); + } + + //查询初始交易密码 + $need_set_pwd = 0; + $pwd_pay = ConfigService::get('login', 'password_pay'); + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] == create_password($pwd_pay, $passwordSalt)) { + $need_set_pwd = 1; + } + + return [ + 'lists' => $goods_lists, + 'user' => $user_res, + 'need_set_pwd' => $need_set_pwd + ]; + } + + /** + * @notes 兑换 + * @param array $params + * @return array|false + * @author BD + * @date 2024/02/22 10:54 + */ + public static function buy(array $params) + { + Db::startTrans(); + try { + $goods = MallGoods::where(['is_show' => 1])->findOrEmpty($params['id']); + $user_id = $params['user_id']; + + $data = [ + 'sn' => generate_sn(MallGoodsRecord::class, 'sn'), + 'user_id' => $user_id, + 'm_goods_id' => $goods['id'], + 'm_goods_title' => $goods['title'], + 'm_goods_image' => FileService::setFileUrl($goods['image']), + 'm_goods_langs' => $goods['langs'], + 'price' => $goods['price'], + 'money' => $goods['money'], + 'point' => $goods['point'], + 'type' => $goods['type'], + 'type2' => $goods['type2'], + 'status' => 1,//状态0进行中1已完成 + ]; + $order = MallGoodsRecord::create($data); + + //剩余数量-1 + MallGoods::update([ + 'id' => $goods['id'], + 'num' => $goods['num'] - 1 + ]); + + //扣除积分 + if($goods['price'] > 0){ + //用户积分修改 + UtilsService::user_money_change($user_id, 2, $goods['price'],'user_point'); + } + + //类型1现金 + switch ($goods['type2']) { + case 1: + if($goods['money'] > 0.01){ + //记录日志 + UtilsService::user_finance_add( + $user_id, + 23, + 1, + $goods['money'], + $order['sn'], + '', + 1//冻结 + ); + + //用户资金修改 + UtilsService::user_money_change($user_id, 1, $goods['money'],'user_money'); + + } + break; + case 2: + + break; + case 3: + break; + } + + Db::commit(); + return []; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 抽奖数据 + * @param $params + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public static function drawIndex(array $params) + { + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + $user_res['point'] = $user['user_point']; + + //单次抽奖消耗积分 + $config = ConfigService::get('website', 'trade'); + $config_res['point'] = $config['draw_point']; + + $goods_lists = MallGoods::field('id,title as name,image as img,langs') + ->where(['is_show' => 1,'type' => 2]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($goods_lists as &$goods) { + //多语言替换 + $data = UtilsService::get_langs_data($goods['langs'],$params['lang']); + $data_title = ''; + + if(count($data) > 0){ + $data_title = $data['title']; + } + + $goods['name'] = $data_title; + $goods['img'] = FileService::getFileUrl($goods['img']); + unset($goods['langs']); + } + + return [ + 'prizeList' => $goods_lists, + 'user' => $user_res, + 'config' => $config_res, + ]; + } + + /** + * @notes 抽奖 + * @param array $params + * @return array|false + * @author BD + * @date 2024/02/22 10:54 + */ + public static function draw(array $params) + { + Db::startTrans(); + try { + + //单次抽奖消耗积分 + $config = ConfigService::get('website', 'trade'); + $draw_point = $config['draw_point']; + + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + + $goods_lists = MallGoods::where(['is_show' => 1,'type' => 2]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + //概率算法 + $lists = []; + foreach($goods_lists as $index=>$item) { + $lists[$index] = $item['win_rate']; + } + + $prizeIndex = UtilsService::get_draw_rand($goods_lists,$lists,$params['user_id'],$draw_point); + + Db::commit(); + return [ + 'index' => $prizeIndex + ]; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } +} \ No newline at end of file diff --git a/app/api/logic/PcLogic.php b/app/api/logic/PcLogic.php new file mode 100644 index 0000000..c9a1880 --- /dev/null +++ b/app/api/logic/PcLogic.php @@ -0,0 +1,240 @@ + $decoratePage, + 'all' => $allArticle, + 'new' => $newArticle, + 'hot' => $hotArticle + ]; + } + + + /** + * @notes 获取文章 + * @param string $sortType + * @param int $limit + * @return mixed + * @author 段誉 + * @date 2022/10/19 9:53 + */ + public static function getLimitArticle(string $sortType, int $limit = 0, int $cate = 0, int $excludeId = 0) + { + // 查询字段 + $field = [ + 'id', 'cid', 'title', 'desc', 'abstract', 'image', + 'author', 'click_actual', 'click_virtual', 'create_time' + ]; + + // 排序条件 + $orderRaw = 'sort desc, id desc'; + if ($sortType == 'new') { + $orderRaw = 'id desc'; + } + if ($sortType == 'hot') { + $orderRaw = 'click_actual + click_virtual desc, id desc'; + } + + // 查询条件 + $where[] = ['is_show', '=', YesNoEnum::YES]; + if (!empty($cate)) { + $where[] = ['cid', '=', $cate]; + } + if (!empty($excludeId)) { + $where[] = ['id', '<>', $excludeId]; + } + + $article = Article::field($field) + ->where($where) + ->append(['click']) + ->orderRaw($orderRaw) + ->hidden(['click_actual', 'click_virtual']); + + if ($limit) { + $article->limit($limit); + } + + return $article->select()->toArray(); + } + + + /** + * @notes 获取配置 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/21 19:38 + */ + public static function getConfigData() + { + // 登录配置 + $loginConfig = [ + // 登录方式 + 'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')), + // 注册强制绑定手机 + 'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')), + // 政策协议 + 'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')), + // 第三方登录 开关 + 'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')), + // 微信授权登录 + 'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')), + // qq授权登录 + 'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')), + ]; + + // 网站信息 + $website = [ + 'shop_name' => ConfigService::get('website', 'shop_name'), + 'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')), + 'pc_logo' => FileService::getFileUrl(ConfigService::get('website', 'pc_logo')), + 'pc_title' => ConfigService::get('website', 'pc_title'), + 'pc_ico' => FileService::getFileUrl(ConfigService::get('website', 'pc_ico')), + 'pc_desc' => ConfigService::get('website', 'pc_desc'), + 'pc_keywords' => ConfigService::get('website', 'pc_keywords'), + ]; + + // 备案信息 + $copyright = ConfigService::get('copyright', 'config', []); + + // 公众号二维码 + $oaQrCode = ConfigService::get('oa_setting', 'qr_code', ''); + $oaQrCode = empty($oaQrCode) ? $oaQrCode : FileService::getFileUrl($oaQrCode); + // 小程序二维码 + $mnpQrCode = ConfigService::get('mnp_setting', 'qr_code', ''); + $mnpQrCode = empty($mnpQrCode) ? $mnpQrCode : FileService::getFileUrl($mnpQrCode); + + return [ + 'domain' => FileService::getFileUrl(), + 'login' => $loginConfig, + 'website' => $website, + 'version' => config('project.version'), + 'copyright' => $copyright, + 'admin_url' => request()->domain() . '/admin', + 'qrcode' => [ + 'oa' => $oaQrCode, + 'mnp' => $mnpQrCode, + ] + ]; + } + + + /** + * @notes 资讯中心 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/10/19 16:55 + */ + public static function getInfoCenter() + { + $data = ArticleCate::field(['id', 'name']) + ->with(['article' => function ($query) { + $query->hidden(['content', 'click_virtual', 'click_actual']) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->append(['click']) + ->limit(10); + }]) + ->where(['is_show' => YesNoEnum::YES]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + return $data; + } + + + /** + * @notes 获取文章详情 + * @param $userId + * @param $articleId + * @param string $source + * @return array + * @author 段誉 + * @date 2022/10/20 15:18 + */ + public static function getArticleDetail($userId, $articleId, $source = 'default') + { + // 文章详情 + $detail = Article::getArticleDetailArr($articleId); + + // 根据来源列表查找对应列表 + $nowIndex = 0; + $lists = self::getLimitArticle($source, 0, $detail['cid']); + foreach ($lists as $key => $item) { + if ($item['id'] == $articleId) { + $nowIndex = $key; + } + } + // 上一篇 + $detail['last'] = $lists[$nowIndex - 1] ?? []; + // 下一篇 + $detail['next'] = $lists[$nowIndex + 1] ?? []; + + // 最新资讯 + $detail['new'] = self::getLimitArticle('new', 8, $detail['cid'], $detail['id']); + // 关注状态 + $detail['collect'] = ArticleCollect::isCollectArticle($userId, $articleId); + // 分类名 + $detail['cate_name'] = ArticleCate::where('id', $detail['cid'])->value('name'); + + return $detail; + } + +} \ No newline at end of file diff --git a/app/api/logic/RechargeLogic.php b/app/api/logic/RechargeLogic.php new file mode 100644 index 0000000..add303a --- /dev/null +++ b/app/api/logic/RechargeLogic.php @@ -0,0 +1,393 @@ + $params['id']])->findOrEmpty(); + + $order_amount_act = round($params['money'] * $method['rate'] , $method['precision']); + + $account = $method['account']; + + //充值类型为 自定义地址 + if($method['type'] == 7){ + $address = $params['address']; + $addressArr = explode(PHP_EOL, $method['address']); + if (!in_array($address, $addressArr)) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + if ($member_id < $method['member_id']) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + $account = $address; + } + + $data = [ + 'sn' => generate_sn(RechargeRecord::class, 'sn'), + 'user_id' => $params['user_id'], + 'method_id' => $params['id'], + 'amount' => $params['money'], + 'amount_act' => $order_amount_act, + 'account' => $account, + 'voucher' => $params['voucher'], + 'rate' => $method['rate'], + 'symbol' => $method['symbol'], + ]; + + $order = RechargeRecord::create($data); + + return [ + 'order_id' => (int)$order['id'], + 'from' => 'recharge' + ]; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 充值配置 + * @param $userId + * @return array + * @author BD + * @date 2024/2/24 16:56 + */ + public static function config($userId) + { + $config = ConfigService::get('website', 'trade'); + + //查询需要绑定提现账户才可提现 + $need_bing_wallet = 0; + if ($config['need_bing_wallet'] == 1) { + $count = WithdrawWallet::where(['user_id' => $userId])->count(); + if($count == 0){ + $need_bing_wallet = 1; + } + + } + + return [ + 'min' => $config['recharge_min'], + 'need_bing_wallet' => $need_bing_wallet + ]; + } + + /** + * @notes 充值方式 + * @param $params + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/10/13 10:53 + */ + public static function getAllMethod(array $params) + { + try { + //查询语言 + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + + $field = ['id','type','name','logo']; + $methods = RechargeMethod::field($field) + ->where(['is_show' => YesNoEnum::YES]) + ->whereIn('lang_id', [0,$language['id']]) + ->where(" member_id = 0 OR ( member_id !=0 AND member_id <= $member_id ) ") + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + + return $methods; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 充值方式详情 + * @param $id + * @param $lang + * @return array + * @author BD + * @date 2024/9/20 17:09 + */ + public static function methodDetail($id,$lang) + { + try { + //查询语言 + $language = Language::where(['symbol' => $lang])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + $field = ['id','type','name','logo','account','is_voucher','img as qrcode','bank_name','bank_username','symbol','rate','precision']; + $method = RechargeMethod::field($field) + ->where(['is_show' => YesNoEnum::YES]) + ->where(['id' => $id]) + ->whereIn('lang_id', [0,$language['id']]) + ->findOrEmpty() + ->toArray(); + + if (empty($method)) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + return $method; + + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + /** + * @notes 充值方式详情-优盾 + * @param array $params + * @return array + * @author BD + * @date 2024/9/20 17:09 + */ + public static function methodDetailUdun(array $params) + { + try { + //查询语言 + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + $method = RechargeMethod::where(['is_show' => YesNoEnum::YES]) + ->where(['id' => $params['id']]) + ->findOrEmpty() + ->toArray(); + + if (empty($method)) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + //查看是否创建地址 + $userUdun = UserUdun::where(['user_id' => $params['user_id'],'method_id' => $method['id']]) + ->findOrEmpty() + ->toArray(); + $address = ""; + $qrcode = ""; + $data = []; + if (empty($userUdun)) { + + //查看是否创建主钱包相同地址 + $userUdun2 = UserUdun::where(['user_id' => $params['user_id'],'main_coin_type' => $method['main_coin_type']]) + ->findOrEmpty() + ->toArray(); + + if (empty($userUdun2)) { + + //没有创建则创建地址 + $udunDispatch = UtilsService::get_udunDispatch(); + + $result = $udunDispatch->createAddress($method['main_coin_type']); + $address = $result['data']['address']; + $qrcode = UtilsService::get_qrcode($address); + }else{ + $address = $userUdun2['address']; + $qrcode = $userUdun2['qrcode']; + } + //保存地址 + $data = [ + 'user_id' => $params['user_id'], + 'method_id' => $method['id'], + 'address' => $address, + 'qrcode' => $qrcode, + 'main_coin_type' => $method['main_coin_type'], + 'coin_type' => $method['coin_type'], + ]; + + UserUdun::create($data); + }else{ + $data['address'] = $userUdun['address']; + $data['qrcode'] = $userUdun['qrcode']; + } + + + return [ + 'address' => $data['address'], + 'qrcode' => $data['qrcode'], + 'protocol' => $method['protocol'], + 'logo' => $method['logo'], + 'name' => $method['name'], + ]; + + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 充值方式详情-波场 + * @param array $params + * @return array + * @author BD + * @date 2024/9/20 17:09 + */ + public static function methodDetailTron(array $params) + { + try { + //查询语言 + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + $method = RechargeMethod::where(['is_show' => YesNoEnum::YES]) + ->where(['id' => $params['id']]) + ->findOrEmpty() + ->toArray(); + + if (empty($method)) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + //查看是否创建地址 + $userTron = UserTron::where(['user_id' => $params['user_id'],'method_id' => $method['id']]) + ->findOrEmpty() + ->toArray(); + $data = [ + 'user_id' => $params['user_id'], + 'method_id' => $method['id'], + ]; + if (empty($userTron)) { + //创建地址 + $tronData = [ + 'action' => 'reg' + ]; + + $response = UtilsService::usdt_request($tronData, 'POST'); + $response = json_decode($response, true); + + if($response['code'] == 200){ + $data['address'] = $response['data']['addr']; + $data['qrcode'] = UtilsService::get_qrcode($data['address']); + $data['key'] = $response['data']['key']; + $data['last_time'] = time(); + UserTron::create($data); + }else{ + throw new \Exception('network.parameterAbnormality');//参数异常 + } + }else{ + $data['address'] = $userTron['address']; + $data['qrcode'] = $userTron['qrcode']; + // 更新最后使用时间 + UserTron::where(['id' => $userTron['id']])->update(['last_time' => time()]); + } + + + return [ + 'address' => $data['address'], + 'qrcode' => $data['qrcode'], + 'protocol' => $method['protocol'], + 'logo' => $method['logo'], + 'name' => $method['name'], + ]; + + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 充值方式详情-自定义地址 + * @param array $params + * @return array + * @author BD + * @date 2024/9/20 17:09 + */ + public static function methodDetailAddress(array $params) + { + try { + //查询语言 + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + $method = RechargeMethod::where(['is_show' => YesNoEnum::YES]) + ->where(['id' => $params['id']]) + ->findOrEmpty() + ->toArray(); + + if (empty($method)) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + //随机获取地址 + $addressArr = explode(PHP_EOL, $method['address']); + + return [ + 'avail_num' => $method['avail_num'], + 'address' => $addressArr[array_rand($addressArr)], + 'protocol' => $method['protocol'], + 'logo' => $method['logo'], + 'name' => $method['name'], + 'symbol' => $method['symbol'], + 'rate' => $method['rate'], + 'precision' => $method['precision'], + 'is_voucher' => $method['is_voucher'], + 'date' => date('Y-m-d'), + ]; + + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 获取常用充值金额 + * @param $lang + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/10/13 10:53 + */ + public static function getCommonMoney($lang) + { + $config = ConfigService::get('website', 'trade'); + return explode("\n", $config['common_money']); + } + +} \ No newline at end of file diff --git a/app/api/logic/RobotLogic.php b/app/api/logic/RobotLogic.php new file mode 100644 index 0000000..b13c53b --- /dev/null +++ b/app/api/logic/RobotLogic.php @@ -0,0 +1,519 @@ +// $params['user_id']]) +// ->field('id,user_money as balance,total_income as totalIncome,is_lh') +// ->findOrEmpty(); + +// //查询会员等级 +// $member_id = UtilsService::get_user_member_id($params['user_id']); +// $userMember = UserMember::where(['id' => $member_id]) +// ->field('id, name, logo, bg_img, text_color, money, level1_num, lh_min, lh_max, lh_num') +// ->findOrEmpty(); + +// $today_income = UserFinance::where("create_time > $todayStart") +// ->where(['user_id' => $params['user_id'],'change_type' => 13]) +// ->sum('change_amount'); + +// $today_order = LhRecord::where("create_time > $todayStart") +// ->where(['user_id' => $params['user_id']]) +// ->count(); + +// $user['member'] = $userMember; +// $user['todayIncome'] = $today_income; +// $user['totalIncome'] = $user['totalIncome']; +// $user['todayOrder'] = $today_order; +// $user['todayTotalOrder'] = $userMember['lh_num']; + + + +// $today_money = LhRecord::where("create_time > $todayStart") +// ->where(['user_id' => $params['user_id']]) +// ->sum('money'); +// $user['todayMoney'] = $today_money; + +// //今日量化过 +// if($user['todayMoney'] > 0){ +// //可量化总额金额 = 今日最后一次量化金额 * 可量化次数 +// $today_last_money = LhRecord::where("create_time > $todayStart") +// ->where(['user_id' => $params['user_id']]) +// ->order('create_time desc') +// ->findOrEmpty(); +// $user['totalyMoney'] = $today_last_money['money'] * $userMember['lh_num']; +// }else{ + +// //查询今日量化情况,已量化、总可量化(根据会员等级最高量化金额,用户余额小于最高,则根据用户余额,用户余额小于最低,则根据最低) +// //大于最大量化金额 +// if($user['balance'] >= $userMember['lh_max']){ +// $user['totalyMoney'] = $userMember['lh_max']; +// //大于最小量化金额 小于最大量化金额 +// }elseif($user['balance'] > $userMember['lh_min'] && $user['balance'] < $userMember['lh_max']){ +// $user['totalyMoney'] = $user['balance']; +// //小于最小量化金额 +// }else{ +// $user['totalyMoney'] = $userMember['lh_min']; +// } +// } + +// return [ +// 'user' => $user, +// // 服务器时间 +// 'server_date' => date('Y/m/d H:i:s'), +// ]; +// } + +// /** +// * @notes 量化 +// * @param $params +// * @return array|false +// * @throws \think\db\exception\DataNotFoundException +// * @throws \think\db\exception\DbException +// * @throws \think\db\exception\ModelNotFoundException +// * @author BD +// * @date 2024/02/22 10:54 +// */ +// public static function buy(array $params) +// { +// Db::startTrans(); +// try { +// // 获取今天0点的时间戳 +// $todayStart = strtotime(date('Y-m-d 00:00:00')); + +// $user = User::where(['id' => $params['user_id']]) -> findOrEmpty(); + +// $coin = LhCoin::where(['is_show' => 1]) ->orderRaw(" RAND() ") -> findOrEmpty(); +// //查询会员等级 +// $member_id = UtilsService::get_user_member_id($params['user_id']); +// $userMember = UserMember::where(['id' => $member_id])->findOrEmpty(); + +// //计算买入金额 +// $money = 0; + +// //查询今日量化情况,总可量化(根据会员等级最高量化金额,用户余额小于最高,则根据用户余额,用户余额小于最低,则根据最低) +// $today_money = LhRecord::where("create_time > $todayStart") +// ->where(['user_id' => $params['user_id']]) +// ->sum('money'); +// $today_order = LhRecord::where("create_time > $todayStart") +// ->where(['user_id' => $params['user_id']]) +// ->count(); + +// //今日量化 +// if($today_order > 0){ +// //买入金额为 今日最后一次量化金额 +// $today_last_money = LhRecord::where("create_time > $todayStart") +// ->where(['user_id' => $params['user_id']]) +// ->order('create_time desc') +// ->findOrEmpty(); +// $money = $today_last_money['money']; +// }else{ +// //查询可量化总额 +// $totalyMoney = 0;//总可量化金额 +// //大于最大量化金额 +// if($user['user_money'] >= $userMember['lh_max']){ +// $totalyMoney = $userMember['lh_max']; +// //大于最小量化金额 小于最大量化金额 +// }elseif($user['user_money'] > $userMember['lh_min'] && $user['user_money'] < $userMember['lh_max']){ +// $totalyMoney = $user['user_money']; +// //小于最小量化金额 +// }else{ +// $totalyMoney = $userMember['lh_min']; +// } + +// $money = $totalyMoney / $userMember['lh_num']; + +// //最后一次,量化金额 = 可量化金额 - 已量化金额 +// if($userMember['lh_num'] - $today_order == 1){ +// $money = $totalyMoney - $today_money; +// } +// } + +// if($money <= 0){ +// throw new \Exception('network.parameterAbnormality'); +// } + +// // //如果用户余额低于最大量化金额,则根据量化金额取值,否则根据用户余额取值 +// // if($userMember['lh_max'] > $user['user_money']){ +// // $userMember['lh_max'] = $user['user_money']; +// // } + +// // $money = mt_rand($userMember['lh_min'], $userMember['lh_max']); + +// $rate = round($userMember['rate_min'] + mt_rand() / mt_getrandmax() * ($userMember['rate_max'] - $userMember['rate_min']), 2); + +// //每次量化收益 = 最小-最大量化金额随机值 * 最小-最大量化收益率随机值 / 每日量化次数 +// $income = round(($money * $rate / 100), 2); + +// $money_sale = round($coin['price'] + ($coin['price'] * $rate ) / 100, 4); + +// $data = [ +// 'sn' => generate_sn(LhRecord::class, 'sn'), +// 'user_id' => $params['user_id'], +// 'coin_id' => $coin['id'], +// 'coin_name' => $coin['name'], +// 'coin_logo' => $coin['logo'], +// 'coin_symbol' => $coin['symbol'], +// 'coin_buy_name' => $coin['buy_name'], +// 'coin_sale_name' => $coin['sale_name'], +// 'money' => $money, +// 'income' => $income, +// 'money_buy' => $coin['price'], +// 'money_sale' => $money_sale +// ]; +// $order = LhRecord::create($data); + +// //记录日志 +// UtilsService::user_finance_add( +// $data['user_id'], +// 13, +// 1, +// $data['income'], +// $data['sn'], +// '', +// 1 //冻结 +// ); + +// //用户资金修改 +// UtilsService::user_money_change($data['user_id'], 1, $data['income'],'user_money'); +// UtilsService::user_money_change($data['user_id'], 1, $data['income'],'total_income'); + +// //团队收益奖励 +// UtilsService::team_reward_add($data['user_id'],$data['income'],2); + +// Db::commit(); +// return []; +// } catch (\Exception $e) { +// Db::rollback(); +// self::setError($e->getMessage()); +// return false; +// } +// } +// /** +// * @notes 抢单 +// * @param $params +// * @return array|false +// * @throws \think\db\exception\DataNotFoundException +// * @throws \think\db\exception\DbException +// * @throws \think\db\exception\ModelNotFoundException +// * @author BD +// * @date 2024/02/22 10:54 +// */ +// public static function grab(array $params) +// { +// Db::startTrans(); +// try { +// $user = User::where(['id' => $params['user_id']]) -> findOrEmpty(); + +// $time24Hours = time() - 24 * 60 * 60;//24小时前 + +// //查看是否存在进行中的订单 +// $orderStatus3 = GoodsRecord::where(['user_id' => $params['user_id'],'status' => 3])->findOrEmpty(); +// if (!$orderStatus3->isEmpty()) { +// throw new \Exception('network.parameterAbnormality');//派单中,请稍后重试 +// } +// $orderStatus4 = GoodsRecord::where(['user_id' => $params['user_id'],'status' => 4])->findOrEmpty(); +// if (!$orderStatus4->isEmpty()) { +// throw new \Exception('network.parameterAbnormality');//订单未支付,请先完成支付 +// } + +// //判断24小时抢单次数 +// //分组模式下,抢单次数=分组订单,未分组,抢单次数=会员等级抢单次数 +// $today_order = GoodsRecord::where("create_time > $time24Hours")->where(['user_id' => $params['user_id']])->count(); + +// //判断用户分组 +// $userGroupRecord = UserGroupRecord::where(['user_id' => $params['user_id']]) +// ->order('id', 'desc') +// ->findOrEmpty(); + +// if(!$userGroupRecord->isEmpty()) { +// $userGroupRuleCount = UserGroupRule::where(['group_id' => $userGroupRecord['group_id']])->count(); +// if ($today_order >= $userGroupRuleCount) { +// throw new \Exception('network.parameterAbnormality');//今日抢单次数已用完 +// } +// }else{ +// //查询会员等级 +// $member_id = UtilsService::get_user_member_id($params['user_id']); +// $userMember = UserMember::where(['id' => $member_id])->findOrEmpty(); +// if ($today_order >= $userMember['order']) { +// throw new \Exception('network.parameterAbnormality');//今日抢单次数已用完 +// } +// } + + +// $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); +// if ($language->isEmpty()) { +// throw new \Exception('network.parameterAbnormality'); +// } + +// $data = [ +// 'sn' => generate_sn(GoodsRecord::class, 'sn'), +// 'user_id' => $params['user_id'], +// 'lang' => $params['lang'], +// 'status' => 5, +// ]; + +// //判断派单模式 1手动2自动 +// $config = ConfigService::get('website', 'trade'); +// //自动---------------------------------------------------------------------------------------- +// if($config['robot_model'] -2 == 0){ +// //查询会员等级 +// $member_id = UtilsService::get_user_member_id($data['user_id']); +// $member = UserMember::where(['id' => $member_id])->findOrEmpty(); + +// $auto_status = false; +// $total_money = 0; +// $commission_cust = 0;//自定义佣金标识 + +// //判断是否有卡单订单 +// $total_order = GoodsRecord::where(['user_id' => $params['user_id']])->count(); + +// $kadan = UserKadan::where(['user_id' => $params['user_id'],'num' => $total_order + 1,'status' => 0])->findOrEmpty(); +// if (!$kadan->isEmpty()) { +// //计算匹配金额 +// $total_money = $kadan['money']; +// $commission_cust = $kadan['commission']; + +// UserKadan::update([ +// 'id' => $kadan['id'], +// 'status' => 1, +// ]); + +// $data['type'] = 3; + +// $auto_status = true; + +// //没有卡单订单 +// }else{ + +// //判断用户分组 +// $userGroupRecord = UserGroupRecord::where(['user_id' => $params['user_id']]) +// ->order('id', 'desc') +// ->findOrEmpty(); +// if(!$userGroupRecord->isEmpty()) { +// $userGroupRule = UserGroupRule::where(['group_id' => $userGroupRecord['group_id'],'num' => $today_order + 1])->findOrEmpty(); + +// //判断是否存在分组规则,不存在则进入手动派单 +// if(!$userGroupRule->isEmpty()){ +// //计算订单金额 金额类型1固定值2百分比 +// if($userGroupRule['money_type'] == 1){ +// $total_money = $userGroupRule['money']; +// }else{ +// $total_money = round($user['user_money'] * $userGroupRule['money_percentage'] / 100,0); +// } + +// //计算订单佣金 佣金类型1固定值2百分比 +// if($userGroupRule['commission_type'] == 1){ +// $commission_cust = $userGroupRule['commission']; +// }else{ +// $commission_cust = round($total_money * $userGroupRule['commission_percentage'] / 100,0); +// } + +// $data['type'] = 2; + +// $auto_status = true; + +// //用户分组规则金额百分比模式下,判断用户余额跟自动派单最低余额 +// if(($userGroupRule['money_type'] == 2) && ($user['user_money'] - $config['robot_range_min_money'] < 0)){ +// $auto_status = false; +// } + +// }else{ +// $auto_status = false; +// } + +// }else{ + + +// //会员自动派单订单 +// if($user['user_money'] - $config['robot_range_min_money'] >= 0){ +// //计算匹配金额 +// $total_money = round($user['user_money'] * rand($config['robot_range'][0],$config['robot_range'][1]) / 100,0); +// $auto_status = true; +// } +// } + +// } + +// if($auto_status){ + +// $goods = Goods::where("money <= $total_money")->group(" RAND() ")->findOrEmpty(); + +// if (!$goods->isEmpty()) { +// //多语言替换 +// $data_langs = UtilsService::get_langs_data($goods['langs'],$params['lang']); +// $goods['title'] = $data_langs['title']; + +// //数量 +// $num = floor($total_money / $goods['money']); + +// //计算佣金 +// $commission = $commission_cust > 0 ? $commission_cust : round($goods['money'] * $num * $member['commission']/100,2); + +// if($commission > 0.01){ +// $data['goods_id'] = $goods['id']; +// $data['goods_title'] = $goods['title']; +// $data['goods_image'] = FileService::setFileUrl($goods['image']); +// $data['unit_price'] = $goods['money']; +// $data['num'] = $num; +// $data['money'] = $goods['money'] * $num; +// $data['commission'] = $commission; +// $data['status'] = 4; +// } +// } +// } +// } + +// $order = GoodsRecord::create($data); + +// Db::commit(); +// return [ +// 'order_id' => $data['sn'], +// 'status' => 5, +// ]; +// } catch (\Exception $e) { +// Db::rollback(); +// self::setError($e->getMessage()); +// return false; +// } +// } + +// /** +// * @notes 获取进行中订单 +// * @param $params +// * @return array +// * @throws \think\db\exception\DataNotFoundException +// * @throws \think\db\exception\DbException +// * @throws \think\db\exception\ModelNotFoundException +// * @author BD +// * @date 2024/02/22 10:54 +// */ +// public static function grabIngRecord(array $params) +// { +// try { +// $field = ['id','sn','goods_title as title','goods_image as image','unit_price','num','money','commission','status']; +// $record = GoodsRecord::field($field) +// ->where(['user_id' => $params['user_id']]) +// ->where('status = 5 OR status = 4') +// ->order(['id' => 'desc']) +// ->findOrEmpty() +// ->toArray(); + +// return $record; +// } catch (\Exception $e) { +// self::setError($e->getMessage()); +// return false; +// } +// } + +// /** +// * @notes 订单支付 +// * @param array $params +// * @return array|false +// * @author BD +// * @date 2024/02/22 10:54 +// */ +// public static function grabPay(array $params) +// { +// Db::startTrans(); +// try { +// $order = GoodsRecord::where(['id' => $params['id'],'user_id' => $params['user_id']])->findOrEmpty(); + +// GoodsRecord::update([ +// 'id' => $order['id'], +// 'status' => 1, +// 'pay_time' => time() +// ]); + +// //支付扣除金额--------------------------------------------------------------------------------------------- +// //记录日志 +// UtilsService::user_finance_add( +// $order['user_id'], +// 7, +// 2, +// $order['money'], +// $order['sn'] +// ); + +// //用户资金修改 +// UtilsService::user_money_change($params['user_id'], 2, $order['money'],'user_money'); + +// $commission = $order['commission']; + +// //收益增加金额--------------------------------------------------------------------------------------------- +// //记录日志 +// UtilsService::user_finance_add( +// $order['user_id'], +// 9, +// 1, +// $commission, +// $order['sn'], +// '', +// 1 //冻结 +// ); + +// //用户资金修改 +// UtilsService::user_money_change($params['user_id'], 1, $commission,'user_money'); +// UtilsService::user_money_change($params['user_id'], 1, $commission,'total_income'); + +// //团队收益奖励 +// UtilsService::team_reward_add($params['user_id'],$commission,2); + +// //订单本金返还--------------------------------------------------------------------------------------------- +// //记录日志 +// UtilsService::user_finance_add( +// $order['user_id'], +// 8, +// 1, +// $order['money'], +// $order['sn'] +// ); + +// //用户资金修改 +// UtilsService::user_money_change($params['user_id'], 1, $order['money'],'user_money'); + +// Db::commit(); +// return [ +// 'order_id' => (int)$order['id'], +// 'from' => 'order' +// ]; +// } catch (\Exception $e) { +// Db::rollback(); +// self::setError($e->getMessage()); +// return false; +// } +// } + +// } \ No newline at end of file diff --git a/app/api/logic/SmsLogic.php b/app/api/logic/SmsLogic.php new file mode 100644 index 0000000..1830853 --- /dev/null +++ b/app/api/logic/SmsLogic.php @@ -0,0 +1,185 @@ + $scene, + 'params' => [ + 'mobile' => $params['mobile'], + 'country_code' => $params['country_code'], + 'code' => mt_rand(100000, 999999), + ] + ]); + + return $result[0]; + + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + /** + * @notes 发送邮件 + * @param $params + * @return false|mixed + * @author BD + * @date 2024/9/21 17:29 + */ + public static function sendEmail($params) + { + try { + if(!filter_var($params['email'], FILTER_VALIDATE_EMAIL)){ + throw new \Exception('network.parameterAbnormality');//请输入正确的邮箱地址 + } + //判断发送频率 + $time = time() - 1*60;//1分钟发送一次 + + $count = EmailRecord::where(['user_id' => $params['user_id']])->where("create_time > $time")->count(); + if($count > 0) throw new \Exception('captcha.validTips');//验证码5分钟内有效,请勿重复发送 + $count = EmailRecord::where(['ip' => request()->ip()])->where("create_time > $time")->count(); + if($count > 0) throw new \Exception('captcha.validTips');//验证码5分钟内有效,请勿重复发送 + + $email = DecorateHint::findOrEmpty(18)->toArray(); + //多语言替换 + $data = UtilsService::get_langs_data($email['langs'],$params['lang']); + $code = mt_rand(100000, 999999); + $content = str_ireplace('{code}', $code, $data['content']); + + $result = UtilsService::send_mail($params['email'],$data['text'],$content); + if (!$result) { + throw new \Exception('network.sendFailed'); + } + + EmailRecord::create([ + 'user_id' => $params['user_id'], + 'email' => $params['email'], + 'subject' => $data['text'], + 'content' => $content, + 'code' => $code, + 'ip' => request()->ip(), + ]); + + return true; + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + /** + * @notes 发送邮件 + * @param $params + * @return false|mixed + * @author BD + * @date 2024/9/21 17:29 + */ + public static function sendEmailNoLogin($params) + { + try { + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + throw new \Exception('network.frequentOperation'); + //密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试 + } + + if(!filter_var($params['email'], FILTER_VALIDATE_EMAIL)){ + $userAccountSafeCache->record(); + throw new \Exception('network.parameterAbnormality');//请输入正确的邮箱地址 + } + //判断发送频率 + $time = time() - 1*60;//1分钟发送一次 + + $user = User::where(['mobile' => $params['mobile'],'country_code' => $params['country_code']])->findOrEmpty(); + if($user->isEmpty()) { + $userAccountSafeCache->record(); + throw new \Exception('login.userNoExist');//用户不存在 + } + + $userInfo = UserInfo::where(['user_id' => $user['id']])->findOrEmpty(); + if($userInfo->isEmpty()) { + throw new \Exception('network.parameterAbnormality'); + } + + if($userInfo['auth_email'] == 0){ + $userAccountSafeCache->record(); + throw new \Exception('pwd.emailNoExist');//该电子邮箱不存在 + } + if($userInfo['email'] != $params['email']){ + $userAccountSafeCache->record(); + throw new \Exception('auth.emailError');//请输入正确的邮箱地址 + } + + + $count = EmailRecord::where(['user_id' => $user['id']])->where("create_time > $time")->count(); + if($count > 0){ + throw new \Exception('captcha.validTips');//验证码5分钟内有效,请勿重复发送 + } + $count = EmailRecord::where(['ip' => request()->ip()])->where("create_time > $time")->count(); + if($count > 0){ + throw new \Exception('captcha.validTips');//验证码5分钟内有效,请勿重复发送 + } + + $email = DecorateHint::findOrEmpty(22)->toArray(); + //多语言替换 + $data = UtilsService::get_langs_data($email['langs'],$params['lang']); + $code = mt_rand(100000, 999999); + $content = str_ireplace('{code}', $code, $data['content']); + + $result = UtilsService::send_mail($params['email'],$data['text'],$content); + if (!$result) { + throw new \Exception('network.sendFailed'); + } + + EmailRecord::create([ + 'user_id' => $user['id'], + 'email' => $params['email'], + 'subject' => $data['text'], + 'content' => $content, + 'code' => $code, + 'ip' => request()->ip(), + ]); + + $userAccountSafeCache->relieve(); + + return true; + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + +} \ No newline at end of file diff --git a/app/api/logic/TeamLogic.php b/app/api/logic/TeamLogic.php new file mode 100644 index 0000000..a1f1fc8 --- /dev/null +++ b/app/api/logic/TeamLogic.php @@ -0,0 +1,137 @@ + $params['user_id']]) + ->field('id,sn,avatar,total_income') + ->findOrEmpty(); + + $user['teamNum'] = UserRelation::where(['parent_id' => $params['user_id']])->where("level <= $distributeLevel")->count(); + + $user['teamNewNum'] = UserRelation::where(['parent_id' => $params['user_id']])->where("level <= $distributeLevel")->where("create_time > $todayStart")->count(); + + $user['teamCom'] = UserFinance::where(['user_id' => $params['user_id']]) + ->where(" change_type IN (11) ") + ->sum('change_amount'); + + //分销---------------------------------------------------------- + foreach ($distributes as &$distribute) { + $level = $distribute['level']; + $distribute['num'] = UserRelation::where(['parent_id' => $params['user_id'],'level' => $level])->count(); + } + + return [ + 'user' => $user, + 'dis_list' => $distributes, + ]; + } + + /** + * @notes 首页数据2 + * @param $params + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public static function getIndexReport(array $params) + { + + $distributeLevel = UtilsService::get_distribute_level(); + //报表---------------------------------------------------------- + + $where = " 1 = 1 "; + $where2 = " 1 = 1 "; + //0全部1今天2近7天3近30天4近60天 + switch ($params['time_type']) { + case 1: + $time = strtotime(date('Y-m-d 00:00:00')); + $where = " create_time > $time "; + $where2 = " uf.create_time > $time "; + break; + case 2: + $time = strtotime("-7 days midnight"); + $where = " create_time > $time "; + $where2 = " uf.create_time > $time "; + break; + case 3: + $time = strtotime("-30 days midnight"); + $where = " create_time > $time "; + $where2 = " uf.create_time > $time "; + break; + case 4: + $time = strtotime("-60 days midnight"); + $where = " create_time > $time "; + $where2 = " uf.create_time > $time "; + break; + } + + //我 + + // //下级 + // $report_time['income'] = UserRelation::alias('ur') + // ->join('user_finance uf', 'uf.user_id = ur.user_id') + // ->where(['ur.parent_id' => $params['user_id']]) + // ->where(" ur.level <= $distributeLevel AND change_type IN (13) ") + // ->where($where2) + // ->sum('uf.change_amount'); + + // $report_time['income'] = $report_time['income'] + $income_my; + + $report_time['teamNum'] = UserRelation::where(['parent_id' => $params['user_id']])->where("level <= $distributeLevel")->where($where)->count(); + $report_time['tasks'] = UserFinance::where($where) + ->where(['user_id' => $params['user_id']]) + ->where(" change_type IN (15) ") + ->sum('change_amount'); + $report_time['invest'] = UserFinance::where($where) + ->where(['user_id' => $params['user_id']]) + ->where(" change_type IN (17) ") + ->sum('change_amount'); + $report_time['recom'] = UserFinance::where($where) + ->where(['user_id' => $params['user_id']]) + ->where(" change_type IN (11) ") + ->sum('change_amount'); + + $report_time['income'] = $report_time['invest'] +$report_time['tasks'] +$report_time['recom']; + + + return $report_time; + } + +} \ No newline at end of file diff --git a/app/api/logic/UserLogic.php b/app/api/logic/UserLogic.php new file mode 100644 index 0000000..9b1835c --- /dev/null +++ b/app/api/logic/UserLogic.php @@ -0,0 +1,1358 @@ +where(['is_show' => 1,'loca' => 2]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($navs as &$nav) { + //多语言替换 + $data = UtilsService::get_langs_data($nav['langs'],$params['lang']); + $data_name = ''; + + if(count($data) > 0){ + $data_name = $data['name']; + } + + $nav['name'] = $data_name; + if($nav['image_ext'] != ''){ + $nav['image'] = $nav['image_ext']; + } + + unset($nav['langs']); + } + + //菜单按钮 + $field3 = ['name','image','link','langs','image_ext']; + $navs2 = DecorateNav::field($field3) + ->where(['is_show' => 1,'loca' => 3]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($navs2 as &$nav2) { + //多语言替换 + $data = UtilsService::get_langs_data($nav2['langs'],$params['lang']); + $data_name = ''; + + if(count($data) > 0){ + $data_name = $data['name']; + } + $nav2['name'] = $data_name; + if($nav['image_ext'] != ''){ + $nav['image'] = $nav['image_ext']; + } + unset($nav2['langs']); + } + + + $user = User::where(['id' => $params['user_id']]) + ->append(['team_num']) + ->field('id,sn,account,mobile,avatar,user_money,user_point,total_income_invest as income,total_recharge,total_withdraw,country_code') + ->findOrEmpty(); + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id]) + ->field('id,name,logo') + ->findOrEmpty(); + $userMember['logo'] = FileService::getFileUrl($userMember['logo']); + + $user['member'] = $userMember; + + $unread_notice = UserNotice::where(['user_id' => $params['user_id']]) + ->where(['read' => 0]) + ->count(); + + return [ + 'navs' => $navs, + 'navs2' => $navs2, + 'user' => $user, + 'unreadNotice' => $unread_notice, + ]; + } + + /** + * @notes 分享 首页数据 + * @param array $params + * @return User|false + * @author BD + * @date 2023/9/21 16:53 + */ + public static function getShareIndexData(array $params) + { + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + $front_link = ConfigService::get('website', 'front_link'); + + $userRes['avatar'] = $user['avatar']; + $userRes['mobile'] = $user['mobile']; + $userRes['sn'] = $user['sn']; + $userRes['link'] = $front_link.'/pages/register/register?code='.$user['sn']; + $userRes['qrcode'] = UtilsService::get_qrcode($userRes['link']); + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id]) + ->field('name,logo') + ->findOrEmpty(); + $userMember['logo'] = FileService::getFileUrl($userMember['logo']); + + + return [ + 'user' => $userRes, + 'member' => $userMember, + ]; + } + + + /** + * @notes 个人信息 + * @param $params + * @return array + * @author BD + * @date 2023/9/20 19:45 + */ + public static function info($params) + { + $user = User::where(['id' => $params['user_id']]) + ->field('id,sn,account,real_name,avatar,mobile,password_pay,create_time,user_money') + ->findOrEmpty(); + $front_link = ConfigService::get('website', 'front_link'); + $user['link'] = $front_link.'/pages/register/register?code='.$user['sn']; + $user['qrcode'] = UtilsService::get_qrcode($user['link']); + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id]) + ->field('id,name,bg_img,logo,text_color,price') + ->findOrEmpty(); + $userMember['logo'] = FileService::getFileUrl($userMember['logo']); + + $user['member'] = $userMember; + + $user['version'] = config('project.version'); + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + $user['time'] = date($timeFormat, strtotime($user['create_time'])); + + $userInfo = UserInfo::where(['user_id' => $params['user_id']])->findOrEmpty(); + + if(!$userInfo['google_key']){ + $secretKey = UtilsService::get_google_secretKey(); + UserInfo::update([ + 'id' => $userInfo['id'], + 'google_key' => $secretKey, + 'google_qrcode' => UtilsService::get_google_qrcode($user['account'],'',$secretKey), + ]); + + $userInfo = UserInfo::where(['user_id' => $params['user_id']])->findOrEmpty(); + } + + if($userInfo['auth_google'] == 1){ + $userInfo['google_key'] = substr_replace($userInfo['google_key'], str_repeat('*', 8), 4, 8); + unset($userInfo['google_qrcode']); + } + + $user['info'] = $userInfo; + + + //查询初始交易密码 + $user['need_set_pwd'] = 0; + $pwd_pay = ConfigService::get('login', 'password_pay'); + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] == create_password($pwd_pay, $passwordSalt)) { + $user['need_set_pwd'] = 1; + } + + unset($user['id']); + unset($user['password_pay']); + unset($userInfo['id']); + unset($userInfo['user_id']); + + return $user->toArray(); + } + + + /** + * @notes 设置用户信息 + * @param int $userId + * @param array $params + * @return User|false + * @author BD + * @date 2023/9/21 16:53 + */ + public static function setInfo(int $userId, array $params) + { + try { + return User::update([ + 'id' => $userId, + $params['field'] => $params['value']] + ); + } catch (\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + /** + * @notes 重置登录密码 + * @param $params + * @return bool + * @author BD + * @date 2023/9/16 18:06 + */ + public static function resetPassword(array $params) + { + try { + // // 校验验证码 + // $smsDriver = new SmsDriver(); + // if (!$smsDriver->verify($params['mobile'], $params['code'], NoticeEnum::FIND_LOGIN_PASSWORD_CAPTCHA)) { + // throw new \Exception('123');//请输入正确的验证码 + // } + + // 重置密码 + $passwordSalt = Config::get('project.unique_identification'); + $password = create_password($params['password'], $passwordSalt); + + // 更新 + User::where('mobile', $params['mobile'])->update([ + 'password' => $password + ]); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 修改登录密码 + * @param $params + * @param $userId + * @return bool + * @author BD + * @date 2023/9/20 19:13 + */ + public static function changePassword(array $params, int $userId) + { + try { + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + return 'network.frequentOperation'; + } + + $user = User::findOrEmpty($userId); + if ($user->isEmpty()) { + throw new \Exception('pwd.userNoExist');//用户不存在 + } + + // 密码盐 + $passwordSalt = Config::get('project.unique_identification'); + + if (!empty($user['password'])) { + if (empty($params['old_password'])) { + $userAccountSafeCache->record(); + throw new \Exception('pwd.oldPwdEmpty');//请输入原密码 + } + $oldPassword = create_password($params['old_password'], $passwordSalt); + if ($oldPassword != $user['password']) { + $userAccountSafeCache->record(); + throw new \Exception('pwd.oldPwdError');//原密码不正确 + } + } + + // 保存密码 + $password = create_password($params['password'], $passwordSalt); + $user->password = $password; + $user->save(); + + $userAccountSafeCache->relieve(); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 修改支付密码 + * @param $params + * @param $userId + * @return bool + * @author BD + * @date 2023/9/20 19:13 + */ + public static function changePayPassword(array $params, int $userId) + { + try { + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + throw new \Exception('network.frequentOperation'); + } + + $user = User::findOrEmpty($userId); + if ($user->isEmpty()) { + throw new \Exception('pwd.userNoExist');//用户不存在 + } + + // 密码盐 + $passwordSalt = Config::get('project.unique_identification'); + + if (!empty($user['password_pay'])) { + if (empty($params['old_password_pay'])) { + $userAccountSafeCache->record(); + throw new \Exception('pwd.oldPwdEmpty');//请输入原密码 + } + $oldPassword = create_password($params['old_password_pay'], $passwordSalt); + if ($oldPassword != $user['password_pay']) { + $userAccountSafeCache->record(); + throw new \Exception('pwd.oldPwdError');//原密码不正确 + } + } + + // 保存密码 + $password = create_password($params['password_pay'], $passwordSalt); + $user->password_pay = $password; + $user->save(); + + $userAccountSafeCache->relieve(); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 修改支付密码 + * @param $params + * @param $userId + * @return bool + * @author BD + * @date 2023/9/20 19:13 + */ + public static function setPayPassword(array $params, int $userId) + { + try { + $user = User::findOrEmpty($userId); + if ($user->isEmpty()) { + throw new \Exception('pwd.userNoExist');//用户不存在 + } + + $pwd_pay = ConfigService::get('login', 'password_pay'); + // 密码盐 + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] !== create_password($pwd_pay, $passwordSalt)) { + throw new \Exception('network.parameterAbnormality');//已设置过不需要重复设置 + } + if ($params['password_pay'] == $pwd_pay) { + throw new \Exception('pwd.pwdSimpleTips');//密码过于简单,请重新设置 + } + + + // 保存密码 + $password = create_password($params['password_pay'], $passwordSalt); + $user->password_pay = $password; + $user->save(); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 绑定手机号 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function bindMobile(array $params) + { + try { + // 变更手机号场景 + $sceneId = NoticeEnum::CHANGE_MOBILE_CAPTCHA; + $where = [ + ['id', '=', $params['user_id']], + ['mobile', '=', $params['mobile']] + ]; + + // 绑定手机号场景 + if ($params['type'] == 'bind') { + $sceneId = NoticeEnum::BIND_MOBILE_CAPTCHA; + $where = [ + ['mobile', '=', $params['mobile']] + ]; + } + + // 校验短信 + $checkSmsCode = (new SmsDriver())->verify($params['mobile'], $params['code'], $sceneId); + if (!$checkSmsCode) { + throw new \Exception('captcha.captchaError');//请输入正确的验证码 + } + + $user = User::where($where)->findOrEmpty(); + if (!$user->isEmpty()) { + throw new \Exception('pwd.mobileExist');//该手机号已被使用 + } + + User::update([ + 'id' => $params['user_id'], + 'mobile' => $params['mobile'], + ]); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 获取用户消息 + * @param $params + * @return array + * @author BD + * @date 2023/9/20 19:45 + */ + public static function notice($params) + { + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + //系统消息 + $notice1 = [ + 'unread' => 0, + 'content' => '', + 'time' => '', + ]; + $notice1['unread'] = UserNotice::where(['user_id' => $params['user_id']]) + ->where(['read' => 0,'notice_type' => 3]) + ->count(); + $notice1_last = UserNotice::where(['user_id' => $params['user_id']]) + ->where(['notice_type' => 3]) + ->order(['read' => 'desc', 'id' => 'desc']) + ->findOrEmpty(); + if (!$notice1_last->isEmpty()) { + //多语言替换 + $data = UtilsService::get_langs_data($notice1_last['langs'],$params['lang']); + $data_text = ''; + + if(count($data) > 0){ + $data_text = $data['text']; + } + + $notice1['content'] = get_file_domain($data_text); + $notice1['time'] = date($timeFormat, strtotime($notice1_last['create_time'])); + } + + //任务消息 + $notice2 = [ + 'unread' => 0, + 'content' => '', + 'time' => '', + ]; + $notice2['unread'] = UserNotice::where(['user_id' => $params['user_id']]) + ->where(['read' => 0,'notice_type' => 2]) + ->count(); + $notice2_last = UserNotice::where(['user_id' => $params['user_id']]) + ->where(['notice_type' => 2]) + ->order(['read' => 'desc', 'id' => 'desc']) + ->findOrEmpty(); + if (!$notice2_last->isEmpty()) { + //多语言替换 + $data = UtilsService::get_langs_data($notice2_last['langs'],$params['lang']); + $data_text = ''; + + if(count($data) > 0){ + $data_text = $data['text']; + } + $notice2['content'] = get_file_domain($data_text); + $notice2['time'] = date($timeFormat, strtotime($notice2_last['create_time'])); + } + + //站内信 + $notice3 = [ + 'unread' => 0, + 'content' => '', + 'time' => '', + ]; + $notice3['unread'] = UserNotice::where(['user_id' => $params['user_id']]) + ->where(['read' => 0,'notice_type' => 1]) + ->count(); + $notice3_last = UserNotice::where(['user_id' => $params['user_id']]) + ->where(['notice_type' => 1]) + ->order(['read' => 'desc', 'id' => 'desc']) + ->findOrEmpty(); + if (!$notice3_last->isEmpty()) { + //多语言替换 + $data = UtilsService::get_langs_data($notice3_last['langs'],$params['lang']); + $data_text = ''; + + if(count($data) > 0){ + $data_text = $data['text']; + } + $notice3['content'] = get_file_domain($data_text); + $notice3['time'] = date($timeFormat, strtotime($notice3_last['create_time'])); + } + + return [ + 'notice1' => $notice1, + 'notice2' => $notice2, + 'notice3' => $notice3, + ]; + } + + /** + * @notes 用户消息详情 + * @param $params + * @return array + * @author BD + * @date 2023/9/20 17:09 + */ + public static function noticeDetail($params) + { + $notice = UserNotice::field('id,title,content,read,langs,create_time')->where(['user_id' => $params['user_id'],'id' => $params['id']])->findOrEmpty(); + if ($notice->isEmpty()) { + throw new \Exception('network.parameterAbnormality'); + } + + //查询语言 + $timeFormat = 'Y-m-d H:i:s'; + $language = Language::where(['symbol' => $params['lang']])->findOrEmpty(); + if (!$language->isEmpty()) { + $timeFormat = $language['time_format']; + } + + $notice['time'] = date($timeFormat, strtotime($notice['create_time'])); + //多语言替换 + $data = UtilsService::get_langs_data($notice['langs'],$params['lang']); + $data_content = ''; + $data_title = ''; + + if(count($data) > 0){ + $data_content = $data['content']; + $data_title = $data['title']; + } + $notice['content'] = get_file_domain($data_content); + $notice['title'] = get_file_domain($data_title); + unset($notice['langs']); + unset($notice['create_time']); + + if($notice['read'] == 0){ + UserNotice::update([ + 'id' => $notice['id'], + 'read' => 1 + ] + ); + } + + return ['data' => $notice]; + } + + /** + * @notes 奖励活动数据 + * @param $params + * @return array + * @author BD + * @date 2023/9/20 17:09 + */ + public static function activityIndex($params) + { + $reward = ConfigService::get('website', 'reward'); + $activities = $reward['activity']; + foreach ($activities as $key => $activity) { + if($activities[$key]['is_show'] == 0){ + unset($activities[$key]); + } + } + + foreach ($activities as &$activity) { + $activity['count'] = UserRewardRecord::where(['user_id' => $params['user_id'],'top_id' => $activity['id']])->count(); + } + $time = strtotime(date('Y-m-d 00:00:00')); + + $report['today_income'] = UserFinance::where("create_time > $time") + ->where(['user_id' => $params['user_id']]) + ->where(" change_type IN (14) ") + ->sum('change_amount'); + + $report['total_income'] = UserFinance::where(['user_id' => $params['user_id']]) + ->where(" change_type IN (14) ") + ->sum('change_amount'); + + return [ + 'activities' => $activities, + 'report' => $report + ]; + } + + /** + * @notes 任务中心数据 + * @param $params + * @return array + * @author BD + * @date 2023/9/20 17:09 + */ + public static function missionIndex($params) + { + //更新任务领取记录 + UtilsService::mission_reward_add($params['user_id']); + + $reward = ConfigService::get('website', 'reward'); + $list = $reward['tasks']; + foreach ($list as $key => $item) { + if($list[$key]['is_show'] == 0){ + unset($list[$key]); + } + } + foreach ($list as &$item) { + $item['record_id'] = 0; + $item['status'] = 1;//0待领取1进行中2已完成 + $rewardRecord = UserRewardRecord::where(['user_id' => $params['user_id'],'top_id' => $item['id'],'type' => 2])->order(['id' => 'asc'])->findOrEmpty(); + + //type 1升级VIP 2邀请下级首充 3累积邀请 + switch ($item['type']) { + case 1: + $member = UserMember::where(['id' => $item['member_id']])->findOrEmpty(); + $item['vip_name'] = $member['name']; + + if(!$rewardRecord->isEmpty()) { + $item['record_id'] = $rewardRecord['id']; + //领取状态1已领取0未领取 + switch ($rewardRecord['status']) { + case 0: + $item['status'] = 0; + + break; + case 1: + $item['status'] = 2; + break; + } + + } + break; + case 2: + + $rewardRecordIng = UserRewardRecord::where(['user_id' => $params['user_id'],'top_id' => $item['id'],'type' => 2,'status' => 0])->order(['id' => 'asc'])->findOrEmpty(); + if(!$rewardRecordIng->isEmpty()) { + $item['record_id'] = $rewardRecordIng['id']; + $item['status'] = 0; + } + break; + case 3: + //判断下级人数 + $recharge_money = $item['recharge_money']; + + $item['total_invite_num'] = UserRelation::alias('ur') + ->join('user u', 'u.id = ur.user_id') + ->where(['ur.parent_id' => $params['user_id'],'ur.level' => 1]) + ->where("u.total_recharge >= $recharge_money") + ->count(); + + $item['percent'] = ($item['total_invite_num'] / $item['invite_num']) * 100; + if($item['percent'] >= 100){ + $item['percent'] = 100; + } + //is_repeat 1可重复领取0不可重复 + if($item['is_repeat'] == 0){ + if(!$rewardRecord->isEmpty()) { + $item['record_id'] = $rewardRecord['id']; + //领取状态1已领取0未领取 + switch ($rewardRecord['status']) { + case 0: + $item['status'] = 0; + + break; + case 1: + $item['status'] = 2; + break; + } + } + + }else{ + + $rewardRecordIng = UserRewardRecord::where(['user_id' => $params['user_id'],'top_id' => $item['id'],'type' => 2,'status' => 0])->order(['id' => 'asc'])->findOrEmpty(); + if(!$rewardRecordIng->isEmpty()) { + $item['record_id'] = $rewardRecordIng['id']; + $item['percent'] = 100; + $item['status'] = 0; + }else{ + + //计算进度 + $count = UserRewardRecord::where(['user_id' => $params['user_id'],'top_id' => $item['id'],'type' => 2])->count(); + $used_invite_num = $count * $item['invite_num']; + + $item['percent'] = (($item['total_invite_num'] - $used_invite_num) / $item['invite_num']) * 100; + } + } + break; + } + + } + + return [ + 'list' => $list + ]; + } + + /** + * @notes 领取任务奖励 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function missionReward(array $params) + { + Db::startTrans(); + try { + $rewardRecord = UserRewardRecord::where(['id' => $params['id'],'user_id' => $params['user_id'],'status' => 0])->findOrEmpty(); + if($rewardRecord->isEmpty()) { + throw new \Exception('network.parameterAbnormality'); + } + UserRewardRecord::update([ + 'id' => $rewardRecord['id'], + 'status' => 1 + ] + ); + + //记录日志 + UtilsService::user_finance_add( + $params['user_id'], + 15, + 1, + $rewardRecord['reward'], + '', + '', + 1 //冻结 + ); + + //用户资金修改 + UtilsService::user_money_change($params['user_id'], 1, $rewardRecord['reward'],'user_money'); + + UtilsService::user_money_change($params['user_id'], 1, $rewardRecord['reward'],'total_income_tasks'); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 任务中心数据 + * @param $params + * @return array + * @author BD + * @date 2023/9/20 17:09 + */ + public static function feedbackCate($params) + { + $field = ['id','name','langs']; + $cates = FeedbackCate::field($field) + ->where(['is_show' => 1]) + ->order(['sort' => 'desc', 'id' => 'desc']) + ->select() + ->toArray(); + foreach ($cates as &$cate) { + //多语言替换 + $data = UtilsService::get_langs_data($cate['langs'],$params['lang']); + $data_name = ''; + + if(count($data) > 0){ + $data_name = $data['name']; + } + $cate['name'] = $data_name; + unset($cate['langs']); + } + + return [ + 'cates' => $cates + ]; + } + + /** + * @notes 意见反馈 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function feedback(array $params) + { + Db::startTrans(); + try { + $cate = FeedbackCate::where(['id' => $params['cid']])->findOrEmpty(); + if($cate->isEmpty()) { + throw new \Exception('network.parameterAbnormality'); + } + $content = $params['content']; + if(strlen($content) < 1 || strlen($content) > 1024){ + throw new \Exception('network.parameterAbnormality'); + } + + FeedbackRecord::create([ + 'user_id' => $params['user_id'], + 'cid' => $params['cid'], + 'content' => $content + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes Google Authenticator校验 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function verifyGoogle(array $params) + { + try { + $userInfo = UserInfo::where(['user_id' => $params['user_id']])->findOrEmpty(); + if($userInfo->isEmpty()) { + throw new \Exception('network.parameterAbnormality'); + } + if($userInfo['auth_google'] != 0) { + throw new \Exception('network.parameterAbnormality'); + } + + $valid = UtilsService::get_google_verify($userInfo['google_key'],$params['code']); + if(!$valid) { + throw new \Exception('captcha.captchaError');//验证码错误 + } + + UserInfo::update([ + 'id' => $userInfo['id'], + 'auth_google' => 1 + ]); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 邮箱校验 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function verifyEmail(array $params) + { + try { + $userInfo = UserInfo::where(['user_id' => $params['user_id']])->findOrEmpty(); + if($userInfo->isEmpty()) { + throw new \Exception('network.parameterAbnormality'); + } + if($userInfo['auth_email'] != 0) { + throw new \Exception('network.parameterAbnormality'); + } + if(!filter_var($params['email'], FILTER_VALIDATE_EMAIL)){ + throw new \Exception('auth.emailError');//请输入正确的邮箱地址 + } + + $time = time() - 5*60;//5分钟内有效 + + $email = EmailRecord::where(['user_id' => $params['user_id'],'is_verify' => 0])->where("create_time > $time")->order('id desc')->findOrEmpty(); + + if($email->isEmpty()) { + throw new \Exception('captcha.captchaError');//验证码错误 + } + if($email['code'] != $params['code']) { + throw new \Exception('captcha.captchaError');//验证码错误 + } + + //判断是否绑定过 + $info_t = UserInfo::where(['email' => $params['email']])->findOrEmpty(); + if(!$info_t->isEmpty()) { + throw new \Exception('auth.emailExisted');//该电子邮箱地址已存在 + } + + UserInfo::update([ + 'id' => $userInfo['id'], + 'email' => $params['email'], + 'auth_email' => 1 + ]); + + EmailRecord::update([ + 'id' => $email['id'], + 'is_verify' => 1 + ]); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 实名认证 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function verifyRealname(array $params) + { + try { + $userInfo = UserInfo::where(['user_id' => $params['user_id']])->findOrEmpty(); + UserInfo::update([ + 'id' => $userInfo['id'], + 'card_name' => $params['card_name'], + 'card_num' => $params['card_num'], + 'card_img1' => $params['card_img1'], + 'card_img2' => $params['card_img2'], + 'card_img3' => $params['card_img3'], + 'auth_card' => 2, + 'card_time' => time() + ]); + + return true; + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 签到配置 + * @param $params + * @return array + * @author BD + * @date 2024/02/22 10:54 + */ + public static function signinConfig(array $params) + { + $format = 'Y-m-d'; + $time = time(); + //获取当前周几 + $week = date('d', $time); + $datesArr = []; + + for ($i=1; $i<=date('t'); $i++){ + $date = date($format ,strtotime( '+' . $i-$week .' days', $time)); + + $datesArr[$i-1]['day'] = date('d', strtotime($date)); + + $datesArr[$i-1]['signined'] = false; + + //查询当日是否签到 + // 获取指定日期的0点时间戳 + $startTime = strtotime($date); + $endTime = strtotime($date . " +1 day"); + + $now = time(); + if($now > $startTime){ + $record = UserSigninRecord::where(['user_id' => $params['user_id']])->where(" create_time >= $startTime AND create_time < $endTime ")->findOrEmpty(); + if(!$record->isEmpty()) { + $datesArr[$i-1]['signined'] = true; + } + } + } + + //判断是否签到 + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id])->findOrEmpty(); + + $signined = false; + $todayStart = strtotime("today midnight"); + $sign_count = UserSigninRecord::where(['user_id' => $params['user_id']])->where("create_time > $todayStart")->count(); + if($sign_count > 0) { + $signined = true; + } + + $totalReward = UserSigninRecord::where(['user_id' => $params['user_id']])->sum('reward'); + + + return [ + 'datesArr' => $datesArr, + 'signined' => $signined, + 'totalReward' => $totalReward, + ]; + } + + /** + * @notes 签到 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function signin(array $params) + { + Db::startTrans(); + try { + $config = ConfigService::get('website', 'reward'); + + $record = UserSigninRecord::create([ + 'sn' => generate_sn(UserSigninRecord::class, 'sn'), + 'user_id' => $params['user_id'], + 'reward' => $config['signin_money'], + 'point' => $config['signin_point'], + ]); + + if($config['signin_money'] > 0){ + //记录日志 + UtilsService::user_finance_add( + $record['user_id'], + 21, + 1, + $record['reward'], + $record['sn'], + '', + 1//冻结 + ); + + //用户资金修改 + UtilsService::user_money_change($record['user_id'], 1, $record['reward'],'user_money'); + } + + //赠送积分 + if($config['signin_point'] > 0){ + UtilsService::user_money_change($record['user_id'], 1, $record['point'],'user_point'); + } + + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 挖矿 首页数据 + * @param $params + * @return array + * @author BD + * @date 2024/02/22 10:54 + */ + public static function getMineIndexData(array $params) + { + Db::startTrans(); + try { + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + + $userRes['avatar'] = $user['avatar']; + $userRes['mobile'] = $user['mobile']; + $userRes['sn'] = $user['sn']; + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id]) + ->field('name,logo,mine_speed') + ->findOrEmpty(); + + $userRes['member_id'] = $member_id; + $userRes['member_name'] = $userMember['name']; + + $userRes['member_logo'] = FileService::getFileUrl($userMember['logo']); + $userRes['total_invest'] = ItemRecord::where(['user_id' => $params['user_id']])->sum('money'); + $userRes['invite_count'] = UserRelation::where(['parent_id' => $params['user_id'],'level' => 1])->count(); + $userRes['is_recive'] = false; + + $field = 'id, name as text, logo, bg_img as image, text_color, money, level1_num,level1_vip_id, item_num, item_add_rate,mine_speed'; + $members = UserMember::field($field) + ->append(['vip_name']) + ->where(['is_show' => 1]) + ->order(['money' => 'asc', 'id' => 'desc']) + ->select() + ->toArray(); + + $config = ConfigService::get('website', 'mine'); + $precision = 6; + + $config['precision2'] = $precision; + $config['endTime'] = 0; + $config['nowNum'] = 0; + $config['maxNum'] = number_format($config['cycle'] * $userMember['mine_speed'], $precision, '.', ''); + $config['status'] = $user['mine_status'];//矿机状态0已暂停1挖矿中2待领取 + $config['mine_speed_sec'] = $userMember['mine_speed']/3600; + $config['percent'] = 0; + + //矿机状态0已暂停1挖矿中2待领取 + switch($config['status']){ + case 0: + if($config['is_auto']){ + $startTime = time(); + + $config['endTime'] = ($config['cycle'] * 60 * 60) * 1000; + $config['nowNum'] = 0; + $config['status'] = 1; + + User::update([ + 'id' => $user['id'], + 'mine_status' => 1, + 'mine_start_time' => $startTime, + ]); + } + + break; + case 1: + $startTime = $user['mine_start_time']; + $cycleTime = $config['cycle'] * 60 * 60; + + $startingTime = time() - $startTime; + //启动时间达标 + if($startingTime - $cycleTime >= 0){ + //是否超时未领取 + $outTime = $config['valid_days'] * 24 * 60 * 60; + if($startingTime - $outTime >= 0){ + User::update([ + 'id' => $user['id'], + 'mine_status' => 0 + ]); + }else{ + $config['nowNum'] = number_format($config['cycle'] * $userMember['mine_speed'], $precision, '.', ''); + $config['status'] = 2; + $config['percent'] = 100; + + User::update([ + 'id' => $user['id'], + 'mine_status' => 2 + ]); + } + }else{ + $config['endTime'] = ($cycleTime - $startingTime) * 1000; + $config['nowNum'] = number_format($startingTime * $userMember['mine_speed'] / (60 * 60), $precision, '.', '');; + $config['status'] = 1; + $config['percent'] = round($startingTime/$cycleTime * 100,2); + + $config['$startingTime'] = $startingTime; + $config['$cycleTime'] = $cycleTime; + } + + break; + case 2: + //是否超时未领取 + $startTime = $user['mine_start_time']; + $startingTime = time() - $startTime; + $outTime = $config['valid_days'] * 24 * 60 * 60; + if($startingTime - $outTime >= 0){ + User::update([ + 'id' => $user['id'], + 'mine_status' => 0 + ]); + }else{ + $config['nowNum'] = $config['maxNum']; + $config['status'] = 2; + $config['percent'] = 100; + } + + break; + } + + $userRes['mine_speed'] = $userMember['mine_speed'].' '.$config['symbol'].' / H'; + foreach ($members as &$member) { + $member['mine_speed'] = $member['mine_speed'].' '.$config['symbol'].' / H'; + } + + Db::commit(); + return [ + 'config' => $config, + 'user' => $userRes, + 'members' => $members, + ]; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 矿机 启动 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function mineStart(array $params) + { + Db::startTrans(); + try { + User::update([ + 'id' => $params['user_id'], + 'mine_status' => 1, + 'mine_start_time' => time(), + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + /** + * @notes 矿机 收益 + * @param $params + * @return bool + * @author BD + * @date 2023/9/21 17:28 + */ + public static function mineReceive(array $params) + { + Db::startTrans(); + try { + $user = User::where(['id' => $params['user_id']])->findOrEmpty(); + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::where(['id' => $member_id])->findOrEmpty(); + + $config = ConfigService::get('website', 'mine'); + + $amount_act = number_format($config['cycle'] * $userMember['mine_speed'], $config['precision'], '.', ''); + + $amount = round($amount_act / $config['rate'] , 2); + + $record = UserMineRecord::create([ + 'sn' => generate_sn(UserMineRecord::class, 'sn'), + 'user_id' => $params['user_id'], + 'amount' => $amount, + 'amount_act' => $amount_act, + 'name' => $config['name'], + 'symbol' => $config['symbol'], + 'rate' => $config['rate'], + 'precision' => $config['precision'], + 'cycle' => $config['cycle'], + 'start_time' => $user['mine_start_time'], + ]); + + if($amount > 0.01){ + //记录日志 + UtilsService::user_finance_add( + $record['user_id'], + 24, + 1, + $record['amount'], + $record['sn'], + '', + 1//冻结 + ); + + //用户资金修改 + UtilsService::user_money_change($record['user_id'], 1, $record['amount'],'user_money'); + //累积挖矿金额增加 + UtilsService::user_money_change($record['user_id'], 1, $record['amount'],'total_income_mine'); + } + + User::update([ + 'id' => $params['user_id'], + 'mine_status' => 0 + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } +} \ No newline at end of file diff --git a/app/api/logic/UserMemberLogic.php b/app/api/logic/UserMemberLogic.php new file mode 100644 index 0000000..76763a7 --- /dev/null +++ b/app/api/logic/UserMemberLogic.php @@ -0,0 +1,137 @@ + $params['user_id']])->sum('money'); + + $user['invite_count'] = UserRelation::where(['parent_id' => $params['user_id'],'level' => 1])->count(); + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($params['user_id']); + $userMember = UserMember::field('id,name') + ->where(['id' => $member_id]) + ->where(['is_show' => 1]) + ->findOrEmpty(); + + return [ + 'user' => $user, + 'member' => $userMember, + ]; + } + /** + * @notes 会员列表 + * @param $params + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public static function getAllData(array $params) + { + $field = ['id, name as text, logo, bg_img as image, text_color, money, level1_num,level1_vip_id, item_num, item_add_rate,mine_speed']; + $members = UserMember::field($field) + ->append(['vip_name']) + ->where(['is_show' => 1]) + ->order(['money' => 'asc', 'id' => 'desc']) + ->select() + ->toArray(); + + $config_mine = ConfigService::get('website', 'mine'); + foreach ($members as &$member) { + $member['mine_speed'] = $member['mine_speed'].' '.$config_mine['symbol'].' / H'; + } + + return $members; + } + + /** + * @notes 加入会员 + * @param $params + * @return array|false + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author BD + * @date 2024/02/22 10:54 + */ + public static function join(array $params) + { + Db::startTrans(); + try { + //判断会员等级是否存在 + $member = UserMember::where(['id' => $params['id']])->findOrEmpty(); + + $data = [ + 'user_id' => $params['user_id'], + 'member_id' => $member['id'], + ]; + + $record = UserMemberRecord::create($data); + + //记录日志 + UtilsService::user_finance_add( + $data['user_id'], + 10, + 2, + $member['price'], + '' + ); + + //用户资金修改 + UtilsService::user_money_change($data['user_id'], 2, $member['price'],'user_money'); + + Db::commit(); + return [ + 'order_id' => $record['id'], + ]; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + +} \ No newline at end of file diff --git a/app/api/service/UserTokenService.php b/app/api/service/UserTokenService.php new file mode 100644 index 0000000..1e736a2 --- /dev/null +++ b/app/api/service/UserTokenService.php @@ -0,0 +1,132 @@ +find(); + + //获取token延长过期的时间 + $expireTime = $time + Config::get('project.user_token.expire_duration'); + $userTokenCache = new UserTokenCache(); + + $multipointLogin = ConfigService::get('login', 'multipoint_login'); + + //token处理 + if ($userSession) { + if ($userSession->expire_time < $time || $multipointLogin === 0) { + //清空缓存 + $userTokenCache->deleteUserInfo($userSession->token); + //如果token过期或账号设置不支持多处登录,更新token + $userSession->token = create_token($userId); + } + $userSession->expire_time = $expireTime; + $userSession->update_time = $time; + $userSession->save(); + } else { + //找不到在该终端的token记录,创建token记录 + $userSession = UserSession::create([ + 'user_id' => $userId, + 'terminal' => $terminal, + 'token' => create_token($userId), + 'expire_time' => $expireTime + ]); + } + + return $userTokenCache->setUserInfo($userSession->token); + } + + + /** + * @notes 延长token过期时间 + * @param $token + * @return array|false|mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/16 10:10 + */ + public static function overtimeToken($token) + { + $time = time(); + $userSession = UserSession::where('token', '=', $token)->findOrEmpty(); + if ($userSession->isEmpty()) { + return false; + } + //延长token过期时间 + $userSession->expire_time = $time + Config::get('project.user_token.expire_duration'); + $userSession->update_time = $time; + $userSession->save(); + + return (new UserTokenCache())->setUserInfo($userSession->token); + } + + + /** + * @notes 设置token为过期 + * @param $token + * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 段誉 + * @date 2022/9/16 10:10 + */ + public static function expireToken($token) + { + $userSession = UserSession::where('token', '=', $token) + ->findOrEmpty(); + if (empty($userSession)) { + return false; + } + + $multipointLogin = ConfigService::get('login', 'multipoint_login'); + + //当支持多处登录的时候,服务端不注销 + if ($multipointLogin === 1) { + return false; + } + + $time = time(); + $userSession->expire_time = $time; + $userSession->update_time = $time; + $userSession->save(); + + return (new UserTokenCache())->deleteUserInfo($token); + } + +} \ No newline at end of file diff --git a/app/api/validate/FinanceValidate.php b/app/api/validate/FinanceValidate.php new file mode 100644 index 0000000..892ffd1 --- /dev/null +++ b/app/api/validate/FinanceValidate.php @@ -0,0 +1,298 @@ + 'require|checkWalletAdd', + 'money' => 'require|gt:0|checkWithdraw', + 'transfer' => 'checkTransfer', + ]; + + + protected $message = [ + 'account.require' => 'network.parameterAbnormality', + 'money.require' => 'network.parameterAbnormality',//请输入金额 + 'money.gt' => 'network.parameterAbnormality',//请输入正确的金额 + ]; + + + public function sceneWalletAdd() + { + return $this->only(['account']); + } + + public function sceneWithdraw() + { + return $this->only(['money']); + } + + public function sceneTransfer() + { + return $this->only(['transfer']); + } + + /** + * @notes 校验绑定钱包 + * @param $money + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2023/2/24 10:42 + */ + protected function checkWalletAdd($money, $rule, $data) + { + + $bindTips = '';//已绑定提示语 + + //查询语言 + $language = Language::where(['symbol' => $data['lang']])->findOrEmpty(); + if ($language->isEmpty()) { + throw new \Exception('network.parameterAbnormality');//参数异常 + } + + //判断提现方式 + $method = WithdrawMethod::where(['id' => $data['method_id']])->findOrEmpty(); + if ($method->isEmpty()) { + return 'network.parameterAbnormality';//参数异常 + } + if ($method['type'] != $data['type']) { + return 'network.parameterAbnormality';//参数异常 + } + + //判断钱包是否绑定 + $userWallet = WithdrawWallet::where(['method_id' => $data['method_id'] ,'user_id' => $data['user_id'] ])->findOrEmpty(); + if (!$userWallet->isEmpty()) { + return 'network.parameterAbnormality';//该钱包已绑定,请勿重复绑定 + } + + //类型1USDT2扫码3银行卡 + switch ($data['type']){ + case 1: + //USDT方式:account、img + if (!isset($data['account']) || strlen($data['account']) < 8 || strlen($data['account']) > 128) { + return 'network.parameterAbnormality'; + } + if($method['is_qrcode']){ + if (!isset($data['img']) || strlen($data['account']) < 8 || strlen($data['account']) > 128 + || strlen($data['img']) < 8 || strlen($data['img']) > 128) { + return 'network.parameterAbnormality'; + } + } + $bindTips = 'withdraw.addressExist';//该地址已使用 + break; + case 2: + //扫码方式:account、img + if (!isset($data['account']) || !isset($data['img'])) { + return 'network.parameterAbnormality'; + } + if (strlen($data['account']) < 6 || strlen($data['account']) > 30 + || strlen($data['img']) < 6 || strlen($data['img']) > 128) { + return 'network.parameterAbnormality'; + } + + $bindTips = 'withdraw.qrcodeAccountExist';//该账号已使用 + break; + case 3: + //银行卡方式:name、account、bank_id + if (!isset($data['account']) || !isset($data['name']) || !isset($data['bank_id'])) { + return 'network.parameterAbnormality'; + } + if (strlen($data['account']) < 6 || strlen($data['account']) > 30 + || strlen($data['name']) < 2 || strlen($data['name']) > 30) { + return 'network.parameterAbnormality'; + } + + $bank = WithdrawBank::where(['id' => $data['bank_id']])->findOrEmpty(); + if ($bank->isEmpty()) { + return 'network.parameterAbnormality';//提现银行不存在 + } + + $bindTips = 'withdraw.bankAccountExist';//该卡号已使用 + break; + default: + $bindTips = 'network.parameterAbnormality';//不支持的类型 + break; + } + + //判断账号是否绑定 + $wallet = WithdrawWallet::where(['account' => $data['account']])->findOrEmpty(); + + if (!$wallet->isEmpty()) { + return $bindTips;//该账号已使用 + } + + return true; + } + + /** + * @notes 校验提现 + * @param $money + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2023/2/24 10:42 + */ + protected function checkWithdraw($money, $rule, $data) + { + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + return 'network.frequentOperation'; + //密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试 + } + + //判断提现方式 + $method = WithdrawMethod::where(['id' => $data['method_id']])->findOrEmpty(); + if ($method->isEmpty()) { + return 'network.parameterAbnormality';//提现方式不存在 + } + + //判断提现金额 + $config = ConfigService::get('website', 'trade'); + $withdraw_min = $config['withdraw_min']; + $withdraw_max = $config['withdraw_max']; + + if($data['money'] < $withdraw_min || $data['money'] > $withdraw_max ) return 'network.parameterAbnormality';//请输入正确的金额 + + //判断余额 + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + + $used_money = UtilsService::get_used_money($data['user_id']); + if($data['money'] - $used_money > 0) return 'network.parameterAbnormality';//余额不足 + + //判断提现次数(每天可提现n次) + $todayStart = strtotime("today midnight"); + $withdraw_num = WithdrawRecord::where(['user_id' => $data['user_id']]) + ->where('status in (0,1)') + ->where("create_time > $todayStart") + ->count(); + if($config['withdraw_num'] <= $withdraw_num){ + return 'network.parameterAbnormality';//每日提现次数限制 + } + + //交易密码 + if (empty($data['pay_pwd'])) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入密码 + } + if (strlen($data['pay_pwd']) != 6) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入正确的密码 + } + + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) { + $userAccountSafeCache->record(); + return 'common.payPwdError';//密码错误 + } + + + $userAccountSafeCache->relieve(); + + return true; + } + + /** + * @notes 校验转账 + * @param $money + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2023/2/24 10:42 + */ + protected function checkTransfer($transfer, $rule, $data) + { + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + return 'network.frequentOperation'; + //密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试 + } + + + //判断转账金额 + $config = ConfigService::get('website', 'trade'); + $transfer_min = $config['transfer_min']; + $transfer_max = $config['transfer_max']; + + if($data['money'] < $transfer_min || $data['money'] > $transfer_max ) return 'network.parameterAbnormality';//请输入正确的金额 + + //判断余额 + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + + $used_money = UtilsService::get_used_money($data['user_id']); + if($data['money'] - $used_money > 0) return 'network.parameterAbnormality';//余额不足 + + //判断是否开启转账 + if($user['is_transfer'] != 1) return 'transfer.transferDisableTips'; + + //判断是否自己 + if($data['account'] == $user['account']) return 'transfer.limitMyself';//禁止给自己转账 + + //判断用户是否存在 + $transferUser = User::where(['account' => $data['account']])->findOrEmpty(); + if ($transferUser->isEmpty()){ + $userAccountSafeCache->record(); + return 'transfer.accountNoExist';//用户不存在 + } + + //交易密码 + if (empty($data['pay_pwd'])) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入密码 + } + if (strlen($data['pay_pwd']) != 6) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入正确的密码 + } + + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) { + $userAccountSafeCache->record(); + return 'common.payPwdError';//密码错误 + } + + $userAccountSafeCache->relieve(); + + return true; + } + +} \ No newline at end of file diff --git a/app/api/validate/ItemValidate.php b/app/api/validate/ItemValidate.php new file mode 100644 index 0000000..c2f48be --- /dev/null +++ b/app/api/validate/ItemValidate.php @@ -0,0 +1,115 @@ + 'checkInvest', + ]; + + + public function sceneInvest() + { + return $this->only(['invest','id','money']); + } + + /** + * @notes 校验投资 + * @param $invest + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/02/22 10:54 + */ + protected function checkInvest($invest, $rule, $data) + { + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + return 'network.frequentOperation'; + //密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试 + } + + // 获取今天0点的时间戳 + $todayStart = strtotime(date('Y-m-d 00:00:00')); + + //判断项目 + $item = Item::where(['is_show' => 1])->findOrEmpty($data['id']); + if($item->isEmpty()){ + return 'network.parameterAbnormality'; + } + + //判断投资金额 + if($data['money'] < $item['min_money'] || $data['money'] > $item['max_money']) return 'network.parameterAbnormality'; + + //判断余额 + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + if($data['money'] - $user['user_money'] > 0) return 'common.InsufficientBalance';//余额不足 + + //限制等级 + //查询会员等级 + $member_id = UtilsService::get_user_member_id($data['user_id']); + $userMember = UserMember::where(['id' => $member_id])->findOrEmpty(); + if($item['member_id'] - $member_id > 0) return 'network.parameterAbnormality';//会员等级限制 + //判断今日投资次数 + //今日量化次数 + $today_order = ItemRecord::where("create_time > $todayStart")->where(['user_id' => $data['user_id']])->count(); + if ($today_order >= $userMember['item_num']) { + return 'network.parameterAbnormality'; + } + + //投资进度 + if($item['progress'] >= 100) return 'network.parameterAbnormality';//进度已满 + + //交易密码 + if (empty($data['pay_pwd'])) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入密码 + } + if (strlen($data['pay_pwd']) != 6) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入正确的密码 + } + + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) { + $userAccountSafeCache->record(); + return 'common.payPwdError';//密码错误 + } + + $userAccountSafeCache->relieve(); + + return true; + } + +} \ No newline at end of file diff --git a/app/api/validate/LanguagePagValidate.php b/app/api/validate/LanguagePagValidate.php new file mode 100644 index 0000000..9406182 --- /dev/null +++ b/app/api/validate/LanguagePagValidate.php @@ -0,0 +1,57 @@ + 'require' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'lang' => 'network.parameterAbnormality', + ]; + + /** + * @notes 详情场景 + * @return LanguagePagValidate + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public function sceneAll() + { + return $this->only(['lang']); + } + +} \ No newline at end of file diff --git a/app/api/validate/LanguageValidate.php b/app/api/validate/LanguageValidate.php new file mode 100644 index 0000000..6ca3cca --- /dev/null +++ b/app/api/validate/LanguageValidate.php @@ -0,0 +1,56 @@ + 'require' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'name' => 'network.parameterAbnormality',//参数异常 + ]; + + /** + * @notes 详情场景 + * @return LanguageValidate + * @author likeadmin + * @date 2023/11/30 13:59 + */ + public function sceneDetail() + { + return $this->only(['name']); + } + +} \ No newline at end of file diff --git a/app/api/validate/LoginAccountValidate.php b/app/api/validate/LoginAccountValidate.php new file mode 100644 index 0000000..9e2ff92 --- /dev/null +++ b/app/api/validate/LoginAccountValidate.php @@ -0,0 +1,108 @@ + 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ',' + . UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS . + ',' . UserTerminalEnum::ANDROID, + 'account' => 'require', + 'password' => 'require|checkPassword', + ]; + + + protected $message = [ + 'terminal.require' => 'network.parameterAbnormality',//终端参数缺失 + 'terminal.in' => 'network.parameterAbnormality',//终端参数状态值不正确 + 'account.require' => 'network.parameterAbnormality',//请输入账号 + 'password.require' => 'network.parameterAbnormality',//请输入密码 + ]; + + + /** + * @notes 登录密码校验 + * @param $password + * @param $other + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/9/15 14:39 + */ + public function checkPassword($password, $other, $data) + { + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + return 'network.pwdErrorLimit'; + //密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试 + } + + $where = []; + + $login_way = $data['login_way'];//0邮箱1手机号 + if($login_way == 1){ + $where = ['country_code' => $data['country_code']]; + } + + $userInfo = User::where($where) + ->where(['account' => $data['account']]) + ->field(['password,is_disable,is_open']) + ->findOrEmpty(); + + if ($userInfo->isEmpty()) { + $userAccountSafeCache->record(); + return 'login.accountNoExist';//用户不存在 + } + + if ($userInfo['is_open'] === YesNoEnum::NO) { + $userAccountSafeCache->record(); + return 'login.accountNoExist';//用户未启用 + } + + if ($userInfo['is_disable'] === YesNoEnum::YES) { + $userAccountSafeCache->record(); + return 'login.accountLocked';//用户已禁用 + } + + $passwordSalt = Config::get('project.unique_identification'); + if ($userInfo['password'] !== create_password($password, $passwordSalt)) { + $userAccountSafeCache->record(); + return 'login.passwordError';//密码错误 + } + + $userAccountSafeCache->relieve(); + + return true; + } +} \ No newline at end of file diff --git a/app/api/validate/MallValidate.php b/app/api/validate/MallValidate.php new file mode 100644 index 0000000..f29cacb --- /dev/null +++ b/app/api/validate/MallValidate.php @@ -0,0 +1,134 @@ + 'checkBuy', + 'draw' => 'checkDraw', + ]; + + + public function sceneBuy() + { + return $this->only(['buy','id']); + } + + public function sceneDraw() + { + return $this->only(['draw','id']); + } + + /** + * @notes 校验兑换 + * @param $buy + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/02/22 10:54 + */ + protected function checkBuy($buy, $rule, $data) + { + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + return 'network.frequentOperation'; + //密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试 + } + + //判断商城商品 + $goods = MallGoods::where(['type' => 1,'is_show' => 1])->findOrEmpty($data['id']); + if($goods->isEmpty()){ + $userAccountSafeCache->record(); + return 'network.parameterAbnormality'; + } + + //判断积分 + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + if($goods['price'] - $user['user_point'] > 0){ + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//积分不足 + } + + //判断剩余数量 + if($goods['num'] <= 0){ + $userAccountSafeCache->record(); + return 'network.parameterAbnormality'; + } + + //交易密码 + if (empty($data['pay_pwd'])) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入密码 + } + if (strlen($data['pay_pwd']) != 6) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入正确的密码 + } + + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) { + $userAccountSafeCache->record(); + return 'common.payPwdError';//密码错误 + } + + $userAccountSafeCache->relieve(); + + return true; + } + + /** + * @notes 校验抽奖 + * @param $buy + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/02/22 10:54 + */ + protected function checkDraw($draw, $rule, $data) + { + //单次抽奖消耗积分 + $config = ConfigService::get('website', 'trade'); + $draw_point = $config['draw_point']; + + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + + $point = $draw_point; + + //判断积分 + if($point - $user['user_point'] > 0) return 'network.parameterAbnormality';//积分不足 + + return true; + } + +} \ No newline at end of file diff --git a/app/api/validate/PasswordValidate.php b/app/api/validate/PasswordValidate.php new file mode 100644 index 0000000..81f1274 --- /dev/null +++ b/app/api/validate/PasswordValidate.php @@ -0,0 +1,197 @@ + 'require|length:6,20|integer', + 'code' => 'require|length:6|integer', + 'password' => 'require|length:6,20|alphaNum', + 'password_confirm' => 'require|confirm', + 'password_pay' => 'require|length:6|integer', + 'password_pay_confirm' => 'require|confirm', + 'type' => 'require|checkReset', + ]; + + + protected $message = [ + 'mobile.require' => 'pwd.mobileEmpty',//请输入手机号 + 'mobile.length' => 'pwd.mobileError',//请输入正确的手机号 + 'mobile.integer' => 'pwd',//请输入正确的手机号 + 'code.require' => 'captcha.captchaEmpty',//请输入验证码 + 'code.length' => 'captcha.captchaError',//请输入正确的验证码 + 'code.integer' => 'captcha.captchaError',//请输入正确的验证码 + 'password.require' => 'pwd.newPwdEmpty',//请输入新密码 + 'password.length' => 'pwd.newPwdLengthError',//密码须在6-20位之间 + 'password.alphaNum' => 'pwd.newPwdFormatError',//密码须为字母数字组合 + 'password_confirm.require' => 'pwd.confirmPwdEmpty',//请输入确认密码 + 'password_confirm.confirm' => 'pwd.twoPwdError',//两次输入的密码不一致 + 'password_pay.require' => 'pwd.newPwdEmpty',//请输入新密码 + 'password_pay.length' => 'pwd.payPwdFormatError',//密码格式不正确 + 'password_pay.integer' => 'pwd.payPwdFormatError',//密码格式不正确 + 'password_pay_confirm.require' => 'pwd.confirmPwdEmpty',//请输入确认密码 + 'password_pay_confirm.confirm' => 'pwd.twoPwdError',//两次输入的密码不一致 + 'type.require' => 'network.parameterAbnormality',//验证方式异常 + ]; + + + /** + * @notes 重置登录密码 + * @return PasswordValidate + * @author 段誉 + * @date 2022/9/16 18:11 + */ + public function sceneResetPassword() + { + return $this->only(['mobile', 'code', 'password', 'password_confirm','type']); + } + + + /** + * @notes 修改密码场景 + * @return PasswordValidate + * @author 段誉 + * @date 2022/9/20 19:14 + */ + public function sceneChangePassword() + { + return $this->only(['password', 'password_confirm']); + } + + /** + * @notes 修改支付密码场景 + * @return PasswordValidate + * @author 段誉 + * @date 2022/9/20 19:14 + */ + public function sceneChangePayPassword() + { + return $this->only(['password_pay', 'password_pay_confirm']); + } + + /** + * @notes 设置支付密码场景 + * @return PasswordValidate + * @author 段誉 + * @date 2022/9/20 19:14 + */ + public function sceneSetPayPassword() + { + return $this->only(['password_pay', 'password_pay_confirm']); + } + + /** + * @notes 校验忘记密码 + * @param $money + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2023/2/24 10:42 + */ + protected function checkReset($type, $rule, $data) + { + + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + return 'network.frequentOperation'; + //密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试 + } + + $type = $data['type']; + + $types = array(0,1);//0谷歌验证 1邮箱验证 + + if(!in_array($type, $types)) { + return 'network.parameterAbnormality'; + } + + $user = User::where(['mobile' => $data['mobile'],'country_code' => $data['country_code']])->findOrEmpty(); + + if($user->isEmpty()) { + $userAccountSafeCache->record(); + return 'login.userNoExist';//用户不存在 + } + + $userInfo = UserInfo::where(['user_id' => $user['id']])->findOrEmpty(); + if($userInfo->isEmpty()) { + return 'network.parameterAbnormality'; + } + + switch ($type) { + case 0: + if($userInfo['auth_google'] == 0) { + $userAccountSafeCache->record(); + return 'pwd.bindGoogleFirst';//请先绑定您的Google Authenticator + } + + $valid = UtilsService::get_google_verify($userInfo['google_key'],$data['code']); + if(!$valid) { + $userAccountSafeCache->record(); + return 'captcha.captchaError';//验证码错误 + } + + break; + case 1: + if($userInfo['auth_email'] == 0) { + $userAccountSafeCache->record(); + return 'pwd.bindEmailFirst';//请先绑定您的电子邮箱 + } + + if(!filter_var($data['email'], FILTER_VALIDATE_EMAIL)){ + $userAccountSafeCache->record(); + return 'auth.emailError';//请输入正确的邮箱地址 + } + + if($userInfo['email'] != $data['email']){ + $userAccountSafeCache->record(); + return 'auth.emailError';//请输入正确的邮箱地址 + } + + $time = time() - 5*60;//5分钟内有效 + + $email = EmailRecord::where(['user_id' => $user['id'],'is_verify' => 0])->where("create_time > $time")->order('id desc')->findOrEmpty(); + + if($email->isEmpty()) { + $userAccountSafeCache->record(); + return 'captcha.captchaError';//验证码错误 + } + if($email['code'] != $data['code']) { + $userAccountSafeCache->record(); + return 'captcha.captchaError';//验证码错误 + } + + break; + } + + $userAccountSafeCache->relieve(); + + return true; + } + +} \ No newline at end of file diff --git a/app/api/validate/RechargeValidate.php b/app/api/validate/RechargeValidate.php new file mode 100644 index 0000000..9488b2c --- /dev/null +++ b/app/api/validate/RechargeValidate.php @@ -0,0 +1,90 @@ + 'require|gt:0|checkMoney', + ]; + + protected $message = [ + 'money.require' => 'network.parameterAbnormality',//请输入金额 + 'money.gt' => 'network.parameterAbnormality',//请输入正确的金额 + ]; + + + public function sceneRecharge() + { + return $this->only(['money']); + } + + + + /** + * @notes 校验金额 + * @param $money + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2023/2/24 10:42 + */ + protected function checkMoney($money, $rule, $data) + { + //判断充值方式 + $method = RechargeMethod::where(['id' => $data['id']])->findOrEmpty(); + if ($method->isEmpty()) { + return 'network.parameterAbnormality';//充值方式不存在 + } + + //判断充值次数 + $config = ConfigService::get('website', 'trade'); + $todayStart = strtotime("today midnight"); + $recharge_num = RechargeRecord::where(['user_id' => $data['user_id']]) + ->where("create_time > $todayStart") + ->count(); + if($config['recharge_num'] <= $recharge_num){ + return 'recharge.rechargeNumError';//每日充值次数限制 + } + + //查询充值凭证 + if ($method['is_voucher']&&!isset($data['voucher'])) { + return 'network.parameterAbnormality';//请上传支付凭证 + } + + //判断充值金额 + $config = ConfigService::get('website', 'trade'); + + if ($data['money'] < $config['recharge_min']) { + return 'network.parameterAbnormality'; + } + + return true; + } + +} \ No newline at end of file diff --git a/app/api/validate/RegisterValidate.php b/app/api/validate/RegisterValidate.php new file mode 100644 index 0000000..2f1c6f6 --- /dev/null +++ b/app/api/validate/RegisterValidate.php @@ -0,0 +1,98 @@ + '/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){6,20}$/' + ]; + + protected $rule = [ + 'channel' => 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ',' + . UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS . + ',' . UserTerminalEnum::ANDROID, + 'account' => 'require|checkAccount', + 'password' => 'require|length:6,20|regex:password', + // 'password_confirm' => 'require|confirm' + ]; + + protected $message = [ + 'channel.require' => 'network.parameterAbnormality',//注册来源参数缺失 + 'channel.in' => 'network.parameterAbnormality',//终端参数状态值不正确 + 'account.require' => 'network.parameterAbnormality', + 'password.require' => 'login.passwordEmpty',//请输入密码 + 'password.length' => 'login.passwordLimit',//密码须在6-20位之间 + 'password.regex' => 'login.passwordFormatError',//密码须为字母数字组合 + 'password_confirm.require' => 'login.passwordConfirmEmpty',//请输入确认密码 + 'password_confirm.confirm' => 'login.twoPasswordError'//两次输入的密码不一致 + ]; + + /** + * @notes 校验注册 + * @param $buy + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/02/22 10:54 + */ + protected function checkAccount($account, $rule, $data) + { + //账号安全机制,连续输错后锁定 + $userAccountSafeCache = new UserAccountSafeCache(); + if (!$userAccountSafeCache->isSafe()) { + return 'network.pwdErrorLimit'; + } + + $login_way = $data['login_way'];//0邮箱1手机号 + + $mobile_pattern = '/^\d{6,20}$/'; + + if($login_way == 0){ + if(!filter_var($data['account'], FILTER_VALIDATE_EMAIL)){ + return 'login.emailError'; + } + }elseif($login_way == 1){ + if(!preg_match($mobile_pattern, $data['account'])){ + return 'login.mobileError'; + } + }else{ + return 'network.parameterAbnormality'; + } + + $user = User::where(['account' => $data['account']])->findOrEmpty(); + + if (!$user->isEmpty()) { + $userAccountSafeCache->record(); + return 'login.accountExist'; + } + + $userAccountSafeCache->relieve(); + + return true; + } +} \ No newline at end of file diff --git a/app/api/validate/RobotValidate.php b/app/api/validate/RobotValidate.php new file mode 100644 index 0000000..9b261d7 --- /dev/null +++ b/app/api/validate/RobotValidate.php @@ -0,0 +1,82 @@ + 'checkBuy', + ]; + + + public function sceneBuy() + { + return $this->only(['buy']); + } + + /** + * @notes 校验量化 + * @param $buy + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/02/22 10:54 + */ + protected function checkBuy($buy, $rule, $data) + { + + // 获取今天0点的时间戳 + $todayStart = strtotime(date('Y-m-d 00:00:00')); + + //查询会员等级 + $member_id = UtilsService::get_user_member_id($data['user_id']); + $userMember = UserMember::where(['id' => $member_id])->findOrEmpty(); + if ($userMember->isEmpty()) { + return 'network.parameterAbnormality'; + } + + //判断余额 + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + if($userMember['lh_min'] - $user['user_money'] > 0) return 'network.parameterAbnormality';//余额不足 + //判断是否开启量化 + if($user['is_lh'] != 1) return 'network.parameterAbnormality'; + + //判断今日量化次数 + $today_order = LhRecord::where("create_time > $todayStart")->where(['user_id' => $data['user_id']])->count(); + if ($today_order >= $userMember['lh_num']) { + return 'network.parameterAbnormality'; + } + + return true; + } + +} \ No newline at end of file diff --git a/app/api/validate/SendSmsValidate.php b/app/api/validate/SendSmsValidate.php new file mode 100644 index 0000000..d7e5922 --- /dev/null +++ b/app/api/validate/SendSmsValidate.php @@ -0,0 +1,39 @@ + 'require', + 'scene' => 'require', + ]; + + protected $message = [ + 'mobile.require' => 'captcha.mobileEmpty',//请输入手机号 + // 'mobile.mobile' => '请输入正确手机号', + 'scene.require' => 'network.parameterAbnormality',//请输入场景值 + ]; +} \ No newline at end of file diff --git a/app/api/validate/SetUserInfoValidate.php b/app/api/validate/SetUserInfoValidate.php new file mode 100644 index 0000000..56fb4b1 --- /dev/null +++ b/app/api/validate/SetUserInfoValidate.php @@ -0,0 +1,63 @@ + 'require|checkField', + 'value' => 'require', + ]; + + protected $message = [ + 'field.require' => 'network.parameterAbnormality',//参数缺失 + 'value.require' => 'network.parameterAbnormality',//值不存在 + ]; + + + /** + * @notes 校验字段内容 + * @param $value + * @param $rule + * @param $data + * @return bool|string + * @author 段誉 + * @date 2022/9/21 17:01 + */ + protected function checkField($value, $rule, $data) + { + $allowField = [ + 'sex', 'avatar', 'real_name', + ]; + + if (!in_array($value, $allowField)) { + return 'network.parameterAbnormality';//参数错误 + } + + return true; + } + + +} \ No newline at end of file diff --git a/app/api/validate/UserMemberValidate.php b/app/api/validate/UserMemberValidate.php new file mode 100644 index 0000000..63e89ec --- /dev/null +++ b/app/api/validate/UserMemberValidate.php @@ -0,0 +1,104 @@ + 'checkJoin', + ]; + + + + + public function sceneJoin() + { + return $this->only(['id']); + } + + + /** + * @notes 校验开通vip + * @param $id + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/02/22 10:54 + */ + protected function checkJoin($id, $rule, $data) + { + //判断会员等级是否存在 + $member = UserMember::where(['id' => $data['id']])->findOrEmpty(); + if ($member->isEmpty()) { + return 'network.parameterAbnormality'; + } + //判断当前会员等级 + $member_id = UtilsService::get_user_member_id($data['user_id']); + $user_member = UserMember::where(['id' => $member_id])->findOrEmpty(); + if ($user_member['price'] >= $member['price']) { + return 'network.parameterAbnormality';//已开通当前会员,请勿重复开通 + } + + //判断余额 + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + if($member['price'] - $user['user_money'] > 0) return 'network.parameterAbnormality';//余额不足 + + + //支付密码 + $userAccountSafeCache = new UserAccountSafeCache(); + if (empty($data['pay_pwd'])) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入密码 + } + if (strlen($data['pay_pwd']) != 6) { + $userAccountSafeCache->record(); + return 'network.parameterAbnormality';//请输入正确的密码 + } + + //账号安全机制,连续输错后锁定,防止账号密码暴力破解 + if (!$userAccountSafeCache->isSafe()) { + return 'network.frequentOperation'; + //密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试 + } + $passwordSalt = Config::get('project.unique_identification'); + if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) { + $userAccountSafeCache->record(); + return 'common.payPwdError';//密码错误 + } + + $userAccountSafeCache->relieve(); + + + + return true; + } + +} \ No newline at end of file diff --git a/app/api/validate/UserValidate.php b/app/api/validate/UserValidate.php new file mode 100644 index 0000000..eaf7315 --- /dev/null +++ b/app/api/validate/UserValidate.php @@ -0,0 +1,203 @@ + 'require', + 'card_name' => 'require|length:2,20', + 'card_num' => 'require|length:6,32|checkCardNum', + 'signin' => 'checkSignin', + 'start' => 'checkMineStart', + 'receive' => 'checkMineReceive', + ]; + + protected $message = [ + 'code.require' => 'network.parameterAbnormality',//参数缺失 + 'card_name.require' => 'network.parameterAbnormality',//参数缺失 + 'card_name.length' => 'auth.realNameError',//请输入正确的姓名 + 'card_num.require' => 'network.parameterAbnormality',//参数缺失 + 'card_num.length' => 'auth.realNumError',//请输入正确的证件号 + ]; + + /** + * @notes 绑定/变更 手机号 + * @return UserValidate + * @author BD + * @date 2023/9/21 19:15 + */ + public function sceneBindMobile() + { + return $this->only(['mobile', 'code']); + } + + /** + * @notes Google Authenticator校验 + * @return UserValidate + * @author BD + * @date 2023/9/21 19:15 + */ + public function sceneVerifyGoogle() + { + return $this->only(['code']); + } + + /** + * @notes 邮箱校验 + * @return UserValidate + * @author BD + * @date 2023/9/21 19:15 + */ + public function sceneVerifyEmail() + { + return $this->only(['code']); + } + + /** + * @notes 实名认证 + * @return UserValidate + * @author BD + * @date 2023/9/21 19:15 + */ + public function sceneVerifyRealname() + { + return $this->only(['card_name','card_num']); + } + + /** + * @notes 签到 + * @return UserValidate + * @author BD + * @date 2024/9/21 19:15 + */ + public function sceneSignin() + { + return $this->only(['signin']); + } + + /** + * @notes 矿机 启动 + * @return UserValidate + * @author BD + * @date 2024/9/21 19:15 + */ + public function sceneMineStart() + { + return $this->only(['start']); + } + + /** + * @notes 矿机 收益 + * @return UserValidate + * @author BD + * @date 2024/9/21 19:15 + */ + public function sceneMineReceive() + { + return $this->only(['receive']); + } + + /** + * @notes 校验卡号 + * @param $num + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2023/9/21 19:15 + */ + protected function checkCardNum($num, $rule, $data) + { + $userInfo = UserInfo::where(['user_id' => $data['user_id']])->findOrEmpty(); + + if($userInfo->isEmpty()) { + return 'network.parameterAbnormality'; + } + if($userInfo['auth_card'] != 0 && $userInfo['auth_card'] != 3) { + return 'network.parameterAbnormality'; + } + + //查询证件照 + if (!isset($data['card_img1'])||!isset($data['card_img2'])||!isset($data['card_img3'])) { + return 'network.parameterAbnormality'; + } + + //判断是否绑定过 + $info_t = UserInfo::where(['card_num' => $data['card_num']])->findOrEmpty(); + if(!$info_t->isEmpty()) { + return 'auth.realNumExited';//该证件已使用过 + } + + return true; + } + + /** + * @notes 校验签到 + * @param $signin + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/9/21 19:15 + */ + protected function checkSignin($signin, $rule, $data) + { + //判断是否签到 + $todayStart = strtotime("today midnight"); + $sign_count = UserSigninRecord::where(['user_id' => $data['user_id']])->where("create_time > $todayStart")->count(); + if($sign_count > 0) { + return 'network.parameterAbnormality'; + } + + return true; + } + + /** + * @notes 校验矿机 启动 + * @param $start + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/9/21 19:15 + */ + protected function checkMineStart($start, $rule, $data) + { + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + if($user['mine_status'] != 0) { + return 'network.parameterAbnormality'; + } + + return true; + } + + /** + * @notes 校验矿机 收益 + * @param $receive + * @param $rule + * @param $data + * @return bool|string + * @author BD + * @date 2024/9/21 19:15 + */ + protected function checkMineReceive($receive, $rule, $data) + { + $user = User::where(['id' => $data['user_id']])->findOrEmpty(); + if($user['mine_status'] != 2) { + return 'network.parameterAbnormality'; + } + + return true; + } +} \ No newline at end of file diff --git a/app/common.php b/app/common.php new file mode 100644 index 0000000..0cbeee0 --- /dev/null +++ b/app/common.php @@ -0,0 +1,302 @@ += 0 ? true : false; +} + + +/** + * @notes 检查文件是否可写 + * @param string $dir + * @return bool + * @author 段誉 + * @date 2021/12/28 18:27 + */ +function check_dir_write(string $dir = '') : bool +{ + $route = root_path() . '/' . $dir; + return is_writable($route); +} + + +/** + * 多级线性结构排序 + * 转换前: + * [{"id":1,"pid":0,"name":"a"},{"id":2,"pid":0,"name":"b"},{"id":3,"pid":1,"name":"c"}, + * {"id":4,"pid":2,"name":"d"},{"id":5,"pid":4,"name":"e"},{"id":6,"pid":5,"name":"f"}, + * {"id":7,"pid":3,"name":"g"}] + * 转换后: + * [{"id":1,"pid":0,"name":"a","level":1},{"id":3,"pid":1,"name":"c","level":2},{"id":7,"pid":3,"name":"g","level":3}, + * {"id":2,"pid":0,"name":"b","level":1},{"id":4,"pid":2,"name":"d","level":2},{"id":5,"pid":4,"name":"e","level":3}, + * {"id":6,"pid":5,"name":"f","level":4}] + * @param array $data 线性结构数组 + * @param string $symbol 名称前面加符号 + * @param string $name 名称 + * @param string $id_name 数组id名 + * @param string $parent_id_name 数组祖先id名 + * @param int $level 此值请勿给参数 + * @param int $parent_id 此值请勿给参数 + * @return array + */ +function linear_to_tree($data, $sub_key_name = 'sub', $id_name = 'id', $parent_id_name = 'pid', $parent_id = 0) +{ + $tree = []; + foreach ($data as $row) { + if ($row[$parent_id_name] == $parent_id) { + $temp = $row; + $child = linear_to_tree($data, $sub_key_name, $id_name, $parent_id_name, $row[$id_name]); + if ($child) { + $temp[$sub_key_name] = $child; + } + $tree[] = $temp; + } + } + return $tree; +} + + +/** + * @notes 删除目标目录 + * @param $path + * @param $delDir + * @return bool|void + * @author 段誉 + * @date 2022/4/8 16:30 + */ +function del_target_dir($path, $delDir) +{ + //没找到,不处理 + if (!file_exists($path)) { + return false; + } + + //打开目录句柄 + $handle = opendir($path); + if ($handle) { + while (false !== ($item = readdir($handle))) { + if ($item != "." && $item != "..") { + if (is_dir("$path/$item")) { + del_target_dir("$path/$item", $delDir); + } else { + unlink("$path/$item"); + } + } + } + closedir($handle); + if ($delDir) { + return rmdir($path); + } + } else { + if (file_exists($path)) { + return unlink($path); + } + return false; + } +} + + +/** + * @notes 下载文件 + * @param $url + * @param $saveDir + * @param $fileName + * @return string + * @author 段誉 + * @date 2022/9/16 9:53 + */ +function download_file($url, $saveDir, $fileName) +{ + if (!file_exists($saveDir)) { + mkdir($saveDir, 0775, true); + } + $fileSrc = $saveDir . $fileName; + file_exists($fileSrc) && unlink($fileSrc); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); + $file = curl_exec($ch); + curl_close($ch); + $resource = fopen($fileSrc, 'a'); + fwrite($resource, $file); + fclose($resource); + if (filesize($fileSrc) == 0) { + unlink($fileSrc); + return ''; + } + return $fileSrc; +} + + +/** + * @notes 去除内容图片域名 + * @param $content + * @return array|string|string[] + * @author 段誉 + * @date 2022/9/26 10:43 + */ +function clear_file_domain($content) +{ + $fileUrl = FileService::getFileUrl(); + return str_replace($fileUrl, '/', $content); +} + + +/** + * @notes 设置内容图片域名 + * @param $content + * @return array|string|string[]|null + * @author 段誉 + * @date 2022/9/26 10:43 + */ +function get_file_domain($content) +{ + $preg = '/()/is'; + $preg1 = '/(