family transfer

This commit is contained in:
CHIEFSOFT\ameye
2023-10-28 13:03:16 -04:00
parent 5b7bb564b0
commit bfcb1dd095
2 changed files with 61 additions and 13 deletions
+8 -7
View File
@@ -141,8 +141,8 @@ long WrenchFamilyPayment( CVars in, CVars &out )
in["curr_balance"] ="0";
long retDb = load_db_record( out, "SELECT amount AS curr_balance FROM members_wallet "
" WHERE member_id = %lu AND currency='%s' AND uid = '%s'", member_id, vw["currency"].c_str(), in["origing_wallet_uid"].c_str());
if (retDb)
" WHERE member_id = %lu AND currency='%s' AND uid = '%s'", member_id, vw["currency"].c_str(), in["origing_wallet"].c_str());
if (retDb > 0 )
{ in["curr_balance"] =out["curr_balance"]; in["curr_balance"].set_valid( true );
logfmt(FLOG_MAX, "Current balance Read ********************" );
}
@@ -151,7 +151,8 @@ long WrenchFamilyPayment( CVars in, CVars &out )
return ret; /* unable to read wallet*/ }
long retDb2 = load_db_record( out, "SELECT * FROM family_transfer WHERE member_id = %lu AND code ='%s' AND id = %lu AND active IS NULL", in["member_id"].Long(), in["code"].c_str(),code_id );
long retDb2 = load_db_record( out, "SELECT * FROM family_transfer "
" WHERE member_id = %lu AND code ='%s' AND id = %lu AND active IS NULL", in["member_id"].Long(), in["code"].c_str(),code_id );
if (retDb2>0)
{
in["coupon_amount"] =out["amount"]; in["coupon_amount"].set_valid( true );
@@ -171,7 +172,7 @@ long WrenchFamilyPayment( CVars in, CVars &out )
x["flags"] = FLAG_INIT; x["flags"].set_valid( true ); // starting the pprocess
payment_id = insert_db_record( DBS_VALID, "members_payments", "members_payments_id_seq", x );
payment_id = 0; // insert_db_record( DBS_VALID, "members_payments", "members_payments_id_seq", x );
if (payment_id) {
ret = PHP_CREATED_OK;
@@ -185,15 +186,15 @@ long WrenchFamilyPayment( CVars in, CVars &out )
x["flags"] = FLAG_OK; x["flags"].set_valid( true );
x["payment_id"] = payment_id; x["payment_id"].set_valid( true );
pgsql_exec("UPDATE members_payments SET flags = %lu WHERE id = %lu",x["flags"].Long(),payment_id );
pgsql_exec("UPDATE coupons_allocation SET active = now() WHERE id = %lu AND CODE='%s' ",code_id,in["code"].c_str() );
load_db_record( out, "SELECT * FROM members_payments WHERE id = %lu ", payment_id );
pgsql_exec("UPDATE family_transfer SET active = now() WHERE id = %lu AND CODE='%s' ",code_id,in["code"].c_str() );
load_db_record( out, "SELECT * FROM family_transfer WHERE id = %lu ", payment_id );
} else {
out["status"] = "Unable to create payment";
}
}
else
{ out["status"] = "Invalid coupon";
{ out["status"] = "error_invalid_transfer";
ret= PHP_API_BAD_PARAM;
}