first commit
This commit is contained in:
19
app/api/config/route.php
Normal file
19
app/api/config/route.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
'middleware' => [
|
||||
app\api\http\middleware\InitMiddleware::class, // 初始化
|
||||
app\api\http\middleware\LoginMiddleware::class, // 登录验证
|
||||
],
|
||||
];
|
||||
124
app/api/controller/ArticleController.php
Normal file
124
app/api/controller/ArticleController.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\lists\article\ArticleCollectLists;
|
||||
use app\api\lists\article\ArticleLists;
|
||||
use app\api\logic\ArticleLogic;
|
||||
|
||||
/**
|
||||
* 文章管理
|
||||
* Class ArticleController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class ArticleController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['lists', 'cate', 'detail','hintDetail'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 文章列表
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 15:30
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->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('操作成功');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
46
app/api/controller/BaseApiController.php
Normal file
46
app/api/controller/BaseApiController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
use app\common\model\user\{User,UserLog};
|
||||
|
||||
class BaseApiController extends BaseLikeAdminController
|
||||
{
|
||||
protected int $userId = 0;
|
||||
protected array $userInfo = [];
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
if (isset($this->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
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
261
app/api/controller/FinanceController.php
Normal file
261
app/api/controller/FinanceController.php
Normal file
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\FinanceLogic;
|
||||
use app\api\validate\{FinanceValidate};
|
||||
use app\api\lists\finance\{WithdrawRecordLists,RechargeRecordLists,UserFinanceLists,UserTransferRecordLists};
|
||||
|
||||
|
||||
/**
|
||||
* 资金控制器
|
||||
* Class FinanceController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class FinanceController extends BaseApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @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 index()
|
||||
{
|
||||
$params = $this->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());
|
||||
}
|
||||
|
||||
}
|
||||
125
app/api/controller/IndexController.php
Normal file
125
app/api/controller/IndexController.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\IndexLogic;
|
||||
use think\response\Json;
|
||||
|
||||
|
||||
/**
|
||||
* index
|
||||
* Class IndexController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class IndexController extends BaseApiController
|
||||
{
|
||||
|
||||
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'countryCode', 'getKefuLists', 'market'];
|
||||
|
||||
|
||||
/**
|
||||
* @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:15
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$params = $this->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);
|
||||
}
|
||||
|
||||
}
|
||||
98
app/api/controller/ItemController.php
Normal file
98
app/api/controller/ItemController.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\ItemLogic;
|
||||
use app\api\validate\{ItemValidate};
|
||||
|
||||
use app\api\lists\item\{ItemRecordLists};
|
||||
|
||||
|
||||
/**
|
||||
* 项目控制器
|
||||
* Class ItemController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class ItemController extends BaseApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @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;
|
||||
$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());
|
||||
}
|
||||
|
||||
}
|
||||
77
app/api/controller/LanguageController.php
Normal file
77
app/api/controller/LanguageController.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\LanguageLogic;
|
||||
use app\api\validate\LanguageValidate;
|
||||
use app\api\validate\LanguagePagValidate;
|
||||
|
||||
/**
|
||||
* 文章管理
|
||||
* Class LanguageController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class LanguageController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['all', 'pagAll', 'detail'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取语言详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @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
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
94
app/api/controller/LoginController.php
Normal file
94
app/api/controller/LoginController.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\validate\{LoginAccountValidate, RegisterValidate, WebScanLoginValidate, WechatLoginValidate};
|
||||
use app\api\logic\LoginLogic;
|
||||
|
||||
/**
|
||||
* 登录注册
|
||||
* Class LoginController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class LoginController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['register', 'account', 'logout', 'codeUrl', 'oaLogin', 'mnpLogin', 'getScanCode', 'scanLogin'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 注册账号
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/7 15:38
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$params = (new RegisterValidate())->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);
|
||||
}
|
||||
|
||||
}
|
||||
97
app/api/controller/MallController.php
Normal file
97
app/api/controller/MallController.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\MallLogic;
|
||||
use app\api\validate\{MallValidate};
|
||||
use app\api\lists\mall\{MallGoodsRecordLists};
|
||||
|
||||
|
||||
/**
|
||||
* 积分商城控制器
|
||||
* Class MallController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class MallController extends BaseApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @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;
|
||||
$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());
|
||||
}
|
||||
}
|
||||
95
app/api/controller/PcController.php
Normal file
95
app/api/controller/PcController.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\PcLogic;
|
||||
use think\response\Json;
|
||||
|
||||
|
||||
/**
|
||||
* PC
|
||||
* Class PcController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class PcController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['index', 'config', 'infoCenter', 'articleDetail'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/21 19:15
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$result = PcLogic::getIndexData();
|
||||
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/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);
|
||||
}
|
||||
|
||||
}
|
||||
164
app/api/controller/RechargeController.php
Normal file
164
app/api/controller/RechargeController.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\lists\recharge\RechargeLists;
|
||||
use app\api\logic\RechargeLogic;
|
||||
use app\api\validate\{RechargeValidate};
|
||||
|
||||
|
||||
/**
|
||||
* 充值控制器
|
||||
* Class RechargeController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class RechargeController extends BaseApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取充值列表
|
||||
* @return \think\response\Json
|
||||
* @author BD
|
||||
* @date 2024/2/23 18:55
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
122
app/api/controller/RobotController.php
Normal file
122
app/api/controller/RobotController.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\RobotLogic;
|
||||
use app\api\validate\{RobotValidate};
|
||||
use app\api\lists\lh\{LhRecordLists};
|
||||
|
||||
/**
|
||||
* 抢单控制器
|
||||
* Class RobotController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class RobotController extends BaseApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @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;
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
70
app/api/controller/SmsController.php
Normal file
70
app/api/controller/SmsController.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\SmsLogic;
|
||||
use app\api\validate\SendSmsValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 短信
|
||||
* Class SmsController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class SmsController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['sendCode','sendEmailNoLogin'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 发送短信验证码
|
||||
* @return \think\response\Json
|
||||
* @author BD
|
||||
* @date 2024/9/21 17:29
|
||||
*/
|
||||
public function sendCode()
|
||||
{
|
||||
$params = (new SendSmsValidate())->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());
|
||||
}
|
||||
|
||||
}
|
||||
61
app/api/controller/TeamController.php
Normal file
61
app/api/controller/TeamController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\TeamLogic;
|
||||
use app\api\lists\team\{TeamUserLists};
|
||||
use think\facade\Request;
|
||||
|
||||
/**
|
||||
* 团队控制器
|
||||
* Class TeamController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class TeamController extends BaseApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 团队列表
|
||||
* @return \think\response\Json
|
||||
* @author BD
|
||||
* @date 2024/2/23 18:55
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->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);
|
||||
}
|
||||
}
|
||||
48
app/api/controller/UploadController.php
Normal file
48
app/api/controller/UploadController.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\enum\FileEnum;
|
||||
use app\common\service\UploadService;
|
||||
use Exception;
|
||||
use think\response\Json;
|
||||
|
||||
|
||||
/** 上传文件
|
||||
* Class UploadController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class UploadController extends BaseApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 上传图片
|
||||
* @return Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 18:11
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
try {
|
||||
$result = UploadService::image(0, $this->userId,FileEnum::SOURCE_USER);
|
||||
return $this->success('上传成功', $result);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
454
app/api/controller/UserController.php
Normal file
454
app/api/controller/UserController.php
Normal file
@@ -0,0 +1,454 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\UserLogic;
|
||||
use app\api\validate\PasswordValidate;
|
||||
use app\api\validate\SetUserInfoValidate;
|
||||
use app\api\validate\UserValidate;
|
||||
use app\api\lists\user\{UserNoticeLists,UserMineRecordLists};
|
||||
use think\facade\Request;
|
||||
|
||||
/**
|
||||
* 用户控制器
|
||||
* Class UserController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class UserController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['resetPassword'];
|
||||
|
||||
/**
|
||||
* @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 index()
|
||||
{
|
||||
$lang = $this->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());
|
||||
}
|
||||
}
|
||||
74
app/api/controller/UserMemberController.php
Normal file
74
app/api/controller/UserMemberController.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\UserMemberLogic;
|
||||
use app\api\validate\{UserMemberValidate};
|
||||
|
||||
/**
|
||||
* 会员控制器
|
||||
* Class UserMemberController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class UserMemberController extends BaseApiController
|
||||
{
|
||||
/**
|
||||
* @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 index()
|
||||
{
|
||||
$params = $this->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);
|
||||
// }
|
||||
|
||||
}
|
||||
56
app/api/http/middleware/InitMiddleware.php
Normal file
56
app/api/http/middleware/InitMiddleware.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\api\http\middleware;
|
||||
|
||||
|
||||
use app\common\exception\ControllerExtendException;
|
||||
use app\api\controller\BaseApiController;
|
||||
use think\exception\ClassNotFoundException;
|
||||
use think\exception\HttpException;
|
||||
|
||||
|
||||
class InitMiddleware
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 初始化
|
||||
* @param $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws ControllerExtendException
|
||||
* @author 段誉
|
||||
* @date 2022/9/6 18:17
|
||||
*/
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
//获取控制器
|
||||
try {
|
||||
$controller = str_replace('.', '\\', $request->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);
|
||||
}
|
||||
|
||||
}
|
||||
80
app/api/http/middleware/LoginMiddleware.php
Normal file
80
app/api/http/middleware/LoginMiddleware.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\api\http\middleware;
|
||||
|
||||
|
||||
use app\common\cache\UserTokenCache;
|
||||
use app\common\service\JsonService;
|
||||
use app\api\service\UserTokenService;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Config;
|
||||
|
||||
class LoginMiddleware
|
||||
{
|
||||
/**
|
||||
* @notes 登录验证
|
||||
* @param $request
|
||||
* @param \Closure $next
|
||||
* @return mixed|\think\response\Json
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/1 17:33
|
||||
*/
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
$token = $request->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);
|
||||
}
|
||||
|
||||
}
|
||||
37
app/api/lists/BaseApiDataLists.php
Normal file
37
app/api/lists/BaseApiDataLists.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists;
|
||||
|
||||
use app\common\lists\BaseDataLists;
|
||||
|
||||
abstract class BaseApiDataLists extends BaseDataLists
|
||||
{
|
||||
protected array $userInfo = [];
|
||||
protected int $userId = 0;
|
||||
|
||||
public string $export;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if (isset($this->request->userInfo) && $this->request->userInfo) {
|
||||
$this->userInfo = $this->request->userInfo;
|
||||
$this->userId = $this->request->userId;
|
||||
}
|
||||
$this->export = $this->request->get('export', '');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
79
app/api/lists/article/ArticleCollectLists.php
Normal file
79
app/api/lists/article/ArticleCollectLists.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists\article;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\article\Article;
|
||||
|
||||
/**
|
||||
* 文章收藏列表
|
||||
* Class ArticleCollectLists
|
||||
* @package app\api\lists\article
|
||||
*/
|
||||
class ArticleCollectLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取收藏列表
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 16:29
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = "c.id,c.article_id,a.title,a.image,a.desc,a.is_show,
|
||||
a.click_virtual, a.click_actual,a.create_time, c.create_time as collect_time";
|
||||
|
||||
$lists = (new Article())->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();
|
||||
}
|
||||
}
|
||||
107
app/api/lists/article/ArticleLists.php
Normal file
107
app/api/lists/article/ArticleLists.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists\article;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\article\Article;
|
||||
use app\common\service\{FileService,UtilsService};
|
||||
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
* Class ArticleLists
|
||||
* @package app\api\lists\article
|
||||
*/
|
||||
class ArticleLists extends BaseApiDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return \string[][]
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 18:54
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['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();
|
||||
}
|
||||
}
|
||||
78
app/api/lists/finance/RechargeRecordLists.php
Normal file
78
app/api/lists/finance/RechargeRecordLists.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists\finance;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\finance\RechargeRecord;
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
/**
|
||||
* 充值记录列表
|
||||
* Class RechargeRecordLists
|
||||
* @package app\api\lists\finance
|
||||
*/
|
||||
class RechargeRecordLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取充值记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$field = 'id,sn,method_id,amount,amount_act,rate,symbol,status,create_time';
|
||||
$lists = RechargeRecord::field($field)
|
||||
->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();
|
||||
}
|
||||
}
|
||||
89
app/api/lists/finance/UserFinanceLists.php
Normal file
89
app/api/lists/finance/UserFinanceLists.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists\finance;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\model\finance\UserFinance;
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
/**
|
||||
* 充值记录列表
|
||||
* Class UserFinanceLists
|
||||
* @package app\api\lists\finance
|
||||
*/
|
||||
class UserFinanceLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取充值记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$where = '1 = 1';
|
||||
|
||||
if( $this->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();
|
||||
}
|
||||
}
|
||||
74
app/api/lists/finance/UserTransferRecordLists.php
Normal file
74
app/api/lists/finance/UserTransferRecordLists.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists\finance;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
|
||||
use app\common\service\{UtilsService,FileService};
|
||||
use app\common\model\finance\UserTransferRecord;
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
/**
|
||||
* 转账记录列表
|
||||
* Class UserTransferRecordLists
|
||||
* @package app\api\lists\finance
|
||||
*/
|
||||
class UserTransferRecordLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取转账记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$field = 'id,sn,user_id,user_id_from,user_id_to,amount,type,create_time';
|
||||
$lists = UserTransferRecord::field($field)
|
||||
->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();
|
||||
}
|
||||
}
|
||||
84
app/api/lists/finance/WithdrawRecordLists.php
Normal file
84
app/api/lists/finance/WithdrawRecordLists.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists\finance;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\finance\WithdrawRecord;
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
/**
|
||||
* 提现记录列表
|
||||
* Class WithdrawRecordLists
|
||||
* @package app\api\lists\finance
|
||||
*/
|
||||
class WithdrawRecordLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取提现记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = 'id,sn,method_id,amount,amount_act,rate,symbol,status,create_time,account,type,remark,charge';
|
||||
$lists = WithdrawRecord::field($field)
|
||||
->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();
|
||||
}
|
||||
}
|
||||
82
app/api/lists/goods/GoodsRecordLists.php
Normal file
82
app/api/lists/goods/GoodsRecordLists.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
namespace app\api\lists\goods;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\goods\GoodsRecord;
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
/**
|
||||
* 抢单记录列表
|
||||
* Class GoodsRecordLists
|
||||
* @package app\api\lists\goods
|
||||
*/
|
||||
class GoodsRecordLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取抢单记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$time = strtotime($this->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();
|
||||
}
|
||||
}
|
||||
88
app/api/lists/item/ItemRecordLists.php
Normal file
88
app/api/lists/item/ItemRecordLists.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists\item;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
|
||||
use app\common\service\{UtilsService,FileService};
|
||||
use app\common\model\item\ItemRecord;
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
/**
|
||||
* 投资记录列表
|
||||
* Class ItemRecordLists
|
||||
* @package app\api\lists\item
|
||||
*/
|
||||
class ItemRecordLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取投资记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$field = 'id,sn,contract_no,item_title,item_image,item_langs,money,point,rate,total_income,cycle,type,status,create_time,end_time';
|
||||
$lists = ItemRecord::field($field)
|
||||
->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();
|
||||
}
|
||||
}
|
||||
70
app/api/lists/lh/LhRecordLists.php
Normal file
70
app/api/lists/lh/LhRecordLists.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
namespace app\api\lists\lh;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\lh\LhRecord;
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
/**
|
||||
* 量化记录列表
|
||||
* Class LhRecordLists
|
||||
* @package app\api\lists\lh
|
||||
*/
|
||||
class LhRecordLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取量化记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$field = 'id,sn,user_id,coin_name,coin_logo,coin_symbol,coin_buy_name,coin_sale_name,money,income,money_buy,money_sale,create_time';
|
||||
$lists = LhRecord::field($field)
|
||||
->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();
|
||||
}
|
||||
}
|
||||
89
app/api/lists/mall/MallGoodsRecordLists.php
Normal file
89
app/api/lists/mall/MallGoodsRecordLists.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace app\api\lists\mall;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
|
||||
use app\common\service\{UtilsService,FileService};
|
||||
use app\common\model\mall\MallGoodsRecord;
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
/**
|
||||
* 奖品记录列表
|
||||
* Class MallGoodsRecordLists
|
||||
* @package app\api\lists\mall
|
||||
*/
|
||||
class MallGoodsRecordLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取奖品记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$where = ' type = 1 ';
|
||||
|
||||
if( $this->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();
|
||||
}
|
||||
}
|
||||
90
app/api/lists/team/TeamUserLists.php
Normal file
90
app/api/lists/team/TeamUserLists.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace app\api\lists\team;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\model\user\{User,UserRelation};
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\service\{UtilsService,FileService};
|
||||
|
||||
/**
|
||||
* 抢单记录列表
|
||||
* Class TeamUserLists
|
||||
* @package app\api\lists\team
|
||||
*/
|
||||
class TeamUserLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取抢单记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$distributeLevel = UtilsService::get_distribute_level();
|
||||
|
||||
$level = $this->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();
|
||||
}
|
||||
}
|
||||
61
app/api/lists/user/UserMineRecordLists.php
Normal file
61
app/api/lists/user/UserMineRecordLists.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace app\api\lists\user;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\user\UserMineRecord;
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\service\{FileService,UtilsService};
|
||||
|
||||
/**
|
||||
* 挖矿记录列表
|
||||
* Class UserMineRecordLists
|
||||
* @package app\api\lists\user
|
||||
*/
|
||||
class UserMineRecordLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取挖矿记录列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$field = 'id,amount,amount_act,symbol,rate,precision,start_time,create_time';
|
||||
$lists = UserMineRecord::field($field)
|
||||
->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();
|
||||
}
|
||||
}
|
||||
73
app/api/lists/user/UserNoticeLists.php
Normal file
73
app/api/lists/user/UserNoticeLists.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
namespace app\api\lists\user;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\user\UserNotice;
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\service\{FileService,UtilsService};
|
||||
|
||||
/**
|
||||
* 用户消息列表
|
||||
* Class UserNoticeLists
|
||||
* @package app\api\lists\user
|
||||
*/
|
||||
class UserNoticeLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取用户消息列表
|
||||
* @return array
|
||||
*@author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$field = 'id,title,content,read,langs,create_time';
|
||||
$lists = UserNotice::field($field)
|
||||
->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();
|
||||
}
|
||||
}
|
||||
156
app/api/logic/ArticleLogic.php
Normal file
156
app/api/logic/ArticleLogic.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\article\Article;
|
||||
use app\common\model\article\ArticleCate;
|
||||
use app\common\model\article\ArticleCollect;
|
||||
use app\common\model\decorate\{DecorateHint};
|
||||
use app\common\service\{FileService,UtilsService};
|
||||
|
||||
|
||||
/**
|
||||
* 文章逻辑
|
||||
* Class ArticleLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class ArticleLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 文章详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 17:09
|
||||
*/
|
||||
public static function detail($params)
|
||||
{
|
||||
//未传语言,则默认使用首个语言
|
||||
if($params['lang'] == ''){
|
||||
$first_lang = UtilsService::get_first_lang();
|
||||
$params['lang'] = $first_lang['symbol'];
|
||||
}
|
||||
// 文章详情
|
||||
$article = Article::getArticleDetailArr($params['id']);
|
||||
//多语言替换
|
||||
$data = UtilsService::get_langs_data($article['langs'],$params['lang']);
|
||||
$data_title = '';
|
||||
$data_content = '';
|
||||
|
||||
if(count($data) > 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();
|
||||
}
|
||||
|
||||
}
|
||||
605
app/api/logic/FinanceLogic.php
Normal file
605
app/api/logic/FinanceLogic.php
Normal file
@@ -0,0 +1,605 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\model\withdraw\WithdrawMethod;
|
||||
use app\common\model\withdraw\WithdrawWallet;
|
||||
use app\common\model\withdraw\WithdrawBank;
|
||||
use app\common\model\finance\{WithdrawRecord,RechargeRecord,UserFinance,UserTransferRecord};
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\service\{FileService,UtilsService,ConfigService};
|
||||
use app\common\model\user\{User,UserInfo};
|
||||
use think\facade\Config;
|
||||
use think\facade\{Db};
|
||||
|
||||
|
||||
/**
|
||||
* 资金逻辑层
|
||||
* Class FinanceLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class FinanceLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @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 getIndexData(array $params)
|
||||
{
|
||||
$user = User::where(['id' => $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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
350
app/api/logic/IndexLogic.php
Normal file
350
app/api/logic/IndexLogic.php
Normal file
@@ -0,0 +1,350 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
|
||||
use app\common\service\{FileService,UtilsService,ConfigService};
|
||||
use app\common\model\article\{Article,ArticleCate};
|
||||
use app\common\model\decorate\{DecorateSwiper,DecorateNav,DecorateHint};
|
||||
use app\common\model\item\Item;
|
||||
use app\common\model\user\{User,UserNotice};
|
||||
use app\common\model\setting\Language;
|
||||
|
||||
|
||||
/**
|
||||
* index
|
||||
* Class IndexLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class IndexLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author BD
|
||||
* @date 2023/9/21 19:15
|
||||
*/
|
||||
public static function getIndexData(array $params)
|
||||
{
|
||||
//未传语言,则默认使用首个语言
|
||||
if($params['lang'] == ''){
|
||||
$first_lang = UtilsService::get_first_lang();
|
||||
$params['lang'] = $first_lang['symbol'];
|
||||
}
|
||||
|
||||
//轮播图
|
||||
$field1 = ['name','image','link','langs','image_ext'];
|
||||
$swipers = DecorateSwiper::field($field1)
|
||||
->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("/<source[^<>]*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;
|
||||
}
|
||||
|
||||
}
|
||||
324
app/api/logic/ItemLogic.php
Normal file
324
app/api/logic/ItemLogic.php
Normal file
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\{UtilsService,ConfigService,FileService};
|
||||
use app\common\model\item\{Item,ItemRecord};
|
||||
use app\common\model\finance\{UserFinance};
|
||||
use app\common\model\user\{User};
|
||||
use app\common\model\member\UserMember;
|
||||
use app\common\model\decorate\{DecorateHint};
|
||||
use app\common\model\setting\Language;
|
||||
use think\facade\Config;
|
||||
use think\facade\{Db};
|
||||
|
||||
|
||||
/**
|
||||
* 项目逻辑
|
||||
* Class ItemLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class ItemLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @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 getIndexData(array $params)
|
||||
{
|
||||
// 获取今天0点的时间戳
|
||||
$todayStart = strtotime(date('Y-m-d 00:00:00'));
|
||||
|
||||
$field_item = ['id','title','image','rate','cycle','progress','type','member_id','langs'];
|
||||
$items = Item::field($field_item)
|
||||
->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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
100
app/api/logic/LanguageLogic.php
Normal file
100
app/api/logic/LanguageLogic.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\model\setting\LanguagePag;
|
||||
|
||||
|
||||
/**
|
||||
* 文章逻辑
|
||||
* Class LanguageLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class LanguageLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 语言详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 17:09
|
||||
*/
|
||||
public static function detail($params)
|
||||
{
|
||||
// 语言详情
|
||||
$field = ['id','name_loc as name','symbol','precision'];
|
||||
$where = ['symbol' => $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;
|
||||
}
|
||||
|
||||
}
|
||||
507
app/api/logic/LoginLogic.php
Normal file
507
app/api/logic/LoginLogic.php
Normal file
@@ -0,0 +1,507 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\cache\WebScanLoginCache;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\api\service\{UserTokenService, WechatUserService};
|
||||
use app\common\enum\{LoginEnum, user\UserTerminalEnum, YesNoEnum};
|
||||
use app\common\service\{
|
||||
UtilsService,
|
||||
ConfigService,
|
||||
FileService,
|
||||
wechat\WeChatConfigService,
|
||||
wechat\WeChatMnpService,
|
||||
wechat\WeChatOaService,
|
||||
wechat\WeChatRequestService
|
||||
};
|
||||
use app\common\model\user\{User,UserInfo,UserAuth,UserNotice};
|
||||
use app\common\model\decorate\DecorateHint;
|
||||
use think\facade\{Db,Config};
|
||||
|
||||
/**
|
||||
* 登录逻辑
|
||||
* Class LoginLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class LoginLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 账号密码注册
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/9/7 15:37
|
||||
*/
|
||||
public static function register(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
//查询IP注册数量
|
||||
$config_ip_num = ConfigService::get('login', 'ip_num');
|
||||
$count_ip = User::where(['register_ip' => 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;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
235
app/api/logic/MallLogic.php
Normal file
235
app/api/logic/MallLogic.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\{UtilsService,ConfigService,FileService};
|
||||
use app\common\model\finance\{UserFinance};
|
||||
use app\common\model\user\{User};
|
||||
use app\common\model\mall\{MallGoods,MallGoodsRecord};
|
||||
use app\common\model\setting\Language;
|
||||
use think\facade\Config;
|
||||
use think\facade\{Db};
|
||||
|
||||
|
||||
/**
|
||||
* 项目逻辑
|
||||
* Class MallLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class MallLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @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 index(array $params)
|
||||
{
|
||||
$user = User::where(['id' => $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;
|
||||
}
|
||||
}
|
||||
}
|
||||
240
app/api/logic/PcLogic.php
Normal file
240
app/api/logic/PcLogic.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\article\Article;
|
||||
use app\common\model\article\ArticleCate;
|
||||
use app\common\model\article\ArticleCollect;
|
||||
use app\common\model\decorate\DecoratePage;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
|
||||
/**
|
||||
* index
|
||||
* Class IndexLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class PcLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/21 19:15
|
||||
*/
|
||||
public static function getIndexData()
|
||||
{
|
||||
// 装修配置
|
||||
$decoratePage = DecoratePage::findOrEmpty(4);
|
||||
// 最新资讯
|
||||
$newArticle = self::getLimitArticle('new', 7);
|
||||
// 全部资讯
|
||||
$allArticle = self::getLimitArticle('all', 5);
|
||||
// 热门资讯
|
||||
$hotArticle = self::getLimitArticle('hot', 8);
|
||||
|
||||
return [
|
||||
'page' => $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;
|
||||
}
|
||||
|
||||
}
|
||||
393
app/api/logic/RechargeLogic.php
Normal file
393
app/api/logic/RechargeLogic.php
Normal file
@@ -0,0 +1,393 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\finance\RechargeRecord;
|
||||
use app\common\model\user\{User,UserUdun,UserTron,UserMember};
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\model\setting\RechargeMethod;
|
||||
use app\common\model\withdraw\WithdrawWallet;
|
||||
use app\common\service\{ConfigService,UtilsService};
|
||||
use think\facade\{Db};
|
||||
|
||||
|
||||
/**
|
||||
* 充值逻辑层
|
||||
* Class RechargeLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class RechargeLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 充值
|
||||
* @param array $params
|
||||
* @return array|false
|
||||
* @author BD
|
||||
* @date 2024/2/24 10:43
|
||||
*/
|
||||
public static function recharge(array $params)
|
||||
{
|
||||
try {
|
||||
$method = RechargeMethod::where(['id' => $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']);
|
||||
}
|
||||
|
||||
}
|
||||
519
app/api/logic/RobotLogic.php
Normal file
519
app/api/logic/RobotLogic.php
Normal file
@@ -0,0 +1,519 @@
|
||||
// <?php
|
||||
// namespace app\api\logic;
|
||||
|
||||
// use app\common\logic\BaseLogic;
|
||||
// use app\common\model\goods\{Goods,GoodsRecord};
|
||||
// use app\common\service\{UtilsService,ConfigService,FileService};
|
||||
// use app\common\model\member\UserMember;
|
||||
// use app\common\model\finance\{UserFinance};
|
||||
// use app\common\model\user\{User,UserRelation,UserKadan,UserGroupRule,UserGroupRecord};
|
||||
// use app\common\model\lh\{LhCoin,LhRecord};
|
||||
// use app\common\model\setting\Language;
|
||||
// use think\facade\{Db};
|
||||
|
||||
|
||||
// /**
|
||||
// * 抢单逻辑
|
||||
// * Class RobotLogic
|
||||
// * @package app\api\logic
|
||||
// */
|
||||
// class RobotLogic extends BaseLogic
|
||||
// {
|
||||
|
||||
// /**
|
||||
// * @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 getIndexData(array $params)
|
||||
// {
|
||||
// // 获取今天0点的时间戳
|
||||
// $todayStart = strtotime(date('Y-m-d 00:00:00'));
|
||||
|
||||
// $user = User::where(['id' => $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;
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
185
app/api/logic/SmsLogic.php
Normal file
185
app/api/logic/SmsLogic.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\service\{UtilsService};
|
||||
use app\common\model\decorate\{DecorateHint};
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\model\notice\EmailRecord;
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use app\common\model\user\{User,UserInfo};
|
||||
use app\common\logic\BaseLogic;
|
||||
|
||||
|
||||
/**
|
||||
* 短信逻辑
|
||||
* Class SmsLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class SmsLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 发送验证码
|
||||
* @param $params
|
||||
* @return false|mixed
|
||||
* @author BD
|
||||
* @date 2024/9/21 17:29
|
||||
*/
|
||||
public static function sendCode($params)
|
||||
{
|
||||
try {
|
||||
$scene = NoticeEnum::getSceneByTag($params['scene']);
|
||||
if (empty($scene)) {
|
||||
throw new \Exception('network.parameterAbnormality');//场景值异常
|
||||
}
|
||||
|
||||
$result = event('Notice', [
|
||||
'scene_id' => $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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
137
app/api/logic/TeamLogic.php
Normal file
137
app/api/logic/TeamLogic.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\{UtilsService,ConfigService,FileService};
|
||||
use app\common\model\finance\{UserFinance};
|
||||
use app\common\model\user\{User,UserRelation,UserNotice};
|
||||
use app\common\model\item\{ItemRecord};
|
||||
use think\facade\{Db};
|
||||
|
||||
|
||||
/**
|
||||
* 团队逻辑
|
||||
* Class TeamLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class TeamLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @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 getIndexData(array $params)
|
||||
{
|
||||
$todayStart = strtotime("today midnight");
|
||||
|
||||
$distributes = ConfigService::get('website', 'distribute');
|
||||
|
||||
$distributeLevel = UtilsService::get_distribute_level();
|
||||
|
||||
//用户----------------------------------------------------------
|
||||
$user = User::where(['id' => $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;
|
||||
}
|
||||
|
||||
}
|
||||
1358
app/api/logic/UserLogic.php
Normal file
1358
app/api/logic/UserLogic.php
Normal file
File diff suppressed because it is too large
Load Diff
137
app/api/logic/UserMemberLogic.php
Normal file
137
app/api/logic/UserMemberLogic.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\member\{UserMember,UserMemberRecord};
|
||||
use app\common\model\user\{User,UserRelation};
|
||||
use app\common\model\item\{ItemRecord};
|
||||
use app\common\service\{ConfigService,UtilsService};
|
||||
use think\facade\{Db};
|
||||
|
||||
|
||||
/**
|
||||
* 会员逻辑
|
||||
* Class UserMemberLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class UserMemberLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author BD
|
||||
* @date 2023/9/21 19:15
|
||||
*/
|
||||
public static function getIndexData(array $params)
|
||||
{
|
||||
|
||||
$user['total_invest'] = ItemRecord::where(['user_id' => $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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
132
app/api/service/UserTokenService.php
Normal file
132
app/api/service/UserTokenService.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\service;
|
||||
|
||||
use app\common\cache\UserTokenCache;
|
||||
use app\common\model\user\UserSession;
|
||||
use think\facade\Config;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
class UserTokenService
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 设置或更新用户token
|
||||
* @param $userId
|
||||
* @param $terminal
|
||||
* @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 setToken($userId, $terminal)
|
||||
{
|
||||
$time = time();
|
||||
$userSession = UserSession::where([['user_id', '=', $userId], ['terminal', '=', $terminal]])->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);
|
||||
}
|
||||
|
||||
}
|
||||
298
app/api/validate/FinanceValidate.php
Normal file
298
app/api/validate/FinanceValidate.php
Normal file
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\service\{ConfigService,UtilsService};
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\setting\RechargeMethod;
|
||||
use app\common\model\withdraw\WithdrawWallet;
|
||||
use app\common\model\withdraw\WithdrawMethod;
|
||||
use app\common\model\withdraw\WithdrawBank;
|
||||
use app\common\model\finance\{WithdrawRecord};
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\member\UserMember;
|
||||
use app\common\model\lh\{LhRecord};
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 资金验证器
|
||||
* Class FinanceValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class FinanceValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'account' => '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;
|
||||
}
|
||||
|
||||
}
|
||||
115
app/api/validate/ItemValidate.php
Normal file
115
app/api/validate/ItemValidate.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\item\{Item,ItemRecord};
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\{UtilsService};
|
||||
use app\common\model\member\UserMember;
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 项目验证器
|
||||
* Class ItemValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class ItemValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'invest' => '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;
|
||||
}
|
||||
|
||||
}
|
||||
57
app/api/validate/LanguagePagValidate.php
Normal file
57
app/api/validate/LanguagePagValidate.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 语言包验证器
|
||||
* Class LanguagePagValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class LanguagePagValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'lang' => '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']);
|
||||
}
|
||||
|
||||
}
|
||||
56
app/api/validate/LanguageValidate.php
Normal file
56
app/api/validate/LanguageValidate.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 语言包验证器
|
||||
* Class LanguageValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class LanguageValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'name' => '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']);
|
||||
}
|
||||
|
||||
}
|
||||
108
app/api/validate/LoginAccountValidate.php
Normal file
108
app/api/validate/LoginAccountValidate.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use app\common\enum\LoginEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\sms\SmsDriver;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 账号密码登录校验
|
||||
* Class LoginValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class LoginAccountValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'terminal' => '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;
|
||||
}
|
||||
}
|
||||
134
app/api/validate/MallValidate.php
Normal file
134
app/api/validate/MallValidate.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\mall\{MallGoods,MallGoodsRecord};
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\{UtilsService};
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 积分奖品验证器
|
||||
* Class MallValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class MallValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'buy' => '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;
|
||||
}
|
||||
|
||||
}
|
||||
197
app/api/validate/PasswordValidate.php
Normal file
197
app/api/validate/PasswordValidate.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\user\{User,UserInfo};
|
||||
use app\common\service\{ConfigService,UtilsService};
|
||||
use app\common\model\notice\EmailRecord;
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
|
||||
/**
|
||||
* 密码校验
|
||||
* Class PasswordValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class PasswordValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'mobile' => '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;
|
||||
}
|
||||
|
||||
}
|
||||
90
app/api/validate/RechargeValidate.php
Normal file
90
app/api/validate/RechargeValidate.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\setting\RechargeMethod;
|
||||
use app\common\model\finance\{RechargeRecord};
|
||||
|
||||
/**
|
||||
* 用户验证器
|
||||
* Class RechargeValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class RechargeValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'money' => '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;
|
||||
}
|
||||
|
||||
}
|
||||
98
app/api/validate/RegisterValidate.php
Normal file
98
app/api/validate/RegisterValidate.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\model\user\User;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
|
||||
/**
|
||||
* 注册验证器
|
||||
* Class RegisterValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class RegisterValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $regex = [
|
||||
'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|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;
|
||||
}
|
||||
}
|
||||
82
app/api/validate/RobotValidate.php
Normal file
82
app/api/validate/RobotValidate.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\member\UserMember;
|
||||
use app\common\model\lh\{LhRecord};
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\{UtilsService};
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 资金验证器
|
||||
* Class RobotValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class RobotValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'buy' => '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;
|
||||
}
|
||||
|
||||
}
|
||||
39
app/api/validate/SendSmsValidate.php
Normal file
39
app/api/validate/SendSmsValidate.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 短信验证
|
||||
* Class SmsValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class SendSmsValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'mobile' => 'require',
|
||||
'scene' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'mobile.require' => 'captcha.mobileEmpty',//请输入手机号
|
||||
// 'mobile.mobile' => '请输入正确手机号',
|
||||
'scene.require' => 'network.parameterAbnormality',//请输入场景值
|
||||
];
|
||||
}
|
||||
63
app/api/validate/SetUserInfoValidate.php
Normal file
63
app/api/validate/SetUserInfoValidate.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\model\user\User;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 设置用户信息验证
|
||||
* Class SetUserInfoValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class SetUserInfoValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'field' => '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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
104
app/api/validate/UserMemberValidate.php
Normal file
104
app/api/validate/UserMemberValidate.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\member\{UserMember,UserMemberRecord};
|
||||
use app\common\model\user\User;
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use app\common\service\{UtilsService};
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 资金验证器
|
||||
* Class UserMemberValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class UserMemberValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => '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;
|
||||
}
|
||||
|
||||
}
|
||||
203
app/api/validate/UserValidate.php
Normal file
203
app/api/validate/UserValidate.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\user\{User,UserInfo,UserSigninRecord};
|
||||
|
||||
/**
|
||||
* 用户验证器
|
||||
* Class UserValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class UserValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'code' => '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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user