From 3f8222064fe6e4efec41f60dd740c67917f1bbda Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 21 Dec 2024 12:53:26 -0500 Subject: [PATCH] Added actions --- api/controller.js | 7 ++ api/routes.js | 4 +- service/members_action.js | 131 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 service/members_action.js diff --git a/api/controller.js b/api/controller.js index 3d2391f..3c4d7f8 100644 --- a/api/controller.js +++ b/api/controller.js @@ -4,10 +4,17 @@ const properties = require('../package.json') const redeem = require('../service/redeem'); const wallets = require('../service/wallets'); const ebroker = require('../service/ebroker'); +const members_action = require('../service/members_action'); const logger = require('../app/logger'); var controllers = { + refreshMemberActions: function(req, res) { + members_action.refreshActions(req, res, function(err, result) { + res.status(200).json({'status': 'OK', 'internal_return': 0, 'result_list': result.result,'total_record': result.total_record }) + }); + }, + getFamilyBanners: function(req, res) { redeem.getredeemoptions(req, res, function(err, result) { res.status(200).json({'status': 'OK', 'internal_return': 0, 'result_list': result.result,'total_record': result.total_record }) diff --git a/api/routes.js b/api/routes.js index 1dd22a9..86351a0 100644 --- a/api/routes.js +++ b/api/routes.js @@ -3,8 +3,8 @@ const controller = require('./controller'); module.exports = function(app) { - app.route('/redeemoptions') - .get(controller.getFamilyBanners); + app.route('/proc/refreshActions') + .get(controller.refreshMemberActions); app.route('/getwallets') .get(controller.getUsersWallets); diff --git a/service/members_action.js b/service/members_action.js new file mode 100644 index 0000000..23b4d0c --- /dev/null +++ b/service/members_action.js @@ -0,0 +1,131 @@ +'use strict'; + +const request = require('request'); +const db = require('../app/db') +const logger = require('../app/logger'); + +var members_action = { + refreshActions: function (req, res, next) { + + //console.log("REQ---->",req.body.uid); + var data = { + "uid": req.body.uid, + "member_id": req.body.member_id, + "limit": (req.body.limit != null && req.body.limit !== "") ? req.body.limit : 20, + "sessionid": req.body.sessionid, + "page": req.body.page + }; + let Qstring =""; // "SELECT uid,id,username FROM members LIMIT 10"; + let QextraString =""; + if ( req.body.uid != null && req.body.uid !== ""){ + QextraString= " AND j.country IN (SELECT c.country FROM members_wallet w " + + " LEFT JOIN currency c ON c.code =w.currency " + + " LEFT JOIN members m ON m.id = w.member_id " + + " WHERE m.uid = '"+req.body.uid+"' )"; + } + + Qstring = " SELECT j.title,j.description,m.id AS job_id,m.expire,m.job_description,j.price, " + + " m.offer_code,j.timeline_days, to_char(m.expire, 'Dy Mon dd, yyyy HH:MI AM') AS expire2," + + " m.uid AS offer_uid,j.uid AS job_uid,m.added::date AS offer_added,j.country AS job_country, " + + " c.code AS currency_code, c.description AS currency_description,j.country, j.category " + + " FROM members_jobs_offer m " + + " LEFT JOIN members_jobs j ON j.id=m.job_id " + + " LEFT JOIN currency c ON c.country=j.country " + + " WHERE m.status = 1 AND m.client_id=0 " + + " AND m.expire IS NOT NULL " + + " AND m.public_view = 1 AND m.expire> now() AND j.status = 1 " + QextraString + + " ORDER BY m.expire DESC LIMIT "+ data.limit; + + var bannerArray = { + "thiskey01": { + "banner": { + "image": "https://www.wrenchboard.com/assets/images/apps/banners/redeem/rex-card.jpg", + "icon": "bannerimage.icon", + "style": "style1", + "text": "This is the title text?", + "description": "Some description of this item, ", + "action": "thiskey" + }, + }, + "thiskey02": { + "banner": { + "image": "https://www.wrenchboard.com/assets/images/apps/banners/redeem/rex-amazon.jpg", + "icon": "bannerimage.icon", + "style": "style1", + "text": "Send your balance to Amazon Digital Card", + "description": "Some descriptio.n of this item, ", + "action": "thiskey" + }, + }, + "thiskey03": { + "banner": { + "image": "https://www.wrenchboard.com/assets/images/apps/banners/redeem/rex-apple.jpg", + "icon": "bannerimage.icon", + "style": "style1", + "text": "This is the title text?", + "description": "Some description of this item, ", + "action": "thiskey" + }, + }, + "thiskey04": { + "banner": { + "image": "https://www.wrenchboard.com/assets/images/apps/banners/redeem/rex-plays.jpg", + "icon": "bannerimage.icon", + "style": "style1", + "text": "This is the title text?", + "description": "Some description of this item, ", + "action": "thiskey" + }, + }, + "thiskey05": { + "banner": { + "image": "https://www.wrenchboard.com/assets/images/apps/banners/redeem/rex-xbox.jpg", + "icon": "bannerimage.icon", + "style": "style1", + "text": "This is the title text?", + "description": "Some description of this item, ", + "action": "thiskey" + }, + }, + "thiskey06": { + "banner": { + "image": "https://www.wrenchboard.com/assets/images/apps/banners/kids/banner-start.jpg", + "icon": "bannerimage.icon", + "style": "style1", + "text": "This is the title text?", + "description": "Some description of this item, ", + "action": "thiskey" + }, + }, + "thiskey07": { + "banner": { + "image": "https://www.wrenchboard.com/assets/images/apps/banners/kids/banner-start.jpg", + "icon": "bannerimage.icon", + "style": "style1", + "text": "This is the title text?", + "description": "Some description of this item, ", + "action": "thiskey" + }, + }, + "thiskey08": { + "banner": { + "image": "https://www.wrenchboard.com/assets/images/apps/banners/kids/banner-start.jpg", + "icon": "bannerimage.icon", + "style": "style1", + "text": "This is the title text?", + "description": "Some description of this item, ", + "action": "thiskey" + }, + } + }; + + + let resultItem ={ + "result": bannerArray, + "total_record": 4 + } + next(null, resultItem ); // pass control to the next handler + + }, +}; +module.exports = members_action;