public function showDetail() { $data = []; $data['id'] = $this->a_id; $data['sub_title'] = $this->a_sub_title; $data['win_username'] = $this->a_win_username; $data['win_price'] = $this->a_win_price; $data['status'] = $this->a_status; $data['cost'] = $this->a_cost; $data['current_time'] = Tools::getNow(); if (empty($this->eventItem)) { $data['title'] = ''; $data['start_at'] = ''; $data['end_at'] = ''; $data['url'] = ''; $data['cover_img'] = []; $data['detail_content_img'] = []; $data['detail_header_img'] = []; } else { $data['title'] = $this->eventItem->e_title; $data['start_at'] = $this->eventItem->e_start_at; $data['end_at'] = $this->eventItem->e_end_at; $data['url'] = $this->eventItem->url; $data['cover_img'] = Img::filterKey('cover_img', Img::toArray($this->eventItem->cover_img)); $data['detail_content_img'] = Img::filterKey('detail_content_img', Img::toArray($this->eventItem->cover_img)); $data['detail_header_img'] = Img::filterKey('detail_header_img', Img::toArray($this->eventItem->cover_img)); } return $data; }
public function showDetail() { $data = []; $this->load('school'); $data['school'] = empty($this->school) ? null : $this->school->showInList(); $data['student_img'] = Img::toArray($this->u_student_imgs, true); $data['student_number'] = $this->u_student_number; $data['student_verified'] = $this->u_is_student_verified; $data['identity_number'] = $this->u_id_number; $data['identity_img'] = Img::toArray($this->u_id_imgs, true); $data['identity_verified'] = $this->u_is_id_verified; $data['entry_year'] = $this->u_entry_year; $data['major'] = $this->u_major; $data['emergency_phone'] = $this->em_contact_phone; $data['emergency_name'] = $this->em_contact_name; $data['home_adress'] = $this->u_home_adress; $data['father_name'] = $this->u_father_name; $data['father_telephone'] = $this->u_father_phone; $data['mother_name'] = $this->u_mother_name; $data['mother_telephone'] = $this->u_mother_phone; $data['apartment'] = $this->u_apartment_no; $data['status'] = $this->u_status; if ($this->u_status == 2) { $data['remark'] = $this->remark; } return $data; }
public function showInList() { $data = []; $data['id'] = $this->ad_id; $data['status'] = $this->ad_status; $date = new DateTime($this->created_at); $data['created_at'] = $date->format('Y-m-d H:i:s'); $data['created_at_timestamps'] = strtotime($data['created_at']); if (empty($this->eventItem)) { $this->load('eventItem'); } if (empty($this->eventItem)) { $data['title'] = ''; $data['cover_img'] = null; $data['url'] = ''; $data['brief'] = ''; $data['active_at'] = ''; } else { $data['title'] = $this->eventItem->e_title; $data['cover_img'] = Img::filterKey('cover_img', Img::toArray($this->eventItem->cover_img)); $data['url'] = $this->eventItem->url; $data['brief'] = $this->eventItem->e_brief; $data['active_at'] = $this->eventItem->e_start_at; } return $data; }
public function showDetail() { $data = []; $data['title'] = $this->e_title; $data['cover_img'] = Img::toArray($this->cover_img); $data['url'] = $this->url; $data['range'] = $this->e_range; if (count($this->positions) > 0) { $positions = []; foreach ($this->positions as $position) { $positions[] = $position->showInList(); } $data['positions'] = $positions; } else { $data['positions'] = null; } if (count($this->ranges) > 0) { $ranges = []; foreach ($this->ranges as $range) { $ranges[] = $range->showInList(); } $data['ranges'] = $ranges; } $data['start_at'] = $this->e_start_at; $data['end_at'] = $this->e_end_at; return $data; }
public function showDetail() { $data = []; $this->load('school'); $data['school'] = empty($this->school) ? null : $this->school->showInList(); $data['student_img'] = Img::toArray($this->u_student_imgs, true); $data['student_number'] = $this->u_student_number; $data['identity_number'] = $this->u_id_number; $data['identity_img'] = Img::toArray($this->u_id_imgs, true); $data['entry_year'] = $this->u_entry_year; $data['major'] = $this->u_major; $data['emergency_phone'] = $this->em_contact_phone; $data['status'] = $this->u_status; return $data; }
public function showDetail() { $data = []; $data['identity_number'] = $this->u_identity_number; $data['identity_imgs'] = Img::toArray($this->u_identity_img, true); $data['home_adress'] = $this->u_home_adress; $data['father_name'] = $this->u_father_name; $data['father_telephone'] = $this->u_father_telephone; $data['mother_name'] = $this->u_mother_name; $data['mother_telephone'] = $this->u_mother_telephone; $data['status'] = $this->u_status; if ($this->u_status == 2) { $data['remark'] = $this->remark; } return $data; }
public function showDetail() { $data = []; $data['title'] = $this->c_title; $data['brief'] = $this->c_brief; $data['official_url'] = $this->c_official_url; $data['imgs'] = Img::toArray($this->c_imgs); if (empty($data['imgs']['club_proof_img'])) { $data['imgs']['club_proof_img'] = null; } $data['status'] = $this->c_status; $data['remark'] = $this->remark; if (!empty($this->school)) { $data['school'] = $this->school->showInList(); } if (!empty($this->user)) { $data['user'] = $this->user->showInList(); } return $data; }
/** * Run the migrations. * * @return void */ public function up() { set_time_limit(0); Schema::table('crowd_fundings', function ($table) { $table->integer('e_id'); }); $list = CrowdFunding::get(); foreach ($list as $key => $funding) { // handle event $event = new EventItem(); $event->e_title = $funding->c_title; $imgs = Img::toArray($funding->c_imgs); if (empty($imgs['cover_img'])) { $cover = ''; } else { $cover = $imgs['cover_img']; unset($imgs['cover_img']); } $event->cover_img = $cover; $event->e_brief = $funding->c_brief; $event->e_range = 0; $event->e_start_at = $funding->active_at; $event->e_end_at = $funding->end_at; $event->created_at = $funding->created_at; $event->e_status = 1; $event->save(); // handle ranges $range = new EventRange(); $range->e_id = $event->e_id; $range->s_id = $funding->s_id; $range->c_id = $funding->c_id; $range->p_id = $funding->pv_id; $range->save(); // handle imgs $funding->c_imgs = implode(',', $imgs); $funding->e_id = $event->e_id; $funding->save(); } }
public function showDetail() { $data = []; $this->load('school'); $data['school'] = $this->school->showInList(); $data['student_img'] = Img::toArray($this->u_student_img, true); $data['student_number'] = $this->u_student_number; $data['teacher_name'] = $this->u_teacher_name; $data['teacher_phone'] = $this->u_teacher_telephone; $data['frend_name1'] = $this->u_frend_name1; $data['frend_telephone1'] = $this->u_frend_telephone1; $data['frend_name2'] = $this->u_frend_name2; $data['frend_telephone2'] = $this->u_frend_telephone2; $data['profession'] = $this->u_prof; $data['degree'] = $this->u_degree; $data['entry_year'] = $this->u_entry_year; $data['status'] = $this->u_status; if ($this->u_status == 2) { $data['remark'] = $this->remark; } return $data; }
public function loadProduct() { if (!$this->p_id || !$this->c_quantity) { throw new Exception("购买数量不能为0", 7001); } $product = Product::find($this->p_id); if (empty($product->p_id)) { throw new Exception("没有获取到产品", 7001); } // caculate quantity $product->load('quantity'); if (empty($product->quantity->q_id)) { throw new Exception("没有获取到产品库存信息", 7001); } $total = $product->quantity->q_total; $sold = $product->quantity->q_sold; $inCart = Cart::where('c_status', '=', 1)->where('p_id', '=', $this->p_id)->sum('c_quantity'); $remain = (int) $total - (int) $sold - (int) $inCart + $this->_quntityOri; if ($this->c_quantity > $remain) { throw new Exception("产品库存不足", 7006); } $product->quantity->q_cart = $inCart + $this->c_quantity - $this->_quntityOri; $product->quantity->save(); $this->c_price_origin = $product->p_price_origin; $this->c_discount = $product->p_discount; $this->c_price = $this->c_price_origin * $this->c_discount / 100; $this->c_amount_origin = $this->c_price_origin * $this->c_quantity; $this->c_amount = $this->c_amount_origin * $this->c_discount / 100; $this->p_name = $product->p_title; $imgs = Img::toArray($product->p_imgs); $this->p_img = array_pop($imgs); }
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); }
private function loadImgs() { $this->_imgs = Img::toArray($this->p_imgs); }
public function getContact() { $token = Input::get('token', ''); $u_id = Input::get('u_id', ''); try { $user = User::chkUserByToken($token, $u_id); $contact = TmpUserProfileBase::find($u_id); $contact->load('school'); $data = []; if (!isset($contact->u_id)) { $data['th_name'] = ''; $data['th_phone'] = ''; $data['fr_name_1'] = ''; $data['fr_phone_1'] = ''; $data['fr_name_2'] = ''; $data['fr_phone_2'] = ''; $data['stu_num'] = ''; $data['stu_img'] = ''; $data['school'] = ''; $data['profession'] = ''; $data['degree'] = ''; $data['entry_year'] = ''; } else { $data['th_name'] = $contact->u_teacher_name; $data['th_phone'] = $contact->u_teacher_telephone; $data['fr_name_1'] = $contact->u_frend_name1; $data['fr_phone_1'] = $contact->u_frend_telephone1; $data['fr_name_2'] = $contact->u_frend_name2; $data['fr_phone_2'] = $contact->u_frend_telephone2; $data['stu_num'] = $contact->u_student_number; $imgs = Img::toArray($contact->u_student_img, true); $data['stu_img'] = $imgs; $data['school'] = empty($contact->school) ? null : $contact->school->showInList(); $data['profession'] = $contact->u_prof; $data['degree'] = $contact->u_degree; $data['entry_year'] = $contact->u_entry_year; } $re = ['result' => 2000, 'data' => $data, 'info' => '获取用户详细成功']; } catch (Exception $e) { $code = 3002; if ($e->getCode() > 2000) { $code = $e->getCode(); } $re = ['result' => $code, 'data' => [], 'info' => '获取用户详细失败:' . $e->getMessage()]; } return Response::json($re); }
public function loadImg() { $this->_imgs = Img::toArray($this->c_imgs); }
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); }
public function getHeadImg() { if (!empty($this->u_head_img)) { $img = Img::toArray($this->u_head_img); $img = empty($img) ? '' : reset($img); return $img; } else { $this->load('importQq'); if (!empty($this->importQq)) { if ($this->importQq->u_head_img) { return $this->importQq->u_head_img; } } $this->load('importWechat'); if (!empty($this->importWechat)) { if ($this->importWechat->u_head_img) { return $this->importWechat->u_head_img; } } } return ''; }