Family transfer
This commit is contained in:
@@ -29,6 +29,7 @@ long WrenchSuggestList(CVars in, CVars &out);
|
||||
long WrenchSuggestWaitingList(CVars in, CVars &out);
|
||||
long WrenchSuggestTaskStatus(CVars in, CVars &out);
|
||||
long WrenchFamilyTransferStart(CVars in, CVars &out);
|
||||
long WrenchFamilyTransfer(CVars in, CVars &out);
|
||||
|
||||
long family_calls(CVars in, CVars &out){
|
||||
logfmt(logINFO, "family_calls()");
|
||||
@@ -54,7 +55,7 @@ long family_calls(CVars in, CVars &out){
|
||||
break;
|
||||
|
||||
case WRENCHBOARD_FAMILY_TRANSFER:
|
||||
|
||||
return WrenchFamilyTransfer(in, out
|
||||
break;
|
||||
|
||||
case WRENCHBOARD_FAMILY_SAMPLETASKS:
|
||||
@@ -394,6 +395,87 @@ long WrenchSampleTasks(CVars in, CVars &out){
|
||||
return ret;
|
||||
}
|
||||
|
||||
long WrenchFamilyTransfer(CVars in, CVars &out){
|
||||
logfmt(logINFO, "ENTER CALL long WrenchFamilyTransfer");
|
||||
char vname[30];
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
long family_member_id = 0;
|
||||
const PGresult *res0;
|
||||
|
||||
try {
|
||||
/*
|
||||
member_id' => int 1
|
||||
'sessionid' => string '64C3E325C554381B055233298A267198A1F19251E2DBD04634B3E6A58847DC0B' (length=64)
|
||||
'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36)
|
||||
'family_uid' => string '1f385837-b5e6-420e-a17a-488c4b8ef015' (length=36)
|
||||
'wallet_uid' => string 'aa6e6488-2e71-4f83-b265-27c3c4339f73' (length=36)
|
||||
'origing_wallet_uid' => string 'cc0f8743-3f18-4214-ba4b-781e5dda9cb8' (length=36)
|
||||
'currency' => string 'NAIRA' (length=5)
|
||||
'amount' => int 100500
|
||||
'family_transfer_mode' => int 100
|
||||
*/
|
||||
}
|
||||
long member_id = REQ_LONG(in, "member_id", 1, -1);
|
||||
long amount = REQ_LONG(in, "amount", 1, -1);
|
||||
REQ_STRING(in, "family_uid", 2, 50, "(.*)");
|
||||
REQ_STRING(in, "uid", 2, 50, "(.*)");
|
||||
REQ_STRING(in, "wallet_uid", 2, 50, "(.*)");
|
||||
REQ_STRING(in, "origing_wallet_uid", 2, 50, "(.*)");
|
||||
REQ_STRING(in, "sessionid", 2, 149, "(.*)");
|
||||
REQ_STRING(in, "currency", 2, 20, "(.*)");
|
||||
logfmt(logINFO, "WrenchFamilyWallet() Verify Session ");
|
||||
CVars rec0;
|
||||
if ( VerifySession(in, out) != PHP_API_OK ){
|
||||
return 0;
|
||||
}
|
||||
|
||||
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());
|
||||
if (res0 != NULL && pgsql_num_rows(res0) > 0) {
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res0, 0);
|
||||
map_to_cvars(f, rec0);
|
||||
family_member_id = rec0["family_member_id"].Long();
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
out["total_record"] = "0";
|
||||
const PGresult *res;
|
||||
res = pgsql_query("SELECT w.amount AS current_balance, w.currency, w.uid AS recipient_wallet_uid "
|
||||
"FROM members_wallet w LEFT JOIN currency c ON c.code=w.currency "
|
||||
"WHERE w.member_id = %lu AND w.uid='%s' ORDER BY c.lorder DESC", rec0["family_member_id"].Long(), in["wallet_uid"].c_str());
|
||||
|
||||
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);
|
||||
out = rec;
|
||||
// lets get the parent wallet too
|
||||
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;
|
||||
out["status"] = "OK";
|
||||
out["exchange_rate"] ="1";
|
||||
}
|
||||
else{
|
||||
out["status"] = "Originating wallet not found";
|
||||
}
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL long WrenchFamilyTransfer(CVars in, CVars &out)");
|
||||
}
|
||||
|
||||
logfmt(logINFO, "EXIT CALL long WrenchFamilyTransfer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
long WrenchFamilyTransferStart(CVars in, CVars &out){
|
||||
logfmt(logINFO, "ENTER CALL long WrenchFamilyWallet");
|
||||
char vname[30];
|
||||
|
||||
Reference in New Issue
Block a user