member_game_setting, member_settlement_setting are added
This commit is contained in:
parent
da5dbe49b0
commit
630618ecf5
13
Cargo.toml
13
Cargo.toml
|
@ -14,7 +14,14 @@ path = "./src/main.rs"
|
||||||
anyhow = { version = "=1.0.59" }
|
anyhow = { version = "=1.0.59" }
|
||||||
captcha = { version = "0" }
|
captcha = { version = "0" }
|
||||||
chrono = { version = "0" }
|
chrono = { version = "0" }
|
||||||
diesel = { version = "1", features = ["chrono", "r2d2", "uuidv07", "postgres"] }
|
diesel = { version = "1", default-features = false, features = [
|
||||||
|
"chrono",
|
||||||
|
"r2d2",
|
||||||
|
"uuidv07",
|
||||||
|
"postgres",
|
||||||
|
"serde_json",
|
||||||
|
"64-column-tables",
|
||||||
|
] }
|
||||||
diesel_migrations = { version = "1" }
|
diesel_migrations = { version = "1" }
|
||||||
diesel-derive-enum = { version = "1", features = ["postgres"] }
|
diesel-derive-enum = { version = "1", features = ["postgres"] }
|
||||||
futures = { version = "0", default-features = false, features = [
|
futures = { version = "0", default-features = false, features = [
|
||||||
|
@ -31,7 +38,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
tokio-cron-scheduler = { version = "0" }
|
tokio-cron-scheduler = { version = "0" }
|
||||||
uuid = { version = "0", features = ["serde", "v4", "v5"] }
|
uuid = { version = "0", features = ["serde", "v4", "v5"] }
|
||||||
|
|
||||||
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.69-snapshot" }
|
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.70-snapshot" }
|
||||||
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.53-snapshot" }
|
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.54-snapshot" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
3
migrations/202207051000_member_game_setting/down.sql
Normal file
3
migrations/202207051000_member_game_setting/down.sql
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
DROP INDEX idx_member_game_settings_member_id;
|
||||||
|
DROP TRIGGER tg_member_game_settings_updated_at;
|
||||||
|
DROP TABLE member_game_settings;
|
25
migrations/202207051000_member_game_setting/up.sql
Normal file
25
migrations/202207051000_member_game_setting/up.sql
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS member_game_settings (
|
||||||
|
id UUID DEFAULT uuid_generate_v4(),
|
||||||
|
member_id UUID NOT NULL,
|
||||||
|
can_bet_casino BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
can_bet_slot BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
can_bet_powerball BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
can_bet_powerladder BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
can_bet_eos BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
can_bet_bogglepowerball BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
||||||
|
updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
||||||
|
PRIMARY KEY (id),
|
||||||
|
CONSTRAINT fk_member_game_settings_member_id
|
||||||
|
FOREIGN KEY(member_id)
|
||||||
|
REFERENCES members(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_member_game_settings_member_id ON member_game_settings (member_id);
|
||||||
|
|
||||||
|
-- trigger (updated_at)
|
||||||
|
CREATE TRIGGER tg_member_game_settings_updated_at
|
||||||
|
BEFORE UPDATE
|
||||||
|
ON member_game_settings
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE PROCEDURE update_updated_at_column();
|
|
@ -0,0 +1,3 @@
|
||||||
|
DROP INDEX idx_member_settlement_settings_member_id;
|
||||||
|
DROP TRIGGER tg_member_settlement_settings_updated_at;
|
||||||
|
DROP TABLE member_settlement_settings;
|
42
migrations/202207101000_member_settlement_setting/up.sql
Normal file
42
migrations/202207101000_member_settlement_setting/up.sql
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
CREATE TYPE settlement_type AS ENUM ('rolling', 'loosing');
|
||||||
|
CREATE TYPE manual_payment_type AS ENUM ('all_child_partner', 'only_direct_partner', 'disable');
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS member_settlement_settings (
|
||||||
|
id UUID DEFAULT uuid_generate_v4(),
|
||||||
|
member_id UUID NOT NULL,
|
||||||
|
can_exchange BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
can_first_charge_comp BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
can_per_charge_comp BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
manual_payment_type_for_partner MANUAL_PAYMENT_TYPE DEFAULT 'all_child_partner',
|
||||||
|
settlement_type SETTLEMENT_TYPE DEFAULT 'rolling',
|
||||||
|
rate_casino DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_casino_loosing DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_casino_bacara DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_casino_roulette DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_casino_dragon_tiger DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_slot DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_slot_loosing DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_powerball_single DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_powerball_combo DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_powerladder_single DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_powerladder_combo DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_eos_single DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_eos_combo DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_bogglepowerball_single DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
rate_bogglepowerball_combo DOUBLE PRECISION NOT NULL DEFAULT 0.00,
|
||||||
|
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
||||||
|
updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
||||||
|
PRIMARY KEY (id),
|
||||||
|
CONSTRAINT fk_member_settlement_settings_member_id
|
||||||
|
FOREIGN KEY(member_id)
|
||||||
|
REFERENCES members(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_member_settlement_settings_member_id ON member_settlement_settings (member_id);
|
||||||
|
|
||||||
|
-- trigger (updated_at)
|
||||||
|
CREATE TRIGGER tg_member_settlement_settings_updated_at
|
||||||
|
BEFORE UPDATE
|
||||||
|
ON member_settlement_settings
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE PROCEDURE update_updated_at_column();
|
|
@ -68,6 +68,42 @@ SELECT
|
||||||
_m.updated_at as _m_updated_at,
|
_m.updated_at as _m_updated_at,
|
||||||
_m.deleted_at as _m_deleted_at,
|
_m.deleted_at as _m_deleted_at,
|
||||||
|
|
||||||
|
mgs.id as mgs_id,
|
||||||
|
mgs.member_id as mgs_member_id,
|
||||||
|
mgs.can_bet_casino as mgs_can_bet_casino,
|
||||||
|
mgs.can_bet_slot as mgs_can_bet_slot,
|
||||||
|
mgs.can_bet_powerball as mgs_can_bet_powerball,
|
||||||
|
mgs.can_bet_powerladder as mgs_can_bet_powerladder,
|
||||||
|
mgs.can_bet_eos as mgs_can_bet_eos,
|
||||||
|
mgs.can_bet_bogglepowerball as mgs_can_bet_bogglepowerball,
|
||||||
|
mgs.created_at as mgs_created_at,
|
||||||
|
mgs.updated_at as mgs_updated_at,
|
||||||
|
|
||||||
|
mss.id as mss_id,
|
||||||
|
mss.member_id as mss_member_id,
|
||||||
|
mss.can_exchange as mss_can_exchange,
|
||||||
|
mss.can_first_charge_comp as mss_can_first_charge_comp,
|
||||||
|
mss.can_per_charge_comp as mss_can_per_charge_comp,
|
||||||
|
mss.manual_payment_type_for_partner as mss_manual_payment_type_for_partner,
|
||||||
|
mss.settlement_type as mss_settlement_type,
|
||||||
|
mss.rate_casino as mss_rate_casino,
|
||||||
|
mss.rate_casino_loosing as mss_rate_casino_loosing,
|
||||||
|
mss.rate_casino_bacara as mss_rate_casino_bacara,
|
||||||
|
mss.rate_casino_roulette as mss_rate_casino_roulette,
|
||||||
|
mss.rate_casino_dragon_tiger as mss_rate_casino_dragon_tiger,
|
||||||
|
mss.rate_slot as mss_rate_slot,
|
||||||
|
mss.rate_slot_loosing as mss_rate_slot_loosing,
|
||||||
|
mss.rate_powerball_single as mss_rate_powerball_single,
|
||||||
|
mss.rate_powerball_combo as mss_rate_powerball_combo,
|
||||||
|
mss.rate_powerladder_single as mss_rate_powerladder_single,
|
||||||
|
mss.rate_powerladder_combo as mss_rate_powerladder_combo,
|
||||||
|
mss.rate_eos_single as mss_rate_eos_single,
|
||||||
|
mss.rate_eos_combo as mss_rate_eos_combo,
|
||||||
|
mss.rate_bogglepowerball_single as mss_rate_bogglepowerball_single,
|
||||||
|
mss.rate_bogglepowerball_combo as mss_rate_bogglepowerball_combo,
|
||||||
|
mss.created_at as mss_created_at,
|
||||||
|
mss.updated_at as mss_updated_at,
|
||||||
|
|
||||||
mba.id as mba_id,
|
mba.id as mba_id,
|
||||||
mba.member_id as mba_member_id,
|
mba.member_id as mba_member_id,
|
||||||
mba.bank_id as mba_bank_id,
|
mba.bank_id as mba_bank_id,
|
||||||
|
@ -96,6 +132,10 @@ FROM members as m
|
||||||
ON ml.id = m.member_level_id
|
ON ml.id = m.member_level_id
|
||||||
LEFT OUTER JOIN members _m
|
LEFT OUTER JOIN members _m
|
||||||
ON _m.id = m.parent_member_id
|
ON _m.id = m.parent_member_id
|
||||||
|
LEFT OUTER JOIN member_settlement_settings mss
|
||||||
|
ON mss.member_id = m.id
|
||||||
|
LEFT OUTER JOIN member_game_settings mgs
|
||||||
|
ON mgs.member_id = m.id
|
||||||
LEFT OUTER JOIN member_bank_accounts mba
|
LEFT OUTER JOIN member_bank_accounts mba
|
||||||
ON mba.member_id = m.id
|
ON mba.member_id = m.id
|
||||||
LEFT OUTER JOIN banks _b
|
LEFT OUTER JOIN banks _b
|
||||||
|
|
|
@ -3,12 +3,15 @@
|
||||||
use crate::repositories::{
|
use crate::repositories::{
|
||||||
bank::models::Bank as _Bank, member::models::Member as _Member,
|
bank::models::Bank as _Bank, member::models::Member as _Member,
|
||||||
member::schema::MemberState as _MemberState, member_class::models::MemberClass as _MemberClass,
|
member::schema::MemberState as _MemberState, member_class::models::MemberClass as _MemberClass,
|
||||||
member_level::models::MemberLevel as _MemberLevel, site::models::Site as _Site,
|
member_game_setting::models::MemberGameSetting as _MemberGameSetting,
|
||||||
|
member_level::models::MemberLevel as _MemberLevel,
|
||||||
|
member_settlement_setting::models::MemberSettlementSetting as _MemberSettlementSetting,
|
||||||
|
site::models::Site as _Site,
|
||||||
};
|
};
|
||||||
use diesel::deserialize::QueryableByName;
|
use diesel::deserialize::QueryableByName;
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Eq, Hash, PartialEq, Debug, Clone)]
|
#[derive(PartialEq, PartialOrd, Debug, Clone)]
|
||||||
pub struct MemberModel {
|
pub struct MemberModel {
|
||||||
///
|
///
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
|
@ -27,15 +30,19 @@ pub struct MemberModel {
|
||||||
///
|
///
|
||||||
pub nickname: String,
|
pub nickname: String,
|
||||||
///
|
///
|
||||||
|
pub parent_member: Option<_Member>,
|
||||||
|
///
|
||||||
|
pub child_member_count: i64,
|
||||||
|
///
|
||||||
pub mobile_phone_number: Option<String>,
|
pub mobile_phone_number: Option<String>,
|
||||||
///
|
///
|
||||||
pub state: _MemberState,
|
pub state: _MemberState,
|
||||||
///
|
///
|
||||||
pub state_changed_at: Option<i64>,
|
pub state_changed_at: Option<i64>,
|
||||||
///
|
///
|
||||||
pub parent_member: Option<_Member>,
|
pub member_game_setting: Option<_MemberGameSetting>,
|
||||||
///
|
///
|
||||||
pub child_member_count: i64,
|
pub member_settlement_setting: Option<_MemberSettlementSetting>,
|
||||||
///
|
///
|
||||||
pub last_signined_ip: Option<String>,
|
pub last_signined_ip: Option<String>,
|
||||||
///
|
///
|
||||||
|
@ -107,6 +114,56 @@ impl QueryableByName<diesel::pg::Pg> for MemberModel {
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let member_game_setting = match row
|
||||||
|
.get::<diesel::sql_types::Nullable<diesel::sql_types::Uuid>, Option<uuid::Uuid>>("mgs_id")?
|
||||||
|
{
|
||||||
|
Some(_) => Some(_MemberGameSetting {
|
||||||
|
id: row.get("mgs_id")?,
|
||||||
|
member_id: row.get("mgs_member_id")?,
|
||||||
|
can_bet_casino: row.get("mgs_can_bet_casino")?,
|
||||||
|
can_bet_slot: row.get("mgs_can_bet_slot")?,
|
||||||
|
can_bet_powerball: row.get("mgs_can_bet_powerball")?,
|
||||||
|
can_bet_powerladder: row.get("mgs_can_bet_powerladder")?,
|
||||||
|
can_bet_eos: row.get("mgs_can_bet_eos")?,
|
||||||
|
can_bet_bogglepowerball: row.get("mgs_can_bet_bogglepowerball")?,
|
||||||
|
created_at: row.get("mgs_created_at")?,
|
||||||
|
updated_at: row.get("mgs_updated_at")?,
|
||||||
|
}),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let member_settlement_setting = match row
|
||||||
|
.get::<diesel::sql_types::Nullable<diesel::sql_types::Uuid>, Option<uuid::Uuid>>("mss_id")?
|
||||||
|
{
|
||||||
|
Some(_) => Some(_MemberSettlementSetting {
|
||||||
|
id: row.get("mss_id")?,
|
||||||
|
member_id: row.get("mss_member_id")?,
|
||||||
|
can_exchange: row.get("mss_can_exchange")?,
|
||||||
|
can_first_charge_comp: row.get("mss_can_first_charge_comp")?,
|
||||||
|
can_per_charge_comp: row.get("mss_can_per_charge_comp")?,
|
||||||
|
manual_payment_type_for_partner: row.get("mss_manual_payment_type_for_partner")?,
|
||||||
|
settlement_type: row.get("mss_settlement_type")?,
|
||||||
|
rate_casino: row.get("mss_rate_casino")?,
|
||||||
|
rate_casino_loosing: row.get("mss_rate_casino_loosing")?,
|
||||||
|
rate_casino_bacara: row.get("mss_rate_casino_bacara")?,
|
||||||
|
rate_casino_roulette: row.get("mss_rate_casino_roulette")?,
|
||||||
|
rate_casino_dragon_tiger: row.get("mss_rate_casino_dragon_tiger")?,
|
||||||
|
rate_slot: row.get("mss_rate_slot")?,
|
||||||
|
rate_slot_loosing: row.get("mss_rate_slot_loosing")?,
|
||||||
|
rate_powerball_single: row.get("mss_rate_powerball_single")?,
|
||||||
|
rate_powerball_combo: row.get("mss_rate_powerball_combo")?,
|
||||||
|
rate_powerladder_single: row.get("mss_rate_powerladder_single")?,
|
||||||
|
rate_powerladder_combo: row.get("mss_rate_powerladder_combo")?,
|
||||||
|
rate_eos_single: row.get("mss_rate_eos_single")?,
|
||||||
|
rate_eos_combo: row.get("mss_rate_eos_combo")?,
|
||||||
|
rate_bogglepowerball_single: row.get("mss_rate_bogglepowerball_single")?,
|
||||||
|
rate_bogglepowerball_combo: row.get("mss_rate_bogglepowerball_combo")?,
|
||||||
|
created_at: row.get("mss_created_at")?,
|
||||||
|
updated_at: row.get("mss_updated_at")?,
|
||||||
|
}),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
Ok(MemberModel {
|
Ok(MemberModel {
|
||||||
id: row.get("m_id")?,
|
id: row.get("m_id")?,
|
||||||
site: _Site {
|
site: _Site {
|
||||||
|
@ -144,6 +201,8 @@ impl QueryableByName<diesel::pg::Pg> for MemberModel {
|
||||||
state: row.get("m_state")?,
|
state: row.get("m_state")?,
|
||||||
state_changed_at: row.get("m_state_changed_at")?,
|
state_changed_at: row.get("m_state_changed_at")?,
|
||||||
bank_account: member_bank_account,
|
bank_account: member_bank_account,
|
||||||
|
member_game_setting,
|
||||||
|
member_settlement_setting,
|
||||||
parent_member,
|
parent_member,
|
||||||
child_member_count: row.get("m_child_member_count")?,
|
child_member_count: row.get("m_child_member_count")?,
|
||||||
last_signined_ip: row.get("m_last_signined_ip")?,
|
last_signined_ip: row.get("m_last_signined_ip")?,
|
||||||
|
@ -155,7 +214,7 @@ impl QueryableByName<diesel::pg::Pg> for MemberModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, Hash, PartialEq, Debug, Clone)]
|
#[derive(Eq, Hash, PartialEq, PartialOrd, Debug, Clone)]
|
||||||
pub struct MemberBankAccountModel {
|
pub struct MemberBankAccountModel {
|
||||||
///
|
///
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::schema::banks;
|
||||||
use beteran_common_rust as bcr;
|
use beteran_common_rust as bcr;
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, Debug, Clone)]
|
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, PartialOrd, Debug, Clone)]
|
||||||
#[table_name = "banks"]
|
#[table_name = "banks"]
|
||||||
pub struct Bank {
|
pub struct Bank {
|
||||||
///
|
///
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::schema::{members, MemberState};
|
||||||
use beteran_common_rust as bcr;
|
use beteran_common_rust as bcr;
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Eq, Hash, PartialEq, Debug, Clone, Identifiable, Queryable)]
|
#[derive(Eq, Hash, PartialEq, PartialOrd, Debug, Clone, Identifiable, Queryable)]
|
||||||
#[table_name = "members"]
|
#[table_name = "members"]
|
||||||
pub struct Member {
|
pub struct Member {
|
||||||
///
|
///
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//!
|
//!
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Eq, Hash, Debug, Clone, Copy, PartialEq, diesel_derive_enum::DbEnum)]
|
#[derive(Eq, Hash, Debug, Clone, Copy, PartialEq, PartialOrd, diesel_derive_enum::DbEnum)]
|
||||||
pub enum MemberState {
|
pub enum MemberState {
|
||||||
Normal,
|
Normal,
|
||||||
Pending,
|
Pending,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::schema::member_classes;
|
||||||
use beteran_common_rust as bcr;
|
use beteran_common_rust as bcr;
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, Debug, Clone)]
|
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, PartialOrd, Debug, Clone)]
|
||||||
#[table_name = "member_classes"]
|
#[table_name = "member_classes"]
|
||||||
pub struct MemberClass {
|
pub struct MemberClass {
|
||||||
///
|
///
|
||||||
|
|
9
src/repositories/member_game_setting/mod.rs
Normal file
9
src/repositories/member_game_setting/mod.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
|
||||||
|
///
|
||||||
|
pub mod models;
|
||||||
|
///
|
||||||
|
pub mod repository;
|
||||||
|
///
|
||||||
|
pub mod schema;
|
72
src/repositories/member_game_setting/models.rs
Normal file
72
src/repositories/member_game_setting/models.rs
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
use super::schema::member_game_settings;
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Identifiable, Queryable, PartialEq, PartialOrd, Debug, Clone)]
|
||||||
|
#[table_name = "member_game_settings"]
|
||||||
|
pub struct MemberGameSetting {
|
||||||
|
///
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
///
|
||||||
|
pub member_id: uuid::Uuid,
|
||||||
|
///
|
||||||
|
pub can_bet_casino: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_slot: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_powerball: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_powerladder: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_eos: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_bogglepowerball: bool,
|
||||||
|
///
|
||||||
|
pub created_at: i64,
|
||||||
|
///
|
||||||
|
pub updated_at: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Insertable, Debug, Clone)]
|
||||||
|
#[table_name = "member_game_settings"]
|
||||||
|
pub struct NewMemberGameSetting {
|
||||||
|
///
|
||||||
|
pub member_id: uuid::Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(AsChangeset, Debug, Clone)]
|
||||||
|
#[table_name = "member_game_settings"]
|
||||||
|
pub struct ModifyMemberGameSetting {
|
||||||
|
///
|
||||||
|
pub can_bet_casino: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_slot: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_powerball: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_powerladder: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_eos: bool,
|
||||||
|
///
|
||||||
|
pub can_bet_bogglepowerball: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct FindAllSearch {
|
||||||
|
///
|
||||||
|
pub member_id: Option<uuid::Uuid>,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct FindAll {
|
||||||
|
///
|
||||||
|
pub search: Option<FindAllSearch>,
|
||||||
|
///
|
||||||
|
pub pagination: Option<bcr::models::pagination::Pagination>,
|
||||||
|
///
|
||||||
|
pub sorts: Option<Vec<bcr::models::pagination::Sort>>,
|
||||||
|
}
|
172
src/repositories/member_game_setting/repository.rs
Normal file
172
src/repositories/member_game_setting/repository.rs
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
use super::{models, schema::member_game_settings};
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use diesel::prelude::*;
|
||||||
|
use diesel::result::Error;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Repository {}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Repository {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("Repository of member_game_settings")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Repository {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Repository {
|
||||||
|
///
|
||||||
|
pub fn new() -> Repository {
|
||||||
|
Repository {}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn insert(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
new_resource: &models::NewMemberGameSetting,
|
||||||
|
) -> Result<models::MemberGameSetting, Error> {
|
||||||
|
let inserted = diesel::insert_into(member_game_settings::table)
|
||||||
|
.values(new_resource)
|
||||||
|
.get_result::<models::MemberGameSetting>(conn)?;
|
||||||
|
|
||||||
|
Ok(inserted)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
id: uuid::Uuid,
|
||||||
|
) -> Result<Option<models::MemberGameSetting>, Error> {
|
||||||
|
match member_game_settings::table
|
||||||
|
.find(id as uuid::Uuid)
|
||||||
|
.first::<models::MemberGameSetting>(conn)
|
||||||
|
{
|
||||||
|
Ok(m) => Ok(Some(m)),
|
||||||
|
Err(e) => match e {
|
||||||
|
diesel::result::Error::NotFound => Ok(None),
|
||||||
|
_ => Err(e),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select_by_member_id(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
member_id: uuid::Uuid,
|
||||||
|
) -> Result<Option<models::MemberGameSetting>, Error> {
|
||||||
|
use member_game_settings::dsl;
|
||||||
|
|
||||||
|
match member_game_settings::table
|
||||||
|
.filter(dsl::member_id.eq(member_id))
|
||||||
|
.first::<models::MemberGameSetting>(conn)
|
||||||
|
{
|
||||||
|
Ok(m) => Ok(Some(m)),
|
||||||
|
Err(e) => match e {
|
||||||
|
diesel::result::Error::NotFound => Ok(None),
|
||||||
|
_ => Err(e),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select_all_count(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
find_all: &models::FindAll,
|
||||||
|
) -> Result<i64, Error> {
|
||||||
|
let mut q = member_game_settings::table.into_boxed();
|
||||||
|
|
||||||
|
if let Some(s) = &find_all.search {
|
||||||
|
if let Some(sp) = s.member_id {
|
||||||
|
q = q.filter(member_game_settings::dsl::member_id.eq(sp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
q.count().get_result(conn)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select_all(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
find_all: &models::FindAll,
|
||||||
|
) -> Result<Vec<models::MemberGameSetting>, Error> {
|
||||||
|
let mut q = member_game_settings::table.into_boxed();
|
||||||
|
|
||||||
|
if let Some(s) = &find_all.search {
|
||||||
|
if let Some(sp) = s.member_id {
|
||||||
|
q = q.filter(member_game_settings::dsl::member_id.eq(sp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(p) = &find_all.pagination {
|
||||||
|
let page = p.page.unwrap_or(1);
|
||||||
|
|
||||||
|
if let Some(page_size) = p.page_size {
|
||||||
|
q = q.offset(((page - 1) * page_size) as i64);
|
||||||
|
q = q.limit(page_size as i64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(orderbys) = &find_all.sorts {
|
||||||
|
for s in orderbys {
|
||||||
|
match s {
|
||||||
|
bcr::models::pagination::Sort::ASC(property) => match property.as_str() {
|
||||||
|
"created_at" => {
|
||||||
|
q = q.order_by(member_game_settings::created_at.asc());
|
||||||
|
}
|
||||||
|
"updated_at" => {
|
||||||
|
q = q.order_by(member_game_settings::updated_at.asc());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
bcr::models::pagination::Sort::DESC(property) => match property.as_str() {
|
||||||
|
"created_at" => {
|
||||||
|
q = q.order_by(member_game_settings::created_at.desc());
|
||||||
|
}
|
||||||
|
"updated_at" => {
|
||||||
|
q = q.order_by(member_game_settings::updated_at.desc());
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
q.load::<models::MemberGameSetting>(conn)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn update(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
id: uuid::Uuid,
|
||||||
|
modify: &models::ModifyMemberGameSetting,
|
||||||
|
) -> Result<u64, Error> {
|
||||||
|
use member_game_settings::dsl;
|
||||||
|
|
||||||
|
diesel::update(dsl::member_game_settings.filter(dsl::id.eq(id)))
|
||||||
|
.set(modify)
|
||||||
|
.execute(conn)
|
||||||
|
.map(|c| c as u64)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn delete(&self, conn: &diesel::PgConnection, id: uuid::Uuid) -> Result<u64, Error> {
|
||||||
|
use member_game_settings::dsl;
|
||||||
|
|
||||||
|
diesel::delete(member_game_settings::table.filter(dsl::id.eq(id)))
|
||||||
|
.execute(conn)
|
||||||
|
.map(|c| c as u64)
|
||||||
|
}
|
||||||
|
}
|
29
src/repositories/member_game_setting/schema.rs
Normal file
29
src/repositories/member_game_setting/schema.rs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
|
||||||
|
table! {
|
||||||
|
|
||||||
|
///
|
||||||
|
member_game_settings(id) {
|
||||||
|
///
|
||||||
|
id -> Uuid,
|
||||||
|
///
|
||||||
|
member_id -> Uuid,
|
||||||
|
///
|
||||||
|
can_bet_casino -> Bool,
|
||||||
|
///
|
||||||
|
can_bet_slot -> Bool,
|
||||||
|
///
|
||||||
|
can_bet_powerball -> Bool,
|
||||||
|
///
|
||||||
|
can_bet_powerladder -> Bool,
|
||||||
|
///
|
||||||
|
can_bet_eos -> Bool,
|
||||||
|
///
|
||||||
|
can_bet_bogglepowerball -> Bool,
|
||||||
|
///
|
||||||
|
created_at -> BigInt,
|
||||||
|
///
|
||||||
|
updated_at -> BigInt,
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ use super::schema::member_levels;
|
||||||
use beteran_common_rust as bcr;
|
use beteran_common_rust as bcr;
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, Debug, Clone)]
|
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, PartialOrd, Debug, Clone)]
|
||||||
#[table_name = "member_levels"]
|
#[table_name = "member_levels"]
|
||||||
pub struct MemberLevel {
|
pub struct MemberLevel {
|
||||||
///
|
///
|
||||||
|
|
9
src/repositories/member_settlement_setting/mod.rs
Normal file
9
src/repositories/member_settlement_setting/mod.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
|
||||||
|
///
|
||||||
|
pub mod models;
|
||||||
|
///
|
||||||
|
pub mod repository;
|
||||||
|
///
|
||||||
|
pub mod schema;
|
128
src/repositories/member_settlement_setting/models.rs
Normal file
128
src/repositories/member_settlement_setting/models.rs
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
use super::schema::{member_settlement_settings, ManualPaymentType, SettlementType};
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Identifiable, Queryable, PartialEq, PartialOrd, Debug, Clone)]
|
||||||
|
#[table_name = "member_settlement_settings"]
|
||||||
|
pub struct MemberSettlementSetting {
|
||||||
|
///
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
///
|
||||||
|
pub member_id: uuid::Uuid,
|
||||||
|
///
|
||||||
|
pub can_exchange: bool,
|
||||||
|
///
|
||||||
|
pub can_first_charge_comp: bool,
|
||||||
|
///
|
||||||
|
pub can_per_charge_comp: bool,
|
||||||
|
///
|
||||||
|
pub manual_payment_type_for_partner: ManualPaymentType,
|
||||||
|
///
|
||||||
|
pub settlement_type: SettlementType,
|
||||||
|
///
|
||||||
|
pub rate_casino: f64,
|
||||||
|
///
|
||||||
|
pub rate_casino_loosing: f64,
|
||||||
|
///
|
||||||
|
pub rate_casino_bacara: f64,
|
||||||
|
///
|
||||||
|
pub rate_casino_roulette: f64,
|
||||||
|
///
|
||||||
|
pub rate_casino_dragon_tiger: f64,
|
||||||
|
///
|
||||||
|
pub rate_slot: f64,
|
||||||
|
///
|
||||||
|
pub rate_slot_loosing: f64,
|
||||||
|
///
|
||||||
|
pub rate_powerball_single: f64,
|
||||||
|
///
|
||||||
|
pub rate_powerball_combo: f64,
|
||||||
|
///
|
||||||
|
pub rate_powerladder_single: f64,
|
||||||
|
///
|
||||||
|
pub rate_powerladder_combo: f64,
|
||||||
|
///
|
||||||
|
pub rate_eos_single: f64,
|
||||||
|
///
|
||||||
|
pub rate_eos_combo: f64,
|
||||||
|
///
|
||||||
|
pub rate_bogglepowerball_single: f64,
|
||||||
|
///
|
||||||
|
pub rate_bogglepowerball_combo: f64,
|
||||||
|
///
|
||||||
|
pub created_at: i64,
|
||||||
|
///
|
||||||
|
pub updated_at: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Insertable, Debug, Clone)]
|
||||||
|
#[table_name = "member_settlement_settings"]
|
||||||
|
pub struct NewMemberSettlementSetting {
|
||||||
|
///
|
||||||
|
pub member_id: uuid::Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(AsChangeset, Debug, Clone)]
|
||||||
|
#[table_name = "member_settlement_settings"]
|
||||||
|
pub struct ModifyMemberSettlementSetting {
|
||||||
|
///
|
||||||
|
pub can_exchange: bool,
|
||||||
|
///
|
||||||
|
pub can_first_charge_comp: bool,
|
||||||
|
///
|
||||||
|
pub can_per_charge_comp: bool,
|
||||||
|
///
|
||||||
|
pub manual_payment_type_for_partner: ManualPaymentType,
|
||||||
|
///
|
||||||
|
pub settlement_type: SettlementType,
|
||||||
|
///
|
||||||
|
pub rate_casino: f64,
|
||||||
|
///
|
||||||
|
pub rate_casino_loosing: f64,
|
||||||
|
///
|
||||||
|
pub rate_casino_bacara: f64,
|
||||||
|
///
|
||||||
|
pub rate_casino_roulette: f64,
|
||||||
|
///
|
||||||
|
pub rate_casino_dragon_tiger: f64,
|
||||||
|
///
|
||||||
|
pub rate_slot: f64,
|
||||||
|
///
|
||||||
|
pub rate_slot_loosing: f64,
|
||||||
|
///
|
||||||
|
pub rate_powerball_single: f64,
|
||||||
|
///
|
||||||
|
pub rate_powerball_combo: f64,
|
||||||
|
///
|
||||||
|
pub rate_powerladder_single: f64,
|
||||||
|
///
|
||||||
|
pub rate_powerladder_combo: f64,
|
||||||
|
///
|
||||||
|
pub rate_eos_single: f64,
|
||||||
|
///
|
||||||
|
pub rate_eos_combo: f64,
|
||||||
|
///
|
||||||
|
pub rate_bogglepowerball_single: f64,
|
||||||
|
///
|
||||||
|
pub rate_bogglepowerball_combo: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct FindAllSearch {
|
||||||
|
///
|
||||||
|
pub member_id: Option<uuid::Uuid>,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct FindAll {
|
||||||
|
///
|
||||||
|
pub search: Option<FindAllSearch>,
|
||||||
|
///
|
||||||
|
pub pagination: Option<bcr::models::pagination::Pagination>,
|
||||||
|
///
|
||||||
|
pub sorts: Option<Vec<bcr::models::pagination::Sort>>,
|
||||||
|
}
|
262
src/repositories/member_settlement_setting/repository.rs
Normal file
262
src/repositories/member_settlement_setting/repository.rs
Normal file
|
@ -0,0 +1,262 @@
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
use super::{models, schema::member_settlement_settings};
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use diesel::prelude::*;
|
||||||
|
use diesel::result::Error;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Repository {}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Repository {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("Repository of member_settlement_settings")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Repository {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Repository {
|
||||||
|
///
|
||||||
|
pub fn new() -> Repository {
|
||||||
|
Repository {}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn insert(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
new_resource: &models::NewMemberSettlementSetting,
|
||||||
|
) -> Result<models::MemberSettlementSetting, Error> {
|
||||||
|
let inserted = diesel::insert_into(member_settlement_settings::table)
|
||||||
|
.values(new_resource)
|
||||||
|
.get_result::<models::MemberSettlementSetting>(conn)?;
|
||||||
|
|
||||||
|
Ok(inserted)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
id: uuid::Uuid,
|
||||||
|
) -> Result<Option<models::MemberSettlementSetting>, Error> {
|
||||||
|
match member_settlement_settings::table
|
||||||
|
.find(id as uuid::Uuid)
|
||||||
|
.first::<models::MemberSettlementSetting>(conn)
|
||||||
|
{
|
||||||
|
Ok(m) => Ok(Some(m)),
|
||||||
|
Err(e) => match e {
|
||||||
|
diesel::result::Error::NotFound => Ok(None),
|
||||||
|
_ => Err(e),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select_by_member_id(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
member_id: uuid::Uuid,
|
||||||
|
) -> Result<Option<models::MemberSettlementSetting>, Error> {
|
||||||
|
use member_settlement_settings::dsl;
|
||||||
|
|
||||||
|
match member_settlement_settings::table
|
||||||
|
.filter(dsl::member_id.eq(member_id))
|
||||||
|
.first::<models::MemberSettlementSetting>(conn)
|
||||||
|
{
|
||||||
|
Ok(m) => Ok(Some(m)),
|
||||||
|
Err(e) => match e {
|
||||||
|
diesel::result::Error::NotFound => Ok(None),
|
||||||
|
_ => Err(e),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select_all_count(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
find_all: &models::FindAll,
|
||||||
|
) -> Result<i64, Error> {
|
||||||
|
let mut q = member_settlement_settings::table.into_boxed();
|
||||||
|
|
||||||
|
if let Some(s) = &find_all.search {
|
||||||
|
if let Some(sp) = s.member_id {
|
||||||
|
q = q.filter(member_settlement_settings::dsl::member_id.eq(sp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
q.count().get_result(conn)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn select_all(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
find_all: &models::FindAll,
|
||||||
|
) -> Result<Vec<models::MemberSettlementSetting>, Error> {
|
||||||
|
let mut q = member_settlement_settings::table.into_boxed();
|
||||||
|
|
||||||
|
if let Some(s) = &find_all.search {
|
||||||
|
if let Some(sp) = s.member_id {
|
||||||
|
q = q.filter(member_settlement_settings::dsl::member_id.eq(sp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(p) = &find_all.pagination {
|
||||||
|
let page = p.page.unwrap_or(1);
|
||||||
|
|
||||||
|
if let Some(page_size) = p.page_size {
|
||||||
|
q = q.offset(((page - 1) * page_size) as i64);
|
||||||
|
q = q.limit(page_size as i64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(orderbys) = &find_all.sorts {
|
||||||
|
for s in orderbys {
|
||||||
|
match s {
|
||||||
|
bcr::models::pagination::Sort::ASC(property) => match property.as_str() {
|
||||||
|
"rate_casino" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino.asc());
|
||||||
|
}
|
||||||
|
"rate_casino_loosing" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino_loosing.asc());
|
||||||
|
}
|
||||||
|
"rate_casino_bacara" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino_bacara.asc());
|
||||||
|
}
|
||||||
|
"rate_casino_roulette" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino_roulette.asc());
|
||||||
|
}
|
||||||
|
"rate_casino_dragon_tiger" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino_dragon_tiger.asc());
|
||||||
|
}
|
||||||
|
"rate_slot" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_slot.asc());
|
||||||
|
}
|
||||||
|
"rate_slot_loosing" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_slot_loosing.asc());
|
||||||
|
}
|
||||||
|
"rate_powerball_single" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_powerball_single.asc());
|
||||||
|
}
|
||||||
|
"rate_powerball_combo" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_powerball_combo.asc());
|
||||||
|
}
|
||||||
|
"rate_powerladder_single" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_powerladder_single.asc());
|
||||||
|
}
|
||||||
|
"rate_powerladder_combo" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_powerladder_combo.asc());
|
||||||
|
}
|
||||||
|
"rate_eos_single" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_eos_single.asc());
|
||||||
|
}
|
||||||
|
"rate_eos_combo" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_eos_combo.asc());
|
||||||
|
}
|
||||||
|
"rate_bogglepowerball_single" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_bogglepowerball_single.asc());
|
||||||
|
}
|
||||||
|
"rate_bogglepowerball_combo" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_bogglepowerball_combo.asc());
|
||||||
|
}
|
||||||
|
"created_at" => {
|
||||||
|
q = q.order_by(member_settlement_settings::created_at.asc());
|
||||||
|
}
|
||||||
|
"updated_at" => {
|
||||||
|
q = q.order_by(member_settlement_settings::updated_at.asc());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
bcr::models::pagination::Sort::DESC(property) => match property.as_str() {
|
||||||
|
"rate_casino" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino.desc());
|
||||||
|
}
|
||||||
|
"rate_casino_loosing" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino_loosing.desc());
|
||||||
|
}
|
||||||
|
"rate_casino_bacara" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino_bacara.desc());
|
||||||
|
}
|
||||||
|
"rate_casino_roulette" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino_roulette.desc());
|
||||||
|
}
|
||||||
|
"rate_casino_dragon_tiger" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_casino_dragon_tiger.desc());
|
||||||
|
}
|
||||||
|
"rate_slot" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_slot.desc());
|
||||||
|
}
|
||||||
|
"rate_slot_loosing" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_slot_loosing.desc());
|
||||||
|
}
|
||||||
|
"rate_powerball_single" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_powerball_single.desc());
|
||||||
|
}
|
||||||
|
"rate_powerball_combo" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_powerball_combo.desc());
|
||||||
|
}
|
||||||
|
"rate_powerladder_single" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_powerladder_single.desc());
|
||||||
|
}
|
||||||
|
"rate_powerladder_combo" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_powerladder_combo.desc());
|
||||||
|
}
|
||||||
|
"rate_eos_single" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_eos_single.desc());
|
||||||
|
}
|
||||||
|
"rate_eos_combo" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_eos_combo.desc());
|
||||||
|
}
|
||||||
|
"rate_bogglepowerball_single" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_bogglepowerball_single.desc());
|
||||||
|
}
|
||||||
|
"rate_bogglepowerball_combo" => {
|
||||||
|
q = q.order_by(member_settlement_settings::rate_bogglepowerball_combo.desc());
|
||||||
|
}
|
||||||
|
"created_at" => {
|
||||||
|
q = q.order_by(member_settlement_settings::created_at.desc());
|
||||||
|
}
|
||||||
|
"updated_at" => {
|
||||||
|
q = q.order_by(member_settlement_settings::updated_at.desc());
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
q.load::<models::MemberSettlementSetting>(conn)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn update(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
id: uuid::Uuid,
|
||||||
|
modify: &models::ModifyMemberSettlementSetting,
|
||||||
|
) -> Result<u64, Error> {
|
||||||
|
use member_settlement_settings::dsl;
|
||||||
|
|
||||||
|
diesel::update(dsl::member_settlement_settings.filter(dsl::id.eq(id)))
|
||||||
|
.set(modify)
|
||||||
|
.execute(conn)
|
||||||
|
.map(|c| c as u64)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn delete(&self, conn: &diesel::PgConnection, id: uuid::Uuid) -> Result<u64, Error> {
|
||||||
|
use member_settlement_settings::dsl;
|
||||||
|
|
||||||
|
diesel::delete(member_settlement_settings::table.filter(dsl::id.eq(id)))
|
||||||
|
.execute(conn)
|
||||||
|
.map(|c| c as u64)
|
||||||
|
}
|
||||||
|
}
|
74
src/repositories/member_settlement_setting/schema.rs
Normal file
74
src/repositories/member_settlement_setting/schema.rs
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Eq, Hash, Debug, Clone, Copy, PartialEq, PartialOrd, diesel_derive_enum::DbEnum)]
|
||||||
|
pub enum SettlementType {
|
||||||
|
Rolling,
|
||||||
|
Loosing,
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
#[derive(Eq, Hash, Debug, Clone, Copy, PartialEq, PartialOrd, diesel_derive_enum::DbEnum)]
|
||||||
|
pub enum ManualPaymentType {
|
||||||
|
Disable,
|
||||||
|
AllChildPartner,
|
||||||
|
OnlyDirectPartner,
|
||||||
|
}
|
||||||
|
|
||||||
|
table! {
|
||||||
|
use diesel::sql_types::{Uuid, BigInt, Bool, Double};
|
||||||
|
use super::{SettlementTypeMapping, ManualPaymentTypeMapping};
|
||||||
|
|
||||||
|
///
|
||||||
|
member_settlement_settings(id) {
|
||||||
|
///
|
||||||
|
id -> Uuid,
|
||||||
|
///
|
||||||
|
member_id -> Uuid,
|
||||||
|
///
|
||||||
|
can_exchange -> Bool,
|
||||||
|
///
|
||||||
|
can_first_charge_comp -> Bool,
|
||||||
|
///
|
||||||
|
can_per_charge_comp -> Bool,
|
||||||
|
///
|
||||||
|
manual_payment_type_for_partner -> ManualPaymentTypeMapping,
|
||||||
|
///
|
||||||
|
settlement_type -> SettlementTypeMapping,
|
||||||
|
///
|
||||||
|
rate_casino -> Double,
|
||||||
|
///
|
||||||
|
rate_casino_loosing -> Double,
|
||||||
|
///
|
||||||
|
rate_casino_bacara -> Double,
|
||||||
|
///
|
||||||
|
rate_casino_roulette -> Double,
|
||||||
|
///
|
||||||
|
rate_casino_dragon_tiger -> Double,
|
||||||
|
///
|
||||||
|
rate_slot -> Double,
|
||||||
|
///
|
||||||
|
rate_slot_loosing -> Double,
|
||||||
|
///
|
||||||
|
rate_powerball_single -> Double,
|
||||||
|
///
|
||||||
|
rate_powerball_combo -> Double,
|
||||||
|
///
|
||||||
|
rate_powerladder_single -> Double,
|
||||||
|
///
|
||||||
|
rate_powerladder_combo -> Double,
|
||||||
|
///
|
||||||
|
rate_eos_single -> Double,
|
||||||
|
///
|
||||||
|
rate_eos_combo -> Double,
|
||||||
|
///
|
||||||
|
rate_bogglepowerball_single -> Double,
|
||||||
|
///
|
||||||
|
rate_bogglepowerball_combo -> Double,
|
||||||
|
///
|
||||||
|
created_at -> BigInt,
|
||||||
|
///
|
||||||
|
updated_at -> BigInt,
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,11 +4,13 @@ pub mod member_bank_account;
|
||||||
pub mod member_bank_deposit;
|
pub mod member_bank_deposit;
|
||||||
pub mod member_bank_withdraw;
|
pub mod member_bank_withdraw;
|
||||||
pub mod member_class;
|
pub mod member_class;
|
||||||
|
pub mod member_game_setting;
|
||||||
pub mod member_level;
|
pub mod member_level;
|
||||||
pub mod member_permission;
|
pub mod member_permission;
|
||||||
pub mod member_referrer;
|
pub mod member_referrer;
|
||||||
pub mod member_role;
|
pub mod member_role;
|
||||||
pub mod member_session;
|
pub mod member_session;
|
||||||
|
pub mod member_settlement_setting;
|
||||||
pub mod resource;
|
pub mod resource;
|
||||||
pub mod resource_action;
|
pub mod resource_action;
|
||||||
pub mod role;
|
pub mod role;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::schema::sites;
|
||||||
use beteran_common_rust as bcr;
|
use beteran_common_rust as bcr;
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, Debug, Clone)]
|
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, PartialOrd, Debug, Clone)]
|
||||||
#[table_name = "sites"]
|
#[table_name = "sites"]
|
||||||
pub struct Site {
|
pub struct Site {
|
||||||
///
|
///
|
||||||
|
|
|
@ -65,7 +65,7 @@ impl From<&compositions::member::models::MemberModel> for bpr::models::member::M
|
||||||
bank_account: d
|
bank_account: d
|
||||||
.bank_account
|
.bank_account
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|d| bpr::models::member_bank_account::MemberBankAccountModel::from(d)),
|
.map(bpr::models::member_bank_account::MemberBankAccountModel::from),
|
||||||
parent_member: d
|
parent_member: d
|
||||||
.parent_member
|
.parent_member
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -76,6 +76,14 @@ impl From<&compositions::member::models::MemberModel> for bpr::models::member::M
|
||||||
mobile_phone_number: d.mobile_phone_number.clone(),
|
mobile_phone_number: d.mobile_phone_number.clone(),
|
||||||
state: d.state as i32,
|
state: d.state as i32,
|
||||||
state_changed_at: d.state_changed_at.map(|d| d as u64),
|
state_changed_at: d.state_changed_at.map(|d| d as u64),
|
||||||
|
member_game_setting: d
|
||||||
|
.member_game_setting
|
||||||
|
.as_ref()
|
||||||
|
.map(bpr::models::member_game_setting::MemberGameSetting::from),
|
||||||
|
member_settlement_setting: d
|
||||||
|
.member_settlement_setting
|
||||||
|
.as_ref()
|
||||||
|
.map(bpr::models::member_settlement_setting::MemberSettlementSetting::from),
|
||||||
last_signined_ip: d.last_signined_ip.clone(),
|
last_signined_ip: d.last_signined_ip.clone(),
|
||||||
last_signined_at: d.last_signined_at.map(|d| d as u64),
|
last_signined_at: d.last_signined_at.map(|d| d as u64),
|
||||||
created_at: d.created_at as u64,
|
created_at: d.created_at as u64,
|
||||||
|
|
2
src/services/member_game_setting/mod.rs
Normal file
2
src/services/member_game_setting/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod models;
|
||||||
|
pub mod service;
|
21
src/services/member_game_setting/models.rs
Normal file
21
src/services/member_game_setting/models.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
use crate::repositories;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
|
||||||
|
impl From<&repositories::member_game_setting::models::MemberGameSetting>
|
||||||
|
for bpr::models::member_game_setting::MemberGameSetting
|
||||||
|
{
|
||||||
|
fn from(d: &repositories::member_game_setting::models::MemberGameSetting) -> Self {
|
||||||
|
bpr::models::member_game_setting::MemberGameSetting {
|
||||||
|
id: d.id.to_string(),
|
||||||
|
member_id: d.member_id.to_string(),
|
||||||
|
can_bet_casino: d.can_bet_casino,
|
||||||
|
can_bet_slot: d.can_bet_slot,
|
||||||
|
can_bet_powerball: d.can_bet_powerball,
|
||||||
|
can_bet_powerladder: d.can_bet_powerladder,
|
||||||
|
can_bet_eos: d.can_bet_eos,
|
||||||
|
can_bet_bogglepowerball: d.can_bet_bogglepowerball,
|
||||||
|
created_at: d.created_at as u64,
|
||||||
|
updated_at: d.updated_at as u64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
795
src/services/member_game_setting/service.rs
Normal file
795
src/services/member_game_setting/service.rs
Normal file
|
@ -0,0 +1,795 @@
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
use crate::compositions;
|
||||||
|
use crate::repositories;
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
use diesel::{
|
||||||
|
r2d2::{ConnectionManager, Pool},
|
||||||
|
PgConnection,
|
||||||
|
};
|
||||||
|
use prost::Message;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Service {
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
pool: Pool<ConnectionManager<PgConnection>>,
|
||||||
|
site_repository: repositories::site::repository::Repository,
|
||||||
|
site_composition: compositions::site::composition::Composition,
|
||||||
|
member_game_setting_repository: repositories::member_game_setting::repository::Repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Service {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("Service of service.member.service.identity")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service {
|
||||||
|
///
|
||||||
|
pub fn new(
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
pool: Pool<ConnectionManager<PgConnection>>,
|
||||||
|
) -> Service {
|
||||||
|
Service {
|
||||||
|
connection_broker,
|
||||||
|
queue_broker,
|
||||||
|
pool,
|
||||||
|
site_repository: repositories::site::repository::Repository::new(),
|
||||||
|
site_composition: compositions::site::composition::Composition::new(),
|
||||||
|
member_game_setting_repository:
|
||||||
|
repositories::member_game_setting::repository::Repository::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe(&self) -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
|
||||||
|
futures::try_join!(
|
||||||
|
self.create_member_game_setting(),
|
||||||
|
self.list_member_game_settings(),
|
||||||
|
self.get_member_game_setting(),
|
||||||
|
self.update_member_game_setting(),
|
||||||
|
self.delete_member_game_setting(),
|
||||||
|
)
|
||||||
|
.map(|_| ())
|
||||||
|
}
|
||||||
|
fn check_site(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
url: Option<String>,
|
||||||
|
site_id: uuid::Uuid,
|
||||||
|
) -> Result<repositories::site::models::Site, bcr::error::rpc::Error> {
|
||||||
|
match self
|
||||||
|
.site_composition
|
||||||
|
.select_by_url(conn, url, site_id)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})? {
|
||||||
|
Some(s) => Ok(s),
|
||||||
|
None => Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid site_url information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client.site_url".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::None,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn create_member_game_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_CREATE_MEMBER_GAME_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_game_setting::CreateMemberGameSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let member_id = uuid::Uuid::from_str(request.member_id.as_str()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid member_id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "member_id".to_string(),
|
||||||
|
value: request.member_id.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let s = self
|
||||||
|
.member_game_setting_repository
|
||||||
|
.insert(
|
||||||
|
&conn,
|
||||||
|
&repositories::member_game_setting::models::NewMemberGameSetting { member_id },
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::CreateMemberGameSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_game_setting::create_member_game_setting_response::Result {
|
||||||
|
member_game_setting: Some(
|
||||||
|
bpr::models::member_game_setting::MemberGameSetting::from(&s),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::CreateMemberGameSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn list_member_game_settings(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_LIST_MEMBER_GAME_SETTINGS,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_game_setting::ListMemberGameSettingsRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let search = match request.search {
|
||||||
|
Some(s) => {
|
||||||
|
let member_id = match s.member_id {
|
||||||
|
Some(d) => match uuid::Uuid::from_str(d.as_str()) {
|
||||||
|
Ok(dd) => Some(dd),
|
||||||
|
Err(e) => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid member_id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "member_id".to_string(),
|
||||||
|
value: d.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(repositories::member_game_setting::models::FindAllSearch { member_id })
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let find_all = repositories::member_game_setting::models::FindAll {
|
||||||
|
search,
|
||||||
|
pagination: request
|
||||||
|
.pagination
|
||||||
|
.as_ref()
|
||||||
|
.map(|d| bcr::models::pagination::Pagination::from(d)),
|
||||||
|
sorts: Some(
|
||||||
|
request
|
||||||
|
.sorts
|
||||||
|
.iter()
|
||||||
|
.map(|d| beteran_common_rust::models::pagination::Sort::from(d))
|
||||||
|
.collect(),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
let count = self
|
||||||
|
.member_game_setting_repository
|
||||||
|
.select_all_count(&conn, &find_all)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let list = self
|
||||||
|
.member_game_setting_repository
|
||||||
|
.select_all(&conn, &find_all)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::ListMemberGameSettingsResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_game_setting::list_member_game_settings_response::Result {
|
||||||
|
member_game_settings: list
|
||||||
|
.iter()
|
||||||
|
.map(|d| bpr::models::member_game_setting::MemberGameSetting::from(d))
|
||||||
|
.collect(),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::ListMemberGameSettingsResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_member_game_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_GET_MEMBER_GAME_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_game_setting::GetMemberGameSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let id = uuid::Uuid::from_str(request.id.as_str()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "id".to_string(),
|
||||||
|
value: request.id.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let s = self
|
||||||
|
.member_game_setting_repository
|
||||||
|
.select(&conn, id)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::GetMemberGameSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_game_setting::get_member_game_setting_response::Result {
|
||||||
|
member_game_setting: s
|
||||||
|
.map(|d| bpr::models::member_game_setting::MemberGameSetting::from(&d)),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::GetMemberGameSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_member_game_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_UPDATE_MEMBER_GAME_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_game_setting::UpdateMemberGameSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let id = uuid::Uuid::from_str(request.id.as_str()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "id".to_string(),
|
||||||
|
value: request.id.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let _affected = self
|
||||||
|
.member_game_setting_repository
|
||||||
|
.update(
|
||||||
|
&conn,
|
||||||
|
id,
|
||||||
|
&repositories::member_game_setting::models::ModifyMemberGameSetting {
|
||||||
|
can_bet_casino: request.can_bet_casino,
|
||||||
|
can_bet_slot: request.can_bet_slot,
|
||||||
|
can_bet_powerball: request.can_bet_powerball,
|
||||||
|
can_bet_powerladder: request.can_bet_powerladder,
|
||||||
|
can_bet_eos: request.can_bet_eos,
|
||||||
|
can_bet_bogglepowerball: request.can_bet_bogglepowerball,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let s = self
|
||||||
|
.member_game_setting_repository
|
||||||
|
.select(&conn, id)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::UpdateMemberGameSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_game_setting::update_member_game_setting_response::Result {
|
||||||
|
member_game_setting: s
|
||||||
|
.map(|d| bpr::models::member_game_setting::MemberGameSetting::from(&d)),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::UpdateMemberGameSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn delete_member_game_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_DELETE_MEMBER_GAME_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_game_setting::DeleteMemberGameSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let id = uuid::Uuid::from_str(request.id.as_str()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "id".to_string(),
|
||||||
|
value: request.id.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let _affected = self
|
||||||
|
.member_game_setting_repository
|
||||||
|
.delete(&conn, id)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::DeleteMemberGameSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_game_setting::delete_member_game_setting_response::Result {},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_game_setting::DeleteMemberGameSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
2
src/services/member_settlement_setting/mod.rs
Normal file
2
src/services/member_settlement_setting/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod models;
|
||||||
|
pub mod service;
|
66
src/services/member_settlement_setting/models.rs
Normal file
66
src/services/member_settlement_setting/models.rs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
use crate::repositories;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
|
||||||
|
impl From<i32> for repositories::member_settlement_setting::schema::ManualPaymentType {
|
||||||
|
fn from(s: i32) -> Self {
|
||||||
|
match s {
|
||||||
|
s if s
|
||||||
|
== repositories::member_settlement_setting::schema::ManualPaymentType::AllChildPartner
|
||||||
|
as i32 =>
|
||||||
|
{
|
||||||
|
repositories::member_settlement_setting::schema::ManualPaymentType::AllChildPartner
|
||||||
|
}
|
||||||
|
s if s
|
||||||
|
== repositories::member_settlement_setting::schema::ManualPaymentType::OnlyDirectPartner
|
||||||
|
as i32 =>
|
||||||
|
{
|
||||||
|
repositories::member_settlement_setting::schema::ManualPaymentType::OnlyDirectPartner
|
||||||
|
}
|
||||||
|
_ => repositories::member_settlement_setting::schema::ManualPaymentType::Disable,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<i32> for repositories::member_settlement_setting::schema::SettlementType {
|
||||||
|
fn from(s: i32) -> Self {
|
||||||
|
match s {
|
||||||
|
s if s == repositories::member_settlement_setting::schema::SettlementType::Loosing as i32 => {
|
||||||
|
repositories::member_settlement_setting::schema::SettlementType::Loosing
|
||||||
|
}
|
||||||
|
_ => repositories::member_settlement_setting::schema::SettlementType::Rolling,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&repositories::member_settlement_setting::models::MemberSettlementSetting>
|
||||||
|
for bpr::models::member_settlement_setting::MemberSettlementSetting
|
||||||
|
{
|
||||||
|
fn from(d: &repositories::member_settlement_setting::models::MemberSettlementSetting) -> Self {
|
||||||
|
bpr::models::member_settlement_setting::MemberSettlementSetting {
|
||||||
|
id: d.id.to_string(),
|
||||||
|
member_id: d.member_id.to_string(),
|
||||||
|
can_exchange: d.can_exchange,
|
||||||
|
can_first_charge_comp: d.can_first_charge_comp,
|
||||||
|
can_per_charge_comp: d.can_per_charge_comp,
|
||||||
|
settlement_type: d.settlement_type as i32,
|
||||||
|
manual_payment_type_for_partner: d.manual_payment_type_for_partner as i32,
|
||||||
|
rate_casino: d.rate_casino,
|
||||||
|
rate_casino_loosing: d.rate_casino_loosing,
|
||||||
|
rate_casino_bacara: d.rate_casino_bacara,
|
||||||
|
rate_casino_roulette: d.rate_casino_roulette,
|
||||||
|
rate_casino_dragon_tiger: d.rate_casino_dragon_tiger,
|
||||||
|
rate_slot: d.rate_slot,
|
||||||
|
rate_slot_loosing: d.rate_slot_loosing,
|
||||||
|
rate_powerball_single: d.rate_powerball_single,
|
||||||
|
rate_powerball_combo: d.rate_powerball_combo,
|
||||||
|
rate_powerladder_single: d.rate_powerladder_single,
|
||||||
|
rate_powerladder_combo: d.rate_powerladder_combo,
|
||||||
|
rate_eos_single: d.rate_eos_single,
|
||||||
|
rate_eos_combo: d.rate_eos_combo,
|
||||||
|
rate_bogglepowerball_single: d.rate_bogglepowerball_single,
|
||||||
|
rate_bogglepowerball_combo: d.rate_bogglepowerball_combo,
|
||||||
|
created_at: d.created_at as u64,
|
||||||
|
updated_at: d.updated_at as u64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
814
src/services/member_settlement_setting/service.rs
Normal file
814
src/services/member_settlement_setting/service.rs
Normal file
|
@ -0,0 +1,814 @@
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
use crate::compositions;
|
||||||
|
use crate::repositories;
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
use diesel::{
|
||||||
|
r2d2::{ConnectionManager, Pool},
|
||||||
|
PgConnection,
|
||||||
|
};
|
||||||
|
use prost::Message;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Service {
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
pool: Pool<ConnectionManager<PgConnection>>,
|
||||||
|
site_repository: repositories::site::repository::Repository,
|
||||||
|
site_composition: compositions::site::composition::Composition,
|
||||||
|
member_settlement_setting_repository:
|
||||||
|
repositories::member_settlement_setting::repository::Repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Service {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("Service of service.member.service.identity")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service {
|
||||||
|
///
|
||||||
|
pub fn new(
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
pool: Pool<ConnectionManager<PgConnection>>,
|
||||||
|
) -> Service {
|
||||||
|
Service {
|
||||||
|
connection_broker,
|
||||||
|
queue_broker,
|
||||||
|
pool,
|
||||||
|
site_repository: repositories::site::repository::Repository::new(),
|
||||||
|
site_composition: compositions::site::composition::Composition::new(),
|
||||||
|
member_settlement_setting_repository:
|
||||||
|
repositories::member_settlement_setting::repository::Repository::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe(&self) -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
|
||||||
|
futures::try_join!(
|
||||||
|
self.create_member_settlement_setting(),
|
||||||
|
self.list_member_settlement_settings(),
|
||||||
|
self.get_member_settlement_setting(),
|
||||||
|
self.update_member_settlement_setting(),
|
||||||
|
self.delete_member_settlement_setting(),
|
||||||
|
)
|
||||||
|
.map(|_| ())
|
||||||
|
}
|
||||||
|
fn check_site(
|
||||||
|
&self,
|
||||||
|
conn: &diesel::PgConnection,
|
||||||
|
url: Option<String>,
|
||||||
|
site_id: uuid::Uuid,
|
||||||
|
) -> Result<repositories::site::models::Site, bcr::error::rpc::Error> {
|
||||||
|
match self
|
||||||
|
.site_composition
|
||||||
|
.select_by_url(conn, url, site_id)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})? {
|
||||||
|
Some(s) => Ok(s),
|
||||||
|
None => Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid site_url information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client.site_url".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::None,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn create_member_settlement_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_CREATE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_settlement_setting::CreateMemberSettlementSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let member_id = uuid::Uuid::from_str(request.member_id.as_str()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid member_id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "member_id".to_string(),
|
||||||
|
value: request.member_id.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let s = self
|
||||||
|
.member_settlement_setting_repository
|
||||||
|
.insert(
|
||||||
|
&conn,
|
||||||
|
&repositories::member_settlement_setting::models::NewMemberSettlementSetting {
|
||||||
|
member_id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::CreateMemberSettlementSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_settlement_setting::create_member_settlement_setting_response::Result {
|
||||||
|
member_settlement_setting: Some(
|
||||||
|
bpr::models::member_settlement_setting::MemberSettlementSetting::from(&s),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::CreateMemberSettlementSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn list_member_settlement_settings(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_LIST_MEMBER_SETTLEMENT_SETTINGS,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_settlement_setting::ListMemberSettlementSettingsRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let search = match request.search {
|
||||||
|
Some(s) => {
|
||||||
|
let member_id = match s.member_id {
|
||||||
|
Some(d) => match uuid::Uuid::from_str(d.as_str()) {
|
||||||
|
Ok(dd) => Some(dd),
|
||||||
|
Err(e) => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid member_id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "member_id".to_string(),
|
||||||
|
value: d.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(repositories::member_settlement_setting::models::FindAllSearch {
|
||||||
|
member_id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let find_all = repositories::member_settlement_setting::models::FindAll {
|
||||||
|
search,
|
||||||
|
pagination: request
|
||||||
|
.pagination
|
||||||
|
.as_ref()
|
||||||
|
.map(|d| bcr::models::pagination::Pagination::from(d)),
|
||||||
|
sorts: Some(
|
||||||
|
request
|
||||||
|
.sorts
|
||||||
|
.iter()
|
||||||
|
.map(|d| beteran_common_rust::models::pagination::Sort::from(d))
|
||||||
|
.collect(),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
let count = self
|
||||||
|
.member_settlement_setting_repository
|
||||||
|
.select_all_count(&conn, &find_all)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let list = self
|
||||||
|
.member_settlement_setting_repository
|
||||||
|
.select_all(&conn, &find_all)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::ListMemberSettlementSettingsResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_settlement_setting::list_member_settlement_settings_response::Result {
|
||||||
|
member_settlement_settings: list
|
||||||
|
.iter()
|
||||||
|
.map(|d| bpr::models::member_settlement_setting::MemberSettlementSetting::from(d))
|
||||||
|
.collect(),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::ListMemberSettlementSettingsResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_member_settlement_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_GET_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_settlement_setting::GetMemberSettlementSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let id = uuid::Uuid::from_str(request.id.as_str()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "id".to_string(),
|
||||||
|
value: request.id.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let s = self
|
||||||
|
.member_settlement_setting_repository
|
||||||
|
.select(&conn, id)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::GetMemberSettlementSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_settlement_setting::get_member_settlement_setting_response::Result {
|
||||||
|
member_settlement_setting: s
|
||||||
|
.map(|d| bpr::models::member_settlement_setting::MemberSettlementSetting::from(&d)),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::GetMemberSettlementSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_member_settlement_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_UPDATE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_settlement_setting::UpdateMemberSettlementSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let id = uuid::Uuid::from_str(request.id.as_str()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "id".to_string(),
|
||||||
|
value: request.id.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let _affected = self
|
||||||
|
.member_settlement_setting_repository
|
||||||
|
.update(
|
||||||
|
&conn,
|
||||||
|
id,
|
||||||
|
&repositories::member_settlement_setting::models::ModifyMemberSettlementSetting {
|
||||||
|
can_exchange: request.can_exchange,
|
||||||
|
can_first_charge_comp: request.can_first_charge_comp,
|
||||||
|
can_per_charge_comp: request.can_per_charge_comp,
|
||||||
|
manual_payment_type_for_partner: repositories::member_settlement_setting::schema::ManualPaymentType::from(request.manual_payment_type_for_partner),
|
||||||
|
settlement_type: repositories::member_settlement_setting::schema::SettlementType::from(request.settlement_type),
|
||||||
|
rate_casino: request.rate_casino,
|
||||||
|
rate_casino_loosing: request.rate_casino_loosing,
|
||||||
|
rate_casino_bacara: request.rate_casino_bacara,
|
||||||
|
rate_casino_roulette: request.rate_casino_roulette,
|
||||||
|
rate_casino_dragon_tiger: request.rate_casino_dragon_tiger,
|
||||||
|
rate_slot: request.rate_slot,
|
||||||
|
rate_slot_loosing: request.rate_slot_loosing,
|
||||||
|
rate_powerball_single: request.rate_powerball_single,
|
||||||
|
rate_powerball_combo: request.rate_powerball_combo,
|
||||||
|
rate_powerladder_single: request.rate_powerladder_single,
|
||||||
|
rate_powerladder_combo: request.rate_powerladder_combo,
|
||||||
|
rate_eos_single: request.rate_eos_single,
|
||||||
|
rate_eos_combo: request.rate_eos_combo,
|
||||||
|
rate_bogglepowerball_single: request.rate_bogglepowerball_single,
|
||||||
|
rate_bogglepowerball_combo: request.rate_bogglepowerball_combo,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let s = self
|
||||||
|
.member_settlement_setting_repository
|
||||||
|
.select(&conn, id)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::UpdateMemberSettlementSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_settlement_setting::update_member_settlement_setting_response::Result {
|
||||||
|
member_settlement_setting: s
|
||||||
|
.map(|d| bpr::models::member_settlement_setting::MemberSettlementSetting::from(&d)),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::UpdateMemberSettlementSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn delete_member_settlement_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_DELETE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let req = bpr::ss::member_settlement_setting::DeleteMemberSettlementSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = match req.client {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "client".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let request = match req.request {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
|
bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid request information".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "request".to_string(),
|
||||||
|
value: "".to_string(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: "".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let id = uuid::Uuid::from_str(request.id.as_str()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
|
||||||
|
message: "invalid id param".to_string(),
|
||||||
|
detail: bcr::error::rpc::InvalidParamsDetail {
|
||||||
|
location: "request".to_string(),
|
||||||
|
param: "id".to_string(),
|
||||||
|
value: request.id.clone(),
|
||||||
|
error_type: bcr::error::rpc::InvalidParamsType::Required,
|
||||||
|
message: e.to_string(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let conn = self.pool.get().map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let _affected = self
|
||||||
|
.member_settlement_setting_repository
|
||||||
|
.delete(&conn, id)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::DeleteMemberSettlementSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::ss::member_settlement_setting::delete_member_settlement_setting_response::Result {},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::ss::member_settlement_setting::DeleteMemberSettlementSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,8 @@ pub mod member_bank_account;
|
||||||
pub mod member_bank_deposit;
|
pub mod member_bank_deposit;
|
||||||
pub mod member_bank_withdraw;
|
pub mod member_bank_withdraw;
|
||||||
pub mod member_class;
|
pub mod member_class;
|
||||||
|
pub mod member_game_setting;
|
||||||
pub mod member_level;
|
pub mod member_level;
|
||||||
pub mod member_referrer;
|
pub mod member_referrer;
|
||||||
|
pub mod member_settlement_setting;
|
||||||
pub mod site;
|
pub mod site;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user