public static function checkProfile($u_id) { $contact = TmpUserProfileBase::find($u_id); if (empty($contact)) { return 0; } if ($contact->u_status == 1) { return 1; } else { return 0; } }
public function postContact() { $token = Input::get('token', ''); $u_id = Input::get('u_id', ''); // shcool id $school = Input::get('school'); // shcool entry year $entryYear = Input::get('entry_year'); // profession area $profession = Input::get('profession'); // graduate degree $degree = Input::get('degree'); // studen card number $studentNum = Input::get('stu_num'); // teacher name $thName = Input::get('th_name'); // teacher phone $thPhone = Input::get('th_phone'); // friend name 1 $frName1 = Input::get('fr_name_1'); // friend phone 1 $frPhone1 = Input::get('fr_phone_1'); // friend name 2 $frName2 = Input::get('fr_name_2'); // friend phone 2 $frPhone2 = Input::get('fr_phone_2'); $imgToken = Input::get('img_token', ''); try { $user = User::chkUserByToken($token, $u_id); $user_contact_people = TmpUserProfileBase::find($u_id); if (!isset($user_contact_people->u_id)) { $user_contact_people = new TmpUserProfileBase(); } if ($user_contact_people->u_status == 1) { throw new Exception("您的审核已经通过", 3002); } $user_contact_people->u_id = $u_id; $user_contact_people->u_teacher_name = $thName; $user_contact_people->u_teacher_telephone = $thPhone; $user_contact_people->u_frend_name1 = $frName1; $user_contact_people->u_frend_telephone1 = $frPhone1; $user_contact_people->u_frend_name2 = $frName2; $user_contact_people->u_frend_telephone2 = $frPhone2; $user_contact_people->u_student_number = $studentNum; $user_contact_people->u_school_id = $school; $user_contact_people->u_prof = $profession; $user_contact_people->u_degree = $degree; $user_contact_people->u_entry_year = $entryYear; $user_contact_people->register(); if ($imgToken) { $imgObj = new Img('user', $imgToken); $imgs = $imgObj->getSavedImg($u_id, '', true); $student_img = []; foreach ($imgs as $k => $img) { if ($k == 'student_img_front' || $k == 'student_img_back') { $student_img[] = $img; } } $user_contact_people->u_student_img = implode(',', $student_img); $user_contact_people->save(); } $re = Tools::reTrue('提交学校信息成功'); } catch (Exception $e) { TmpUserProfileBase::clearByUser($u_id); $re = Tools::reFalse($e->getCode(), '提交学校信息失败:' . $e->getMessage()); } return Response::json($re); }
public function getCrowdFunding($id) { $u_id = Input::get('u_id', 0); try { $crowdfunding = CrowdFunding::find($id); $crowdfunding->load(['eventItem', 'user', 'user.school', 'replies' => function ($q) { $q->with(['user'])->take(3)->orderBy('created_at', 'DESC'); }, 'praises' => function ($q) { $q->where('praises.u_id', '=', $this->u_id); }, 'favorites' => function ($q) { $q->where('favorites.u_id', '=', $this->u_id); }]); $data = $crowdfunding->showDetail(); $mobile = ''; $apartment_no = ''; if ($crowdfunding->c_open_file) { $base = TmpUserProfileBase::find($crowdfunding->user->u_id); if (!empty($base)) { $apartment_no = $base->u_apartment_no; } } $data['apartment_no'] = $apartment_no; $data['participates_count'] = $crowdfunding->getParticipates(0, true); $data['is_praised'] = 0; $data['is_favorited'] = 0; if (count($crowdfunding->praises) > 0) { $data['is_praised'] = 1; } if (count($crowdfunding->favorites) > 0) { $data['is_favorited'] = 1; } $re = Tools::reTrue('获取众筹成功', $data); } catch (Exception $e) { $re = Tools::reFalse($e->getCode(), '获取众筹失败:' . $e->getMessage()); } return Response::json($re); }
public function putCrowdFunding($id) { $token = Input::get('token', ''); $u_id = Input::get('u_id', 0); $title = Input::get('title', ''); $cate = Input::get('cate', 1); $amount = Input::get('amount', 0); $time = Input::get('time', 0); $yield_time = Input::get('yield_time', 0); $shipping = Input::get('shipping', 0); $shipping_fee = Input::get('shipping_fee', 0); $brief = Input::get('brief', ''); $yield_desc = Input::get('yield_desc', ''); $content = Input::get('content', ''); $open_file = Input::get('open_file', 0); $local_only = Input::get('local_only', 0); $is_schedule = Input::get('is_schedule', 0); $active_at = Input::get('active_at'); if (empty($active_at)) { $active_at = Tools::getNow(); } $mobile = Input::get('mobile', ''); $price = Input::get('price', 0); $quantity = Input::get('quantity', 0); $is_limit = Input::get('is_limit', 0); $img_token = Input::get('img_token', ''); $img_token_2 = Input::get('img_token_2', ''); $apartment_no = Input::get('apartment_no', ''); $content = urldecode($content); $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); if ($cate == 8 && $user->u_type != 2) { throw new Exception("错误的发布类型", 2001); } $crowd_funding = CrowdFunding::find($id); if (empty($crowd_funding) || $crowd_funding->u_id != $u_id) { throw new Exception("无法获取到请求的众筹", 2001); } $funding_product = CrowdFundingProduct::where('cf_id', '=', $crowd_funding->cf_id)->first(); if (empty($funding_product)) { throw new Exception("库存信息丢失", 2001); } if (Cart::getCartTypeCount(Cart::$TYPE_CROWD_FUNDING, $funding_product->p_id)) { throw new Exception("已有人购买", 2001); } if ($apartment_no) { $tmp_base = TmpUserProfileBase::find($user->u_id); $tmp_base->u_apartment_no = $apartment_no; $tmp_base->save(); } $event = EventItem::find($crowd_funding->e_id); // put funding $event->e_title = $title; $event->e_brief = $brief; $event->e_start_at = $active_at; $date_obj = new DateTime($active_at); $date_obj->modify('+' . $time . ' days'); $event->e_end_at = $date_obj->format('Y-m-d H:i:s'); $crowd_funding->c_local_only = $local_only; $crowd_funding->c_yield_desc = $yield_desc; $crowd_funding->c_content = $content; $crowd_funding->c_yield_time = $yield_time; $crowd_funding->u_mobile = $mobile; $crowd_funding->c_is_schedule = $is_schedule; $crowd_funding->c_time = $time; $crowd_funding->c_shipping = $shipping; $crowd_funding->c_shipping_fee = $shipping_fee; $crowd_funding->c_target_amount = $amount; $crowd_funding->c_cate = $cate; $crowd_funding->c_open_file = $open_file; if ($amount <= 2000) { $crowd_funding->c_status = 4; } else { $crowd_funding->c_status = 1; } // if the user is an official user, set funding type to offical if ($user->u_type == 2) { $crowd_funding->c_cate = 8; } if (is_numeric($modified_img_index)) { $imgObj = new Img('crowd_funding', $img_token_2); $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++; } $new_paths = Img::attachHost($new_paths); $crowd_funding->c_imgs = implode(',', $new_paths); } } if ($img_token_2) { $imgObj = new Img('crowd_funding', $img_token_2); $imgs = $imgObj->getSavedImg($crowd_funding->cf_id, $crowd_funding->c_imgs, true); if (!empty($modified_img)) { foreach ($modified_img as $del) { if (array_key_exists($del, $imgs)) { unset($imgs[$del]); } } } $crowd_funding->c_imgs = implode(',', $imgs); } if ($img_token) { $img_obj = new Img('event', $img_token); $cover_img = $img_obj->replace($event->e_id, 'cover_img'); $event->cover_img = $cover_img; } $crowd_funding->save(); $event->save(); // put funding product $funding_product = CrowdFundingProduct::where('cf_id', '=', $crowd_funding->cf_id)->first(); if (empty($funding_product)) { throw new Exception("库存信息丢失", 2001); } $funding_product->p_price = $price; $funding_product->p_target_quantity = $quantity; if ($is_limit) { $funding_product->p_max_quantity = $quantity; } else { $funding_product->p_max_quantity = 0; } $funding_product->save(); $re = Tools::reTrue('编辑众筹成功'); } catch (Exception $e) { $re = Tools::reFalse($e->getCode(), '编辑众筹失败:' . $e->getMessage()); } return Response::json($re); }
public function censorUserProfileStudent($id) { $check = Input::get('check'); try { $tmp = TmpUserProfileBase::find($id); $base = UserProfileBase::find($id); $log = new LogUserProfileCensors(); $log->u_id = $id; $log->cate = 'base'; $log->admin_id = Tools::getAdminId(); if ($check == 1) { $tmp->u_is_student_verified = 1; if (!empty($base)) { $base->u_is_student_verified = 1; } if ($tmp->u_is_id_verified) { $user = User::find($id); $user->u_is_verified = 1; $user->save(); } $log->content = '认证用户学生证信息: 通过'; } else { $tmp->u_is_student_verified = 2; if (!empty($base)) { $base->u_is_student_verified = 2; } $log->content = '认证用户学生证信息: 不通过'; } $msg = new MessageDispatcher($id); $msg->fireTextToUser($log->content); $log->addLog(); $tmp->save(); if (!empty($base)) { $base->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); }