174 lines
5.6 KiB
PHP
174 lines
5.6 KiB
PHP
<?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\create_task_template;
|
||
|
||
|
||
use app\adminapi\logic\ConfigLogic;
|
||
use app\common\model\create_task_template\CreateTaskTemplate;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* CreateTaskTemplate逻辑
|
||
* Class CreateTaskTemplateLogic
|
||
* @package app\adminapi\logic\create_task_template
|
||
*/
|
||
class CreateTaskTemplateLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/18 14:50
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
CreateTaskTemplate::create([
|
||
'title' => $params['title'],
|
||
'admin_id' => $params['admin_id'],
|
||
'task_role_id' => $params['task_role_id'],
|
||
'type' => $params['type'],
|
||
'stage_day_one' => $params['stage_day_one'],
|
||
'money' => $params['money'],
|
||
'proportion_one' => $params['proportion_one'],
|
||
'stage_day_two' => $params['stage_day_two'],
|
||
'proportion_two' => $params['proportion_two'],
|
||
'money_two' => $params['money_two'],
|
||
'stage_day_three' => $params['stage_day_three'],
|
||
'new_money_three' => $params['new_money_three'],
|
||
'money_longtime' => $params['money_longtime'],
|
||
'types' => $params['types'],
|
||
'recharge' => $params['recharge'],
|
||
'content' => $params['content']
|
||
]);
|
||
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/18 14:50
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
CreateTaskTemplate::where('id', $params['id'])->update([
|
||
'title' => $params['title'],
|
||
'admin_id' => $params['admin_id'],
|
||
'task_role_id' => $params['task_role_id'],
|
||
'type' => $params['type'],
|
||
'stage_day_one' => $params['stage_day_one'],
|
||
'money' => $params['money'],
|
||
'proportion_one' => $params['proportion_one'],
|
||
'stage_day_two' => $params['stage_day_two'],
|
||
'proportion_two' => $params['proportion_two'],
|
||
'money_two' => $params['money_two'],
|
||
'stage_day_three' => $params['stage_day_three'],
|
||
'new_money_three' => $params['new_money_three'],
|
||
'money_longtime' => $params['money_longtime'],
|
||
'types' => $params['types'],
|
||
'recharge' => $params['recharge'],
|
||
'content' => $params['content']
|
||
]);
|
||
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/18 14:50
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return CreateTaskTemplate::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/18 14:50
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
return CreateTaskTemplate::findOrEmpty($params['id'])->toArray();
|
||
}
|
||
|
||
public static function taskTypeList($taskRoleId=0)
|
||
{
|
||
$type = '';
|
||
switch ($taskRoleId) {
|
||
case 1:
|
||
$type = 'town_task_type_master';
|
||
break;
|
||
case 2:
|
||
$type = 'town_task_type_marketing_director';
|
||
break;
|
||
case 3:
|
||
$type = 'town_task_type';
|
||
break;
|
||
case 4:
|
||
$type = 'village_task_type';
|
||
break;
|
||
case 5:
|
||
$type = 'task_type';
|
||
break;
|
||
}
|
||
if ($type) {
|
||
$data = ConfigLogic::getDictByType($type);
|
||
return $data;
|
||
} else {
|
||
return [];
|
||
}
|
||
}
|
||
|
||
public static function getList($role)
|
||
{
|
||
return CreateTaskTemplate::field(['id', 'title', 'admin_id', 'task_role_id', 'type', 'stage_day_one', 'money', 'proportion_one', 'stage_day_two', 'proportion_two', 'money_two', 'stage_day_three', 'new_money_three', 'money_longtime', 'types', 'recharge', 'content'])
|
||
->order(['id' => 'desc'])
|
||
->whereIn('task_role_id', explode(',', $role))
|
||
->select()
|
||
->toArray();
|
||
}
|
||
} |