示例#1
0
 /**
  * 
  * 处理多媒体文件
  * @return array
  */
 public function deal_media_upload($thumb_config)
 {
     foreach ($_FILES as $file) {
         $media = array();
         $media['path'] = 'img/' . date('Ymd') . '/' . substr(create_uniqid(), 0, 6) . '/';
         $path = $this->config->item('upload_path') . $media['path'];
         if ($file["error"] == 0) {
             $media['name'] = $file['name'];
             $path = make_dir($path);
             $to_file = $path . $file['name'];
             $thumb_config['source_image'] = $to_file;
             if (move_uploaded_file($file["tmp_name"], $to_file) !== false) {
                 $media['id'] = $this->media_model->add_media($media);
             } else {
                 $media = array();
             }
         }
     }
     return $media;
 }
示例#2
0
 /**
  * 生产礼卡
  */
 public function create_giftcard($d)
 {
     $data = array();
     $num = $d['ecode'] - $d['scode'];
     $time = date('Y-m-d H:i:s');
     $tmp_arr = array();
     for ($i = 0; $i <= $num; $i++) {
         $tmp_arr[] = $d['scode'] + $i;
     }
     $tmp_str = implode(',', $tmp_arr);
     $sql = "SELECT COUNT(*) AS `cnt` FROM `gift_management`.`gift_card` WHERE `num_code` IN({$tmp_str})";
     $row = $this->db->query($sql)->row();
     if ($row->cnt > 0) {
         return -1;
     }
     for ($i = 0; $i <= $num; $i++) {
         $num_code = $d['scode'] + $i;
         $password = substr(create_uniqid(), 2, 6);
         $data[] = array('num_code' => $num_code, 'password' => $password, 'ctime' => $time);
     }
     $rt = FALSE;
     if ($data) {
         $this->db->insert_batch($this->_gift_card_tb, $data);
         $rt = $this->db->affected_rows();
     }
     return $rt;
 }