startOfDay()->toDateTimeString(); $yesterdayEndTime = Carbon::yesterday()->endOfDay()->toDateTimeString(); //查询价格异常订单 $results = DB::table('business_order_items as a') ->select('c.title as cn_name', 'b.title as title', DB::raw('ROUND(a.goods_price / 100,2) AS goods_price') , 'b.cost','a.created_at','a.business_order_id') ->leftJoin('goods_skus as b', 'a.external_sku_id', '=', 'b.external_sku_id') ->leftJoin('goods as c', 'b.goods_id', '=', 'c.id') ->whereBetween('a.created_at', [$yesterdayStartTime,$yesterdayEndTime]) ->havingRaw('goods_price < cost') ->get(); if($results->isNotEmpty()){ Log::info($yesterdayStartTime.'异常订单',$results->toArray()); $messageService = new MessageService(); foreach ($results as $v){ $messageService->createPriceExceptionMessage($v->business_order_id, $v->cn_name,$v->title,$v->goods_price,$v->cost); } } Log::info('任务完成:check-CheckPrice'); } }