model is modified

This commit is contained in:
병준 박 2022-09-05 08:06:17 +00:00
parent dc10f5b8c4
commit dfc328b636
7 changed files with 90 additions and 37 deletions

View File

@ -10,14 +10,15 @@ CREATE TABLE IF NOT EXISTS api_kgon_betting_history (
cash DOUBLE PRECISION,
before_cash DOUBLE PRECISION,
after_cash DOUBLE PRECISION,
key TEXT NOT NULL,
ref_id TEXT NOT NULL,
o_ref_id TEXT NOT NULL,
group_key TEXT,
detail TEXT,
is_bonus BOOLEAN NOT NULL,
is_promo BOOLEAN NOT NULL,
is_jackpot BOOLEAN NOT NULL,
site_username TEXT NOT NULL,
key TEXT NOT NULL,
ref_id TEXT NOT NULL,
o_ref_id TEXT,
betting_type TEXT NOT NULL,
category TEXT NOT NULL,
created_at BIGINT NOT NULL,

View File

@ -2,45 +2,69 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct Betting {
/// KGON 거래 고유 코드
pub _id: String,
/// 게임사 코드
#[serde(rename = "vendorId")]
pub vendor_id: i64,
/// 게임사
#[serde(rename = "vendorName")]
pub vendor_name: String,
/// 게임코드
#[serde(rename = "gameId")]
pub game_id: i64,
/// 게임명
#[serde(rename = "gameName")]
pub game_name: String,
/// 게임종류
#[serde(rename = "gameCategory")]
pub game_category: String,
/// 게임형식
#[serde(rename = "gameType")]
pub game_type: String,
/// 환율
pub currency: String,
/// 거래금액
pub cash: f64,
/// 이전보유금액
#[serde(rename = "beforeCash")]
pub before_cash: f64,
/// 이후보유금액
#[serde(rename = "afterCash")]
pub after_cash: f64,
/// 사이트 매장 코드
#[serde(rename = "groupKey")]
pub group_key: Option<String>,
/// 게임 데이터
pub detail: Option<serde_json::Value>,
/// 보너스 여부
#[serde(rename = "isBonus")]
pub is_bonus: bool,
/// 프로모션 여부
#[serde(rename = "isPromo")]
pub is_promo: bool,
/// 잭팟 여부
#[serde(rename = "isJackpot")]
pub is_jackpot: bool,
/// 사이트 회원 아이디
#[serde(rename = "siteUsername")]
pub site_username: String,
/// 게임사 고유코드
pub key: String,
/// 게임사 상위 배팅 코드
#[serde(rename = "refId")]
pub ref_id: String,
#[serde(rename = "oRefId")]
pub o_ref_id: String,
#[serde(rename = "groupKey")]
pub group_key: Option<String>,
#[serde(rename = "isBonus")]
pub is_bonus: bool,
#[serde(rename = "isPromo")]
pub is_promo: bool,
#[serde(rename = "isJackpot")]
pub is_jackpot: bool,
#[serde(rename = "siteUsername")]
pub site_username: String,
pub o_ref_id: Option<String>,
/// 결과로서 turn_bet, turn_win, turn_draw, turn_cancel이 존재
#[serde(rename = "type")]
pub betting_type: String,
/// 카테고리
pub category: String,
/// 일자 - 파트너의 timezone 반영
#[serde(rename = "createdAt")]
pub created_at: String,
/// UTC TIME 으로서 한국시간에서 9시간이 빠진 시간입니다. 다음 검색시 sdate에 입력하세요
#[serde(rename = "utcCreatedAt")]
pub utc_created_at: String,
}

View File

@ -69,7 +69,17 @@ impl Api {
let balance = r.balance.unwrap_or(0.00);
let balance_bota = r.balance_bota.unwrap_or(0.00);
let balance_sum = r.balance_sum.unwrap_or(0.00);
let companies = r.companies;
let companies = match r.companies {
Some(v) => {
let vv = serde_json::from_value::<String>(v).map_err(|e| Error {
code: -1,
msg: Some(e.to_string()),
})?;
Some(vv)
}
None => None,
};
Ok(models::GetBalanceForUserResponse {
balance,

View File

@ -13,7 +13,7 @@ pub struct _GetBalanceForUserResponse {
pub balance_bota: Option<f64>,
#[serde(rename = "balanceSum")]
pub balance_sum: Option<f64>,
pub companies: Option<String>,
pub companies: Option<serde_json::Value>,
}
#[derive(Serialize, Deserialize, Debug)]

View File

@ -28,14 +28,10 @@ pub struct BettingHistory {
///
pub after_cash: f64,
///
pub key: String,
///
pub ref_id: String,
///
pub o_ref_id: String,
///
pub group_key: Option<String>,
///
pub detail: Option<String>,
///
pub is_bonus: bool,
///
pub is_promo: bool,
@ -44,6 +40,12 @@ pub struct BettingHistory {
///
pub site_username: String,
///
pub key: String,
///
pub ref_id: String,
///
pub o_ref_id: Option<String>,
///
pub betting_type: String,
///
pub category: String,
@ -80,14 +82,10 @@ pub struct NewBettingHistory {
///
pub after_cash: f64,
///
pub key: String,
///
pub ref_id: String,
///
pub o_ref_id: String,
///
pub group_key: Option<String>,
///
pub detail: Option<String>,
///
pub is_bonus: bool,
///
pub is_promo: bool,
@ -96,6 +94,12 @@ pub struct NewBettingHistory {
///
pub site_username: String,
///
pub key: String,
///
pub ref_id: String,
///
pub o_ref_id: Option<String>,
///
pub betting_type: String,
///
pub category: String,

View File

@ -27,14 +27,10 @@ table! {
///
after_cash -> Double,
///
key -> Text,
///
ref_id -> Text,
///
o_ref_id -> Text,
///
group_key -> Nullable<Text>,
///
detail -> Nullable<Text>,
///
is_bonus -> Bool,
///
is_promo -> Bool,
@ -43,6 +39,12 @@ table! {
///
site_username -> Text,
///
key -> Text,
///
ref_id -> Text,
///
o_ref_id -> Nullable<Text>,
///
betting_type -> Text,
///
category -> Text,

View File

@ -137,6 +137,17 @@ impl Synchronizer {
});
}
};
let detail = match b.detail {
Some(v) => {
let vv = serde_json::from_value::<String>(v).map_err(|e| api::core::models::Error {
code: -1,
msg: Some(format!("serde_json::from_value error: {}", e)),
})?;
Some(vv)
}
None => None,
};
new_betting_history.push(repositories::betting_history::models::NewBettingHistory {
id: b._id,
@ -150,14 +161,15 @@ impl Synchronizer {
cash: b.cash,
before_cash: b.before_cash,
after_cash: b.after_cash,
key: b.key,
ref_id: b.ref_id,
o_ref_id: b.o_ref_id,
group_key: b.group_key,
detail,
is_bonus: b.is_bonus,
is_promo: b.is_promo,
is_jackpot: b.is_jackpot,
site_username: b.site_username,
key: b.key,
ref_id: b.ref_id,
o_ref_id: b.o_ref_id,
betting_type: b.betting_type,
category: b.category,
created_at,