---
# System prepended metadata

title: Entertainment Project

---

## Order Types

```ruby=
OrderTypeSeed.generate_order_types
AdminPermissionSeed.generate_admin_permissions
```

## Domains

```ruby=
domains_data = [
    { name: 'agent.com', genre: :agent, status: :active },
    { name: 'client.com', genre: :client, status: :active },
    { name: 'admin.com', genre: :admin, status: :active },
]

domains_data.each do |domain|
  Domain.find_or_create_by domain
end
```

## Casino Platforms

```ruby
casino_platform_data = [
    { name: 'IM', service_name: 'im_esports', betting_record_system_name: 'imesport' },
    { name: 'MG+', service_name: 'mg_plus', betting_record_system_name: 'mgplus' },
    { name: 'JILI', service_name: 'jili', betting_record_system_name: 'jili' },
    { name: 'KA', service_name: 'ka_gaming', betting_record_system_name: 'ka' },
    { name: 'FB', service_name: 'fb_sport_book', betting_record_system_name: 'fb' },
    { name: 'IC', service_name: 'ic', betting_record_system_name: 'ic' }
]

casino_platform_data.each do |casino_platform|
  object = CasinoPlatform.where(casino_platform).first_or_create
  puts "find or create casino platform id: #{object.id}, name: #{object.name}, service_name: #{object.service_name}"
end

game_category_data = [
    { name: 'slot', sort: 1, status: :visible, genre: :settleable },
    { name: 'e_sport', sort: 2, status: :visible, genre: :settleable },
    { name: 'sport', sort: 3, status: :visible, genre: :settleable },
    { name: 'sabong', sort: 4, status: :visible, genre: :settleable }
].freeze

game_category_data.each do |game_category|
  object = GameCategory.where(game_category).first_or_create
  puts "find or create game category id: #{object.id}, name: #{object.name}, sort: #{object.sort}"
end

## Generate subplatform
sub_platform_data = [
    { name: 'Jili', casino_platform: 'jili', game_category: 'slot', code_name: :jili,
    redirect_param: '', sort: 1, betting_record_system_name: 'jili' },
    { name: 'MG', casino_platform: 'mg_plus', game_category: 'slot', code_name: :mg_plus_slot,
    redirect_param: '', sort: 2, betting_record_system_name: 'mg_plus_slot' },
    { name: 'KA', casino_platform: 'ka_gaming', game_category: 'slot', code_name: :ka,
    redirect_param: '', sort: 3, betting_record_system_name: 'ka' },
    { name: 'IC', casino_platform: 'ic', game_category: 'sabong', code_name: :ic,
    redirect_param: '', sort: 4, betting_record_system_name: 'ic' },
    { name: 'FB Sports', casino_platform: 'fb_sport_book', game_category: 'sport', code_name: :fb_sport,                 redirect_param: '', sort: 5, betting_record_system_name: 'fb' },

]
sub_platform_data.each do |sub_platform|
  object = SubPlatform.where(name: sub_platform[:name],
                             casino_platform: CasinoPlatform.find_by_service_name(sub_platform[:casino_platform]),
                             game_category: GameCategory.find_by_name(sub_platform[:game_category]),
                             redirect_param: sub_platform[:redirect_param],
                             sort: sub_platform[:sort],
                             betting_record_system_name: sub_platform[:betting_record_system_name],
                             code_name: sub_platform[:code_name]).first_or_create
  puts object.errors.full_messages
  puts "find or create sub platform id: #{object.id}, name: #{object.name},
                                    casino_platform: #{object.casino_platform.name},
                                    game_category: #{object.game_category.name},
                                    redirect_params: #{object.redirect_param},
                                    sort: #{object.sort},
                                    betting_record_system_name: #{object.betting_record_system_name}"
end
```

## Financial Tags

