ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

手机号和身份证正则表达式,生成订单号 24位,selectRaw统计日期

2021-11-25 10:30:00  阅读:235  来源: 互联网

标签:24 00 订单号 strtotime start selectRaw time date


手机号和身份证正则表达式

if(!empty($post['phone'])){

                    if (!preg_match("/^1[3456789]\d{9}$/", $post['phone'])) {

                        return __error('手机号码格式不正确');

                    }

                }

                if(!empty($post['identity'])) {

                    if (!preg_match("/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/", $post['identity'])) {

                        return __error('身份证格式不正确');

                    }

                }

//生成订单号 24位

function generate($prefix = 'C')

{

    return $prefix . date('YmdHis', time()) . substr(microtime(), 2, 6) . sprintf('%03d', rand(0, 999));

}

     /**

     * //获取指定日期内每一天的日期

     * @param Date $startdate 开始日期

     * @param Date $enddate 结束日期

     * @return Array

     */

    function getDateRange($startdate, $enddate)

    {

        $stimestamp = strtotime($startdate);

        $etimestamp = strtotime($enddate);

        // 计算日期段内有多少天

        $days = (int) (($etimestamp - $stimestamp) / 86400) + 1;

        // 保存每天日期

        $date = [];

        for ($i = 0; $i < $days; $i++) {

            $date[] = date('Y-m-d', $stimestamp + (86400 * $i));

        }

        // unset($date[$days-1]);

        return $date;

    }

统计日期

$nums = BathArchiveDetail::from('bath_archive_detail as h')

                ->leftJoin('bath_archive as a', 'h.archive_id', '=', 'a.id')

                ->leftJoin('bath_device as d', 'd.id', '=', 'h.device_id')

                ->where('h.is_deleted', 0)

                ->where('a.is_deleted', 0)

                ->whereIn('a.site_id', $sids)

                //日洗浴次数

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00')) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ',h.id,null)) as daynums')

                //日洗浴次数-异常

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00')) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ' && h.bath_status = 0,h.id,null)) as daynonums')

                //日洗浴次数-正常

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00')) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ' && h.bath_status = 1,h.id,null)) as dayoknums')

                //周洗浴次数

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00', strtotime('-7 days'))) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ',h.id,null)) as weeknums')

                //周洗浴次数-异常

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00', strtotime('-7 days'))) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ' && h.bath_status = 0,h.id,null)) as weeknonums')

                //周洗浴次数-正常

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00', strtotime('-7 days'))) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ' && h.bath_status = 1,h.id,null)) as weekoknums')

                //月洗浴次数

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00', strtotime('-30 days'))) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ',h.id,null)) as monthnums')

                //月洗浴次数-异常

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00', strtotime('-30 days'))) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ' && h.bath_status = 0,h.id,null)) as monthnonums')

                //月洗浴次数-正常

                ->selectRaw('COUNT(IF(h.start_time >= ' . strtotime(date('Y-m-d 00:00:00', strtotime('-30 days'))) . ' && h.start_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ' && h.bath_status = 1,h.id,null)) as monthoknums')

                ->first();

标签:24,00,订单号,strtotime,start,selectRaw,time,date
来源: https://blog.csdn.net/weixin_51899618/article/details/121531797

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有