field("id,merchant_order_id")->whereLike('merchant_callback_msg', 'error')->whereRaw('status = 2 and ' . $whereRaw)->select(); if($data->isEmpty()){ $this->yes('ok','暂无异常订单'); } $errorOrder=[]; foreach ($data->toArray() as $vo) { // var_dump($vo);die; $errorOrder[] = $vo['merchant_order_id']; } if($errorOrder){ $errorMsg = implode("\n", $errorOrder); $this->no(0 ,$errorMsg); } } public function check_channel_balance() { $cid = [17]; $channel = DB::name('channel_list')->field("id,name,key")->where('status',1)->whereNotIn('id', $cid)->select(); if($channel->isEmpty()){ $this->yes('ok','暂无可用渠道'); } $channelService = ChannelService::instance(); $day = input('day'); if (!$day) { $day = date('Y-m-d', strtotime('-1 day')); } $tip_info=[]; foreach ($channel->toArray() as $vo){ try{ $account_data = $channelService->call('account', $vo['id'], $day); if (is_array($account_data) && isset($account_data['account'])) { $balance = $account_data['account']; if(1< $balance && $balance < 10000){ $tip_info[] = $vo['name'].'余额不足,只剩下'.$balance; } } }catch (\Exception $e){ } } if($tip_info && !empty($tip_info)){ $errorMsg = implode("\n", $tip_info); $this->no(0 ,$errorMsg); } $this->yes('ok','暂时正常'); } #检测异常订单error过期预警 public function check_orderparam() { $cur = time(); $time = 60*60*25; $whereRaw = $cur . '-unix_timestamp(create_at) <=' . $time; $data = DB::name('merchant_order')->field("id,merchant_order_id,mid")->whereLike('param', '%error%')->whereRaw( $whereRaw)->select(); if($data->isEmpty()){ $this->yes('ok','暂无异常订单信息'); } $errorOrder=[]; foreach ($data->toArray() as $vo) { if(!in_array($vo['mid'],$errorOrder)){ $errorOrder[] = $vo['mid']; } // var_dump($vo);die; } if($errorOrder){ $errorMsg = implode("\n", $errorOrder); $this->no(0 ,$errorMsg); } } }