first commit

This commit is contained in:
Your Name
2026-01-19 14:19:22 +08:00
commit fe2d9c1868
4777 changed files with 665503 additions and 0 deletions

View 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
// +----------------------------------------------------------------------
namespace app\common\cache;
/**
* //后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
* Class AdminAccountSafeCache
* @package app\common\cache
*/
class AdminAccountSafeCache extends BaseCache
{
private $key;//缓存次数名称
public $minute = 30;//缓存设置为30分钟即密码错误次数达到锁定30分钟
public $count = 5; //设置连续输错次数即30分钟内连续输错误5次后锁定
public function __construct()
{
parent::__construct();
$ip = \request()->ip();
$this->key = $this->tagName . $ip;
}
/**
* @notes 记录登录错误次数
* @author 令狐冲
* @date 2021/6/30 01:51
*/
public function record()
{
if ($this->get($this->key)) {
//缓存存在,记录错误次数
$this->inc($this->key, 1);
} else {
//缓存不存在,第一次设置缓存
$this->set($this->key, 1, $this->minute * 60);
}
}
/**
* @notes 判断是否安全
* @return bool
* @author 令狐冲
* @date 2021/6/30 01:53
*/
public function isSafe()
{
$count = $this->get($this->key);
if ($count >= $this->count) {
return false;
}
return true;
}
/**
* @notes 删除该ip记录错误次数
* @author 令狐冲
* @date 2021/6/30 01:55
*/
public function relieve()
{
$this->delete($this->key);
}
}

122
app/common/cache/AdminAuthCache.php vendored Normal file
View File

@@ -0,0 +1,122 @@
<?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\common\cache;
use app\adminapi\logic\auth\AuthLogic;
/**
* 管理员权限缓存
* Class AdminAuthCache
* @package app\common\cache
*/
class AdminAuthCache extends BaseCache
{
private $prefix = 'admin_auth_';
private $authConfigList = [];
private $cacheMd5Key = ''; //权限文件MD5的key
private $cacheAllKey = ''; //全部权限的key
private $cacheUrlKey = ''; //管理员的url缓存key
private $authMd5 = ''; //权限文件MD5的值
private $adminId = '';
public function __construct($adminId = '')
{
parent::__construct();
$this->adminId = $adminId;
// 全部权限
$this->authConfigList = AuthLogic::getAllAuth();
// 当前权限配置文件的md5
$this->authMd5 = md5(json_encode($this->authConfigList));
$this->cacheMd5Key = $this->prefix . 'md5';
$this->cacheAllKey = $this->prefix . 'all';
$this->cacheUrlKey = $this->prefix . 'url_' . $this->adminId;
$cacheAuthMd5 = $this->get($this->cacheMd5Key);
$cacheAuth = $this->get($this->cacheAllKey);
//权限配置和缓存权限对比,不一样说明权限配置文件已修改,清理缓存
if ($this->authMd5 !== $cacheAuthMd5 || empty($cacheAuth)) {
$this->deleteTag();
}
}
/**
* @notes 获取管理权限uri
* @param $adminId
* @return array|mixed
* @author 令狐冲
* @date 2021/8/19 15:27
*/
public function getAdminUri()
{
//从缓存获取,直接返回
$urisAuth = $this->get($this->cacheUrlKey);
if ($urisAuth) {
return $urisAuth;
}
//获取角色关联的菜单id(菜单或权限)
$urisAuth = AuthLogic::getAuthByAdminId($this->adminId);
if (empty($urisAuth)) {
return [];
}
$this->set($this->cacheUrlKey, $urisAuth, 3600);
//保存到缓存并读取返回
return $urisAuth;
}
/**
* @notes 获取全部权限uri
* @return array|mixed
* @author cjhao
* @date 2021/9/13 11:41
*/
public function getAllUri()
{
$cacheAuth = $this->get($this->cacheAllKey);
if ($cacheAuth) {
return $cacheAuth;
}
// 获取全部权限
$authList = AuthLogic::getAllAuth();
//保存到缓存并读取返回
$this->set($this->cacheMd5Key, $this->authMd5);
$this->set($this->cacheAllKey, $authList);
return $authList;
}
/**
* @notes 清理管理员缓存
* @return bool
* @author cjhao
* @date 2021/10/13 18:47
*/
public function clearAuthCache()
{
$this->clear($this->cacheUrlKey);
return true;
}
}

118
app/common/cache/AdminTokenCache.php vendored Normal file
View File

@@ -0,0 +1,118 @@
<?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\common\cache;
use app\common\model\auth\Admin;
use app\common\model\auth\AdminSession;
use app\common\model\auth\SystemRole;
/**
* 管理员token缓存
* Class AdminTokenCache
* @package app\common\cache
*/
class AdminTokenCache extends BaseCache
{
private $prefix = 'token_admin_';
/**
* @notes 通过token获取缓存管理员信息
* @param $token
* @return false|mixed
* @author 令狐冲
* @date 2021/6/30 16:57
*/
public function getAdminInfo($token)
{
//直接从缓存获取
$adminInfo = $this->get($this->prefix . $token);
if ($adminInfo) {
return $adminInfo;
}
//从数据获取信息被设置缓存(可能后台清除缓存)
$adminInfo = $this->setAdminInfo($token);
if ($adminInfo) {
return $adminInfo;
}
return false;
}
/**
* @notes 通过有效token设置管理信息缓存
* @param $token
* @return array|false|mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 令狐冲
* @date 2021/7/5 12:12
*/
public function setAdminInfo($token)
{
$adminSession = AdminSession::where([['token', '=', $token], ['expire_time', '>', time()]])
->find();
if (empty($adminSession)) {
return [];
}
$admin = Admin::where('id', '=', $adminSession->admin_id)
->append(['role_id'])
->find();
$roleName = '';
$roleLists = SystemRole::column('name', 'id');
if ($admin['root'] == 1) {
$roleName = '系统管理员';
} else {
foreach ($admin['role_id'] as $roleId) {
$roleName .= $roleLists[$roleId] ?? '';
$roleName .= '/';
}
$roleName = trim($roleName, '/');
}
$adminInfo = [
'admin_id' => $admin->id,
'root' => $admin->root,
'name' => $admin->name,
'account' => $admin->account,
'role_name' => $roleName,
'role_id' => $admin->role_id,
'token' => $token,
'terminal' => $adminSession->terminal,
'expire_time' => $adminSession->expire_time,
];
$this->set($this->prefix . $token, $adminInfo, new \DateTime(Date('Y-m-d H:i:s', $adminSession->expire_time)));
return $this->getAdminInfo($token);
}
/**
* @notes 删除缓存
* @param $token
* @return bool
* @author 令狐冲
* @date 2021/7/3 16:57
*/
public function deleteAdminInfo($token)
{
return $this->delete($this->prefix . $token);
}
}

68
app/common/cache/BaseCache.php vendored Normal file
View File

@@ -0,0 +1,68 @@
<?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\common\cache;
use think\App;
use think\Cache;
/**
* 缓存基础类,用于管理缓存
* Class BaseCache
* @package app\common\cache
*/
abstract class BaseCache extends Cache
{
/**
* 缓存标签
* @var string
*/
protected $tagName;
public function __construct()
{
parent::__construct(app());
$this->tagName = get_class($this);
}
/**
* @notes 重写父类set自动打上标签
* @param string $key
* @param mixed $value
* @param null $ttl
* @return bool
* @author 段誉
* @date 2021/12/27 14:16
*/
public function set($key, $value, $ttl = null): bool
{
return $this->store()->tag($this->tagName)->set($key, $value, $ttl);
}
/**
* @notes 清除缓存类所有缓存
* @return bool
* @author 段誉
* @date 2021/12/27 14:16
*/
public function deleteTag(): bool
{
return $this->tag($this->tagName)->clear();
}
}

70
app/common/cache/ExportCache.php vendored Normal file
View File

@@ -0,0 +1,70 @@
<?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\common\cache;
class ExportCache extends BaseCache
{
protected $uniqid = '';
public function __construct()
{
parent::__construct();
//以微秒计的当前时间,生成一个唯一的 ID,以tagname为前缀
$this->uniqid = md5(uniqid($this->tagName,true).mt_rand());
}
/**
* @notes 获取excel缓存目录
* @return string
* @author 令狐冲
* @date 2021/7/28 17:36
*/
public function getSrc()
{
return app()->getRootPath() . 'runtime/file/export/'.date('Y-m').'/'.$this->uniqid.'/';
}
/**
* @notes 设置文件路径缓存地址
* @param $fileName
* @return string
* @author 令狐冲
* @date 2021/7/28 17:36
*/
public function setFile($fileName)
{
$src = $this->getSrc();
$key = md5($src . $fileName) . time();
$this->set($key, ['src' => $src, 'name' => $fileName], 300);
return $key;
}
/**
* @notes 获取文件缓存的路径
* @param $key
* @return mixed
* @author 令狐冲
* @date 2021/7/26 18:36
*/
public function getFile($key)
{
return $this->get($key);
}
}

View 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
// +----------------------------------------------------------------------
namespace app\common\cache;
/**
* //后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
* Class AdminAccountSafeCache
* @package app\common\cache
*/
class UserAccountSafeCache extends BaseCache
{
private $key;//缓存次数名称
public $minute = 30;//缓存设置为15分钟即密码错误次数达到锁定30分钟
public $count = 5; //设置连续输错次数即15分钟内连续输错误5次后锁定
public function __construct()
{
parent::__construct();
$ip = \request()->ip();
$this->key = $this->tagName . $ip;
}
/**
* @notes 记录登录错误次数
* @author 令狐冲
* @date 2021/6/30 01:51
*/
public function record()
{
if ($this->get($this->key)) {
//缓存存在,记录错误次数
$this->inc($this->key, 1);
} else {
//缓存不存在,第一次设置缓存
$this->set($this->key, 1, $this->minute * 60);
}
}
/**
* @notes 判断是否安全
* @return bool
* @author 令狐冲
* @date 2021/6/30 01:53
*/
public function isSafe()
{
$count = $this->get($this->key);
if ($count >= $this->count) {
return false;
}
return true;
}
/**
* @notes 删除该ip记录错误次数
* @author 令狐冲
* @date 2021/6/30 01:55
*/
public function relieve()
{
$this->delete($this->key);
}
}

105
app/common/cache/UserTokenCache.php vendored Normal file
View File

@@ -0,0 +1,105 @@
<?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\common\cache;
use app\common\model\user\User;
use app\common\model\user\UserSession;
class UserTokenCache extends BaseCache
{
private $prefix = 'token_user_';
/**
* @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:11
*/
public function getUserInfo($token)
{
//直接从缓存获取
$userInfo = $this->get($this->prefix . $token);
if ($userInfo) {
return $userInfo;
}
//从数据获取信息被设置缓存(可能后台清除缓存)
$userInfo = $this->setUserInfo($token);
if ($userInfo) {
return $userInfo;
}
return false;
}
/**
* @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:11
*/
public function setUserInfo($token)
{
$userSession = UserSession::where([['token', '=', $token], ['expire_time', '>', time()]])->find();
if (empty($userSession)) {
return [];
}
$user = User::where('id', '=', $userSession->user_id)
->find();
$userInfo = [
'user_id' => $user->id,
'nickname' => $user->nickname,
'token' => $token,
'sn' => $user->sn,
'mobile' => $user->mobile,
'avatar' => $user->avatar,
'terminal' => $userSession->terminal,
'expire_time' => $userSession->expire_time,
];
$ttl = new \DateTime(Date('Y-m-d H:i:s', $userSession->expire_time));
$this->set($this->prefix . $token, $userInfo, $ttl);
return $this->getUserInfo($token);
}
/**
* @notes 删除缓存
* @param $token
* @return bool
* @author 段誉
* @date 2022/9/16 10:13
*/
public function deleteUserInfo($token)
{
return $this->delete($this->prefix . $token);
}
}

View 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\common\command;
use app\common\enum\CrontabEnum;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use Cron\CronExpression;
use think\facade\Console;
use app\common\model\Crontab as CrontabModel;
/**
* 定时任务
* Class Crontab
* @package app\command
*/
class Crontab extends Command
{
protected function configure()
{
$this->setName('crontab')
->setDescription('定时任务');
}
protected function execute(Input $input, Output $output)
{
$lists = CrontabModel::where('status', CrontabEnum::START)->select()->toArray();
if (empty($lists)) {
return false;
}
foreach ($lists as $item) {
$nextTime = (new CronExpression($item['expression']))
->getNextRunDate($item['last_time'])
->getTimestamp();
if ($nextTime > time()) {
// 未到时间,不执行
continue;
}
// 开始执行
self::start($item);
}
}
public static function start($item)
{
// 开始执行
$startTime = microtime(true);
try {
$params = explode(' ', $item['params']);
if (is_array($params) && !empty($item['params'])) {
Console::call($item['command'], $params);
} else {
Console::call($item['command']);
}
// 清除错误信息
CrontabModel::where('id', $item['id'])->update(['error' => '']);
} catch (\Exception $e) {
// 记录错误信息
CrontabModel::where('id', $item['id'])->update([
'error' => $e->getMessage(),
'status' => CrontabEnum::ERROR
]);
} finally {
$endTime = microtime(true);
// 本次执行时间
$useTime = round(($endTime - $startTime), 2);
// 最大执行时间
$maxTime = max($useTime, $item['max_time']);
// 更新最后执行时间
CrontabModel::where('id', $item['id'])->update([
'last_time' => time(),
'time' => $useTime,
'max_time' => $maxTime
]);
}
}
}

