Files
WrenchBoradWeb/www-api/app/Controllers/Promo.php
T
CHIEFSOFT\ameye e703e093ab promo end point
2024-09-19 10:25:41 -04:00

80 lines
3.1 KiB
PHP

<?php
namespace App\Controllers;
use CodeIgniter\API\ResponseTrait;
class Promo extends BaseController
{
use ResponseTrait;
public function promoStart(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$out =[];
//$in["action"] = -1;
$in['action'] = WRENCHBOARD_MARKET_PLAN01_NEXT1;
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
$out['internal_return'] = $ret;
// $in["promo"] = $promo;
// $in["promo_owner"] = $promoOwner;
log_message('critical', "Promo::promoStart ********* ALL ".serialize($in) );
$in["loc"] = $_SERVER["REMOTE_ADDR"];
$in['limit'] = 10;
// $out["firstname"] = "Firstname";
// $out["promo_title"] = "This is the promo title";
// $out["promo_description"] = "This is the promo description , This is the promo description ,This is the promo description ,This is the promo description ,This is the promo description ,This is the promo description ,This is the promo description ,";
$out["site_name"]= "WrenchBoard";
$out["server_name"]= "https://www.wrenchboard.com";
$out['yyyy'] = '2024';
$out['user_server_name'] = 'https://dev-users.wrenchboard.com';
return $this->respond( $this->summaryReturnData($in,$out), 200);
}
public function promoVerify(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$in["action"] = -1; // bad number - we dont want formating WRENCHBOARD_ACCOUNT_JOBLIST; dont send this line , the formater will be confused
$out=[];
log_message('critical', "***** ***** Promo::promoVerify Ret ");
return $this->respond( $this->summaryReturnData($in,$out), 200);
}
public function promoTask(){
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$in["action"] = -1; // bad number - we dont want formating WRENCHBOARD_ACCOUNT_JOBLIST; dont send this line , the formater will be confused
$out=[];
$endpoint = "PROMO_JOBS-". $in["promo"];
$out = $this->getCache($endpoint);
$countItem = 0;
if( is_array($out)){
$countItem = count($out);
}
if ( $countItem == 0 ){
$local_url = "http://".$this->micro_service_net1.":3033/promojobs";
$out = $this->APIcall('GET', $local_url, $in);
// dont cache junk
if ( is_array($out) && is_array($out["result_list"]) && count($out["result_list"]) > 0){
$this->saveCache($endpoint,$out,3000);
}
$out['internal_return'] = 0; // just backwad comaptobility
log_message('critical', "***** ***** Promo::getJobsData Cache Done:::Ret ");
}
$endpoint = "WRENCH_JOB_INTEREST_COUNT";
$int_list = $this->getCache($endpoint)["result_list"];
$out["interest_list"] = ( isset($int_list) && is_array($int_list) ) ? $int_list : [];
log_message('critical', "***** ***** Promo::getJobsData Ret ");
return $this->respond( $this->summaryReturnData($in,$out), 200);
}
}