sendJobStatusSql.php
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace Model;
/**
 * 邮件发送任务状态
 * @author:dc
 * @time 2023/4/10 16:27
 * Class sendJobStatusSql
 * @package Model
 */
class sendJobStatusSql {
    /**
     * 表
     * @var string
     */
    public static $table = 'send_job_status';
    /**
     * 统计
     * @param int $job_id
     * @param string $to
     * @return string
     * @author:dc
     * @time 2023/4/11 16:13
     */
    public static function count(int $job_id, string $to=''):string {
        return "select count(*) from `".self::$table."` where `job_id` = {$job_id} ".($to ? "and `to_email` = '{$to}'" : '');
    }
    /**
     * @param int $job_id
     * @return string
     * @author:dc
     * @time 2023/4/17 17:25
     */
    public static function countSum(int $job_id){
        $sucees = "(select count(*) from `".self::$table."` where `job_id` = {$job_id} and `status` = 1) as s";
        $error = "(select count(*) from `".self::$table."` where `job_id` = {$job_id} and `status` = 0) as e";
        return "select count(*) as t,{$sucees},{$error} from `".self::$table."` where `job_id` = {$job_id} ";
    }
    /**
     * job任务详情页
     * @param $where
     * @param int $page
     * @param int $limit
     * @param bool $isExport
     * @return string
     */
    public static function detail($where, int $page = 1, int $limit = 20, bool $isExport = false)
    {
        if ($isExport) {
            return "select * from `" . static::$table . "` where " . $where . " order by id desc";
        }
        return "select * from `" . static::$table . "` where " . $where . " order by id desc limit {$limit} offset " . (($page - 1) * $limit);
    }
    /**
     * 详情页统计
     * @param string $where
     * @return string
     * @author:dc
     * @time 2023/4/11 16:13
     */
    public static function detailCount(string $where):string {
        return "select count(`id`) from `".static::$table."` where ".$where;
    }
    
}