This commit is contained in:
2022-08-06 08:51:32 -04:00
parent 082253aa68
commit e9b0bbc899
+15 -3
View File
@@ -594,6 +594,7 @@ long WrenchSendJobsOfferIndividual(CVars in, CVars &out) {
in["client_id"] = "0";
CVars x;
CVars y;
CVars u;
CVars z;
try {
@@ -615,6 +616,11 @@ long WrenchSendJobsOfferIndividual(CVars in, CVars &out) {
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;
@@ -626,10 +632,16 @@ long WrenchSendJobsOfferIndividual(CVars in, CVars &out) {
return ret;
} // no price zero for job on this path
// 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())) {
// 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"];