FastMovieAI 二开基线 v1.0 (完整源码)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"title": "模型",
|
||||
"icon": "Grid",
|
||||
"path": "/app/model/admin",
|
||||
"sort": 999,
|
||||
"children": [
|
||||
{
|
||||
"title": "模型管理",
|
||||
"path": "/app/model/admin/Model/index",
|
||||
"component": "table"
|
||||
},
|
||||
{
|
||||
"title": "任务列表",
|
||||
"path": "/app/model/admin/Task/index",
|
||||
"component": "table"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\api;
|
||||
|
||||
use plugin\control\expose\api\Control as ApiControl;
|
||||
|
||||
class Control
|
||||
{
|
||||
use ApiControl;
|
||||
public function __construct()
|
||||
{
|
||||
$this->path = __DIR__;
|
||||
$this->plugin = 'model';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\api;
|
||||
|
||||
use app\expose\api\Install as ApiInstall;
|
||||
|
||||
class Install
|
||||
{
|
||||
use ApiInstall;
|
||||
public function __construct()
|
||||
{
|
||||
$this->plugin='model';
|
||||
$this->path = __DIR__;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\admin\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\State;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use support\Request;
|
||||
|
||||
class ModelController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginModel();
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$channelList = PluginChannelsUser::options();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('channels_uid', '渠道', 'select', '', [
|
||||
'options' => $channelList,
|
||||
'props' => [
|
||||
'placeholder' => '渠道搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('name', '模型名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '模型名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_type', '模型类型', 'select', '', [
|
||||
'options' => ModelType::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '模型类型搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_name', '模型名称(壹定)', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '模型名称(壹定)搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('assistant_name', '助手名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '助手名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('scene', '场景', 'select', '', [
|
||||
'options' => ModelScene::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '场景搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '80px'
|
||||
]
|
||||
]);
|
||||
$builder->add('channels', '渠道', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'channels.nickname',
|
||||
'avatar' => 'channels,headimg',
|
||||
'info' => 'channels.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'channels_uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('icon', '模型图标', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width:40px;height:40px;'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('name', '模型名称(本地)', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_type', '模型类型', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelType::getOptions()
|
||||
],
|
||||
]);
|
||||
$builder->add('model_name', '模型名称(壹定)', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('assistant_name', '助手名称', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('sort', '排序(小到大)', [
|
||||
'props' => [
|
||||
'width' => '130px'
|
||||
]
|
||||
]);
|
||||
$builder->add('point', '积分', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('scene', '场景', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelScene::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => State::getOptions()
|
||||
],
|
||||
]);
|
||||
$builder->add('description', '描述', [
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$channels_uid = $request->get('channels_uid');
|
||||
if ($channels_uid) {
|
||||
$where[] = ['channels_uid', '=', $channels_uid];
|
||||
}
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name', 'like', "%{$name}%"];
|
||||
}
|
||||
$model_name = $request->get('model_name');
|
||||
if ($model_name) {
|
||||
$where[] = ['model_name', 'like', "%{$model_name}%"];
|
||||
}
|
||||
$assistant_name = $request->get('assistant_name');
|
||||
if ($assistant_name) {
|
||||
$where[] = ['assistant_name', 'like', "%{$assistant_name}%"];
|
||||
}
|
||||
$scene = $request->get('scene');
|
||||
if ($scene) {
|
||||
$where[] = ['scene', '=', $scene];
|
||||
}
|
||||
$model_type = $request->get('model_type');
|
||||
if ($model_type) {
|
||||
$where[] = ['model_type', '=', $model_type];
|
||||
}
|
||||
$list = PluginModel::where($where)->with(['channels' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile');
|
||||
}])->order('id desc')->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\admin\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use support\Request;
|
||||
|
||||
class TaskController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginModelTask();
|
||||
}
|
||||
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$channelList = PluginChannelsUser::options();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('channels_uid', '渠道', 'select', '', [
|
||||
'options' => $channelList,
|
||||
'props' => [
|
||||
'placeholder' => '渠道搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('task_id', '任务ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '任务ID搜索',
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('user_id', '用户ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '用户ID搜索',
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_type', '模型类型', 'select', '', [
|
||||
'options' => ModelType::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '模型类型搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('status', '状态', 'select', '', [
|
||||
'options' => ModelTaskStatus::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '状态搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
|
||||
$formBuilder->add('model_name', '模型名称(壹定)', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '模型名称(壹定)搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('scene', '场景', 'select', '', [
|
||||
'options' => ModelScene::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '场景搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
// $builder->addAction('操作', [
|
||||
// 'width' => '200px',
|
||||
// 'fixed' => 'right'
|
||||
// ]);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('channels', '渠道', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'channels.nickname',
|
||||
'avatar' => 'channels.headimg',
|
||||
'info' => 'channels.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'channels_uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('task_id', '任务ID', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_name', '模型名称', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_type', '模型类型', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelType::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('status', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelTaskStatus::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('scene', '场景', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelScene::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.image_path', '结果图片', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width:40px;height:40px;'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.video_path', '结果视频', [
|
||||
'component' => [
|
||||
'name' => 'video',
|
||||
'props' => [
|
||||
'style' => 'width:40px;height:40px;'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.message', '错误消息', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'text',
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$channels_uid = $request->get('channels_uid');
|
||||
if ($channels_uid) {
|
||||
$where[] = ['pmt.channels_uid', '=', $channels_uid];
|
||||
}
|
||||
$model_name = $request->get('model_name');
|
||||
if ($model_name) {
|
||||
$where[] = ['pm.name', 'like', "%{$model_name}%"];
|
||||
}
|
||||
$model_type = $request->get('model_type');
|
||||
if ($model_type) {
|
||||
$where[] = ['pm.model_type', '=', $model_type];
|
||||
}
|
||||
$scene = $request->get('scene');
|
||||
if ($scene) {
|
||||
$where[] = ['pm.scene', '=', $scene];
|
||||
}
|
||||
$status = $request->get('status');
|
||||
if ($status) {
|
||||
$where[] = ['pmt.status', '=', $status];
|
||||
}
|
||||
$task_id = $request->get('task_id');
|
||||
if ($task_id) {
|
||||
$where[] = ['pmt.task_id', '=', $task_id];
|
||||
}
|
||||
$user_id = $request->get('user_id');
|
||||
if ($user_id) {
|
||||
$where[] = ['pmt.uid', '=', $user_id];
|
||||
}
|
||||
$list = PluginModelTask::alias('pmt')
|
||||
->join('plugin_model pm', 'pmt.model_id = pm.id')
|
||||
->with(['user' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile,channels_uid');
|
||||
}, 'result' => function ($query) {
|
||||
$query->field('task_id,result,image,image_path,video_path,message,channels_uid');
|
||||
}, 'channels' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile');
|
||||
}])
|
||||
->field('pmt.*,pm.name as model_name')
|
||||
->where($where)
|
||||
->order('pmt.id desc')
|
||||
->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\admin\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\model\app\model\PluginModelVoice;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelVoiceStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use support\Request;
|
||||
|
||||
class VoiceController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginModelVoice();
|
||||
}
|
||||
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$channelList = PluginChannelsUser::options();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('channels_uid', '渠道', 'select', '', [
|
||||
'options' => $channelList,
|
||||
'props' => [
|
||||
'placeholder' => '渠道搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('task_id', '任务ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '任务ID搜索',
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('user_id', '用户ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '用户ID搜索',
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_type', '模型类型', 'select', '', [
|
||||
'options' => ModelType::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '模型类型搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('status', '状态', 'select', '', [
|
||||
'options' => ModelVoiceStatus::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '状态搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
|
||||
$formBuilder->add('model_name', '模型名称(壹定)', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '模型名称(壹定)搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('scene', '场景', 'select', '', [
|
||||
'options' => ModelScene::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '场景搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
// $builder->addAction('操作', [
|
||||
// 'width' => '200px',
|
||||
// 'fixed' => 'right'
|
||||
// ]);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('channels', '渠道', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'channels.nickname',
|
||||
'avatar' => 'channels.headimg',
|
||||
'info' => 'channels.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'channels_uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('task_id', '任务ID', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_name', '模型名称', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_type', '模型类型', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelType::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('status', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelVoiceStatus::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('scene', '场景', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelScene::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.image_path', '结果图片', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width:40px;height:40px;'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.video_path', '结果视频', [
|
||||
'component' => [
|
||||
'name' => 'video',
|
||||
'props' => [
|
||||
'style' => 'width:40px;height:40px;'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.message', '错误消息', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'text',
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$channels_uid = $request->get('channels_uid');
|
||||
if ($channels_uid) {
|
||||
$where[] = ['pmt.channels_uid', '=', $channels_uid];
|
||||
}
|
||||
$model_name = $request->get('model_name');
|
||||
if ($model_name) {
|
||||
$where[] = ['pm.name', 'like', "%{$model_name}%"];
|
||||
}
|
||||
$model_type = $request->get('model_type');
|
||||
if ($model_type) {
|
||||
$where[] = ['pm.model_type', '=', $model_type];
|
||||
}
|
||||
$scene = $request->get('scene');
|
||||
if ($scene) {
|
||||
$where[] = ['pm.scene', '=', $scene];
|
||||
}
|
||||
$status = $request->get('status');
|
||||
if ($status) {
|
||||
$where[] = ['pmt.status', '=', $status];
|
||||
}
|
||||
$task_id = $request->get('task_id');
|
||||
if ($task_id) {
|
||||
$where[] = ['pmt.task_id', '=', $task_id];
|
||||
}
|
||||
$user_id = $request->get('user_id');
|
||||
if ($user_id) {
|
||||
$where[] = ['pmt.uid', '=', $user_id];
|
||||
}
|
||||
$list = PluginModelVoice::alias('pmt')
|
||||
->join('plugin_model pm', 'pmt.model_id = pm.id')
|
||||
->with(['user' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile,channels_uid');
|
||||
}, 'result' => function ($query) {
|
||||
$query->field('task_id,result,image,image_path,video_path,message,channels_uid');
|
||||
}, 'channels' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile');
|
||||
}])
|
||||
->field('pmt.*,pm.name as model_name')
|
||||
->where($where)
|
||||
->order('pmt.id desc')
|
||||
->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\State;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\utils\enum\ModelPointType;
|
||||
use plugin\shortplay\utils\PricingCalculator;
|
||||
|
||||
class ModelController extends Basic
|
||||
{
|
||||
protected $notNeedLoginAll = ['models'];
|
||||
public function models()
|
||||
{
|
||||
$PluginModel = PluginModel::where(['state' => State::YES['value']])->order('sort asc')->field('id,channels_uid,icon,name,point,point_type,scene,description,form')->select()->each(function ($item) {
|
||||
$item->unit_point = $item->point;
|
||||
if ($item->point_type == ModelPointType::FIELD_RULE['value']) {
|
||||
$formData = [
|
||||
'resolution' => '720P',
|
||||
'duration' => 5,
|
||||
];
|
||||
$calculator = new PricingCalculator($item->form, $formData, $item->point);
|
||||
$item->point = $calculator->calculate() / 5;
|
||||
}
|
||||
});
|
||||
$models = [];
|
||||
foreach ($PluginModel as $model) {
|
||||
$models[$model->scene][] = [
|
||||
'id' => $model->id,
|
||||
'icon' => $model->icon,
|
||||
'name' => $model->name,
|
||||
'point' => $model->point,
|
||||
'scene' => $model->scene,
|
||||
'description' => $model->description,
|
||||
'form' => $model->form,
|
||||
'unit_point' => $model->unit_point,
|
||||
'unit' => ModelPointType::get($model->point_type, 'unit')
|
||||
];
|
||||
}
|
||||
return $this->resData($models);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use support\Request;
|
||||
|
||||
class TaskController extends Basic
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['uid', '=', $request->uid];
|
||||
$where[] = ['status', 'in', [ModelTaskStatus::WAIT['value'], ModelTaskStatus::PROCESSING['value'], ModelTaskStatus::WAIT_DOWNLOAD['value'], ModelTaskStatus::DOWNLOADING['value'], ModelTaskStatus::UPLOADING['value'], ModelTaskStatus::SUCCESS['value']]];
|
||||
$scene = $request->get('scene', 'all');
|
||||
if ($scene != 'all') {
|
||||
$where[] = ['scene', '=', $scene];
|
||||
}
|
||||
$scenes=$request->get('scenes');
|
||||
if ($scenes) {
|
||||
$where[] = ['scene', 'in', $scenes];
|
||||
}
|
||||
$model_type = $request->get('model_type', 'all');
|
||||
if ($model_type != 'all') {
|
||||
$where[] = ['model_type', '=', $model_type];
|
||||
}
|
||||
$alias_id = $request->get('alias_id');
|
||||
if ($alias_id) {
|
||||
$where[] = ['alias_id', '=', $alias_id];
|
||||
}
|
||||
$list = PluginModelTask::where($where)
|
||||
->with(['user' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile,channels_uid');
|
||||
}, 'result' => function ($query) {
|
||||
$query->field('task_id,result,image,image_path,video_path,message,channels_uid');
|
||||
}])
|
||||
->order('id desc')
|
||||
->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\State;
|
||||
use FFMpeg\FFMpeg;
|
||||
use FFMpeg\Format\Audio\Mp3;
|
||||
use FFMpeg\Format\Audio\Wav;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\app\model\PluginModelVoice;
|
||||
use plugin\model\app\model\PluginModelVoiceText;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelVoiceStatus;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use support\Request;
|
||||
use Webman\Http\UploadFile;
|
||||
use Workerman\Coroutine;
|
||||
|
||||
class VoiceController extends Basic
|
||||
{
|
||||
public function submit(Request $request)
|
||||
{
|
||||
$D = $request->post();
|
||||
if (empty($D['text_id'])) {
|
||||
return $this->fail('请选择文案');
|
||||
}
|
||||
if (empty($D['model_id'])) {
|
||||
return $this->fail('请选择模型');
|
||||
}
|
||||
$PluginModelVoiceText = PluginModelVoiceText::where(['id' => $D['text_id'], 'channels_uid' => $request->channels_uid])->find();
|
||||
if (!$PluginModelVoiceText) {
|
||||
return $this->fail('文案不存在');
|
||||
}
|
||||
$PluginModel = PluginModel::where(['id' => $D['model_id'], 'channels_uid' => $request->channels_uid, 'state' => State::YES['value'], 'scene' => ModelScene::DIALOGUE_VOICE['value']])->find();
|
||||
if (!$PluginModel) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
$audio_url = '';
|
||||
$file = $request->file('file');
|
||||
if (empty($file)) {
|
||||
return $this->fail('请录制语音');
|
||||
}
|
||||
$fileName = uniqid('voice_') . '.wav';
|
||||
$temp_path = runtime_path('temp/' . $fileName);
|
||||
// 判断文件的mime是否为MP3或WAV
|
||||
if (!str_starts_with($file->getUploadMimeType(), 'audio/wav')) {
|
||||
// 使用phpffmpeg转换为MP3
|
||||
$ffmpeg = \FFMpeg\FFMpeg::create([
|
||||
'ffmpeg.binaries' => '/www/server/ffmpeg/ffmpeg-6.1/ffmpeg',
|
||||
'ffprobe.binaries' => '/www/server/ffmpeg/ffmpeg-6.1/ffprobe',
|
||||
]);
|
||||
$media = $ffmpeg->open($file->getRealPath());
|
||||
$wav = new Wav();
|
||||
$media->save($wav, $temp_path);
|
||||
$file = new UploadFile($temp_path, $fileName, 'audio/wav', $file->getUploadErrorCode());
|
||||
}
|
||||
if ($file->getSize() > 1024 * 1024 * 10) {
|
||||
unlink($temp_path);
|
||||
return $this->fail('语音文件大小不能超过10MB,请重新录制');
|
||||
}
|
||||
$result = Uploads::upload($request->channels_uid, $file, null, 'uploads/voice_audio');
|
||||
if (file_exists($temp_path)) {
|
||||
unlink($temp_path);
|
||||
}
|
||||
$audio_url = $result['url'];
|
||||
$PluginModelVoice = new PluginModelVoice();
|
||||
$PluginModelVoice->uid = $request->uid;
|
||||
$PluginModelVoice->channels_uid = $request->channels_uid;
|
||||
if (!empty($D['voice_id'])) {
|
||||
$PluginModelVoice = PluginModelVoice::where(['id' => $D['voice_id'], 'channels_uid' => $request->channels_uid, 'uid' => $request->uid])->find();
|
||||
if (!$PluginModelVoice) {
|
||||
return $this->fail('音色不存在');
|
||||
}
|
||||
$audio_url = $PluginModelVoice->audio_url;
|
||||
}
|
||||
$PluginModelVoice->text_id = $D['text_id'];
|
||||
$PluginModelVoice->model_id = $D['model_id'];
|
||||
if ($audio_url) {
|
||||
$PluginModelVoice->audio = $audio_url;
|
||||
}
|
||||
$PluginModelVoice->status = ModelVoiceStatus::WAIT['value'];
|
||||
$PluginModelVoice->save();
|
||||
$ids = [
|
||||
'id' => $PluginModelVoice->id,
|
||||
'uid' => $request->uid,
|
||||
'channels_uid' => $request->channels_uid,
|
||||
];
|
||||
$data = [
|
||||
'model' => $PluginModel->model_id,
|
||||
'notify_url' => 'https://' . $request->host() . '/app/model/Notify/voiceClone',
|
||||
'form_data' => [
|
||||
'audio' => $audio_url,
|
||||
]
|
||||
];
|
||||
Coroutine::create(function () use ($ids, $data) {
|
||||
$status = ModelVoiceStatus::CLONING['value'];
|
||||
try {
|
||||
$result = Yidevs::AudioVoiceClone($ids['channels_uid'], $data);
|
||||
$PluginModelVoice = PluginModelVoice::where(['id' => $ids['id'], 'channels_uid' => $ids['channels_uid']])->find();
|
||||
$PluginModelVoice->status = ModelVoiceStatus::CLONING['value'];
|
||||
$PluginModelVoice->task_id = $result['task_id'];
|
||||
$PluginModelVoice->save();
|
||||
} catch (\Throwable $th) {
|
||||
$PluginModelVoice = PluginModelVoice::where(['id' => $ids['id'], 'channels_uid' => $ids['channels_uid']])->find();
|
||||
$PluginModelVoice->status = ModelVoiceStatus::FAIL['value'];
|
||||
$PluginModelVoice->message = $th->getMessage();
|
||||
$PluginModelVoice->save();
|
||||
$status = ModelVoiceStatus::FAIL['value'];
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $ids['uid'],
|
||||
'event' => 'clonevoice',
|
||||
], [
|
||||
'id' => $PluginModelVoice->id,
|
||||
'status' => $status,
|
||||
]);
|
||||
});
|
||||
return $this->resData(['voice_id' => $PluginModelVoice->id]);
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$PluginModelVoice = PluginModelVoice::where(['id' => $id, 'channels_uid' => $request->channels_uid, 'uid' => $request->uid])->find();
|
||||
if (!$PluginModelVoice) {
|
||||
return $this->fail('音色不存在');
|
||||
}
|
||||
$name = $request->post('name');
|
||||
if ($name) {
|
||||
$PluginModelVoice->name = $name;
|
||||
}
|
||||
$description = $request->post('description');
|
||||
if ($description) {
|
||||
$PluginModelVoice->description = $description;
|
||||
}
|
||||
$image = $request->post('image');
|
||||
if ($image) {
|
||||
$PluginModelVoice->image = $image;
|
||||
}
|
||||
$headimg = $request->post('headimg');
|
||||
if ($headimg) {
|
||||
$PluginModelVoice->headimg = $headimg;
|
||||
}
|
||||
$gender = $request->post('gender');
|
||||
if ($gender) {
|
||||
$PluginModelVoice->gender = $gender;
|
||||
}
|
||||
$age = $request->post('age');
|
||||
if ($age) {
|
||||
$PluginModelVoice->age = $age;
|
||||
}
|
||||
$PluginModelVoice->save();
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
public function detail(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$PluginModelVoice = PluginModelVoice::where(['id' => $id, 'channels_uid' => $request->channels_uid, 'uid' => $request->uid])->find();
|
||||
if (!$PluginModelVoice) {
|
||||
return $this->fail('音色不存在');
|
||||
}
|
||||
return $this->resData($PluginModelVoice);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\State;
|
||||
use plugin\model\app\model\PluginModelVoiceText;
|
||||
use support\Request;
|
||||
|
||||
class VoiceTextController extends Basic
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$where[] = ['state', '=', State::YES['value']];
|
||||
$text = $request->get('text');
|
||||
if ($text) {
|
||||
$where[] = ['text', 'like', "%{$text}%"];
|
||||
}
|
||||
$list = PluginModelVoiceText::where($where)->order('id desc')->select();
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,765 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use app\expose\enum\Week;
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\utils\enum\ModelPointType;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use support\Request;
|
||||
|
||||
class ModelController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginModel();
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$builder->addAction('操作', [
|
||||
'width' => '200px',
|
||||
'fixed' => 'right'
|
||||
]);
|
||||
$builder->addTableAction('编辑', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/model/control/Model/update',
|
||||
'props' => [
|
||||
'title' => '编辑《{name}》'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addTableAction('删除', [
|
||||
'model' => Action::COMFIRM['value'],
|
||||
'path' => '/app/model/control/Model/delete',
|
||||
'where' => [
|
||||
['is_system', '!=', 1]
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'error',
|
||||
'message' => '确定要删除《{name}》吗?',
|
||||
'confirmButtonClass' => 'el-button--danger'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addHeader();
|
||||
$builder->addHeaderAction('创建', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/model/control/Model/create',
|
||||
'props' => [
|
||||
'title' => '创建'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addHeaderAction('初始化', [
|
||||
'model' => Action::COMFIRM['value'],
|
||||
'path' => '/app/model/control/Model/init',
|
||||
'props' => [
|
||||
'title' => '初始化'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('name', '模型名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '模型名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_type', '模型类型', 'select', '', [
|
||||
'options' => ModelType::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '模型类型搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_name', '模型名称(壹定)', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '模型名称(壹定)搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('assistant_name', '助手名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '助手名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('scene', '场景', 'select', '', [
|
||||
'options' => ModelScene::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '场景搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '80px'
|
||||
]
|
||||
]);
|
||||
$builder->add('icon', '模型图标', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width:40px;height:40px;'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('name', '模型名称(本地)', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_type', '模型类型', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelType::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '140px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_name', '模型名称(壹定)', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('assistant_name', '助手名称', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('sort', '排序(小到大)', [
|
||||
'props' => [
|
||||
'width' => '130px'
|
||||
]
|
||||
]);
|
||||
$builder->add('point', '积分', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('scene', '场景', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelScene::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'switch',
|
||||
'api' => '/app/model/control/Model/indexUpdateState',
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
],
|
||||
]);
|
||||
$builder->add('description', '描述', [
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name', 'like', "%{$name}%"];
|
||||
}
|
||||
$model_name = $request->get('model_name');
|
||||
if ($model_name) {
|
||||
$where[] = ['model_name', 'like', "%{$model_name}%"];
|
||||
}
|
||||
$assistant_name = $request->get('assistant_name');
|
||||
if ($assistant_name) {
|
||||
$where[] = ['assistant_name', 'like', "%{$assistant_name}%"];
|
||||
}
|
||||
$scene = $request->get('scene');
|
||||
if ($scene) {
|
||||
$where[] = ['scene', '=', $scene];
|
||||
}
|
||||
$model_type = $request->get('model_type');
|
||||
if ($model_type) {
|
||||
$where[] = ['model_type', '=', $model_type];
|
||||
}
|
||||
$list = PluginModel::where($where)->order('id desc')->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$D = $request->post();
|
||||
$D['channels_uid'] = $request->channels_uid;
|
||||
$model = new PluginModel();
|
||||
$model_type = $D['model_type'];
|
||||
switch ($model_type) {
|
||||
case ModelType::CHAT['value']:
|
||||
$ydModel = Yidevs::ChatModels($request->channels_uid, ['model_id' => $D['model_id']]);
|
||||
$ydAssistant = Yidevs::ChatAssistantlist($request->channels_uid, ['assistant_id' => $D['assistant_id']]);
|
||||
break;
|
||||
case ModelType::DRAW['value']:
|
||||
$ydModel = Yidevs::DrawModels($request->channels_uid, ['model_id' => $D['model_id']]);
|
||||
$ydAssistant = Yidevs::DrawAssistantlist($request->channels_uid, ['assistant_id' => $D['assistant_id']]);
|
||||
break;
|
||||
case ModelType::TOVIDEO['value']:
|
||||
$ydModel = Yidevs::VideoModels($request->channels_uid, ['model_id' => $D['model_id']]);
|
||||
$ydAssistant = Yidevs::VideoAssistantlist($request->channels_uid, ['assistant_id' => $D['assistant_id']]);
|
||||
break;
|
||||
case ModelType::AUDIO['value']:
|
||||
$ydModel = Yidevs::AudioModels($request->channels_uid, ['model_id' => $D['model_id']]);
|
||||
$ydAssistant = Yidevs::AudioAssistantlist($request->channels_uid, ['assistant_id' => $D['assistant_id']]);
|
||||
break;
|
||||
}
|
||||
if (!isset($ydModel[0])) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
if ($ydModel[0]['model_id'] != $D['model_id']) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
if (!isset($ydAssistant[0])) {
|
||||
return $this->fail('助手不存在');
|
||||
}
|
||||
if ($ydAssistant[0]['assistant_id'] != $D['assistant_id']) {
|
||||
return $this->fail('助手不存在');
|
||||
}
|
||||
$modelSelected = $ydModel[0];
|
||||
$D['model_name'] = $modelSelected['name'];
|
||||
if (!empty($modelSelected['form'])) {
|
||||
$D['form'] = $modelSelected['form'];
|
||||
}
|
||||
$assistantSelected = $ydAssistant[0];
|
||||
$D['assistant_name'] = $assistantSelected['name'];
|
||||
if ($model->save($D)) {
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
return $this->fail('创建失败');
|
||||
}
|
||||
$builder = $this->getFormBuilder($request);
|
||||
$builder->addValue('id', null);
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$D = $request->post();
|
||||
$model = PluginModel::where(['id' => $D['id']])->find();
|
||||
$model_type = $D['model_type'];
|
||||
switch ($model_type) {
|
||||
case ModelType::CHAT['value']:
|
||||
$ydModel = Yidevs::ChatModels($request->channels_uid, ['model_id' => $D['model_id']]);
|
||||
$ydAssistant = Yidevs::ChatAssistantlist($request->channels_uid, ['assistant_id' => $D['assistant_id']]);
|
||||
break;
|
||||
case ModelType::DRAW['value']:
|
||||
$ydModel = Yidevs::DrawModels($request->channels_uid, ['model_id' => $D['model_id']]);
|
||||
$ydAssistant = Yidevs::DrawAssistantlist($request->channels_uid, ['assistant_id' => $D['assistant_id']]);
|
||||
break;
|
||||
case ModelType::TOVIDEO['value']:
|
||||
$ydModel = Yidevs::VideoModels($request->channels_uid, ['model_id' => $D['model_id']]);
|
||||
$ydAssistant = Yidevs::VideoAssistantlist($request->channels_uid, ['assistant_id' => $D['assistant_id']]);
|
||||
break;
|
||||
case ModelType::AUDIO['value']:
|
||||
$ydModel = Yidevs::AudioModels($request->channels_uid, ['model_id' => $D['model_id']]);
|
||||
$ydAssistant = Yidevs::AudioAssistantlist($request->channels_uid, ['assistant_id' => $D['assistant_id']]);
|
||||
break;
|
||||
}
|
||||
if (!isset($ydModel[0])) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
if ($ydModel[0]['model_id'] != $D['model_id']) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
if (!isset($ydAssistant[0])) {
|
||||
return $this->fail('助手不存在');
|
||||
}
|
||||
if ($ydAssistant[0]['assistant_id'] != $D['assistant_id']) {
|
||||
return $this->fail('助手不存在');
|
||||
}
|
||||
$modelSelected = $ydModel[0];
|
||||
$D['model_name'] = $modelSelected['name'];
|
||||
if (!empty($modelSelected['form'])) {
|
||||
$D['form'] = $modelSelected['form'];
|
||||
}
|
||||
$assistantSelected = $ydAssistant[0];
|
||||
$D['assistant_name'] = $assistantSelected['name'];
|
||||
if ($model->save($D)) {
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
return $this->fail('更新失败');
|
||||
}
|
||||
$id = $request->get('id');
|
||||
$model = PluginModel::where(['id' => $id])->find();
|
||||
$builder = $this->getFormBuilder($request);
|
||||
$builder->setData($model->toArray());
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
public function getFormBuilder(Request $request)
|
||||
{
|
||||
$Component = new ComponentBuilder();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'labelPosition' => 'right',
|
||||
'label-width' => "200px",
|
||||
'class' => 'w-80 mx-auto',
|
||||
'size' => 'large'
|
||||
]);
|
||||
$formBuilder->add('icon', '模型图标', 'bundle', '', [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'accept' => 'image/jpeg,image/png,image/jpg',
|
||||
'multiple' => 1,
|
||||
'size' => 2
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('name', '模型名称', 'input', '', [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'placeholder' => '模型名称'
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_type', '模型类别', 'radio', ModelType::CHAT['value'], [
|
||||
'required' => true,
|
||||
'options' => ModelType::getOptions(),
|
||||
'subProps' => [
|
||||
'border' => true
|
||||
],
|
||||
'where' => [
|
||||
['id', 'null', null]
|
||||
]
|
||||
]);
|
||||
# 对话模型
|
||||
$ydModel = Yidevs::ChatModels($request->channels_uid);
|
||||
$modelList = $assistantList = [];
|
||||
foreach ($ydModel as $model) {
|
||||
$modelList[] = [
|
||||
'value' => $model['model_id'],
|
||||
'tips' => $model['integral'] . $model['integral_unit'],
|
||||
'label' => $model['name']
|
||||
];
|
||||
}
|
||||
$ydAssistant = Yidevs::ChatAssistantlist($request->channels_uid);
|
||||
foreach ($ydAssistant as $assistant) {
|
||||
$assistantList[] = [
|
||||
'value' => $assistant['assistant_id'],
|
||||
'tips' => $assistant['integral'] . $assistant['integral_unit'],
|
||||
'label' => $assistant['name']
|
||||
];
|
||||
}
|
||||
$formBuilder->add('model_id', '绑定模型', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => $modelList,
|
||||
'where' => [
|
||||
['model_type', '=', ModelType::CHAT['value']]
|
||||
],
|
||||
'props' => [
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('assistant_id', '绑定助手', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => $assistantList,
|
||||
'where' => [
|
||||
['model_type', '=', ModelType::CHAT['value']]
|
||||
],
|
||||
'props' => [
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
# 绘图模型
|
||||
$ydModel = Yidevs::DrawModels($request->channels_uid);
|
||||
$modelList = $assistantList = [];
|
||||
foreach ($ydModel as $model) {
|
||||
$modelList[] = [
|
||||
'value' => $model['model_id'],
|
||||
'tips' => $model['integral'] . $model['integral_unit'],
|
||||
'label' => $model['name']
|
||||
];
|
||||
}
|
||||
$ydAssistant = Yidevs::DrawAssistantlist($request->channels_uid);
|
||||
foreach ($ydAssistant as $assistant) {
|
||||
$assistantList[] = [
|
||||
'value' => $assistant['assistant_id'],
|
||||
'tips' => $assistant['integral'] . $assistant['integral_unit'],
|
||||
'label' => $assistant['name']
|
||||
];
|
||||
}
|
||||
$formBuilder->add('model_id', '绑定模型', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => $modelList,
|
||||
'where' => [
|
||||
['model_type', '=', ModelType::DRAW['value']]
|
||||
],
|
||||
'props' => [
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('assistant_id', '绑定助手', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => $assistantList,
|
||||
'where' => [
|
||||
['model_type', '=', ModelType::DRAW['value']]
|
||||
],
|
||||
'props' => [
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
# 视频模型
|
||||
$ydModel = Yidevs::VideoModels($request->channels_uid);
|
||||
$modelList = $assistantList = [];
|
||||
foreach ($ydModel as $model) {
|
||||
$modelList[] = [
|
||||
'value' => $model['model_id'],
|
||||
'tips' => $model['integral'] . $model['integral_unit'],
|
||||
'label' => $model['name']
|
||||
];
|
||||
}
|
||||
$ydAssistant = Yidevs::VideoAssistantlist($request->channels_uid);
|
||||
foreach ($ydAssistant as $assistant) {
|
||||
$assistantList[] = [
|
||||
'value' => $assistant['assistant_id'],
|
||||
'tips' => $assistant['integral'] . $assistant['integral_unit'],
|
||||
'label' => $assistant['name']
|
||||
];
|
||||
}
|
||||
$formBuilder->add('model_id', '绑定模型', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => $modelList,
|
||||
'where' => [
|
||||
['model_type', '=', ModelType::TOVIDEO['value']]
|
||||
],
|
||||
'props' => [
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('assistant_id', '绑定助手', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => $assistantList,
|
||||
'where' => [
|
||||
['model_type', '=', ModelType::TOVIDEO['value']]
|
||||
],
|
||||
'props' => [
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
# 音频模型
|
||||
$ydModel = Yidevs::AudioModels($request->channels_uid);
|
||||
$modelList = $assistantList = [];
|
||||
foreach ($ydModel as $model) {
|
||||
$modelList[] = [
|
||||
'value' => $model['model_id'],
|
||||
'tips' => $model['integral'] . $model['integral_unit'],
|
||||
'label' => $model['name']
|
||||
];
|
||||
}
|
||||
$ydAssistant = Yidevs::AudioAssistantlist($request->channels_uid);
|
||||
foreach ($ydAssistant as $assistant) {
|
||||
$assistantList[] = [
|
||||
'value' => $assistant['assistant_id'],
|
||||
'tips' => $assistant['integral'] . $assistant['integral_unit'],
|
||||
'label' => $assistant['name']
|
||||
];
|
||||
}
|
||||
$formBuilder->add('model_id', '绑定模型', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => $modelList,
|
||||
'where' => [
|
||||
['model_type', '=', ModelType::AUDIO['value']]
|
||||
],
|
||||
'props' => [
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('assistant_id', '绑定助手', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => $assistantList,
|
||||
'where' => [
|
||||
['model_type', '=', ModelType::AUDIO['value']]
|
||||
],
|
||||
'props' => [
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
|
||||
$formBuilder->add('state', '状态', 'switch', State::YES['value'], [
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('point', '扣除数量', 'input-number', '', [
|
||||
'required' => true,
|
||||
]);
|
||||
$formBuilder->add('point_type', '计费类型', 'radio', ModelPointType::TIMES['value'], [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 12,
|
||||
'md' => 16,
|
||||
'lg' => 18,
|
||||
'xl' => 20
|
||||
],
|
||||
'required' => true,
|
||||
'options' => ModelPointType::getOptions(),
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '计费类型'], ['type' => 'info', 'size' => 'small'])
|
||||
->add('text', ['default' => ModelPointType::FIELD_RULE['label'] . ':通过表单中,组件选择器、单选框、多选框的值中的基础点数和倍数计算点数'], ['type' => 'info', 'size' => 'small'])
|
||||
->builder()
|
||||
],
|
||||
'subProps' => [
|
||||
'border' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('scene', '场景', 'select', '', [
|
||||
'required' => true,
|
||||
'options' => ModelScene::getOptions()
|
||||
]);
|
||||
$formBuilder->add('sort', '排序(小到大)', 'input-number', '', [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'placeholder' => '排序(小到大)'
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('description', '描述', 'input', '', [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'type' => 'textarea',
|
||||
'autosize' => [
|
||||
'minRows' => 4,
|
||||
'maxRows' => 20
|
||||
],
|
||||
'placeholder' => '描述'
|
||||
]
|
||||
]);
|
||||
return $formBuilder;
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$model = PluginModel::where(['id' => $id])->find();
|
||||
if ($model->delete()) {
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据方法
|
||||
* 从 JSON 文件读取数据并写入数据库
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function init(Request $request)
|
||||
{
|
||||
// 从请求中获取 uid(channels_uid)
|
||||
$uid = $request->channels_uid;
|
||||
if (empty($uid)) {
|
||||
return $this->fail('缺少渠道参数');
|
||||
}
|
||||
|
||||
// JSON 文件路径(放在 plugin/model 目录下)
|
||||
$jsonFile = base_path('plugin/model/modal.json');
|
||||
|
||||
// 检查文件是否存在
|
||||
if (!file_exists($jsonFile)) {
|
||||
return $this->fail('初始化数据文件不存在:' . $jsonFile);
|
||||
}
|
||||
|
||||
// 读取 JSON 文件内容
|
||||
$jsonContent = file_get_contents($jsonFile);
|
||||
if ($jsonContent === false) {
|
||||
return $this->fail('读取初始化数据文件失败');
|
||||
}
|
||||
|
||||
// 解析 JSON 数据
|
||||
$dataList = json_decode($jsonContent, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
return $this->fail('JSON 数据格式错误:' . json_last_error_msg());
|
||||
}
|
||||
|
||||
// 确保是数组格式
|
||||
if (!is_array($dataList)) {
|
||||
return $this->fail('JSON 数据格式错误:必须是数组格式');
|
||||
}
|
||||
|
||||
// 定义需要排除的字段(id 和 channels_uid)
|
||||
$excludeFields = ['id', 'channels_uid'];
|
||||
|
||||
// 定义允许的字段(除了 id 和 channels_uid 之外的所有字段)
|
||||
$allowedFields = [
|
||||
'name',
|
||||
'icon',
|
||||
'model_type',
|
||||
'model_id',
|
||||
'model_name',
|
||||
'assistant_id',
|
||||
'assistant_name',
|
||||
'scene',
|
||||
'point',
|
||||
'state',
|
||||
'sort',
|
||||
'description',
|
||||
'create_time',
|
||||
'update_time'
|
||||
];
|
||||
|
||||
$successCount = 0;
|
||||
$failCount = 0;
|
||||
$skipCount = 0;
|
||||
$errors = [];
|
||||
|
||||
// 遍历数据并插入数据库
|
||||
foreach ($dataList as $index => $data) {
|
||||
try {
|
||||
// 过滤掉不需要的字段
|
||||
$insertData = [];
|
||||
foreach ($allowedFields as $field) {
|
||||
if (isset($data[$field])) {
|
||||
$insertData[$field] = $data[$field];
|
||||
}
|
||||
}
|
||||
|
||||
// 检查必填字段
|
||||
if (!isset($insertData['model_id']) || !isset($insertData['assistant_id']) || !isset($insertData['scene'])) {
|
||||
$failCount++;
|
||||
$errors[] = "第 " . ($index + 1) . " 条数据缺少必填字段(model_id、assistant_id、scene)";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 设置 channels_uid
|
||||
$insertData['channels_uid'] = $uid;
|
||||
|
||||
// 检查是否存在相同的数据(model_id、assistant_id、scene、channels_uid)
|
||||
$exists = PluginModel::where([
|
||||
'model_id' => $insertData['model_id'],
|
||||
'assistant_id' => $insertData['assistant_id'],
|
||||
'scene' => $insertData['scene'],
|
||||
'channels_uid' => $uid
|
||||
])->find();
|
||||
|
||||
// 如果存在相同数据,跳过
|
||||
if ($exists) {
|
||||
$skipCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 如果没有设置 create_time,则使用当前时间
|
||||
if (!isset($insertData['create_time'])) {
|
||||
$insertData['create_time'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
// 如果没有设置 update_time,则使用当前时间
|
||||
if (!isset($insertData['update_time'])) {
|
||||
$insertData['update_time'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
// 如果没有设置 state,则默认为 1
|
||||
if (!isset($insertData['state'])) {
|
||||
$insertData['state'] = 1;
|
||||
}
|
||||
|
||||
// 如果没有设置 sort,则默认为 0
|
||||
if (!isset($insertData['sort'])) {
|
||||
$insertData['sort'] = 0;
|
||||
}
|
||||
|
||||
// 创建模型实例并保存
|
||||
$model = new PluginModel();
|
||||
if ($model->save($insertData)) {
|
||||
$successCount++;
|
||||
} else {
|
||||
$failCount++;
|
||||
$errors[] = "第 " . ($index + 1) . " 条数据保存失败";
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$failCount++;
|
||||
$errors[] = "第 " . ($index + 1) . " 条数据保存失败:" . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// 返回结果
|
||||
$message = "初始化完成,成功:{$successCount} 条";
|
||||
if ($skipCount > 0) {
|
||||
$message .= ",跳过:{$skipCount} 条(已存在相同数据)";
|
||||
}
|
||||
if ($failCount > 0) {
|
||||
$message .= ",失败:{$failCount} 条";
|
||||
if (!empty($errors)) {
|
||||
$message .= "。" . implode('; ', array_slice($errors, 0, 5)); // 只显示前5个错误
|
||||
if (count($errors) > 5) {
|
||||
$message .= "(还有 " . (count($errors) - 5) . " 个错误)";
|
||||
}
|
||||
}
|
||||
return $this->fail($message);
|
||||
}
|
||||
|
||||
return $this->success($message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use app\expose\enum\Week;
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use support\Request;
|
||||
|
||||
class TaskController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginModelTask();
|
||||
}
|
||||
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$builder->addTableAction('重试', [
|
||||
'model' => Action::COMFIRM['value'],
|
||||
'path' => '/app/model/control/Task/retry',
|
||||
'where' => [
|
||||
['retry', '=', 1]
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
'message' => '确定要重试《{task_id}》任务吗?',
|
||||
'confirmButtonClass' => 'el-button--danger'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('task_id', '任务ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '任务ID搜索',
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('user_id', '用户ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '用户ID搜索',
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_type', '模型类型', 'select', '', [
|
||||
'options' => ModelType::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '模型类型搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('status', '状态', 'select', '', [
|
||||
'options' => ModelTaskStatus::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '状态搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
|
||||
$formBuilder->add('model_name', '模型名称(壹定)', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '模型名称(壹定)搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('scene', '场景', 'select', '', [
|
||||
'options' => ModelScene::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '场景搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
// $builder->addAction('操作', [
|
||||
// 'width' => '200px',
|
||||
// 'fixed' => 'right'
|
||||
// ]);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('task_id', '任务ID', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_name', '模型名称', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model_type', '模型类型', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelType::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('status', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelTaskStatus::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('scene', '场景', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelScene::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.image_path', '图片', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width:40px;height:40px;'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.video_path', '视频', [
|
||||
'component' => [
|
||||
'name' => 'link',
|
||||
'props' => [
|
||||
'target' => '_blank'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.audio_path', '音频', [
|
||||
'component' => [
|
||||
'name' => 'link',
|
||||
'props' => [
|
||||
'target' => '_blank'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('result.message', '错误消息', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'text',
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['pmt.channels_uid', '=', $request->channels_uid];
|
||||
$model_name = $request->get('model_name');
|
||||
if ($model_name) {
|
||||
$where[] = ['pm.name', 'like', "%{$model_name}%"];
|
||||
}
|
||||
$model_type = $request->get('model_type');
|
||||
if ($model_type) {
|
||||
$where[] = ['pm.model_type', '=', $model_type];
|
||||
}
|
||||
$scene = $request->get('scene');
|
||||
if ($scene) {
|
||||
$where[] = ['pm.scene', '=', $scene];
|
||||
}
|
||||
$status = $request->get('status');
|
||||
if ($status) {
|
||||
$where[] = ['pmt.status', '=', $status];
|
||||
}
|
||||
$task_id = $request->get('task_id');
|
||||
if ($task_id) {
|
||||
$where[] = ['pmt.task_id', '=', $task_id];
|
||||
}
|
||||
$user_id = $request->get('user_id');
|
||||
if ($user_id) {
|
||||
$where[] = ['pmt.uid', '=', $user_id];
|
||||
}
|
||||
$list = PluginModelTask::alias('pmt')
|
||||
->join('plugin_model pm', 'pmt.model_id = pm.id')
|
||||
->with(['user' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile,channels_uid');
|
||||
}, 'result' => function ($query) {
|
||||
$query->field('task_id,result,image,image_path,video_path,message,channels_uid');
|
||||
}])
|
||||
->field('pmt.*,pm.name as model_name')
|
||||
->where($where)
|
||||
->order('pmt.id desc')
|
||||
->paginate($limit)->each(function ($item) {
|
||||
$item->retry = 0;
|
||||
if (in_array($item->status, [ModelTaskStatus::PROCESSING['value'], ModelTaskStatus::DOWNLOADING['value'], ModelTaskStatus::UPLOADING['value']]) && $item->update_time < date('Y-m-d H:i:s', strtotime('-30 minutes'))) {
|
||||
$item->retry = 1;
|
||||
}
|
||||
});
|
||||
return $this->resData($list);
|
||||
}
|
||||
public function retry(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$PluginModelTask = PluginModelTask::where('id', $id)->find();
|
||||
if (!$PluginModelTask) {
|
||||
return $this->fail('任务不存在');
|
||||
}
|
||||
switch ($PluginModelTask->status) {
|
||||
case ModelTaskStatus::PROCESSING['value']:
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT['value'];
|
||||
break;
|
||||
case ModelTaskStatus::DOWNLOADING['value']:
|
||||
case ModelTaskStatus::UPLOADING['value']:
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT_DOWNLOAD['value'];
|
||||
break;
|
||||
}
|
||||
$PluginModelTask->save();
|
||||
return $this->success('重试成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\app\model\PluginModelVoice;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelVoiceStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use support\Request;
|
||||
|
||||
class VoiceController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginModelVoice();
|
||||
}
|
||||
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$channelList = PluginChannelsUser::options();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('task_id', '任务ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '任务ID搜索',
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('user_id', '用户ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '用户ID搜索',
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('model_id', '模型', 'select', '', [
|
||||
'options' => PluginModel::options(['scene' => ModelScene::DIALOGUE_VOICE['value']]),
|
||||
'props' => [
|
||||
'placeholder' => '模型搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('status', '状态', 'select', '', [
|
||||
'options' => ModelVoiceStatus::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '状态搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
// $builder->addAction('操作', [
|
||||
// 'width' => '200px',
|
||||
// 'fixed' => 'right'
|
||||
// ]);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('task_id', '任务ID', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('model.name', '模型名称', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('status', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ModelVoiceStatus::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '120px'
|
||||
]
|
||||
]);
|
||||
$builder->add('message', '错误消息', [
|
||||
'props' => [
|
||||
'minWidth' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'text',
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$model_id = $request->get('model_id');
|
||||
if ($model_id) {
|
||||
$where[] = ['model_id', '=', $model_id];
|
||||
}
|
||||
$status = $request->get('status');
|
||||
if ($status) {
|
||||
$where[] = ['status', '=', $status];
|
||||
}
|
||||
$task_id = $request->get('task_id');
|
||||
if ($task_id) {
|
||||
$where[] = ['task_id', '=', $task_id];
|
||||
}
|
||||
$user_id = $request->get('user_id');
|
||||
if ($user_id) {
|
||||
$where[] = ['uid', '=', $user_id];
|
||||
}
|
||||
$list = PluginModelVoice::where($where)
|
||||
->with(['user' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile,channels_uid');
|
||||
}, 'model' => function ($query) {
|
||||
$query->field('id,name');
|
||||
}])
|
||||
->order('id desc')
|
||||
->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use plugin\model\app\model\PluginModelVoiceText;
|
||||
use support\Request;
|
||||
|
||||
class VoiceTextController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginModelVoiceText();
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$builder->addAction('操作', [
|
||||
'width' => '200px',
|
||||
'fixed' => 'right'
|
||||
]);
|
||||
$builder->addTableAction('编辑', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/model/control/VoiceText/update',
|
||||
'props' => [
|
||||
'title' => '编辑《{name}》'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addTableAction('删除', [
|
||||
'model' => Action::COMFIRM['value'],
|
||||
'path' => '/app/model/control/VoiceText/delete',
|
||||
'props' => [
|
||||
'type' => 'error',
|
||||
'message' => '确定要删除《{name}》吗?',
|
||||
'confirmButtonClass' => 'el-button--danger'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addHeader();
|
||||
$builder->addHeaderAction('创建', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/model/control/VoiceText/create',
|
||||
'props' => [
|
||||
'title' => '创建'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('text', '文案', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '文案搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '80px'
|
||||
]
|
||||
]);
|
||||
$builder->add('text', '文案', []);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'switch',
|
||||
'api' => '/app/model/control/VoiceText/indexUpdateState',
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
],
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$text = $request->get('text');
|
||||
if ($text) {
|
||||
$where[] = ['text', 'like', "%{$text}%"];
|
||||
}
|
||||
$list = PluginModelVoiceText::where($where)->order('id desc')->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$data = $request->post();
|
||||
$data['channels_uid'] = $request->channels_uid;
|
||||
$model = new PluginModelVoiceText();
|
||||
if ($model->save($data)) {
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
return $this->fail('创建失败');
|
||||
}
|
||||
$builder = $this->getFormBuilder($request);
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$D = $request->post();
|
||||
$model = PluginModelVoiceText::where(['id' => $D['id']])->find();
|
||||
if ($model->save($D)) {
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
return $this->fail('更新失败');
|
||||
}
|
||||
$id = $request->get('id');
|
||||
$model = PluginModelVoiceText::where(['id' => $id])->find();
|
||||
$builder = $this->getFormBuilder($request);
|
||||
$builder->setData($model->toArray());
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
public function getFormBuilder(Request $request)
|
||||
{
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'labelPosition' => 'right',
|
||||
'label-width' => "200px",
|
||||
'class' => 'w-80 mx-auto',
|
||||
'size' => 'large'
|
||||
]);
|
||||
$formBuilder->add('state', '状态', 'switch', State::YES['value'], [
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('text', '文案', 'input', '', [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'type' => 'textarea',
|
||||
'autosize' => [
|
||||
'minRows' => 4,
|
||||
'maxRows' => 20
|
||||
],
|
||||
'placeholder' => '文案'
|
||||
]
|
||||
]);
|
||||
return $formBuilder;
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$model = PluginModelVoiceText::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
|
||||
if ($model->delete()) {
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\State;
|
||||
use plugin\finance\expose\helper\Account;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\app\model\PluginModelVoice;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use plugin\model\utils\enum\ModelVoiceStatus;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayActorCharacterLook;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use plugin\shortplay\utils\enum\PropStatus;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use think\facade\Db;
|
||||
|
||||
class NotifyController extends Basic
|
||||
{
|
||||
public function draw(Request $request)
|
||||
{
|
||||
Log::error('draw' . json_encode($request->post()));
|
||||
$taskId = $request->post('task_id');
|
||||
$PluginModelTask = PluginModelTask::where(['task_id' => $taskId, 'model_type' => ModelType::DRAW['value']])->with(['result'])->find();
|
||||
if (!$PluginModelTask) {
|
||||
return 'success';
|
||||
}
|
||||
$status = $request->post('status');
|
||||
if ($status == ModelTaskStatus::SUCCESS['value']) {
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT_DOWNLOAD['value'];
|
||||
$PluginModelTask->result->result = $request->post();
|
||||
$PluginModelTask->result->image = $request->post('url');
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
} elseif ($status == ModelTaskStatus::FAIL['value']) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->result->result = $request->post();
|
||||
$PluginModelTask->result->message = $request->post('message');
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
if (!empty($PluginModelTask->consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($PluginModelTask->uid, $PluginModelTask->channels_uid, $PluginModelTask->consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
$pushData = [
|
||||
'id' => $PluginModelTask->alias_id
|
||||
];
|
||||
switch ($PluginModelTask->scene) {
|
||||
case ModelScene::ACTOR_IMAGE['value']:
|
||||
$PluginModelTask = PluginModelTask::where(['pre_task_id' => $PluginModelTask->id, 'status' => ModelTaskStatus::WAIT['value']])->find();
|
||||
if ($PluginModelTask) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->save();
|
||||
if (!empty($PluginModelTask->consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($PluginModelTask->uid, $PluginModelTask->channels_uid, $PluginModelTask->consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
$pushData['status'] = ActorStatus::INITIALIZING;
|
||||
break;
|
||||
case ModelScene::PROP_IMAGE['value']:
|
||||
$PluginModelTask = PluginModelTask::where(['pre_task_id' => $PluginModelTask->id, 'status' => ModelTaskStatus::WAIT['value']])->find();
|
||||
if ($PluginModelTask) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->save();
|
||||
if (!empty($PluginModelTask->consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($PluginModelTask->uid, $PluginModelTask->channels_uid, $PluginModelTask->consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
$pushData['status'] = PropStatus::INITIALIZING;
|
||||
break;
|
||||
case ModelScene::ACTOR_COSTUME['value']:
|
||||
$PluginModelTask = PluginModelTask::where(['pre_task_id' => $PluginModelTask->id, 'status' => ModelTaskStatus::WAIT['value']])->find();
|
||||
if ($PluginModelTask) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->save();
|
||||
if (!empty($PluginModelTask->consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($PluginModelTask->uid, $PluginModelTask->channels_uid, $PluginModelTask->consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
$PluginShortplayActorCharacterLook = PluginShortplayActorCharacterLook::where(['id' => $PluginModelTask->alias_id])->find();
|
||||
$PluginShortplayActorCharacterLook->delete();
|
||||
$pushData['storyboard_id'] = $PluginShortplayActorCharacterLook->storyboard_id;
|
||||
$pushData['episode_id'] = $PluginShortplayActorCharacterLook->episode_id;
|
||||
$pushData['drama_id'] = $PluginShortplayActorCharacterLook->drama_id;
|
||||
$pushData['actor_id'] = $PluginShortplayActorCharacterLook->actor_id;
|
||||
break;
|
||||
case ModelScene::ACTOR_THREE_VIEW_IMAGE['value']:
|
||||
$pushData['status'] = ActorStatus::INITIALIZING;
|
||||
break;
|
||||
case ModelScene::PROP_THREE_VIEW_IMAGE['value']:
|
||||
$pushData['status'] = PropStatus::INITIALIZING;
|
||||
break;
|
||||
case ModelScene::ACTOR_COSTUME_THREE_VIEW['value']:
|
||||
$PluginShortplayActorCharacterLook = PluginShortplayActorCharacterLook::where(['id' => $PluginModelTask->alias_id])->find();
|
||||
$PluginShortplayActorCharacterLook->delete();
|
||||
$pushData['storyboard_id'] = $PluginShortplayActorCharacterLook->storyboard_id;
|
||||
$pushData['episode_id'] = $PluginShortplayActorCharacterLook->episode_id;
|
||||
$pushData['drama_id'] = $PluginShortplayActorCharacterLook->drama_id;
|
||||
$pushData['actor_id'] = $PluginShortplayActorCharacterLook->actor_id;
|
||||
break;
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $PluginModelTask->uid,
|
||||
'channels_uid' => $PluginModelTask->channels_uid,
|
||||
'event' => 'generate' . strtolower(str_replace('_', '', $PluginModelTask->scene)),
|
||||
], $pushData);
|
||||
}
|
||||
return 'success';
|
||||
}
|
||||
public function video(Request $request)
|
||||
{
|
||||
Log::error('video' . json_encode($request->post()));
|
||||
$taskId = $request->post('task_id');
|
||||
$PluginModelTask = PluginModelTask::where(['task_id' => $taskId, 'model_type' => ModelType::TOVIDEO['value']])->with(['result'])->find();
|
||||
if (!$PluginModelTask) {
|
||||
return 'success';
|
||||
}
|
||||
$status = $request->post('status');
|
||||
if ($status == ModelTaskStatus::SUCCESS['value']) {
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT_DOWNLOAD['value'];
|
||||
$PluginModelTask->result->result = $request->post();
|
||||
$PluginModelTask->result->video = $request->post('url');
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
} elseif ($status == ModelTaskStatus::FAIL['value']) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->result->result = $request->post();
|
||||
$PluginModelTask->result->message = $request->post('message');
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
if (!empty($PluginModelTask->consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($PluginModelTask->uid, $PluginModelTask->channels_uid, $PluginModelTask->consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
$pushData = [
|
||||
'id' => $PluginModelTask->alias_id
|
||||
];
|
||||
Push::send([
|
||||
'uid' => $PluginModelTask->uid,
|
||||
'channels_uid' => $PluginModelTask->channels_uid,
|
||||
'event' => 'generate' . strtolower(str_replace('_', '', $PluginModelTask->scene)),
|
||||
], $pushData);
|
||||
}
|
||||
return 'success';
|
||||
}
|
||||
public function audio(Request $request)
|
||||
{
|
||||
Log::error('audio' . json_encode($request->post()));
|
||||
$taskId = $request->post('task_id');
|
||||
$PluginModelTask = PluginModelTask::where(['task_id' => $taskId, 'model_type' => ModelType::AUDIO['value']])->with(['result'])->find();
|
||||
$status = $request->post('status');
|
||||
if ($status == ModelTaskStatus::SUCCESS['value']) {
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT_DOWNLOAD['value'];
|
||||
$PluginModelTask->result->result = $request->post();
|
||||
$PluginModelTask->result->audio = $request->post('url');
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
} elseif ($status == ModelTaskStatus::FAIL['value']) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->result->result = $request->post();
|
||||
$PluginModelTask->result->message = $request->post('message');
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
if (!empty($PluginModelTask->consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($PluginModelTask->uid, $PluginModelTask->channels_uid, $PluginModelTask->consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
$pushData = [
|
||||
'id' => $PluginModelTask->alias_id
|
||||
];
|
||||
Push::send([
|
||||
'uid' => $PluginModelTask->uid,
|
||||
'channels_uid' => $PluginModelTask->channels_uid,
|
||||
'event' => 'generate' . strtolower(str_replace('_', '', $PluginModelTask->scene)),
|
||||
], $pushData);
|
||||
}
|
||||
return 'success';
|
||||
}
|
||||
public function voiceClone(Request $request)
|
||||
{
|
||||
Log::error('voiceClone' . json_encode($request->post()));
|
||||
$taskId = $request->post('task_id');
|
||||
$PluginModelVoice = PluginModelVoice::where(['task_id' => $taskId])->find();
|
||||
if (!$PluginModelVoice) {
|
||||
return 'success';
|
||||
}
|
||||
$status = $request->post('status');
|
||||
if ($status == ModelTaskStatus::SUCCESS['value']) {
|
||||
$PluginModelVoice->status = ModelVoiceStatus::SUCCESS['value'];
|
||||
$PluginModelVoice->voice_id = $request->post('voice_id');
|
||||
$PluginModelVoice->save();
|
||||
$pushData = [
|
||||
'id' => $PluginModelVoice->id,
|
||||
'status' => ModelVoiceStatus::SUCCESS['value'],
|
||||
];
|
||||
} elseif ($status == ModelTaskStatus::FAIL['value']) {
|
||||
$PluginModelVoice->status = ModelVoiceStatus::FAIL['value'];
|
||||
$PluginModelVoice->message = $request->post('message');
|
||||
$PluginModelVoice->save();
|
||||
$pushData = [
|
||||
'id' => $PluginModelVoice->id,
|
||||
'status' => ModelVoiceStatus::FAIL['value'],
|
||||
];
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $PluginModelVoice->uid,
|
||||
'event' => 'clonevoice',
|
||||
], $pushData);
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Here is your custom functions.
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
class PluginModel extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
'form' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function getIconAttr($value,$data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setIconAttr($value,$data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
public static function options($where = [])
|
||||
{
|
||||
$models = self::where($where)->field('id,name')->select();
|
||||
$data = [];
|
||||
foreach ($models as $item) {
|
||||
$data[] = [
|
||||
'label' => $item->name,
|
||||
'value' => $item->id,
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\user\app\model\PluginUser;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
|
||||
class PluginModelTask extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
'consume_ids' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function result()
|
||||
{
|
||||
return $this->hasOne(PluginModelTaskResult::class, 'task_id', 'id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(PluginUser::class, 'id', 'uid');
|
||||
}
|
||||
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
public static function processing($where = [])
|
||||
{
|
||||
return self::where($where)->whereIn('status', [ModelTaskStatus::WAIT['value'],ModelTaskStatus::PROCESSING['value'], ModelTaskStatus::WAIT_DOWNLOAD['value'], ModelTaskStatus::DOWNLOADING['value'], ModelTaskStatus::UPLOADING['value']])->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
|
||||
class PluginModelTaskResult extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
// 设置JSON字段的类型
|
||||
'params' => 'json',
|
||||
'result' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function getImagePathAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setImagePathAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getAudioPathAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setAudioPathAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getVideoPathAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setVideoPathAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\user\app\model\PluginUser;
|
||||
|
||||
class PluginModelVoice extends Basic
|
||||
{
|
||||
public function getAudioAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setAudioAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function model()
|
||||
{
|
||||
return $this->hasOne(PluginModel::class, 'id', 'model_id');
|
||||
}
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(PluginUser::class, 'id', 'uid');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
|
||||
class PluginModelVoiceText extends Basic
|
||||
{
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use support\Request;
|
||||
|
||||
return [
|
||||
'debug' => true,
|
||||
'controller_suffix' => 'Controller',
|
||||
'controller_reuse' => false
|
||||
];
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
return [
|
||||
'files' => [
|
||||
base_path() . '/plugin/model/app/functions.php',
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
return new Webman\Container;
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'' => app\exception\Handler::class,
|
||||
];
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'' => [
|
||||
app\middleware\Template::class,
|
||||
app\middleware\Platform::class
|
||||
],
|
||||
'control' => [
|
||||
plugin\control\expose\middleware\ControlAuth::class
|
||||
],
|
||||
'admin' => [
|
||||
app\expose\middleware\AdminAuth::class
|
||||
],
|
||||
'api' => [
|
||||
plugin\control\expose\middleware\DomainMapping::class,
|
||||
plugin\user\expose\middleware\UserAuth::class,
|
||||
plugin\user\expose\middleware\Twofa::class,
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use plugin\model\process\audio\AudioTransfer;
|
||||
use plugin\model\process\chat\Submit;
|
||||
use plugin\model\process\draw\ImageTransfer;
|
||||
use plugin\model\process\video\VideoTransfer;
|
||||
use Workerman\Events\Select;
|
||||
|
||||
return [
|
||||
'ChatSubmit' => [
|
||||
'eventLoop' => Select::class,
|
||||
'handler' => Submit::class,
|
||||
'count' => 5
|
||||
],
|
||||
'ImageTransfer' => [
|
||||
'eventLoop' => Select::class,
|
||||
'handler' => ImageTransfer::class,
|
||||
'count' => 5
|
||||
],
|
||||
'VideoTransfer' => [
|
||||
'eventLoop' => Select::class,
|
||||
'handler' => VideoTransfer::class,
|
||||
'count' => 5
|
||||
],
|
||||
'AudioTransfer' => [
|
||||
'eventLoop' => Select::class,
|
||||
'handler' => AudioTransfer::class,
|
||||
'count' => 5
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
|
||||
$Component = new ComponentBuilder;
|
||||
return [
|
||||
[
|
||||
#配置项名称
|
||||
'title' => '配置项名称',
|
||||
#配置项字段
|
||||
'field' => 'web_name',
|
||||
#配置项值
|
||||
'value' => 'FastMovie',
|
||||
#配置项组件
|
||||
'component' => 'input',
|
||||
#配置项额外属性
|
||||
'extra' => [
|
||||
#是否必填
|
||||
'required' => true,
|
||||
#element-plus表单中的rules规则
|
||||
'rules' => [
|
||||
['type'=>'string','required'=>true,'message'=>'请输入配置项值']
|
||||
],
|
||||
#使用接口验证
|
||||
'rules_api' => [
|
||||
'url' => '/app/model/example/test'
|
||||
],
|
||||
#提示
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '提示信息'], ['type' => 'info', 'size' => 'small'])
|
||||
->builder()
|
||||
],
|
||||
#组件属性
|
||||
'props' => [
|
||||
'type' => 'text',
|
||||
'placeholder' => '请输入应用名称'
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of webman.
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the MIT-LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @author walkor<walkor@workerman.net>
|
||||
* @copyright walkor<walkor@workerman.net>
|
||||
* @link http://www.workerman.net/
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Multilingual configuration
|
||||
*/
|
||||
return [
|
||||
// Default language
|
||||
'locale' => 'zh_CN',
|
||||
// Fallback language
|
||||
'fallback_locale' => ['zh_CN', 'en'],
|
||||
// Folder where language files are stored
|
||||
'path' => base_path() . '/plugin/model/resource/translations',
|
||||
];
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of webman.
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the MIT-LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @author walkor<walkor@workerman.net>
|
||||
* @copyright walkor<walkor@workerman.net>
|
||||
* @link http://www.workerman.net/
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
use support\view\Raw;
|
||||
use support\view\Twig;
|
||||
use support\view\Blade;
|
||||
// use support\view\ThinkPHP;
|
||||
use support\ThinkPHP;
|
||||
|
||||
return [
|
||||
'handler' => ThinkPHP::class,
|
||||
];
|
||||
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"title": "模型",
|
||||
"icon": "Grid",
|
||||
"path": "/app/Model/control",
|
||||
"sort": 999,
|
||||
"children": [
|
||||
{
|
||||
"title": "模型管理",
|
||||
"path": "/app/model/control/Model/index",
|
||||
"component": "table",
|
||||
"children": [
|
||||
{
|
||||
"title": "创建模型",
|
||||
"path": "/app/model/control/Model/create",
|
||||
"component": "form",
|
||||
"show": false
|
||||
},
|
||||
{
|
||||
"title": "编辑模型",
|
||||
"path": "/app/model/control/Model/update",
|
||||
"component": "form",
|
||||
"show": false
|
||||
},
|
||||
{
|
||||
"title": "删除模型",
|
||||
"path": "/app/model/control/Model/delete",
|
||||
"component": "form",
|
||||
"show": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "任务列表",
|
||||
"path": "/app/model/control/Task/index",
|
||||
"component": "table",
|
||||
"children": [
|
||||
{
|
||||
"title": "编辑模型",
|
||||
"path": "/app/model/control/Task/update",
|
||||
"component": "form",
|
||||
"show": false
|
||||
},
|
||||
{
|
||||
"title": "删除模型",
|
||||
"path": "/app/model/control/Task/delete",
|
||||
"component": "form",
|
||||
"show": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "音色",
|
||||
"path": "/app/model/control/Voice/group",
|
||||
"children": [
|
||||
{
|
||||
"title": "音色列表",
|
||||
"path": "/app/model/control/Voice/index",
|
||||
"component": "table"
|
||||
},
|
||||
{
|
||||
"title": "音色文案",
|
||||
"path": "/app/model/control/VoiceText/index",
|
||||
"component": "table",
|
||||
"children": [
|
||||
{
|
||||
"title": "创建音色文案",
|
||||
"path": "/app/model/control/VoiceText/create",
|
||||
"component": "form",
|
||||
"show": false
|
||||
},
|
||||
{
|
||||
"title": "编辑音色文案",
|
||||
"path": "/app/model/control/VoiceText/update",
|
||||
"component": "form",
|
||||
"show": false
|
||||
},
|
||||
{
|
||||
"title": "删除音色文案",
|
||||
"path": "/app/model/control/VoiceText/delete",
|
||||
"component": "form",
|
||||
"show": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
[
|
||||
{
|
||||
"name": "通义千问-Plus",
|
||||
"model_type": "chat",
|
||||
"model_id": 2,
|
||||
"model_name": "Yc-reasoner",
|
||||
"assistant_id": 1,
|
||||
"assistant_name": "编剧助手",
|
||||
"scene": "creative_script",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 1,
|
||||
"description": "Qwen3系列Plus模型,实现思考模式和非思考模式的有效融合,可在对话中切换模式。"
|
||||
},
|
||||
{
|
||||
"name": "千问3-Max",
|
||||
"model_type": "chat",
|
||||
"model_id": 2,
|
||||
"model_name": "Yc-reasoner",
|
||||
"assistant_id": 1,
|
||||
"assistant_name": "编剧助手",
|
||||
"scene": "creative_script",
|
||||
"point": 0,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "通义千问3系列Max模型,适配场景更加复杂的智能体需求。"
|
||||
},
|
||||
{
|
||||
"name": "生成封面",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 2,
|
||||
"assistant_name": "封面制作",
|
||||
"scene": "drama_cover",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "AI生成封面"
|
||||
},
|
||||
{
|
||||
"name": "美术指导",
|
||||
"model_type": "chat",
|
||||
"model_id": 2,
|
||||
"model_name": "Yc-reasoner",
|
||||
"assistant_id": 2,
|
||||
"assistant_name": "场景分镜设计",
|
||||
"scene": "creative_scenes",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "擦我擦"
|
||||
},
|
||||
{
|
||||
"name": "续写分集",
|
||||
"model_type": "chat",
|
||||
"model_id": 2,
|
||||
"model_name": "Yc-reasoner",
|
||||
"assistant_id": 3,
|
||||
"assistant_name": "分集助手",
|
||||
"scene": "creative_episode",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "续写"
|
||||
},
|
||||
{
|
||||
"name": "分镜师",
|
||||
"model_type": "chat",
|
||||
"model_id": 2,
|
||||
"model_name": "Yc-reasoner",
|
||||
"assistant_id": 4,
|
||||
"assistant_name": "分镜设计",
|
||||
"scene": "creative_storyboards",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "分镜"
|
||||
},
|
||||
{
|
||||
"name": "banono-pro",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 3,
|
||||
"assistant_name": "场景图片",
|
||||
"scene": "scene_image",
|
||||
"point": 60,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "根据场景提示词生成场景图片"
|
||||
},
|
||||
{
|
||||
"name": "角色形象",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 5,
|
||||
"assistant_name": "角色主图",
|
||||
"scene": "actor_image",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "创建角色形象"
|
||||
},
|
||||
{
|
||||
"name": "角色三视图",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 4,
|
||||
"assistant_name": "角色三视图",
|
||||
"scene": "actor_three_view_image",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "角色三视图"
|
||||
},
|
||||
{
|
||||
"name": "分镜图",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 6,
|
||||
"assistant_name": "分镜图",
|
||||
"scene": "storyboard_image",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "分镜图"
|
||||
},
|
||||
{
|
||||
"name": "分镜合成视频",
|
||||
"model_type": "tovideo",
|
||||
"model_id": 8,
|
||||
"model_name": "万相2.2极速版(无声视频)",
|
||||
"assistant_id": 7,
|
||||
"assistant_name": "分镜转视频",
|
||||
"scene": "storyboard_video",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "分镜合成视频"
|
||||
},
|
||||
{
|
||||
"name": "形象服饰",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 7,
|
||||
"assistant_name": "形象助手",
|
||||
"scene": "character_look_costume",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 1,
|
||||
"description": "形象服饰"
|
||||
},
|
||||
{
|
||||
"name": "角色换装bannono",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 8,
|
||||
"assistant_name": "重塑角色",
|
||||
"scene": "actor_costume",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "角色换装"
|
||||
},
|
||||
{
|
||||
"name": "角色换装三视图",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 4,
|
||||
"assistant_name": "角色三视图",
|
||||
"scene": "actor_costume_three_view",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "角色换装三视图"
|
||||
},
|
||||
{
|
||||
"name": "物品图",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 9,
|
||||
"assistant_name": "物品主图",
|
||||
"scene": "prop_image",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "物品图"
|
||||
},
|
||||
{
|
||||
"name": "物品三视图",
|
||||
"model_type": "draw",
|
||||
"model_id": 4,
|
||||
"model_name": "Banono-Pro",
|
||||
"assistant_id": 10,
|
||||
"assistant_name": "物品三视图",
|
||||
"scene": "prop_three_view_image",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "物品三视图"
|
||||
},
|
||||
{
|
||||
"name": "DeepSeek",
|
||||
"model_type": "chat",
|
||||
"model_id": 2,
|
||||
"model_name": "Yc-reasoner",
|
||||
"assistant_id": 1,
|
||||
"assistant_name": "编剧助手",
|
||||
"scene": "creative_script",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "1"
|
||||
},
|
||||
{
|
||||
"name": "音频合成",
|
||||
"model_type": "audio",
|
||||
"model_id": 9,
|
||||
"model_name": "cosyvoice-v3-flash",
|
||||
"assistant_id": 8,
|
||||
"assistant_name": "文字转语音",
|
||||
"scene": "dialogue_voice",
|
||||
"point": 1,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "音频合成"
|
||||
},
|
||||
{
|
||||
"name": "旁白合成",
|
||||
"model_type": "audio",
|
||||
"model_id": 9,
|
||||
"model_name": "cosyvoice-v3-flash",
|
||||
"assistant_id": 8,
|
||||
"assistant_name": "文字转语音",
|
||||
"scene": "storyboard_narration_voice",
|
||||
"point": 0,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "旁白合成"
|
||||
},
|
||||
{
|
||||
"name": "阿里云",
|
||||
"model_type": "draw",
|
||||
"model_id": 7,
|
||||
"model_name": "万相2.6 image",
|
||||
"assistant_id": 6,
|
||||
"assistant_name": "分镜图",
|
||||
"scene": "storyboard_image",
|
||||
"point": 100,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "图像处理,生图模型"
|
||||
},
|
||||
{
|
||||
"name": "香蕉",
|
||||
"model_type": "draw",
|
||||
"model_id": 2,
|
||||
"model_name": "Banono",
|
||||
"assistant_id": 3,
|
||||
"assistant_name": "场景图片",
|
||||
"scene": "scene_image",
|
||||
"point": 100,
|
||||
"state": 1,
|
||||
"sort": 0,
|
||||
"description": "用于生成场景图片"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "interface-example",
|
||||
"title": "应用示例项目",
|
||||
"version": "0.0.1",
|
||||
"description": "应用市场",
|
||||
"author": {
|
||||
"name": "余心",
|
||||
"email": "unknown.renloong@gmail.com"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\process\audio;
|
||||
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\app\model\PluginModelTaskResult;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardDialogue;
|
||||
use support\Log;
|
||||
use think\facade\Db;
|
||||
use Workerman\Coroutine;
|
||||
use Workerman\Crontab\Crontab;
|
||||
use Workerman\Timer;
|
||||
|
||||
class AudioTransfer
|
||||
{
|
||||
public function onWorkerStart($worker)
|
||||
{
|
||||
$id = $worker->id;
|
||||
new Crontab('*/5 * * * * *', function () use ($id) {
|
||||
try {
|
||||
if ($id) {
|
||||
Timer::sleep(0.3 * $id);
|
||||
}
|
||||
Coroutine::create(function () {
|
||||
$PluginModelTask = PluginModelTask::where(['status' => ModelTaskStatus::WAIT_DOWNLOAD['value'], 'model_type' => ModelType::AUDIO['value']])->order('last_heartbeat asc,id asc')->lock(true)->find();
|
||||
if (!$PluginModelTask) {
|
||||
return;
|
||||
}
|
||||
$PluginModelTask->status = ModelTaskStatus::DOWNLOADING['value'];
|
||||
$PluginModelTask->last_heartbeat = date('Y-m-d H:i:s', strtotime('+5 seconds'));
|
||||
$PluginModelTask->save();
|
||||
$PluginModelTaskResult = PluginModelTaskResult::where('task_id', $PluginModelTask->id)->find();
|
||||
if (!$PluginModelTaskResult) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$ModelScene = ModelScene::get($PluginModelTask->scene);
|
||||
$classify = Uploads::getClassify($PluginModelTask->channels_uid, 'uploads/' . $PluginModelTask->scene, $ModelScene['label']);
|
||||
$result = Uploads::download($PluginModelTask->channels_uid, $PluginModelTaskResult->audio, $classify);
|
||||
} catch (\Throwable $th) {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT_DOWNLOAD['value'];
|
||||
$PluginModelTask->save();
|
||||
Log::error("音频转存处理失败:" . $th->getMessage(), $th->getTrace());
|
||||
return;
|
||||
}
|
||||
$pushData = [
|
||||
'task_id' => $PluginModelTask->id,
|
||||
'id' => $PluginModelTask->alias_id,
|
||||
'audio' => $result->file_url
|
||||
];
|
||||
$event = 'generate' . strtolower(str_replace('_', '', $PluginModelTask->scene));
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->status = ModelTaskStatus::SUCCESS['value'];
|
||||
$PluginModelTask->save();
|
||||
$PluginModelTaskResult = PluginModelTaskResult::where('task_id', $PluginModelTask->id)->find();
|
||||
$PluginModelTaskResult->audio_path = $result->file_name;
|
||||
$PluginModelTaskResult->save();
|
||||
switch ($PluginModelTask->scene) {
|
||||
case ModelScene::DIALOGUE_VOICE['value']:
|
||||
$PluginShortplayDramaStoryboardDialogue = PluginShortplayDramaStoryboardDialogue::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayDramaStoryboardDialogue->audio = $result->file_name;
|
||||
$PluginShortplayDramaStoryboardDialogue->save();
|
||||
$event = 'generatestoryboard';
|
||||
$pushData['event'] = ModelScene::DIALOGUE_VOICE['value'];
|
||||
$pushData['id']=$PluginShortplayDramaStoryboardDialogue->storyboard_id;
|
||||
$pushData['dialogue_id']=$PluginShortplayDramaStoryboardDialogue->id;
|
||||
break;
|
||||
case ModelScene::STORYBOARD_NARRATION_VOICE['value']:
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayDramaStoryboard->narration_audio = $result->file_name;
|
||||
$PluginShortplayDramaStoryboard->save();
|
||||
$event = 'generatestoryboard';
|
||||
$pushData['event'] = ModelScene::STORYBOARD_NARRATION_VOICE['value'];
|
||||
break;
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
Log::error("音频转存保存失败:" . $th->getMessage(), $th->getTrace());
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $PluginModelTask->uid,
|
||||
'channels_uid' => $PluginModelTask->channels_uid,
|
||||
'event' => $event
|
||||
], $pushData);
|
||||
});
|
||||
} catch (\Throwable $th) {
|
||||
Log::error("音频转存定时任务失败:" . $th->getMessage(), $th->getTrace());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\process\chat;
|
||||
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\finance\expose\helper\Account;
|
||||
use plugin\finance\utils\enum\PointsBillScene;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\app\model\PluginModelTaskResult;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisodeActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardDialogue;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardProp;
|
||||
use plugin\shortplay\app\model\PluginShortplayProp;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use plugin\shortplay\utils\enum\PropStatus;
|
||||
use support\Log;
|
||||
use think\facade\Db;
|
||||
use Workerman\Coroutine;
|
||||
use Workerman\Crontab\Crontab;
|
||||
use Workerman\Timer;
|
||||
|
||||
class Submit
|
||||
{
|
||||
public function onWorkerStart($worker)
|
||||
{
|
||||
$id = $worker->id;
|
||||
new Crontab('*/5 * * * * *', function () use (&$id) {
|
||||
try {
|
||||
if ($id) {
|
||||
Timer::sleep(0.3 * $id);
|
||||
}
|
||||
Coroutine::create(function () {
|
||||
$PluginModelTask = PluginModelTask::where(['status' => ModelTaskStatus::WAIT['value'], 'model_type' => ModelType::CHAT['value']])->order('last_heartbeat asc,id asc')->lock(true)->find();
|
||||
if (!$PluginModelTask) {
|
||||
return;
|
||||
}
|
||||
if ($PluginModelTask->expectation_execution_count !== null) {
|
||||
$PluginModelTask->execution_count = Db::raw('execution_count + 1');
|
||||
}
|
||||
$PluginModelTask->status = ModelTaskStatus::PROCESSING['value'];
|
||||
$PluginModelTask->last_heartbeat = date('Y-m-d H:i:s', strtotime('+5 seconds'));
|
||||
$PluginModelTask->save();
|
||||
p($PluginModelTask->id);
|
||||
$event = 'generate' . strtolower(str_replace('_', '', $PluginModelTask->scene));
|
||||
$PluginModelTaskResult = PluginModelTaskResult::where('task_id', $PluginModelTask->id)->find();
|
||||
if (!$PluginModelTaskResult) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->save();
|
||||
Push::send([
|
||||
'uid' => $PluginModelTask->uid,
|
||||
'channels_uid' => $PluginModelTask->channels_uid,
|
||||
'event' => $event
|
||||
], [
|
||||
'task_id' => $PluginModelTask->id,
|
||||
'id' => $PluginModelTask->alias_id
|
||||
]);
|
||||
return;
|
||||
}
|
||||
$data = $PluginModelTaskResult->params;
|
||||
switch ($PluginModelTask->scene) {
|
||||
case ModelScene::CREATIVE_EPISODE['value']:
|
||||
try {
|
||||
$data['params']['form_data']['episode_no'] = $data['params']['form_data']['episode_no'] + 1;
|
||||
p($PluginModelTask->id, $data['params']['form_data']['episode_no'], 'start');
|
||||
$result = Yidevs::ChatAssistantCompletions($data['channels_uid'], $data['params']);
|
||||
p($PluginModelTask->id, $data['params']['form_data']['episode_no'], 'success');
|
||||
} catch (\Throwable $th) {
|
||||
Log::error('CREATIVE_EPISODE Error:' . $th->getMessage() . PHP_EOL . $th->getTraceAsString());
|
||||
}
|
||||
$taksStatus = ModelTaskStatus::FAIL['value'];
|
||||
if (!empty($result)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $data['drama_id']])->find();
|
||||
$episode_num = $PluginShortplayDrama->episode_num + 1;
|
||||
$PluginShortplayDrama->episode_num = Db::raw('episode_num + 1');
|
||||
$PluginShortplayDrama->save();
|
||||
$PluginShortplayDramaEpisode = new PluginShortplayDramaEpisode();
|
||||
$PluginShortplayDramaEpisode->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaEpisode->drama_id = $data['drama_id'];
|
||||
$PluginShortplayDramaEpisode->episode_no = $episode_num;
|
||||
$PluginShortplayDramaEpisode->title = $result['title'];
|
||||
$PluginShortplayDramaEpisode->outline = $result['description'];
|
||||
$PluginShortplayDramaEpisode->content = $result['content'];
|
||||
$PluginShortplayDramaEpisode->save();
|
||||
if (!empty($result['actor'])) {
|
||||
$PluginShortplayActors = PluginShortplayActor::whereIn('actor_id', $result['actor'])->field('id,actor_id')->select();
|
||||
foreach ($PluginShortplayActors as $PluginShortplayActor) {
|
||||
if (!PluginShortplayDramaActor::where(['drama_id' => $PluginShortplayDrama->id, 'actor_id' => $PluginShortplayActor->id])->count()) {
|
||||
$PluginShortplayDramaActor = new PluginShortplayDramaActor();
|
||||
$PluginShortplayDramaActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaActor->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayDramaActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaActor->save();
|
||||
}
|
||||
$PluginShortplayDramaEpisodeActor = new PluginShortplayDramaEpisodeActor();
|
||||
$PluginShortplayDramaEpisodeActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaEpisodeActor->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayDramaEpisodeActor->episode_id = $PluginShortplayDramaEpisode->id;
|
||||
$PluginShortplayDramaEpisodeActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaEpisodeActor->save();
|
||||
}
|
||||
}
|
||||
$updateActors = [];
|
||||
if (!empty($result['create_actor'])) {
|
||||
foreach ($result['create_actor'] as $actor) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['name' => $actor['name'], 'channels_uid' => $data['channels_uid'], 'drama_id' => $PluginShortplayDrama->id])->field('id,actor_id')->find();
|
||||
if (!$PluginShortplayActor) {
|
||||
if (empty($actor['description'])) {
|
||||
continue;
|
||||
}
|
||||
$PluginShortplayActor = new PluginShortplayActor();
|
||||
$PluginShortplayActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayActor->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayActor->episode_id = $PluginShortplayDramaEpisode->id;
|
||||
$PluginShortplayActor->uid = $data['uid'];
|
||||
$PluginShortplayActor->actor_id = uniqid();
|
||||
$PluginShortplayActor->name = $actor['name'];
|
||||
$PluginShortplayActor->species_type = $actor['species'];
|
||||
$PluginShortplayActor->gender = $actor['gender'];
|
||||
$PluginShortplayActor->age = $actor['age'];
|
||||
$PluginShortplayActor->remarks = $actor['description'];
|
||||
$PluginShortplayActor->status = ActorStatus::INITIALIZING['value'];
|
||||
$PluginShortplayActor->save();
|
||||
$updateActors[] = "{$PluginShortplayActor->name}{{$PluginShortplayActor->actor_id}}";
|
||||
}
|
||||
$PluginShortplayDramaActor = new PluginShortplayDramaActor();
|
||||
$PluginShortplayDramaActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaActor->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayDramaActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaActor->save();
|
||||
$PluginShortplayDramaEpisodeActor = new PluginShortplayDramaEpisodeActor();
|
||||
$PluginShortplayDramaEpisodeActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaEpisodeActor->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayDramaEpisodeActor->episode_id = $PluginShortplayDramaEpisode->id;
|
||||
$PluginShortplayDramaEpisodeActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaEpisodeActor->save();
|
||||
}
|
||||
}
|
||||
$PluginModelTask = PluginModelTask::where(['id' => $PluginModelTask->id])->with(['result'])->find();
|
||||
if (
|
||||
$PluginModelTask->expectation_execution_count === null
|
||||
|| ($PluginModelTask->expectation_execution_count !== null && $PluginModelTask->success_execution_count + 1 >= $PluginModelTask->expectation_execution_count)
|
||||
) {
|
||||
$PluginModelTask->status = ModelTaskStatus::SUCCESS['value'];
|
||||
$PluginModelTask->success_execution_count = Db::raw('success_execution_count + 1');
|
||||
$PluginModelTask->result->result = $result;
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
} else {
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT['value'];
|
||||
$PluginModelTask->success_execution_count = Db::raw('success_execution_count + 1');
|
||||
$PluginModelTask->last_heartbeat = date('Y-m-d H:i:s', strtotime('+10 seconds'));
|
||||
$data['params']['form_data']['pre_episode'] = $result['content'];
|
||||
if (!empty($updateActors)) {
|
||||
$data['params']['form_data']['actors'] .= "," . implode(',', $updateActors);
|
||||
}
|
||||
$PluginModelTask->result->params = $data;
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
}
|
||||
$taksStatus = ModelTaskStatus::SUCCESS['value'];
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
Log::error('续写分集失败 Error:' . $th->getMessage() . PHP_EOL . $th->getTraceAsString());
|
||||
}
|
||||
}
|
||||
if ($taksStatus == ModelTaskStatus::FAIL['value']) {
|
||||
$PluginModelTask = PluginModelTask::where(['id' => $PluginModelTask->id])->find();
|
||||
if (
|
||||
$PluginModelTask->expectation_execution_count === null
|
||||
|| ($PluginModelTask->expectation_execution_count !== null && $PluginModelTask->success_execution_count + 1 >= $PluginModelTask->expectation_execution_count)
|
||||
|| ($PluginModelTask->expectation_execution_count !== null && $PluginModelTask->execution_count >= $PluginModelTask->expectation_execution_count * 2)
|
||||
) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->save();
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'continueepisode',
|
||||
], [
|
||||
'drama_id' => $data['drama_id']
|
||||
]);
|
||||
} else {
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT['value'];
|
||||
$PluginModelTask->last_heartbeat = date('Y-m-d H:i:s', strtotime('+10 seconds'));
|
||||
$PluginModelTask->save();
|
||||
}
|
||||
} else {
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'continueepisode',
|
||||
], [
|
||||
'drama_id' => $data['drama_id']
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case ModelScene::CREATIVE_STORYBOARDS['value']:
|
||||
try {
|
||||
p('start');
|
||||
$result = Yidevs::ChatAssistantCompletions($data['channels_uid'], $data['params']);
|
||||
p($result);
|
||||
} catch (\Throwable $th) {
|
||||
Log::error('CREATIVE_STORYBOARDS Error:' . $th->getMessage() . PHP_EOL . $th->getTraceAsString());
|
||||
}
|
||||
$taksStatus = ModelTaskStatus::FAIL['value'];
|
||||
if (!empty($result)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$previous_dialogues = '';
|
||||
$whereOr = [];
|
||||
$whereOr[] = ['uid', '=', null];
|
||||
$whereOr[] = ['uid', '=', $data['uid']];
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $data['drama_id']])->find();
|
||||
$sort = PluginShortplayDramaStoryboard::where(['drama_id' => $data['drama_id'], 'episode_id' => $data['episode_id']])->max('sort') + 1 ?? 1;
|
||||
$PluginShortplayDramaStoryboard = new PluginShortplayDramaStoryboard;
|
||||
$PluginShortplayDramaStoryboard->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaStoryboard->drama_id = $data['drama_id'];
|
||||
$PluginShortplayDramaStoryboard->episode_id = $data['episode_id'];
|
||||
$PluginShortplayDramaStoryboard->scene_id = $result['scene_id'];
|
||||
$PluginShortplayDramaStoryboard->sort = $sort;
|
||||
$PluginShortplayDramaStoryboard->description = $result['description'];
|
||||
if (!empty($result['image_prompt'])) {
|
||||
$PluginShortplayDramaStoryboard->image_prompt = $result['image_prompt'];
|
||||
}
|
||||
if (!empty($result['video_prompt'])) {
|
||||
$PluginShortplayDramaStoryboard->video_prompt = $result['video_prompt'];
|
||||
}
|
||||
$PluginShortplayDramaStoryboard->shot_type = $result['shot_type'];
|
||||
$PluginShortplayDramaStoryboard->shot_angle = $result['shot_angle'];
|
||||
$PluginShortplayDramaStoryboard->shot_motion = $result['shot_motion'];
|
||||
if (empty($result['narration'])) {
|
||||
$PluginShortplayDramaStoryboard->narration = $result['narration'];
|
||||
}
|
||||
// $PluginShortplayDramaStoryboard->sfx = $storyboard['sfx'];
|
||||
$PluginShortplayDramaStoryboard->duration = $result['duration'];
|
||||
$PluginShortplayDramaStoryboard->save();
|
||||
$updateActors = [];
|
||||
if (!empty($result['actor'])) {
|
||||
foreach ($result['actor'] as $actor_key => $actor) {
|
||||
$PluginShortplayActor = null;
|
||||
if (!empty($actor['actor_id'])) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['actor_id' => $actor['actor_id']])->find();
|
||||
}
|
||||
if (!$PluginShortplayActor) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['channels_uid' => $data['channels_uid'], 'name' => $actor['name']])->whereOr($whereOr)->find();
|
||||
}
|
||||
if (!$PluginShortplayActor && !empty($actor['description'])) {
|
||||
$PluginShortplayActor = new PluginShortplayActor;
|
||||
$PluginShortplayActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayActor->uid = $data['uid'];
|
||||
$PluginShortplayActor->drama_id = $data['drama_id'];
|
||||
$PluginShortplayActor->episode_id = $data['episode_id'];
|
||||
$PluginShortplayActor->actor_id = uniqid();
|
||||
$PluginShortplayActor->name = $actor['name'];
|
||||
$PluginShortplayActor->remarks = $actor['description'];
|
||||
$PluginShortplayActor->status = ActorStatus::INITIALIZING['value'];
|
||||
$PluginShortplayActor->save();
|
||||
$PluginShortplayDramaActor = new PluginShortplayDramaActor();
|
||||
$PluginShortplayDramaActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaActor->drama_id = $data['drama_id'];
|
||||
$PluginShortplayDramaActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaActor->save();
|
||||
$PluginShortplayDramaEpisodeActor = new PluginShortplayDramaEpisodeActor;
|
||||
$PluginShortplayDramaEpisodeActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaEpisodeActor->drama_id = $data['drama_id'];
|
||||
$PluginShortplayDramaEpisodeActor->episode_id = $data['episode_id'];
|
||||
$PluginShortplayDramaEpisodeActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaEpisodeActor->save();
|
||||
$updateActors[] = "{$PluginShortplayActor->name}{{$PluginShortplayActor->actor_id}}";
|
||||
}
|
||||
if ($PluginShortplayActor) {
|
||||
$PluginShortplayDramaStoryboardActor = new PluginShortplayDramaStoryboardActor();
|
||||
$PluginShortplayDramaStoryboardActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaStoryboardActor->drama_id = $data['drama_id'];
|
||||
$PluginShortplayDramaStoryboardActor->episode_id = $data['episode_id'];
|
||||
$PluginShortplayDramaStoryboardActor->storyboard_id = $PluginShortplayDramaStoryboard->id;
|
||||
$PluginShortplayDramaStoryboardActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaStoryboardActor->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
$PluginShortplayActor = null;
|
||||
if (!empty($result['dialogues'])) {
|
||||
foreach ($result['dialogues'] as $dialogue_key => $dialogue) {
|
||||
if (!empty($dialogue['actor']['actor_id'])) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['actor_id' => $dialogue['actor']['actor_id']])->find();
|
||||
}
|
||||
if (!$PluginShortplayActor) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['channels_uid' => $data['channels_uid'], 'name' => $dialogue['actor']['name']])->whereOr($whereOr)->find();
|
||||
}
|
||||
if (!$PluginShortplayActor) {
|
||||
continue;
|
||||
}
|
||||
$PluginShortplayDramaStoryboardDialogue = new PluginShortplayDramaStoryboardDialogue();
|
||||
$PluginShortplayDramaStoryboardDialogue->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaStoryboardDialogue->storyboard_id = $PluginShortplayDramaStoryboard->id;
|
||||
$PluginShortplayDramaStoryboardDialogue->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaStoryboardDialogue->prosody_speed = $dialogue['prosody_speed'];
|
||||
$PluginShortplayDramaStoryboardDialogue->prosody_volume = $dialogue['prosody_volume'];
|
||||
$PluginShortplayDramaStoryboardDialogue->emotion = $dialogue['emotion'];
|
||||
$PluginShortplayDramaStoryboardDialogue->start_time = $dialogue['start_time'];
|
||||
$PluginShortplayDramaStoryboardDialogue->end_time = $dialogue['end_time'];
|
||||
$PluginShortplayDramaStoryboardDialogue->inner_monologue = empty($dialogue['inner_monologue']) ? 0 : 1;
|
||||
$content = $dialogue['content'];
|
||||
if (empty($content)) {
|
||||
$content = '……';
|
||||
}
|
||||
$PluginShortplayDramaStoryboardDialogue->content = $content;
|
||||
$PluginShortplayDramaStoryboardDialogue->save();
|
||||
$previous_dialogues .= "{$PluginShortplayActor->name}:{$content}\n";
|
||||
}
|
||||
}
|
||||
$updateProps = [];
|
||||
if (!empty($result['prop'])) {
|
||||
foreach ($result['prop'] as $prop_key => $prop) {
|
||||
$PluginShortplayProp = null;
|
||||
if (!empty($prop['prop_id'])) {
|
||||
$PluginShortplayProp = PluginShortplayProp::where(['prop_id' => $prop['prop_id']])->find();
|
||||
}
|
||||
if (!$PluginShortplayProp) {
|
||||
$PluginShortplayProp = PluginShortplayProp::where(['name' => $prop['name'], 'channels_uid' => $data['channels_uid'], 'drama_id' => $data['drama_id']])->find();
|
||||
}
|
||||
if (!$PluginShortplayProp && !empty($prop['description'])) {
|
||||
$PluginShortplayProp = new PluginShortplayProp;
|
||||
$PluginShortplayProp->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayProp->uid = $data['uid'];
|
||||
$PluginShortplayProp->drama_id = $data['drama_id'];
|
||||
$PluginShortplayProp->episode_id = $data['episode_id'];
|
||||
$PluginShortplayProp->prop_id = uniqid();
|
||||
$PluginShortplayProp->name = $prop['name'];
|
||||
$PluginShortplayProp->description = $prop['description'];
|
||||
$PluginShortplayProp->status = PropStatus::INITIALIZING['value'];
|
||||
$PluginShortplayProp->save();
|
||||
$updateProps[] = "{$PluginShortplayProp->name}{{$PluginShortplayProp->prop_id}}";
|
||||
}
|
||||
if ($PluginShortplayProp) {
|
||||
$PluginShortplayDramaStoryboardProp = new PluginShortplayDramaStoryboardProp();
|
||||
$PluginShortplayDramaStoryboardProp->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaStoryboardProp->storyboard_id = $PluginShortplayDramaStoryboard->id;
|
||||
$PluginShortplayDramaStoryboardProp->prop_id = $PluginShortplayProp->id;
|
||||
$PluginShortplayDramaStoryboardProp->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
$success_execution_count = $PluginModelTask->success_execution_count + 1;
|
||||
$PluginModelTask = PluginModelTask::where(['id' => $PluginModelTask->id])->with(['result'])->find();
|
||||
if ($result['is_end']) {
|
||||
$PluginModelTask->success_execution_count = $PluginModelTask->expectation_execution_count;
|
||||
}
|
||||
if (
|
||||
$PluginModelTask->expectation_execution_count === null
|
||||
|| ($PluginModelTask->expectation_execution_count !== null && $PluginModelTask->success_execution_count + 1 >= $PluginModelTask->expectation_execution_count)
|
||||
) {
|
||||
$PluginModel = PluginModel::where(['id' => $PluginModelTask->model_id])->find();
|
||||
$point = $PluginModel->point * $success_execution_count;
|
||||
Account::decPoints($PluginShortplayDrama->uid, $PluginShortplayDrama->channels_uid, $point > 200 ? 200 : $point, PointsBillScene::CONSUME['value'], null, '生成分镜', true, true);
|
||||
$PluginModelTask->status = ModelTaskStatus::SUCCESS['value'];
|
||||
$PluginModelTask->success_execution_count = Db::raw('success_execution_count + 1');
|
||||
$PluginModelTask->result->result = $result;
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
} else {
|
||||
$storyboards = '';
|
||||
if (!empty($data['params']['form_data']['storyboards'])) {
|
||||
$storyboards = $data['params']['form_data']['storyboards'];
|
||||
}
|
||||
$storyboards .= "- 序号:" . $PluginShortplayDramaStoryboard->sort . "\n- 画面描述:" . $PluginShortplayDramaStoryboard->description . "\n";
|
||||
$storyboards .= "- 对话:" . $previous_dialogues . "\n\n";
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT['value'];
|
||||
$PluginModelTask->success_execution_count = Db::raw('success_execution_count + 1');
|
||||
$PluginModelTask->last_heartbeat = date('Y-m-d H:i:s', strtotime('+10 seconds'));
|
||||
if (!empty($updateActors)) {
|
||||
$data['params']['form_data']['actors'] .= "," . implode(',', $updateActors);
|
||||
}
|
||||
if (!empty($updateProps)) {
|
||||
$data['params']['form_data']['props'] .= "," . implode(',', $updateProps);
|
||||
}
|
||||
$data['params']['form_data']['previous_description'] = $PluginShortplayDramaStoryboard->description;
|
||||
$data['params']['form_data']['previous_dialogues'] = $previous_dialogues;
|
||||
$data['params']['form_data']['previous_sort'] = $PluginShortplayDramaStoryboard->sort;
|
||||
$data['params']['form_data']['sort'] = $sort + 1;
|
||||
$data['params']['form_data']['storyboards'] = $storyboards;
|
||||
$PluginModelTask->result->params = $data;
|
||||
$PluginModelTask->result->result = $result;
|
||||
$PluginModelTask->together(['result'])->save();
|
||||
}
|
||||
$taksStatus = ModelTaskStatus::SUCCESS['value'];
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
Log::error('CREATIVE_STORYBOARDS RESULT:', $result);
|
||||
Log::error('Generate Storyboard Error:' . $th->getMessage() . PHP_EOL . $th->getTraceAsString());
|
||||
}
|
||||
}
|
||||
if ($taksStatus == ModelTaskStatus::FAIL['value']) {
|
||||
$PluginModelTask = PluginModelTask::where(['id' => $PluginModelTask->id])->find();
|
||||
if (
|
||||
$PluginModelTask->expectation_execution_count === null
|
||||
|| ($PluginModelTask->expectation_execution_count !== null && $PluginModelTask->success_execution_count + 1 >= $PluginModelTask->expectation_execution_count)
|
||||
|| ($PluginModelTask->expectation_execution_count !== null && $PluginModelTask->execution_count >= $PluginModelTask->expectation_execution_count * 2)
|
||||
) {
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->save();
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'hash' => $data['drama_id'],
|
||||
'event' => 'generatescenestoryboard',
|
||||
], [
|
||||
'drama_id' => $data['drama_id'],
|
||||
'episode_id' => $data['episode_id'],
|
||||
]);
|
||||
} else {
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT['value'];
|
||||
$PluginModelTask->last_heartbeat = date('Y-m-d H:i:s', strtotime('+10 seconds'));
|
||||
$PluginModelTask->save();
|
||||
}
|
||||
} else {
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'hash' => $data['drama_id'],
|
||||
'event' => 'generatescenestoryboard',
|
||||
], [
|
||||
'drama_id' => $data['drama_id'],
|
||||
'episode_id' => $data['episode_id'],
|
||||
]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
} catch (\Throwable $th) {
|
||||
Log::error("Chat Submit Process Error:" . $th->getMessage(), $th->getTrace());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\process\draw;
|
||||
|
||||
use app\expose\enum\State;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\app\model\PluginModelTaskResult;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayActorCharacterLook;
|
||||
use plugin\shortplay\app\model\PluginShortplayCharacterLook;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisodeActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaScene;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayProp;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use plugin\shortplay\utils\enum\PropStatus;
|
||||
use support\Log;
|
||||
use think\facade\Db;
|
||||
use Workerman\Coroutine;
|
||||
use Workerman\Crontab\Crontab;
|
||||
use Workerman\Timer;
|
||||
|
||||
class ImageTransfer
|
||||
{
|
||||
public function onWorkerStart($worker)
|
||||
{
|
||||
$id = $worker->id;
|
||||
new Crontab('*/5 * * * * *', function () use ($id) {
|
||||
try {
|
||||
if ($id) {
|
||||
Timer::sleep(0.3 * $id);
|
||||
}
|
||||
Coroutine::create(function () {
|
||||
$PluginModelTask = PluginModelTask::where(['status' => ModelTaskStatus::WAIT_DOWNLOAD['value'], 'model_type' => ModelType::DRAW['value']])->order('last_heartbeat asc,id asc')->lock(true)->find();
|
||||
if (!$PluginModelTask) {
|
||||
return;
|
||||
}
|
||||
$PluginModelTask->status = ModelTaskStatus::DOWNLOADING['value'];
|
||||
$PluginModelTask->last_heartbeat = date('Y-m-d H:i:s', strtotime('+5 seconds'));
|
||||
$PluginModelTask->save();
|
||||
$event = 'generate' . strtolower(str_replace('_', '', $PluginModelTask->scene));
|
||||
$pushData = [
|
||||
'task_id' => $PluginModelTask->id,
|
||||
'id' => $PluginModelTask->alias_id
|
||||
];
|
||||
$PluginModelTaskResult = PluginModelTaskResult::where('task_id', $PluginModelTask->id)->find();
|
||||
if (!$PluginModelTaskResult) {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->status = ModelTaskStatus::FAIL['value'];
|
||||
$PluginModelTask->save();
|
||||
Push::send([
|
||||
'uid' => $PluginModelTask->uid,
|
||||
'channels_uid' => $PluginModelTask->channels_uid,
|
||||
'event' => $event
|
||||
], $pushData);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$ModelScene = ModelScene::get($PluginModelTask->scene);
|
||||
$classify = Uploads::getClassify($PluginModelTask->channels_uid, 'uploads/' . $PluginModelTask->scene, $ModelScene['label']);
|
||||
$result = Uploads::download($PluginModelTask->channels_uid, $PluginModelTaskResult->image, $classify);
|
||||
} catch (\Throwable $th) {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT_DOWNLOAD['value'];
|
||||
$PluginModelTask->save();
|
||||
Log::error("图片转存处理失败:" . $th->getMessage(), $th->getTrace());
|
||||
return;
|
||||
}
|
||||
$pushData['image'] = $result->file_url;
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->status = ModelTaskStatus::SUCCESS['value'];
|
||||
$PluginModelTask->save();
|
||||
$PluginModelTaskResult = PluginModelTaskResult::where('task_id', $PluginModelTask->id)->find();
|
||||
$PluginModelTaskResult->image_path = $result->file_name;
|
||||
$PluginModelTaskResult->save();
|
||||
switch ($PluginModelTask->scene) {
|
||||
case ModelScene::DRAMA_COVER['value']:
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayDrama->cover = $result->file_name;
|
||||
$PluginShortplayDrama->save();
|
||||
break;
|
||||
case ModelScene::SCENE_IMAGE['value']:
|
||||
$PluginShortplayDramaScene = PluginShortplayDramaScene::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayDramaScene->image = $result->file_name;
|
||||
$PluginShortplayDramaScene->save();
|
||||
break;
|
||||
case ModelScene::ACTOR_IMAGE['value']:
|
||||
$PluginShortplayActor = PluginShortplayActor::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayActor->headimg = $result->file_name;
|
||||
$PluginShortplayActor->status = $PluginShortplayActor->headimg && $PluginShortplayActor->three_view_image ? ActorStatus::GENERATED['value'] : ActorStatus::INITIALIZING['value'];
|
||||
$PluginShortplayActor->save();
|
||||
$threeViewImageState = PluginModelTask::processing(['alias_id' => $PluginShortplayActor->id, 'scene' => ModelScene::ACTOR_THREE_VIEW_IMAGE['value']]);
|
||||
if ($threeViewImageState > 0) {
|
||||
$pushData['status'] = ActorStatus::PENDING;
|
||||
} else {
|
||||
$pushData['status'] = ActorStatus::get($PluginShortplayActor->status);
|
||||
}
|
||||
break;
|
||||
case ModelScene::ACTOR_THREE_VIEW_IMAGE['value']:
|
||||
$PluginShortplayActor = PluginShortplayActor::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayActor->three_view_image = $result->file_name;
|
||||
$PluginShortplayActor->status = $PluginShortplayActor->headimg && $PluginShortplayActor->three_view_image ? ActorStatus::GENERATED['value'] : ActorStatus::INITIALIZING['value'];
|
||||
$PluginShortplayActor->save();
|
||||
$pushData['status'] = ActorStatus::get($PluginShortplayActor->status);
|
||||
break;
|
||||
case ModelScene::STORYBOARD_IMAGE['value']:
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayDramaStoryboard->image = $result->file_name;
|
||||
$PluginShortplayDramaStoryboard->use_material_type='image';
|
||||
$PluginShortplayDramaStoryboard->save();
|
||||
$event = 'generatestoryboard';
|
||||
$pushData['event'] = ModelScene::STORYBOARD_IMAGE['value'];
|
||||
break;
|
||||
case ModelScene::ACTOR_COSTUME['value']:
|
||||
$PluginShortplayActorCharacterLook = PluginShortplayActorCharacterLook::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayActorCharacterLook->headimg = $result->file_name;
|
||||
$PluginShortplayActorCharacterLook->save();
|
||||
$event = 'generatestoryboard';
|
||||
$pushData['storyboard_id'] = $PluginShortplayActorCharacterLook->storyboard_id;
|
||||
$pushData['episode_id'] = $PluginShortplayActorCharacterLook->episode_id;
|
||||
$pushData['drama_id'] = $PluginShortplayActorCharacterLook->drama_id;
|
||||
$pushData['id'] = $PluginShortplayActorCharacterLook->actor_id;
|
||||
$pushData['event'] = ModelScene::ACTOR_COSTUME['value'];
|
||||
break;
|
||||
case ModelScene::ACTOR_COSTUME_THREE_VIEW['value']:
|
||||
$PluginShortplayActorCharacterLook = PluginShortplayActorCharacterLook::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayActorCharacterLook->three_view_image = $result->file_name;
|
||||
$PluginShortplayActorCharacterLook->status = ActorStatus::GENERATED['value'];
|
||||
$PluginShortplayActorCharacterLook->save();
|
||||
$event = 'generatestoryboard';
|
||||
$pushData['event'] = ModelScene::ACTOR_COSTUME_THREE_VIEW['value'];
|
||||
$pushData['storyboard_id'] = $PluginShortplayActorCharacterLook->storyboard_id;
|
||||
$pushData['episode_id'] = $PluginShortplayActorCharacterLook->episode_id;
|
||||
$pushData['drama_id'] = $PluginShortplayActorCharacterLook->drama_id;
|
||||
$pushData['id'] = $PluginShortplayActorCharacterLook->actor_id;
|
||||
|
||||
if ($PluginShortplayActorCharacterLook->storyboard_id) {
|
||||
$PluginShortplayDramaStoryboardActor = PluginShortplayDramaStoryboardActor::where(['storyboard_id' => $PluginShortplayActorCharacterLook->storyboard_id, 'actor_id' => $PluginShortplayActorCharacterLook->actor_id])->find();
|
||||
$PluginShortplayDramaStoryboardActor->character_look_id = $PluginShortplayActorCharacterLook->id;
|
||||
$PluginShortplayDramaStoryboardActor->headimg = $PluginShortplayActorCharacterLook->headimg;
|
||||
$PluginShortplayDramaStoryboardActor->three_view_image = $PluginShortplayActorCharacterLook->three_view_image;
|
||||
$PluginShortplayDramaStoryboardActor->save();
|
||||
} elseif ($PluginShortplayActorCharacterLook->episode_id) {
|
||||
$PluginShortplayDramaEpisodeActor = PluginShortplayDramaEpisodeActor::where(['episode_id' => $PluginShortplayActorCharacterLook->episode_id, 'actor_id' => $PluginShortplayActorCharacterLook->actor_id])->find();
|
||||
$PluginShortplayDramaEpisodeActor->character_look_id = $PluginShortplayActorCharacterLook->id;
|
||||
$PluginShortplayDramaEpisodeActor->headimg = $PluginShortplayActorCharacterLook->headimg;
|
||||
$PluginShortplayDramaEpisodeActor->three_view_image = $PluginShortplayActorCharacterLook->three_view_image;
|
||||
$PluginShortplayDramaEpisodeActor->save();
|
||||
} elseif ($PluginShortplayActorCharacterLook->drama_id) {
|
||||
$PluginShortplayDramaActor = PluginShortplayDramaActor::where(['drama_id' => $PluginShortplayActorCharacterLook->drama_id, 'actor_id' => $PluginShortplayActorCharacterLook->actor_id])->find();
|
||||
$PluginShortplayDramaActor->character_look_id = $PluginShortplayActorCharacterLook->id;
|
||||
$PluginShortplayDramaActor->headimg = $PluginShortplayActorCharacterLook->headimg;
|
||||
$PluginShortplayDramaActor->three_view_image = $PluginShortplayActorCharacterLook->three_view_image;
|
||||
$PluginShortplayDramaActor->save();
|
||||
}
|
||||
break;
|
||||
case ModelScene::PROP_IMAGE['value']:
|
||||
$PluginShortplayProp = PluginShortplayProp::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayProp->image = $result->file_name;
|
||||
$PluginShortplayProp->status = $PluginShortplayProp->image && $PluginShortplayProp->three_view_image ? PropStatus::GENERATED['value'] : PropStatus::INITIALIZING['value'];
|
||||
$PluginShortplayProp->save();
|
||||
$threeViewImageState = PluginModelTask::processing(['alias_id' => $PluginShortplayProp->id, 'scene' => ModelScene::PROP_THREE_VIEW_IMAGE['value']]);
|
||||
if ($threeViewImageState > 0) {
|
||||
$pushData['status'] = PropStatus::PENDING;
|
||||
} else {
|
||||
$pushData['status'] = PropStatus::get($PluginShortplayProp->status);
|
||||
}
|
||||
break;
|
||||
case ModelScene::PROP_THREE_VIEW_IMAGE['value']:
|
||||
$PluginShortplayProp = PluginShortplayProp::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayProp->three_view_image = $result->file_name;
|
||||
$PluginShortplayProp->status = $PluginShortplayProp->image && $PluginShortplayProp->three_view_image ? PropStatus::GENERATED['value'] : PropStatus::INITIALIZING['value'];
|
||||
$PluginShortplayProp->save();
|
||||
$pushData['status'] = PropStatus::get($PluginShortplayProp->status);
|
||||
break;
|
||||
case ModelScene::CHARACTER_LOOK_COSTUME['value']:
|
||||
$PluginShortplayCharacterLook = PluginShortplayCharacterLook::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayCharacterLook->costume_url = $result->file_name;
|
||||
$PluginShortplayCharacterLook->status = PropStatus::GENERATED['value'];
|
||||
$PluginShortplayCharacterLook->save();
|
||||
$pushData['status'] = PropStatus::get($PluginShortplayCharacterLook->status);
|
||||
break;
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
Log::error("图片转存保存失败:" . $th->getMessage(), $th->getTrace());
|
||||
return;
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $PluginModelTask->uid,
|
||||
'channels_uid' => $PluginModelTask->channels_uid,
|
||||
'event' => $event
|
||||
], $pushData);
|
||||
switch ($PluginModelTask->scene) {
|
||||
case ModelScene::ACTOR_IMAGE['value']:
|
||||
try {
|
||||
$PluginModelTask = PluginModelTask::where(['pre_task_id' => $PluginModelTask->id, 'status' => ModelTaskStatus::WAIT['value']])->with(['result'])->find();
|
||||
if ($PluginModelTask) {
|
||||
$data = $PluginModelTask->result->params;
|
||||
$data['form_data']['images'] = [$result->file_url];
|
||||
$result = Yidevs::DrawAssistantTIGI($PluginModelTask->channels_uid, $data);
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->task_id = $result['task_id'];
|
||||
$PluginModelTask->status = ModelTaskStatus::PROCESSING['value'];
|
||||
$PluginModelTask->save();
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->pre_task_status = ModelTaskStatus::SUCCESS['value'];
|
||||
$PluginModelTask->save();
|
||||
Log::error('GenerateActorThreeView Error:' . $e->getMessage());
|
||||
}
|
||||
break;
|
||||
case ModelScene::PROP_IMAGE['value']:
|
||||
try {
|
||||
$PluginModelTask = PluginModelTask::where(['pre_task_id' => $PluginModelTask->id, 'status' => ModelTaskStatus::WAIT['value']])->with(['result'])->find();
|
||||
if ($PluginModelTask) {
|
||||
$data = $PluginModelTask->result->params;
|
||||
$data['form_data']['images'] = [$result->file_url];
|
||||
$result = Yidevs::DrawAssistantTIGI($PluginModelTask->channels_uid, $data);
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->task_id = $result['task_id'];
|
||||
$PluginModelTask->status = ModelTaskStatus::PROCESSING['value'];
|
||||
$PluginModelTask->save();
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->pre_task_status = ModelTaskStatus::SUCCESS['value'];
|
||||
$PluginModelTask->save();
|
||||
Log::error('GeneratePropThreeView Error:' . $e->getMessage());
|
||||
}
|
||||
break;
|
||||
case ModelScene::ACTOR_COSTUME['value']:
|
||||
try {
|
||||
$PluginModelTask = PluginModelTask::where(['pre_task_id' => $PluginModelTask->id, 'status' => ModelTaskStatus::WAIT['value']])->with(['result'])->find();
|
||||
if ($PluginModelTask) {
|
||||
$data = $PluginModelTask->result->params;
|
||||
$data['form_data']['images'] = [$result->file_url];
|
||||
$result = Yidevs::DrawAssistantTIGI($PluginModelTask->channels_uid, $data);
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->task_id = $result['task_id'];
|
||||
$PluginModelTask->status = ModelTaskStatus::PROCESSING['value'];
|
||||
$PluginModelTask->save();
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->pre_task_status = ModelTaskStatus::SUCCESS['value'];
|
||||
$PluginModelTask->save();
|
||||
Log::error('GenerateActorThreeView Error:' . $e->getMessage());
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
} catch (\Throwable $th) {
|
||||
Log::error("图片转存定时任务失败:" . $th->getMessage(), $th->getTrace());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\process\video;
|
||||
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\app\model\PluginModelTaskResult;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use support\Log;
|
||||
use think\facade\Db;
|
||||
use Workerman\Coroutine;
|
||||
use Workerman\Crontab\Crontab;
|
||||
use Workerman\Timer;
|
||||
|
||||
class VideoTransfer
|
||||
{
|
||||
public function onWorkerStart($worker)
|
||||
{
|
||||
$id = $worker->id;
|
||||
new Crontab('*/5 * * * * *', function () use ($id) {
|
||||
try {
|
||||
if ($id) {
|
||||
Timer::sleep(0.3 * $id);
|
||||
}
|
||||
Coroutine::create(function () {
|
||||
$PluginModelTask = PluginModelTask::where(['status' => ModelTaskStatus::WAIT_DOWNLOAD['value'], 'model_type' => ModelType::TOVIDEO['value']])->order('last_heartbeat asc,id asc')->lock(true)->find();
|
||||
if (!$PluginModelTask) {
|
||||
return;
|
||||
}
|
||||
$PluginModelTask->status = ModelTaskStatus::DOWNLOADING['value'];
|
||||
$PluginModelTask->last_heartbeat = date('Y-m-d H:i:s', strtotime('+5 seconds'));
|
||||
$PluginModelTask->save();
|
||||
$PluginModelTaskResult = PluginModelTaskResult::where('task_id', $PluginModelTask->id)->find();
|
||||
if (!$PluginModelTaskResult) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$ModelScene = ModelScene::get($PluginModelTask->scene);
|
||||
$classify = Uploads::getClassify($PluginModelTask->channels_uid, 'uploads/' . $PluginModelTask->scene, $ModelScene['label']);
|
||||
$result = Uploads::download($PluginModelTask->channels_uid, $PluginModelTaskResult->video, $classify);
|
||||
} catch (\Throwable $th) {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->status = ModelTaskStatus::WAIT_DOWNLOAD['value'];
|
||||
$PluginModelTask->save();
|
||||
Log::error("视频转存处理失败:" . $th->getMessage(), $th->getTrace());
|
||||
return;
|
||||
}
|
||||
$pushData = [
|
||||
'task_id' => $PluginModelTask->id,
|
||||
'id' => $PluginModelTask->alias_id,
|
||||
'video' => $result->file_url
|
||||
];
|
||||
$event = 'generate' . strtolower(str_replace('_', '', $PluginModelTask->scene));
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginModelTask = PluginModelTask::where('id', $PluginModelTask->id)->find();
|
||||
$PluginModelTask->status = ModelTaskStatus::SUCCESS['value'];
|
||||
$PluginModelTask->save();
|
||||
$PluginModelTaskResult = PluginModelTaskResult::where('task_id', $PluginModelTask->id)->find();
|
||||
$PluginModelTaskResult->video_path = $result->file_name;
|
||||
$PluginModelTaskResult->save();
|
||||
switch ($PluginModelTask->scene) {
|
||||
case ModelScene::STORYBOARD_VIDEO['value']:
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where('id', $PluginModelTask->alias_id)->find();
|
||||
$PluginShortplayDramaStoryboard->video = $result->file_name;
|
||||
$PluginShortplayDramaStoryboard->use_material_type='video';
|
||||
$PluginShortplayDramaStoryboard->save();
|
||||
$event = 'generatestoryboard';
|
||||
$pushData['event'] = ModelScene::STORYBOARD_VIDEO['value'];
|
||||
break;
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
Log::error("视频转存保存失败:" . $th->getMessage(), $th->getTrace());
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $PluginModelTask->uid,
|
||||
'channels_uid' => $PluginModelTask->channels_uid,
|
||||
'event' => $event
|
||||
], $pushData);
|
||||
});
|
||||
} catch (\Throwable $th) {
|
||||
Log::error("视频转存定时任务失败:" . $th->getMessage(), $th->getTrace());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'form_basic_title'=>'Basic',
|
||||
];
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'success' => 'Success',
|
||||
'fail' => 'Fail',
|
||||
];
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'success' => 'Success',
|
||||
];
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'form_basic_title'=>'基础信息',
|
||||
];
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'success' => '成功',
|
||||
'fail' => '失败',
|
||||
];
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'success' => '成功',
|
||||
];
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\utils\enum;
|
||||
|
||||
use app\expose\enum\builder\Enum;
|
||||
|
||||
class ModelPointType extends Enum
|
||||
{
|
||||
const TIMES = [
|
||||
'label' => '次',
|
||||
'value' => 'times',
|
||||
'unit' => '次'
|
||||
];
|
||||
const FIELD_RULE = [
|
||||
'label' => '字段规则',
|
||||
'value' => 'field_rule',
|
||||
'unit' => '秒起'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\utils\enum;
|
||||
|
||||
use app\expose\enum\builder\Enum;
|
||||
|
||||
class ModelScene extends Enum
|
||||
{
|
||||
const CREATIVE_SCRIPT = [
|
||||
'label' => '创意剧本',
|
||||
'value' => 'creative_script',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const CREATIVE_EPISODE = [
|
||||
'label' => '续写分集',
|
||||
'value' => 'creative_episode',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const CREATIVE_SCENES = [
|
||||
'label' => '创作场景',
|
||||
'value' => 'creative_scenes',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const CREATIVE_STORYBOARDS = [
|
||||
'label' => '创作分镜',
|
||||
'value' => 'creative_storyboards',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const DRAMA_COVER = [
|
||||
'label' => '短剧封面',
|
||||
'value' => 'drama_cover',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const SCENE_IMAGE = [
|
||||
'label' => '场景图片',
|
||||
'value' => 'scene_image',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const ACTOR_IMAGE = [
|
||||
'label' => '角色形象',
|
||||
'value' => 'actor_image',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const ACTOR_THREE_VIEW_IMAGE = [
|
||||
'label' => '角色三视图',
|
||||
'value' => 'actor_three_view_image',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const STORYBOARD_IMAGE = [
|
||||
'label' => '分镜图片',
|
||||
'value' => 'storyboard_image',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const CHARACTER_LOOK_COSTUME = [
|
||||
'label' => '角色服饰',
|
||||
'value' => 'character_look_costume',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const ACTOR_COSTUME = [
|
||||
'label' => '角色换装',
|
||||
'value' => 'actor_costume',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const ACTOR_COSTUME_THREE_VIEW = [
|
||||
'label' => '角色换装三视图',
|
||||
'value' => 'actor_costume_three_view',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const PROP_IMAGE = [
|
||||
'label' => '物品图片',
|
||||
'value' => 'prop_image',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const PROP_THREE_VIEW_IMAGE = [
|
||||
'label' => '物品三视图',
|
||||
'value' => 'prop_three_view_image',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const STORYBOARD_VIDEO = [
|
||||
'label' => '分镜视频',
|
||||
'value' => 'storyboard_video',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const DIALOGUE_VOICE = [
|
||||
'label' => '台词语音',
|
||||
'value' => 'dialogue_voice',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const STORYBOARD_NARRATION_VOICE = [
|
||||
'label' => '分镜旁白语音',
|
||||
'value' => 'storyboard_narration_voice',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const STORYBOARD_SFX_VOICE = [
|
||||
'label' => '分镜音效',
|
||||
'value' => 'storyboard_sfx_voice',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
const STORYBOARD_MUSIC_VOICE = [
|
||||
'label' => '分镜音乐',
|
||||
'value' => 'storyboard_music_voice',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
],
|
||||
'extra' => [
|
||||
'charge_unit' => '次',
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\utils\enum;
|
||||
|
||||
use app\expose\enum\builder\Enum;
|
||||
|
||||
class ModelTaskStatus extends Enum
|
||||
{
|
||||
const WAIT = [
|
||||
'label' => '待处理',
|
||||
'value' => 'wait',
|
||||
'props' => [
|
||||
'type' => 'info'
|
||||
]
|
||||
];
|
||||
const PROCESSING = [
|
||||
'label' => '处理中',
|
||||
'value' => 'processing',
|
||||
'props' => [
|
||||
'type' => 'primary'
|
||||
]
|
||||
];
|
||||
const WAIT_DOWNLOAD = [
|
||||
'label' => '等待下载',
|
||||
'value' => 'wait_download',
|
||||
'props' => [
|
||||
'type' => 'primary'
|
||||
]
|
||||
];
|
||||
const DOWNLOADING = [
|
||||
'label' => '下载中',
|
||||
'value' => 'downloading',
|
||||
'props' => [
|
||||
'type' => 'primary'
|
||||
]
|
||||
];
|
||||
const UPLOADING = [
|
||||
'label' => '上传中',
|
||||
'value' => 'uploading',
|
||||
'props' => [
|
||||
'type' => 'primary'
|
||||
]
|
||||
];
|
||||
const SUCCESS = [
|
||||
'label' => '成功',
|
||||
'value' => 'success',
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
];
|
||||
const FAIL = [
|
||||
'label' => '失败',
|
||||
'value' => 'fail',
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\utils\enum;
|
||||
|
||||
use app\expose\enum\builder\Enum;
|
||||
|
||||
class ModelType extends Enum
|
||||
{
|
||||
const CHAT = [
|
||||
'label' => '对话',
|
||||
'value' => 'chat',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
]
|
||||
];
|
||||
const DRAW = [
|
||||
'label' => '绘图',
|
||||
'value' => 'draw',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
]
|
||||
];
|
||||
const TOVIDEO = [
|
||||
'label' => '视频生成',
|
||||
'value' => 'tovideo',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
]
|
||||
];
|
||||
const AUDIO = [
|
||||
'label' => '音频生成',
|
||||
'value' => 'audio',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\model\utils\enum;
|
||||
|
||||
use app\expose\enum\builder\Enum;
|
||||
|
||||
class ModelVoiceStatus extends Enum
|
||||
{
|
||||
const WAIT = [
|
||||
'label' => '待提交',
|
||||
'value' => 'wait',
|
||||
'props' => [
|
||||
'type' => 'info'
|
||||
]
|
||||
];
|
||||
const CLONING = [
|
||||
'label' => '克隆中',
|
||||
'value' => 'cloning',
|
||||
'props' => [
|
||||
'type' => 'primary'
|
||||
]
|
||||
];
|
||||
const SUCCESS = [
|
||||
'label' => '成功',
|
||||
'value' => 'success',
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
];
|
||||
const FAIL = [
|
||||
'label' => '失败',
|
||||
'value' => 'fail',
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user