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];
 }
Example #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];
 }
 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;
 }
 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]);
 }
 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]);
 }
Example #6
0
 public function run()
 {
     $order_id = Input::get('order_id', 0);
     $user_id = Input::get('user_id', 0);
     $open_id = Input::get('open_id', '');
     $pay_ment = PayMentORM::whereOrderId($order_id)->where('openid', '<>', '')->first();
     if (empty($pay_ment)) {
         $order = OrderORM::whereId($order_id)->wherePayStatus(BaseORM::DISABLE)->first();
         if (empty($order)) {
             return '订单未找到';
         }
         if ($user_id != $order->user_id) {
             return '用户不正确';
         }
         $album = AlbumORM::whereId($order->album_id)->first();
         if (empty($album)) {
             return '相册未找到';
         }
         $template = TemplateORM::whereId($album->template_id)->first();
         if (empty($template)) {
             return '相册模版未找到';
         }
         $params['out_trade_no'] = $this->_generate_out_trade_no($order_id, $user_id);
         $params['subject'] = '购买相册打印服务';
         $params['quantity'] = $order->quantity;
         $params['total_fee'] = $order->total_amount;
         $params['price'] = $template->price;
         $params['body'] = '购买相册打印服务';
         $params['user_id'] = $user_id;
         $params['openid'] = $open_id;
         $params['order_id'] = $order_id;
         $r = PayMentORM::edit(0, $params);
         $pay_ment = $r[1];
     }
     try {
         $m = new Wxpay();
         $jsParameters = $m->getJsApiParameters($pay_ment->out_trade_no, $pay_ment->total_fee * 100, $pay_ment->openid);
         return json_decode($jsParameters, true);
     } catch (Exception $e) {
         return '内部错误';
     }
 }
Example #7
0
 public function run()
 {
     $user_id = Input::get('user_id', 0);
     $class_id = Input::get('class_id', 0);
     $template_id = Input::get('template_id', 0);
     $user = UserORM::whereId($user_id)->whereStatus(BaseORM::ENABLE)->first();
     if (empty($user)) {
         return '用户未找到';
     }
     $class = TemplateClassORM::whereId($class_id)->whereStatus(BaseORM::ENABLE)->first();
     if (empty($class)) {
         return '相册分类未找到';
     }
     $template = TemplateORM::whereId($template_id)->whereClass($class_id)->whereStatus(BaseORM::ENABLE)->first();
     if (empty($template)) {
         return '模版未找到';
     }
     $r = AlbumORM::edit(0, ['user_id' => $user_id, 'class' => $class_id, 'template_id' => $template_id]);
     return $r[1];
 }
 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 '删除失败';
     }
 }