Files
WrenchBoradWeb/www-api/app/Controllers/AirFlow.php
T
CHIEFSOFT\ameye 74cf9f43bf new cron jons
2024-09-09 16:47:24 -04:00

231 lines
8.8 KiB
PHP

<?php
namespace App\Controllers;
define('WRB_CRONJOB_JOBDUE_REMINDER',771);
define('WRB_CRONJOB_JOBDUE_PAYMENTS',772);
define('WRB_CRONJOB_SIGNUP_ALERT', 773);
define('WRB_CRONJOB_PASTDUE_ALERT',774);
define('WRB_CRONJOB_OFFER_REFUND_ALERT',775);
define('WRB_CRONJOB_PENDOFFER_ALERT',776);
define('WRB_CRONJOB_NOTIFICATIONS', 777) ;
define('WRB_CRONJOB_GROUPJOBS', 778);
define('WRB_CRONJOB_TESTNOTIFICATIONS', 779);
define('WRB_CRONJOB_SCHEULETRANSFER', 780);
define('WRB_CRONJOB_PROCESSTRANSFER', 781);
define('WRB_CRONJOB_PENDINGSM', 790) ;
class AirFlow extends BaseController
{
public function flowNewAccount(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
log_message('critical', "AirFlow::flowNewAccount ********* ALL ".serialize($in) );
return []; //json_encode( $final_out );
}
public function flowOfferPending(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
log_message('critical', "AirFlow::flowOfferPending ********* ALL ".serialize($in) );
return $this-> offersreminders();
// return []; //json_encode( $final_out );
}
public function flowDueReminder(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
log_message('critical', "AirFlow::flowDueReminder ********* ALL ".serialize($in) );
return $this->jobLevelAlerts();
// return []; //json_encode( $final_out );
}
//
public function flowInterestcount(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
log_message('critical', "AirFlow::flowInterestcount ********* CRON ");
$in["action"] = "LOCAL_CALL_NO_ACTION";
$endpoint = "WRENCH_JOB_INTEREST_COUNT";
$res1 = $this->getCache($endpoint);
if (count($res1)==0){
$local_url = "http://".$this->micro_service_net1.":3033/interestCount";
$out = $this->APIcall('GET', $local_url, $in);
$this->saveCache($endpoint,$out,480);
}
return []; //json_encode( $final_out );
}
public function flowApproveReminder(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
log_message('critical', "AirFlow::flowApproveReminder ********* ALL ".serialize($in) );
return []; //json_encode( $final_out );
}
public function flowProcessTransfer(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
log_message('critical', "AirFlow::flowProcessTransfer ********* ALL ".serialize($in) );
$in["loc"] = $_SERVER["REMOTE_ADDR"];
$in['call_action'] = WRB_CRONJOB_PROCESSTRANSFER;
$in['one_limit'] = 10; //remove this
$in['limit'] = 10;
$ret['WRB_CRONJOB_PROCESSTRANSFER'] = (new \App\Models\BackendModel())->wrenchboard_api($in, $out);
return []; //json_encode( $final_out );
}
public function flowScheduleTransfer(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
// ALTER TABLE money_transfer ADD proc INT DEFAULT 0;
// SELECT initiatingamount, status, added,proc FROM money_transfer WHERE added > (now() - interval '3000 minutes') AND status = 0 ORDER BY id DESC LIMIT 100;
log_message('critical', "AirFlow::flowScheduleTransfer ********* ALL ".serialize($in) );
$in["loc"] = $_SERVER["REMOTE_ADDR"];
$in['call_action'] = WRB_CRONJOB_SCHEULETRANSFER;
$in['one_limit'] = 10; //remove this
$in['limit'] = 10;
$ret['WRB_CRONJOB_SCHEULETRANSFER'] = (new \App\Models\BackendModel())->wrenchboard_api($in, $out);
return []; //json_encode( $final_out );
}
public function flowTestNotifications(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
log_message('critical', "AirFlow::flowTestNotifications ********* ALL ".serialize($in) );
$in["loc"] = $_SERVER["REMOTE_ADDR"];
$in['call_action'] = WRB_CRONJOB_TESTNOTIFICATIONS;
$in['one_limit'] = 10; //remove this
$in['limit'] = 10;
$ret['WRB_CRONJOB_TESTNOTIFICATIONS'] = (new \App\Models\BackendModel())->wrenchboard_api($in, $out);
return []; //json_encode( $final_out );
}
public function flowSendNotifications(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
log_message('critical', "AirFlow::flowApproveReminder ********* ALL ".serialize($in) );
$in["loc"] = $_SERVER["REMOTE_ADDR"];
$in['call_action'] = WRB_CRONJOB_NOTIFICATIONS;
$in['one_limit'] = 10; //remove this
$in['limit'] = 10;
$ret['WRB_CRONJOB_NOTIFICATIONS'] = (new \App\Models\BackendModel())->wrenchboard_api($in, $out);
return []; //json_encode( $final_out );
}
public function flowSignupReport(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
$in["action"] =WRB_JOB_CRONJOB;
// $wrenchboard = new \App\Models\BackendModel();
$in['call_action'] = WRB_CRONJOB_SIGNUP_ALERT;
$in['one_limit'] = 3;
// $ret['WRB_CRONJOB_SIGNUP_ALERT'] = $wrenchboard->wrenchboard_api($in, $out);
$ret['WRB_CRONJOB_SIGNUP_ALERT'] = (new \App\Models\BackendModel())->wrenchboard_api($in, $out);
// $out['internal_return'] = $ret;
$out = $ret;
log_message('critical', "AirFlow::flowSignupReport ********* ALL ".serialize($in) );
return []; //json_encode( $final_out );
}
public function flowRefreshBlog(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
$endpoint = "WRENCH_BLOG_DATA";
$res1 = $this->getCache($endpoint);
if (count($res1)==0){
$rawData = $this->apiData(0);
$res1= $rawData['payload']; //[0]['payload'];
$this->saveCache($endpoint,$res1);
}
log_message('critical', "AirFlow::flowRefreshBlog ********* ALL ".serialize($in) );
return []; //json_encode( $final_out );
}
private function jobLevelAlerts(){
$in["action"] =WRB_JOB_CRONJOB;
$wrenchboard = new \App\Models\BackendModel();
$in['call_action'] = WRB_CRONJOB_JOBDUE_REMINDER;
$in['one_limit'] = 3;
$ret['WRB_CRONJOB_JOBDUE_REMINDER'] = $wrenchboard->wrenchboard_api($in, $out);
//
// $in['call_action'] = WRB_CRONJOB_PENDOFFER_ALERT;
// $in['one_limit'] = 3;
// $ret['WRB_CRONJOB_PENDOFFER_ALERT'] = $wrenchboard->wrenchboard_api($in, $out);
$in['call_action'] = WRB_CRONJOB_JOBDUE_PAYMENTS;
$in['one_limit'] = 3;
$ret['WRB_CRONJOB_JOBDUE_PAYMENTS'] = $wrenchboard->wrenchboard_api($in, $out);
$in['call_action'] = WRB_CRONJOB_PASTDUE_ALERT;
$in['one_limit'] = 3;
$ret['WRB_CRONJOB_PASTDUE_ALERT'] = $wrenchboard->wrenchboard_api($in, $out);
$in['call_action'] = WRB_CRONJOB_OFFER_REFUND_ALERT;
$in['one_limit'] = 1;
$ret['WRB_CRONJOB_OFFER_REFUND_ALERT'] = $wrenchboard->wrenchboard_api($in, $out);
// $out['internal_return'] = $ret;
$out = $ret;
log_message('critical', "WrenchCrons ===> 0001");
//$response = []; //json_decode($complete, true);
return $this->response->setJson($out);
}
public function offersreminders(){
log_message('critical', "WrenchCrons ===> offersreminders ******** 0001");
$in["action"] =WRB_JOB_CRONJOB;
$wrenchboard = new \App\Models\BackendModel();
$in['call_action'] = WRB_CRONJOB_PENDOFFER_ALERT;
$in['one_limit'] = 10;
$in['mode'] = 100;
$ret['WRB_CRONJOB_PENDOFFER_ALERT_100'] = $wrenchboard->wrenchboard_api($in, $out);
$in['call_action'] = WRB_CRONJOB_PENDOFFER_ALERT;
$in['one_limit'] = 10;
$in['mode'] = 200; // 12 hours before expritation
$ret['WRB_CRONJOB_PENDOFFER_ALERT_200'] = $wrenchboard->wrenchboard_api($in, $out);
$in['call_action'] = WRB_CRONJOB_PENDOFFER_ALERT;
$in['one_limit'] = 10;
$in['mode'] = 300; // 6h hours before expritation
$ret['WRB_CRONJOB_PENDOFFER_ALERT_300'] = $wrenchboard->wrenchboard_api($in, $out);
// $out['internal_return'] = $ret;
$out = $ret;
log_message('critical', "WrenchCrons ===> 0001");
//$response = []; //json_decode($complete, true);
return $this->response->setJson($out);
}
}