Merge branch 'develop'

This commit is contained in:
mzl
2025-09-18 15:05:57 +08:00
parent 5fef15b0fa
commit b7b6edb06c
46 changed files with 522 additions and 1512 deletions
@@ -1,49 +0,0 @@
<?php
namespace app\common\utils\approval\model;
use support\Model;
class ApprovalCcs extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'approval_ccs';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'instance_id', 'user_id', 'notified_at', 'read_at', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -1,49 +0,0 @@
<?php
namespace app\common\utils\approval\model;
use support\Model;
class ApprovalFlows extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'approval_flows';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'name', 'type', 'steps', 'is_active', 'timeout_hours', 'timeout_action', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -1,49 +0,0 @@
<?php
namespace app\common\utils\approval\model;
use support\Model;
class ApprovalInstances extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'approval_instances';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'flow_type', 'biz_id', 'biz_type', 'form_data', 'initiator_id', 'status', 'current_step', 'finished_at', 'deadline_at', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -1,49 +0,0 @@
<?php
namespace app\common\utils\approval\model;
use support\Model;
class ApprovalRecords extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'approval_records';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'instance_id', 'approver_id', 'step_index', 'action', 'comment', 'approved_at', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -1,7 +1,6 @@
<?php
namespace app\common\utils\approval\service;
use app\common\service\MessageNotificationsService;
use support\exception\BusinessException;
use support\Db;
@@ -234,31 +233,6 @@ class ApprovalFlowService
});
}
/** 我的待办 */
public function getPendingApprovals(int $userId): array
{
return Db::table('approval_records as ar')
->join('approval_instances as ai', 'ar.instance_id', '=', 'ai.id')
->where('ar.approver_id', $userId)
->where('ar.status', 'pending')
->where('ai.status', 'processing')
->select('ai.*')
->distinct()
->get()
->toArray();
}
/** 审批历史 */
public function getApprovalHistory(int $instanceId): array
{
return Db::table('approval_records')
->where('instance_id', $instanceId)
->orderBy('step_index')
->orderByRaw('COALESCE(approved_at, created_at) asc')
->get()
->toArray();
}
/** 流程图数据(把 skipped/timeout 视作已完结的中性状态) */
public function getFlowDiagramData(int $instanceId): array
{
@@ -577,7 +551,7 @@ class ApprovalFlowService
$prefix = $isCC ? '【抄送】' : '【审批】';
$text = $map[$action] ?? $action;
$approvalType = array_flip(\app\common\service\SysDictService::pluckKeyValueByCode('approval_type')->toArray());
$approvalType = array_flip(\app\common\service\SysDictService::pluckKeyValueByCode('approval_type'));
switch ($instance->flow_type) {
case 'stock_orders': // 备货单