From 9b1769193b86c06bbc48662496d22286375552cb Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sun, 24 Nov 2024 16:57:31 -0500 Subject: [PATCH] POINT ADDED --- wrenchboard/src/shared_tool/site_crons.cc | 47 ++++++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/wrenchboard/src/shared_tool/site_crons.cc b/wrenchboard/src/shared_tool/site_crons.cc index 3b6e2cf8..c9a7d8bc 100644 --- a/wrenchboard/src/shared_tool/site_crons.cc +++ b/wrenchboard/src/shared_tool/site_crons.cc @@ -281,17 +281,52 @@ long RefreshPromoActivities(CVars in, CVars &out){ } long RegisterPromoPoint(CVars in){ +/* +CREATE TABLE promo_points( + id SERIAL, + uid uuid DEFAULT uuid_generate_v4(), + admin_id INT REFERENCES promo_admin(id), + category VARCHAR(50) NOT NULL, + point INT DEFAULT 0, + added timestamp without time zone DEFAULT now() + ); + ALTER TABLE ONLY promo_points + ADD CONSTRAINT promo_points_id_key UNIQUE (id); + ALTER TABLE promo_admin ADD points INT Default 0; +*/ - CVars yp; - yp["category"] ="SIGNUP_POINT"; - yp["admin_id"] = in["admin_id"]; yp["admin_id"].set_valid( true ); - yp["description"] = "Sign up was completed"; - RegisterPromoAction(yp); - return 0; + long ret = PHP_API_BAD_PARAM; + //const PGresult *res; + CVars xx; + try { + //long blog_id = REQ_LONG(in, "blog_id", 1, -1); + REQ_STRING (in, "category", 5, 49, "(.*)"); + long admin_id = REQ_LONG(in, "admin_id", 1, -1); + long points = REQ_LONG(in, "points", 1, -1); + + xx["category"] = in["category"]; xx["category"].set_valid( true ); + xx["point"] = in["points"]; xx["point"].set_valid( true ); + xx["admin_id"] = in["admin_id"]; xx["admin_id"].set_valid( true ); + long point_id = insert_db_record(DBS_VALID, "promo_points", "promo_points_id_seq", xx); + if( point_id > 0 ){ + pgsql_query("UPDATE promo_admin SET points= points + %lu WHERE id = %lu ", in["points"].Long(), in["admin_id"].Long()); + CVars yp; + yp["category"] ="SIGNUP_POINT"; + yp["admin_id"] = in["admin_id"]; yp["admin_id"].set_valid( true ); + yp["description"] = "Sign up was completed"; + RegisterPromoAction(yp); + + ret = PHP_API_OK; + } + + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long RegisterPromoAction(CVars in, CVars &out)"); + } + return ret; } long RegisterPromoAction(CVars in){