assign mode fam,ily

This commit is contained in:
CHIEFSOFT\ameye
2024-03-26 21:17:17 -04:00
parent c4975d66ff
commit c1c1c4f84b
2 changed files with 193 additions and 0 deletions
@@ -43,6 +43,8 @@ enum { PARTNER_STRIPE };
#define LOGIN_MODE_FAMILY 1105
#define ASSIGN_MODE_FAMILY 110011
#define ASSIGN_MODE_MEDIA_FAMILY 110012
#define ASSIGN_MODE_INDIVIDUAL 110022
#define ASSIGN_MODE_EMAIL 110033
#define ASSIGN_MODE_GROUP 110044
+191
View File
@@ -28,6 +28,7 @@ long WrenchJobPostNotifyOffer(CVars in, CVars &out);
long WrenchJobPostCancelOffer(CVars in, CVars &out);
long WrenchJobOfferSystems(CVars in, CVars &out);
long WrenchSendJobsOfferFamily(CVars in, CVars &out);
long WrenchSendMediaOfferFamily(CVars in, CVars &out);
long WrenchSendJobsOfferCreateAssign(CVars in, CVars &out);
long WrenchJobsOfferInterestList(CVars in, CVars &out);
long WrenchUserJobsInterestList(CVars in, CVars &out);
@@ -176,6 +177,10 @@ long WrenchJobOfferSystems(CVars in, CVars &out){
long assign_mode = REQ_LONG(in, "assign_mode", 1, -1);
switch(assign_mode){
case ASSIGN_MODE_MEDIA_FAMILY:
logfmt(logINFO, "WrenchJobOfferSystems()->ASSIGN_MODE_MEDIA_FAMILY");
return WrenchSendMediaOfferFamily(in, out);
break;
case ASSIGN_MODE_FAMILY:
logfmt(logINFO, "WrenchJobOfferSystems()->ASSIGN_MODE_FAMILY");
return WrenchSendJobsOfferFamily(in, out);
@@ -1191,6 +1196,192 @@ long WrenchConcludeJobsOffer(CVars in, CVars &out) {
return ret;
}
long WrenchSendMediaOfferFamily(CVars in, CVars &out) {
logfmt(logINFO, "ENTER WrenchJobOfferSystems()->WrenchSendMediaOfferFamily");
/*
'member_id' => int 1
'sessionid' => string '625EECF44B88FFC527E598B48C1A5110830D5964B4DC9DB2AD9EBEB5609BC9BF' (length=64)
'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36)
'media_uid' => string '04cd4af1-d761-4507-b2b6-f56e24e676e1' (length=36)
'family_uid' => string 'a24f1193-7885-4c26-afac-3e5ad744ef40' (length=36)
'amount' => int 37600
'currency' => string 'NGN' (length=3)
'media_type' => string 'COMMON' (length=6)
'job_description' => string 'Delivery detail will gp here any deliver details will go here ,Delivery detail will gp here any deliver details will go here ' (length=126)
'action' => int 13025
'assign_mode' => int 110012
*/
long ret = PHP_API_BAD_PARAM;
// logfmt(logINFO, "WrenchSendMediaOfferFamily()");
long member_id = REQ_LONG(in, "member_id", 1, -1);
REQ_STRING(in, "uid", 1, 59, "(.*)");
REQ_STRING(in, "media_uid", 1, 59, "(.*)");
REQ_STRING(in, "family_uid", 1, 59, "(.*)");
REQ_STRING(in, "job_description", 1, 5500, "(.*)");
long amount = REQ_LONG(in, "amount", 1, -1);
REQ_STRING(in, "currency", 2, 4, "(.*)");
srand((unsigned) time(NULL));
int r = rand();
in["offer_code"] = 10000000 * r*r;
in["offer_code"].set_valid(true);
long offer_id = 0;
out = in;
/*
'member_id' => int 1
'sessionid' => string 'DFD8812B9A3ABE7FCF920B71A22AA3E93BB9F9C33AE22E90AAC47537367B2E2B' (length=64)
'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36)
'job_id' => string '98' (length=2)
'job_uid' => string '473d3239-ecd7-4eb5-859c-78261720cb8e' (length=36)
'family_uid' => string 'a24f1193-7885-4c26-afac-3e5ad744ef40' (length=36)
'job_description' => string 'Nitetronic Z6 Anti Snoring Pillow, Best Snore Stopper Device, Clinically Proven Snoring Solution for Snorers, Smart Stop Snoring Technology Suitable for All Sleepers' (length=165)
'action' => int 13025
'assign_mode' => int 110011
CREATE TABLE members_jobs_offer (
id SERIAL,
offer_code varchar(15) UNIQUE NOT NULL,
member_id INT REFERENCES members(id),
client_id INT DEFAULT 0,
group_id INT DEFAULT 0,
job_id INT REFERENCES members_jobs(id),
email varchar(50),
job_description varchar(500),
status integer DEFAULT 1,
sent_count integer DEFAULT 0,
added timestamp without time zone DEFAULT now()
);
*/
in["client_id"] = "0";
CVars x;
CVars y;
CVars u;
CVars z;
CVars xy;
CVars xout;
bool family_found = false;
try {
// let us use this email to see if this already a user on the system
if (load_db_record(out, "SELECT family_member_id AS client_id FROM members_family WHERE member_id = %lu AND uid='%s';",member_id, in["family_uid"].c_str())) {
in["client_id"] = out["client_id"]; // overidding if account is found
if (out["client_id"].length() > 0) {
x["client_id"] = in["client_id"];
x["client_id"].set_valid(true);
family_found = true;
}
}
if (family_found == false){
out["status"] = "Family not Found....";
return ret;
}
// we need this job id
if (load_db_record(y, " SELECT * FROM members_jobs WHERE id =%lu", in["job_id"].Long())) {
// valid load of job needed
} else {
out["status"] = "Unable to create offer";
return ret;
}
load_db_record(u,"SELECT code AS currency FROM currency WHERE country = '%s'", y["country"].c_str() );
logfmt(logINFO, " The Currency code = %s", u["currency"].c_str());
long wallet_id = CheckWallet( in["member_id"].Long() , u);
logfmt(logINFO, " The wallet_id = %lu", wallet_id);
if (in["client_id"].Long() == in["member_id"].Long()) {
out["status"] = "Unable to create offer";
return ret;
} // same client and member not allowed
if (y["price"].Long() > 0) {
} else {
out["status"] = "Unable to create offer";
return ret;
} // no price zero for job on this path
// Now do you have money to do this ....
z["balance"] = "0";
z["balance"].set_valid(true); // just initialize it
if (load_db_record(z, " SELECT * FROM members_wallet WHERE id =%lu AND member_id =%lu AND amount >= %lu",wallet_id, in["member_id"].Long(), y["price"].Long())) {
} else {
out["status"] = "Insufficient balance to create this offer";
logfmt(logINFO, "Price2 = %lu Balance = %lu", y["price"].Long(), z["amount"].Long());
}
// we re ready to create the offer now
x["member_id"] = in["member_id"];
x["member_id"].set_valid(true);
x["job_id"] = in["job_id"];
x["job_id"].set_valid(true);
x["email"] = in["email"];
x["email"].set_valid(true);
x["job_description"] = in["job_description"];
x["job_description"].set_valid(true);
x["offer_code"] = in["offer_code"];
x["offer_code"].set_valid(true);
const char * loc = getenv("REMOTE_ADDR");
x["loc"] = loc;
x["loc"].set_valid(true);
offer_id = insert_db_record(DBS_VALID, "members_jobs_offer", "members_jobs_offer_id_seq", x);
if (offer_id > 0) {
CVars y;
y["member_id"] = x["member_id"];
y["offer_id"] = offer_id;
y["code"] = "OFDPS";
y["dir"] = DIR_TARGET;
if (WrenchOfferPayment(y, out) == PHP_CREATED_OK) { // if you reserve pauments
char offer_code[15] = "";
GetOfferCode(offer_id, offer_code, sizeof (offer_code)); // this stamp the offer code directly in that call
pgsql_exec("UPDATE members_jobs_offer SET expire = now() + '1 day',payment_id=%lu WHERE id = %lu", out["payment_id"].Long(), offer_id); // date of expiration will be dynamic latter
ret = PHP_CREATED_OK;
x["offer_id"] = offer_id;
x["offer_id"].set_valid(true);
job_email(JOBS_INDIVIDUAL_OFFER_MAIL, x, out);
load_db_record(out, "SELECT *,id AS offer_id FROM members_jobs_offer WHERE id = %lu ", offer_id);
out["status"] = "Offer sent to recipient";
recommendation_engine(RECOMMEND_OFFERS , y, out); // trigger the card interaction in apps
if ( load_db_record(xy, "SELECT mj.client_id AS member_id, m.uid AS member_uid "
" FROM members_jobs_offer mj "
" LEFT JOIN members m ON m.id = mj.client_id "
" WHERE mj.id = %lu ",offer_id ) > 0 ){
xy["msg"] = "You have a task to start !";
xy["msg"].set_valid(true);
plan_notification(xy, xout);
}
} else {
out["error_msg"] = "error_unable_to_create_fund_for_task";
out["status"] = "Unable to create this offer";
}
} else {
out["status"] = "Unable to create offer";
}
} catch (bad_parameter) {
out["log_status"] = "Invalid Log Action";
}
logfmt(logINFO, "/WrenchSendMediaOfferFamily()");
return ret;
}
long WrenchSendJobsOfferFamily(CVars in, CVars &out) {
long ret = PHP_API_BAD_PARAM;
logfmt(logINFO, "WrenchSendJobsOfferFamily()");