diff --git a/wrenchboard/src/shared_tool/jobs.cc b/wrenchboard/src/shared_tool/jobs.cc index c189d92d..e3c8e50d 100644 --- a/wrenchboard/src/shared_tool/jobs.cc +++ b/wrenchboard/src/shared_tool/jobs.cc @@ -1198,19 +1198,7 @@ long WrenchConcludeJobsOffer(CVars in, CVars &out) { 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); @@ -1219,8 +1207,10 @@ long WrenchSendMediaOfferFamily(CVars in, CVars &out) { 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, "(.*)"); + REQ_LONG(in, "timeline_days", 1, -1); + REQ_STRING(in, "currency", 2, 4, "(.*)"); + long job_id = 0; srand((unsigned) time(NULL)); int r = rand(); in["offer_code"] = 10000000 * r*r; @@ -1228,33 +1218,6 @@ long WrenchSendMediaOfferFamily(CVars in, CVars &out) { 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; @@ -1283,14 +1246,14 @@ long WrenchSendMediaOfferFamily(CVars in, CVars &out) { } // we need this job id - if (load_db_record(y, " SELECT * FROM members_jobs WHERE id =%lu", in["job_id"].Long())) { + if (load_db_record(y, " SELECT * FROM common_media WHERE id ='%s'", in["media_uid"].c_str())) { // 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() ); + load_db_record(u,"SELECT code AS currency FROM currency WHERE country = '%s'", in["currency"].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); @@ -1316,14 +1279,48 @@ long WrenchSendMediaOfferFamily(CVars in, CVars &out) { logfmt(logINFO, "Price2 = %lu Balance = %lu", y["price"].Long(), z["amount"].Long()); } +//*************************************** + CVars x; + x["member_id"] = in["member_id"]; + x["member_id"].set_valid(true); + x["title"] = y["title"]; + x["title"].set_valid(true); + x["price"] = in["amount"]; + x["price"].set_valid(true); + x["timeline_days"] = in["timeline_days"]; + x["timeline_days"].set_valid(true); + x["description"] = y["description"]; + x["description"].set_valid(true); + x["loc"] = in["loc"]; + x["loc"].set_valid(true); + x["job_detail"] = in["job_description"]; + x["job_detail"].set_valid(true); + //country added + x["country"] = in["country"]; + x["country"].set_valid(true); + + x["job_type"] = "MEDIA"; + x["job_type"].set_valid(true); + + x["media_uid"] = in["media_uid"]; + x["media_uid"].set_valid(true); + + + job_id = insert_db_record(DBS_VALID, "members_jobs", "members_jobs_id_seq", x); + + if (job_id) { + + } + +//*************************************** // 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"] = job_id; x["job_id"].set_valid(true); - x["email"] = in["email"]; - x["email"].set_valid(true); + x["media_uid"] = in["media_uid"]; + x["media_uid"].set_valid(true); x["job_description"] = in["job_description"]; x["job_description"].set_valid(true); x["offer_code"] = in["offer_code"]; @@ -1344,7 +1341,7 @@ long WrenchSendMediaOfferFamily(CVars in, CVars &out) { 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 + pgsql_exec("UPDATE members_jobs_offer SET expire = now() + '2 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;