feat:完成审核功能所关联的发送客户消息功能
This commit is contained in:
parent
1431447307
commit
6b238a4923
@ -40,7 +40,8 @@ class CodeModule extends BaseController
|
||||
'a.code_module_style',
|
||||
'a.code_module_script',
|
||||
'a.code_module_sort',
|
||||
'a.code_module_audit'
|
||||
'a.code_module_audit',
|
||||
'a.customer_guid'
|
||||
])
|
||||
->order('code_module_sort', 'asc');
|
||||
|
||||
@ -128,14 +129,19 @@ class CodeModule extends BaseController
|
||||
*/
|
||||
public function auditCodeModule(Request $request)
|
||||
{
|
||||
$params = $request->param();
|
||||
$this->validate($params, [
|
||||
'code_module_guid|代码块guid' => 'require',
|
||||
'code_module_audit|审核状态' => 'require|in:2,3',
|
||||
]);
|
||||
|
||||
ModelCodeModule::auditCodeModule($params);
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$params = $request->param();
|
||||
$this->validate($params, [
|
||||
'code_module_guid|代码块guid' => 'require',
|
||||
'code_module_audit|审核状态' => 'require|in:2,3',
|
||||
]);
|
||||
ModelCodeModule::auditCodeModule($params);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
throw $th;
|
||||
}
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '审核成功'
|
||||
|
@ -180,7 +180,16 @@ class CodeModuleCategory extends BaseController
|
||||
]);
|
||||
Db::startTrans();
|
||||
try {
|
||||
LogicCodeModuleCategoryAudit::handleAudit(explode(',', $params['code_module_category_guid']), $params['code_module_category_audit']);
|
||||
$ps = "无附言";
|
||||
if (isset($params['ps']) && $params['ps']) {
|
||||
$ps = $params['ps'];
|
||||
}
|
||||
|
||||
LogicCodeModuleCategoryAudit::handleAudit(
|
||||
explode(',', $params['code_module_category_guid']),
|
||||
$params['code_module_category_audit'],
|
||||
$ps
|
||||
);
|
||||
Db::commit();
|
||||
return msg('审核成功!');
|
||||
} catch (\Throwable $th) {
|
||||
|
@ -71,21 +71,22 @@ class CodeModuleCategory
|
||||
->whereOr([
|
||||
['cmc.code_module_category_guid', 'in', $module_category_guids],
|
||||
['cmc.code_module_category_parent_guid', 'in', $module_category_guids],
|
||||
])->field([
|
||||
'cmc.code_module_category_id',
|
||||
'cmc.code_module_category_guid',
|
||||
'cmc.customer_guid',
|
||||
'cmc.code_module_category_audit',
|
||||
'cmc.code_module_category_sort',
|
||||
'cmc.code_module_category_parent_guid',
|
||||
'cmc.code_module_category_name',
|
||||
'cmc.code_module_category_audit',
|
||||
'cmc.code_module_category_global_mode',
|
||||
'cmc.code_module_category_library_type',
|
||||
'cmc.code_module_category_ps',
|
||||
'cmcp.code_module_category_name' => "code_module_category_parent_name",
|
||||
'cust.customer_name',
|
||||
])
|
||||
])->where([['cmcp.code_module_category_delete_time', 'NUll', null]])
|
||||
->field([
|
||||
'cmc.code_module_category_id',
|
||||
'cmc.code_module_category_guid',
|
||||
'cmc.customer_guid',
|
||||
'cmc.code_module_category_audit',
|
||||
'cmc.code_module_category_sort',
|
||||
'cmc.code_module_category_parent_guid',
|
||||
'cmc.code_module_category_name',
|
||||
'cmc.code_module_category_audit',
|
||||
'cmc.code_module_category_global_mode',
|
||||
'cmc.code_module_category_library_type',
|
||||
'cmc.code_module_category_ps',
|
||||
'cmcp.code_module_category_name' => "code_module_category_parent_name",
|
||||
'cust.customer_name',
|
||||
])
|
||||
->leftjoin('code_module_category cmcp', 'cmc.code_module_category_parent_guid = cmcp.code_module_category_guid')
|
||||
->leftjoin('customer cust', 'cmc.customer_guid = cust.customer_guid')
|
||||
->order('code_module_category_sort')
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace app\admin\logic\Code;
|
||||
|
||||
use app\common\model\Code\CodeModuleCategory as ModelCodeModuleCategory;
|
||||
use app\common\logic\CustomerMessage\Audit\CodeModuleCategory as CustomerMessageAuditCodeModuleCategory;
|
||||
use app\common\exception\Tool;
|
||||
|
||||
|
||||
@ -13,25 +14,30 @@ class CodeModuleCategoryAudit
|
||||
*
|
||||
* @param array $code_module_category_guids 类目guid数组
|
||||
* @param int $code_module_category_audit 审核状态
|
||||
* @param string $ps 附言
|
||||
* @return void
|
||||
* @date 2023-07-05
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function handleAudit(array $code_module_category_guids, int $code_module_category_audit): void
|
||||
public static function handleAudit(array $code_module_category_guids, int $code_module_category_audit, string $ps): void
|
||||
{
|
||||
foreach ($code_module_category_guids as $code_module_category_guid) {
|
||||
//类目审核基本信息验证
|
||||
$module_category = ModelCodeModuleCategory::find($code_module_category_guid);
|
||||
if (!$module_category) {
|
||||
throwErrorMsg("含有不存在的类目!");
|
||||
}
|
||||
if ($module_category->code_module_category_audit != ModelCodeModuleCategory::AUDIT_UNAUDITED) {
|
||||
throwErrorMsg("含有已审核过的的类目!");
|
||||
}
|
||||
//主类目审核处理
|
||||
if ($module_category->code_module_category_parent_guid == ModelCodeModuleCategory::MASTER_DEFAULT) {
|
||||
self::handleMainCategory($module_category, $code_module_category_audit);
|
||||
self::handleMainCategory($module_category, $code_module_category_audit, $ps);
|
||||
}
|
||||
//子类目审核处理
|
||||
else {
|
||||
self::handleSonCategory($module_category, $code_module_category_audit);
|
||||
self::handleSonCategory($module_category, $code_module_category_audit, $ps);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -41,23 +47,31 @@ class CodeModuleCategoryAudit
|
||||
*
|
||||
* @param ModelCodeModuleCategory $module_category 模型实例
|
||||
* @param int $code_module_category_audit 审核状态
|
||||
* @param string $ps 附言
|
||||
* @return void
|
||||
* @date 2023-07-05
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function handleMainCategory(ModelCodeModuleCategory $module_category, int $code_module_category_audit): void
|
||||
public static function handleMainCategory(ModelCodeModuleCategory $module_category, int $code_module_category_audit, string $ps): void
|
||||
{
|
||||
//主类目的审核将会直接将所属的子类目们审核状态连带修改
|
||||
//(例: 主类目审核通过则子类目将会全员审核状态为通过)
|
||||
//【主类目更新】
|
||||
$module_category->code_module_category_audit = $code_module_category_audit;
|
||||
$module_category->save();
|
||||
CustomerMessageAuditCodeModuleCategory::sendAuditMessage($module_category->code_module_category_guid, $code_module_category_audit, $ps);
|
||||
|
||||
//【所属子类目们的更新】
|
||||
ModelCodeModuleCategory::where('code_module_category_parent_guid', $module_category->code_module_category_guid)->select()->update([
|
||||
'code_module_category_audit' => $code_module_category_audit
|
||||
]);
|
||||
$son_code_module_category_guids = ModelCodeModuleCategory::where('code_module_category_parent_guid', $module_category->code_module_category_guid)
|
||||
->column('code_module_category_guid');
|
||||
foreach ($son_code_module_category_guids as $son_code_module_category_guid) {
|
||||
ModelCodeModuleCategory::update([
|
||||
'code_module_category_audit' => $code_module_category_audit,
|
||||
'code_module_category_guid' => $son_code_module_category_guid,
|
||||
]);
|
||||
CustomerMessageAuditCodeModuleCategory::sendAuditMessage($son_code_module_category_guid, $code_module_category_audit, $ps);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,16 +79,18 @@ class CodeModuleCategoryAudit
|
||||
*
|
||||
* @param ModelCodeModuleCategory $module_category 模型实例
|
||||
* @param int $code_module_category_audit 审核状态
|
||||
* @param string $ps 附言
|
||||
* @return void
|
||||
* @date 2023-07-05
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function handleSonCategory(ModelCodeModuleCategory $module_category, int $code_module_category_audit): void
|
||||
public static function handleSonCategory(ModelCodeModuleCategory $module_category, int $code_module_category_audit, string $ps): void
|
||||
{
|
||||
//【当前子类目更新】
|
||||
$module_category->code_module_category_audit = $code_module_category_audit;
|
||||
$module_category->save();
|
||||
CustomerMessageAuditCodeModuleCategory::sendAuditMessage($module_category->code_module_category_guid, $code_module_category_audit, $ps);
|
||||
|
||||
//【所属主类目更新】
|
||||
$module_category_parent_guid = $module_category->code_module_category_parent_guid;
|
||||
@ -97,10 +113,12 @@ class CodeModuleCategoryAudit
|
||||
break;
|
||||
}
|
||||
}
|
||||
$audit = $is_all_not_failed ? ModelCodeModuleCategory::AUDIT_FAILED : ModelCodeModuleCategory::AUDIT_PASS;
|
||||
ModelCodeModuleCategory::update([
|
||||
'code_module_category_guid' => $module_category_parent_guid,
|
||||
'code_module_category_audit' => $is_all_not_failed ? ModelCodeModuleCategory::AUDIT_FAILED : ModelCodeModuleCategory::AUDIT_PASS,
|
||||
'code_module_category_audit' => $audit,
|
||||
]);
|
||||
CustomerMessageAuditCodeModuleCategory::sendAuditMessage($module_category_parent_guid, $audit, $ps);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ namespace app\api\controller\CodeCustomer;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\model\Code\CodeModule as ModelCodeModule;
|
||||
use app\common\model\Code\CodeModuleCategory as ModelCodeModuleCategory;
|
||||
use app\api\logic\Code\CodeModule as LogicCodeModule;
|
||||
use app\common\model\Token as ModelToken;
|
||||
use app\Request;
|
||||
@ -16,6 +17,7 @@ use think\facade\Db;
|
||||
use app\common\exception\Tool;
|
||||
use think\facade\Env;
|
||||
use app\BaseModel;
|
||||
use app\common\logic\CustomerMessage\Audit\CodeModule as CustomerMessageAuditCodeModule;
|
||||
|
||||
|
||||
class CodeModule extends BaseController
|
||||
@ -31,30 +33,48 @@ class CodeModule extends BaseController
|
||||
*/
|
||||
public function addCodeModule(Request $request): array
|
||||
{
|
||||
BaseModel::setUserGuid(false);
|
||||
$params = $request->param();
|
||||
$this->validate($params, [
|
||||
'code_module_category_guid|类目' => 'require',
|
||||
'code_module_name|代码块名称' => 'require',
|
||||
'code_module_html|html内容' => 'require',
|
||||
]);
|
||||
LogicCodeModule::validateAddCodeModule($params);
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
BaseModel::setUserGuid(false);
|
||||
$params = $request->param();
|
||||
$this->validate($params, [
|
||||
'code_module_category_guid|类目' => 'require',
|
||||
'code_module_name|代码块名称' => 'require',
|
||||
'code_module_html|html内容' => 'require',
|
||||
]);
|
||||
LogicCodeModule::validateAddCodeModule($params);
|
||||
|
||||
$params['code_module_audit'] = LogicCodeModule::buildCodeModuleAudit($params['code_module_category_guid']);
|
||||
$module_create = ModelCodeModule::create($params, [
|
||||
'code_module_category_guid',
|
||||
'code_module_name',
|
||||
'code_module_html',
|
||||
'code_module_style',
|
||||
'code_module_script',
|
||||
'code_module_sort',
|
||||
'code_module_audit',
|
||||
'code_module_guid',
|
||||
'code_module_create_user_guid',
|
||||
'code_module_update_user_guid',
|
||||
'customer_guid',
|
||||
]);
|
||||
|
||||
//公共类目提交则走发送审核消息流程
|
||||
$category = ModelCodeModuleCategory::find($module_create->code_module_category_guid);
|
||||
if (!$category) {
|
||||
throwErrorMsg("当前代码块所属类目不存在!");
|
||||
}
|
||||
if ($category->code_module_category_library_type == ModelCodeModuleCategory::LIBRARY_COMMON) {
|
||||
CustomerMessageAuditCodeModule::unaudited($module_create->code_module_guid);
|
||||
}
|
||||
Db::commit();
|
||||
return msg('添加代码块成功!');
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
throw $th;
|
||||
}
|
||||
|
||||
$params['customer_guid'] = ModelToken::getCurrentCustomer()->customer_guid;
|
||||
$params['code_module_audit'] = LogicCodeModule::buildCodeModuleAudit($params['code_module_category_guid']);
|
||||
ModelCodeModule::create($params, [
|
||||
'code_module_category_guid',
|
||||
'code_module_name',
|
||||
'code_module_html',
|
||||
'code_module_style',
|
||||
'code_module_script',
|
||||
'code_module_sort',
|
||||
'code_module_audit',
|
||||
'code_module_guid',
|
||||
'code_module_create_user_guid',
|
||||
'code_module_update_user_guid'
|
||||
]);
|
||||
return msg('添加代码块成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ use app\common\model\Token as ModelToken;
|
||||
use think\facade\Env;
|
||||
use app\api\logic\Code\CodeModuleCategory as LogicCodeModuleCategory;
|
||||
use app\common\logic\Code\CodeModuleCategory as CommonLogicCodeModuleCategory;
|
||||
use app\common\logic\CustomerMessage\Audit\CodeModuleCategory as CustomerMessageAuditCodeModuleCategory;
|
||||
use app\BaseModel;
|
||||
|
||||
|
||||
@ -33,32 +34,43 @@ class CodeModuleCategory extends BaseController
|
||||
*/
|
||||
public function addCodeModuleCategory(Request $request): array
|
||||
{
|
||||
BaseModel::setUserGuid(false);
|
||||
$params = $request->param();
|
||||
$this->validate($params, [
|
||||
'code_module_category_parent_guid|上级类目guid' => 'require',
|
||||
'code_module_category_name|类目名' => 'require',
|
||||
'code_module_category_sort|排序' => 'require',
|
||||
'code_module_category_global_mode|全局模式' => 'require',
|
||||
'code_module_category_library_type|库类型' => 'require',
|
||||
]);
|
||||
$params['customer_guid'] = ModelToken::getCurrentCustomer()->customer_guid;
|
||||
$params['code_module_category_audit'] = LogicCodeModuleCategory::buildCodeModuleCategoryAudit($params['code_module_category_library_type']);
|
||||
LogicCodeModuleCategory::validateAddCodeModuleCategory($params);
|
||||
ModelCodeModuleCategory::create($params, [
|
||||
'code_module_category_name',
|
||||
'code_module_category_parent_guid',
|
||||
'code_module_category_sort',
|
||||
'code_module_category_global_mode',
|
||||
'code_module_category_library_type',
|
||||
'customer_guid',
|
||||
'code_module_category_audit',
|
||||
'code_module_category_ps',
|
||||
'code_module_category_guid',
|
||||
'code_module_category_create_user_guid',
|
||||
'code_module_category_update_user_guid'
|
||||
]);
|
||||
return msg('添加类目成功!');
|
||||
Db::startTrans();
|
||||
try {
|
||||
BaseModel::setUserGuid(false);
|
||||
$params = $request->param();
|
||||
$this->validate($params, [
|
||||
'code_module_category_parent_guid|上级类目guid' => 'require',
|
||||
'code_module_category_name|类目名' => 'require',
|
||||
'code_module_category_sort|排序' => 'require',
|
||||
'code_module_category_global_mode|全局模式' => 'require',
|
||||
'code_module_category_library_type|库类型' => 'require',
|
||||
]);
|
||||
$params['customer_guid'] = ModelToken::getCurrentCustomer()->customer_guid;
|
||||
$params['code_module_category_audit'] = LogicCodeModuleCategory::buildCodeModuleCategoryAudit($params['code_module_category_library_type']);
|
||||
LogicCodeModuleCategory::validateAddCodeModuleCategory($params);
|
||||
$category_create = ModelCodeModuleCategory::create($params, [
|
||||
'code_module_category_name',
|
||||
'code_module_category_parent_guid',
|
||||
'code_module_category_sort',
|
||||
'code_module_category_global_mode',
|
||||
'code_module_category_library_type',
|
||||
'customer_guid',
|
||||
'code_module_category_audit',
|
||||
'code_module_category_ps',
|
||||
'code_module_category_guid',
|
||||
'code_module_category_create_user_guid',
|
||||
'code_module_category_update_user_guid'
|
||||
]);
|
||||
//公共类目提交则走发送审核消息流程
|
||||
if ($category_create->code_module_category_library_type == ModelCodeModuleCategory::LIBRARY_COMMON) {
|
||||
CustomerMessageAuditCodeModuleCategory::unaudited($category_create->code_module_category_guid);
|
||||
}
|
||||
Db::commit();
|
||||
return msg('添加类目成功!');
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
throw $th;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,6 +115,10 @@ class CodeModuleCategory extends BaseController
|
||||
'code_module_category_update_user_guid'
|
||||
])->save($params);
|
||||
CommonLogicCodeModuleCategory::hanldCommonInfoFieldsDataSync($params['code_module_category_guid']);
|
||||
//公共类目提交则走发送审核消息流程
|
||||
if ($params['code_module_category_library_type'] == ModelCodeModuleCategory::LIBRARY_COMMON) {
|
||||
CustomerMessageAuditCodeModuleCategory::unaudited($params['code_module_category_guid']);
|
||||
}
|
||||
Db::commit();
|
||||
return msg('编辑类目成功!');
|
||||
} catch (\Throwable $th) {
|
||||
|
@ -7,6 +7,8 @@ use app\common\model\Code\CodeModule as ModelCodeModule;
|
||||
use app\common\model\Token as ModelToken;
|
||||
use app\common\arw\adjfut\src\Exception\ErrorMsg;
|
||||
use app\common\exception\Tool;
|
||||
use app\common\logic\CustomerMessage\Audit\CodeModuleCategory as CustomerMessageAuditCodeModuleCategory;
|
||||
use app\common\logic\CustomerMessage\Audit\CodeModule as CustomerMessageAuditCodeModule;
|
||||
|
||||
|
||||
class CodeModuleCategory
|
||||
@ -51,14 +53,17 @@ class CodeModuleCategory
|
||||
$category = self::validateMasterCodeModuleCategory($code_module_category_guid, true);
|
||||
//主级类目拷贝送审
|
||||
$master_category_add = $addCategory($category);
|
||||
CustomerMessageAuditCodeModuleCategory::unaudited($master_category_add->code_module_category_guid);
|
||||
//子级类目拷贝送审
|
||||
$category_sons = ModelCodeModuleCategory::where('code_module_category_parent_guid', $code_module_category_guid)->select();
|
||||
foreach ($category_sons as $category_son) {
|
||||
$son_category_add = $addCategory($category_son, $master_category_add->code_module_category_guid);
|
||||
CustomerMessageAuditCodeModuleCategory::unaudited($son_category_add->code_module_category_guid);
|
||||
//各个子级类目的代码块送审
|
||||
$code_modules = ModelCodeModule::where('code_module_category_guid', $category_son->code_module_category_guid)->select();
|
||||
foreach ($code_modules as $code_module) {
|
||||
$addModule($code_module, $son_category_add->code_module_category_guid);
|
||||
CustomerMessageAuditCodeModule::unaudited($son_category_add->code_module_category_guid);
|
||||
}
|
||||
}
|
||||
|
||||
|
30
app/common/logic/Code/CodeModule.php
Normal file
30
app/common/logic/Code/CodeModule.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic\Code;
|
||||
|
||||
use app\common\model\Code\CodeModule as ModelCodeModule;
|
||||
use app\common\model\Code\CodeModuleCategory as ModelCodeModuleCategory;
|
||||
use app\common\model\Token as ModelToken;
|
||||
|
||||
|
||||
class CodeModule
|
||||
{
|
||||
|
||||
/**
|
||||
* 代码块新增前客户guid处理
|
||||
*
|
||||
* @param ModelCodeModule $model
|
||||
* @return array
|
||||
* @date 2023-08-02
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function onBeforeCustomerGuid(ModelCodeModule $model): void
|
||||
{
|
||||
$category = ModelCodeModuleCategory::scope('notMaster')->find($model->code_module_category_guid);
|
||||
if (!$category) {
|
||||
throwErrorMsg("当前代码块所属类目不存在!");
|
||||
}
|
||||
$model->customer_guid = $category->customer_guid;
|
||||
}
|
||||
}
|
@ -60,7 +60,10 @@ class CodeModuleCategory
|
||||
throwErrorMsg('当前类目已有子类目,不可更换上级类目!');
|
||||
}
|
||||
} else {
|
||||
$model->code_module_category_parent_guid = ModelCodeModuleCategory::MASTER_DEFAULT;
|
||||
//新增前若没指定上级类目自自动将当前类目定为主级类目
|
||||
if (!isset($model->code_module_category_guid)) {
|
||||
$model->code_module_category_parent_guid = ModelCodeModuleCategory::MASTER_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,14 +78,16 @@ class CodeModuleCategory
|
||||
*/
|
||||
public static function validateCategoryInfo(ModelCodeModuleCategory $model): void
|
||||
{
|
||||
if ($model->code_module_category_parent_guid != ModelCodeModuleCategory::MASTER_DEFAULT) {
|
||||
$parent_category = ModelCodeModuleCategory::find($model->code_module_category_parent_guid);
|
||||
if (!$parent_category) {
|
||||
throwErrorMsg("上级类目不存在!");
|
||||
}
|
||||
foreach (ModelCodeModuleCategory::COMMON_INFO_FIELDS as $field) {
|
||||
if ($model->$field != $parent_category->$field) {
|
||||
throwErrorMsg("父子类目共用信息{$field}未完全相同! ");
|
||||
if (isset($model->code_module_category_parent_guid) && $model->code_module_category_parent_guid) {
|
||||
if ($model->code_module_category_parent_guid != ModelCodeModuleCategory::MASTER_DEFAULT) {
|
||||
$parent_category = ModelCodeModuleCategory::find($model->code_module_category_parent_guid);
|
||||
if (!$parent_category) {
|
||||
throwErrorMsg("上级类目不存在!");
|
||||
}
|
||||
foreach (ModelCodeModuleCategory::COMMON_INFO_FIELDS as $field) {
|
||||
if ($model->$field != $parent_category->$field) {
|
||||
throwErrorMsg("父子类目共用信息{$field}未完全相同! ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
144
app/common/logic/CustomerMessage/Audit/CodeModule.php
Normal file
144
app/common/logic/CustomerMessage/Audit/CodeModule.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?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 = $module->code_module_create_time;
|
||||
|
||||
//所属类目信息获取
|
||||
$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,
|
||||
];
|
||||
}
|
||||
}
|
145
app/common/logic/CustomerMessage/Audit/CodeModuleCategory.php
Normal file
145
app/common/logic/CustomerMessage/Audit/CodeModuleCategory.php
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic\CustomerMessage\Audit;
|
||||
|
||||
use app\common\model\Code\CodeModuleCategory as ModelCodeModuleCategory;
|
||||
use app\common\model\Customer\CustomerMessage as ModelCustomerMessage;
|
||||
use app\common\model\Token as ModelToken;
|
||||
|
||||
/**
|
||||
* 客户消息-代码块类目审核
|
||||
*/
|
||||
class CodeModuleCategory
|
||||
{
|
||||
/**
|
||||
* 发送客户类目审核消息(依据审核状态来进行对应消息发送)
|
||||
*
|
||||
* @param string $code_module_category_guid 代码块类目guid
|
||||
* @param int $audit 审核状态
|
||||
* @return void
|
||||
* @date 2023-08-01
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function sendAuditMessage(string $code_module_category_guid, int $audit, string $ps = "无附言"): void
|
||||
{
|
||||
switch ($audit) {
|
||||
case ModelCodeModuleCategory::AUDIT_UNAUDITED:
|
||||
self::unaudited($code_module_category_guid, $ps);
|
||||
break;
|
||||
case ModelCodeModuleCategory::AUDIT_PASS:
|
||||
self::passAudit($code_module_category_guid, $ps);
|
||||
break;
|
||||
case ModelCodeModuleCategory::AUDIT_FAILED:
|
||||
self::rejectAudit($code_module_category_guid, $ps);
|
||||
break;
|
||||
default:
|
||||
throwErrorMsg('审核状态不正确!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 待审核消息
|
||||
*
|
||||
* @param string $code_module_category_guid 代码块类目guid
|
||||
* @param string $ps 附言
|
||||
* @return void
|
||||
* @date 2023-08-01
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function unaudited(string $code_module_category_guid, string $ps = "无附言"): void
|
||||
{
|
||||
$title = "【公共代码块类目审核中】";
|
||||
$content_info = self::bulidContentInfo($code_module_category_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_category_guid 代码块类目guid
|
||||
* @param string $ps 附言
|
||||
* @return void
|
||||
* @date 2023-08-01
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function passAudit(string $code_module_category_guid, string $ps = "无附言"): void
|
||||
{
|
||||
$title = "【公共代码块类目审核结果】";
|
||||
$content_info = self::bulidContentInfo($code_module_category_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_category_guid 代码块类目guid
|
||||
* @param string $ps 附言
|
||||
* @return void
|
||||
* @date 2023-08-01
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function rejectAudit(string $code_module_category_guid, string $ps = "无附言"): void
|
||||
{
|
||||
$title = "【公共代码块类目审核结果】";
|
||||
$content_info = self::bulidContentInfo($code_module_category_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_category_guid 代码块类目guid
|
||||
* @param string $type 审核结果类型
|
||||
* @return array ['content' => 审核消息内容 , 'customer_guid' => 客户guid]
|
||||
* @date 2023-08-01
|
||||
* @author xjh
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function bulidContentInfo(string $code_module_category_guid, string $main_content): array
|
||||
{
|
||||
$category = ModelCodeModuleCategory::find($code_module_category_guid);
|
||||
if (!$category) {
|
||||
throwErrorMsg("客户消息-代码块类目审核信息构建异常(类目不存在!)");
|
||||
}
|
||||
//类目提交审核的时间
|
||||
$start_datetime = $category->code_module_category_create_time;
|
||||
|
||||
//主子级类目区分处理
|
||||
if ($category->code_module_category_parent_guid == ModelCodeModuleCategory::MASTER_DEFAULT) {
|
||||
$category_name = "主级类目:{$category->code_module_category_name}";
|
||||
} else {
|
||||
$parent_category = ModelCodeModuleCategory::find($category->code_module_category_parent_guid);
|
||||
if (!$parent_category) {
|
||||
throwErrorMsg("客户消息-代码模块类目审核信息构建异常(所属父级类目不存在!)");
|
||||
}
|
||||
$category_name = "(所属主级类目:{$parent_category->code_module_category_name})子级类目:{$category->code_module_category_name}";
|
||||
}
|
||||
|
||||
//整体消息内容
|
||||
$content = "您在 {$start_datetime} 提交的公共类目【{$category_name}】" . $main_content;
|
||||
|
||||
return [
|
||||
'content' => $content,
|
||||
'customer_guid' => $category->customer_guid,
|
||||
];
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@ use app\common\exception\Tool;
|
||||
use think\facade\Db;
|
||||
use app\common\model\Dictionary\Dictionary as ModelDictionary;
|
||||
use app\common\model\Code\CodeModuleCategory as ModelCodeModuleCategory;
|
||||
use app\common\logic\CustomerMessage\Audit\CodeModule as CustomerMessageAuditCodeModule;
|
||||
use app\common\logic\Code\CodeModule as CommonLogicCodeModule;
|
||||
|
||||
class CodeModule extends BaseModel
|
||||
{
|
||||
@ -82,7 +84,7 @@ class CodeModule extends BaseModel
|
||||
*/
|
||||
public static function onBeforeInsert(self $model): void
|
||||
{
|
||||
// Tool::dataAddSortProc($model, ['code_module_category_guid' => $model->code_module_category_guid]);
|
||||
CommonLogicCodeModule::onBeforeCustomerGuid($model);
|
||||
$model->completeCreateField();
|
||||
}
|
||||
|
||||
@ -91,7 +93,6 @@ class CodeModule extends BaseModel
|
||||
*/
|
||||
public static function onBeforeUpdate(self $model): void
|
||||
{
|
||||
// Tool::dataEditSortProc($model, ['code_module_category_guid' => $model->code_module_category_guid]);
|
||||
$model->completeUpdateField();
|
||||
}
|
||||
|
||||
@ -100,7 +101,6 @@ class CodeModule extends BaseModel
|
||||
*/
|
||||
public static function onBeforeDelete(self $model): void
|
||||
{
|
||||
// Tool::dataDeleteSortProc($model);
|
||||
$model->completeDeleteField();
|
||||
}
|
||||
|
||||
@ -244,23 +244,14 @@ class CodeModule extends BaseModel
|
||||
{
|
||||
$params_audit_status = $params['code_module_audit'];
|
||||
$code_module_guids_arr = explode(',', $params['code_module_guid']);
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
if (count($code_module_guids_arr) > 1) {
|
||||
foreach ($code_module_guids_arr as $key => $value) {
|
||||
self::audit($value, $params);
|
||||
}
|
||||
} else {
|
||||
self::audit($params['code_module_guid'], $params);
|
||||
if (count($code_module_guids_arr) > 1) {
|
||||
foreach ($code_module_guids_arr as $key => $value) {
|
||||
self::audit($value, $params);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
throw $th;
|
||||
} else {
|
||||
self::audit($params['code_module_guid'], $params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -270,19 +261,22 @@ class CodeModule extends BaseModel
|
||||
public static function audit($value, $params)
|
||||
{
|
||||
$model = self::where('code_module_guid', $value)->find();
|
||||
if (!$model)
|
||||
if (!$model) {
|
||||
throwErrorMsg("该代码块不存在", 1);
|
||||
}
|
||||
|
||||
$audit_status = $model->code_module_audit;
|
||||
$code_module_name = $model->code_module_name;
|
||||
|
||||
if ($audit_status == 2)
|
||||
if ($audit_status == 2) {
|
||||
throwErrorMsg("{$code_module_name} 代码块已通过审核!");
|
||||
if ($audit_status == 3)
|
||||
}
|
||||
if ($audit_status == 3) {
|
||||
throwErrorMsg("{$code_module_name} 代码块已驳回审核!");
|
||||
}
|
||||
|
||||
$model->allowField(['code_module_audit'])->save($params);
|
||||
CustomerMessageAuditCodeModule::sendAuditMessage($value, $params['code_module_audit'], $params['ps']);
|
||||
|
||||
$model->allowField([
|
||||
'code_module_audit',
|
||||
])->save($params);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user