代码学习总结

        return $this->wrapTransaction(function () use ($request) {
            $periods = $request->input('periods', []);
            $teacherId = $request->input('teacher_id', 0);
            $action = $request->input('action', 'camp-on');
            $role = $request->input('role', 'user');
            ScheduleModule::getDomainService()->bookSchedules(
                $teacherId,
                $periods,
                $action,
                $role
            );
            return '';
        }, 'bookSchedule');
    protected function wrapTransaction($callable, $funcKey)
    {
        try {
            DB::beginTransaction();
            $result = $callable();
            DB::commit();
            return $this->response($result);
        } catch (\Exception $ex) {
            DB::rollback();
            \Log::error($funcKey);
            $code = $ex->getCode();
            \Log::error($code . ' ' . $ex->getMessage() . ' ' . $ex->getTraceAsString());
            if (empty($code)) {
                $code = -1;
            }
            return $this->response(null, $code, $ex->getMessage());
        }
    }
        $schedules = $schedules->filter(function ($item) {
            // 如果某天零点时间大于time()时间,那么就选取某天的零点时间
            if (strtotime($item->dateFrom) > time()) {
                $time = strtotime($item->dateFrom); // 获取开始时间
            } else {
                // 否则就获取当天日期加现在的时间点的时间戳
                $time = strtotime(explode(' ', $item->dateFrom)[0] . ' ' . date('H:i:s'));
            }
            // 获取开始时间
            $timeLimit = self::filterStartTime($time);
            return $item->timeFrom >= $timeLimit;
        });
        //按日期分组
        $schedules = $schedules->mapToGroups(function ($item) {
            $key = explode(' ', $item->dateFrom)[0];
            return [$key =>
                [
                    'date' => $key,
                    'time_from' => $item->timeFrom,
                    'time_to' => $item->timeTo,
                    'is_free' => $item->isFree,
                ]
            ];
        })->toArray();
        $start = date('Y-m-d H:i:s', max(time(), strtotime($month)));
        $end = date('Y-m-t 23:59:59', strtotime($month)); // 当月最后一天的函数

 

转载于:https://www.cnblogs.com/cjjjj/p/10186346.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
网页制作代码+课程总结;旅游网站 CSS代码@charset "utf-8"; body { font-size: 12px; color: #666; text-align: center; margin: 0px; padding: 0px; } #container{ text-align:left; padding:0px; width:1400px; position:relative; margin-top:0px; margin-right:auto; margin-bottom:0px; margin-left:auto; } #top{ padding-top:15px; height:90px; } #logo{ margin:0px; padding:0px; float:left; width:365px; text-align:right; } .pic{ vertical-align:middle; padding-right:20px; } #ss{ float:left; width:835px; text-align:right; height:35px; padding-top:0px; padding-right:200px; padding-bottom:0px; padding-left:0px; margin:0px; } #daohang{ margin-top:5px; margin-right:0px; margin-bottom:0px; margin-left:195px; float:left; text-align:right; padding:0px; height:38px; width:840px; } #daohang ul{ margin:0px; padding:0px; list-style:none; } #daohang ul li{ text-align:center; float:left; width:90px; } #daohang a{ background-image:url(images/bj01.jpg); display:block; margin:0px; padding-top:10px; padding-right:0px; padding-bottom:13px; padding-left:0px; } #daohang a:link,#daohang a:visited{ color:#FFF; text-decoration:none; } #daohang a:hover{ color:#333; text-decoration:underline; } #banner{ background-image:url(images/pic.jpg); background-repeat:no-repeat; height:160px; text-align:center; padding-top:400px; padding-right:0px; padding-bottom:0px; padding-left:0px; margin:0px; } #banner img{ padding:0px 5px 0px 5px;} .daohang { font-size: 16px; color: #09F; background-color: #060; text-align: center; display: block; } #footer{ color: #000; background-image: url(images/bj03.jpg); background-repeat: repeat-x; text-align: center; padding: 30px 0px 29px 0px; font-size: 16px; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值