From dbe3e6d136e8fa80a51c9877375d0065c2125efa Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Tue, 24 Oct 2023 04:47:30 -0400 Subject: [PATCH] family wallet --- wrenchboard/src/include/account.h | 18 +++++ wrenchboard/src/shared_tool/account.cc | 18 +---- wrenchboard/src/shared_tool/family_acc.cc | 81 ++++++++++++++++++++++- www-api/app/Models/ResultFormatter.php | 1 + 4 files changed, 98 insertions(+), 20 deletions(-) diff --git a/wrenchboard/src/include/account.h b/wrenchboard/src/include/account.h index 918e03f3..34635fc6 100644 --- a/wrenchboard/src/include/account.h +++ b/wrenchboard/src/include/account.h @@ -40,5 +40,23 @@ long WrenchUpdateSiteGallery(CVars in, CVars &out); long WrenchReturnStartJobList(CVars in, CVars &out); long WrenchLoadDashData(CVars in, CVars &out); +long LoginLogger( long member_id, long login_mode); +long WrenchBoardMobileSendMoney(CVars in, CVars &out); +long WrenchBoardMobileSendJobInterest(CVars in, CVars &out); +long WrenchReturnPendingJobList(CVars in, CVars &out); +long WrenchBoardMobileSendUserWallet(CVars in, CVars &out); +long WrenchBoardStartBalanceTopup(CVars in, CVars &out); +long WrenchBoardCompleteBalanceTopup(CVars in, CVars &out); +long WrenchResendSendReferLoadLink(CVars in, CVars &out); +long WrenchBoardDeleteAccount(CVars in, CVars &out); +long VerifyWrenchAccountLink(CVars in, CVars &out); +long LoginWrenchBoardAuxAccount(CVars in, CVars &out); +long WrenchDeleteUsersCCard(CVars in, CVars &out); +long WrenchFlutterCreditHook(CVars in, CVars &out); +long WrenchBoardTopupResult(CVars in, CVars &out); +long WrenchRegisterMyFileUpload(CVars in, CVars &out); +long WrenchGetRecentDash(CVars in, CVars &out); +long LoginWrenchBoardQRAccount(CVars in, CVars &out); + #endif diff --git a/wrenchboard/src/shared_tool/account.cc b/wrenchboard/src/shared_tool/account.cc index 64c663ec..a29fc2ee 100644 --- a/wrenchboard/src/shared_tool/account.cc +++ b/wrenchboard/src/shared_tool/account.cc @@ -113,23 +113,7 @@ status INT DEFAULT 1, created timestamp without time zone DEFAULT now() ); */ -long LoginLogger( long member_id, long login_mode); -long WrenchBoardMobileSendMoney(CVars in, CVars &out); -long WrenchBoardMobileSendJobInterest(CVars in, CVars &out); -long WrenchReturnPendingJobList(CVars in, CVars &out); -long WrenchBoardMobileSendUserWallet(CVars in, CVars &out); -long WrenchBoardStartBalanceTopup(CVars in, CVars &out); -long WrenchBoardCompleteBalanceTopup(CVars in, CVars &out); -long WrenchResendSendReferLoadLink(CVars in, CVars &out); -long WrenchBoardDeleteAccount(CVars in, CVars &out); -long VerifyWrenchAccountLink(CVars in, CVars &out); -long LoginWrenchBoardAuxAccount(CVars in, CVars &out); -long WrenchDeleteUsersCCard(CVars in, CVars &out); -long WrenchFlutterCreditHook(CVars in, CVars &out); -long WrenchBoardTopupResult(CVars in, CVars &out); -long WrenchRegisterMyFileUpload(CVars in, CVars &out); -long WrenchGetRecentDash(CVars in, CVars &out); -long LoginWrenchBoardQRAccount(CVars in, CVars &out); + long test() { FILE* oldFile = Output2FILE::Stream(); diff --git a/wrenchboard/src/shared_tool/family_acc.cc b/wrenchboard/src/shared_tool/family_acc.cc index 6997315e..446a8398 100644 --- a/wrenchboard/src/shared_tool/family_acc.cc +++ b/wrenchboard/src/shared_tool/family_acc.cc @@ -16,9 +16,10 @@ #include "jobs_manager.h" #include "family_acc.h" #include "common_tool.h" +#include "account.h" long WrenchFamilyList(CVars in, CVars &out); -long WrenchFamilyWallet(CVars in, CVars &out); +long WrenchFamilyWallet(CVars in, CVars &out); long WrenchFamilyAdd(CVars in, CVars &out); long WrenchFamilyUpdate(CVars in, CVars &out); long WrenchFamilyManage(CVars in, CVars &out); @@ -385,9 +386,83 @@ long WrenchSampleTasks(CVars in, CVars &out){ } long WrenchFamilyWallet(CVars in, CVars &out){ - logfmt(logINFO, "ENTER CALL long WrenchFamilyWallet"); + logfmt(logINFO, "ENTER CALL long WrenchFamilyWallet"); + char vname[30]; + long ret = PHP_API_BAD_PARAM; + const PGresult *res0; - + try { + long member_id = REQ_LONG(in, "member_id", 1, -1); + REQ_STRING(in, "family_uid", 2, 50, "(.*)"); + REQ_STRING(in, "uid", 2, 50, "(.*)"); + REQ_STRING(in, "sessionid", 2, 149, "(.*)"); + 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) { + mapf = pgsql_fetch_assoc(res0, 0); + map_to_cvars(f, rec0); + } + else{ + return 0; + } + + + + out["total_record"] = "0"; + const PGresult *res; + res = pgsql_query("SELECT w.amount,c.*,w.amount AS current_balance,c.country,w.transfer_limit,w.uid AS wallet_uid " + "FROM members_wallet w LEFT JOIN currency c ON c.code=w.currency " + "WHERE w.member_id = %lu ORDER BY c.lorder DESC", rec0["family_member_id"].Long()); + + if (res != NULL && pgsql_num_rows(res) > 0) { + out["total_record"] = pgsql_num_rows(res); + + for (int i = 0, n = pgsql_num_rows(res); i < n; i++) { + mapf = pgsql_fetch_assoc(res, i); + if (f.empty()) continue; + CVars rec; + map_to_cvars(f, rec); + + snprintf(vname, sizeof (vname), "amount_%05d", i); + out[vname] = rec["amount"]; + snprintf(vname, sizeof (vname), "currency_%05d", i); + out[vname] = rec["currency"]; + + // amount | id | code | description | symbol | action_type | lorder | current_balance + snprintf(vname, sizeof (vname), "description_%05d", i); + out[vname] = rec["description"]; + + snprintf(vname, sizeof (vname), "symbol_%05d", i); + out[vname] = rec["symbol"]; + + snprintf(vname, sizeof (vname), "action_type_%05d", i); + out[vname] = rec["action_type"]; + + snprintf(vname, sizeof (vname), "code_%05d", i); + out[vname] = rec["code"]; + + snprintf(vname, sizeof (vname), "country_%05d", i); + out[vname] = rec["country"]; + + snprintf(vname, sizeof (vname), "transfer_limit_%05d", i); + out[vname] = rec["transfer_limit"]; + + snprintf(vname, sizeof (vname), "wallet_uid_%05d", i); + out[vname] = rec["wallet_uid"]; + + + } + } + ret = PHP_API_OK; + out["status"] = "OK"; + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long WrenchFamilyWallet(CVars in, CVars &out)"); + } logfmt(logINFO, "EXIT CALL long WrenchFamilyWallet"); return 0; diff --git a/www-api/app/Models/ResultFormatter.php b/www-api/app/Models/ResultFormatter.php index 628495bc..84c725e6 100644 --- a/www-api/app/Models/ResultFormatter.php +++ b/www-api/app/Models/ResultFormatter.php @@ -761,6 +761,7 @@ class ResultFormatter extends Model break; case WRENCHBOARD_ACCOUNT_WALLETS: + case WRENCHBOARD_FAMILY_WALLET: $total = $out["total_record"]; $res = array( "status" => $out["status"],