Backend Service
This commit is contained in:
@@ -12,11 +12,7 @@
|
|||||||
//char confirmation[20] = "";
|
//char confirmation[20] = "";
|
||||||
//Confirmation(payment_id, confirmation, sizeof (confirmation));
|
//Confirmation(payment_id, confirmation, sizeof (confirmation));
|
||||||
|
|
||||||
|
void GenerateInnerConfirmationSeed(char * number, int sz, int seed) {
|
||||||
|
|
||||||
|
|
||||||
void GenerateInnerConfirmationSeed( char * number, int sz, int seed )
|
|
||||||
{
|
|
||||||
char chars[] = "WRB01234WRB56789WRB";
|
char chars[] = "WRB01234WRB56789WRB";
|
||||||
int n = sizeof (chars);
|
int n = sizeof (chars);
|
||||||
int i;
|
int i;
|
||||||
@@ -29,8 +25,7 @@ void GenerateInnerConfirmationSeed( char * number, int sz, int seed )
|
|||||||
*/
|
*/
|
||||||
srand((unsigned int) time((time_t *) NULL));
|
srand((unsigned int) time((time_t *) NULL));
|
||||||
|
|
||||||
for ( i=0; i<10 && i<sz-1; i++ )
|
for (i = 0; i < 10 && i < sz - 1; i++) {
|
||||||
{
|
|
||||||
int k = seed % n;
|
int k = seed % n;
|
||||||
if (seed > 1 && k == i) {
|
if (seed > 1 && k == i) {
|
||||||
number[i] = chars[n - k];
|
number[i] = chars[n - k];
|
||||||
@@ -41,25 +36,20 @@ void GenerateInnerConfirmationSeed( char * number, int sz, int seed )
|
|||||||
number[i] = 0;
|
number[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfirmationNew(unsigned long payment_id, char * number, int sz) {
|
||||||
|
|
||||||
void ConfirmationNew( unsigned long payment_id, char * number, int sz )
|
|
||||||
{
|
|
||||||
SQLINTEGER rows;
|
SQLINTEGER rows;
|
||||||
char confirmation[11];
|
char confirmation[11];
|
||||||
|
|
||||||
// Lock table to prevent generation of two identical confirmation numbers
|
// Lock table to prevent generation of two identical confirmation numbers
|
||||||
pgsql_exec("BEGIN; LOCK TABLE members_payments;");
|
pgsql_exec("BEGIN; LOCK TABLE members_payments;");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
GenerateInnerConfirmationSeed(confirmation, sizeof (confirmation), i++);
|
GenerateInnerConfirmationSeed(confirmation, sizeof (confirmation), i++);
|
||||||
|
|
||||||
//st.CloseCursor();
|
//st.CloseCursor();
|
||||||
rows = 0;
|
rows = 0;
|
||||||
const PGresult *res = pgsql_query("SELECT id FROM members_payments WHERE confirmation='%s'", confirmation);
|
const PGresult *res = pgsql_query("SELECT id FROM members_payments WHERE confirmation='%s'", confirmation);
|
||||||
if (res!=NULL )
|
if (res != NULL) {
|
||||||
{
|
|
||||||
rows = pgsql_num_rows(res);
|
rows = pgsql_num_rows(res);
|
||||||
}
|
}
|
||||||
} while (rows > 0 && i < 100);
|
} while (rows > 0 && i < 100);
|
||||||
@@ -69,29 +59,25 @@ void ConfirmationNew( unsigned long payment_id, char * number, int sz )
|
|||||||
strsafecpy(number, confirmation, sz);
|
strsafecpy(number, confirmation, sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetMemberAccountLink(long member_id, unsigned long acc_link, char * number) {
|
||||||
void GetMemberAccountLink( long member_id, unsigned long acc_link, char * number )
|
|
||||||
{
|
|
||||||
SQLINTEGER rows;
|
SQLINTEGER rows;
|
||||||
char offer_code[14];
|
char offer_code[14];
|
||||||
|
|
||||||
// Lock table to prevent generation of two identical confirmation numbers
|
// Lock table to prevent generation of two identical confirmation numbers
|
||||||
pgsql_exec("BEGIN; LOCK TABLE members_jobs_offer;" );
|
pgsql_exec("BEGIN; LOCK TABLE members;");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
GenerateInnerConfirmationSeed(offer_code, sizeof (offer_code), i++);
|
GenerateInnerConfirmationSeed(offer_code, sizeof (offer_code), i++);
|
||||||
|
|
||||||
//st.CloseCursor();
|
//st.CloseCursor();
|
||||||
rows = 0;
|
rows = 0;
|
||||||
const PGresult *res = pgsql_query("SELECT id FROM members WHERE offer_code='%s'", offer_code );
|
const PGresult *res = pgsql_query("SELECT id FROM members WHERE acc_link='%s'", offer_code);
|
||||||
if (res!=NULL )
|
if (res != NULL) {
|
||||||
{
|
|
||||||
rows = pgsql_num_rows(res);
|
rows = pgsql_num_rows(res);
|
||||||
}
|
}
|
||||||
} while (rows > 0 && i < 100);
|
} while (rows > 0 && i < 100);
|
||||||
|
|
||||||
pgsql_exec("UPDATE members_jobs_offer SET acc_link='%s' WHERE id=%lu", offer_code, member_id );
|
pgsql_exec("UPDATE members SET acc_link='%s' WHERE id=%lu", offer_code, member_id);
|
||||||
pgsql_exec("COMMIT"); // Unlock table 'data'
|
pgsql_exec("COMMIT"); // Unlock table 'data'
|
||||||
// strsafecpy( acc_link, offer_code, sz );
|
// strsafecpy( acc_link, offer_code, sz );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ long MemberSessionCheck(long uid, const char *sessionid, int create) {
|
|||||||
return 0L; // No route
|
return 0L; // No route
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long CreateMember(CVars in, CVars &out) {
|
long CreateMember(CVars in, CVars &out) {
|
||||||
long ret = PHP_API_BAD_PARAM;
|
long ret = PHP_API_BAD_PARAM;
|
||||||
logfmt(logINFO, "CreateMember()");
|
logfmt(logINFO, "CreateMember()");
|
||||||
@@ -248,6 +247,7 @@ long CreateMember(CVars in, CVars &out) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
long getMemberProfile(CVars in, CVars &out);
|
long getMemberProfile(CVars in, CVars &out);
|
||||||
|
|
||||||
long MemberProfile(CVars in, CVars &out) {
|
long MemberProfile(CVars in, CVars &out) {
|
||||||
|
|
||||||
|
|
||||||
@@ -270,7 +270,6 @@ long MemberProfile(CVars in, CVars &out){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long getMemberProfile(CVars in, CVars &out) {
|
long getMemberProfile(CVars in, CVars &out) {
|
||||||
|
|
||||||
|
|
||||||
@@ -367,8 +366,8 @@ long medTrUpdateProfile(CVars in, CVars &out) {
|
|||||||
|
|
||||||
long setMemberReminders(CVars in, CVars &out);
|
long setMemberReminders(CVars in, CVars &out);
|
||||||
long getMemberReminders(CVars in, CVars &out);
|
long getMemberReminders(CVars in, CVars &out);
|
||||||
long MemberReminders(CVars in, CVars &out)
|
|
||||||
{
|
long MemberReminders(CVars in, CVars &out) {
|
||||||
try {
|
try {
|
||||||
long task_mode = REQ_LONG(in, "task_mode", 0, -1);
|
long task_mode = REQ_LONG(in, "task_mode", 0, -1);
|
||||||
switch (task_mode) {
|
switch (task_mode) {
|
||||||
@@ -387,7 +386,6 @@ long MemberReminders(CVars in, CVars &out)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long setMemberReminders(CVars in, CVars &out) {
|
long setMemberReminders(CVars in, CVars &out) {
|
||||||
long ret = PHP_API_BAD_PARAM;
|
long ret = PHP_API_BAD_PARAM;
|
||||||
logfmt(logINFO, "CreateMember()");
|
logfmt(logINFO, "CreateMember()");
|
||||||
@@ -542,7 +540,6 @@ long DeletAallCards(CVars in, CVars &out) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long medTrMemberServiceById(CVars in, CVars &out) {
|
long medTrMemberServiceById(CVars in, CVars &out) {
|
||||||
long ret = PHP_API_BAD_PARAM;
|
long ret = PHP_API_BAD_PARAM;
|
||||||
|
|
||||||
@@ -577,7 +574,6 @@ long medTrMemberServiceById(CVars in, CVars &out) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long medTrLanguageList(CVars in, CVars &out) {
|
long medTrLanguageList(CVars in, CVars &out) {
|
||||||
long ret = PHP_API_BAD_PARAM;
|
long ret = PHP_API_BAD_PARAM;
|
||||||
char vname[20];
|
char vname[20];
|
||||||
@@ -621,6 +617,7 @@ long medTrLanguageList(CVars in, CVars &out) {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* street | city | zipcode
|
* street | city | zipcode
|
||||||
kleen=> SELECT t.*,a.agent_name,TO_CHAR(t.service_date :: TIMESTAMP, 'Day Mon dd, yyyy HH:MM AM') AS long_date FROM members_service_request t LEFT JOIN agents a ON a.id=t.agent_id;
|
kleen=> SELECT t.*,a.agent_name,TO_CHAR(t.service_date :: TIMESTAMP, 'Day Mon dd, yyyy HH:MM AM') AS long_date FROM members_service_request t LEFT JOIN agents a ON a.id=t.agent_id;
|
||||||
@@ -763,14 +760,7 @@ long getServiceDetail(long service_id, CVars &out) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<string> split_string(const char *str, char c = ' ') {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vector<string> split_string(const char *str, char c = ' ')
|
|
||||||
{
|
|
||||||
vector<string> result;
|
vector<string> result;
|
||||||
do {
|
do {
|
||||||
const char *begin = str;
|
const char *begin = str;
|
||||||
@@ -782,36 +772,42 @@ vector<string> split_string(const char *str, char c = ' ')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trim from start (in place)
|
// trim from start (in place)
|
||||||
|
|
||||||
static inline void ltrim(std::string &s) {
|
static inline void ltrim(std::string &s) {
|
||||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
|
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
|
||||||
std::not1(std::ptr_fun<int, int>(std::isspace))));
|
std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim from end (in place)
|
// trim from end (in place)
|
||||||
|
|
||||||
static inline void rtrim(std::string &s) {
|
static inline void rtrim(std::string &s) {
|
||||||
s.erase(std::find_if(s.rbegin(), s.rend(),
|
s.erase(std::find_if(s.rbegin(), s.rend(),
|
||||||
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
|
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim from both ends (in place)
|
// trim from both ends (in place)
|
||||||
|
|
||||||
static inline void trim(std::string &s) {
|
static inline void trim(std::string &s) {
|
||||||
ltrim(s);
|
ltrim(s);
|
||||||
rtrim(s);
|
rtrim(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim from start (copying)
|
// trim from start (copying)
|
||||||
|
|
||||||
static inline std::string ltrim_copy(std::string s) {
|
static inline std::string ltrim_copy(std::string s) {
|
||||||
ltrim(s);
|
ltrim(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim from end (copying)
|
// trim from end (copying)
|
||||||
|
|
||||||
static inline std::string rtrim_copy(std::string s) {
|
static inline std::string rtrim_copy(std::string s) {
|
||||||
rtrim(s);
|
rtrim(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim from both ends (copying)
|
// trim from both ends (copying)
|
||||||
|
|
||||||
static inline std::string trim_copy(std::string s) {
|
static inline std::string trim_copy(std::string s) {
|
||||||
trim(s);
|
trim(s);
|
||||||
return s;
|
return s;
|
||||||
@@ -905,8 +901,7 @@ long kleenNewLundryPickUp(CVars in, CVars &out) {
|
|||||||
out["service_id"] = insert_db_record(DBS_VALID, "members_service_request", "members_service_request_id_seq", x);
|
out["service_id"] = insert_db_record(DBS_VALID, "members_service_request", "members_service_request_id_seq", x);
|
||||||
if (out["service_id"].Long() > 0) {
|
if (out["service_id"].Long() > 0) {
|
||||||
|
|
||||||
if (in["instruction"].length() > 0)
|
if (in["instruction"].length() > 0) {
|
||||||
{
|
|
||||||
// let us save instruction to another table
|
// let us save instruction to another table
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user