Пример #1
0
 public static function delApply($id)
 {
     try {
         return Model_WeiLiao_FlashMan::data_access()->filter('id', $id)->delete();
     } catch (Exception $e) {
         return false;
     }
 }
Пример #2
0
 /**
  * 处理申请
  */
 private function doApply($hasApplys)
 {
     if (empty($hasApplys)) {
         $dates = Model_WeiLiao_FlashMan::getDates();
         $onDay = $dates['nextStart'];
         $amStartTime = strtotime($onDay . ' 00:00:00');
         $amEndTime = strtotime($onDay . ' 00:59:59');
         $pmStartTime = $amStartTime + 12 * 3600;
         $pmEndTime = $amEndTime + 12 * 3600;
     } else {
         $hasNum = count($hasApplys);
         if ($hasNum % 2 != 0) {
             // 脏数据 怎么处理
         }
         $hasEnd = end($hasApplys);
         $isSecondDay = false;
         // 跨天
         if (date('Ymd', $hasEnd['endTime']) != date('Ymd', $hasEnd['endTime'] + 10)) {
             $isSecondDay = true;
         }
         if (!$isSecondDay) {
             $onDay = $hasEnd['onDay'];
             $amStartTime = $hasEnd['startTime'] + 3600 - 12 * 3600;
             $amEndTime = $hasEnd['endTime'] + 3600 - 12 * 3600;
             $pmStartTime = $hasEnd['startTime'] + 3600;
             $pmEndTime = $hasEnd['endTime'] + 3600;
         } else {
             $onDay = date('Ymd', $hasEnd['endTime'] + 3600);
             $amStartTime = strtotime($onDay . ' 00:00:00');
             $amEndTime = strtotime($onDay . ' 00:59:59');
             $pmStartTime = $amStartTime + 12 * 3600;
             $pmEndTime = $amEndTime + 12 * 3600;
         }
     }
     $insertParams['am'] = array('brokerId' => $this->out['brokerId'], 'cityId' => $this->out['cityId'], 'onDay' => $onDay, 'startTime' => $amStartTime, 'endTime' => $amEndTime);
     $insertParams['pm'] = array('brokerId' => $this->out['brokerId'], 'cityId' => $this->out['cityId'], 'onDay' => $onDay, 'startTime' => $pmStartTime, 'endTime' => $pmEndTime);
     $temp = date('H:i', $amStartTime) . '~' . date('H:i', $amEndTime) . ',' . date('H:i', $pmStartTime) . '~' . date('H:i', $pmEndTime);
     $this->out['tip'] = '展示时间 ' . date('m', strtotime($onDay)) . '月' . date('d', strtotime($onDay)) . '日:' . $temp;
     $this->out['insertError'] = false;
     $ids = array();
     foreach ($insertParams as $key => $params) {
         $ids[$key] = Model_WeiLiao_FlashMan::addApply($params);
         if (!$ids[$key]) {
             $this->out['insertError'] = true;
             if ($key == 'pm') {
                 // 删除已插入的那条
                 Model_WeiLiao_FlashMan::delApply($ids['am']);
             }
             break;
         }
     }
 }