public function saveScore(Request $request)
 {
     $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.*']);
     $fids = Product::whereIn('bid', $this->_brands->pluck('id'))->pluck('fid');
     $key = 'bonus_' . $this->user->getKey() . '_game';
     $times = intval(Cache::get($key, 0));
     $save_code_key = 'save_put_code_' . $this->user->getKey();
     $ver_code = $request->get('ver_code');
     if (session($save_code_key) == $ver_code && !empty($fids) && $times > 0) {
         $fids = array_unique((array) $fids);
         //把关注店铺,相关的厂商都加红包
         $score = $request->get('score');
         //分数
         if ($score < 1) {
             $data = ['err_msg' => '红包金额不能为空.'];
             return $this->failure(NULL, false, $data, true);
         }
         $type_id = $request->get('type_id');
         //活动id
         foreach ($fids as $fid) {
             $activity_bouns = new ActivityBonus();
             $activity_bouns->uid = $this->user->getKey();
             $activity_bouns->fid = $fid;
             $activity_bouns->activity_id = with(Activity::where('fid', $fid)->where('type_id', $type_id)->first())->id;
             $activity_bouns->bonus = intval($score) > 98 ? 98 : intval($score);
             $activity_bouns->status = 0;
             $activity_bouns->save();
         }
         Cache::decrement($key);
         session([$save_code_key => '']);
         //红包的个数
         $bonus_cnt = ActivityBonus::where('uid', $this->user->getKey())->where('status', 0)->count();
         $data = ['times' => --$times, 'bonus_cnt' => $bonus_cnt];
         return $this->success(NULL, false, $data);
     } else {
         $data = ['err_msg' => '暂时没添加相关活动。'];
         return $this->failure(NULL, false, $data, true);
     }
 }