From 53dcb43ce1f786232656fa7f65a785ed0ff75b1c Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 11 Nov 2023 11:34:50 -0500 Subject: [PATCH] wallet default --- wrenchboard/src/shared_tool/payments.cc | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/wrenchboard/src/shared_tool/payments.cc b/wrenchboard/src/shared_tool/payments.cc index 195a5d24..961c2750 100644 --- a/wrenchboard/src/shared_tool/payments.cc +++ b/wrenchboard/src/shared_tool/payments.cc @@ -838,9 +838,22 @@ Foreign-key constraints: REQ_STRING (in, "code", 4, 5, "(.*)"); REQ_LONG( in, "dir", 1, -1 ); REQ_LONG( in, "offer_id", 1, -1 ); - + + + long retDb2 = load_db_record( out, "SELECT jj.price,0 as fee,c.code AS currency FROM members_jobs_offer j " + " LEFT JOIN members_jobs jj ON jj.id=j.job_id LEFT JOIN currency c ON c.country=jj.country WHERE j.id =%lu ",in["offer_id"].Long()); + if (retDb2 > 0) + { in["amount"] =out["price"]; in["amount"].set_valid( true ); // get this one LIVE + in["fee"] =out["fee"]; in["fee"].set_valid( true ); // get this one LIVE + } + else + { out["status"] = "Invalid offer"; + return PHP_API_BAD_PARAM; + } + + CVars vw; - vw["currency"] = "NAIRA"; // this might become a variable based on the country + vw["currency"] = out["currency"]; // ""NAIRA"; // this might become a variable based on the country vw["currency"].set_valid( true ); long wallet_id = CheckWallet(in["member_id"].Long(),vw); @@ -854,15 +867,7 @@ Foreign-key constraints: return PHP_API_BAD_PARAM; } - long retDb2 = load_db_record( out, "SELECT jj.price,0 as fee FROM members_jobs_offer j LEFT JOIN members_jobs jj ON jj.id=j.job_id WHERE j.id =%lu ",in["offer_id"].Long()); - if (retDb2) - { in["amount"] =out["price"]; in["amount"].set_valid( true ); // get this one LIVE - in["fee"] =out["fee"]; in["fee"].set_valid( true ); // get this one LIVE - } - else - { out["status"] = "Invalid offer"; - return PHP_API_BAD_PARAM; - } + long totalAmount = in["amount"].Long() + in["fee"].Long(); if ( in["curr_balance"] < in["amount"].Long() + in["fee"].Long()) {