Merge branch 'feature/mzl_dev'
This commit is contained in:
+115
-4
@@ -2,7 +2,9 @@
|
||||
/**
|
||||
* Here is your custom functions.
|
||||
*/
|
||||
|
||||
|
||||
use Webman\RedisQueue\Redis as RedisQueueRedis;
|
||||
|
||||
/**
|
||||
* 标准化账号参数
|
||||
*
|
||||
@@ -70,17 +72,126 @@ if (!function_exists('getConfig')) {
|
||||
* 询单号生成
|
||||
*/
|
||||
if (!function_exists('orderNum')) {
|
||||
function orderNum() {
|
||||
function orderNum()
|
||||
{
|
||||
return "SN".date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 调试用
|
||||
* 调试用(console)
|
||||
*/
|
||||
if (!function_exists('dpr')) {
|
||||
function dpr(\Throwable $e)
|
||||
{
|
||||
var_dump("=== === 报错打印 === ===", "文件:".$e->getFile(), "行数:".$e->getLine(), "详情:".$e->getMessage(), "=== === 报错打印 === ===");
|
||||
$contents = "=== === 报错打印 === ===\n";
|
||||
$contents .= "文件:".$e->getFile()."\n";
|
||||
$contents .= "行数:".$e->getLine()."\n";
|
||||
$contents .= "详情:".$e->getMessage()."\n";
|
||||
$contents .= "=== === 报错打印 === ===\n";
|
||||
var_dump($contents);
|
||||
return $contents;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调试用(file)
|
||||
*/
|
||||
if (!function_exists('flg')) {
|
||||
function flg($eventData = '', $isFs = true, $fileName = 'flg', $fileCatalog = 'flg')
|
||||
{
|
||||
if ($eventData == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_array($eventData) || is_object($eventData)) {
|
||||
$eventData = json_encode($eventData);
|
||||
}
|
||||
|
||||
$fileCatalog = substr(__FILE__, 0, strpos(__FILE__, 'app/')) . "runtime/" . $fileCatalog;
|
||||
if (!is_dir($fileCatalog)) {
|
||||
mkdir($fileCatalog, 0777, true);
|
||||
exec('chown -R nginx:nginx ' . $fileCatalog);
|
||||
}
|
||||
|
||||
$fileName = $fileName . '-' . date('Ymd') . '.log';
|
||||
|
||||
if ($isFs) {
|
||||
$data = [
|
||||
'content' => $eventData,
|
||||
'time' => date('Y-m-d H:i:s', time())
|
||||
];
|
||||
RedisQueueRedis::send("server", $data);
|
||||
}
|
||||
|
||||
return file_put_contents($fileCatalog . "/" . $fileName, date("Y-m-d H:i:s", time()) . "::" . $eventData . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* 发送飞书文本消息
|
||||
*/
|
||||
if (!function_exists('sendFeishuTextMessage')) {
|
||||
function sendFeishuTextMessage($webhookUrl, $message) {
|
||||
$data = [
|
||||
'msg_type' => 'text',
|
||||
'content' => [
|
||||
'text' => $message
|
||||
]
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $webhookUrl);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换模板
|
||||
*/
|
||||
if (!function_exists('replaceTpl')) {
|
||||
function replaceTpl(array $data = [], string $templatePath = 'common/utils/scaffold/templates/Email.stub')
|
||||
{
|
||||
if (!$data || !$templatePath) return '';
|
||||
$templatePath = app_path($templatePath);
|
||||
$content = file_get_contents($templatePath);
|
||||
foreach ($data as $key => $value) {
|
||||
$content = str_replace('{{'.$key.'}}', $value, $content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换模板
|
||||
*/
|
||||
if (!function_exists('InquiryFormat')) {
|
||||
function InquiryFormat(array $data = [])
|
||||
{
|
||||
if (!$data) return '';
|
||||
$content = '';
|
||||
// foreach ($data as $key => $value) {
|
||||
// $content .= $key . ':' . $value . "\r\n";
|
||||
// }
|
||||
$content .= '编号:'.$data['order_no'] . "\r\n";
|
||||
$content .= '询单质量:'.$data['quality'] . "\r\n";
|
||||
$content .= '渠道:'.$data['channel'] . "\r\n";
|
||||
$content .= '邮箱:'.$data['email'] . "\r\n";
|
||||
$content .= '电话:'.$data['tel'] . "\r\n";
|
||||
$content .= 'WhatsApp:'.$data['whatsapp'] . "\r\n";
|
||||
$content .= '国家:'.$data['country'] . "\r\n";
|
||||
$content .= '联系人:'.$data['contacts'] . "\r\n";
|
||||
$content .= '录单人:'.$data['enter_user_id'] . "\r\n";
|
||||
$content .= '录单时间:'.$data['r_time'] . "\r\n";
|
||||
$content .= '内容:'.$data['content'];
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user