u
This commit is contained in:
@@ -9,8 +9,7 @@ void handle_customer(HttpRequest& req, HttpResponse& resp, RouteContext& /*ctx*/
|
||||
int limit = req.get_query_int("limit", 20);
|
||||
int shop = get_active_shop_id();
|
||||
int subshop = get_active_shop_subshop_id();
|
||||
int64_t max_last_changed = get_active_max_last_changed();
|
||||
|
||||
auto customers = get_customer_list(cursor, limit, shop, subshop, max_last_changed);
|
||||
auto customers = get_customer_list(cursor, limit, shop, subshop);
|
||||
resp.send_json(200, customers);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,7 @@ static const char* CUSTOMER_COUNT_SQL =
|
||||
"SELECT COUNT(DISTINCT k.kKunde) AS cnt FROM dbo.tkunde k "
|
||||
"LEFT JOIN dbo.tInetKundeShop iks ON iks.kKunde = k.kKunde "
|
||||
"AND iks.kShop = ? AND iks.kSubShop = ? "
|
||||
"WHERE k.kKundenGruppe = 1 "
|
||||
"AND (? = 0 OR EXISTS (SELECT 1 FROM dbo.tInetKundeShop x "
|
||||
"WHERE (? = 0 OR EXISTS (SELECT 1 FROM dbo.tInetKundeShop x "
|
||||
"WHERE x.kKunde = k.kKunde AND x.kShop = ?)) "
|
||||
"AND CONVERT(BIGINT, k.bRowversion) > ?";
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
#include "../db/pool.hpp"
|
||||
#include "../log.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "shop.hpp"
|
||||
#include <cstdio>
|
||||
|
||||
static const char* CUSTOMER_LIST_SQL =
|
||||
"SELECT TOP (?) "
|
||||
@@ -37,8 +39,6 @@ static const char* CUSTOMER_LIST_SQL =
|
||||
" AND tInetKundeShop.kSubShop = ? "
|
||||
"WHERE vCustomer.kShop = ? "
|
||||
" AND CONVERT(BIGINT, vCustomer.bLastChanged) > ? "
|
||||
" AND CONVERT(BIGINT, vCustomer.bLastChanged) <= ? "
|
||||
" AND vCustomer.kCustomerGroupId = 1 "
|
||||
"ORDER BY vCustomer.bLastChanged ASC";
|
||||
|
||||
inline std::string format_birthday(const std::string& c_date_of_birth) {
|
||||
@@ -56,13 +56,12 @@ inline std::string format_birthday(const std::string& c_date_of_birth) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
inline nlohmann::json get_customer_list(int64_t cursor, int limit, int shop, int subshop, int64_t max_last_changed) {
|
||||
inline nlohmann::json get_customer_list(int64_t cursor, int limit, int shop, int subshop) {
|
||||
std::vector<Param> ps = {
|
||||
{ParamType::Int, "", limit},
|
||||
{ParamType::Int, "", subshop},
|
||||
{ParamType::Int, "", shop},
|
||||
{ParamType::BigInt, "", cursor},
|
||||
{ParamType::BigInt, "", max_last_changed},
|
||||
};
|
||||
ResultSet rs;
|
||||
if (!get_pool().execute(CUSTOMER_LIST_SQL, ps, rs)) {
|
||||
|
||||
Reference in New Issue
Block a user