public function show($id)
 {
     $marketAc = Market::find($id);
     if (count($marketAc) < 1) {
         abort(404);
     }
     $day = getWeekDate();
     $cardAr = [];
     $orderAr = [];
     $rechargeAr = [];
     foreach ($day as $day) {
         $cardAr[] = UserCa::where('market_id', $id)->whereBetween('created_at', [$day . ' 00:00:00', $day . ' 23:59:59'])->count();
         /* 订单金额 */
         $orders = Order::where('market_id', $id)->whereBetween('created_at', [$day . ' 00:00:00', $day . ' 23:59:59'])->get();
         $orderPrice = 0;
         foreach ($orders as $order) {
             $orderPrice += $order->price;
         }
         $orderAr[] = $orderPrice;
         /* 混合订单金额 */
         $mixOrders = MixOrder::where('market_id', $id)->whereBetween('created_at', [$day . ' 00:00:00', $day . ' 23:59:59'])->get();
         $mixOrderPrice = 0;
         foreach ($mixOrders as $order) {
             $mixOrderPrice += $order->price;
         }
         $mixOrderAr[] = $mixOrderPrice;
         /* 充值金额 */
         $recharges = Recharge::where('market_id', $id)->whereBetween('created_at', [$day . ' 00:00:00', $day . ' 23:59:59'])->get();
         $rechargePrice = 0;
         foreach ($recharges as $d) {
             $rechargePrice += $d->price;
         }
         $rechargeAr[] = $rechargePrice;
     }
     $data['cards'] = $cardAr;
     $data['orderPrice'] = $orderAr;
     $data['mixOrderPrice'] = $mixOrderAr;
     $data['rechargePrice'] = $rechargeAr;
     $markets = Market::all();
     $data['markets'] = $markets;
     $data['marketAc'] = $marketAc;
     return view('card.data_day.show', $data);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(SeedMessageRequest $request)
 {
     $postData = $request->all();
     //获取请求过来的数据
     $startTime = e($postData['startTime']);
     $endTime = e($postData['endTime']);
     $text = e($postData['text']);
     //$user = User::findOrFail(1);
     $user = $request->user();
     $cards = UserCa::whereBetween('created_at', [$startTime, $endTime])->get();
     if (count($cards) < 1) {
         return redirect()->back()->withInput()->withErrors(array('attempt' => '未查到数据'));
         //回传错误信息
     }
     $user = $request->user();
     //        $this->dispatch(new SendReminderEmail($user));
     /* $email =  '2265798990@qq.com';
             for($i=0;$i<1000;$i++){
                 $t = floor($i/5)+10;
                 $job = (new SendEmail($user,$text,$email))->delay($t);
                 $this->dispatch($job);
             }
     
             dd($job);*/
     foreach ($cards as $key => $li) {
         $t = floor($key / 5) + 10;
         print_r($t . '</br>');
         $job = (new SeedMessage($user, $text, $li->phone))->delay($t);
         $jobS = $this->dispatch($job);
         print_r($jobS . '</br>');
     }
     $SmsRecord = new SmsRecord();
     $SmsRecord->startTime = $startTime;
     $SmsRecord->endTime = $endTime;
     $SmsRecord->text = $text;
     $SmsRecord->mumber = count($cards);
     $SmsRecord->user_id = $user->id;
     $SmsRecord->save();
     return redirect()->route('card.sms.index')->with('message', '成功发送短信队列!共发送' . count($cards) . "条记录");
 }
 /**
  * 后台首页 === 后台控制台概要页面
  *
  * @return Response
  */
 public function index()
 {
     $startTime = date('Y-m-d', time()) . ' 00:00:00';
     $endTime = date('Y-m-d', time()) . ' 23:59:59';
     $data['cards'] = UserCa::whereBetween('created_at', [$startTime, $endTime])->get()->count();
     $data['orders'] = Order::whereBetween('created_at', [$startTime, $endTime])->get()->count();
     $recharges = Recharge::whereBetween('created_at', [$startTime, $endTime])->get();
     $consumes = CountOrder::whereBetween('created_at', [$startTime, $endTime])->get();
     $rechargesPrice = 0;
     $consumesPrice = 0;
     if (count($recharges) > 0) {
         foreach ($recharges as $key => $li) {
             $rechargesPrice += $li->price;
         }
     }
     if (count($consumes) > 0) {
         foreach ($consumes as $key => $li) {
             $consumesPrice += $li->product_price * $li->product_weight;
         }
     }
     $data['rechargesPrice'] = $rechargesPrice;
     $data['consumesPrice'] = $consumesPrice;
     return view('card.home.index', $data);
 }
 /**
  * 删除内容
  *
  * @param  int $id
  * @param  string $type 内容模型类型
  * @return void
  */
 public function destroy($id)
 {
     $card = $this->card->findOrFail($id);
     $card->delete();
 }