fix transfer

This commit is contained in:
CHIEFSOFT\ameye
2023-10-28 09:37:04 -04:00
parent 45a0170d88
commit 4072ce65e5
+25 -8
View File
@@ -401,6 +401,7 @@ long WrenchFamilyTransfer(CVars in, CVars &out){
long ret = PHP_API_BAD_PARAM;
long family_member_id = 0;
const PGresult *res0;
int err_count = 0;
try {
/*
@@ -427,7 +428,7 @@ long WrenchFamilyTransfer(CVars in, CVars &out){
logfmt(logINFO, "WrenchFamilyWallet() Verify Session ");
CVars rec0;
if ( VerifySession(in, out) != PHP_API_OK ){
return 0;
return ret;
}
res0 = pgsql_query("SELECT family_member_id FROM members_family WHERE member_id = %lu AND uid='%s' ", in["member_id"].Long(), in["family_uid"].c_str());
@@ -437,7 +438,8 @@ long WrenchFamilyTransfer(CVars in, CVars &out){
family_member_id = rec0["family_member_id"].Long();
}
else{
return 0;
out["status"] = "Family not found";
return ret;
}
out["total_record"] = "0";
@@ -448,7 +450,6 @@ long WrenchFamilyTransfer(CVars in, CVars &out){
if (res != NULL && pgsql_num_rows(res) > 0) {
out["total_record"] = pgsql_num_rows(res);
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
CVars rec;
map_to_cvars(f, rec);
@@ -457,18 +458,34 @@ long WrenchFamilyTransfer(CVars in, CVars &out){
if( load_db_record(out,"SELECT w.amount AS origing_current_balance,w.uid AS origing_wallet_uid,"
" w.transfer_limit AS origing_transfer_limit, w.currency as origing_currency "
" FROM members_wallet w "
" WHERE w.member_id = %lu AND w.currency='%s'", in["member_id"].Long(), out["currency"].c_str()) ){
ret = PHP_API_OK;
" WHERE w.member_id = %lu AND w.currency='%s' AND w.uid='%s'", in["member_id"].Long(), out["currency"].c_str(), in["origing_wallet_uid"].c_str()) ){
if (in["amount"].Long() > out["transfer_limit"].Long() ){
err_count++;
out["error_limit"] = "amount_greater_than_limit";
}
if (in["amount"].Long() > out["origing_current_balance"].Long() ){
err_count++;
out["error_balance"] = "amount_greater_than_balance";
}
if (err_count> 0){
out["status"] = "Send Error";
return ret;
}
out["status"] = "OK";
out["exchange_rate"] ="1";
ret = PHP_API_OK;
}
else{
out["status"] = "Originating wallet not found";
}
}
ret = PHP_API_OK;
out["status"] = "OK";
} catch (bad_parameter) {
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long WrenchFamilyTransfer(CVars in, CVars &out)");
}