5 changed files with 129 additions and 37 deletions
-
9app/model/Audit.php
-
79app/model/Resource.php
-
31app/service/AuditService.php
-
42app/service/ProcessService.php
-
5app/service/ResourceService.php
@ -0,0 +1,9 @@ |
|||
<?php |
|||
|
|||
namespace app\model; |
|||
|
|||
use app\exception\ModelException; |
|||
|
|||
class Audit extends Model |
|||
{ |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
|
|||
namespace app\service; |
|||
|
|||
use app\model\Audit; |
|||
|
|||
class AuditService |
|||
{ |
|||
/** |
|||
* @param $ids 资源/内容 数组 |
|||
* @param $target_type 1资源 2内容 |
|||
* @param $type 1上传 2下载 |
|||
* @param $status 1待审核 2审核通过 3审核失败 |
|||
* @return void |
|||
* 批量添加审核记录表 |
|||
*/ |
|||
public function addAudit($ids, $target_type, $type = 1, $status = 1) |
|||
{ |
|||
$audit_ary = []; |
|||
foreach ($ids as $id) { |
|||
$audit['target_id'] = $id; |
|||
$audit['target_type'] = $target_type; |
|||
$audit['type'] = $type; |
|||
$audit['status'] = $status; |
|||
$audit_ary [] = $audit; |
|||
} |
|||
$audit = new Audit(); |
|||
$audit->saveAll($audit_ary); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
<?php |
|||
|
|||
namespace app\service; |
|||
|
|||
use app\model\Process; |
|||
use app\model\Resource; |
|||
|
|||
class ProcessService |
|||
{ |
|||
public $resource_status_map; |
|||
|
|||
public function __construct() |
|||
{ |
|||
$this->resource_status_map = Resource::STATUS_MAP; |
|||
} |
|||
|
|||
/** |
|||
* @param $insert_audit_flag 是否需要插入审核表 |
|||
* @return int |
|||
* 通过流程表 获取资源上传后的状态 |
|||
*/ |
|||
public function getResouceUploadStatus($resource, $insert_audit_flag = false) |
|||
{ |
|||
$status = $this->resource_status_map['not']; |
|||
|
|||
$process = (Process::where('flag', 'resource_upload')->find()); |
|||
//流程停用开启 上传后状态直接是审核通过
|
|||
if ($process->stop_using == 1) { |
|||
$status = $this->resource_status_map['success']; |
|||
} |
|||
|
|||
//自动发起开启 上传后状态直接是等待审核
|
|||
if ($process->auto_propose == 1) { |
|||
$status = $this->resource_status_map['wait']; |
|||
if ($insert_audit_flag) { |
|||
(new AuditService())->addAudit([$resource->id], 1); |
|||
} |
|||
} |
|||
|
|||
return $status; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue