提交其他文件
This commit is contained in:
159
app/adminapi/logic/TeamasterAccountLogLogic.php
Normal file
159
app/adminapi/logic/TeamasterAccountLogLogic.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?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\adminapi\logic;
|
||||
|
||||
|
||||
use app\common\model\TeamasterAccountLog;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* TeamasterAccountLog逻辑
|
||||
* Class TeamasterAccountLogLogic
|
||||
* @package app\adminapi\logic
|
||||
*/
|
||||
class TeamasterAccountLogLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2026/02/02 02:11
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
TeamasterAccountLog::create([
|
||||
'team_user_id' => $params['team_user_id'],
|
||||
'user_id' => $params['user_id'],
|
||||
'change_type' => $params['change_type'],
|
||||
'action' => $params['action'],
|
||||
'amount' => $params['amount'],
|
||||
'before_amount' => $params['before_amount'],
|
||||
'after_amount' => $params['after_amount'],
|
||||
'source_sn' => $params['source_sn'],
|
||||
'sub_sn' => $params['sub_sn'],
|
||||
'remark' => $params['remark'],
|
||||
'create_time' => $params['create_time'],
|
||||
'update_time' => $params['update_time'],
|
||||
'status' => $params['status']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2026/02/02 02:11
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
TeamasterAccountLog::where('id', $params['id'])->update([
|
||||
'team_user_id' => $params['team_user_id'],
|
||||
'user_id' => $params['user_id'],
|
||||
'change_type' => $params['change_type'],
|
||||
'action' => $params['action'],
|
||||
'amount' => $params['amount'],
|
||||
'before_amount' => $params['before_amount'],
|
||||
'after_amount' => $params['after_amount'],
|
||||
'source_sn' => $params['source_sn'],
|
||||
'sub_sn' => $params['sub_sn'],
|
||||
'remark' => $params['remark'],
|
||||
'create_time' => $params['create_time'],
|
||||
'update_time' => $params['update_time'],
|
||||
'status' => $params['status']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2026/02/02 02:11
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return TeamasterAccountLog::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2026/02/02 02:11
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return TeamasterAccountLog::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function allTotal($params){
|
||||
$time = "";
|
||||
if(isset($params['start_time'])&&isset($params['end_time'])){
|
||||
$start = strtotime($params['start_time']);
|
||||
$end = strtotime($params['end_time']);
|
||||
$time = "create_time between '".$start."' and '".$end."'";
|
||||
}
|
||||
$change_type = "";
|
||||
if(isset($params['c_type'])){
|
||||
if($params['c_type']!=""&&$params['c_type']!=null){
|
||||
$change_type = "change_type = ".$params['c_type']."";
|
||||
}
|
||||
}
|
||||
$action = "";
|
||||
if(isset($params['action'])){
|
||||
if($params['action']!=""&&$params['action']!=null){
|
||||
$action = "action = ".$params['action']."";
|
||||
}
|
||||
}else{
|
||||
$action = "action = 1";
|
||||
}
|
||||
|
||||
$amount = TeamasterAccountLog::where($time)
|
||||
->where($change_type)
|
||||
->where($action)
|
||||
->sum("amount");
|
||||
return $amount;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user