Пример #1
0
 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');
 }
Пример #2
0
 public function activity_product()
 {
     if (!empty($this->activity_type)) {
         $activity = Activity::find($this->activity_type);
         if (!empty($activity) && $activity->start_date <= date("Y-m-d H:i:s") && $activity->end_date >= date("Y-m-d H:i:s") && $activity->status == 1) {
             $class_dir = ActivityType::find($activity->type_id)->class_dir;
             $config = json_decode($activity->argc, true);
         } else {
             return $this;
         }
     } else {
         return $this;
     }
     return with(new $class_dir())->config($config)->product_decorate($this);
 }
Пример #3
0
 public function activity_bonus($uid)
 {
     $activity_type = Product::find($this->pid)->activity_type;
     if (!empty($activity_type)) {
         $activity = Activity::find($activity_type);
         if (!empty($activity) && $activity->start_date <= date("Y-m-d H:i:s") && $activity->end_date >= date("Y-m-d H:i:s") && $activity->status == 1) {
             $class_dir = ActivityType::find($activity->type_id)->class_dir;
             $config = json_decode($activity->argc, true);
         } else {
             return '';
         }
     } else {
         return '';
     }
     $bonus_config = ['fid' => Product::find($this->pid)->fid, 'uid' => $uid, 'aid' => $activity_type];
     return with(new $class_dir())->config($config)->bonus($bonus_config);
 }
Пример #4
0
 public function getTypeHtml(Request $request)
 {
     $id = $request->get('id');
     $type_id = $request->get('type_id');
     if ($type_id) {
         $argc = Activity::find($id)->argc;
         $class_dir = ActivityType::find($type_id)->class_dir;
         $html = with(new $class_dir())->show_edit_html($argc);
     } else {
         $html = '';
     }
     exit($html);
 }