预约上门服务时间

获取在规定时间内配送的时间段


<?php
/**
 * 预约上门服务时间
 * User: john
 * Date: 2015/7/10
 * Time: 10:51
 */
class service_time extends Controller
{

    function __construct($app)
    {
        parent::__construct($app);
    }

    function dispatch()
    {
        $config = array(
            '09:00 - 12:00',
            '12:00 - 15:00',
            '15:00 - 18:00',
            '18:00 - 21:00',
        );
        $day = 0;
        $nowtime = date("H");
        if($nowtime >= 18)
            $day = 1;

        $redata = array();
        for($i=0;$i<=6;$i++){
            //判断今天哪些时段不能被用户选择
            $tmpConfig = $config;
            if( $i==0 and $day == 0 ){
                if( $nowtime >= 9 and $nowtime <12 ){
                    unset($tmpConfig[0]);
                    $items = array_values($tmpConfig);
                }elseif( $nowtime >= 12 and $nowtime <15 ){
                    unset($tmpConfig[0]);
                    unset($tmpConfig[1]);
                    $items = array_values($tmpConfig);
                }elseif( $nowtime >= 15 and $nowtime <18 ){
                    unset($tmpConfig[0]);
                    unset($tmpConfig[1]);
                    unset($tmpConfig[2]);
                    $items = array_values($tmpConfig);
                }
            }else{
                $day += $i;
                $items = $config;
            }
            $redata[] = array(
                'time'=>date('m月d日',strtotime('+'. ($i+$day) .' day')),
                'items'=> $items
            );
        }
        return self::_return_json(2000,'ok',array('data'=>$redata));
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值