diff --git a/Cargo.toml b/Cargo.toml index 38cd1a2..f201ca1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tokio-cron-scheduler = { version = "0" } uuid = { version = "0", features = ["serde", "v4", "v5"] } -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.54-snapshot" } +beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.72-snapshot" } +beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.56-snapshot" } [build-dependencies] diff --git a/src/repositories/member_game_setting/models.rs b/src/repositories/member_game_setting/models.rs index 5c3a8ef..7ed69ef 100644 --- a/src/repositories/member_game_setting/models.rs +++ b/src/repositories/member_game_setting/models.rs @@ -33,6 +33,18 @@ pub struct MemberGameSetting { pub struct NewMemberGameSetting { /// 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, } /// diff --git a/src/repositories/member_settlement_setting/models.rs b/src/repositories/member_settlement_setting/models.rs index 5d42ad2..9c388d8 100644 --- a/src/repositories/member_settlement_setting/models.rs +++ b/src/repositories/member_settlement_setting/models.rs @@ -61,6 +61,46 @@ pub struct MemberSettlementSetting { pub struct NewMemberSettlementSetting { /// 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, } /// diff --git a/src/services/member/service.rs b/src/services/member/service.rs index f486bc1..728bc20 100644 --- a/src/services/member/service.rs +++ b/src/services/member/service.rs @@ -22,6 +22,9 @@ pub struct Service<'a> { member_repository: repositories::member::repository::Repository, member_session_repository: repositories::member_session::repository::Repository, member_bank_account_repository: repositories::member_bank_account::repository::Repository, + member_game_setting_repository: repositories::member_game_setting::repository::Repository, + member_settlement_setting_repository: + repositories::member_settlement_setting::repository::Repository, argon2_config: argon2::Config<'a>, password_salt: String, } @@ -51,6 +54,10 @@ impl Service<'_> { member_session_repository: repositories::member_session::repository::Repository::new(), member_bank_account_repository: repositories::member_bank_account::repository::Repository::new(), + member_game_setting_repository: + repositories::member_game_setting::repository::Repository::new(), + member_settlement_setting_repository: + repositories::member_settlement_setting::repository::Repository::new(), argon2_config: argon2::Config::default(), password_salt, } @@ -384,6 +391,72 @@ impl Service<'_> { })?; } + if let Some(a) = request.game_setting { + let new_member_game_setting = + repositories::member_game_setting::models::NewMemberGameSetting { + member_id: m.id, + can_bet_casino: a.can_bet_casino, + can_bet_slot: a.can_bet_slot, + can_bet_powerball: a.can_bet_powerball, + can_bet_powerladder: a.can_bet_powerladder, + can_bet_eos: a.can_bet_eos, + can_bet_bogglepowerball: a.can_bet_bogglepowerball, + }; + self + .member_game_setting_repository + .insert(&conn, &new_member_game_setting) + .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, + }) + })?; + } + + if let Some(a) = request.settlement_setting { + let new_member_settlement_setting = + repositories::member_settlement_setting::models::NewMemberSettlementSetting { + member_id: m.id, + can_exchange: a.can_exchange, + can_first_charge_comp: a.can_first_charge_comp, + can_per_charge_comp: a.can_per_charge_comp, + manual_payment_type_for_partner: + repositories::member_settlement_setting::schema::ManualPaymentType::from( + a.manual_payment_type_for_partner, + ), + settlement_type: + repositories::member_settlement_setting::schema::SettlementType::from( + a.settlement_type, + ), + rate_casino: a.rate_casino, + rate_casino_loosing: a.rate_casino_loosing, + rate_casino_bacara: a.rate_casino_bacara, + rate_casino_roulette: a.rate_casino_roulette, + rate_casino_dragon_tiger: a.rate_casino_dragon_tiger, + rate_slot: a.rate_slot, + rate_slot_loosing: a.rate_slot_loosing, + rate_powerball_single: a.rate_powerball_single, + rate_powerball_combo: a.rate_powerball_combo, + rate_powerladder_single: a.rate_powerladder_single, + rate_powerladder_combo: a.rate_powerladder_combo, + rate_eos_single: a.rate_eos_single, + rate_eos_combo: a.rate_eos_combo, + rate_bogglepowerball_single: a.rate_bogglepowerball_single, + rate_bogglepowerball_combo: a.rate_bogglepowerball_combo, + }; + self + .member_settlement_setting_repository + .insert(&conn, &new_member_settlement_setting) + .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 member = self.member_composition.select(&conn, m.id).map_err(|e| { bcr::error::rpc::Error::Server(bcr::error::rpc::Server { code: bpr::protobuf::rpc::Error::SERVER_00, @@ -1129,6 +1202,96 @@ impl Service<'_> { })?; } + if let Some(a) = request.game_setting { + let id = uuid::Uuid::from_str(a.id.as_str()).map_err(|e| { + bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams { + message: "invalid game_setting.id param".to_string(), + detail: bcr::error::rpc::InvalidParamsDetail { + location: "request".to_string(), + param: "game_setting.id".to_string(), + value: a.id.clone(), + error_type: bcr::error::rpc::InvalidParamsType::Required, + message: e.to_string(), + }, + }) + })?; + + let modify_member_game_setting = + repositories::member_game_setting::models::ModifyMemberGameSetting { + can_bet_casino: a.can_bet_casino, + can_bet_slot: a.can_bet_slot, + can_bet_powerball: a.can_bet_powerball, + can_bet_powerladder: a.can_bet_powerladder, + can_bet_eos: a.can_bet_eos, + can_bet_bogglepowerball: a.can_bet_bogglepowerball, + }; + self + .member_game_setting_repository + .update(&conn, id, &modify_member_game_setting) + .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, + }) + })?; + } + + if let Some(a) = request.settlement_setting { + let id = uuid::Uuid::from_str(a.id.as_str()).map_err(|e| { + bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams { + message: "invalid settlement_setting.id param".to_string(), + detail: bcr::error::rpc::InvalidParamsDetail { + location: "request".to_string(), + param: "settlement_setting.id".to_string(), + value: a.id.clone(), + error_type: bcr::error::rpc::InvalidParamsType::Required, + message: e.to_string(), + }, + }) + })?; + + let modify_member_settlement_setting = + repositories::member_settlement_setting::models::ModifyMemberSettlementSetting { + can_exchange: a.can_exchange, + can_first_charge_comp: a.can_first_charge_comp, + can_per_charge_comp: a.can_per_charge_comp, + manual_payment_type_for_partner: + repositories::member_settlement_setting::schema::ManualPaymentType::from( + a.manual_payment_type_for_partner, + ), + settlement_type: + repositories::member_settlement_setting::schema::SettlementType::from( + a.settlement_type, + ), + rate_casino: a.rate_casino, + rate_casino_loosing: a.rate_casino_loosing, + rate_casino_bacara: a.rate_casino_bacara, + rate_casino_roulette: a.rate_casino_roulette, + rate_casino_dragon_tiger: a.rate_casino_dragon_tiger, + rate_slot: a.rate_slot, + rate_slot_loosing: a.rate_slot_loosing, + rate_powerball_single: a.rate_powerball_single, + rate_powerball_combo: a.rate_powerball_combo, + rate_powerladder_single: a.rate_powerladder_single, + rate_powerladder_combo: a.rate_powerladder_combo, + rate_eos_single: a.rate_eos_single, + rate_eos_combo: a.rate_eos_combo, + rate_bogglepowerball_single: a.rate_bogglepowerball_single, + rate_bogglepowerball_combo: a.rate_bogglepowerball_combo, + }; + self + .member_settlement_setting_repository + .update(&conn, id, &modify_member_settlement_setting) + .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 m = self.member_composition.select(&conn, id).map_err(|e| { bcr::error::rpc::Error::Server(bcr::error::rpc::Server { code: bpr::protobuf::rpc::Error::SERVER_00, diff --git a/src/services/member_game_setting/service.rs b/src/services/member_game_setting/service.rs index 924b87e..b333729 100644 --- a/src/services/member_game_setting/service.rs +++ b/src/services/member_game_setting/service.rs @@ -170,7 +170,15 @@ impl Service { .member_game_setting_repository .insert( &conn, - &repositories::member_game_setting::models::NewMemberGameSetting { member_id }, + &repositories::member_game_setting::models::NewMemberGameSetting { + member_id, + 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 { diff --git a/src/services/member_settlement_setting/service.rs b/src/services/member_settlement_setting/service.rs index e7f26b0..7e5c89c 100644 --- a/src/services/member_settlement_setting/service.rs +++ b/src/services/member_settlement_setting/service.rs @@ -173,6 +173,26 @@ impl Service { &conn, &repositories::member_settlement_setting::models::NewMemberSettlementSetting { member_id, + 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| {