```ruby=
financial_tags_data = [
  { name: 'New Client', code: 'new_client', remark: :beginner },
  { name: 'Beginner', code: 'beginner', remark: :junior },
  { name: 'Advanced Client', code: 'advanced_client', remark: :experienced_client },
  { name: 'Vip Group A', code: 'vip_a', remark: 'vip_a' },
  { name: 'Vip Group B', code: 'vip_b', remark: 'vip_b' },
  { name: 'Vip Group C', code: 'vip_c', remark: 'vip_c' },
  { name: 'Violaters', code: 'violaters', remark: :beginner },
  { name: 'Huge amount', code: 'huge_amount', remark: :junior },
  { name: 'SEO', code: 'seo', remark: :beginner },
  { name: 'Test', code: 'test', remark: :beginner },
  { name: 'Dangerous', code: 'Dangerous', remark: :junior } 
]

financial_tags_data.each do |financial_tag|
  object = FinancialTag.where(financial_tag).first_or_create
  puts "find or create financial tag id: #{object.id}, name: #{object.name}, code: #{object.code}"
end


payment_methods_data = [
    { name: 'USDT-ERC20', code: 'remit', currency: 'usdt' },
    { name: 'USDT-TRC20', code: 'remit_trc', currency: 'usdt' },
    { name: 'GCASH', code: 'gcash', currency: 'PHP' },
]

payment_methods_data.each do |payment_method|
    object = PaymentMethod.where(payment_method).first_or_initialize
    object.save if object.valid?
    puts "find or create payment method id: #{object.id}, name: #{object.name}, code: #{object.code}, currency: #{object.currency}"
end


FinancialTag.all.each do |financial_tag|
  PaymentMethod.all.each do |payment_method|
    object = PaymentMethodConfig.where(financial_tag: financial_tag, payment_method: payment_method).first_or_create
    puts "find or create payment method config
          id: #{object.id}, financial_tag: #{financial_tag.name}, payment_method: #{payment_method.name}"
  end
end

```

## MembershipTier