View File

@@ -0,0 +1,147 @@
<?php
namespace app\common\command;
use app\common\service\{UtilsService};
use app\common\model\finance\UserFinance;
use app\common\model\item\ItemRecord;
use think\console\{Command,Output,Input};
use think\facade\{Db,Log};
class InvestSettle extends Command
{
protected function configure()
{
$this->setName('invest_settle')
->setDescription('投资结算');
}
protected function execute(Input $input, Output $output)
{
Db::startTrans();
try {
$nowTime = time();
//每日/时付息,到期还本
$lists1 = ItemRecord::where(['status' => 1])
->where("type IN (1,4)")
->order(['create_time' => 'desc','id' => 'desc'])
->select()
->toArray();
foreach ($lists1 as &$item) {
//判断返还时间
$return_num = $item['wait_num'] - 1;
$return_time = $item['end_time'] - ($return_num * 24 * 60 * 60);
if($item['type'] == 4 ) $return_time = $item['end_time'] - ($return_num * 1 * 60 * 60);
if($return_time > $nowTime) continue;
$status = 1;
//最后一期,返还本金
if($return_num == 0){
$status = 2;//完成
//本金返回
//记录日志
UtilsService::user_finance_add(
$item['user_id'],
18,
1,
$item['money'],
$item['sn'],
''
);
//用户资金修改
UtilsService::user_money_change($item['user_id'], 1, $item['money'],'user_money');
}
ItemRecord::update([
'id' => $item['id'],
'wait_num' => $return_num,
'status' => $status //状态1进行中2已完成
]);
//利息返还
$money_rate = round($item['money'] * $item['rate'] / 100 , 2);
if($money_rate > 0.01){
//记录日志
UtilsService::user_finance_add(
$item['user_id'],
17,
1,
$money_rate,
$item['sn'],
''
);
//用户资金修改
UtilsService::user_money_change($item['user_id'], 1, $money_rate,'user_money');
UtilsService::user_money_change($item['user_id'], 1, $money_rate,'total_income_invest');
//团队收益奖励
UtilsService::team_reward_add($item['user_id'],$money_rate,2);
}
}
// //到期还本付息
// $lists2 = ItemRecord::where(['status' => 1])
// ->where("end_time <= $nowTime")
// ->where("type IN (2,3)")
// ->order(['create_time' => 'desc','id' => 'desc'])
// ->select()
// ->toArray();
// foreach ($lists2 as &$item) {
// ItemRecord::update([
// 'id' => $item['id'],
// 'wait_num' => 0,
// 'status' => 2 //状态1进行中2已完成
// ]);
// //本金返回
// //记录日志
// UtilsService::user_finance_add(
// $item['user_id'],
// 18,
// 1,
// $item['money'],
// $item['sn'],
// ''
// );
// //用户资金修改
// UtilsService::user_money_change($item['user_id'], 1, $item['money'],'user_money');
// //利息返还
// if($item['total_income'] > 0.01){
// //记录日志
// UtilsService::user_finance_add(
// $item['user_id'],
// 17,
// 1,
// $item['total_income'],
// $item['sn'],
// ''
// );
// //用户资金修改
// UtilsService::user_money_change($item['user_id'], 1, $item['total_income'],'user_money');
// UtilsService::user_money_change($item['user_id'], 1, $item['total_income'],'total_income_invest');
// //团队收益奖励
// UtilsService::team_reward_add($item['user_id'],$item['total_income'],2);
// }
// }
Db::commit();
} catch (\Exception $e) {
Db::rollback();
Log::write('失败原因:' . $e->getMessage());
return false;
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace app\common\command;
use app\common\model\item\Item;
use think\console\{Command,Output,Input};
use think\facade\{Db,Log};
class ItemProgress extends Command
{
protected function configure()
{
$this->setName('item_progress')
->setDescription('项目进度自增');
}
protected function execute(Input $input, Output $output)
{
Db::startTrans();
try {
$items = Item::where(['is_show' => 1])
->order(['create_time' => 'desc'])
->select()
->toArray();
foreach ($items as &$item) {
if($item['progress'] >= 100) continue;
$item['progress'] = $item['progress'] + $item['progress_auto'];
Item::update([
'id' => $item['id'],
'progress' => $item['progress'],
]);
}
Db::commit();
} catch (\Exception $e) {
Db::rollback();
Log::write('失败原因:' . $e->getMessage());
return false;
}
}
}

View File

@@ -0,0 +1,134 @@
<?php
namespace app\common\command;
use app\common\service\{ConfigService,UtilsService};
use app\common\model\user\{User,UserTron};
use app\common\model\finance\RechargeRecord;
use app\common\model\setting\RechargeMethod;
use think\console\{Command,Output,Input};
use think\facade\{Db,Log};
class TronOrder extends Command
{
protected function configure()
{
$this->setName('tron_order')
->setDescription('同步波场钱包余额');
}
protected function execute(Input $input, Output $output)
{
Db::startTrans();
try {
//为了性能只获取最后操作时间5分钟内的钱包
$now_5 = time() - 5 * 60;//5分钟前
$userTrons = UserTron::where("last_time > $now_5")
->order(['create_time' => 'desc'])
->select()
->toArray();
//查询余额
$data = [
'action' => 'infos',
];
$addrs = array();
foreach ($userTrons as $key=>$userTron) {
$addrs[$key] = $userTron['address'];
}
if(count($addrs) > 0){
$data['addrs'] = json_encode($addrs);
$response = UtilsService::usdt_request($data, 'POST');
$response = json_decode($response, true);
if($response['code'] == 200){
foreach ($response['data']['data'] as $res) {
UserTron::where(['address' => $res['addr']])
->update([
'money_trx' => $res['trx'],
'money_usdt' => $res['usdt'],
]);
//充值逻辑
foreach ($userTrons as $userTron) {
if($userTron['address'] == $res['addr']){
//金额相差超过0.01才生效
if(floatval($res['usdt']) - floatval($userTron['money_usdt']) >= 0.01){
$method = RechargeMethod::where(['id' => $userTron['method_id']])->findOrEmpty();
if(!$method->isEmpty()){
$money = $res['usdt'] - $userTron['money_usdt'];
$order_amount_act = round($money * $method['rate'] , 2);
//判断充值金额
$config = ConfigService::get('website', 'trade');
if ($order_amount_act >= $config['recharge_min']) {
$data = [
'sn' => generate_sn(RechargeRecord::class, 'sn'),
'user_id' => $userTron['user_id'],
'method_id' => $userTron['method_id'],
'amount' => $order_amount_act,
'amount_act' => round($money , $method['precision']),
'rate' => $method['rate'],
'symbol' => $method['symbol'],
'status' => 1,
];
$record = RechargeRecord::create($data);
//记录日志
UtilsService::user_finance_add(
$userTron['user_id'],
1,
1,
$data['amount'],
'',
'',
1//冻结
);
//用户资金修改
UtilsService::user_money_change($userTron['user_id'], 1, $data['amount'],'user_money');
//充值金额增加
UtilsService::user_money_change($userTron['user_id'], 1, $data['amount'],'total_recharge');
//充值活动奖励
UtilsService::activity_reward_add($userTron['user_id'],$data['amount']);
//更新充值记录用户余额
$user = User::where(['id' => $record['user_id']])->findOrEmpty();
if (!$user->isEmpty()) {
RechargeRecord::update([
'id' => $record['id'],
'user_money' => $user['user_money']
]);
//充值次数+1
User::update([
'id' => $user['id'],
'recharge_num' => $user['recharge_num'] + 1
]);
}
}
}
}
}
}
}
}
}
Db::commit();
} catch (\Exception $e) {
Db::rollback();
Log::write('失败原因:' . $e->getMessage());
return false;
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace app\common\command;
use app\common\model\finance\UserFinance;
use think\console\{Command,Output,Input};
use think\facade\{Db,Log};
class UnfreezeFunds extends Command
{
protected function configure()
{
$this->setName('unfreeze_funds')
->setDescription('用户资金释放');
}
protected function execute(Input $input, Output $output)
{
Db::startTrans();
try {
$nowTime = time();
$lists = UserFinance::where(['frozen' => 1])
->where("thaw_time < $nowTime")
->order(['id' => 'desc'])
->select()
->toArray();
foreach ($lists as &$item) {
UserFinance::update([
'id' => $item['id'],
'frozen' => 0,
]);
}
Db::commit();
} catch (\Exception $e) {
Db::rollback();
Log::write('失败原因:' . $e->getMessage());
return false;
}
}
}

View File

@@ -0,0 +1,121 @@
<?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\common\controller;
use app\BaseController;
use app\common\lists\BaseDataLists;
use app\common\service\JsonService;
use think\facade\App;
/**
* 控制器基类
* Class BaseLikeAdminController
* @package app\common\controller
*/
class BaseLikeAdminController extends BaseController
{
public array $notNeedLogin = [];
/**
* @notes 操作成功
* @param string $msg
* @param array $data
* @param int $code
* @param int $show
* @return \think\response\Json
* @author 段誉
* @date 2021/12/27 14:21
*/
protected function success(string $msg = 'success', array $data = [], int $code = 1, int $show = 0)
{
return JsonService::success($msg, $data, $code, $show);
}
/**
* @notes 数据返回
* @param $data
* @return \think\response\Json
* @author 段誉
* @date 2021/12/27 14:21\
*/
protected function data($data)
{
return JsonService::data($data);
}
/**
* @notes 列表数据返回
* @param \app\common\lists\BaseDataLists|null $lists
* @return \think\response\Json
* @author 令狐冲
* @date 2021/7/8 00:40
*/
protected function dataLists(BaseDataLists $lists = null)
{
//列表类和控制器一一对应,"app/应用/controller/控制器的方法" =》"app\应用\lists\"目录下
//(例如:"app/adminapi/controller/auth/AdminController.php的lists()方法" =》 "app/adminapi/lists/auth/AminLists.php")
//当对象为空时,自动创建列表对象
if (is_null($lists)) {
$listName = str_replace('.', '\\', App::getNamespace() . '\\lists\\' . $this->request->controller() . ucwords($this->request->action()));
$lists = invoke($listName);
}
return JsonService::dataLists($lists);
}
/**
* @notes 操作失败
* @param string $msg
* @param array $data
* @param int $code
* @param int $show
* @return \think\response\Json
* @author 段誉
* @date 2021/12/27 14:21
*/
protected function fail(string $msg = 'fail', array $data = [], int $code = 0, int $show = 1)
{
return JsonService::fail($msg, $data, $code, $show);
}
/**
* @notes 是否免登录验证
* @return bool
* @author 段誉
* @date 2021/12/27 14:21
*/
public function isNotNeedLogin() : bool
{
$notNeedLogin = $this->notNeedLogin;
if (empty($notNeedLogin)) {
return false;
}
$action = $this->request->action();
if (!in_array(trim($action), $notNeedLogin)) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,28 @@
<?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\common\enum;
/**
* 管理后台登录终端
* Class terminalEnum
* @package app\common\enum
*/
class AdminTerminalEnum
{
const PC = 1;
const MOBILE = 2;
}

View 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\common\enum;
/**
* 定时任务枚举
* Class CrontabEnum
* @package app\common\enum
*/
class CrontabEnum
{
/**
* 类型
* CRONTAB 定时任务
*/
const CRONTAB = 1;
const DAEMON = 2;
/**
* 定时任务状态
*/
const START = 1;
const STOP = 2;
const ERROR = 3;
}

View 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\common\enum;
class DefaultEnum
{
//默认排序
const SORT = 50;
//显示隐藏
const HIDE = 0;//隐藏
const SHOW = 1;//显示
//性别
const UNKNOWN = 0;//未知
const MAN = 1;//男
const WOMAN = 2;//女
//属性
const SYSTEM = 1;//系统默认
const CUSTOM = 2;//自定义
/**
* @notes 获取显示状态
* @param bool $value
* @return string|string[]
* @author ljj
* @date 2022/2/8 3:56 下午
*/
public static function getShowDesc($value = true)
{
$data = [
self::HIDE => '隐藏',
self::SHOW => '显示'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
/**
* @notes 启用状态
* @param bool $value
* @return string|string[]
* @author ljj
* @date 2022/2/14 4:02 下午
*/
public static function getEnableDesc($value = true)
{
$data = [
self::HIDE => '停用',
self::SHOW => '启用'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
/**
* @notes 性别
* @param bool $value
* @return string|string[]
* @author ljj
* @date 2022/2/10 11:40 上午
*/
public static function getSexDesc($value = true)
{
$data = [
self::UNKNOWN => '未知',
self::MAN => '男',
self::WOMAN => '女'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
/**
* @notes 属性
* @param bool $value
* @return string|string[]
* @author ljj
* @date 2022/2/14 4:41 下午
*/
public static function getAttrDesc($value = true)
{
$data = [
self::SYSTEM => '系统默认',
self::CUSTOM => '自定义'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
/**
* @notes 是否推荐
* @param bool $value
* @return string|string[]
* @author ljj
* @date 2022/2/23 3:30 下午
*/
public static function getRecommendDesc($value = true)
{
$data = [
self::HIDE => '不推荐',
self::SHOW => '推荐'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace app\common\enum;
class ExportEnum
{
//获取导出信息
const INFO = 1;
//导出excel
const EXPORT = 2;
}

View File

@@ -0,0 +1,30 @@
<?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\common\enum;
class FileEnum
{
// 图片类型
const IMAGE_TYPE = 10; // 图片类型
const VIDEO_TYPE = 20; // 视频类型
const FILE_TYPE = 30; // 文件类型
// 图片来源
const SOURCE_ADMIN = 0; // 后台
const SOURCE_USER = 1; // 用户
}

View 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\common\enum;
class GeneratorEnum
{
// 模板类型
const TEMPLATE_TYPE_SINGLE = 0;// 单表
const TEMPLATE_TYPE_TREE = 1; // 树表
// 生成方式
const GENERATE_TYPE_ZIP = 0; // 压缩包下载
const GENERATE_TYPE_MODULE = 1; // 生成到模块
// 删除方式
const DELETE_TRUE = 0; // 真实删除
const DELETE_SOFT = 1; // 软删除
// 删除字段名 (默认名称)
const DELETE_NAME = 'delete_time';
// 菜单创建类型
const GEN_SELF = 0; // 手动添加
const GEN_AUTO = 1; // 自动添加
// 关联模型类型relations
const RELATION_HAS_ONE = 'has_one';
const RELATION_HAS_MANY = 'has_many';
/**
* @notes 获取模板类型描述
* @param bool $value
* @return string|string[]
* @author 段誉
* @date 2022/6/14 11:24
*/
public static function getTemplateTypeDesc($value = true)
{
$data = [
self::TEMPLATE_TYPE_SINGLE => '单表(增删改查)',
self::TEMPLATE_TYPE_TREE => '树表(增删改查)',
];
if ($value === true) {
return $data;
}
return $data[$value] ?? '';
}
}

View File

@@ -0,0 +1,32 @@
<?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\common\enum;
/**
* 登录枚举
* Class LoginEnum
* @package app\common\enum
*/
class LoginEnum
{
/**
* 支持的登录方式
* ACCOUNT_PASSWORD 账号/手机号密码登录
* MOBILE_CAPTCHA 手机验证码登录
* THIRD_LOGIN 第三方登录
*/
const ACCOUNT_PASSWORD = 1;
const MOBILE_CAPTCHA = 2;
const THIRD_LOGIN = 3;
}

View File

@@ -0,0 +1,60 @@
<?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\common\enum;
class MenuEnum
{
//商城页面
const SHOP_PAGE = [
[
'index' => 1,
'name' => '首页',
'path' => '/pages/index/index',
'params' => [],
'type' => 'shop',
],
];
//菜单类型
const NAVIGATION_HOME = 1;//首页导航
const NAVIGATION_PERSONAL = 2;//个人中心
//链接类型
const LINK_SHOP = 1;//商城页面
const LINK_CATEGORY = 2;//分类页面
const LINK_CUSTOM = 3;//自定义链接
/**
* @notes 链接类型
* @param bool $value
* @return string|string[]
* @author ljj
* @date 2022/2/14 12:14 下午
*/
public static function getLinkDesc($value = true)
{
$data = [
self::LINK_SHOP => '商城页面',
self::LINK_CATEGORY => '分类页面',
self::LINK_CUSTOM => '自定义链接'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
}

View 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\common\enum;
/**
* 微信公众号枚举
* Class OfficialAccountEnum
* @package app\common\enum
*/
class OfficialAccountEnum
{
/**
* 菜单类型
* click - 关键字
* view - 跳转网页链接
* miniprogram - 小程序
*/
const MENU_TYPE = ['click', 'view', 'miniprogram'];
/**
* 关注回复
*/
const REPLY_TYPE_FOLLOW = 1;
/**
* 关键字回复
*/
const REPLY_TYPE_KEYWORD = 2;
/**
* 默认回复
*/
const REPLY_TYPE_DEFAULT= 3;
/**
* 回复类型
* follow - 关注回复
* keyword - 关键字回复
* default - 默认回复
*/
const REPLY_TYPE = [
self::REPLY_TYPE_FOLLOW => 'follow',
self::REPLY_TYPE_KEYWORD => 'keyword',
self::REPLY_TYPE_DEFAULT => 'default'
];
/**
* 匹配类型 - 全匹配
*/
const MATCHING_TYPE_FULL = 1;
/**
* 匹配类型 - 模糊匹配
*/
const MATCHING_TYPE_FUZZY = 2;
/**
* 消息类型 - 事件
*/
const MSG_TYPE_EVENT = 'event';
/**
* 消息类型 - 文本
*/
const MSG_TYPE_TEXT = 'text';
/**
* 事件类型 - 关注
*/
const EVENT_SUBSCRIBE = 'subscribe';
/**
* @notes 获取类型英文名称
* @param $type
* @return string
* @author Tab
* @date 2021/7/29 16:32
*/
public static function getReplyType($type)
{
return self::REPLY_TYPE[$type] ?? '';
}
}

View 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\common\enum;
/**
* 通过枚举类,枚举只有两个值的时候使用
* Class YesNoEnum
* @package app\common\enum
*/
class YesNoEnum
{
const YES = 1;
const NO = 0;
/**
* @notes 获取禁用状态
* @param bool $value
* @return string|string[]
* @author 令狐冲
* @date 2021/7/8 19:02
*/
public static function getDisableDesc($value = true)
{
$data = [
self::YES => '禁用',
self::NO => '正常'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
}

View File

@@ -0,0 +1,272 @@
<?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\common\enum\notice;
/**
* 通知枚举
* Class NoticeEnum
* @package app\common\enum
*/
class NoticeEnum
{
/**
* 通知类型
*/
const SYSTEM = 1;
const SMS = 2;
const OA = 3;
const MNP = 4;
/**
* 短信验证码场景
*/
const LOGIN_CAPTCHA = 101;
const BIND_MOBILE_CAPTCHA = 102;
const CHANGE_MOBILE_CAPTCHA = 103;
const FIND_LOGIN_PASSWORD_CAPTCHA = 104;
/**
* 验证码场景
*/
const SMS_SCENE = [
self::LOGIN_CAPTCHA,
self::BIND_MOBILE_CAPTCHA,
self::CHANGE_MOBILE_CAPTCHA,
self::FIND_LOGIN_PASSWORD_CAPTCHA,
];
//通知类型
const BUSINESS_NOTIFICATION = 1;//业务通知
const VERIFICATION_CODE = 2;//验证码
/**
* @notes 通知类型
* @param bool $value
* @return string|string[]
* @author ljj
* @date 2022/2/17 2:49 下午
*/
public static function getTypeDesc($value = true)
{
$data = [
self::BUSINESS_NOTIFICATION => '业务通知',
self::VERIFICATION_CODE => '验证码'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
/**
* @notes 获取场景描述
* @param $sceneId
* @param false $flag
* @return string|string[]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getSceneDesc($sceneId, $flag = false)
{
$desc = [
self::LOGIN_CAPTCHA => '登录验证码',
self::BIND_MOBILE_CAPTCHA => '绑定手机验证码',
self::CHANGE_MOBILE_CAPTCHA => '变更手机验证码',
self::FIND_LOGIN_PASSWORD_CAPTCHA => '找回登录密码验证码',
];
if ($flag) {
return $desc;
}
return $desc[$sceneId] ?? '';
}
/**
* @notes 更具标记获取场景
* @param $tag
* @return int|string
* @author 段誉
* @date 2022/9/15 15:08
*/
public static function getSceneByTag($tag)
{
$scene = [
// 手机验证码登录
'YZMDL' => self::LOGIN_CAPTCHA,
// 绑定手机号验证码
'BDSJHM' => self::BIND_MOBILE_CAPTCHA,
// 变更手机号验证码
'BGSJHM' => self::CHANGE_MOBILE_CAPTCHA,
// 找回登录密码
'ZHDLMM' => self::FIND_LOGIN_PASSWORD_CAPTCHA,
];
return $scene[$tag] ?? '';
}
/**
* @notes 获取场景变量
* @param $sceneId
* @param false $flag
* @return array|string[]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getVars($sceneId, $flag = false)
{
$desc = [
self::LOGIN_CAPTCHA => '验证码:code',
self::BIND_MOBILE_CAPTCHA => '验证码:code',
self::CHANGE_MOBILE_CAPTCHA => '验证码:code',
self::FIND_LOGIN_PASSWORD_CAPTCHA => '验证码:code',
];
if ($flag) {
return $desc;
}
return isset($desc[$sceneId]) ? ['可选变量 ' . $desc[$sceneId]] : [];
}
/**
* @notes 获取系统通知示例
* @param $sceneId
* @param false $flag
* @return array|string[]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getSystemExample($sceneId, $flag = false)
{
$desc = [];
if ($flag) {
return $desc;
}
return isset($desc[$sceneId]) ? [$desc[$sceneId]] : [];
}
/**
* @notes 获取短信通知示例
* @param $sceneId
* @param false $flag
* @return array|string[]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getSmsExample($sceneId, $flag = false)
{
$desc = [
self::LOGIN_CAPTCHA => '您正在登录,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
self::BIND_MOBILE_CAPTCHA => '您正在绑定手机号,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
self::CHANGE_MOBILE_CAPTCHA => '您正在变更手机号,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
self::FIND_LOGIN_PASSWORD_CAPTCHA => '您正在找回登录密码,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
];
if ($flag) {
return $desc;
}
return isset($desc[$sceneId]) ? ['示例:' . $desc[$sceneId]] : [];
}
/**
* @notes 获取公众号模板消息示例
* @param $sceneId
* @param false $flag
* @return array|string[]|\string[][]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getOaExample($sceneId, $flag = false)
{
$desc = [];
if ($flag) {
return $desc;
}
return $desc[$sceneId] ?? [];
}
/**
* @notes 获取小程序订阅消息示例
* @param $sceneId
* @param false $flag
* @return array|mixed
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getMnpExample($sceneId, $flag = false)
{
$desc = [];
if ($flag) {
return $desc;
}
return $desc[$sceneId] ?? [];
}
/**
* @notes 提示
* @param $type
* @param $sceneId
* @return array|string|string[]|\string[][]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getOperationTips($type, $sceneId)
{
// 场景变量
$vars = self::getVars($sceneId);
// 其他提示
$other = [];
// 示例
switch ($type) {
case self::SYSTEM:
$example = self::getSystemExample($sceneId);
break;
case self::SMS:
$other[] = '生效条件1、管理后台完成短信设置。 2、第三方短信平台申请模板 3、若是腾讯云模板变量名须换成变量名出现顺序对应的数字(例:您好{nickname},您的订单{order_sn}已发货! 须改为 您好{1},您的订单{2}已发货!)';
$example = self::getSmsExample($sceneId);
break;
case self::OA:
$other[] = '配置路径:公众号后台 > 广告与服务 > 模板消息';
$other[] = '推荐行业主营行业IT科技/互联网|电子商务 副营行业:消费品/消费品';
$example = self::getOaExample($sceneId);
break;
case self::MNP:
$other[] = '配置路径:小程序后台 > 功能 > 订阅消息';
$example = self::getMnpExample($sceneId);
break;
}
$tips = array_merge($vars, $example, $other);
return $tips;
}
}

View File

@@ -0,0 +1,55 @@
<?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\common\enum\notice;
/**
* 短信枚举
* Class SmsEnum
* @package app\common\enum
*/
class SmsEnum
{
/**
* 发送状态
*/
const SEND_ING = 0;
const SEND_SUCCESS = 1;
const SEND_FAIL = 2;
/**
* 短信平台
*/
const ALI = 1;
const TENCENT = 2;
const SMSBAO = 3;
/**
* @notes 获取短信平台名称
* @param $value
* @return string
* @author 段誉
* @date 2022/8/5 11:10
*/
public static function getNameDesc($value)
{
$desc = [
'ALI' => '阿里云短信',
'TENCENT' => '腾讯云短信',
'SMSBAO' => '短信宝短信',
];
return $desc[$value] ?? '';
}
}

View File

@@ -0,0 +1,55 @@
<?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\common\enum\user;
/**
* 管理后台登录终端
* Class terminalEnum
* @package app\common\enum
*/
class UserEnum
{
/**
* 性别
* SEX_OTHER = 未知
* SEX_MEN = 男
* SEX_WOMAN = 女
*/
const SEX_OTHER = 0;
const SEX_MEN = 1;
const SEX_WOMAN = 2;
/**
* @notes 性别描述
* @param bool $from
* @return string|string[]
* @author 段誉
* @date 2022/9/7 15:05
*/
public static function getSexDesc($from = true)
{
$desc = [
self::SEX_OTHER => '未知',
self::SEX_MEN => '男',
self::SEX_WOMAN => '女',
];
if (true === $from) {
return $desc;
}
return $desc[$from] ?? '';
}
}

View File

@@ -0,0 +1,64 @@
<?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\common\enum\user;
/**
* 管理后台登录终端
* Class terminalEnum
* @package app\common\enum
*/
class UserTerminalEnum
{
//const OTHER = 0; //其他来源
const WECHAT_MMP = 1; //微信小程序
const WECHAT_OA = 2; //微信公众号
const H5 = 3;//手机H5登录
const PC = 4;//电脑PC
const IOS = 5;//苹果app
const ANDROID = 6;//安卓app
const ALL_TERMINAL = [
self::WECHAT_MMP,
self::WECHAT_OA,
self::H5,
self::PC,
self::IOS,
self::ANDROID,
];
/**
* @notes 获取终端
* @param bool $from
* @return array|mixed|string
* @author cjhao
* @date 2021/7/30 18:09
*/
public static function getTermInalDesc($from = true)
{
$desc = [
self::WECHAT_MMP => '微信小程序',
self::WECHAT_OA => '微信公众号',
self::H5 => '手机H5',
self::PC => '电脑PC',
self::IOS => '苹果APP',
self::ANDROID => '安卓APP',
];
if(true === $from){
return $desc;
}
return $desc[$from] ?? '';
}
}

View File

@@ -0,0 +1,40 @@
<?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\common\exception;
use think\Exception;
/**
* 控制器继承异常
* Class ControllerExtendException
* @package app\common\exception
*/
class ControllerExtendException extends Exception
{
/**
* 构造方法
* @access public
* @param string $message
* @param string $model
* @param array $config
*/
public function __construct(string $message, string $model = '', array $config = [])
{
$this->message = '控制器需要继承模块的基础控制器:' . $message;
$this->model = $model;
}
}

View File

@@ -0,0 +1,30 @@
<?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\common\http\middleware;
/**
* 基础中间件
* Class LikeShopMiddleware
* @package app\common\http\middleware
*/
class BaseMiddleware
{
public function handle($request, \Closure $next)
{
return $next($request);
}
}

View File

@@ -0,0 +1,50 @@
<?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\common\http\middleware;
use Closure;
/**
* 自定义跨域中间件
* Class LikeAdminAllowMiddleware
* @package app\common\http\middleware
*/
class LikeAdminAllowMiddleware
{
/**
* @notes 跨域处理
* @param $request
* @param \Closure $next
* @param array|null $header
* @return mixed|\think\Response
* @author 令狐冲
* @date 2021/7/26 11:51
*/
public function handle($request, Closure $next, ?array $header = [])
{
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Authorization, Sec-Fetch-Mode, DNT, X-Mx-ReqToken, Keep-Alive, User-Agent, If-Match, If-None-Match, If-Unmodified-Since, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Accept-Language, Origin, Accept-Encoding,Access-Token,token,version");
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, post');
header('Access-Control-Max-Age: 1728000');
header('Access-Control-Allow-Credentials:true');
if (strtoupper($request->method()) == "OPTIONS") {
return response();
}
return $next($request);
}
}

View File

@@ -0,0 +1,43 @@
<?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\common\listener;
use app\common\logic\NoticeLogic;
use think\facade\Log;
/**
* 通知事件监听
* Class NoticeListener
* @package app\listener
*/
class NoticeListener
{
public function handle($params)
{
try {
if (empty($params['scene_id'])) {
throw new \Exception('场景ID不能为空');
}
// 根据不同的场景发送通知
$result = NoticeLogic::noticeByScene($params);
if (false === $result) {
throw new \Exception(NoticeLogic::getError());
}
return true;
} catch (\Exception $e) {
Log::write('通知发送失败:'.$e->getMessage());
return $e->getMessage();
}
}
}

View File

@@ -0,0 +1,220 @@
<?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\common\lists;
use app\common\enum\ExportEnum;
use app\common\service\JsonService;
use app\common\validate\ListsValidate;
use app\Request;
use think\facade\Config;
/**
* 数据列表基类
* Class BaseDataLists
* @package app\common\lists
*/
abstract class BaseDataLists implements ListsInterface
{
use ListsSearchTrait;
use ListsSortTrait;
use ListsExcelTrait;
public Request $request; //请求对象
public int $pageNo; //页码
public int $pageSize; //每页数量
public int $limitOffset; //limit查询offset值
public int $limitLength; //limit查询数量
public int $pageSizeMax;
public int $pageType = 0; //默认类型0-一般分页1-不分页,获取最大所有数据
protected string $orderBy;
protected string $field;
protected $startTime;
protected $endTime;
protected $start;
protected $end;
protected array $params;
protected $sortOrder = [];
public string $export;
public function __construct()
{
//参数验证
(new ListsValidate())->get()->goCheck();
//请求参数设置
$this->request = request();
$this->params = $this->request->param();
//分页初始化
$this->initPage();
//搜索初始化
$this->initSearch();
//排序初始化
$this->initSort();
//导出初始化
$this->initExport();
}
/**
* @notes 分页参数初始化
* @author 令狐冲
* @date 2021/7/30 23:55
*/
private function initPage()
{
$this->pageSizeMax = Config::get('project.lists.page_size_max');
$this->pageSize = Config::get('project.lists.page_size');
$this->pageType = $this->request->get('page_type', 1);
if ($this->pageType == 1) {
//分页
$this->pageNo = $this->request->get('page_no', 1) ?: 1;
$this->pageSize = $this->request->get('page_size', $this->pageSize) ?: $this->pageSize;
} else {
//不分页
$this->pageNo = 1;//强制到第一页
$this->pageSize = $this->pageSizeMax;// 直接取最大记录数
}
//limit查询参数设置
$this->limitOffset = ($this->pageNo - 1) * $this->pageSize;
$this->limitLength = $this->pageSize;
}
/**
* @notes 初始化搜索
* @return array
* @author 令狐冲
* @date 2021/7/31 00:00
*/
private function initSearch()
{
if (!($this instanceof ListsSearchInterface)) {
return [];
}
$startTime = $this->request->get('start_time');
if ($startTime) {
$this->startTime = strtotime($startTime);
}
$endTime = $this->request->get('end_time');
if ($endTime) {
$this->endTime = strtotime($endTime);
}
$this->start = $this->request->get('start');
$this->end = $this->request->get('end');
return $this->searchWhere = $this->createWhere($this->setSearch());
}
/**
* @notes 初始化排序
* @return array|string[]
* @author 令狐冲
* @date 2021/7/31 00:03
*/
private function initSort()
{
if (!($this instanceof ListsSortInterface)) {
return [];
}
$this->field = $this->request->get('field', '');
$this->orderBy = $this->request->get('order_by', '');
return $this->sortOrder = $this->createOrder($this->setSortFields(), $this->setDefaultOrder());
}
/**
* @notes 导出初始化
* @return false|\think\response\Json
* @author 令狐冲
* @date 2021/7/31 01:15
*/
private function initExport()
{
$this->export = $this->request->get('export', '');
//不做导出操作
if ($this->export != ExportEnum::INFO && $this->export != ExportEnum::EXPORT) {
return false;
}
//导出操作,但是没有实现导出接口
if (!($this instanceof ListsExcelInterface)) {
return JsonService::throw('该列表不支持导出');
}
$this->fileName = $this->request->get('file_name', '') ?: $this->setFileName();
//不导出文件,不初始化一下参数
if ($this->export != ExportEnum::EXPORT) {
return false;
}
//导出文件名设置
$this->fileName .= '-' . date('Y-m-d-His') . '.xlsx';
//导出文件准备
if ($this->export == ExportEnum::EXPORT) {
//指定导出范围第2页到第5页的数据
if ($this->pageType == 1) {
$this->pageStart = $this->request->get('page_start', $this->pageStart);
$this->pageEnd = $this->request->get('page_end', $this->pageEnd);
//改变查询数量参数第2页到第5页的数据查询->page(2,(5-2+1)*25)
$this->limitOffset = ($this->pageStart - 1) * $this->pageSize;
$this->limitLength = ($this->pageEnd - $this->pageStart + 1) * $this->pageSize;
}
$count = $this->count();
//判断导出范围是否有数据
if ($count == 0 || ceil($count / $this->pageSize) < $this->pageStart) {
$msg = $this->pageType ? '第' . $this->pageStart . '页到第' . $this->pageEnd . '页没有数据,无法导出' : '没有数据,无法导出';
return JsonService::throw($msg);
}
}
}
/**
* @notes 不需要分页,可以调用此方法,无需查询第二次
* @return int
* @author 令狐冲
* @date 2021/7/6 00:34
*/
public function defaultCount(): int
{
return count($this->lists());
}
}

View 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\common\lists;
interface ListsExcelInterface
{
/**
* @notes 设置导出字段
* @return array
* @author 令狐冲
* @date 2021/7/21 16:04
*/
public function setExcelFields(): array;
/**
* @notes 设置导出文件名
* @return string
* @author 令狐冲
* @date 2021/7/26 17:47
*/
public function setFileName():string;
}

View File

@@ -0,0 +1,136 @@
<?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\common\lists;
use app\common\cache\ExportCache;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
trait ListsExcelTrait
{
public int $pageStart = 1; //导出开始页码
public int $pageEnd = 200; //导出介绍页码
public string $fileName = ''; //文件名称
/**
* @notes 创建excel
* @param $excelFields
* @param $lists
* @return string
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @author 令狐冲
* @date 2021/7/21 16:04
*/
public function createExcel($excelFields, $lists)
{
$title = array_values($excelFields);
$data = [];
foreach ($lists as $row) {
$temp = [];
foreach ($excelFields as $key => $excelField) {
$fieldData = $row[$key];
if (is_numeric($fieldData) && strlen($fieldData) >= 12) {
$fieldData .= "\t";
}
$temp[$key] = $fieldData;
}
$data[] = $temp;
}
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
//设置单元格内容
foreach ($title as $key => $value) {
// 单元格内容写入
$sheet->setCellValueByColumnAndRow($key + 1, 1, $value);
}
$row = 2; //从第二行开始
foreach ($data as $item) {
$column = 1;
foreach ($item as $value) {
//单元格内容写入
$sheet->setCellValueByColumnAndRow($column, $row, $value);
$column++;
}
$row++;
}
$getHighestRowAndColumn = $sheet->getHighestRowAndColumn();
$HighestRow = $getHighestRowAndColumn['row'];
$column = $getHighestRowAndColumn['column'];
$titleScope = 'A1:' . $column . '1';//第一标题范围A1:D1)
$sheet->getStyle($titleScope)
->getFill()
->setFillType(Fill::FILL_SOLID) // 设置填充样式
->getStartColor()
->setARGB('00B0F0');
// 设置文字颜色为白色
$sheet->getStyle($titleScope)->getFont()->getColor()
->setARGB('FFFFFF');
// $sheet->getStyle('B2')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD);
$spreadsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$allCope = 'A1:' . $column . $HighestRow;//整个表格范围A1:D5
$sheet->getStyle($allCope)->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
//创建excel文件
$exportCache = new ExportCache();
$src = $exportCache->getSrc();
if (!file_exists($src)) {
mkdir($src, 0775, true);
}
$writer->save($src . $this->fileName);
//设置本地excel缓存并返回下载地址
$vars = ['file' => $exportCache->setFile($this->fileName)];
return (string)(url('adminapi/download/export', $vars, true, true));
}
/**
* @notes 获取导出信息
* @return array
* @author 令狐冲
* @date 2021/7/29 16:08
*/
public function excelInfo()
{
$count = $this->count();
$sum_page = max(ceil($count / $this->pageSize), 1);
return [
'count' => $count, //所有数据记录数
'page_size' => $this->pageSize,//每页记录数
'sum_page' => $sum_page,//一共多少页
'max_page' => floor($this->pageSizeMax / $this->pageSize),//最多导出多少页
'all_max_size' => $this->pageSizeMax,//最多导出记录数
'page_start' => $this->pageStart,//导出范围页码开始值
'page_end' => min($sum_page, $this->pageEnd),//导出范围页码结束值
'file_name' => $this->fileName,//默认文件名
];
}
}

View File

@@ -0,0 +1,30 @@
<?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\common\lists;
interface ListsExtendInterface
{
/**
* @notes 扩展字段
* @return mixed
* @author 令狐冲
* @date 2021/7/21 17:45
*/
public function extend();
}

View 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\common\lists;
interface ListsInterface
{
/**
* @notes 实现数据列表
* @return array
* @author 令狐冲
* @date 2021/7/6 00:33
*/
public function lists(): array;
/**
* @notes 实现数据列表记录数
* @return int
* @author 令狐冲
* @date 2021/7/6 00:34
*/
public function count(): int;
}

View File

@@ -0,0 +1,29 @@
<?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\common\lists;
interface ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return array
* @author 令狐冲
* @date 2021/7/7 19:44
*/
public function setSearch(): array;
}

View 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\common\lists;
trait ListsSearchTrait
{
protected array $params;
protected $searchWhere = [];
/**
* @notes 搜索条件生成
* @param $search
* @return array
* @author 令狐冲
* @date 2021/7/7 19:36
*/
private function createWhere($search)
{
if (empty($search)) {
return [];
}
$where = [];
foreach ($search as $whereType => $whereFields) {
switch ($whereType) {
case '=':
case '<>':
case '>':
case '>=':
case '<':
case '<=':
case 'in':
foreach ($whereFields as $whereField) {
$paramsName = substr_symbol_behind($whereField);
if (!isset($this->params[$paramsName]) || $this->params[$paramsName] == '') {
continue;
}
$where[] = [$whereField, $whereType, $this->params[$paramsName]];
}
break;
case '%like%':
foreach ($whereFields as $whereField) {
$paramsName = substr_symbol_behind($whereField);
if (!isset($this->params[$paramsName]) || empty($this->params[$paramsName])) {
continue;
}
$where[] = [$whereField, 'like', '%' . $this->params[$paramsName] . '%'];
}
break;
case '%like':
foreach ($whereFields as $whereField) {
$paramsName = substr_symbol_behind($whereField);
if (!isset($this->params[$paramsName]) || empty($this->params[$paramsName])) {
continue;
}
$where[] = [$whereField, 'like', '%' . $this->params[$paramsName]];
}
break;
case 'like%':
foreach ($whereFields as $whereField) {
$paramsName = substr_symbol_behind($whereField);
if (!isset($this->params[$paramsName]) || empty($this->params[$paramsName])) {
continue;
}
$where[] = [$whereField, 'like', $this->params[$paramsName] . '%'];
}
break;
case 'between_time':
if (!is_numeric($this->startTime) || !is_numeric($this->endTime)) {
break;
}
$where[] = [$whereFields, 'between', [$this->startTime, $this->endTime]];
break;
case 'between':
if (empty($this->start) || empty($this->end)) {
break;
}
$where[] = [$whereFields, 'between', [$this->start, $this->end]];
break;
case 'find_in_set': // find_in_set查询
foreach ($whereFields as $whereField) {
$paramsName = substr_symbol_behind($whereField);
if (!isset($this->params[$paramsName]) || $this->params[$paramsName] == '') {
continue;
}
$where[] = [$whereField, 'find in set', $this->params[$paramsName]];
}
break;
}
}
return $where;
}
}

View File

@@ -0,0 +1,38 @@
<?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\common\lists;
interface ListsSortInterface
{
/**
* @notes 设置支持排序字段
* @return array
* @author 令狐冲
* @date 2021/7/7 19:44
*/
public function setSortFields(): array;
/**
* @notes 设置默认排序条件
* @return array
* @author 令狐冲
* @date 2021/7/16 00:01
*/
public function setDefaultOrder():array;
}

View File

@@ -0,0 +1,53 @@
<?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\common\lists;
trait ListsSortTrait
{
protected string $orderBy;
protected string $field;
/**
* @notes 生成排序条件
* @param $sortField
* @param $defaultOrder
* @return array|string[]
* @author 令狐冲
* @date 2021/7/16 00:06
*/
private function createOrder($sortField, $defaultOrder)
{
if (empty($sortField) || empty($this->orderBy) || empty($this->field) || !in_array($this->field, array_keys($sortField))) {
return $defaultOrder;
}
if (isset($sortField[$this->field])) {
$field = $sortField[$this->field];
} else {
return $defaultOrder;
}
if ($this->orderBy == 'desc') {
return [$field => 'desc'];
}
if ($this->orderBy == 'asc') {
return [$field => 'asc'];
}
return $defaultOrder;
}
}

View File

@@ -0,0 +1,114 @@
<?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\common\logic;
/**
* 逻辑基类
* Class BaseLogic
* @package app\common\logic
*/
class BaseLogic
{
/**
* 错误信息
* @var string
*/
protected static $error;
/**
* 返回状态码
* @var int
*/
protected static $returnCode = 0;
protected static $returnData;
/**
* @notes 获取错误信息
* @return string
* @author 段誉
* @date 2021/7/21 18:23
*/
public static function getError() : string
{
if (false === self::hasError()) {
return 'network.systemError';
}
return self::$error;
}
/**
* @notes 设置错误信息
* @param $error
* @author 段誉
* @date 2021/7/21 18:20
*/
public static function setError($error) : void
{
!empty($error) && self::$error = $error;
}
/**
* @notes 是否存在错误
* @return bool
* @author 段誉
* @date 2021/7/21 18:32
*/
public static function hasError() : bool
{
return !empty(self::$error);
}
/**
* @notes 设置状态码
* @param $code
* @author 段誉
* @date 2021/7/28 17:05
*/
public static function setReturnCode($code) : void
{
self::$returnCode = $code;
}
/**
* @notes 特殊场景返回指定状态码,默认为0
* @return int
* @author 段誉
* @date 2021/7/28 15:14
*/
public static function getReturnCode() : int
{
return self::$returnCode;
}
/**
* @notes 获取内容
* @return mixed
* @author cjhao
* @date 2021/9/11 17:29
*/
public static function getReturnData()
{
return self::$returnData;
}
}

View File

@@ -0,0 +1,184 @@
<?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\common\logic;
use app\common\enum\notice\NoticeEnum;
use app\common\enum\YesNoEnum;
use app\common\model\notice\NoticeRecord;
use app\common\model\notice\NoticeSetting;
use app\common\model\user\User;
use app\common\service\sms\SmsMessageService;
/**
* 通知逻辑层
* Class NoticeLogic
* @package app\common\logic
*/
class NoticeLogic extends BaseLogic
{
/**
* @notes 根据场景发送短信
* @param $params
* @return bool
* @author 段誉
* @date 2022/9/15 15:28
*/
public static function noticeByScene($params)
{
try {
$noticeSetting = NoticeSetting::where('scene_id', $params['scene_id'])->findOrEmpty()->toArray();
if (empty($noticeSetting)) {
throw new \Exception('找不到对应场景的配置');
}
// 合并额外参数
$params = self::mergeParams($params);
$res = false;
self::setError('发送通知失败');
// 短信通知
if (isset($noticeSetting['sms_notice']['status']) && $noticeSetting['sms_notice']['status'] == YesNoEnum::YES) {
$res = (new SmsMessageService())->send($params);
}
return $res;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 整理参数
* @param $params
* @return array
* @author 段誉
* @date 2022/9/15 15:28
*/
public static function mergeParams($params)
{
// 用户相关
if (!empty($params['params']['user_id'])) {
$user = User::findOrEmpty($params['params']['user_id'])->toArray();
$params['params']['nickname'] = $user['nickname'];
$params['params']['user_name'] = $user['nickname'];
$params['params']['user_sn'] = $user['sn'];
$params['params']['mobile'] = $params['params']['mobile'] ?? $user['mobile'];
}
// 跳转路径
$jumpPath = self::getPathByScene($params['scene_id'], $params['params']['order_id'] ?? 0);
$params['url'] = $jumpPath['url'];
$params['page'] = $jumpPath['page'];
return $params;
}
/**
* @notes 根据场景获取跳转链接
* @param $sceneId
* @param $extraId
* @return string[]
* @author 段誉
* @date 2022/9/15 15:29
*/
public static function getPathByScene($sceneId, $extraId)
{
// 小程序主页路径
$page = '/pages/index/index';
// 公众号主页路径
$url = '/mobile/pages/index/index';
return [
'url' => $url,
'page' => $page,
];
}
/**
* @notes 替换消息内容中的变量占位符
* @param $content
* @param $params
* @return array|mixed|string|string[]
* @author 段誉
* @date 2022/9/15 15:29
*/
public static function contentFormat($content, $params)
{
foreach ($params['params'] as $k => $v) {
$search = '{' . $k . '}';
$content = str_replace($search, $v, $content);
}
return $content;
}
/**
* @notes 添加通知记录
* @param $params
* @param $noticeSetting
* @param $sendType
* @param $content
* @param string $extra
* @return NoticeRecord|\think\Model
* @author 段誉
* @date 2022/9/15 15:29
*/
public static function addNotice($params, $noticeSetting, $sendType, $content, $extra = '')
{
return NoticeRecord::create([
'user_id' => $params['params']['user_id'] ?? 0,
'title' => self::getTitleByScene($sendType, $noticeSetting),
'content' => $content,
'scene_id' => $noticeSetting['scene_id'],
'read' => YesNoEnum::NO,
'recipient' => $noticeSetting['recipient'],
'send_type' => $sendType,
'notice_type' => $noticeSetting['type'],
'extra' => $extra,
]);
}
/**
* @notes 通知记录标题
* @param $sendType
* @param $noticeSetting
* @return string
* @author 段誉
* @date 2022/9/15 15:30
*/
public static function getTitleByScene($sendType, $noticeSetting)
{
switch ($sendType) {
case NoticeEnum::SMS:
$title = '';
break;
case NoticeEnum::OA:
$title = $noticeSetting['oa_notice']['name'] ?? '';
break;
case NoticeEnum::MNP:
$title = $noticeSetting['mnp_notice']['name'] ?? '';
break;
default:
$title = '';
}
return $title;
}
}

View File

@@ -0,0 +1,50 @@
<?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\common\model;
use app\common\service\FileService;
use think\Model;
/**
* 基础模型
* Class BaseModel
* @package app\common\model
*/
class BaseModel extends Model
{
/**
* @notes 公共处理图片,补全路径
* @param $value
* @return string
* @author 张无忌
* @date 2021/9/10 11:02
*/
public function getImageAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 公共图片处理,去除图片域名
* @param $value
* @return mixed|string
* @author 张无忌
* @date 2021/9/10 11:04
*/
public function setImageAttr($value)
{
return trim($value) ? FileService::setFileUrl($value) : '';
}
}

View 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
// +----------------------------------------------------------------------
namespace app\common\model;
class Config extends BaseModel
{
}

View 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
// +----------------------------------------------------------------------
namespace app\common\model;
use app\common\enum\CrontabEnum;
use think\model\concern\SoftDelete;
/**
* 定时任务模型
* Class Crontab
* @package app\common\model
*/
class Crontab extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $name = 'dev_crontab';
/**
* @notes 类型获取器
* @param $value
* @return string
* @author 段誉
* @date 2022/3/29 12:05
*/
public function getTypeDescAttr($value)
{
$desc = [
CrontabEnum::CRONTAB => '定时任务',
CrontabEnum::DAEMON => '守护进程',
];
return $desc[$value] ?? '';
}
/**
* @notes 状态获取器
* @param $value
* @return string
* @author 段誉
* @date 2022/3/29 12:06
*/
public function getStatusDescAttr($value)
{
$desc = [
CrontabEnum::START => '运行',
CrontabEnum::STOP => '停止',
CrontabEnum::ERROR => '错误',
];
return $desc[$value] ?? '';
}
/**
* @notes 最后执行时间获取器
* @param $value
* @return string
* @author 段誉
* @date 2022/3/29 12:06
*/
public function getLastTimeAttr($value)
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace app\common\model;
class OperationLog extends BaseModel
{
}

View File

@@ -0,0 +1,111 @@
<?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\common\model\article;
use app\common\enum\YesNoEnum;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 资讯管理模型
* Class Article
* @package app\common\model\article;
*/
class Article extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 获取分类名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getCateNameAttr($value, $data)
{
return ArticleCate::where('id', $data['cid'])->value('name');
}
/**
* @notes 浏览量
* @param $value
* @param $data
* @return mixed
* @author 段誉
* @date 2022/9/15 11:33
*/
public function getClickAttr($value, $data)
{
return $data['click_actual'] + $data['click_virtual'];
}
/**
* @notes 设置图片域名
* @param $value
* @param $data
* @return array|string|string[]|null
* @author 段誉
* @date 2022/9/28 10:17
*/
public function getContentAttr($value, $data)
{
return get_file_domain($value);
}
/**
* @notes 清除图片域名
* @param $value
* @param $data
* @return array|string|string[]
* @author 段誉
* @date 2022/9/28 10:17
*/
public function setContentAttr($value, $data)
{
return clear_file_domain($value);
}
/**
* @notes 获取文章详情
* @param $id
* @return array
* @author 段誉
* @date 2022/10/20 15:23
*/
public static function getArticleDetailArr(int $id)
{
$article = Article::where(['id' => $id, 'is_show' => YesNoEnum::YES])
->findOrEmpty();
if ($article->isEmpty()) {
return [];
}
// 增加点击量
$article->click_actual += 1;
$article->save();
return $article->append(['click'])
->hidden(['click_virtual', 'click_actual'])
->toArray();
}
}

View 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\common\model\article;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 资讯分类管理模型
* Class ArticleCate
* @package app\common\model\article;
*/
class ArticleCate extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 关联文章
* @return \think\model\relation\HasMany
* @author 段誉
* @date 2022/10/19 16:59
*/
public function article()
{
return $this->hasMany(Article::class, 'cid', 'id');
}
/**
* @notes 状态描述
* @param $value
* @param $data
* @return string
* @author 段誉
* @date 2022/9/15 11:25
*/
public function getIsShowDescAttr($value, $data)
{
return $data['is_show'] ? '启用' : '停用';
}
/**
* @notes 文章数量
* @param $value
* @param $data
* @return int
* @author 段誉
* @date 2022/9/15 11:32
*/
public function getArticleCountAttr($value, $data)
{
return Article::where(['cid' => $data['id']])->count('id');
}
}

View File

@@ -0,0 +1,52 @@
<?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\common\model\article;
use app\common\enum\YesNoEnum;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 资讯收藏
* Class ArticleCollect
* @package app\common\model\article
*/
class ArticleCollect extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 是否已收藏文章
* @param $userId
* @param $articleId
* @return bool (true=已收藏, false=未收藏)
* @author 段誉
* @date 2022/10/20 15:13
*/
public static function isCollectArticle($userId, $articleId)
{
$collect = ArticleCollect::where([
'user_id' => $userId,
'article_id' => $articleId,
'status' => YesNoEnum::YES
])->findOrEmpty();
return !$collect->isEmpty();
}
}

View File

@@ -0,0 +1,116 @@
<?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\common\model\auth;
use app\common\enum\YesNoEnum;
use app\common\model\BaseModel;
use app\common\model\dept\Dept;
use think\model\concern\SoftDelete;
use app\common\service\FileService;
class Admin extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $append = [
'role_id',
'dept_id',
'jobs_id',
];
/**
* @notes 关联角色id
* @param $value
* @param $data
* @return array
* @author 段誉
* @date 2022/11/25 15:00
*/
public function getRoleIdAttr($value, $data)
{
return AdminRole::where('admin_id', $data['id'])->column('role_id');
}
/**
* @notes 关联部门id
* @param $value
* @param $data
* @return array
* @author 段誉
* @date 2022/11/25 15:00
*/
public function getDeptIdAttr($value, $data)
{
return AdminDept::where('admin_id', $data['id'])->column('dept_id');
}
/**
* @notes 关联岗位id
* @param $value
* @param $data
* @return array
* @author 段誉
* @date 2022/11/25 15:01\
*/
public function getJobsIdAttr($value, $data)
{
return AdminJobs::where('admin_id', $data['id'])->column('jobs_id');
}
/**
* @notes 获取禁用状态
* @param $value
* @param $data
* @return string|string[]
* @author 令狐冲
* @date 2021/7/7 01:25
*/
public function getDisableDescAttr($value, $data)
{
return YesNoEnum::getDisableDesc($data['disable']);
}
/**
* @notes 最后登录时间获取器 - 格式化:年-月-日 时:分:秒
* @param $value
* @return string
* @author Tab
* @date 2021/7/13 11:35
*/
public function getLoginTimeAttr($value)
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
}
/**
* @notes 头像获取器 - 头像路径添加域名
* @param $value
* @return string
* @author Tab
* @date 2021/7/13 11:35
*/
public function getAvatarAttr($value)
{
return empty($value) ? FileService::getFileUrl(config('project.default_image.admin_avatar')) : FileService::getFileUrl(trim($value, '/'));
}
}

View File

@@ -0,0 +1,32 @@
<?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\common\model\auth;
use app\common\model\BaseModel;
class AdminDept extends BaseModel
{
/**
* @notes 删除用户关联部门
* @param $adminId
* @return bool
* @author 段誉
* @date 2022/11/25 14:14
*/
public static function delByUserId($adminId)
{
return self::where(['admin_id' => $adminId])->delete();
}
}

View File

@@ -0,0 +1,32 @@
<?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\common\model\auth;
use app\common\model\BaseModel;
class AdminJobs extends BaseModel
{
/**
* @notes 删除用户关联岗位
* @param $adminId
* @return bool
* @author 段誉
* @date 2022/11/25 14:14
*/
public static function delByUserId($adminId)
{
return self::where(['admin_id' => $adminId])->delete();
}
}

View File

@@ -0,0 +1,34 @@
<?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\common\model\auth;
use app\common\model\BaseModel;
class AdminRole extends BaseModel
{
/**
* @notes 删除用户关联角色
* @param $adminId
* @return bool
* @author 段誉
* @date 2022/11/25 14:14
*/
public static function delByUserId($adminId)
{
return self::where(['admin_id' => $adminId])->delete();
}
}

View File

@@ -0,0 +1,32 @@
<?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\common\model\auth;
use app\common\model\BaseModel;
class AdminSession extends BaseModel
{
/**
* @notes 关联管理员表
* @return \think\model\relation\HasOne
* @author 令狐冲
* @date 2021/7/5 14:39
*/
public function admin()
{
return $this->hasOne(Admin::class, 'id', 'admin_id')
->field('id,multipoint_login');
}
}

View File

@@ -0,0 +1,31 @@
<?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\common\model\auth;
use app\common\model\BaseModel;
/**
* 系统菜单
* Class SystemMenu
* @package app\common\model\auth
*/
class SystemMenu extends BaseModel
{
}

View File

@@ -0,0 +1,43 @@
<?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\common\model\auth;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 角色模型
* Class Role
* @package app\common\model
*/
class SystemRole extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $name = 'system_role';
/**
* @notes 角色与菜单关联关系
* @return \think\model\relation\HasMany
* @author 段誉
* @date 2022/7/6 11:16
*/
public function roleMenuIndex()
{
return $this->hasMany(SystemRoleMenu::class, 'role_id');
}
}

View File

@@ -0,0 +1,30 @@
<?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\common\model\auth;
use app\common\model\BaseModel;
/**
* 角色与菜单权限关系
* Class SystemRoleMenu
* @package app\common\model\auth
*/
class SystemRoleMenu extends BaseModel
{
}

View File

@@ -0,0 +1,59 @@
<?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\common\model\decorate;
use app\common\model\BaseModel;
/**
* 提示内容模型
* Class DecorateHint
* @package app\common\model\decorate
*/
class DecorateHint extends BaseModel
{
protected $name = 'decorate_hint';
/**
* @notes 设置图片域名
* @param $value
* @param $data
* @return array|string|string[]|null
* @author 段誉
* @date 2022/9/28 10:17
*/
public function getContentAttr($value, $data)
{
return get_file_domain($value);
}
/**
* @notes 清除图片域名
* @param $value
* @param $data
* @return array|string|string[]
* @author 段誉
* @date 2022/9/28 10:17
*/
public function setContentAttr($value, $data)
{
return clear_file_domain($value);
}
}

View File

@@ -0,0 +1,34 @@
<?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\common\model\decorate;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 菜单按钮模型
* Class DecorateNav
* @package app\common\model\decorate
*/
class DecorateNav extends BaseModel
{
use SoftDelete;
protected $name = 'decorate_nav';
protected $deleteTime = 'delete_time';
}

View File

@@ -0,0 +1,44 @@
<?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\common\model\decorate;
use app\common\model\BaseModel;
use app\common\service\FileService;
/**
* 轮播图模型
* Class DecorateSwiper
* @package app\common\model\decorate
*/
class DecorateSwiper extends BaseModel
{
protected $name = 'decorate_swiper';
/**
* @notes 图片域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getImageAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
}

View 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\common\model\dept;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 部门模型
* Class Dept
* @package app\common\model\article
*/
class Dept extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 状态描述
* @param $value
* @param $data
* @return string
* @author 段誉
* @date 2022/5/25 18:03
*/
public function getStatusDescAttr($value, $data)
{
return $data['status'] ? '正常' : '停用';
}
}

View File

@@ -0,0 +1,44 @@
<?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\common\model\dept;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 岗位模型
* Class Jobs
* @package app\common\model\dept
*/
class Jobs extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 状态描述
* @param $value
* @param $data
* @return string
* @author 段誉
* @date 2022/5/25 18:03
*/
public function getStatusDescAttr($value, $data)
{
return $data['status'] ? '正常' : '停用';
}
}

View File

@@ -0,0 +1,47 @@
<?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\common\model\dict;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 字典数据模型
* Class DictData
* @package app\common\model\dict
*/
class DictData extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 状态描述
* @param $value
* @param $data
* @return string
* @author 段誉
* @date 2022/6/20 16:31
*/
public function getStatusDescAttr($value, $data)
{
return $data['status'] ? '正常' : '停用';
}
}

View File

@@ -0,0 +1,47 @@
<?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\common\model\dict;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 字典类型模型
* Class DictType
* @package app\common\model\dict
*/
class DictType extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 状态描述
* @param $value
* @param $data
* @return string
* @author 段誉
* @date 2022/6/20 15:54
*/
public function getStatusDescAttr($value, $data)
{
return $data['status'] ? '正常' : '停用';
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace app\common\model\feedback;
use app\common\model\BaseModel;
/**
* 意见反馈类型模型
* Class FeedbackCate
* @package app\common\model\feedback
*/
class FeedbackCate extends BaseModel
{
protected $name = 'feedback_cate';
}

View File

@@ -0,0 +1,32 @@
<?php
namespace app\common\model\feedback;
use app\common\model\feedback\FeedbackCate;
use app\common\model\BaseModel;
/**
* 意见反馈记录模型
* Class FeedbackRecord
* @package app\common\model\feedback
*/
class FeedbackRecord extends BaseModel
{
protected $name = 'feedback_record';
/**
* @notes 获取分类名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getCateNameAttr($value, $data)
{
return FeedbackCate::where('id', $data['cid'])->value('name');
}
}

View File

@@ -0,0 +1,24 @@
<?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\common\model\file;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
class File extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
}

View File

@@ -0,0 +1,25 @@
<?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\common\model\file;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
class FileCate extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
}

View File

@@ -0,0 +1,116 @@
<?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\common\model\finance;
use app\common\model\BaseModel;
use app\common\service\FileService;
use think\model\concern\SoftDelete;
use app\common\model\setting\RechargeMethod;
use app\common\model\user\{User,UserRelation,UserRelationAgent};
use app\common\model\dict\DictData;
/**
* 充值记录模型
* Class RechargeRecord
* @package app\common\model\finance
*/
class RechargeRecord extends BaseModel
{
use SoftDelete;
protected $name = 'recharge_record';
protected $deleteTime = 'delete_time';
/**
* @notes 获取方式名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getMethodAttr($value, $data)
{
return RechargeMethod::where('id', $data['method_id'])->findOrEmpty();
}
/**
* @notes 获取方式名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getMethodNameAttr($value, $data)
{
return RechargeMethod::where('id', $data['method_id'])->value('name');
}
/**
* @notes voucher域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getVoucherAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 充值状态
* @param $value
* @return string|string[]
* @author 段誉
* @date 2023/2/23 18:32
*/
public function getStatusTextAttr($value, $data)
{
return DictData::where(['value' => $data['status'],'type_value'=>'recharge_status'])->value('name');
}
/**
* @notes 获取用户层级
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamTopAttr($value, $data)
{
$top_relation = UserRelationAgent::where(['user_id' => $data['user_id']])->order('level desc')->findOrEmpty();
$prev_relation = UserRelationAgent::where(['user_id' => $data['user_id'],'level' => 1])->findOrEmpty();
$level = '';
if (!$top_relation->isEmpty()) {
$level = $top_relation['level'];
}
$top_user = User::where('id', $top_relation['parent_id'])->findOrEmpty();
return [
'top_account' => $top_user['account'],
'prev_account' => User::where('id', $prev_relation['parent_id'])->value('account'),
'level' => $level
];
}
}

View File

@@ -0,0 +1,62 @@
<?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\common\model\finance;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
use app\common\model\user\{User,UserRelation,UserRelationAgent};
/**
* 资金明细模型
* Class UserFinance
* @package app\common\model\finance
*/
class UserFinance extends BaseModel
{
use SoftDelete;
protected $name = 'user_finance';
protected $deleteTime = 'delete_time';
/**
* @notes 获取用户层级
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamTopAttr($value, $data)
{
$top_relation = UserRelationAgent::where(['user_id' => $data['user_id']])->order('level desc')->findOrEmpty();
$prev_relation = UserRelationAgent::where(['user_id' => $data['user_id'],'level' => 1])->findOrEmpty();
$level = '';
if (!$top_relation->isEmpty()) {
$level = $top_relation['level'];
}
$top_user = User::where('id', $top_relation['parent_id'])->findOrEmpty();
return [
'top_account' => $top_user['account'],
'prev_account' => User::where('id', $prev_relation['parent_id'])->value('account'),
'level' => $level
];
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace app\common\model\finance;
use app\common\model\user\{User};
use app\common\model\BaseModel;
/**
* 用户转账记录模型
* Class UserTransferRecord
* @package app\common\model\finance
*/
class UserTransferRecord extends BaseModel
{
protected $name = 'user_transfer_record';
/**
* @notes 转入转出用户详情
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getUsersInfoAttr($value, $data)
{
$field = 'mobile';
//转出用户
$userFrom = User::field($field)->where(['id' => $data['user_id_from']])->findOrEmpty();
//转入用户
$userTo = User::field($field)->where(['id' => $data['user_id_to']])->findOrEmpty();
return [
'user_from' => $userFrom['mobile'],
'user_to' => $userTo['mobile'],
];
}
}

View File

@@ -0,0 +1,120 @@
<?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\common\model\finance;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
use app\common\model\withdraw\WithdrawMethod;
use app\common\model\user\{User,UserRelation,UserRelationAgent};
use app\common\model\dict\DictData;
use app\common\service\{FileService};
/**
* 提现记录模型
* Class WithdrawRecord
* @package app\common\model\finance
*/
class WithdrawRecord extends BaseModel
{
use SoftDelete;
protected $name = 'withdraw_record';
protected $deleteTime = 'delete_time';
/**
* @notes 二维码域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getImgAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 获取方式名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getMethodNameAttr($value, $data)
{
return WithdrawMethod::where('id', $data['method_id'])->value('name');
}
/**
* @notes 获取实际金额
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getActAmountAttr($value, $data)
{
$record = WithdrawRecord::where(['id' => $data['id']])->findOrEmpty();
$method = WithdrawMethod::where(['id' => $record['method_id']])->findOrEmpty();
return round(($record['amount'] - $record['charge']) * $record['rate'] , $method['precision']);
}
/**
* @notes 提现状态
* @param $value
* @return string|string[]
* @author 段誉
* @date 2023/2/23 18:32
*/
public function getStatusTextAttr($value, $data)
{
return DictData::where(['value' => $data['status'],'type_value'=>'withdraw_status'])->value('name');
}
/**
* @notes 获取用户层级
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamTopAttr($value, $data)
{
$top_relation = UserRelationAgent::where(['user_id' => $data['user_id']])->order('level desc')->findOrEmpty();
$prev_relation = UserRelationAgent::where(['user_id' => $data['user_id'],'level' => 1])->findOrEmpty();
$level = '';
if (!$top_relation->isEmpty()) {
$level = $top_relation['level'];
}
$top_user = User::where('id', $top_relation['parent_id'])->findOrEmpty();
return [
'top_account' => $top_user['account'],
'prev_account' => User::where('id', $prev_relation['parent_id'])->value('account'),
'level' => $level
];
}
}

View 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\common\model\goods;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 商品模型
* Class Goods
* @package app\common\model\goods
*/
class Goods extends BaseModel
{
use SoftDelete;
protected $name = 'goods';
protected $deleteTime = 'delete_time';
/**
* @notes 获取分类名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getCateNameAttr($value, $data)
{
return GoodsCate::where('id', $data['cid'])->value('name');
}
}

View File

@@ -0,0 +1,34 @@
<?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\common\model\goods;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 商品分类模型
* Class GoodsCate
* @package app\common\model\goods
*/
class GoodsCate extends BaseModel
{
use SoftDelete;
protected $name = 'goods_cate';
protected $deleteTime = 'delete_time';
}

View File

@@ -0,0 +1,44 @@
<?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\common\model\goods;
use app\common\model\BaseModel;
use app\common\service\FileService;
/**
* 抢单记录模型
* Class GoodsRecord
* @package app\common\model\goods
*/
class GoodsRecord extends BaseModel
{
protected $name = 'goods_record';
/**
* @notes 图片域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getGoodsImageAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
}

View File

@@ -0,0 +1,92 @@
<?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\common\model\item;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
use app\common\model\member\{UserMember};
/**
* 项目模型
* Class Item
* @package app\common\model\item
*/
class Item extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 设置图片域名
* @param $value
* @param $data
* @return array|string|string[]|null
* @author 段誉
* @date 2022/9/28 10:17
*/
public function getContentAttr($value, $data)
{
return get_file_domain($value);
}
/**
* @notes 清除图片域名
* @param $value
* @param $data
* @return array|string|string[]
* @author 段誉
* @date 2022/9/28 10:17
*/
public function setContentAttr($value, $data)
{
return clear_file_domain($value);
}
/**
* @notes 获取分类名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getCateNameAttr($value, $data)
{
return ItemCate::where('id', $data['cid'])->value('name');
}
/**
* @notes 获取会员名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getVipNameAttr($value, $data)
{
//查询会员等级
$vip_name = '';
$userMember = UserMember::where(['id' => $data['member_id']])->findOrEmpty();
if (!$userMember->isEmpty()) {
$vip_name = $userMember['name'];
}
return $vip_name;
}
}

View File

@@ -0,0 +1,34 @@
<?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\common\model\item;
use app\common\model\BaseModel;
/**
* 项目分类模型
* Class ItemCate
* @package app\common\model\item
*/
class ItemCate extends BaseModel
{
protected $name = 'item_cate';
}

View File

@@ -0,0 +1,50 @@
<?php
namespace app\common\model\item;
use app\common\model\BaseModel;
use app\common\model\user\{User,UserRelation,UserRelationAgent};
/**
* 项目记录模型
* Class ItemRecord
* @package app\common\model\item
*/
class ItemRecord extends BaseModel
{
protected $name = 'item_record';
/**
* @notes 获取用户层级
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamTopAttr($value, $data)
{
$top_relation = UserRelationAgent::where(['user_id' => $data['user_id']])->order('level desc')->findOrEmpty();
$prev_relation = UserRelationAgent::where(['user_id' => $data['user_id'],'level' => 1])->findOrEmpty();
$level = '';
if (!$top_relation->isEmpty()) {
$level = $top_relation['level'];
}
$top_user = User::where('id', $top_relation['parent_id'])->findOrEmpty();
return [
'top_account' => $top_user['account'],
'prev_account' => User::where('id', $prev_relation['parent_id'])->value('account'),
'level' => $level
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace app\common\model\lh;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
use app\common\service\FileService;
/**
* 量化货币模型
* Class LhCoin
* @package app\common\model\lh
*/
class LhCoin extends BaseModel
{
use SoftDelete;
protected $name = 'lh_coin';
protected $deleteTime = 'delete_time';
/**
* @notes 图片域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getLogoAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace app\common\model\lh;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
use app\common\service\FileService;
/**
* 量化记录模型
* Class LhRecord
* @package app\common\model\lh
*/
class LhRecord extends BaseModel
{
use SoftDelete;
protected $name = 'lh_record';
protected $deleteTime = 'delete_time';
/**
* @notes 图片域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getLogoAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace app\common\model\mall;
use app\common\model\BaseModel;
/**
* 积分、抽奖奖品模型
* Class MallGoods
* @package app\common\model\mall
*/
class MallGoods extends BaseModel
{
protected $name = 'mall_goods';
}

View File

@@ -0,0 +1,31 @@
<?php
namespace app\common\model\mall;
use app\common\model\BaseModel;
use app\common\service\FileService;
/**
* 奖品记录模型
* Class MallGoodsRecord
* @package app\common\model\mall
*/
class MallGoodsRecord extends BaseModel
{
protected $name = 'mall_goods_record';
/**
* @notes 图片域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getMGoodsImageAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
}

View 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\common\model\member;
use app\common\model\BaseModel;
use app\common\service\FileService;
/**
* 会员等级模型
* Class UserMember
* @package app\common\model\member
*/
class UserMember extends BaseModel
{
protected $name = 'user_member';
/**
* @notes 设置图片域名
* @param $value
* @param $data
* @return array|string|string[]|null
* @author 段誉
* @date 2022/9/28 10:17
*/
public function getContentAttr($value, $data)
{
return get_file_domain($value);
}
/**
* @notes 清除图片域名
* @param $value
* @param $data
* @return array|string|string[]
* @author 段誉
* @date 2022/9/28 10:17
*/
public function setContentAttr($value, $data)
{
return clear_file_domain($value);
}
/**
* @notes 图片域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getBgImgAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 图片域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getLogoAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 获取所属名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getVipNameAttr($value, $data)
{
return UserMember::where('id', $data['level1_vip_id'])->value('name');
}
}

View File

@@ -0,0 +1,34 @@
<?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\common\model\member;
use app\common\model\BaseModel;
/**
* 会员记录模型
* Class UserMemberRecord
* @package app\common\model\member
*/
class UserMemberRecord extends BaseModel
{
protected $name = 'user_member_record';
}

View File

@@ -0,0 +1,21 @@
<?php
namespace app\common\model\notice;
use app\common\model\BaseModel;
/**
* 邮件发送记录模型
* Class EmailRecord
* @package app\common\model\notice
*/
class EmailRecord extends BaseModel
{
protected $name = 'email_record';
}

View File

@@ -0,0 +1,47 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | // +----------------------------------------------------------------------
// | 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\common\model\notice;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 通知记录模型
* Class Notice
* @package app\common\model
*/
class NoticeRecord extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
}

View File

@@ -0,0 +1,120 @@
<?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\common\model\notice;
use app\common\enum\DefaultEnum;
use app\common\enum\notice\NoticeEnum;
use app\common\model\BaseModel;
class NoticeSetting extends BaseModel
{
/**
* @notes 短信通知状态
* @param $value
* @param $data
* @return string|string[]
* @author ljj
* @date 2022/2/16 3:22 下午
*/
public function getSmsStatusDescAttr($value,$data)
{
if ($data['sms_notice']) {
$sms_text = json_decode($data['sms_notice'],true);
return DefaultEnum::getEnableDesc($sms_text['status']);
}else {
return '停用';
}
}
/**
* @notes 通知类型
* @param $value
* @param $data
* @return string|string[]
* @author ljj
* @date 2022/2/17 2:50 下午
*/
public function getTypeDescAttr($value,$data)
{
return NoticeEnum::getTypeDesc($data['type']);
}
/**
* @notes 接收者描述获取器
* @param $value
* @return string
* @author Tab
* @date 2021/8/18 16:42
*/
public function getRecipientDescAttr($value)
{
$desc = [
1 => '买家',
2 => '卖家',
];
return $desc[$value] ?? '';
}
/**
* @notes 系统通知获取器
* @param $value
* @return array|mixed
* @author Tab
* @date 2021/8/18 19:11
*/
public function getSystemNoticeAttr($value)
{
return empty($value) ? [] : json_decode($value, true);
}
/**
* @notes 短信通知获取器
* @param $value
* @return array|mixed
* @author Tab
* @date 2021/8/18 19:12
*/
public function getSmsNoticeAttr($value)
{
return empty($value) ? [] : json_decode($value, true);
}
/**
* @notes 公众号通知获取器
* @param $value
* @return array|mixed
* @author Tab
* @date 2021/8/18 19:13
*/
public function getOaNoticeAttr($value)
{
return empty($value) ? [] : json_decode($value, true);
}
/**
* @notes 小程序通知获取器
* @param $value
* @return array|mixed
* @author Tab
* @date 2021/8/18 19:13
*/
public function getMnpNoticeAttr($value)
{
return empty($value) ? [] : json_decode($value, true);
}
}

View File

@@ -0,0 +1,30 @@
<?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\common\model\notice;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 短信记录模型
* Class SmsLog
* @package app\common\model
*/
class SmsLog extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
}

View File

@@ -0,0 +1,34 @@
<?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\common\model\setting;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 语言包模型
* Class Language
* @package app\common\model\setting
*/
class Language extends BaseModel
{
use SoftDelete;
protected $name = 'language';
protected $deleteTime = 'delete_time';
}

View 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\common\model\setting;
use app\common\model\BaseModel;
use app\common\enum\YesNoEnum;
use app\common\model\setting\{Language};
/**
* 语言包模型
* Class LanguagePag
* @package app\common\model\setting
*/
class LanguagePag extends BaseModel
{
protected $name = 'language_pag';
/**
* @notes 获取源语言
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getFromValueAttr($value, $data)
{
$language = Language::where(['is_show' => YesNoEnum::YES])->order(['sort' => 'desc', 'id' => 'desc'])->findOrEmpty();
return LanguagePag::where(['lang' => $language['symbol'],'type' => $data['type'],'name' => $data['name']])->value('value');
}
}

View File

@@ -0,0 +1,28 @@
<?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\common\model\setting;
use app\common\model\BaseModel;
/**
* 代码生成器-数据表信息模型
* Class OperationLog
* @package app\common\model\setting
*/
class OperationLog extends BaseModel
{
}

View File

@@ -0,0 +1,105 @@
<?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\common\model\setting;
use app\common\model\BaseModel;
use app\common\service\FileService;
use think\model\concern\SoftDelete;
use app\common\model\member\{UserMember};
/**
* 充值方式模型
* Class RechargeMethod
* @package app\common\model\setting
*/
class RechargeMethod extends BaseModel
{
use SoftDelete;
protected $name = 'recharge_method';
protected $deleteTime = 'delete_time';
/**
* @notes logo域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getLogoAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 二维码域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getImgAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 二维码域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getQrcodeAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 获取所属名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getLangNameAttr($value, $data)
{
if($data['lang_id'] == 0){
return '通用';
}
return Language::where('id', $data['lang_id'])->value('name');
}
/**
* @notes 获取会员名称
* @param $value
* @param $data
* @return string
* @author heshihu
* @date 2022/2/22 9:53
*/
public function getVipNameAttr($value, $data)
{
//查询会员等级
$vip_name = '';
$userMember = UserMember::where(['id' => $data['member_id']])->findOrEmpty();
if (!$userMember->isEmpty()) {
$vip_name = $userMember['name'];
}
return $vip_name;
}
}

View File

@@ -0,0 +1,44 @@
<?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\common\model\setting;
use app\common\model\BaseModel;
use app\common\service\FileService;
/**
* 轮播图模型
* Class DecorateSwiper
* @package app\common\model\setting
*/
class DecorateSwiper extends BaseModel
{
protected $name = 'decorateSwiper';
/**
* @notes 图片域名替换
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getImageAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
}

View 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\common\model\tools;
use app\common\model\BaseModel;
/**
* 代码生成器-数据表字段信息模型
* Class GenerateColumn
* @package app\common\model\tools
*/
class GenerateColumn extends BaseModel
{
/**
* @notes 关联table表
* @return \think\model\relation\BelongsTo
* @author 段誉
* @date 2022/6/15 18:59
*/
public function generateTable()
{
return $this->belongsTo(GenerateTable::class, 'id', 'table_id');
}
}

View File

@@ -0,0 +1,59 @@
<?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\common\model\tools;
use app\common\enum\GeneratorEnum;
use app\common\model\BaseModel;
/**
* 代码生成器-数据表信息模型
* Class GenerateTable
* @package app\common\model\tools
*/
class GenerateTable extends BaseModel
{
protected $json = ['menu', 'tree', 'relations', 'delete'];
protected $jsonAssoc = true;
/**
* @notes 关联数据表字段
* @return \think\model\relation\HasMany
* @author 段誉
* @date 2022/6/15 10:46
*/
public function tableColumn()
{
return $this->hasMany(GenerateColumn::class, 'table_id', 'id');
}
/**
* @notes 模板类型描述
* @param $value
* @param $data
* @return string|string[]
* @author 段誉
* @date 2022/6/14 11:25
*/
public function getTemplateTypeDescAttr($value, $data)
{
return GeneratorEnum::getTemplateTypeDesc($data['template_type']);
}
}

View File

@@ -0,0 +1,558 @@
<?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\common\model\user;
use app\common\enum\user\UserEnum;
use app\common\model\BaseModel;
use app\common\model\user\{UserRelation,UserRelationAgent,UserInfo,UserGroup,UserGroupRecord,UserMineRecord};
use app\common\model\member\{UserMember};
use app\common\model\lh\{LhRecord};
use app\common\model\finance\{UserFinance};
use app\common\model\goods\{GoodsRecord};
use app\common\model\item\ItemRecord;
use app\common\service\{FileService,ConfigService,UtilsService};
use think\model\concern\SoftDelete;
/**
* 用户模型
* Class User
* @package app\common\model\user
*/
class User extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 关联用户授权模型
* @return \think\model\relation\HasOne
* @author 段誉
* @date 2022/9/22 16:03
*/
public function userAuth()
{
return $this->hasOne(UserAuth::class, 'user_id');
}
/**
* @notes 搜索器-用户信息
* @param $query
* @param $value
* @param $data
* @author 段誉
* @date 2022/9/22 16:12
*/
public function searchKeywordAttr($query, $value, $data)
{
if ($value) {
$query->where('sn|account|mobile', 'like', '%' . $value . '%');
}
}
/**
* @notes 搜索器-注册来源
* @param $query
* @param $value
* @param $data
* @author 段誉
* @date 2022/9/22 16:13
*/
public function searchChannelAttr($query, $value, $data)
{
if ($value) {
$query->where('channel', '=', $value);
}
}
/**
* @notes 搜索器-注册时间
* @param $query
* @param $value
* @param $data
* @author 段誉
* @date 2022/9/22 16:13
*/
public function searchCreateTimeStartAttr($query, $value, $data)
{
if ($value) {
$query->where('create_time', '>=', strtotime($value));
}
}
/**
* @notes 搜索器-注册时间
* @param $query
* @param $value
* @param $data
* @author 段誉
* @date 2022/9/22 16:13
*/
public function searchCreateTimeEndAttr($query, $value, $data)
{
if ($value) {
$query->where('create_time', '<=', strtotime($value));
}
}
/**
* @notes 头像获取器 - 用于头像地址拼接域名
* @param $value
* @return string
* @author Tab
* @date 2021/7/17 14:28
*/
public function getAvatarAttr($value)
{
return trim($value) ? FileService::getFileUrl($value) : '';
}
/**
* @notes 获取器-性别描述
* @param $value
* @param $data
* @return string|string[]
* @author 段誉
* @date 2022/9/7 15:15
*/
public function getSexAttr($value, $data)
{
return UserEnum::getSexDesc($value);
}
/**
* @notes 登录时间
* @param $value
* @return string
* @author 段誉
* @date 2022/9/23 18:15
*/
public function getLoginTimeAttr($value)
{
return $value ? date('Y-m-d H:i:s', $value) : '';
}
/**
* @notes 生成用户编码
* @param string $prefix
* @param int $length
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/16 10:33
*/
public static function createUserSn($prefix = '', $length = 8)
{
$rand_str = '';
for ($i = 0; $i < $length; $i++) {
$rand_str .= mt_rand(0, 9);
}
$sn = $prefix . $rand_str;
if (User::where(['sn' => $sn])->find()) {
return self::createUserSn($prefix, $length);
}
return $sn;
}
/**
* @notes 获取团队人数
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamNumAttr($value, $data)
{
$config = ConfigService::get('website', 'distribute');
$level = count($config);
return UserRelation::where(['parent_id' => $data['id']])->where("level <= $level")->count();
}
/**
* @notes 获取量化次数
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getLhNumAttr($value, $data)
{
return LhRecord::where(['user_id' => $data['id']])->count();
}
/**
* @notes 获取今日量化次数
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTodayLhNumAttr($value, $data)
{
// 获取今天0点的时间戳
$todayStart = strtotime(date('Y-m-d 00:00:00'));
return LhRecord::where(['user_id' => $data['id']])->where("create_time > $todayStart")->count();
}
/**
* @notes 获取投资次数
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getItemNumAttr($value, $data)
{
return ItemRecord::where(['user_id' => $data['id']])->count();
}
/**
* @notes 获取挖矿情况
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getMineAttr($value, $data)
{
$start_time = strtotime(date('Y-m-d 00:00:00', time()));//0点
$end_time = time();
$today_income = UserMineRecord::where(['user_id' => $data['id']])->where(" create_time >= $start_time AND create_time <= $end_time ")->sum('amount');
$start_time = 0;
$total_income = UserMineRecord::where(['user_id' => $data['id']])->where(" create_time >= $start_time AND create_time <= $end_time ")->sum('amount');
return [
'total_income' => $total_income,
'today_income' => $today_income,
];
}
/**
* @notes 获取今日投资次数
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTodayItemNumAttr($value, $data)
{
// 获取今天0点的时间戳
$todayStart = strtotime(date('Y-m-d 00:00:00'));
return ItemRecord::where(['user_id' => $data['id']])->where("create_time > $todayStart")->count();
}
/**
* @notes 获取团队总充值
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamRechargeAttr($value, $data)
{
$config = ConfigService::get('website', 'distribute');
$level = count($config);
$sum = UserRelation::alias('ur')
->join('user u', 'u.id = ur.user_id')
->where(['ur.parent_id' => $data['id']])
->where("ur.level <= $level AND u.total_recharge > 0")
->sum('u.total_recharge');
return $sum;
}
/**
* @notes 获取量化次数
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getUnusedMoneyAttr($value, $data)
{
return UserFinance::where(['user_id' => $data['id'],'frozen' => 1])->sum('change_amount');
}
/**
* @notes 获取团队总提现
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamWithdrawAttr($value, $data)
{
$config = ConfigService::get('website', 'distribute');
$level = count($config);
$sum = UserRelation::alias('ur')
->join('user u', 'u.id = ur.user_id')
->where(['ur.parent_id' => $data['id']])
->where("ur.level <= $level AND u.total_withdraw > 0")
->sum('u.total_withdraw');
return $sum;
}
/**
* @notes 获取推广情况
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamReportAttr($value, $data)
{
$items = ConfigService::get('website', 'distribute');
foreach ($items as &$item) {
$level = $item['level'];
$item['num'] = UserRelation::where(['parent_id' => $data['id'],'level' => $level])->count();
$item['num_valid'] = UserRelation::alias('ur')
->join('user_member_record umr', 'ur.user_id = umr.user_id')
->where(['ur.parent_id' => $data['id'],'level' => $level])
->where("umr.member_id > 1")
->count();
}
return $items;
}
/**
* @notes 获取用户层级
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getTeamTopAttr($value, $data)
{
$top_relation = UserRelationAgent::where(['user_id' => $data['id']])->order('level desc')->findOrEmpty();
$prev_relation = UserRelationAgent::where(['user_id' => $data['id'],'level' => 1])->findOrEmpty();
$level = '';
if (!$top_relation->isEmpty()) {
$level = $top_relation['level'];
}
$top_user = User::where('id', $top_relation['parent_id'])->findOrEmpty();
return [
'top_account' => $top_user['account'],
'top_name' => $top_user['is_agent'] == 1 ? $top_user['agent_name']:'',
'prev_account' => User::where('id', $prev_relation['parent_id'])->value('account'),
'level' => $level
];
}
/**
* @notes 获取用户层级
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getAgentTeamTopAttr($value, $data)
{
$top_relations = UserRelationAgent::where(['user_id' => $data['id']])->order('level desc')->select();
//只有一条数据的话即为代理直接下级超过一条数据则替换一代ID为代理二代ID
$top_relation = $top_relations[0];
if(count($top_relations) > 1){
$top_relation = $top_relations[1];
}
$prev_relation = UserRelationAgent::where(['user_id' => $data['id'],'level' => 1])->findOrEmpty();
$level = '';
if (!$top_relation->isEmpty()) {
$level = $top_relation['level'];
}
return [
'top_account' => User::where('id', $top_relation['parent_id'])->value('account'),
'prev_account' => User::where('id', $prev_relation['parent_id'])->value('account'),
'level' => $level
];
}
/**
* @notes 获取注册IP数量
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getRegisterIpNumAttr($value, $data)
{
return User::where(['register_ip' => $data['register_ip']])->count();
}
/**
* @notes 获取注册国家
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getRegisterCountryAttr($value, $data)
{
$country = "";
// if($data['register_isp'] == ''){
// if($data['register_ip'] != ''){
// $country = UtilsService::get_country_by_ip($data['register_ip'],1);
// if($country == ''){
// $country = UtilsService::get_country_by_ip($data['register_ip'],2);
// }
// if($country != ''){
// User::where(['id' => $data['id']])->update(['register_isp' => $country]);
// }
// }
// }else{
// $country = $data['register_isp'];
// }
return $country;
}
/**
* @notes 获取登录IP数量
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getLoginIpNumAttr($value, $data)
{
return User::where(['login_ip' => $data['login_ip']])->count();
}
/**
* @notes 订单数
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getOrderNumAttr($value, $data)
{
return GoodsRecord::where(['user_id' => $data['id']])->count();
}
/**
* @notes 24小时订单数
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getOrderNum24Attr($value, $data)
{
$time24Hours = time() - 24 * 60 * 60;//24小时前
return GoodsRecord::where(['user_id' => $data['id']])->where("create_time > $time24Hours")->count();
}
/**
* @notes 会员等级
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getVipNameAttr($value, $data)
{
//查询会员等级
$vip_name = '';
$member_id = UtilsService::get_user_member_id($data['id']);
$userMember = UserMember::where(['id' => $member_id])->findOrEmpty();
if (!$userMember->isEmpty()) {
$vip_name = $userMember['name'];
}
return $vip_name;
}
/**
* @notes 用户详情
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getUserInfoAttr($value, $data)
{
return UserInfo::where(['user_id' => $data['id']])->findOrEmpty();
}
/**
* @notes 用户分组
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getGroupNameAttr($value, $data)
{
$group_name = '未分组';
$record = UserGroupRecord::where(['user_id' => ($data['id'])])->findOrEmpty();
if (!$record->isEmpty()) {
$group_name = UserGroup::where('id', $record['group_id'])->value('name');
}
return $group_name;
}
}

View File

@@ -0,0 +1,27 @@
<?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\common\model\user;
use app\common\model\BaseModel;
/**
* 用户授权表
* Class UserAuth
* @package app\common\model
*/
class UserAuth extends BaseModel
{
}

View File

@@ -0,0 +1,45 @@
<?php
namespace app\common\model\user;
use app\common\model\BaseModel;
use app\common\model\user\{UserGroupRule,UserGroupRecord};
/**
* 用户分组模型
* Class UserGroup
* @package app\common\model\user
*/
class UserGroup extends BaseModel
{
protected $name = 'user_group';
/**
* @notes 规则数量
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getRuleNumAttr($value, $data)
{
return UserGroupRule::where(['group_id' => $data['id']])->count();
}
/**
* @notes 用户数量
* @param $value
* @param $data
* @return string
* @author BD
* @date 2024/02/22 10:54
*/
public function getUserNumAttr($value, $data)
{
return UserGroupRecord::where(['group_id' => $data['id']])->count();
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace app\common\model\user;
use app\common\model\BaseModel;
/**
* 用户分组记录模型
* Class UserGroupRecord
* @package app\common\model\user
*/
class UserGroupRecord extends BaseModel
{
protected $name = 'user_group_record';
}

View File

@@ -0,0 +1,21 @@
<?php
namespace app\common\model\user;
use app\common\model\BaseModel;
/**
* 分组规则模型
* Class UserGroupRule
* @package app\common\model\user
*/
class UserGroupRule extends BaseModel
{
protected $name = 'user_group_rule';
}

Some files were not shown because too many files have changed in this diff Show More