From d2e6f433660ada52f99341c5b19503632562ee0b Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 9 Mar 2024 09:59:31 -0500 Subject: [PATCH] wallet srevice --- api/controller.js | 6 +- service/redeem.js | 323 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 326 insertions(+), 3 deletions(-) create mode 100644 service/redeem.js diff --git a/api/controller.js b/api/controller.js index b1267b2..b1db098 100644 --- a/api/controller.js +++ b/api/controller.js @@ -2,12 +2,12 @@ const properties = require('../package.json') const jobs = require('../service/jobs'); -const banners = require('../service/banners'); +const redeem = require('../service/redeem'); const logger = require('../app/logger'); var controllers = { getFamilyBanners: function(req, res) { - banners.getfamilybanners(req, res, function(err, result) { + redeem.getfamilybanners(req, res, function(err, result) { // logger.info(result); /* "status": "OK", @@ -21,7 +21,7 @@ var controllers = { }, getHomeBanners: function(req, res) { //homebanners - banners.homebanners(req, res, function(err, dist) { + redeem.homebanners(req, res, function(err, dist) { if (err) { res.send(err); } diff --git a/service/redeem.js b/service/redeem.js new file mode 100644 index 0000000..b11b402 --- /dev/null +++ b/service/redeem.js @@ -0,0 +1,323 @@ +'use strict'; + +const request = require('request'); +const db = require('../app/db') +const logger = require('../app/logger'); + +var redeem = { + getfamilybanners: 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; + + // // logger.info(Qstring); + // db.query(Qstring, function (err, result) { + // try { + // if (err) throw err; + // let resultItem ={ + // "result": result.rows, + // "total_record": result.rowCount + // } + // // logger.info(result); + // next(null, resultItem); // pass control to the next handler + // // next(null, result.rows); // pass control to the next handler + // } catch (e) { + // next(e.message, null); // pass control to the next handler + // } +/* + + + + +*/ + + // }); + 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" + }, + } + }; + + // "another1task": { + // "banner": { + // "image": "https://www.wrenchboard.com/assets/images/apps/banners/recommend-banner.jpg", + // "icon": "bannerimage.icon", + // "style": "style4", + // "text": "Dummy for now", + // "description": "dummy dummy dummy", + // "action": "thisaction" + // } + // }, + + let resultItem ={ + "result": bannerArray, + "total_record": 4 + } + next(null, resultItem ); // pass control to the next handler + + }, + homebanners: function (req, res, next) { +var result=[]; + + this.RecoCheckOffers(req, res, function(err, result){ + logger.info("************************ aaaa"); + logger.info(result); + logger.info("************************ bbbb"); + }); + + var result_list =[ + { + "title": "Some family accounts are yet to log in.", + "contract": null, + "card_type": "FAMILY_NOLOGIN", + "card_style": null, + "description": "Some family members have not logged in - a little nudge might help.", + "blog_id": "0", + "card_icon": "icon1", + "offer_id": "0", + "banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg", + "banner_location": "URL", + "link_path": "acc-family", + "button_text": "Continue", + "short_button_text": "View Now", + "short_title": "Some family accounts are yet to log in", + "short_description": "Help your family member get started.", + "short_style": "short_style" + }, + { + "title": "Yo man , you have Coupons to play with", + "contract": null, + "card_type": "COUPONS", + "card_style": null, + "description": "You have received some cash coupons waiting to be redeemed.", + "blog_id": "0", + "card_icon": "icon1", + "offer_id": "0", + "banner": "https://www.wrenchboard.com/assets/images/apps/banners/banner-coupons.jpg", + "banner_location": "URL", + "link_path": "my-coupon", + "button_text": "Continue", + "short_button_text": "Redeem", + "short_title": "Redeem your Cash Coupons!", + "short_description": "You have received some cash coupons waiting to be redeemed.", + "short_style": "short_style lg" + }, + { + "title": "Some of your task as owner Need Review now ", + "contract": null, + "card_type": "REVIEWJOB", + "card_style": null, + "description": "Some of your task as owner Need Review now,Some of your task as owner Need Review now, S Need Review now", + "blog_id": "0", + "card_icon": "icon1", + "offer_id": "0", + "banner": "banner-job-due.jpg", + "banner_location": "LOCAL", + "link_path": "my-review-jobs", + "button_text": "View Tasks", + "short_button_text": "Start Review", + "short_title": "Review Ready Tasks", + "short_description": "Some of your jobs are waiting for approval ", + "short_style": "short_style lr" + }, + { + "title": "Some of your task as owner of the tasks are due ", + "contract": null, + "card_type": "PASTDUEJOB", + "card_style": null, + "description": "Some of your task as owner of the tasks are due, Some of your task as owner of the tasks are due", + "blog_id": "0", + "card_icon": "icon1", + "offer_id": "0", + "banner": "https://www.wrenchboard.com/assets/images/apps/banners/past-due.jpg", + "banner_location": "URL", + "link_path": "my-pastdue-jobs", + "button_text": "View Tasks", + "short_button_text": "View", + "short_title": "Past Due Tasks", + "short_description": "Some of you task are now past due", + "short_style": "short_style lr" + }, + { + "title": "Share WrenchBoard with a friend.", + "contract": null, + "card_type": "INVITE", + "card_style": null, + "description": "Show WrenchBoard to a friend and earn free coupons. Get started.", + "blog_id": "0", + "card_icon": "icon1", + "offer_id": "0", + "banner": "banner-refer.jpg", + "banner_location": "LOCAL", + "link_path": "referral", + "button_text": "Continue", + "short_button_text": "View now", + "short_title": "Invite a Friend - get Rewards", + "short_description": "Share WrenchBoard with a friend.", + "short_style": "short_style by" + } + ]; + + let resultItem ={ + "result": result_list, + "total_record": 5 + } + next(null, resultItem ); // pass control to the next handler + + }, + RecoCheckOffers : function (req, res, next) { + let Qstring ="SELECT * FROM members_jobs_offer WHERE expire > now() "+ + "AND status = 1 AND client_id > 0 AND client_id =" +req.body.member_id; + logger.info(Qstring); + db.query(Qstring, function (err, result) { + try { + if (err) throw err; + let resultItem ={ + "result": + [ + { + "title": "Share RecoCheckOffers with a friend.", + "contract": null, + "card_type": "INVITE", + "card_style": null, + "description": "Show WrenchBoard to a friend and earn free coupons. Get started.", + "blog_id": "0", + "card_icon": "icon1", + "offer_id": "0", + "banner": "banner-refer.jpg", + "banner_location": "LOCAL", + "link_path": "referral", + "button_text": "Continue", + "short_button_text": "View now", + "short_title": "Invite a Friend - get Rewards", + "short_description": "Share WrenchBoard with a friend.", + "short_style": "short_style by" + } + ] + + , + "total_record": result.rowCount + }; + logger.info(result); + next(null, resultItem); // pass control to the next handler + } catch (e) { + next(e.message, null); // pass control to the next handler + } + }); + + }, + RecoCheckFamilyLogin : function (req, res, next) {}, + RecoCheckFamilyCount : function (req, res, next) {}, + RecoCheckFamilyCount : function (req, res, next) {}, + RecoCheckCoupons : function (req, res, next) {}, + RecoCheckTaskDue : function (req, res, next) {}, + RecoCheckTaskReview : function (req, res, next) {}, + RecoCheckBlog : function (req, res, next) {}, + RecoOffersInterest : function (req, res, next) {}, + RecoReferAFreind : function (req, res, next) {}, + RecoPendingInterestCount : function (req, res, next) {} +}; +module.exports = redeem;