bug fixed
This commit is contained in:
parent
a24d3dddb0
commit
41a53aeafb
|
@ -3,206 +3,13 @@
|
||||||
|
|
||||||
use super::models;
|
use super::models;
|
||||||
use crate::repositories;
|
use crate::repositories;
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
use diesel::{result::Error, sql_query, RunQueryDsl};
|
use diesel::{result::Error, sql_query, RunQueryDsl};
|
||||||
|
use std::fmt::Write;
|
||||||
|
|
||||||
static MEMBER_QUERY: &str = "
|
static MEMBER_COUNT_QUERY: &str = "
|
||||||
SELECT
|
SELECT
|
||||||
m.id as m_id,
|
COUNT(m.id)
|
||||||
m.site_id as m_site_id,
|
|
||||||
m.member_class_id as m_member_class_id,
|
|
||||||
m.member_level_id as m_member_level_id,
|
|
||||||
m.username as m_username,
|
|
||||||
m.password as m_password,
|
|
||||||
m.nickname as m_nickname,
|
|
||||||
m.mobile_phone_number as m_mobile_phone_number,
|
|
||||||
m.state as m_state,
|
|
||||||
m.state_changed_at as m_state_changed_at,
|
|
||||||
m.parent_member_id as m_parent_member_id,
|
|
||||||
m.child_member_count as m_child_member_count,
|
|
||||||
m.last_signined_ip as m_last_signined_ip,
|
|
||||||
m.last_signined_at as m_last_signined_at,
|
|
||||||
m.created_at as m_created_at,
|
|
||||||
m.updated_at as m_updated_at,
|
|
||||||
m.deleted_at as m_deleted_at,
|
|
||||||
|
|
||||||
m_s.id as m_s_id,
|
|
||||||
m_s.url as m_s_url,
|
|
||||||
m_s.name as m_s_name,
|
|
||||||
m_s.path as m_s_path,
|
|
||||||
m_s.show as m_s_show,
|
|
||||||
m_s.can_use as m_s_can_use,
|
|
||||||
m_s.memo as m_s_memo,
|
|
||||||
m_s.expires_at as m_s_expires_at,
|
|
||||||
m_s.created_at as m_s_created_at,
|
|
||||||
m_s.updated_at as m_s_updated_at,
|
|
||||||
|
|
||||||
m_mc.id as m_mc_id,
|
|
||||||
m_mc.parent_id as m_mc_parent_id,
|
|
||||||
m_mc.name as m_mc_name,
|
|
||||||
m_mc.show as m_mc_show,
|
|
||||||
m_mc.created_at as m_mc_created_at,
|
|
||||||
m_mc.updated_at as m_mc_updated_at,
|
|
||||||
|
|
||||||
m_ml.id as m_ml_id,
|
|
||||||
m_ml.name as m_ml_name,
|
|
||||||
m_ml.show as m_ml_show,
|
|
||||||
m_ml.sort_order as m_ml_sort_order,
|
|
||||||
m_ml.created_at as m_ml_created_at,
|
|
||||||
m_ml.updated_at as m_ml_updated_at,
|
|
||||||
|
|
||||||
m_mgs.id as m_mgs_id,
|
|
||||||
m_mgs.member_id as m_mgs_member_id,
|
|
||||||
m_mgs.can_bet_casino as m_mgs_can_bet_casino,
|
|
||||||
m_mgs.can_bet_slot as m_mgs_can_bet_slot,
|
|
||||||
m_mgs.can_bet_powerball as m_mgs_can_bet_powerball,
|
|
||||||
m_mgs.can_bet_powerladder as m_mgs_can_bet_powerladder,
|
|
||||||
m_mgs.can_bet_eos as m_mgs_can_bet_eos,
|
|
||||||
m_mgs.can_bet_bogglepowerball as m_mgs_can_bet_bogglepowerball,
|
|
||||||
m_mgs.created_at as m_mgs_created_at,
|
|
||||||
m_mgs.updated_at as m_mgs_updated_at,
|
|
||||||
|
|
||||||
m_mss.id as m_mss_id,
|
|
||||||
m_mss.member_id as m_mss_member_id,
|
|
||||||
m_mss.can_exchange as m_mss_can_exchange,
|
|
||||||
m_mss.can_first_charge_comp as m_mss_can_first_charge_comp,
|
|
||||||
m_mss.can_per_charge_comp as m_mss_can_per_charge_comp,
|
|
||||||
m_mss.manual_payment_type_for_partner as m_mss_manual_payment_type_for_partner,
|
|
||||||
m_mss.settlement_type as m_mss_settlement_type,
|
|
||||||
m_mss.rate_casino as m_mss_rate_casino,
|
|
||||||
m_mss.rate_casino_loosing as m_mss_rate_casino_loosing,
|
|
||||||
m_mss.rate_casino_bacara as m_mss_rate_casino_bacara,
|
|
||||||
m_mss.rate_casino_roulette as m_mss_rate_casino_roulette,
|
|
||||||
m_mss.rate_casino_dragon_tiger as m_mss_rate_casino_dragon_tiger,
|
|
||||||
m_mss.rate_slot as m_mss_rate_slot,
|
|
||||||
m_mss.rate_slot_loosing as m_mss_rate_slot_loosing,
|
|
||||||
m_mss.rate_powerball_single as m_mss_rate_powerball_single,
|
|
||||||
m_mss.rate_powerball_combo as m_mss_rate_powerball_combo,
|
|
||||||
m_mss.rate_powerladder_single as m_mss_rate_powerladder_single,
|
|
||||||
m_mss.rate_powerladder_combo as m_mss_rate_powerladder_combo,
|
|
||||||
m_mss.rate_eos_single as m_mss_rate_eos_single,
|
|
||||||
m_mss.rate_eos_combo as m_mss_rate_eos_combo,
|
|
||||||
m_mss.rate_bogglepowerball_single as m_mss_rate_bogglepowerball_single,
|
|
||||||
m_mss.rate_bogglepowerball_combo as m_mss_rate_bogglepowerball_combo,
|
|
||||||
m_mss.created_at as m_mss_created_at,
|
|
||||||
m_mss.updated_at as m_mss_updated_at,
|
|
||||||
|
|
||||||
m_mba.id as m_mba_id,
|
|
||||||
m_mba.member_id as m_mba_member_id,
|
|
||||||
m_mba.bank_id as m_mba_bank_id,
|
|
||||||
m_mba.name as m_mba_name,
|
|
||||||
m_mba.account_number as m_mba_account_number,
|
|
||||||
m_mba.exchange_password as m_mba_exchange_password,
|
|
||||||
m_mba.memo as m_mba_memo,
|
|
||||||
m_mba.created_at as m_mba_created_at,
|
|
||||||
m_mba.updated_at as m_mba_updated_at,
|
|
||||||
|
|
||||||
m_mba_b.id as m_mba_b_id,
|
|
||||||
m_mba_b.name as m_mba_b_name,
|
|
||||||
m_mba_b.sort_order as m_mba_b_sort_order,
|
|
||||||
m_mba_b.show as m_mba_b_show,
|
|
||||||
m_mba_b.can_use as m_mba_b_can_use,
|
|
||||||
m_mba_b.memo as m_mba_b_memo,
|
|
||||||
m_mba_b.created_at as m_mba_b_created_at,
|
|
||||||
m_mba_b.updated_at as m_mba_b_updated_at,
|
|
||||||
|
|
||||||
pm.id as pm_id,
|
|
||||||
pm.site_id as pm_site_id,
|
|
||||||
pm.member_class_id as pm_member_class_id,
|
|
||||||
pm.member_level_id as pm_member_level_id,
|
|
||||||
pm.username as pm_username,
|
|
||||||
pm.password as pm_password,
|
|
||||||
pm.nickname as pm_nickname,
|
|
||||||
pm.mobile_phone_number as pm_mobile_phone_number,
|
|
||||||
pm.state as pm_state,
|
|
||||||
pm.state_changed_at as pm_state_changed_at,
|
|
||||||
pm.parent_member_id as pm_parent_member_id,
|
|
||||||
pm.child_member_count as pm_child_member_count,
|
|
||||||
pm.last_signined_ip as pm_last_signined_ip,
|
|
||||||
pm.last_signined_at as pm_last_signined_at,
|
|
||||||
pm.created_at as pm_created_at,
|
|
||||||
pm.updated_at as pm_updated_at,
|
|
||||||
pm.deleted_at as pm_deleted_at,
|
|
||||||
|
|
||||||
pm_s.id as pm_s_id,
|
|
||||||
pm_s.url as pm_s_url,
|
|
||||||
pm_s.name as pm_s_name,
|
|
||||||
pm_s.path as pm_s_path,
|
|
||||||
pm_s.show as pm_s_show,
|
|
||||||
pm_s.can_use as pm_s_can_use,
|
|
||||||
pm_s.memo as pm_s_memo,
|
|
||||||
pm_s.expires_at as pm_s_expires_at,
|
|
||||||
pm_s.created_at as pm_s_created_at,
|
|
||||||
pm_s.updated_at as pm_s_updated_at,
|
|
||||||
|
|
||||||
pm_mc.id as pm_mc_id,
|
|
||||||
pm_mc.parent_id as pm_mc_parent_id,
|
|
||||||
pm_mc.name as pm_mc_name,
|
|
||||||
pm_mc.show as pm_mc_show,
|
|
||||||
pm_mc.created_at as pm_mc_created_at,
|
|
||||||
pm_mc.updated_at as pm_mc_updated_at,
|
|
||||||
|
|
||||||
pm_ml.id as pm_ml_id,
|
|
||||||
pm_ml.name as pm_ml_name,
|
|
||||||
pm_ml.show as pm_ml_show,
|
|
||||||
pm_ml.sort_order as pm_ml_sort_order,
|
|
||||||
pm_ml.created_at as pm_ml_created_at,
|
|
||||||
pm_ml.updated_at as pm_ml_updated_at,
|
|
||||||
|
|
||||||
pm_mgs.id as pm_mgs_id,
|
|
||||||
pm_mgs.member_id as pm_mgs_member_id,
|
|
||||||
pm_mgs.can_bet_casino as pm_mgs_can_bet_casino,
|
|
||||||
pm_mgs.can_bet_slot as pm_mgs_can_bet_slot,
|
|
||||||
pm_mgs.can_bet_powerball as pm_mgs_can_bet_powerball,
|
|
||||||
pm_mgs.can_bet_powerladder as pm_mgs_can_bet_powerladder,
|
|
||||||
pm_mgs.can_bet_eos as pm_mgs_can_bet_eos,
|
|
||||||
pm_mgs.can_bet_bogglepowerball as pm_mgs_can_bet_bogglepowerball,
|
|
||||||
pm_mgs.created_at as pm_mgs_created_at,
|
|
||||||
pm_mgs.updated_at as pm_mgs_updated_at,
|
|
||||||
|
|
||||||
pm_mss.id as pm_mss_id,
|
|
||||||
pm_mss.member_id as pm_mss_member_id,
|
|
||||||
pm_mss.can_exchange as pm_mss_can_exchange,
|
|
||||||
pm_mss.can_first_charge_comp as pm_mss_can_first_charge_comp,
|
|
||||||
pm_mss.can_per_charge_comp as pm_mss_can_per_charge_comp,
|
|
||||||
pm_mss.manual_payment_type_for_partner as pm_mss_manual_payment_type_for_partner,
|
|
||||||
pm_mss.settlement_type as pm_mss_settlement_type,
|
|
||||||
pm_mss.rate_casino as pm_mss_rate_casino,
|
|
||||||
pm_mss.rate_casino_loosing as pm_mss_rate_casino_loosing,
|
|
||||||
pm_mss.rate_casino_bacara as pm_mss_rate_casino_bacara,
|
|
||||||
pm_mss.rate_casino_roulette as pm_mss_rate_casino_roulette,
|
|
||||||
pm_mss.rate_casino_dragon_tiger as pm_mss_rate_casino_dragon_tiger,
|
|
||||||
pm_mss.rate_slot as pm_mss_rate_slot,
|
|
||||||
pm_mss.rate_slot_loosing as pm_mss_rate_slot_loosing,
|
|
||||||
pm_mss.rate_powerball_single as pm_mss_rate_powerball_single,
|
|
||||||
pm_mss.rate_powerball_combo as pm_mss_rate_powerball_combo,
|
|
||||||
pm_mss.rate_powerladder_single as pm_mss_rate_powerladder_single,
|
|
||||||
pm_mss.rate_powerladder_combo as pm_mss_rate_powerladder_combo,
|
|
||||||
pm_mss.rate_eos_single as pm_mss_rate_eos_single,
|
|
||||||
pm_mss.rate_eos_combo as pm_mss_rate_eos_combo,
|
|
||||||
pm_mss.rate_bogglepowerball_single as pm_mss_rate_bogglepowerball_single,
|
|
||||||
pm_mss.rate_bogglepowerball_combo as pm_mss_rate_bogglepowerball_combo,
|
|
||||||
pm_mss.created_at as pm_mss_created_at,
|
|
||||||
pm_mss.updated_at as pm_mss_updated_at,
|
|
||||||
|
|
||||||
pm_mba.id as pm_mba_id,
|
|
||||||
pm_mba.member_id as pm_mba_member_id,
|
|
||||||
pm_mba.bank_id as pm_mba_bank_id,
|
|
||||||
pm_mba.name as pm_mba_name,
|
|
||||||
pm_mba.account_number as pm_mba_account_number,
|
|
||||||
pm_mba.exchange_password as pm_mba_exchange_password,
|
|
||||||
pm_mba.memo as pm_mba_memo,
|
|
||||||
pm_mba.created_at as pm_mba_created_at,
|
|
||||||
pm_mba.updated_at as pm_mba_updated_at,
|
|
||||||
|
|
||||||
pm_mba_b.id as pm_mba_b_id,
|
|
||||||
pm_mba_b.name as pm_mba_b_name,
|
|
||||||
pm_mba_b.sort_order as pm_mba_b_sort_order,
|
|
||||||
pm_mba_b.show as pm_mba_b_show,
|
|
||||||
pm_mba_b.can_use as pm_mba_b_can_use,
|
|
||||||
pm_mba_b.memo as pm_mba_b_memo,
|
|
||||||
pm_mba_b.created_at as pm_mba_b_created_at,
|
|
||||||
pm_mba_b.updated_at as pm_mba_b_updated_at
|
|
||||||
|
|
||||||
FROM members as m
|
FROM members as m
|
||||||
INNER JOIN sites m_s
|
INNER JOIN sites m_s
|
||||||
ON m_s.id = m.site_id
|
ON m_s.id = m.site_id
|
||||||
|
@ -236,6 +43,237 @@ FROM members as m
|
||||||
ON pm_mba_b.id = pm_mba.bank_id
|
ON pm_mba_b.id = pm_mba.bank_id
|
||||||
";
|
";
|
||||||
|
|
||||||
|
static MEMBER_QUERY: &str = "
|
||||||
|
SELECT
|
||||||
|
m.id as m_id,
|
||||||
|
m.site_id as m_site_id,
|
||||||
|
m.member_class_id as m_member_class_id,
|
||||||
|
m.member_level_id as m_member_level_id,
|
||||||
|
m.username as m_username,
|
||||||
|
m.password as m_password,
|
||||||
|
m.nickname as m_nickname,
|
||||||
|
m.mobile_phone_number as m_mobile_phone_number,
|
||||||
|
m.state as m_state,
|
||||||
|
m.state_changed_at as m_state_changed_at,
|
||||||
|
m.parent_member_id as m_parent_member_id,
|
||||||
|
m.child_member_count as m_child_member_count,
|
||||||
|
m.last_signined_ip as m_last_signined_ip,
|
||||||
|
m.last_signined_at as m_last_signined_at,
|
||||||
|
m.created_at as m_created_at,
|
||||||
|
m.updated_at as m_updated_at,
|
||||||
|
m.deleted_at as m_deleted_at,
|
||||||
|
|
||||||
|
m_s.id as m_s_id,
|
||||||
|
m_s.url as m_s_url,
|
||||||
|
m_s.name as m_s_name,
|
||||||
|
m_s.path as m_s_path,
|
||||||
|
m_s.show as m_s_show,
|
||||||
|
m_s.can_use as m_s_can_use,
|
||||||
|
m_s.memo as m_s_memo,
|
||||||
|
m_s.expires_at as m_s_expires_at,
|
||||||
|
m_s.created_at as m_s_created_at,
|
||||||
|
m_s.updated_at as m_s_updated_at,
|
||||||
|
|
||||||
|
m_mc.id as m_mc_id,
|
||||||
|
m_mc.parent_id as m_mc_parent_id,
|
||||||
|
m_mc.name as m_mc_name,
|
||||||
|
m_mc.show as m_mc_show,
|
||||||
|
m_mc.created_at as m_mc_created_at,
|
||||||
|
m_mc.updated_at as m_mc_updated_at,
|
||||||
|
|
||||||
|
m_ml.id as m_ml_id,
|
||||||
|
m_ml.name as m_ml_name,
|
||||||
|
m_ml.show as m_ml_show,
|
||||||
|
m_ml.sort_order as m_ml_sort_order,
|
||||||
|
m_ml.created_at as m_ml_created_at,
|
||||||
|
m_ml.updated_at as m_ml_updated_at,
|
||||||
|
|
||||||
|
m_mgs.id as m_mgs_id,
|
||||||
|
m_mgs.member_id as m_mgs_member_id,
|
||||||
|
m_mgs.can_bet_casino as m_mgs_can_bet_casino,
|
||||||
|
m_mgs.can_bet_slot as m_mgs_can_bet_slot,
|
||||||
|
m_mgs.can_bet_powerball as m_mgs_can_bet_powerball,
|
||||||
|
m_mgs.can_bet_powerladder as m_mgs_can_bet_powerladder,
|
||||||
|
m_mgs.can_bet_eos as m_mgs_can_bet_eos,
|
||||||
|
m_mgs.can_bet_bogglepowerball as m_mgs_can_bet_bogglepowerball,
|
||||||
|
m_mgs.created_at as m_mgs_created_at,
|
||||||
|
m_mgs.updated_at as m_mgs_updated_at,
|
||||||
|
|
||||||
|
m_mss.id as m_mss_id,
|
||||||
|
m_mss.member_id as m_mss_member_id,
|
||||||
|
m_mss.can_exchange as m_mss_can_exchange,
|
||||||
|
m_mss.can_first_charge_comp as m_mss_can_first_charge_comp,
|
||||||
|
m_mss.can_per_charge_comp as m_mss_can_per_charge_comp,
|
||||||
|
m_mss.manual_payment_type_for_partner as m_mss_manual_payment_type_for_partner,
|
||||||
|
m_mss.settlement_type as m_mss_settlement_type,
|
||||||
|
m_mss.rate_casino as m_mss_rate_casino,
|
||||||
|
m_mss.rate_casino_loosing as m_mss_rate_casino_loosing,
|
||||||
|
m_mss.rate_casino_bacara as m_mss_rate_casino_bacara,
|
||||||
|
m_mss.rate_casino_roulette as m_mss_rate_casino_roulette,
|
||||||
|
m_mss.rate_casino_dragon_tiger as m_mss_rate_casino_dragon_tiger,
|
||||||
|
m_mss.rate_slot as m_mss_rate_slot,
|
||||||
|
m_mss.rate_slot_loosing as m_mss_rate_slot_loosing,
|
||||||
|
m_mss.rate_powerball_single as m_mss_rate_powerball_single,
|
||||||
|
m_mss.rate_powerball_combo as m_mss_rate_powerball_combo,
|
||||||
|
m_mss.rate_powerladder_single as m_mss_rate_powerladder_single,
|
||||||
|
m_mss.rate_powerladder_combo as m_mss_rate_powerladder_combo,
|
||||||
|
m_mss.rate_eos_single as m_mss_rate_eos_single,
|
||||||
|
m_mss.rate_eos_combo as m_mss_rate_eos_combo,
|
||||||
|
m_mss.rate_bogglepowerball_single as m_mss_rate_bogglepowerball_single,
|
||||||
|
m_mss.rate_bogglepowerball_combo as m_mss_rate_bogglepowerball_combo,
|
||||||
|
m_mss.created_at as m_mss_created_at,
|
||||||
|
m_mss.updated_at as m_mss_updated_at,
|
||||||
|
|
||||||
|
m_mba.id as m_mba_id,
|
||||||
|
m_mba.member_id as m_mba_member_id,
|
||||||
|
m_mba.bank_id as m_mba_bank_id,
|
||||||
|
m_mba.name as m_mba_name,
|
||||||
|
m_mba.account_number as m_mba_account_number,
|
||||||
|
m_mba.exchange_password as m_mba_exchange_password,
|
||||||
|
m_mba.memo as m_mba_memo,
|
||||||
|
m_mba.created_at as m_mba_created_at,
|
||||||
|
m_mba.updated_at as m_mba_updated_at,
|
||||||
|
|
||||||
|
m_mba_b.id as m_mba_b_id,
|
||||||
|
m_mba_b.name as m_mba_b_name,
|
||||||
|
m_mba_b.sort_order as m_mba_b_sort_order,
|
||||||
|
m_mba_b.show as m_mba_b_show,
|
||||||
|
m_mba_b.can_use as m_mba_b_can_use,
|
||||||
|
m_mba_b.memo as m_mba_b_memo,
|
||||||
|
m_mba_b.created_at as m_mba_b_created_at,
|
||||||
|
m_mba_b.updated_at as m_mba_b_updated_at,
|
||||||
|
|
||||||
|
pm.id as pm_id,
|
||||||
|
pm.site_id as pm_site_id,
|
||||||
|
pm.member_class_id as pm_member_class_id,
|
||||||
|
pm.member_level_id as pm_member_level_id,
|
||||||
|
pm.username as pm_username,
|
||||||
|
pm.password as pm_password,
|
||||||
|
pm.nickname as pm_nickname,
|
||||||
|
pm.mobile_phone_number as pm_mobile_phone_number,
|
||||||
|
pm.state as pm_state,
|
||||||
|
pm.state_changed_at as pm_state_changed_at,
|
||||||
|
pm.parent_member_id as pm_parent_member_id,
|
||||||
|
pm.child_member_count as pm_child_member_count,
|
||||||
|
pm.last_signined_ip as pm_last_signined_ip,
|
||||||
|
pm.last_signined_at as pm_last_signined_at,
|
||||||
|
pm.created_at as pm_created_at,
|
||||||
|
pm.updated_at as pm_updated_at,
|
||||||
|
pm.deleted_at as pm_deleted_at,
|
||||||
|
|
||||||
|
pm_s.id as pm_s_id,
|
||||||
|
pm_s.url as pm_s_url,
|
||||||
|
pm_s.name as pm_s_name,
|
||||||
|
pm_s.path as pm_s_path,
|
||||||
|
pm_s.show as pm_s_show,
|
||||||
|
pm_s.can_use as pm_s_can_use,
|
||||||
|
pm_s.memo as pm_s_memo,
|
||||||
|
pm_s.expires_at as pm_s_expires_at,
|
||||||
|
pm_s.created_at as pm_s_created_at,
|
||||||
|
pm_s.updated_at as pm_s_updated_at,
|
||||||
|
|
||||||
|
pm_mc.id as pm_mc_id,
|
||||||
|
pm_mc.parent_id as pm_mc_parent_id,
|
||||||
|
pm_mc.name as pm_mc_name,
|
||||||
|
pm_mc.show as pm_mc_show,
|
||||||
|
pm_mc.created_at as pm_mc_created_at,
|
||||||
|
pm_mc.updated_at as pm_mc_updated_at,
|
||||||
|
|
||||||
|
pm_ml.id as pm_ml_id,
|
||||||
|
pm_ml.name as pm_ml_name,
|
||||||
|
pm_ml.show as pm_ml_show,
|
||||||
|
pm_ml.sort_order as pm_ml_sort_order,
|
||||||
|
pm_ml.created_at as pm_ml_created_at,
|
||||||
|
pm_ml.updated_at as pm_ml_updated_at,
|
||||||
|
|
||||||
|
pm_mgs.id as pm_mgs_id,
|
||||||
|
pm_mgs.member_id as pm_mgs_member_id,
|
||||||
|
pm_mgs.can_bet_casino as pm_mgs_can_bet_casino,
|
||||||
|
pm_mgs.can_bet_slot as pm_mgs_can_bet_slot,
|
||||||
|
pm_mgs.can_bet_powerball as pm_mgs_can_bet_powerball,
|
||||||
|
pm_mgs.can_bet_powerladder as pm_mgs_can_bet_powerladder,
|
||||||
|
pm_mgs.can_bet_eos as pm_mgs_can_bet_eos,
|
||||||
|
pm_mgs.can_bet_bogglepowerball as pm_mgs_can_bet_bogglepowerball,
|
||||||
|
pm_mgs.created_at as pm_mgs_created_at,
|
||||||
|
pm_mgs.updated_at as pm_mgs_updated_at,
|
||||||
|
|
||||||
|
pm_mss.id as pm_mss_id,
|
||||||
|
pm_mss.member_id as pm_mss_member_id,
|
||||||
|
pm_mss.can_exchange as pm_mss_can_exchange,
|
||||||
|
pm_mss.can_first_charge_comp as pm_mss_can_first_charge_comp,
|
||||||
|
pm_mss.can_per_charge_comp as pm_mss_can_per_charge_comp,
|
||||||
|
pm_mss.manual_payment_type_for_partner as pm_mss_manual_payment_type_for_partner,
|
||||||
|
pm_mss.settlement_type as pm_mss_settlement_type,
|
||||||
|
pm_mss.rate_casino as pm_mss_rate_casino,
|
||||||
|
pm_mss.rate_casino_loosing as pm_mss_rate_casino_loosing,
|
||||||
|
pm_mss.rate_casino_bacara as pm_mss_rate_casino_bacara,
|
||||||
|
pm_mss.rate_casino_roulette as pm_mss_rate_casino_roulette,
|
||||||
|
pm_mss.rate_casino_dragon_tiger as pm_mss_rate_casino_dragon_tiger,
|
||||||
|
pm_mss.rate_slot as pm_mss_rate_slot,
|
||||||
|
pm_mss.rate_slot_loosing as pm_mss_rate_slot_loosing,
|
||||||
|
pm_mss.rate_powerball_single as pm_mss_rate_powerball_single,
|
||||||
|
pm_mss.rate_powerball_combo as pm_mss_rate_powerball_combo,
|
||||||
|
pm_mss.rate_powerladder_single as pm_mss_rate_powerladder_single,
|
||||||
|
pm_mss.rate_powerladder_combo as pm_mss_rate_powerladder_combo,
|
||||||
|
pm_mss.rate_eos_single as pm_mss_rate_eos_single,
|
||||||
|
pm_mss.rate_eos_combo as pm_mss_rate_eos_combo,
|
||||||
|
pm_mss.rate_bogglepowerball_single as pm_mss_rate_bogglepowerball_single,
|
||||||
|
pm_mss.rate_bogglepowerball_combo as pm_mss_rate_bogglepowerball_combo,
|
||||||
|
pm_mss.created_at as pm_mss_created_at,
|
||||||
|
pm_mss.updated_at as pm_mss_updated_at,
|
||||||
|
|
||||||
|
pm_mba.id as pm_mba_id,
|
||||||
|
pm_mba.member_id as pm_mba_member_id,
|
||||||
|
pm_mba.bank_id as pm_mba_bank_id,
|
||||||
|
pm_mba.name as pm_mba_name,
|
||||||
|
pm_mba.account_number as pm_mba_account_number,
|
||||||
|
pm_mba.exchange_password as pm_mba_exchange_password,
|
||||||
|
pm_mba.memo as pm_mba_memo,
|
||||||
|
pm_mba.created_at as pm_mba_created_at,
|
||||||
|
pm_mba.updated_at as pm_mba_updated_at,
|
||||||
|
|
||||||
|
pm_mba_b.id as pm_mba_b_id,
|
||||||
|
pm_mba_b.name as pm_mba_b_name,
|
||||||
|
pm_mba_b.sort_order as pm_mba_b_sort_order,
|
||||||
|
pm_mba_b.show as pm_mba_b_show,
|
||||||
|
pm_mba_b.can_use as pm_mba_b_can_use,
|
||||||
|
pm_mba_b.memo as pm_mba_b_memo,
|
||||||
|
pm_mba_b.created_at as pm_mba_b_created_at,
|
||||||
|
pm_mba_b.updated_at as pm_mba_b_updated_at
|
||||||
|
|
||||||
|
FROM members as m
|
||||||
|
INNER JOIN sites m_s
|
||||||
|
ON m_s.id = m.site_id
|
||||||
|
INNER JOIN member_classes m_mc
|
||||||
|
ON m_mc.id = m.member_class_id
|
||||||
|
INNER JOIN member_levels m_ml
|
||||||
|
ON m_ml.id = m.member_level_id
|
||||||
|
LEFT OUTER JOIN member_settlement_settings m_mss
|
||||||
|
ON m_mss.member_id = m.id
|
||||||
|
LEFT OUTER JOIN member_game_settings m_mgs
|
||||||
|
ON m_mgs.member_id = m.id
|
||||||
|
LEFT OUTER JOIN member_bank_accounts m_mba
|
||||||
|
ON m_mba.member_id = m.id
|
||||||
|
LEFT OUTER JOIN banks m_mba_b
|
||||||
|
ON m_mba_b.id = m_mba.bank_id
|
||||||
|
LEFT OUTER JOIN members pm
|
||||||
|
ON pm.id = m.parent_member_id
|
||||||
|
LEFT OUTER JOIN sites pm_s
|
||||||
|
ON pm_s.id = pm.site_id
|
||||||
|
LEFT OUTER JOIN member_classes pm_mc
|
||||||
|
ON pm_mc.id = pm.member_class_id
|
||||||
|
LEFT OUTER JOIN member_levels pm_ml
|
||||||
|
ON pm_ml.id = pm.member_level_id
|
||||||
|
LEFT OUTER JOIN member_settlement_settings pm_mss
|
||||||
|
ON pm_mss.member_id = pm.id
|
||||||
|
LEFT OUTER JOIN member_game_settings pm_mgs
|
||||||
|
ON pm_mgs.member_id = pm.id
|
||||||
|
LEFT OUTER JOIN member_bank_accounts pm_mba
|
||||||
|
ON pm_mba.member_id = pm.id
|
||||||
|
LEFT OUTER JOIN banks pm_mba_b
|
||||||
|
ON pm_mba_b.id = pm_mba.bank_id
|
||||||
|
";
|
||||||
|
|
||||||
pub struct Composition {}
|
pub struct Composition {}
|
||||||
|
|
||||||
impl std::fmt::Debug for Composition {
|
impl std::fmt::Debug for Composition {
|
||||||
|
@ -310,18 +348,70 @@ impl Composition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
fn get_pagination(
|
||||||
pub fn select_all(
|
|
||||||
&self,
|
&self,
|
||||||
conn: &diesel::PgConnection,
|
|
||||||
find_all: &repositories::member::models::FindAll,
|
find_all: &repositories::member::models::FindAll,
|
||||||
) -> Result<Vec<models::MemberModel>, Error> {
|
) -> Result<String, Error> {
|
||||||
use std::fmt::Write;
|
let mut query_pagination = String::new();
|
||||||
|
|
||||||
let mut query = String::new();
|
if let Some(pagination) = &find_all.pagination {
|
||||||
write!(&mut query, "{}", MEMBER_QUERY)
|
let page = pagination.page.unwrap_or(1);
|
||||||
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
if let Some(page_size) = pagination.page_size {
|
||||||
|
write!(
|
||||||
|
&mut query_pagination,
|
||||||
|
" OFFSET {} LIMIT {} ",
|
||||||
|
((page - 1) * page_size) as i64,
|
||||||
|
page_size as i64
|
||||||
|
)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(query_pagination)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_ordery_by(
|
||||||
|
&self,
|
||||||
|
find_all: &repositories::member::models::FindAll,
|
||||||
|
) -> Result<String, Error> {
|
||||||
|
let mut query_ordery_by = String::new();
|
||||||
|
|
||||||
|
if let Some(sorts) = &find_all.sorts {
|
||||||
|
for s in sorts {
|
||||||
|
if !query_ordery_by.is_empty() {
|
||||||
|
write!(&mut query_ordery_by, " , ")
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let (property, sort) = match s {
|
||||||
|
bcr::pagination::Sort::ASC(property) => (property.clone(), "ASC".to_string()),
|
||||||
|
bcr::pagination::Sort::DESC(property) => (property.clone(), "DESC".to_string()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let property = match property.as_str() {
|
||||||
|
"username" => "m.username".to_string(),
|
||||||
|
"nickname" => "m.nickname".to_string(),
|
||||||
|
"mobile_phone_number" => "m.mobile_phone_number".to_string(),
|
||||||
|
"last_signined_ip" => "m.last_signined_ip".to_string(),
|
||||||
|
"state" => "m.state".to_string(),
|
||||||
|
"state_changed_at" => "m.state_changed_at".to_string(),
|
||||||
|
"created_at" => "m.created_at".to_string(),
|
||||||
|
"updated_at" => "m.updated_at".to_string(),
|
||||||
|
"deleted_at" => "m.deleted_at".to_string(),
|
||||||
|
_ => "".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
if !property.is_empty() {
|
||||||
|
write!(&mut query_ordery_by, "{} {}", property, sort)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(query_ordery_by)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_where(&self, find_all: &repositories::member::models::FindAll) -> Result<String, Error> {
|
||||||
let mut query_where = String::new();
|
let mut query_where = String::new();
|
||||||
|
|
||||||
if let Some(s) = &find_all.search {
|
if let Some(s) = &find_all.search {
|
||||||
|
@ -349,6 +439,32 @@ impl Composition {
|
||||||
write!(&mut query_where, "m.member_level_id = '{}'", sp)
|
write!(&mut query_where, "m.member_level_id = '{}'", sp)
|
||||||
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
}
|
}
|
||||||
|
if let Some(sp) = &s.username {
|
||||||
|
if !query_where.is_empty() {
|
||||||
|
write!(&mut query_where, " AND ")
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
write!(&mut query_where, "m.username = '{}'", sp)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
if !s.usernames.is_empty() {
|
||||||
|
if !query_where.is_empty() {
|
||||||
|
write!(&mut query_where, " AND ")
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(
|
||||||
|
&mut query_where,
|
||||||
|
"m.username IN ({})",
|
||||||
|
s.usernames
|
||||||
|
.iter()
|
||||||
|
.map(|v| format!("'{}'", v))
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(",")
|
||||||
|
)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(sp) = &s.username_like {
|
if let Some(sp) = &s.username_like {
|
||||||
if !query_where.is_empty() {
|
if !query_where.is_empty() {
|
||||||
write!(&mut query_where, " AND ")
|
write!(&mut query_where, " AND ")
|
||||||
|
@ -357,6 +473,31 @@ impl Composition {
|
||||||
write!(&mut query_where, "m.username like '{}'", sp)
|
write!(&mut query_where, "m.username like '{}'", sp)
|
||||||
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
}
|
}
|
||||||
|
if let Some(sp) = &s.nickname {
|
||||||
|
if !query_where.is_empty() {
|
||||||
|
write!(&mut query_where, " AND ")
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
write!(&mut query_where, "m.nickname = '{}'", sp)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
if !s.nicknames.is_empty() {
|
||||||
|
if !query_where.is_empty() {
|
||||||
|
write!(&mut query_where, " AND ")
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(
|
||||||
|
&mut query_where,
|
||||||
|
"m.nickname IN ({})",
|
||||||
|
s.nicknames
|
||||||
|
.iter()
|
||||||
|
.map(|v| format!("'{}'", v))
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(",")
|
||||||
|
)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
if let Some(sp) = &s.nickname_like {
|
if let Some(sp) = &s.nickname_like {
|
||||||
if !query_where.is_empty() {
|
if !query_where.is_empty() {
|
||||||
write!(&mut query_where, " AND ")
|
write!(&mut query_where, " AND ")
|
||||||
|
@ -402,7 +543,28 @@ impl Composition {
|
||||||
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(query_where)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select_all_count(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
find_all: &repositories::member::models::FindAll,
|
||||||
|
) -> Result<i64, Error> {
|
||||||
|
use diesel::sql_types::BigInt;
|
||||||
|
|
||||||
|
#[derive(QueryableByName)]
|
||||||
|
struct Count {
|
||||||
|
#[sql_type = "BigInt"]
|
||||||
|
count: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut query = String::new();
|
||||||
|
write!(&mut query, "{}", MEMBER_COUNT_QUERY)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
|
||||||
|
let query_where = self.get_where(find_all)?;
|
||||||
if !query_where.is_empty() {
|
if !query_where.is_empty() {
|
||||||
write!(&mut query, " WHERE {}", query_where)
|
write!(&mut query, " WHERE {}", query_where)
|
||||||
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
@ -410,6 +572,43 @@ impl Composition {
|
||||||
|
|
||||||
println!("query: {}", query);
|
println!("query: {}", query);
|
||||||
|
|
||||||
|
match sql_query(query).get_result::<Count>(conn) {
|
||||||
|
Ok(m) => Ok(m.count),
|
||||||
|
Err(e) => match e {
|
||||||
|
diesel::result::Error::NotFound => Ok(0),
|
||||||
|
_ => Err(e),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select_all(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
find_all: &repositories::member::models::FindAll,
|
||||||
|
) -> Result<Vec<models::MemberModel>, Error> {
|
||||||
|
let mut query = String::new();
|
||||||
|
write!(&mut query, "{}", MEMBER_QUERY)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
|
||||||
|
let query_where = self.get_where(find_all)?;
|
||||||
|
if !query_where.is_empty() {
|
||||||
|
write!(&mut query, " WHERE {}", query_where)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
let query_ordery_by = self.get_ordery_by(find_all)?;
|
||||||
|
if !query_ordery_by.is_empty() {
|
||||||
|
write!(&mut query, " ORDER BY {}", query_ordery_by)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
let query_pagination = self.get_pagination(find_all)?;
|
||||||
|
if !query_pagination.is_empty() {
|
||||||
|
write!(&mut query, " {} ", query_pagination)
|
||||||
|
.map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("query: {}", query);
|
||||||
|
|
||||||
match sql_query(query).get_results::<models::MemberModel>(conn) {
|
match sql_query(query).get_results::<models::MemberModel>(conn) {
|
||||||
Ok(m) => Ok(m),
|
Ok(m) => Ok(m),
|
||||||
Err(e) => match e {
|
Err(e) => match e {
|
||||||
|
|
|
@ -123,8 +123,16 @@ pub struct FindAllSearch {
|
||||||
///
|
///
|
||||||
pub parent_member_id: Option<uuid::Uuid>,
|
pub parent_member_id: Option<uuid::Uuid>,
|
||||||
///
|
///
|
||||||
|
pub username: Option<String>,
|
||||||
|
///
|
||||||
|
pub usernames: Vec<String>,
|
||||||
|
///
|
||||||
pub username_like: Option<String>,
|
pub username_like: Option<String>,
|
||||||
///
|
///
|
||||||
|
pub nickname: Option<String>,
|
||||||
|
///
|
||||||
|
pub nicknames: Vec<String>,
|
||||||
|
///
|
||||||
pub nickname_like: Option<String>,
|
pub nickname_like: Option<String>,
|
||||||
///
|
///
|
||||||
pub mobile_phone_number_like: Option<String>,
|
pub mobile_phone_number_like: Option<String>,
|
||||||
|
|
|
@ -714,7 +714,11 @@ impl Service<'_> {
|
||||||
member_class_id,
|
member_class_id,
|
||||||
member_level_id,
|
member_level_id,
|
||||||
parent_member_id,
|
parent_member_id,
|
||||||
|
username: s.username,
|
||||||
|
usernames: s.usernames,
|
||||||
username_like: s.username_like,
|
username_like: s.username_like,
|
||||||
|
nickname: s.nickname,
|
||||||
|
nicknames: s.nicknames,
|
||||||
nickname_like: s.nickname_like,
|
nickname_like: s.nickname_like,
|
||||||
mobile_phone_number_like: s.mobile_phone_number_like,
|
mobile_phone_number_like: s.mobile_phone_number_like,
|
||||||
last_signined_ip: s.last_signined_ip,
|
last_signined_ip: s.last_signined_ip,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user