From ef3548f17d88c9db5db8bbb03efd25bb525e6bd2 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 23 Sep 2024 05:59:21 -0400 Subject: [PATCH] offer id --- wrenchboard/src/shared_tool/site_crons.cc | 43 +++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/wrenchboard/src/shared_tool/site_crons.cc b/wrenchboard/src/shared_tool/site_crons.cc index d62d96bc..ffaa07cc 100644 --- a/wrenchboard/src/shared_tool/site_crons.cc +++ b/wrenchboard/src/shared_tool/site_crons.cc @@ -156,12 +156,43 @@ long sitecrons_calls(CVars in, CVars &out) { } long ProcessExpiredOffers(CVars in, CVars &out){ -// if ( load_db_record(out, "SELECT count(uid) AS pending_count FROM money_transfer WHERE status =1 AND completed IS NULL ")> 0){ -// if ( out["pending_count"].Long() > 0 ){ -// alert_email(WRB_CRONJOB_PENDINGSM,out, out); -// } -// } -return 0; + char vname[30]; + long ret = PHP_API_BAD_PARAM; + try { + out["total_record"] = "0"; + const PGresult *res; + res = pgsql_query("SELECT status,member_id, id AS offer_id, uid,offer_code FROM members_jobs_offer " + " WHERE expire< now() " + " AND status = 1 " + " AND refund_auto IS NULL " + " ORDER BY id ASC LIMIT 10"); + + 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); + pgsql_query("UPDATE members_jobs_offer SET refund_auto= now(), updated = now() " + " WHERE id = %lu AND uid::text = '%s' ", rec["offer_id"].Long(),rec["uid"].c_str()); // move the status so no retry + } + } + ret = PHP_API_OK; + out["status"] = "OK"; + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long ProcessExpiredOffers(CVars in, CVars &out)"); + } + + + + + + + + logfmt(logINFO, "/ProcessExpiredOffers()"); + return ret; } long ProcessTransferJobs(CVars in, CVars &out){