/** * Display a listing of the resource. * * @return Response */ public function index(Request $request, $id) { //总销售金额 $order = new Order(); $_data['sell_total_money'] = $order->newQuery()->whereRaw('`status`>?', array(1))->sum('total_money'); //总订单数 $_data['order_total_cnt'] = $order->newQuery()->count(); //总商品数 $product = new Product(); $_data['product_total_cnt'] = $product->newQuery()->count(); //总用户数 $user = new User(); $_data['user_total_cnt'] = $user->newQuery()->count(); $this->_week_start = $week_start = date("Y-m-d 00:00:00", strtotime("-" . (date("w") - 1) . " days")); //本周销售 $_data['sell_week_money'] = $order->newQuery()->whereRaw('created_at>= ? and `status`>?', array($week_start, 1))->sum('total_money'); //本周订单 $_data['order_week_cnt'] = $order->newQuery()->whereRaw('created_at>= ?', array($week_start))->count(); //本周商品 $_data['product_week_cnt'] = $product->newQuery()->whereRaw('created_at>= ?', array($week_start))->count(); //本周用户 $_data['user_week_cnt'] = $user->newQuery()->whereRaw('created_at>= ?', array($week_start))->count(); $this->_data = $_data; return $this->view('admin.dashboard'); }
public function special(Request $request, $activity_id = 0) { $stores_ids = $this->user->stores->pluck('id'); $this->_brands = Brand::join('store_brand as s', 's.bid', '=', 'brands.id')->whereIn('s.sid', $stores_ids)->get(['brands.*']); $pagesize = $request->input('pagesize') ?: $this->site['pagesize']['m']; $this->_input = $request->all(); $product = new Product(); //查找猴子捞月所有在线,有效活动id $now = date("Y-m-d H:i:s"); if (!empty($activity_id)) { $activity = Activity::find($activity_id); } elseif (!empty($request->get('type_id'))) { $fids = $product->newQuery()->whereIn('bid', $this->_brands->pluck('id'))->pluck('fid'); if (!empty($fids)) { $fids = array_unique((array) $fids); } $builder = Activity::whereIn('fid', $fids)->where('type_id', $request->get('type_id')); $activity = $builder->first(); $activity_id = $builder->pluck('id'); } else { return $this->failure(NULL); } if (empty($activity)) { return $this->failure('activity::activity.no_activity'); } elseif ($activity->start_date > $now || $activity->end_date < $now || $activity->status != 1) { return $this->failure('activity::activity.failure_activity'); } //查看当前以以和店铺 猴子捞月 活动所有商品 $builder = $product->newQuery()->with(['sizes', 'covers']); $this->_activity = $activity; $this->_table_data = $builder->whereIn('activity_type', (array) $activity_id)->whereIn('bid', $this->_brands->pluck('id'))->paginate($pagesize); return $this->view('activity::m.special'); }
public function classify(Request $request) { $search_key = $request->input('search_key'); $stores_ids = $this->user->stores->pluck('id'); $this->_brands = Brand::join('store_brand as s', 's.bid', '=', 'brands.id')->whereIn('s.sid', $stores_ids)->get(['brands.*']); $pagesize = $request->input('pagesize') ?: $this->site['pagesize']['m']; $this->_input = $request->all(); $product = new Product(); $builder = $product->newQuery()->with(['sizes', 'covers']); if (!empty($search_key)) { $builder->where('title', 'like', '%' . $search_key . '%'); } $this->_search_key = $search_key; $this->_table_data = $builder->whereIn('bid', $this->_brands->pluck('id'))->paginate($pagesize); return $this->view('m.classify'); }
public function export(Request $request) { $product = new Product(); $builder = $product->newQuery()->with('brand'); $page = $request->input('page') ?: 0; $pagesize = $request->input('pagesize') ?: config('site.pagesize.export', 1000); $total = $this->_getCount($request, $builder); if (empty($page)) { $this->_of = $request->input('of'); $this->_table = $product->getTable(); $this->_total = $total; $this->_pagesize = $pagesize > $total ? $total : $pagesize; return $this->view('admin.product.export'); } $data = $this->_getExport($request, $builder); return $this->success('', FALSE, $data); }
public function index(Request $request, $sid = NULL, $redirect_url = NULL) { if (!empty($sid)) { $store = Store::find($sid); !empty($store) && $this->user->stores()->sync([$sid], FALSE); } if (empty($this->user->stores->count())) { return $this->failure('store.failure_follow'); } if (!empty($redirect_url)) { return redirect()->intended($redirect_url); } $stores_ids = $this->user->stores->pluck('id'); $this->_brands = Brand::join('store_brand as s', 's.bid', '=', 'brands.id')->whereIn('s.sid', $stores_ids)->get(['brands.*']); $pagesize = $request->input('pagesize') ?: config('site.pagesize.m', $this->site['pagesize']['common']); $this->_input = $request->all(); $product = new Product(); $builder = $product->newQuery()->with(['sizes', 'covers']); $this->_table_data = $builder->whereIn('bid', $this->_brands->pluck('id'))->paginate($pagesize); return $this->view('m.index'); }