fix
This commit is contained in:
@@ -508,6 +508,8 @@ long CreateWrenchBoardAccount(CVars in, CVars &out) {
|
|||||||
ret = insert_db_record(DBS_VALID, "members", "members_id_seq", x);
|
ret = insert_db_record(DBS_VALID, "members", "members_id_seq", x);
|
||||||
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
|
|
||||||
|
|
||||||
out["member_id"] = ret;
|
out["member_id"] = ret;
|
||||||
out["member_id"].set_valid(true);
|
out["member_id"].set_valid(true);
|
||||||
x["member_id"] = ret;
|
x["member_id"] = ret;
|
||||||
@@ -515,10 +517,16 @@ long CreateWrenchBoardAccount(CVars in, CVars &out) {
|
|||||||
x["pending_id"] = out["pending_id"];
|
x["pending_id"] = out["pending_id"];
|
||||||
x["pending_id"].set_valid(true);
|
x["pending_id"].set_valid(true);
|
||||||
|
|
||||||
|
CVars u;
|
||||||
|
load_db_record(u,"SELECT code AS currency FROM currency WHERE country = '%s'", x["country"].c_str() );
|
||||||
|
logfmt(logINFO, " The Currency code = %s", u["currency"].c_str());
|
||||||
|
out["wallet_id"] = CheckWallet( x["member_id"].Long() , u);
|
||||||
|
logfmt(logINFO, " The wallet_id = %lu", out["wallet_id"].Long());
|
||||||
|
|
||||||
CVars vw;
|
CVars vw;
|
||||||
vw["currency"] = "NAIRA"; // this will become a variable based on the country
|
// vw["currency"] = "NAIRA"; // this will become a variable based on the country
|
||||||
vw["currency"].set_valid( true );
|
// vw["currency"].set_valid( true );
|
||||||
out["wallet_id"] = CheckWallet(out["member_id"].Long(),vw); // initial wallet
|
// out["wallet_id"] = CheckWallet(out["member_id"].Long(),vw); // initial wallet
|
||||||
|
|
||||||
// - password already set pgsql_query("UPDATE members SET password = md5('%s') WHERE id = %lu",in["pass1"].c_str(),ret);
|
// - password already set pgsql_query("UPDATE members SET password = md5('%s') WHERE id = %lu",in["pass1"].c_str(),ret);
|
||||||
pgsql_query("UPDATE members_pending SET status = 5 WHERE id = %lu", out["pending_id"].Long());
|
pgsql_query("UPDATE members_pending SET status = 5 WHERE id = %lu", out["pending_id"].Long());
|
||||||
|
|||||||
@@ -705,7 +705,7 @@ long WrenchSendJobsOfferPublic(CVars in, CVars &out) {
|
|||||||
CVars x;
|
CVars x;
|
||||||
CVars y;
|
CVars y;
|
||||||
CVars z;
|
CVars z;
|
||||||
|
CVars u;
|
||||||
|
|
||||||
|
|
||||||
// we need this job id
|
// we need this job id
|
||||||
@@ -716,6 +716,10 @@ long WrenchSendJobsOfferPublic(CVars in, CVars &out) {
|
|||||||
return ret;
|
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 (y["price"].Long() > 0) {
|
if (y["price"].Long() > 0) {
|
||||||
} else {
|
} else {
|
||||||
@@ -726,20 +730,20 @@ long WrenchSendJobsOfferPublic(CVars in, CVars &out) {
|
|||||||
// Now do you have money to do this ....
|
// Now do you have money to do this ....
|
||||||
z["balance"] = "0";
|
z["balance"] = "0";
|
||||||
z["balance"].set_valid(true); // just initialize it
|
z["balance"].set_valid(true); // just initialize it
|
||||||
if (load_db_record(z, " SELECT * FROM members WHERE id =%lu AND balance >= %lu", in["member_id"].Long(), y["price"].Long())) {
|
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 {
|
} else {
|
||||||
out["status"] = "Insuficient balancde to create this offer";
|
out["status"] = "Insufficient balance to create this offer";
|
||||||
logfmt(logINFO, "Price2 = %lu Balance = %lu", y["price"].Long(), z["balance"].Long());
|
logfmt(logINFO, "Price2 = %lu Balance = %lu", y["price"].Long(), z["amount"].Long());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y["price"].Long() >= z["balance"].Long()) {
|
if (y["price"].Long() >= z["amount"].Long()) {
|
||||||
out["status"] = "Insuficient balancde to create this offer";
|
out["status"] = "Insufficient balance to create this offer";
|
||||||
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long(), z["balance"].Long());
|
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long(), z["amount"].Long());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long(), z["balance"].Long());
|
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long(), z["amount"].Long());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// if ( load_db_record( out, "SELECT count(id) AS duplicate_name FROM members_jobs_offer WHERE LOWER(group_name)=LOWER('%s') AND member_id =%lu AND status = 1",in["group_name"].c_str(), in["member_id"].Long() ))
|
// if ( load_db_record( out, "SELECT count(id) AS duplicate_name FROM members_jobs_offer WHERE LOWER(group_name)=LOWER('%s') AND member_id =%lu AND status = 1",in["group_name"].c_str(), in["member_id"].Long() ))
|
||||||
@@ -811,6 +815,7 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) {
|
|||||||
CVars x;
|
CVars x;
|
||||||
CVars y;
|
CVars y;
|
||||||
CVars z;
|
CVars z;
|
||||||
|
CVars u;
|
||||||
|
|
||||||
long total_member = 0;
|
long total_member = 0;
|
||||||
load_db_record(out, "SELECT count(id) AS m_count FROM members_job_groupmember WHERE group_id = %lu AND member_id= %lu", in["group_id"].Long(), in["member_id"].Long());
|
load_db_record(out, "SELECT count(id) AS m_count FROM members_job_groupmember WHERE group_id = %lu AND member_id= %lu", in["group_id"].Long(), in["member_id"].Long());
|
||||||
@@ -825,6 +830,7 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// we need this job id
|
// 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 members_jobs WHERE id =%lu", in["job_id"].Long())) {
|
||||||
// valid load of job needed
|
// valid load of job needed
|
||||||
@@ -833,6 +839,10 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) {
|
|||||||
return ret;
|
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 (y["price"].Long() > 0) {
|
if (y["price"].Long() > 0) {
|
||||||
} else {
|
} else {
|
||||||
@@ -841,20 +851,32 @@ long WrenchSendJobsOfferGroup(CVars in, CVars &out) {
|
|||||||
} // no price zero for job on this path
|
} // no price zero for job on this path
|
||||||
|
|
||||||
// Now do you have money to do this ....
|
// Now do you have money to do this ....
|
||||||
if (load_db_record(z, " SELECT * FROM members WHERE id =%lu AND balance >= %lu", in["member_id"].Long(), y["price"].Long())) {
|
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 {
|
} else {
|
||||||
|
out["status"] = "Insufficient balance to create this offer";
|
||||||
|
logfmt(logINFO, "Price2 = %lu Balance = %lu", y["price"].Long(), z["balance"].Long());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y["price"].Long() * total_member >= z["balance"].Long()) // note that we have all members here for the price
|
if (y["price"].Long() >= z["amount"].Long()) {
|
||||||
{
|
out["status"] = "Insufficient balance to create this offer";
|
||||||
out["status"] = "Insuficient balancde to create this offer";
|
|
||||||
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long(), z["balance"].Long());
|
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long(), z["balance"].Long());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long() * total_member, z["balance"].Long());
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
if (y["price"].Long() * total_member >= z["balance"].Long()) // note that we have all members here for the price
|
||||||
|
{
|
||||||
|
out["status"] = "Insufficient balance to create this offer";
|
||||||
|
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long(), z["balance"].Long());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
logfmt(logINFO, "Price = %lu Balance = %lu", y["price"].Long() * total_member, z["amount"].Long());
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user