144 lines
4.8 KiB
PHP
144 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace app\common\logic\CustomerMessage\Audit;
|
|
|
|
use app\common\model\Code\CodeModule as ModelCodeModule;
|
|
use app\common\model\Code\CodeModuleCategory as ModelCodeModuleCategory;
|
|
use app\common\model\Customer\CustomerMessage as ModelCustomerMessage;
|
|
use app\common\model\Token as ModelToken;
|
|
|
|
/**
|
|
* 客户消息-代码块类目审核
|
|
*/
|
|
class CodeModule
|
|
{
|
|
/**
|
|
* 发送客户类目审核消息(依据审核状态来进行对应消息发送)
|
|
*
|
|
* @param string $code_module_guid 代码块guid
|
|
* @param int $audit 审核状态
|
|
* @return void
|
|
* @date 2023-08-02
|
|
* @author xjh
|
|
* @since 1.0.0
|
|
*/
|
|
public static function sendAuditMessage(string $code_module_guid, int $audit, string $ps = "无附言"): void
|
|
{
|
|
switch ($audit) {
|
|
case ModelCodeModule::AUDIT_UNAUDITED:
|
|
self::unaudited($code_module_guid, $ps);
|
|
break;
|
|
case ModelCodeModule::AUDIT_PASS:
|
|
self::passAudit($code_module_guid, $ps);
|
|
break;
|
|
case ModelCodeModule::AUDIT_FAILED:
|
|
self::rejectAudit($code_module_guid, $ps);
|
|
break;
|
|
default:
|
|
throwErrorMsg('审核状态不正确!');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 待审核消息
|
|
*
|
|
* @param string $code_module_guid 代码块guid
|
|
* @param string $ps 附言
|
|
* @return void
|
|
* @date 2023-08-02
|
|
* @author xjh
|
|
* @since 1.0.0
|
|
*/
|
|
public static function unaudited(string $code_module_guid, string $ps = "无附言"): void
|
|
{
|
|
$title = "【公共代码块审核中】";
|
|
$content_info = self::bulidContentInfo($code_module_guid, '正在认真审核中,请耐心等待...');
|
|
ModelCustomerMessage::create([
|
|
'customer_message_title' => $title,
|
|
'customer_message_content' => $content_info['content'],
|
|
'customer_message_postscript' => $ps,
|
|
'customer_guid' => $content_info['customer_guid'],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 审核通过消息
|
|
*
|
|
* @param string $code_module_guid 代码块guid
|
|
* @param string $ps 附言
|
|
* @return void
|
|
* @date 2023-08-02
|
|
* @author xjh
|
|
* @since 1.0.0
|
|
*/
|
|
public static function passAudit(string $code_module_guid, string $ps = "无附言"): void
|
|
{
|
|
$title = "【公共代码块审核结果】";
|
|
$content_info = self::bulidContentInfo($code_module_guid, '审核结果:通过!');
|
|
ModelCustomerMessage::create([
|
|
'customer_message_title' => $title,
|
|
'customer_message_content' => $content_info['content'],
|
|
'customer_message_postscript' => $ps,
|
|
'customer_guid' => $content_info['customer_guid'],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 审核驳回消息
|
|
*
|
|
* @param string $code_module_guid 代码块guid
|
|
* @param string $ps 附言
|
|
* @return void
|
|
* @date 2023-08-02
|
|
* @author xjh
|
|
* @since 1.0.0
|
|
*/
|
|
public static function rejectAudit(string $code_module_guid, string $ps = "无附言"): void
|
|
{
|
|
$title = "【公共代码块审核结果】";
|
|
$content_info = self::bulidContentInfo($code_module_guid, '审核结果:驳回!');
|
|
ModelCustomerMessage::create([
|
|
'customer_message_title' => $title,
|
|
'customer_message_content' => $content_info['content'],
|
|
'customer_message_postscript' => $ps,
|
|
'customer_guid' => $content_info['customer_guid'],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 获取审核消息所需信息
|
|
*
|
|
* @param string $code_module_guid 代码块guid
|
|
* @param string $type 审核结果类型
|
|
* @return array ['content' => 审核消息内容 , 'customer_guid' => 所属客户guid]
|
|
* @date 2023-08-02
|
|
* @author xjh
|
|
* @since 1.0.0
|
|
*/
|
|
public static function bulidContentInfo(string $code_module_guid, string $main_content): array
|
|
{
|
|
$module = ModelCodeModule::find($code_module_guid);
|
|
if (!$module) {
|
|
throwErrorMsg("客户消息-代码块审核信息构建异常(代码块不存在!)");
|
|
}
|
|
//代码块提交审核的时间
|
|
$start_datetime = date('Y-m-d H:i:s');
|
|
|
|
//所属类目信息获取
|
|
$category = ModelCodeModuleCategory::scope('notMaster')->find($module->code_module_category_guid);
|
|
if (!$category) {
|
|
throwErrorMsg("客户消息-代码块类目审核信息构建异常(代码块所属类目不存在!)");
|
|
}
|
|
|
|
//代码块名称构建
|
|
$module_name = "(所属类目:{$category->code_module_category_name})代码块:{$module->code_module_name}";
|
|
|
|
//整体消息内容
|
|
$content = "您在 {$start_datetime} 提交的公共代码块【{$module_name}】" . $main_content;
|
|
|
|
return [
|
|
'content' => $content,
|
|
'customer_guid' => $module->customer_guid,
|
|
];
|
|
}
|
|
} |