Files
fdesk/app/process/Task.php
T

83 lines
3.2 KiB
PHP
Raw Normal View History

2025-07-25 13:55:30 +08:00
<?php
namespace app\process;
2025-11-03 18:16:51 +08:00
use app\common\model\FinPaymentApply;
use app\common\model\User;
2025-07-25 13:55:30 +08:00
use app\crm\model\Customer;
use support\Log;
use Workerman\Crontab\Crontab;
class Task
{
public function onWorkerStart()
{
2025-11-03 18:16:51 +08:00
// 每半小时执行一次,通知待跟进客户
2025-07-25 13:55:30 +08:00
new Crontab('0 */30 * * * *', function(){
echo date('Y-m-d H:i:s') . "\n";
Log::info('send follow start',[time()]);
$where = [
['follow_next', '<=', time() + 3600],
['follow_next', '>', time()],
['warn', '<', 1]
];
$customer = Customer::where($where)->get();
foreach ($customer as $item) {
2025-10-11 18:11:59 +08:00
$contacts = $item->contacts??$item['phone'];
$contacts = $contacts??$item['whatsApp'];
$contacts = $contacts??$item['email'];
$data = [
'sender_id' => 0, //发送人ID 0默认系统
'sender_type' => 'system', //发送者类型 user admin system
'title' => '客户跟进提醒 - ' . $contacts, //标题
'content' => $contacts . ' 到达预定跟进时间,请及时跟进', //内容
'scene' => 1, //场景 0系统公共 1系统通知
'recipient' => [$item->user_id], //接收人 空为全部
'push_method' => 0 //推送方式0系统推送1手动推送
2025-07-25 13:55:30 +08:00
];
2025-10-11 18:11:59 +08:00
\Webman\RedisQueue\Redis::send("notice",$data);
$item->warn = 1;
$item->save();
2025-07-25 13:55:30 +08:00
}
2025-11-03 18:16:51 +08:00
Log::info('send follow end',[time()]);
});
// 检查入账资料是否提交
new Crontab('* */70 * * * *', function () {
$G = date('G');
if ($G > 22 || $G < 8) {
return;
}
$where = [
['submit_files', '=', ''],
['warn', '<', 2],
['created_at', '>', time() - 60 * 60 * 48],
['created_at', '<', time() - 60 * 60 * 24],
];
$payment = FinPaymentApply::where($where)->orderBy('id', 'desc')->get();
foreach ($payment as $item) {
Log::info('fin_payment_apply submit_files ', [$item->toArray()]);
$notice = [
'code' => $item->apply_no,
'payment_entity' => $item->payment_entity ?? $item->remitter,
'content' => '认领收款单后请在24小时内提交入账资料',
'reply' => '',
];
$email = [];
$email[] = User::where('id', $item->claimed_by)->value('email');
$email[] = User::where('id', $item->doc_user_id)->value('email');
$email = array_unique($email);
\app\common\utils\email\MailSend::send($email, '【XYH】付款记录', replaceTpl($notice, 'payment_files'));
$item->warn = ++$item->warn;
$item->save();
}
2025-07-25 13:55:30 +08:00
});
}
}