```ruby =
membership_tier_data = [
{
  :tier=>{"name"=>"bronze", "next"=>"silver", "bet_amount_threshold"=>0, "vip_bonus"=>nil}, 
  :rakeback=>{"baccarat"=>0.1e0, "sport"=>0.1e0, "e_sport"=>0.1e0, "slot"=>0.1e0, "lottery"=>0.1e0, "chess_game"=>0.0, "fishing_game"=>0.1e0, "sabong"=>0.0, "genre"=>"vip"},
 :transactions_setting=>{"withdraw_count_per_day"=>10, "withdraw_amount_per_day"=>400000}, :financial_tag=>"New Client"},

{:tier=>{"name"=>"silver", "next"=>"gold", "bet_amount_threshold"=>80000, "vip_bonus"=>128}, 
  :rakeback=>{"baccarat"=>0.2e0, "sport"=>0.2e0, "e_sport"=>0.2e0, "slot"=>0.2e0, "lottery"=>0.2e0, "chess_game"=>0.0, "fishing_game"=>0.2e0, "sabong"=>0.0, "genre"=>"vip"}, :transactions_setting=>{"withdraw_count_per_day"=>10, "withdraw_amount_per_day"=>640000}, :financial_tag=>"Beginner"},
{:tier=>{"name"=>"gold", "next"=>"platinum", "bet_amount_threshold"=>320000, "vip_bonus"=>288}, :rakeback=>{"baccarat"=>0.3e0, "sport"=>0.3e0, "e_sport"=>0.3e0, "slot"=>0.3e0, "lottery"=>0.3e0, "chess_game"=>0.0, "fishing_game"=>0.3e0, "sabong"=>0.0, "genre"=>"vip"}, 
  :transactions_setting=>{"withdraw_count_per_day"=>10, "withdraw_amount_per_day"=>640000}, :financial_tag=>"Advanced Client"},
{:tier=>{"name"=>"platinum", "next"=>"emerald", "bet_amount_threshold"=>400000, "vip_bonus"=>528}, :rakeback=>{"baccarat"=>0.4e0, "sport"=>0.4e0, "e_sport"=>0.4e0, "slot"=>0.4e0, "lottery"=>0.4e0, "chess_game"=>0.0, "fishing_game"=>0.4e0, "sabong"=>0.0, "genre"=>"vip"}, :transactions_setting=>{"withdraw_count_per_day"=>10, "withdraw_amount_per_day"=>800000}, :financial_tag=>"Vip Group A"},
{:tier=>{"name"=>"emerald", "next"=>"ruby", "bet_amount_threshold"=>800000, "vip_bonus"=>768}, 
  :rakeback=>{"baccarat"=>0.5e0, "sport"=>0.5e0, "e_sport"=>0.5e0, "slot"=>0.5e0, "lottery"=>0.5e0, "chess_game"=>0.0, "fishing_game"=>0.5e0, "sabong"=>0.0, "genre"=>"vip"},:transactions_setting=>{"withdraw_count_per_day"=>10, "withdraw_amount_per_day"=>800000}, :financial_tag=>"Vip Group B"},
  
  
{:tier=>{"name"=>"ruby", "next"=>"diamond", "bet_amount_threshold"=>2400000, "vip_bonus"=>1088}, :rakeback=>{"baccarat"=>0.6e0, "sport"=>0.6e0, "e_sport"=>0.6e0, "slot"=>0.6e0, "lottery"=>0.6e0, "chess_game"=>0.0, "fishing_game"=>0.6e0, "sabong"=>0.0, "genre"=>"vip"}, :transactions_setting=>{"withdraw_count_per_day"=>10, "withdraw_amount_per_day"=>800000}, :financial_tag=>"Vip Group C"},
  
  
{:tier=>{"name"=>"diamond", "next"=>"blue diamond", "bet_amount_threshold"=>4000000, "vip_bonus"=>1328}, :rakeback=>{"baccarat"=>0.7e0, "sport"=>0.7e0, "e_sport"=>0.7e0, "slot"=>0.7e0, "lottery"=>0.7e0, "chess_game"=>0.0, "fishing_game"=>0.7e0, "sabong"=>0.0, "genre"=>"vip"},
  :transactions_setting=>{"withdraw_count_per_day"=>10, "withdraw_amount_per_day"=>1600000}, :financial_tag=>"Vip Group C"},
  
{:tier=>{"name"=>"blue diamond", "next"=>nil, "bet_amount_threshold"=>6400000, "vip_bonus"=>2128}, :rakeback=>{"baccarat"=>0.8e0, "sport"=>0.8e0, "e_sport"=>0.8e0, "slot"=>0.8e0, "lottery"=>0.8e0, "chess_game"=>0.0, "fishing_game"=>0.8e0, "sabong"=>0.0, "genre"=>"vip"}, :transactions_setting=>{"withdraw_count_per_day"=>10, "withdraw_amount_per_day"=>1600000}, :financial_tag=>"Vip Group C"}
]

membership_tier_data.each do |data|
  object = MembershipTier.where(data[:tier]).first_or_initialize
  object.financial_tag = FinancialTag.find_by_name(data[:financial_tag])
  object.rakeback ||= Rakeback.create(data[:rakeback])
  object.transactions_setting ||= TransactionsSetting.create(data[:transactions_setting])
  object.save
  p '--------------------------------'
  p object.errors.full_messages
end

```

   
## Some Not sure if needed
```ruby=
##generate promoted action category
# use name for translation
promoted_actions_category_data = [
  { display_name: '硬广', name: 'banner_ads' },
  { display_name: '競價', name: 'keyword_bids' },
  { display_name: '站群', name: 'multiple_websites_from_same_domain' },
  { display_name: 'app', name: 'app_marketing' },
  { display_name: '代理', name: 'agent_referrals' },
  { display_name: '电销', name: 'telemarketing' },
  { display_name: '社交', name: 'chatting' },
  { display_name: '直客', name: 'direct_client' },
  { display_name: '论坛', name: 'forum_articles_and_comments' },
  { display_name: 'SEO', name: 'search_engine_optimization' }
]
promoted_actions_category_data.each do |category|
  object = PromotedActionsCategory.where(category).first_or_create
  puts "find or create promoted actions category id: #{object.id}, display_name: #{object.display_name}, name: #{object.name}"
end

##generate direct_clients_rakeback_data
direct_clients_rakeback_data = {
  baccarat: 0.6, sport: 0.6, e_sport: 0.6, slot: 0.6, lottery: 0.6, chess_game: 0, fishing_game: 0.6, sabong: 0, genre: 0
}
object = PromotionCode.find_or_create_by(name: 'direct_clients',
                                         promoted_actions_category: PromotedActionsCategory.find_by_name(:direct_client),
                                         financial_tag_genre: :fixed,
                                         financial_tag: FinancialTag.find_by_remark(:beginner))
object.rakeback ||= Rakeback.create(direct_clients_rakeback_data)
puts "find or create promotion code id: #{object.id}, name: #{object.name}
      find or create rakeback baccarat: #{object.rakeback.baccarat}, sport: #{object.rakeback.sport},
                              e_sport: #{object.rakeback.e_sport}, slot: #{object.rakeback.slot},
                              lottery: #{object.rakeback.lottery}, chess_game: #{object.rakeback.chess_game},
                              fishing_game: #{object.rakeback.fishing_game}, sabong: #{object.rakeback.sabong}"

##generate commission_tier_data
commission_tier_data = [
  { name: '1', prev: '', net_profit: 0, company_bet_result: 0, valid_client_count: 5, minimum_withdraw: 300.00,
    commission_rate: 30.00, fee_rate: 0.00, baccarat_rate: 12.00, sport_rate: 15.00, e_sport_rate: 15.00,
    slot_rate: 15.00, lottery_rate: 12.00, chess_game_rate: 10.00, fishing_game_rate: 15.00, sabong_rate: 0 },
  { name: '2', prev: '1', net_profit: 50000, company_bet_result: 50000, valid_client_count: 5, minimum_withdraw: 300.00,
    commission_rate: 35.00, fee_rate: 0.00, baccarat_rate: 12.00, sport_rate: 15.00, e_sport_rate: 15.00,
    slot_rate: 15.00, lottery_rate: 12.00, chess_game_rate: 10.00, fishing_game_rate: 15.00, sabong_rate: 0 },
  { name: '3', prev: '2', net_profit: 100000, company_bet_result: 100000, valid_client_count: 5, minimum_withdraw: 300.00,
    commission_rate: 40.00, fee_rate: 0.00, baccarat_rate: 10.00, sport_rate: 15.00, e_sport_rate: 15.00,
    slot_rate: 14.00, lottery_rate: 10.00, chess_game_rate: 10.00, fishing_game_rate: 14.00, sabong_rate: 0 },
  { name: '4', prev: '3', net_profit: 500000, company_bet_result: 500000, valid_client_count: 5, minimum_withdraw: 300.00,
    commission_rate: 45.00, fee_rate: 0.00, baccarat_rate: 9.00, sport_rate: 15.00, e_sport_rate: 15.00,
    slot_rate: 13.00, lottery_rate: 9.00, chess_game_rate: 10.00, fishing_game_rate: 13.00, sabong_rate: 0 }
]
commission_tier_data.each do |data|
  object = CommissionTier.where(data).first_or_create
  puts "find or create commission tier id: #{object.id}, name: #{object.name}, prev: #{object.prev}, net_profit: #{object.net_profit},
                                       valid_client_count: #{object.valid_client_count}, minimum_withdraw: #{object.minimum_withdraw},
                                       commission_rate: #{object.commission_rate}, fee_rate: #{object.fee_rate},
                                       baccarat_rate: #{object.baccarat_rate}, sport_rate: #{object.sport_rate},
                                       e_sport_rate: #{object.e_sport_rate}, slot_rate: #{object.slot_rate},
                                       lottery_rate: #{object.lottery_rate}, chess_game_rate: #{object.chess_game_rate},
                                       fishing_game_rate: #{object.fishing_game_rate}, sabong_rate: #{object.sabong_rate}"
end

##generate setting_data
setting_data = [
  { title: :android_version, code: :android_version, value: '1.0.0' },
  { title: :android_version_code, code: :android_version_code, value: '1' },
  { title: :android_download_link, code: :android_download_link, value: 'http://hjc1.30001a.info' },
  { title: :ios_version, code: :ios_version, value: '1.0.0' },
  { title: :ios_version_code, code: :ios_version_code, value: '1' },
  { title: :ios_download_link, code: :ios_download_link, value: 'http://hjc1.30001a.info' },
  { title: :app_priority_host, code: :app_priority_host, value: 'https://abc.gcgc55.com' },
  { title: :customer_service_link, code: :customer_service_link, value: 'http://h6kf.com' },
  { title: '需二步验证的部门', code: :forced_two_factor_departments, value: 'money, customer_service, risk, operation' },
  { title: '需二步验证的管理员', code: :forced_two_factor_users, value: '' }
]
setting_data.each do |data|
  object = Setting.where(data).first_or_create
  puts "find or create setting id: #{object.id}, title: #{object.title}, code: #{object.code}, value: #{object.value}"
end

object = Setting.where(title: 'CDN url', code: 'cdn_url').first_or_create
puts "find or create setting id: #{object.id}, title: #{object.title}, code: #{object.code}"

```

