redis) { $this->redis = RedisService::getInstance(); } } #检测异常接口预警 public function check_notify() { $cur = time(); $time = 60*6; $whereRaw = $cur . '-unix_timestamp(create_at) <=' . $time; $data = DB::name('merchant_order')->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','暂时正常'); } #检测商户余额并同志 public function check_merchant_account() { $mid = input('mid'); $jk_account = input('jk_account'); $merchant = DB::name('merchant_list')->field("id,name,account_surplus,account_baitiao")->where('status',1)->where('id',$mid)->find(); if(!$merchant){ $this->yes('ok','无此商户'); } if($merchant['account_surplus'] <= $jk_account){ #进入预警流程 #设置redis,根据mid设置redis, if(!$this->redis->get('Cherck_merchnat_account-'.$mid)){ $this->redis->set('Cherck_merchnat_account-'.$mid,1); $this->no(0 ,$merchant['name'].'余额不足,只剩下'.$merchant['account_surplus'].'请及时充值'); } } } #检测异常订单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); } } }