日报
This commit is contained in:
+54
-2
@@ -6,6 +6,7 @@ use app\controller\FeishuController;
|
||||
use app\model\Customer;
|
||||
use app\model\CustomerHis;
|
||||
use app\model\FeishuUser;
|
||||
use app\model\RequestTracks;
|
||||
use app\model\User;
|
||||
use support\Log;
|
||||
use Webman\App;
|
||||
@@ -65,7 +66,8 @@ class Task
|
||||
$item->warn = 1;
|
||||
$item->update();
|
||||
Log::info('send',['open_id'=>$item['open_id'],'url'=>$url]);
|
||||
FeishuController::send($feishuUser->sign, $feishuUser->open_id, '跟进提醒', '您有新的跟进提醒', $url);
|
||||
$content = FeishuController::postMsg( '跟进提醒', '您有新的跟进提醒', $url);
|
||||
FeishuController::send($feishuUser->sign, $feishuUser->open_id, $content, 'post');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +75,7 @@ class Task
|
||||
});
|
||||
|
||||
|
||||
// 每小时执行一次
|
||||
//回收站客户转向公海 每小时执行一次
|
||||
new Crontab('0 10 * * * *', function(){
|
||||
echo date('Y-m-d H:i:s') . "\n";
|
||||
Log::info('send high seas start',[time()]);
|
||||
@@ -95,6 +97,56 @@ class Task
|
||||
Log::info('send high seas end',[time()]);
|
||||
});
|
||||
|
||||
//总结日报, 每天执行一次
|
||||
new Crontab('0 30 17 * * *', function () {
|
||||
echo date('Y-m-d H:i:s') . "\n";
|
||||
Log::info('start daily', [time()]);
|
||||
|
||||
$where = [
|
||||
['created_at', '<=', time() - (3600 * 24)],
|
||||
];
|
||||
$requestTracks = RequestTracks::select('*, COUNT(*) as count')
|
||||
->where($where)
|
||||
->whereIn('path', ['customer/claim', 'customer/save', 'follow/save', 'customer/collect'])
|
||||
->groupBy('user_id','path')
|
||||
->orderBy('user_id', 'asc')
|
||||
->get();
|
||||
|
||||
$statistics = [];
|
||||
$users = [];
|
||||
$daily = '';
|
||||
foreach ($requestTracks as $item) {
|
||||
$statistics[$item->user_id][$item->path] = $item->count;
|
||||
$users[] = $item->user_id;
|
||||
}
|
||||
|
||||
foreach ($users as $userId) {
|
||||
$daily .= date('Y-m-d') . "\n";
|
||||
$daily .= '领取客户'.$statistics[$userId]['customer/claim'].'位\n';
|
||||
$daily .= '创建或修改客户'.$statistics[$userId]['customer/save'].'位\n';
|
||||
$daily .= '添加跟进'.$statistics[$userId]['follow/save'].'次\n';
|
||||
$daily .= '询盘跟单客户'.$statistics[$userId]['customer/collect'].'位\n';
|
||||
$daily .= '请及时查看,30分钟后将向主管发送';
|
||||
|
||||
$feishuUser = FeishuUser::where(['user_id' => $userId])->first();
|
||||
if ($feishuUser) {
|
||||
// 获取凭证
|
||||
$certificate = config('feishu.'.$feishuUser->sign);
|
||||
// 使用parse_url解析URL
|
||||
$parsedUrl = parse_url($certificate['rUrl']);
|
||||
// 获取域名和端口
|
||||
$host = $parsedUrl['host'];
|
||||
$port = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : '';
|
||||
$url = 'http://'. $host .$port. '/pages/customer/detile?id=';
|
||||
$content = FeishuController::postMsg( '跟进提醒', $daily, $url);
|
||||
FeishuController::send($feishuUser->sign, $feishuUser->open_id, $content, 'post');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Log::info('send high seas end', [time()]);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user