## whitelist
```ruby
ips = ['192.168.228.1', '103.43.215.138']

ips.each do |ip|
 wl = Whitelist.new(ip: ip, status: :active, genre: :client)
 wl.save
end


ips = ['192.168.228.1', '103.43.215.138']

ips.each do |ip|
 wl = Whitelist.new(ip: ip, status: :active, genre: :admin)
 wl.save
end

```

## Accounts

```ruby=
## generate admin position
admin_position_data = [
  { code: 'ceo', display_name: 'CEO' },
  { code: 'financial_staff', display_name: '財務組員' },
  { code: 'financial_manager', display_name: '財務主管' },
  { code: 'accounting_staff', display_name: '會計組員' },
  { code: 'accounting_manager', display_name: '會計主管' },
  { code: 'quality_assurance_engineer', display_name: '測試工程師' }, # add IT in translation
  { code: 'designer', display_name: '設計組員' },  # Add IT in translation
  { code: 'design_supervisor', display_name: '設計組長' },  # Add IT in translation
  { code: 'developer', display_name: '技術組員' },
  { code: 'information_technology_supervisor', display_name: '技術組長' },
  { code: 'information_technology_manager', display_name: '技術主管' },
  { code: 'telemarketing_staff', display_name: '電銷組員' },
  { code: 'telemarketing_supervisor', display_name: '電銷組長' },
  { code: 'telemarketing_manager', display_name: '電銷主管' },
  { code: 'customer_service_staff', display_name: '客服組員' },
  { code: 'customer_service_supervisor', display_name: '客服組長' },
  { code: 'customer_service_manager', display_name: '客服主管' },
  { code: 'temporary_permissions', display_name: '閒置人員' },
  { code: 'marketing_staff', display_name: '市場組員' },
  { code: 'marketing_supervisor', display_name: '市場組長' },
  { code: 'marketing_assistant', display_name: '市場助理' },
  { code: 'marketing_manager', display_name: '市場主管' },
  { code: 'technical_operations_staff', display_name: '運維組員' },
  { code: 'technical_operations_supervisor', display_name: '運維組長' },
  { code: 'technical_operations_manager', display_name: '運維主管' },
  { code: 'operations', display_name: '運營組員' },
  { code: 'operations_manager', display_name: '運營主管' },
  { code: 'risk_control_staff', display_name: '風控組員' },
  { code: 'risk_control_manager', display_name: '風控主管' }
]
admin_position_data.each do |position|
  object = Admin::Position.where(position).first_or_create
  puts "find or create position id: #{object.id}, code: #{object.code}, display_name: #{object.display_name}"
end

##generate admin department
admin_department_data = [
  { code: 'management', display_name: '綜合管理部門' },
  { code: 'money', display_name: '財務部門' },
  { code: 'accountant', display_name: '會計部門' },
  { code: 'developer', display_name: '技術部門' },
  { code: 'customer_service', display_name: '客服部門' },
  { code: 'other', display_name: '臨時部門' },
  { code: 'marketing', display_name: '市場部門' },
  { code: 'server', display_name: '運維部門' },
  { code: 'operation', display_name: '運營部門' },
  { code: 'risk', display_name: '風控部門' }
]
admin_department_data.each do |department|
  object = Admin::Department.where(department).first_or_create
  puts "find or create department id: #{object.id}, code: #{object.code}, display_name: #{object.display_name}"
end

```
