public function putFlea($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $mobile = Input::get('mobile', '');
     $prodName = Input::get('prod_name', '');
     $prodDesc = Input::get('content', '');
     $prodBrief = Input::get('prod_brief', '');
     $price = Input::get('price', '');
     $publish = Input::get('publish', 1);
     $product_cate = Input::get('cate', 7);
     $active_at = Input::get('active_at');
     $open_file = Input::get('open_file', 0);
     if (empty($active_at)) {
         $active_at = Tools::getNow();
     }
     $img_token = Input::get('img_token', '');
     $prodDesc = urldecode($prodDesc);
     $modified_img = Input::get('modified_img', '');
     $modified_img_index = Input::get('modified_img_index', '');
     if ($modified_img) {
         $modified_img = explode(',', $modified_img);
     }
     try {
         $user = User::chkUserByToken($token, $u_id);
         $product = Product::find($id);
         if (empty($product) || $product->u_id != $u_id) {
             throw new Exception("没有找到请求的产品", 1);
         }
         $product->p_title = $prodName;
         $product->p_desc = $prodDesc;
         $product->sort = 1;
         $product->p_cate = $product_cate;
         $product->p_brief = $prodBrief;
         $product->p_status = $publish == 1 ? 1 : 2;
         $product->p_price_origin = $price;
         $product->p_price = $price;
         $product->active_at = $active_at;
         $product->p_mobile = $mobile;
         $product->open_file = $open_file;
         $old_imgs = Img::toArray($product->p_imgs);
         if (empty($old_imgs['cover_img'])) {
             $cover_img = '';
         } else {
             $cover_img = $old_imgs['cover_img'];
             unset($old_imgs['cover_img']);
         }
         if (is_numeric($modified_img_index)) {
             $imgObj = new Img('product', $img_token);
             $new_paths = [];
             if (!empty($modified_img)) {
                 foreach ($modified_img as $old_path) {
                     $new_path = $imgObj->reindexImg($id, $modified_img_index, $old_path);
                     $new_paths[] = $new_path;
                     $modified_img_index++;
                 }
                 foreach ($old_imgs as $obj) {
                     if (!in_array($obj, $new_paths)) {
                         $imgObj->remove($id, $obj);
                     }
                 }
                 $new_paths = Img::attachHost($new_paths);
                 $product->p_imgs = implode(',', $new_paths);
             }
         }
         if ($cover_img) {
             if ($product->p_imgs) {
                 $product->p_imgs .= ',' . $cover_img;
             } else {
                 $product->p_imgs = $cover_img;
             }
         }
         if ($img_token) {
             $imgObj = new Img('product', $img_token);
             $imgs = $imgObj->getSavedImg($id, $product->p_imgs, true);
             if (!empty($modified_img)) {
                 foreach ($modified_img as $del) {
                     if (array_key_exists($del, $imgs)) {
                         unset($imgs[$del]);
                     }
                 }
             }
             $product->p_imgs = implode(',', $imgs);
         }
         $product->save();
         $re = Tools::reTrue('更新产品成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '更新产品失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function putUserBase()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $name = Input::get('name');
     $nickname = Input::get('nickname', '');
     $gender = Input::get('gender', '');
     $bio = Input::get('biograph', '');
     $id_number = Input::get('id_number', '');
     $id_school = Input::get('id_school', 0);
     $entry_year = Input::get('entry_year', '');
     $major = Input::get('major', '');
     $stu_num = Input::get('stu_num', '');
     $mobile = Input::get('mobile', '');
     $age = Input::get('age', '');
     $birth = Input::get('birth', '');
     $img_token = Input::get('img_token', '');
     $modified_img = Input::get('modified_img', '');
     $modified_img_index = Input::get('modified_img_index', '');
     if ($modified_img) {
         $modified_img = explode(',', $modified_img);
     }
     try {
         $user = User::chkUserByToken($token, $u_id);
         $profile = TmpUserProfileBase::find($u_id);
         if (empty($profile)) {
             $profile = new TmpUserProfileBase();
             $profile->u_id = $u_id;
         }
         $user->u_name = $name;
         $user->u_nickname = $nickname;
         $user->u_sex = $gender;
         $user->u_biograph = $bio;
         $user->u_age = $age;
         $user->u_birthday = $birth;
         if ($id_school) {
             $profile->s_id = $id_school;
             $user->u_school_id = $id_school;
         }
         if ($mobile) {
             $user->u_mobile = $mobile;
         }
         $profile->u_entry_year = $entry_year;
         $profile->u_major = $major;
         $profile->u_id_number = $id_number;
         $profile->u_student_number = $stu_num;
         if (is_numeric($modified_img_index)) {
             $imgObj = new Img('user', $img_token);
             $new_paths = [];
             if (!empty($modified_img)) {
                 foreach ($modified_img as $old_path) {
                     $new_path = $imgObj->reindexImg($u_id, $modified_img_index, $old_path);
                     $new_paths[] = $new_path;
                     $modified_img_index++;
                 }
                 $to_delete = Img::toArray($user->u_home_img);
                 foreach ($to_delete as $obj) {
                     if (!in_array($obj, $new_paths)) {
                         $imgObj->remove($u_id, $obj);
                     }
                 }
                 $new_paths = Img::attachHost($new_paths);
                 $user->u_home_img = implode(',', $new_paths);
             }
         }
         if ($img_token) {
             $imgObj = new Img('user', $img_token);
             $imgs = $imgObj->getSavedImg($u_id, implode(',', [$profile->u_id_imgs, $profile->u_student_imgs, $user->u_home_img, $user->u_head_img]), true);
             $stu_imgs = Img::filterKey('student_img_', $imgs);
             $id_imgs = Img::filterKey('identity_img_', $imgs);
             $home_imgs = Img::filterKey('home_img_', $imgs);
             $head_img = Img::filterKey('head_img', $imgs);
             if (!empty($modified_img)) {
                 foreach ($modified_img as $del) {
                     if (array_key_exists($del, $home_imgs)) {
                         unset($home_imgs[$del]);
                     }
                 }
             }
             $profile->u_student_imgs = implode(',', $stu_imgs);
             $profile->u_id_imgs = implode(',', $id_imgs);
             $user->u_home_img = implode(',', $home_imgs);
             $user->u_head_img = implode(',', $head_img);
         }
         $this->saveClubInfo($user);
         $profile->save();
         $user->save();
         $re = Tools::reTrue('提交信息成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '提交信息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }