Example #1
0
 /**
  * 导出短信
  * @return 
  */
 public function export()
 {
     $data = $this->get_data();
     $batch_number = $data['batch_number'] ? trim($data['batch_number']) : '';
     $format = $data['format'] ? trim($data['format']) : 'txt';
     $address = $data['address'] ? trim($data['address']) : '';
     $ids = $data['ids'] ? $data['ids'] : '';
     $all = $data['all'] ? (int) $data['all'] : 0;
     if (empty($batch_number)) {
         $this->send_response(400, NULL, '401204:备份批号为空');
     }
     if (!$all && empty($ids) && empty($address)) {
         $this->send_response(400, NULL, '401221:id,address不能都为空');
     }
     if (!in_array($format, array('xls', 'txt'))) {
         $this->send_response(400, NULL, '401222:导出格式不支持');
     }
     if ($ids) {
         $ids = explode(',', $ids);
     }
     if ($address) {
         $address = $this->_format_address($address);
     }
     $result = $this->model->export($this->user_id, $batch_number, $format, $ids, $address, $all);
     $this->send_response(200, array('data' => $result));
 }