Пример #1
0
 public function run()
 {
     $user_id = Input::get('user_id', 0);
     $album_id = Input::get('album_id', 0);
     $user = UserORM::whereId($user_id)->whereStatus(BaseORM::ENABLE)->first();
     if (empty($user)) {
         return '用户未找到';
     }
     $album = AlbumORM::whereId($album_id)->whereUserId($user_id)->first();
     if (empty($album)) {
         return '相册未找到';
     }
     $sources = AlbumSourceORM::whereAlbumId($album_id)->orderBy('is_front', 'DESC')->get();
     $template_source_count = TemplateSourceORM::whereTemplateId($album->template_id)->count();
     $images = [];
     foreach ($sources as $s) {
         $tmp = [];
         $tmp['id'] = $s->id;
         $tmp['album_id'] = $s->album_id;
         $tmp['source'] = Config::get('app.image_host') . $s->source;
         $tmp['is_front'] = $s->is_front;
         $images[] = $tmp;
     }
     $can_add = 0;
     if ($template_source_count > count($sources)) {
         $can_add = 1;
     }
     return ['album' => $album, 'images' => $images, 'can_add' => $can_add];
 }
Пример #2
0
 public function run()
 {
     $album_id = Input::get('album_id', 0);
     $source = Input::get('source', '');
     $user_id = Input::get('user_id', 0);
     $template_id = Input::get('template_id', 0);
     $album = AlbumORM::whereId($album_id)->whereTemplateId($template_id)->whereUserId($user_id)->first();
     if (empty($album)) {
         return '相册未找到';
     }
     $template = TemplateORM::whereId($template_id)->whereStatus(BaseORM::ENABLE)->first();
     if (empty($template)) {
         return '模版未找到';
     }
     $sources = TemplateSourceORM::whereTemplateId($template_id)->count();
     $has_make = AlbumSourceORM::whereAlbumId($album_id)->count();
     if ($has_make >= $sources) {
         return '相册图片数量已满';
     }
     if (empty($source)) {
         return '图片路径错误';
     }
     $r = AlbumSourceORM::edit(0, ['album_id' => $album_id, 'source' => $source, 'is_front' => $has_make == 0 ? 1 : 0]);
     return $r[1];
 }
Пример #3
0
 public function run()
 {
     $user_id = intval(Input::get('user_id', 0));
     $album_id = intval(Input::get('album_id', 0));
     $quantity = intval(Input::get('quantity', 1));
     $real_name = trim(Input::get('real_name', ''));
     $mobile = trim(Input::get('mobile', ''));
     $address = trim(Input::get('address', ''));
     if (empty($real_name)) {
         return '姓名必须填写';
     }
     if (empty($mobile)) {
         return '联系电话必须填写';
     }
     if (empty($address)) {
         return '联系地址必须填写';
     }
     $user = UserORM::whereId($user_id)->whereStatus(BaseORM::ENABLE)->first();
     if (empty($user)) {
         return '用户未找到';
     }
     $album = AlbumORM::whereId($album_id)->whereUserId($user_id)->first();
     if (empty($album)) {
         return '相册未找到';
     }
     $source = AlbumSourceORM::whereAlbumId($album_id)->get();
     if (count($source) == 0) {
         return '该相册没有任何图片';
     }
     $template = TemplateORM::whereId($album->template_id)->first();
     if (empty($template)) {
         return '相册模版未找到';
     }
     if (intval($quantity) <= 0) {
         return '数量错误';
     }
     $price = $template->price;
     $total_amount = $price * $quantity;
     $orm = new OrderORM();
     $orm->user_id = $user_id;
     $orm->album_id = $album_id;
     $orm->quantity = $quantity;
     $orm->total_amount = $total_amount;
     $orm->save();
     $order = OrderORM::find($orm->id);
     $user->real_name = $real_name;
     $user->mobile = $mobile;
     $user->address = $address;
     $user->save();
     return $order;
 }
Пример #4
0
 public function show()
 {
     $id = (int) Input::get('id', 0);
     $album = AlbumORM::find($id);
     if ($id > 0 && empty($album)) {
         Session::flash('error', '相册未找到');
         return Redirect::route('albumLists');
     }
     $sources = AlbumSourceORM::whereAlbumId($id)->get();
     $classes = TemplateClassORM::all();
     array_ch_key('id', $classes);
     $format_classes = array_ch_key('id', $classes);
     $user = UserORM::find($album->user_id);
     return View::make('album.show', ['row' => $album, 'user' => $user, 'source' => $sources, 'classes' => $format_classes]);
 }
Пример #5
0
 public function show()
 {
     $id = (int) Input::get('id', 0);
     $order = OrderORM::find($id);
     if ($id > 0 && empty($order)) {
         Session::flash('error', '订单未找到');
         return Redirect::route('orderLists');
     }
     $user = UserORM::whereId($order->user_id)->first();
     $album = AlbumORM::whereId($order->album_id)->first();
     $template = TemplateORM::whereId($album->template_id)->first();
     $template_class = TemplateClassORM::whereId($template->class)->first();
     $source = AlbumSourceORM::whereAlbumId($album->id)->get();
     return View::make('order.show', ['row' => $order, 'user' => $user, 'album' => $album, 'template' => $template, 'class' => $template_class, 'source' => $source, 'id' => $id]);
 }
Пример #6
0
 public function run()
 {
     $user_id = Input::get('user_id', 0);
     $ids = Input::get('ids', '');
     if (empty($ids)) {
         return '图片不能为空';
     }
     $ids_arr = explode(',', $ids);
     $images = AlbumSourceORM::whereIn('id', $ids_arr)->get();
     if (count($images) <= 0) {
         return '图片未找到';
     }
     $albums = [];
     foreach ($images as $i) {
         $albums[] = $i->album_id;
     }
     $album_array = AlbumORM::whereIn('id', $albums)->get();
     if (count($album_array) <= 0) {
         return '相册未找到';
     }
     $users = [];
     foreach ($album_array as $a) {
         $users[] = $a->user_id;
     }
     foreach ($users as $u) {
         if ($u != $user_id) {
             return '用户信息错误';
             break;
         }
     }
     try {
         $images = AlbumSourceORM::whereIn('id', $ids_arr)->delete();
         return [];
     } catch (Exception $e) {
         return '删除失败';
     }
 }