From 062e30f89b966d513ce97e6212c8b747cd87570b Mon Sep 17 00:00:00 2001 From: Olusesan Ameye Date: Mon, 20 Jun 2022 10:36:08 -0400 Subject: [PATCH] fix --- wrenchboard/src/shared_tool/coupons.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wrenchboard/src/shared_tool/coupons.cc b/wrenchboard/src/shared_tool/coupons.cc index a3611e1b..100c27df 100644 --- a/wrenchboard/src/shared_tool/coupons.cc +++ b/wrenchboard/src/shared_tool/coupons.cc @@ -56,10 +56,12 @@ logfmt(logINFO, "coupons_calls()"); break; case WRENCHBOARD_COUPON_MEMLIST: // member list + in["mode"] = 100; in["mode"].set_valid( true ); return MemberCouponList(in, out); break; case WRENCHBOARD_COUPON_PENDLIST: // member list + in["mode"] = 200; in["mode"].set_valid( true ); return MemberCouponList(in, out); break; @@ -179,9 +181,18 @@ long MemberCouponList( CVars in, CVars &out ){ try { REQ_LONG(in, "member_id", 1, -1); + long mode = REQ_LONG(in, "mode", 1, -1); + + in["active_q"] = "ca.active IS NOT NULL"; + if ( mode == 200 ){ + in["active_q"] = "ca.active IS NULL"; + } + in["active_q"].set_valid( true ); + out["total_record"] = "0"; const PGresult *res; - res = pgsql_query("SELECT id AS coupon_id, ca.code, ca.amount, ca.added::date,ca.status FROM coupons_allocation ca WHERE ca.member_id = %lu AND ca.active IS NULL ORDER BY ca.id DESC", in["member_id"].Long()); + + res = pgsql_query("SELECT id AS coupon_id, ca.code, ca.amount, ca.added::date,ca.status FROM coupons_allocation ca WHERE ca.member_id = %lu AND %s ORDER BY ca.id DESC", in["member_id"].Long(),in["active_q"].c_str()); if (res != NULL && pgsql_num_rows(res) > 0) { out["total_record"] = pgsql_num_rows(res);