long ReferEmailsCleanup()

This commit is contained in:
CHIEFSOFT\ameye
2024-11-28 10:37:27 -05:00
parent b5c9747774
commit 2c83410442
+36
View File
@@ -39,6 +39,7 @@ long RefreshBlogs(CVars in, CVars &out);
long RefreshPromoActivities(CVars in, CVars &out);
long RegisterPromoPoint(CVars in);
long RegisterPromoAction(CVars in);
long ReferEmailsCleanup();
/*
CREATE TABLE cron_jobs (
@@ -270,6 +271,7 @@ long RefreshPromoActivities(CVars in, CVars &out){
}
}
ReferEmailsCleanup(); // clean up account refer
ret = PHP_API_OK;
out["status"] = "OK";
@@ -280,6 +282,40 @@ long RefreshPromoActivities(CVars in, CVars &out){
return ret;
}
long ReferEmailsCleanup(){
logfmt(logINFO, "ReferEmailsCleanup() *** **** **** ENTRY");
char vname[30];
long ret = PHP_API_BAD_PARAM;
out["total_record"] = "0";
const PGresult *res, *resF;
// check if pending
res = pgsql_query("SELECT id, email ,added, status FROM members_refer_friend WHERE status =1 AND added < now() + '-14 days' LIMIT 20");
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++) {
map<const char*, const char*>f = pgsql_fetch_assoc(res, i);
if (f.empty()) continue;
CVars rec;
map_to_cvars(f, rec);
// check if on pending table
const PGresult *res1 = pgsql_query("SELECT * FROM members WHERE email='%s'", rec["email"].c_str());
if (res1 != NULL && pgsql_num_rows(res1) > 0) {
out["status"] = "Unable to add this email";
pgsql_query("UPDATE members_refer_friend SET status = 5 WHERE status = 1 AND email = '%s' AND id=%lu", rec["email"].c_str(), rec["id"].Long());
}
else{
pgsql_query("UPDATE members_refer_friend SET status = 0 WHERE status = 1 AND email = '%s' AND id=%lu", rec["email"].c_str(), rec["id"].Long());
}
}
}
return 0;
}
long RegisterPromoPoint(CVars in){
/*
CREATE TABLE promo_points(