data_center/app/common/enum/notice/NoticeEnum.php

296 lines
8.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\enum\notice;
/**
* 通知枚举
* Class NoticeEnum
* @package app\common\enum
*/
class NoticeEnum
{
/**
* 通知类型
*/
const SYSTEM = 1;
const SMS = 2;
const OA = 3;
const MNP = 4;
/**
* 短信验证码场景
*/
const LOGIN_CAPTCHA = 101;
const BIND_MOBILE_CAPTCHA = 102;
const CHANGE_MOBILE_CAPTCHA = 103;
const FIND_LOGIN_PASSWORD_CAPTCHA = 104;
const REGISTER_CAPTCHA = 105;
const WQ = 106;
const FCHT = 107;
const WQTZ = 108;
const FACE_CREATE = 109;
/**
* 验证码场景
*/
const SMS_SCENE = [
self::LOGIN_CAPTCHA,
self::BIND_MOBILE_CAPTCHA,
self::CHANGE_MOBILE_CAPTCHA,
self::FIND_LOGIN_PASSWORD_CAPTCHA,
self::REGISTER_CAPTCHA,
];
//通知类型
const BUSINESS_NOTIFICATION = 1;//业务通知
const VERIFICATION_CODE = 2;//验证码
/**
* @notes 通知类型
* @param bool $value
* @return string|string[]
* @author ljj
* @date 2022/2/17 2:49 下午
*/
public static function getTypeDesc($value = true)
{
$data = [
self::BUSINESS_NOTIFICATION => '业务通知',
self::VERIFICATION_CODE => '验证码'
];
if ($value === true) {
return $data;
}
return $data[$value];
}
/**
* @notes 获取场景描述
* @param $sceneId
* @param false $flag
* @return string|string[]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getSceneDesc($sceneId, $flag = false)
{
$desc = [
self::LOGIN_CAPTCHA => '登录验证码',
self::BIND_MOBILE_CAPTCHA => '绑定手机验证码',
self::CHANGE_MOBILE_CAPTCHA => '变更手机验证码',
self::FIND_LOGIN_PASSWORD_CAPTCHA => '找回登录密码验证码',
self::REGISTER_CAPTCHA => '注册验证码',
self::WQ => '网签短信',
self::FCHT => '废除合同',
self::WQTZ => '网签通知',
self::FACE_CREATE => '人脸识别上传通知',
];
if ($flag) {
return $desc;
}
return $desc[$sceneId] ?? '';
}
/**
* @notes 更具标记获取场景
* @param $tag
* @return int|string
* @author 段誉
* @date 2022/9/15 15:08
*/
public static function getSceneByTag($tag)
{
$scene = [
// 手机验证码登录
'YZMDL' => self::LOGIN_CAPTCHA,
// 绑定手机号验证码
'BDSJHM' => self::BIND_MOBILE_CAPTCHA,
// 变更手机号验证码
'BGSJHM' => self::CHANGE_MOBILE_CAPTCHA,
// 找回登录密码
'ZHDLMM' => self::FIND_LOGIN_PASSWORD_CAPTCHA,
//注册
'YZMZC' => self::REGISTER_CAPTCHA,
//网签
'WQ'=>self::WQ,
//废除合同
'FCHT'=>self::FCHT,
//网签通知
'WQTZ'=>self::WQTZ,
//人脸识别
'FACE_CREATE'=>self::FACE_CREATE,
];
return $scene[$tag] ?? '';
}
/**
* @notes 获取场景变量
* @param $sceneId
* @param false $flag
* @return array|string[]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getVars($sceneId, $flag = false)
{
$desc = [
self::LOGIN_CAPTCHA => '验证码:code',
self::BIND_MOBILE_CAPTCHA => '验证码:code',
self::CHANGE_MOBILE_CAPTCHA => '验证码:code',
self::FIND_LOGIN_PASSWORD_CAPTCHA => '验证码:code',
self::REGISTER_CAPTCHA => '验证码:code',
];
if ($flag) {
return $desc;
}
return isset($desc[$sceneId]) ? ['可选变量 ' . $desc[$sceneId]] : [];
}
/**
* @notes 获取系统通知示例
* @param $sceneId
* @param false $flag
* @return array|string[]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getSystemExample($sceneId, $flag = false)
{
$desc = [];
if ($flag) {
return $desc;
}
return isset($desc[$sceneId]) ? [$desc[$sceneId]] : [];
}
/**
* @notes 获取短信通知示例
* @param $sceneId
* @param false $flag
* @return array|string[]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getSmsExample($sceneId, $flag = false)
{
$desc = [
self::LOGIN_CAPTCHA => '您正在登录,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
self::BIND_MOBILE_CAPTCHA => '您正在绑定手机号,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
self::CHANGE_MOBILE_CAPTCHA => '您正在变更手机号,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
self::FIND_LOGIN_PASSWORD_CAPTCHA => '您正在找回登录密码,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
self::REGISTER_CAPTCHA => '您正在注册账号,验证码${code}切勿将验证码泄露于他人本条验证码有效期5分钟。',
];
if ($flag) {
return $desc;
}
return isset($desc[$sceneId]) ? ['示例:' . $desc[$sceneId]] : [];
}
/**
* @notes 获取公众号模板消息示例
* @param $sceneId
* @param false $flag
* @return array|string[]|\string[][]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getOaExample($sceneId, $flag = false)
{
$desc = [];
if ($flag) {
return $desc;
}
return $desc[$sceneId] ?? [];
}
/**
* @notes 获取小程序订阅消息示例
* @param $sceneId
* @param false $flag
* @return array|mixed
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getMnpExample($sceneId, $flag = false)
{
$desc = [];
if ($flag) {
return $desc;
}
return $desc[$sceneId] ?? [];
}
/**
* @notes 提示
* @param $type
* @param $sceneId
* @return array|string|string[]|\string[][]
* @author 段誉
* @date 2022/3/29 11:33
*/
public static function getOperationTips($type, $sceneId)
{
// 场景变量
$vars = self::getVars($sceneId);
// 其他提示
$other = [];
// 示例
switch ($type) {
case self::SYSTEM:
$example = self::getSystemExample($sceneId);
break;
case self::SMS:
$other[] = '生效条件1、管理后台完成短信设置。 2、第三方短信平台申请模板 3、若是腾讯云模板变量名须换成变量名出现顺序对应的数字(例:您好{nickname},您的订单{order_sn}已发货! 须改为 您好{1},您的订单{2}已发货!)';
$example = self::getSmsExample($sceneId);
break;
case self::OA:
$other[] = '配置路径:公众号后台 > 广告与服务 > 模板消息';
$other[] = '推荐行业主营行业IT科技/互联网|电子商务 副营行业:消费品/消费品';
$example = self::getOaExample($sceneId);
break;
case self::MNP:
$other[] = '配置路径:小程序后台 > 功能 > 订阅消息';
$example = self::getMnpExample($sceneId);
break;
}
$tips = array_merge($vars, $example, $other);
return $tips;
}
}