<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
<SQLS>

	<!--
		シーケンスの取得
		条　件：シーケンスキー
	-->
	<SELECT_SEQUENCE>
		SELECT
			seq_key
			, seq_param
		FROM
			t_sequence
		WHERE
			seq_key = __ELEMENT01__
		FOR UPDATE
	</SELECT_SEQUENCE>

	<!--
		シーケンスの更新
		更新値：シーケンス番号
		条　件：シーケンスキー
	-->
	<UPDATE_SEQUENCE>
		UPDATE
			t_sequence
		SET
			seq_param = __ELEMENT02__
		WHERE
			seq_key = __ELEMENT01__
	</UPDATE_SEQUENCE>

	<!--
		管理者ログインチェック
		条　件：ユーザ名
				ユーザパスワード
	-->
	<SELECT_ADMIN_LOGIN>
		SELECT
			u_id
			, user_name
			, password
			, admin_flg
			, user_account
			, first_name
			, last_name
		FROM
			v_users_admin
		WHERE
			user_name		= '__ELEMENT01__'
			AND password	= '__ELEMENT02__'
			AND wl_id		= '__ELEMENT03__'
	</SELECT_ADMIN_LOGIN>

	<!--
		管理者ログインチェック
		条　件：ユーザ名
				ユーザパスワード
	-->
	<SELECT_LOGIN_BY_USER_NAME>
		SELECT
			u_id
			, user_name
			, password
			, fail_count
		FROM
			t_login
		WHERE
			user_name = '__ELEMENT01__'
	</SELECT_LOGIN_BY_USER_NAME>

	<!--
		ログインチェック
		条　件：ユーザ名
				ユーザパスワード
	-->
	<SELECT_LOGIN>
		SELECT
			u_id									AS u_id
			, user_name								AS user_name
			, password								AS password
			, wl_id									AS wl_id
			, mail									AS mail
			, account_type							AS account_type
			, user_account							AS user_account
			, currency								AS currency
			, tel									AS tel
			, last_name								AS last_name
			, first_name							AS first_name
			, birth									AS birth
			, country								AS country
			, state									AS state
			, city									AS city
			, zip_code								AS zip_code
			, address								AS address
			, address2								AS address2
			, bank_name								AS bank_name
			, branch_name							AS branch_name
			, branch_number							AS branch_number
			, account_number						AS account_number
			, account_name							AS account_name
			, admin_flg								AS admin_flg
			, status								AS status
			, kyc_flg								AS kyc_flg
			, agent_flg								AS agent_flg
			, agent_code							AS agent_code
			, parent_agent_code						AS parent_agent_code
			, create_time							AS create_time
			, DATE_FORMAT(create_time, '%Y/%m/%d')	AS create_time_string
			, apply_email							AS apply_email
			, apply_time							AS apply_time
			, veri_apply_flg						AS veri_apply_flg
			, veri_apply_time						AS veri_apply_time
			, mail_send_flg							AS mail_send_flg
		FROM
			v_users_active
		WHERE
			user_name		= '__ELEMENT01__'
			AND password	= '__ELEMENT02__'
			AND wl_id		= '__ELEMENT03__'
	</SELECT_LOGIN>

	<!--
		口座番号による、ユーザの取得
		条　件：口座番号
	-->
	<SELECT_USER_BY_ACCOUNT>
		SELECT
			u_id											AS u_id
			, user_name										AS user_name
			, password										AS password
			, wl_id											AS wl_id
			, wl_name										AS wl_name
			, mail											AS mail
			, account_type									AS account_type
			, user_account									AS user_account
			, currency										AS currency
			, tel											AS tel
			, last_name										AS last_name
			, first_name									AS first_name
			, birth											AS birth
			, DATE_FORMAT(birth, '%Y/%m/%d')				AS birth_string
			, YEAR(birth)									AS birth_year
			, MONTH(birth)									AS birth_month
			, DAY(birth)									AS birth_day
			, country										AS country
			, state											AS state
			, city											AS city
			, zip_code										AS zip_code
			, address										AS address
			, address2										AS address2
			, bank_country									AS bank_country
			, bank_name										AS bank_name
			, branch_name									AS branch_name
			, branch_number									AS branch_number
			, account_number								AS account_number
			, swift_code									AS receipt_bank_swift
			, bank_address									AS receipt_address_1
			, account_name									AS account_name
			, admin_flg										AS admin_flg
			, status										AS status
			, kyc_flg										AS kyc_flg
			, agent_flg										AS agent_flg
			, agent_code									AS agent_code
			, parent_agent_code								AS parent_agent_code
			, create_time									AS create_time
			, DATE_FORMAT(create_time, '%Y/%m/%d %H:%i:%s')	AS create_time_string
			, apply_email									AS apply_email
			, apply_time									AS apply_time
			, veri_apply_flg								AS veri_apply_flg
			, veri_apply_time								AS veri_apply_time
			, mail_send_flg									AS mail_send_flg
			, crm_id										AS crm_id
			, note											AS note
			, risk											AS risk
			, ceo_first_name								AS ceo_first_name
			, ceo_last_name									AS ceo_last_name
			, corp_url										AS corp_url
			, target_country								AS target_country
			, site_name										AS site_name
			, site_url										AS site_url
			, registration_number							AS registration_number
			, registration_date 							AS registration_date
			, skype_account 								AS skype_account
			, initial_email_address                         AS initial_email_address
			, initial_contact_name                          AS initial_contact_name
			, type_of_usage 								AS type_of_usage
			, agreement_status 								AS agreement_status
			, transfer_batch_flg							AS transfer_batch_flg
			, manager_name									AS manager_name
			, manager_email									AS manager_email
			, manager_tel									AS manager_tel
			, gps_account_flg								AS gps_account_flg
			, gps_kind_of_payment							AS gps_kind_of_payment
			, kyc_validate_status 							AS kyc_validate_status
			, use_langage									AS use_language
			, risk_level									AS risk_level		<!-- Mikko 2019: 3501 -->
			, exchange_commision_id							AS exchange_commision_id
			, kyc_status_update_counter 					AS kyc_status_update_counter
			, user_threshold								AS user_threshold
			, user_dup_source								AS user_dup_source
			, tier_tag					 					AS tier_level
			, create_ip_address								AS create_ip_address
			, transfer_flg					 				AS transfer_flg
			, test_account_flg					 			AS test_account_flg
		FROM
			v_users_all AS users
		WHERE
			user_account = '__ELEMENT01__'
	</SELECT_USER_BY_ACCOUNT>

	<!--
		口座番号による、ユーザの取得
		条　件：口座番号
	-->
	<SELECT_USER_BY_ID_PW>
		SELECT
			u_id									AS u_id
			, user_name								AS user_name
			, password								AS password
			, mail									AS mail
			, account_type							AS account_type
			, user_account							AS user_account
			, currency								AS currency
			, tel									AS tel
			, last_name								AS last_name
			, first_name							AS first_name
			, birth									AS birth
			, DATE_FORMAT(birth, '%Y/%m/%d')		AS birth_string
			, YEAR(birth)							AS birth_year
			, MONTH(birth)							AS birth_month
			, DAY(birth)							AS birth_day
			, country								AS country
			, state									AS state
			, city									AS city
			, zip_code								AS zip_code
			, address								AS address
			, address2								AS address2
			, bank_country							AS bank_country
			, bank_name								AS bank_name
			, branch_name							AS branch_name
			, branch_number							AS branch_number
			, account_number						AS account_number
			, swift_code							AS receipt_bank_swift
			, bank_address							AS receipt_address_1
			, account_name							AS account_name
			, admin_flg								AS admin_flg
			, status								AS status
			, kyc_flg								AS kyc_flg
			, agent_flg								AS agent_flg
			, agent_code							AS agent_code
			, parent_agent_code						AS parent_agent_code
			, create_time							AS create_time
			, DATE_FORMAT(create_time, '%Y/%m/%d')	AS create_time_string
			, apply_email							AS apply_email
			, apply_time							AS apply_time
			, veri_apply_flg						AS veri_apply_flg
			, veri_apply_time						AS veri_apply_time
			, mail_send_flg							AS mail_send_flg
			, crm_id								AS crm_id
			, note									AS note
		FROM
			v_users_all AS users
		WHERE
			user_name		= '__ELEMENT01__'
			AND password	= '__ELEMENT02__'
	</SELECT_USER_BY_ID_PW>

	<!--
		口座番号による、ユーザの取得
		条　件：口座番号
	-->
	<SELECT_USER_BY_ACCOUNT_OR_EMAIL>
		SELECT
			u_id									AS u_id
			, user_name								AS user_name
			, password								AS password
			, mail									AS mail
			, account_type							AS account_type
			, user_account							AS user_account
			, currency								AS currency
			, tel									AS tel
			, last_name								AS last_name
			, first_name							AS first_name
			, birth									AS birth
			, DATE_FORMAT(birth, '%Y/%m/%d')		AS birth_string
			, YEAR(birth)							AS birth_year
			, MONTH(birth)							AS birth_month
			, DAY(birth)							AS birth_day
			, country								AS country
			, state									AS state
			, city									AS city
			, zip_code								AS zip_code
			, address								AS address
			, address2								AS address2
			, bank_country							AS bank_country
			, bank_name								AS bank_name
			, branch_name							AS branch_name
			, branch_number							AS branch_number
			, account_number						AS account_number
			, swift_code							AS receipt_bank_swift
			, bank_address							AS receipt_address_1
			, account_name							AS account_name
			, admin_flg								AS admin_flg
			, status								AS status
			, kyc_flg								AS kyc_flg
			, agent_flg								AS agent_flg
			, agent_code							AS agent_code
			, parent_agent_code						AS parent_agent_code
			, create_time							AS create_time
			, DATE_FORMAT(create_time, '%Y/%m/%d')	AS create_time_string
			, apply_email							AS apply_email
			, apply_time							AS apply_time
			, veri_apply_flg						AS veri_apply_flg
			, veri_apply_time						AS veri_apply_time
			, mail_send_flg							AS mail_send_flg
			, crm_id								AS crm_id
			, note									AS note
			, risk									AS risk
		FROM
			v_users_all AS users
		WHERE
			user_account	= '__ELEMENT01__'
			OR mail			= '__ELEMENT01__'
			OR user_name	= '__ELEMENT01__'
	</SELECT_USER_BY_ACCOUNT_OR_EMAIL>

	<!--
		未認証再送信メール時の時間再設定
		条　件：ID
	-->
	<UPDATE_VERI_DATE>
		UPDATE
			v_users_all
		SET
			regist_time = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			user_account	= '__ELEMENT01__'
			OR mail			= '__ELEMENT01__'
			OR user_name	= '__ELEMENT01__'
	</UPDATE_VERI_DATE>

	<!--
		エージェントによる、ユーザの取得
		条　件：エージェント
	-->
	<SELECT_USER_BY_AGENT_CODE>
		SELECT
			u_id									AS u_id
			, user_name								AS user_name
			, password								AS password
			, mail									AS mail
			, account_type							AS account_type
			, user_account							AS user_account
			, currency								AS currency
			, tel									AS tel
			, last_name								AS last_name
			, first_name							AS first_name
			, birth									AS birth
			, DATE_FORMAT(birth, '%Y/%m/%d')		AS birth_string
			, YEAR(birth)							AS birth_year
			, MONTH(birth)							AS birth_month
			, DAY(birth)							AS birth_day
			, country								AS country
			, state									AS state
			, city									AS city
			, zip_code								AS zip_code
			, address								AS address
			, address2								AS address2
			, bank_country							AS bank_country
			, bank_name								AS bank_name
			, branch_name							AS branch_name
			, branch_number							AS branch_number
			, account_number						AS account_number
			, swift_code							AS receipt_bank_swift
			, bank_address							AS receipt_address_1
			, account_name							AS account_name
			, admin_flg								AS admin_flg
			, status								AS status
			, kyc_flg								AS kyc_flg
			, agent_flg								AS agent_flg
			, agent_code							AS agent_code
			, parent_agent_code						AS parent_agent_code
			, commision_id							AS commision_id
			, create_time							AS create_time
			, DATE_FORMAT(create_time, '%Y/%m/%d')	AS create_time_string
			, apply_email							AS apply_email
			, apply_time							AS apply_time
			, veri_apply_flg						AS veri_apply_flg
			, veri_apply_time						AS veri_apply_time
			, mail_send_flg							AS mail_send_flg
			, crm_id								AS crm_id
			, note									AS note
		FROM
			v_users_all AS users
		WHERE
			agent_code = '__ELEMENT01__'
	</SELECT_USER_BY_AGENT_CODE>

	<!--
		口座の一覧
		条　件：検索条件
	-->
	<LIST_ACCOUNTS>
		SELECT
			data.u_id										AS u_id
			, data.user_name								AS user_name
			, data.password									AS password
			, data.wl_name									AS wl_name
			, data.mail										AS mail
			, data.account_type								AS account_type
			, data.user_account								AS user_account
			, data.currency									AS currency
			, data.tel										AS tel
			, data.last_name								AS last_name
			, data.first_name								AS first_name
			, data.birth									AS birth
			, data.country									AS country
			, data.state									AS state
			, data.city										AS city
			, data.zip_code									AS zip_code
			, data.address									AS address
			, data.address2									AS address2
			, data.bank_name								AS bank_name
			, data.branch_name								AS branch_name
			, data.branch_number							AS branch_number
			, data.account_number							AS account_number
			, data.account_name								AS account_name
			, data.admin_flg								AS admin_flg
			, data.status									AS status
			, data.kyc_flg									AS kyc_flg
			, data.agent_flg								AS agent_flg
			, data.agent_code								AS agent_code
			, data.parent_agent_code						AS parent_agent_code
			, data.create_time								AS create_time
			, DATE_FORMAT(data.create_time, '%Y/%m/%d')		AS create_time_string
			, data.apply_email								AS apply_email
			, data.apply_time								AS apply_time
			, data.veri_apply_flg							AS veri_apply_flg
			, data.veri_apply_time							AS veri_apply_time
			, data.mail_send_flg							AS mail_send_flg
			, data.last_login_time							AS last_login_time
			, data.close_time								AS close_time
			, data.suspension_time							AS suspension_time
			, data.tier_tag									AS tier_level
			, data.crm_id									AS crm_id
			, data.note 									AS note
			, COUNT(distinct(user_cards.card_holder_id))	AS card_holds
			, user.kyc_validate_status						AS validate_status
			, data.test_account_flg					 		AS test_account_flg
		FROM
			v_users_all			AS data
			LEFT OUTER JOIN
				t_user_cards	AS user_cards
			ON(data.user_account = user_cards.user_account)
			LEFT OUTER JOIN
				t_user	AS user
			ON(data.user_account = user.user_account)
			LEFT OUTER JOIN
				t_kyc	AS kyc
			ON(data.user_account = kyc.user_account)
		WHERE
			1
			__ELEMENT01__
		GROUP BY
			data.user_account
		HAVING
			u_id != ''
			__ELEMENT02__
		ORDER BY
			create_time DESC
		__ELEMENT03__
	</LIST_ACCOUNTS>

	<!-- mark -->
	<LIST_ACCOUNTS_REVISED>
		SELECT
			data.u_id AS u_id,
			t_login.user_name AS user_name,
			t_login.password AS password,
			data.wl_name AS wl_name,
			data.mail AS mail,
			data.account_type AS account_type,
			data.user_account AS user_account,
			data.currency AS currency,
			data.tel AS tel,
			data.last_name AS last_name,
			data.first_name AS first_name,
			data.birth AS birth,
			data.country AS country,
			data.state AS state,
			data.city AS city,
			data.zip_code AS zip_code,
			data.address AS address,
			data.address2 AS address2,
			data.bank_name AS bank_name,
			data.branch_name AS branch_name,
			data.branch_number AS branch_number,
			data.account_number AS account_number,
			data.account_name AS account_name,
			data.admin_flg AS admin_flg,
			data.status AS status,
			data.kyc_flg AS kyc_flg,
			data.agent_flg AS agent_flg,
			data.agent_code AS agent_code,
			data.parent_agent_code AS parent_agent_code,
			data.create_time AS create_time,
			DATE_FORMAT(data.create_time, '%Y/%m/%d') AS create_time_string,
			data.apply_email AS apply_email,
			data.apply_time AS apply_time,
			data.veri_apply_flg AS veri_apply_flg,
			data.veri_apply_time AS veri_apply_time,
			data.mail_send_flg AS mail_send_flg,
			data.last_login_time AS last_login_time,
			data.close_time AS close_time,
			data.suspension_time AS suspension_time,
			data.tier_tag AS tier_level,
			data.crm_id AS crm_id,
			data.note AS note,
			COUNT(DISTINCT (user_cards.card_holder_id)) AS card_holds,
			data.kyc_validate_status AS validate_status,
			data.test_account_flg	AS test_account_flg
		FROM t_login
		LEFT JOIN (
		    SELECT
		      t_user.*,
		      t_mst_white_label.wl_name
		    FROM t_user
		    JOIN t_mst_white_label
		      ON t_mst_white_label.wl_id = t_user.wl_id
		    WHERE admin_flg = 0 AND del_flg = 0
		          ) data
		  ON data.u_id = t_login.u_id
		LEFT OUTER JOIN t_user_cards AS user_cards
		  ON (data.user_account = user_cards.user_account)
		LEFT OUTER JOIN t_kyc AS kyc
		  ON (data.user_account = kyc.user_account)
		WHERE 1
			__ELEMENT01__
		GROUP BY
			data.user_account
		HAVING
			u_id != ''
			__ELEMENT02__
		ORDER BY
			create_time DESC
			__ELEMENT03__
	</LIST_ACCOUNTS_REVISED>

	<!-- mark -->
	<LIST_ACCOUNTS_REVISED_BI>
		SELECT
			data.u_id AS u_id,
			data.wl_name AS wl_name,
			data.mail AS mail,
			data.account_type AS account_type,
			data.user_account AS user_account,
			data.currency AS currency,
			data.last_name AS last_name,
			data.first_name AS first_name,
			data.birth AS birth,
			data.country AS country,
			data.state AS state,
			data.city AS city,
			data.zip_code AS zip_code,
			data.address AS address,
			data.address2 AS address2,
			data.account_number AS account_number,
			data.account_name AS account_name,
			data.admin_flg AS admin_flg,
			data.status AS status,
			data.kyc_flg AS kyc_flg,
			data.agent_flg AS agent_flg,
			data.agent_code AS agent_code,
			data.parent_agent_code AS parent_agent_code,
			data.create_time AS create_time,
			data.mail_send_flg AS mail_send_flg,
			data.last_login_time AS last_login_time,
			data.close_time AS close_time,
			data.suspension_time AS suspension_time,
			data.tier_tag AS tier_level,
			data.crm_id AS crm_id,
			COUNT(DISTINCT (user_cards.card_holder_id)) AS card_holds,
			data.kyc_validate_status AS validate_status,
			data.test_account_flg	AS test_account_flg
		FROM t_login
		LEFT JOIN (
		    SELECT
		      t_user.*,
		      t_mst_white_label.wl_name
		    FROM t_user
		    JOIN t_mst_white_label
		      ON t_mst_white_label.wl_id = t_user.wl_id
		    WHERE admin_flg = 0 AND del_flg = 0
		          ) data
		  ON data.u_id = t_login.u_id
		LEFT OUTER JOIN t_user_cards AS user_cards
		  ON (data.user_account = user_cards.user_account)
		LEFT OUTER JOIN t_kyc AS kyc
		  ON (data.user_account = kyc.user_account)
		WHERE 1
			__ELEMENT01__
		GROUP BY
			data.user_account
		HAVING
			u_id != ''
			__ELEMENT02__
		ORDER BY
			__ELEMENT03__
			__ELEMENT04__
	</LIST_ACCOUNTS_REVISED_BI>

	<!--
		口座の一覧件数
		条　件：検索条件
	-->
	<COUNT_ACCOUNTS>
		SELECT
			COUNT(data.u_id)	AS counter
		FROM
			v_users_all			AS data
		WHERE
			1
			__ELEMENT01__
			AND u_id != ''
			__ELEMENT02__
	</COUNT_ACCOUNTS>

	<!-- mark -->
	<COUNT_ACCOUNTS_REVISED>
		SELECT
			COUNT(data.u_id)	AS counter
		FROM
			t_login
		LEFT JOIN
			t_user 			AS data
		ON
			data.u_id = t_login.u_id
		WHERE
			1
			AND admin_flg = 0
			AND del_flg = 0
			__ELEMENT01__
			AND data.u_id != ''
			__ELEMENT02__
	</COUNT_ACCOUNTS_REVISED>

	<!--
		エージェントの一覧
		条　件：なし
	-->
	<LIST_AGENT>
		SELECT
			agents.u_id												AS u_id
			, agents.user_name										AS user_name
			, agents.password										AS password
			, agents.wl_id											AS wl_id
			, agents.wl_name										AS wl_name
			, agents.mail											AS mail
			, agents.account_type									AS account_type
			, agents.user_account									AS user_account
			, agents.currency										AS currency
			, agents.tel											AS tel
			, agents.last_name										AS last_name
			, agents.first_name										AS first_name
			, agents.birth											AS birth
			, agents.country										AS country
			, agents.state											AS state
			, agents.city											AS city
			, agents.zip_code										AS zip_code
			, agents.address										AS address
			, agents.address2										AS address2
			, agents.bank_name										AS bank_name
			, agents.branch_name									AS branch_name
			, agents.branch_number									AS branch_number
			, agents.account_number									AS account_number
			, agents.account_name									AS account_name
			, agents.agent_flg										AS agent_flg
			, agents.agent_code										AS agent_code
			, agents.parent_agent_code								AS parent_agent_code
			, agents.admin_flg										AS admin_flg
			, agents.status											AS status
			, agents.kyc_flg										AS kyc_flg
			, agents.agent_flg										AS agent_flg
			, agents.agent_code										AS agent_code
			, agents.create_time									AS create_time
			, DATE_FORMAT(agents.create_time, '%Y/%m/%d')			AS create_time_string
			, agents.apply_email									AS apply_email
			, agents.apply_time										AS apply_time
			, agents.veri_apply_flg									AS veri_apply_flg
			, agents.veri_apply_time								AS veri_apply_time
			, agents.mail_send_flg									AS mail_send_flg
			, IFNULL(corporation.ceo_first_name, '')				AS ceo_first_name
			, IFNULL(corporation.ceo_last_name, '')					AS ceo_last_name
			, IFNULL(corporation.corp_url, '')						AS corp_url
			, IFNULL(corporation.target_country, '')				AS target_country
			, IFNULL(corporation.site_name, '')						AS site_name
			, IFNULL(corporation.site_url, '')						AS site_url
			, IFNULL(corporation.registration_number, '')  			AS registration_number
			, IFNULL(corporation.skype_account, '')  			    AS skype_account
			, IFNULL(corporation.initial_email_address, '')  	    AS initial_email_address
			, IFNULL(corporation.initial_contact_name, '')          AS initial_contact_name
			, IFNULL(corporation.skype_account, '')  			    AS skype_account
			, IFNULL(corporation.type_of_usage, '')					AS type_of_usage
			, IFNULL(corporation.agreement_status, '') 				AS agreement_status
			, IFNULL(corporation.manager_name, '')					AS manager_name
			, IFNULL(corporation.manager_email, '')					AS manager_email
			, IFNULL(corporation.manager_tel, '')					AS manager_tel
			, IFNULL(children_agent.counter, '0')					AS agent_counter
			, IFNULL(children_user.counter, '0')					AS user_counter
		FROM
			v_users_active			AS agents
			LEFT OUTER JOIN
				t_corporation		AS corporation
			ON(agents.u_id = corporation.u_id)
			LEFT OUTER JOIN
				v_children_agent	AS children_agent
			ON(agents.agent_code = children_agent.parent_agent_code)
			LEFT OUTER JOIN
				v_children_user		AS children_user
			ON(agents.agent_code = children_user.parent_agent_code)
		WHERE
			agents.agent_flg = '1'
			__ELEMENT01__
		ORDER BY
			create_time DESC
	</LIST_AGENT>

	<!--
		エージェント所持口座の一覧
		条　件：エージェントコード
	-->
	<LIST_AGENT_CHILDREN>
		SELECT
			u_id									AS u_id
			, user_name								AS user_name
			, password								AS password
			, mail									AS mail
			, account_type							AS account_type
			, user_account							AS user_account
			, currency								AS currency
			, tel									AS tel
			, last_name								AS last_name
			, first_name							AS first_name
			, birth									AS birth
			, country								AS country
			, state									AS state
			, city									AS city
			, zip_code								AS zip_code
			, address								AS address
			, address2								AS address2
			, bank_name								AS bank_name
			, branch_name							AS branch_name
			, branch_number							AS branch_number
			, account_number						AS account_number
			, account_name							AS account_name
			, agent_flg								AS agent_flg
			, agent_code							AS agent_code
			, parent_agent_code						AS parent_agent_code
			, admin_flg								AS admin_flg
			, status								AS status
			, kyc_flg								AS kyc_flg
			, agent_flg								AS agent_flg
			, agent_code							AS agent_code
			, create_time							AS create_time
			, DATE_FORMAT(create_time, '%Y/%m/%d')	AS create_time_string
			, apply_email							AS apply_email
			, apply_time							AS apply_time
			, veri_apply_flg						AS veri_apply_flg
			, veri_apply_time						AS veri_apply_time
			, mail_send_flg							AS mail_send_flg
		FROM
			v_users_active
		WHERE
			agent_flg				= '1'
			AND parent_agent_code	= '__ELEMENT01__'
			AND user_account		!= '__ELEMENT02__'
		ORDER BY
			create_time DESC
	</LIST_AGENT_CHILDREN>

	<!--
		エージェント所持口座の一覧
		条　件：エージェントコード
	-->
	<LIST_AGENT_COMMISION>
		SELECT
			mst_commision.fee_name					AS fee_name
			, mst_commision.commision_type			AS commision_type
			, mst_commision.m_f_id					AS m_f_id
			, mst_commision.wallet_type				AS wallet_type
			, IFNULL(parent.agent_code, '')			AS parent_agent_code
			, IFNULL(parent.children_percent, 0)	AS whole_percent
			, IFNULL(parent.children_fix, 0)		AS whole_fix
			, IFNULL(agent.agent_code, '')			AS agent_code
			, IFNULL(agent.percent, 0)				AS percent
			, IFNULL(agent.fix, 0)					AS fix
			, IFNULL(agent.children_percent, 0)		AS children_percent
			, IFNULL(agent.children_fix, 0)			AS children_fix
		FROM
			v_mst_commision 		AS mst_commision
			LEFT OUTER JOIN
				t_commision			AS agent
			ON(mst_commision.m_f_id				= agent.m_f_id
				AND mst_commision.wallet_type	= agent.wallet_type
				AND agent.agent_code			= '__ELEMENT01__')
			LEFT OUTER JOIN
				t_commision			AS parent
			ON(mst_commision.m_f_id				= parent.m_f_id
				AND mst_commision.wallet_type	= parent.wallet_type
				AND parent.agent_code			= '__ELEMENT02__')
		ORDER BY
			mst_commision.m_f_id
			, mst_commision.wallet_type
	</LIST_AGENT_COMMISION>

    <!-- エージェント所持口座の一覧
		条　件：エージェントコード
        anton
     -->
    <LIST_AGENT_COMMISION_EN>
        SELECT
			if(mst_commision.fee_name = "月額維持", "Monthly Maintenance Fee", 
				if(mst_commision.fee_name = "入金", "Deposit",
				if(mst_commision.fee_name = "出金（成功時）", "Successful Withdrawal",
				if(mst_commision.fee_name = "出金（失敗時）", "Failed Withdrawal", 
				if(mst_commision.fee_name = "口座間振替", "Internal Transfer",
				if(mst_commision.fee_name = "休止", "Suspension",
				if(mst_commision.fee_name = "削除", "Deletion",				
				if(mst_commision.fee_name = "カード入金", "Card Deposit", mst_commision.fee_name
				))))))))					AS fee_name
			, if(mst_commision.commision_type = "個人", "Individual", 
				if(mst_commision.commision_type = "法人", "Corporate", 
				if(mst_commision.commision_type = "個人→法人", "Individual → Corporate", 
				if(mst_commision.commision_type = "個人→個人", "Individual → Individual",
				if(mst_commision.commision_type = "法人→個人", "Corporate → Individual",
				if(mst_commision.commision_type = "法人→法人", "Corporate → Corporate", mst_commision.fee_name
				))))))			            AS commision_type
			, mst_commision.m_f_id						AS m_f_id
			, mst_commision.wallet_type				AS wallet_type
			, IFNULL(parent.agent_code, '')			AS parent_agent_code
			, IFNULL(parent.children_percent, 0)	AS whole_percent
			, IFNULL(parent.children_fix, 0)		AS whole_fix
			, IFNULL(agent.agent_code, '')			AS agent_code
			, IFNULL(agent.percent, 0)				AS percent
			, IFNULL(agent.fix, 0)					AS fix
			, IFNULL(agent.children_percent, 0)		AS children_percent
			, IFNULL(agent.children_fix, 0)			AS children_fix
		FROM
			v_mst_commision 		AS mst_commision
			LEFT OUTER JOIN
				t_commision			AS agent
			ON(mst_commision.m_f_id				= agent.m_f_id
				AND mst_commision.wallet_type	= agent.wallet_type
				AND agent.agent_code			= '__ELEMENT01__')
			LEFT OUTER JOIN
				t_commision			AS parent
			ON(mst_commision.m_f_id				= parent.m_f_id
				AND mst_commision.wallet_type	= parent.wallet_type
				AND parent.agent_code			= '__ELEMENT02__')
		ORDER BY
			mst_commision.m_f_id
			, mst_commision.wallet_type
    </LIST_AGENT_COMMISION_EN>
    
	<!--
		エージェントコミッション取得
		条　件：エージェントコード
	-->

	<SELECT_AGENT_COMMISION_BY_AGENT_CODE>
		SELECT
			mst_commision.fee_name				AS fee_name
			, mst_commision.commision_type		AS commision_type
			, mst_commision.m_f_id				AS m_f_id
			, mst_commision.wallet_type			AS wallet_type
			, IFNULL(commission.agent_code, '')	AS agent_code
			, commission.currency				AS currency
			, SUM(commission.percent)			AS percent
			, SUM(commission.fix)				AS fix
		FROM
			v_mst_commision 		AS mst_commision
			LEFT OUTER JOIN
				t_agent_commision	AS commission
			ON(mst_commision.m_f_id				= commission.m_f_id
				AND mst_commision.wallet_type	= commission.wallet_type)
		WHERE
			commission.agent_code				= '__ELEMENT01__'
			AND YEAR(commission.create_time)	= '__ELEMENT02__'
			AND MONTH(commission.create_time)	= '__ELEMENT03__'
		GROUP BY
			mst_commision.m_f_id
			, mst_commision.wallet_type
			, commission.currency
		UNION ALL
		SELECT
			'為替手数料'	AS fee_name
			, '共通' 		AS commision_type
			, '9' 			AS m_f_id
			, '7' 			AS wallet_type
			, '__ELEMENT01__'		AS agent_code
			, commission.currency				AS currency
			, SUM(commission.percent)			AS percent
			, SUM(commission.fix)				AS fix
		FROM
			t_agent_commision AS commission
		WHERE
			m_f_id								= '9'
			AND commission.agent_code			= '__ELEMENT01__'
			AND YEAR(commission.create_time)	= '__ELEMENT02__'
			AND MONTH(commission.create_time)	= '__ELEMENT03__'
		GROUP BY
			commission.currency
	</SELECT_AGENT_COMMISION_BY_AGENT_CODE>

	<!--
		エージェント所持口座の一覧
		条　件：エージェントコード
	-->
	<SELECT_AGENT_COMMISION>
		SELECT
			mst_commision.fee_name					AS fee_name
			, mst_commision.commision_type			AS commision_type
			, mst_commision.m_f_id					AS m_f_id
			, mst_commision.wallet_type				AS wallet_type
			, IFNULL(agent.agent_code, '')			AS agent_code
			, IFNULL(agent.percent, 0)				AS percent
			, IFNULL(agent.fix, 0)					AS fix
			, IFNULL(agent.children_percent, 0)		AS children_percent
			, IFNULL(agent.children_fix, 0)			AS children_fix
		FROM
			v_mst_commision 		AS mst_commision
			LEFT OUTER JOIN
				t_commision			AS agent
			ON(mst_commision.m_f_id				= agent.m_f_id
				AND mst_commision.wallet_type	= agent.wallet_type
				AND agent.agent_code			= '__ELEMENT01__')
		WHERE
			mst_commision.m_f_id			= '__ELEMENT02__'
			AND mst_commision.wallet_type	= '__ELEMENT03__'
	</SELECT_AGENT_COMMISION>

	<SELECT_AGENT_CODE_BY_AID>
		SELECT
			parent_agent_code						AS parent_agent_code
			, agent_code							AS agent_code
		FROM
			t_user
		WHERE
			user_account = (SELECT
					user_account
				FROM
					t_api_signature
				WHERE
					a_id = '__ELEMENT01__'
			)
	</SELECT_AGENT_CODE_BY_AID>

	<!--
		エージェント手数料の登録
		登録値：エージェントコード
				手数料マスタID
				手数料タイプ
				エージェント
				マスター

	-->
	<INSERT_AGENT_COMMISION>
		INSERT INTO t_commision (
			agent_code
			, m_f_id
			, wallet_type
			, percent
			, fix
			, children_percent
			, children_fix
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_AGENT_COMMISION>

	<!--
		エージェントの一件取得
		条　件：ユーザ口座番号
	-->
	<SELECT_AGENT>
		SELECT
			users_active.u_id									AS u_id
			, users_active.wl_id								AS wl_id
			, users_active.user_name							AS user_name
			, users_active.password								AS password
			, users_active.mail									AS mail
			, users_active.account_type							AS account_type
			, users_active.user_account							AS user_account
			, users_active.currency								AS currency
			, users_active.tel									AS tel
			, users_active.corporation_name						AS corporation_name
			, users_active.last_name							AS last_name
			, users_active.first_name							AS first_name
			, DATE_FORMAT(users_active.birth, '%Y/%m/%d')		AS birth
			, users_active.country								AS country
			, users_active.state								AS state
			, users_active.city									AS city
			, users_active.zip_code								AS zip_code
			, users_active.address								AS address
			, users_active.address2								AS address2
			, users_active.bank_name							AS bank_name
			, users_active.branch_name							AS branch_name
			, users_active.branch_number						AS branch_number
			, users_active.account_number						AS account_number
			, users_active.account_name							AS account_name
			, users_active.agent_flg							AS agent_flg
			, users_active.agent_code							AS agent_code
			, users_active.parent_agent_code					AS parent_agent_code
			, users_active.admin_flg							AS admin_flg
			, users_active.status								AS status
			, users_active.kyc_flg								AS kyc_flg
			, users_active.agent_flg							AS agent_flg
			, users_active.agent_code							AS agent_code
			, users_active.create_time							AS create_time
			, DATE_FORMAT(users_active.create_time, '%Y/%m/%d')	AS create_time_string
			, users_active.apply_email							AS apply_email
			, users_active.apply_time							AS apply_time
			, users_active.veri_apply_flg						AS veri_apply_flg
			, users_active.veri_apply_time						AS veri_apply_time
			, users_active.mail_send_flg						AS mail_send_flg
			, users_active.commision_id							AS commision_id
			, users_active.exchange_commision_id				AS exchange_commision_id
			, IFNULL(parent.corporation_name, '')				AS parent_corporation_name
		FROM
			v_users_active	AS users_active
			LEFT OUTER JOIN
				t_user		AS parent
			ON(users_active.parent_agent_code = parent.agent_code)
		WHERE
			users_active.user_account = '__ELEMENT01__'
	</SELECT_AGENT>

	<!--
		エージェントの一件取得（エージェントコード）
		条　件：エージェントコード
	-->
	<SELECT_AGENT_AGENT_CODE>
		SELECT
			u_id									AS u_id
			, user_name								AS user_name
			, password								AS password
			, mail									AS mail
			, account_type							AS account_type
			, user_account							AS user_account
			, currency								AS currency
			, tel									AS tel
			, corporation_name						AS corporation_name
			, last_name								AS last_name
			, first_name							AS first_name
			, DATE_FORMAT(birth, '%Y/%m/%d')		AS birth
			, country								AS country
			, state									AS state
			, city									AS city
			, zip_code								AS zip_code
			, address								AS address
			, address2								AS address2
			, bank_name								AS bank_name
			, branch_name							AS branch_name
			, branch_number							AS branch_number
			, account_number						AS account_number
			, account_name							AS account_name
			, agent_flg								AS agent_flg
			, agent_code							AS agent_code
			, parent_agent_code						AS parent_agent_code
			, admin_flg								AS admin_flg
			, status								AS status
			, kyc_flg								AS kyc_flg
			, agent_flg								AS agent_flg
			, agent_code							AS agent_code
			, create_time							AS create_time
			, DATE_FORMAT(create_time, '%Y/%m/%d')	AS create_time_string
			, apply_email							AS apply_email
			, apply_time							AS apply_time
			, veri_apply_flg						AS veri_apply_flg
			, veri_apply_time						AS veri_apply_time
			, mail_send_flg							AS mail_send_flg
		FROM
			v_users_active
		WHERE
			agent_flg		= '1'
			AND agent_code	= '__ELEMENT01__'
	</SELECT_AGENT_AGENT_CODE>

	<!--
		エージェントの更新
		更新値：会社名
				姓
				名
				国
				都道府県
				市
				住所
				郵便番号
				電話番号
				メールアドレス
				銀行名
		条　件：ユーザ口座番号
	-->
	<UPDATE_AGENT>
		UPDATE
			t_user
		SET
			corporation_name		= '__ELEMENT02__'
			, commision_id			= '__ELEMENT03__'
			, exchange_commision_id	= '__ELEMENT04__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_AGENT>

	<!--
		エージェント手数料の削除
		条　件：エージェントコード
	-->
	<DELETE_AGENT_COMMISION>
		DELETE
		FROM
			t_commision
		WHERE
			agent_code = '__ELEMENT01__'
	</DELETE_AGENT_COMMISION>

	<!--
		親エージェントコードの更新
		更新値：親エージェントコード
		条　件：口座番号
	-->
	<UPDATE_PARENT_AGENT_CODE>
		UPDATE
			t_user
		SET
			parent_agent_code	= '__ELEMENT02__'
		WHERE
			user_account		= '__ELEMENT01__'
	</UPDATE_PARENT_AGENT_CODE>


	<!--
		口座番号の取得
		条　件：口座番号
	-->
	<SELECT_ACCOUNT>
		SELECT
			user_account
			, user_name
		FROM
			v_users_all
		WHERE
			user_account = '__ELEMENT01__'
	</SELECT_ACCOUNT>

	<!--
		口座番号の取得
		条　件：口座番号orログインメールアドレス
	-->
	<SELECT_ACCOUNT_BY_EMAIL_OR_ACCOUNT>
		SELECT
			u_id
			, user_account
			, user_name
		FROM
			v_users_all
		WHERE
			user_account	= '__ELEMENT01__'
			OR mail			= '__ELEMENT01__'
			OR user_name	= '__ELEMENT01__'
	</SELECT_ACCOUNT_BY_EMAIL_OR_ACCOUNT>

	<!--
		口座番号の取得
		条　件：口座番号
	-->
	<SELECT_ACCOUNT_BY_UID>
		SELECT
			user_account
			, user_name
		FROM
			v_users_all
		WHERE
			u_id = '__ELEMENT01__'
	</SELECT_ACCOUNT_BY_UID>

	<!--
		ログインデータの登録
		登録値：UID
				ユーザ名
				パスワード
	-->
	<INSERT_LOGIN>
		INSERT INTO t_login (
			u_id
			, user_name
			, password
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
		)
	</INSERT_LOGIN>

	<!--
		ユーザデータの登録
		登録値：UID
				メルアド
				口座種別
				口座番号
				電話番号
				姓
				名
				生年月日
				国
				都道府県
				市
				郵便番号
				番地
	-->
	<INSERT_USER>
		INSERT INTO t_user (
			u_id
			, mail
			, account_type
			, user_account
			, tel
			, last_name
			, first_name
			, birth
			, country
			, state
			, city
			, zip_code
			, address
			, address2
			, agent_code
			, agent_flg
			, parent_agent_code
			, create_time
			, regist_time
			, create_ip_address
			, status
			, crm_id
			, wl_id
			, use_langage
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__-__ELEMENT09__-__ELEMENT10__ 00:00:00'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
			, '__ELEMENT16__'
			, '__ELEMENT17__'
			, '__ELEMENT18__'
			, '__ELEMENT19__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT20__'
			, '__ELEMENT21__'
			, '__ELEMENT22__'
			, '__ELEMENT23__'
			, '__ELEMENT24__'
		)
	</INSERT_USER>

	<!--
		手数料の登録
		登録値：手数料ID
				手数料名
				手数料種別
	-->
	<INSERT_FEES>
		INSERT INTO t_fees (
			f_id
			, fee_type_name
			, fee_type
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
		)
	</INSERT_FEES>

	<!--
		手数料詳細の登録
		登録値：手数料ID
				手数料マスタID
				ウォレットタイプ
				手数料フラグ
				固定値
				パーセンテージ
				パーセンテージ最高値
	-->
	<INSERT_FEES_DETAIL>
		INSERT INTO t_fees_detail (
			f_id
			, m_f_id
			, wallet_type
			, fee_flg
			, fix
			, percent
			, max_value
			, min_value
			, app_flg
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
		)
	</INSERT_FEES_DETAIL>

	<!--
		手数料の更新
		更新値：手数料名
				手数料種別
		条　件：手数料ID
	-->
	<UPDATE_FEES>
		UPDATE
			t_fees
		SET
			fee_type_name	= '__ELEMENT02__'
		WHERE
			f_id = '__ELEMENT01__'
	</UPDATE_FEES>

	<!--
		手数料詳細の更新
		更新値：手数料フラグ
				固定値
				パーセンテージ
				パーセンテージ最高値
		条　件：手数料ID
				手数料マスタID
				ウォレットタイプ
	-->
	<UPDATE_FEES_DETAIL>
		UPDATE
			t_fees_detail
		SET
			fee_flg			= '__ELEMENT04__'
			, fix			= '__ELEMENT05__'
			, percent		= '__ELEMENT06__'
			, max_value		= '__ELEMENT07__'
			, min_value		= '__ELEMENT08__'
			, app_flg		= '__ELEMENT09__'
		WHERE
			f_id			= '__ELEMENT01__'
			AND m_f_id		= '__ELEMENT02__'
			AND wallet_type	= '__ELEMENT03__'
	</UPDATE_FEES_DETAIL>

	<!--
		手数料の取得
		条　件：なし
	-->
	<LIST_FEES>
		SELECT DISTINCT
			f_id
			, fee_type_name
			, fee_type
		FROM
			v_fees
	</LIST_FEES>

	<!--
		手数料の取得
		条　件：なし
	-->
	<LIST_FEE_NAMES>
		SELECT
			f_id
			, fee_type_name
			, fee_type
		FROM
			t_fees
		ORDER BY
			fee_type
			, f_id
	</LIST_FEE_NAMES>

	<SELECT_FEE_BY_FID>
		SELECT
			f_id
			, fee_type_name
			, fee_type
		FROM
			t_fees
		WHERE
			f_id = '__ELEMENT01__'
	</SELECT_FEE_BY_FID>

	<SELECT_PATTERN_BY_MFID>
		SELECT DISTINCT
			pattern_name
		FROM
			t_mst_exchange_fee
		WHERE
			m_f_id = '__ELEMENT01__'
	</SELECT_PATTERN_BY_MFID>
	<!--
		手数料の取得（ターゲット別）
		条　件：なし
	-->
	<LIST_FEES_BY_TARGET_TYPE>
		SELECT
			f_id
			, fee_type_name
			, fee_type
		FROM
			t_fees
		WHERE
			fee_type = '__ELEMENT01__'
	</LIST_FEES_BY_TARGET_TYPE>

	<!--
		手数料の取得（ターゲット名別）
		条　件：なし
	-->
	<LIST_FEES_BY_TARGET_TYPE_NAME>
		SELECT
			f_id
			, fee_type_name
			, fee_type
		FROM
			t_fees
		WHERE
			fee_type_name = '__ELEMENT01__'
	</LIST_FEES_BY_TARGET_TYPE_NAME>

	<!--
		手数料の取得（1件取得）
		条　件：なし
	-->
	<SELECT_FEES>
		SELECT DISTINCT
			f_id
			, fee_type_name
			, fee_type
			, m_f_id
			, fee_name
			, wallet_type
			, app_flg
			, fee_flg
			, fix
			, percent
			, min_value
			, max_value
		FROM
			v_fees
		WHERE
			f_id = '__ELEMENT01__'
	</SELECT_FEES>

	<!--
		手数料の削除
		条　件：手数料ID
	-->
	<DELETE_FEES>
		DELETE
		FROM
			t_fees
		WHERE
			f_id = '__ELEMENT01__'
	</DELETE_FEES>

	<!--
		手数料詳細の削除
		条　件：手数料ID
	-->
	<DELETE_FEES_DETAIL>
		DELETE
		FROM
			t_fees_detail
		WHERE
			f_id = '__ELEMENT01__'
	</DELETE_FEES_DETAIL>

	<!--
		入金の取得
		条　件：なし
		
		2019/04/15
		anton
	-->
	<LIST_DEPOSIT>
		SELECT
			deposit.d_id					AS d_id
			, IFNULL(users.user_name, '')	AS user_name
			, users.test_account_flg		AS test_account_flg
			, deposit.user_account			AS user_account
			, deposit.amount				AS amount
			, deposit.currency				AS currency
			, deposit.deposit_date			AS deposit_date
			, deposit.deposit_bank			AS deposit_bank
			, deposit.message				AS message
			, deposit.comment				AS comment
			, deposit.create_time			AS create_time
			, IFNULL(mst_currency.digit, 0)	AS digit
			, deposit.old_filename			AS old_filename
			, deposit.new_filename			AS new_filename
			, deposit.err_flg				AS err_flg
			, deposit.fee					AS fee
			, deposit.transaction_number	AS transaction_number
		FROM
			t_deposit			AS deposit
			INNER JOIN
				v_users_all			AS users
			ON(deposit.user_account = users.user_account)
			LEFT OUTER JOIN
				t_mst_currency	AS mst_currency
			ON(mst_currency.currency_name = deposit.currency)
		WHERE
			mst_currency.c_id > 0
			__ELEMENT01__
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
		ORDER BY
			deposit.create_time DESC
	</LIST_DEPOSIT>

	<!--
		入金の取得（通貨別）
		条　件：なし
		
		2019/04/15
		anton
	-->
	<LIST_DEPOSIT_TOTAL>
		SELECT
			mst_currency.currency_name			AS currency
			, COUNT(deposit.user_account)		AS user_account
			, IFNULL(SUM(deposit.amount), 0)	AS amount
			, mst_currency.digit				AS digit
		FROM
			t_mst_currency AS mst_currency
			LEFT OUTER JOIN
				t_deposit	AS deposit
			ON(mst_currency.currency_name = deposit.currency)
			INNER JOIN
				v_users_all	AS users
			ON(deposit.user_account = users.user_account)
		WHERE
			mst_currency.c_id > 0
			__ELEMENT01__
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
		GROUP BY
			currency
	</LIST_DEPOSIT_TOTAL>

	<!--
		入金の1件取得
		条　件：入金ID
		
		2019/04/15
		anton
	-->
	<SELECT_DEPOSIT>
		SELECT
			deposit.d_id											AS d_id
			, IFNULL(users.user_name, '')							AS user_name
			, deposit.user_account									AS user_account
			, deposit.amount										AS amount
			, deposit.currency										AS currency
			, deposit.deposit_date									AS deposit_date
			, deposit.deposit_bank									AS deposit_bank
			, deposit.message										AS message
			, deposit.comment										AS comment
			, deposit.create_time									AS create_time
			, DATE_FORMAT(deposit.create_time, '%Y/%m/%d %H:%i:%s')	AS create_time_string
			, deposit.method										AS method
			, deposit.fee											AS fee
			, deposit.process_user									AS process_user
			, proc_users.user_name									AS process_user_name
			, deposit.old_filename									AS old_filename
			, deposit.new_filename									AS new_filename
			, deposit.transaction_number 							AS transaction_number
		FROM
			t_deposit			AS deposit
			LEFT OUTER JOIN
				v_users_all			AS users
			ON(deposit.user_account = users.user_account)
			LEFT OUTER JOIN
				v_users_admin	AS proc_users
			ON(deposit.process_user = proc_users.user_account)
		WHERE
			deposit.d_id= '__ELEMENT01__'
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
	</SELECT_DEPOSIT>
	
	<!-- 
		Advertisement Query
	 -->
	<SELECT_DEPOSIT_CDS_FOR_CHECKING>
		SELECT 
			transaction_number,  
			amount, 
			currency,
			deposit_date,
			fee
		FROM
			t_deposit
		WHERE
			user_account = '__ELEMENT01__'
			AND
			deposit_bank = 'Credit Card Deposit'
		LIMIT 5
	</SELECT_DEPOSIT_CDS_FOR_CHECKING>

	<!--
		入金の登録
		登録値：口座番号
				数量
				通貨
				入金日
				入金銀行
				メッセージ
				コメント
	-->
	
	<SELECT_FLAT3_DEPOSIT_TRANSNUM>
		SELECT
			flat3_transaction_id
		FROM
			t_deposit
		WHERE 1
			__ELEMENT01__
	</SELECT_FLAT3_DEPOSIT_TRANSNUM>
	
	<SELECT_ACCOUNT_NUMS>
		SELECT
			user_account
		FROM
			t_user
		WHERE 1
			__ELEMENT01__
	</SELECT_ACCOUNT_NUMS>
	
	<INSERT_DEPOSIT_FLAT3>
		INSERT INTO t_deposit
		(
			transaction_number, 
			user_account, 
			amount, 
			currency, 
			method, 
			deposit_bank, 
			deposit_date, 
			fee, 
			comment, 
			create_time, 
			process_user, 
			type, 
			err_flg, 
			flat3_transaction_id
		)
		VALUES
		(
			'__ELEMENT01__',
			'__ELEMENT02__',
			'__ELEMENT03__',
			'__ELEMENT04__',
			'__ELEMENT05__',
			'__ELEMENT06__',
			'__ELEMENT07__',
			'__ELEMENT08__',
			'__ELEMENT09__',
			'__ELEMENT10__',
			'__ELEMENT11__',
			'__ELEMENT12__',
			'__ELEMENT13__',
			'__ELEMENT14__'
		)
	</INSERT_DEPOSIT_FLAT3>
	
	<INSERT_DEPOSIT>
		INSERT INTO t_deposit (
			user_account
			, amount
			, currency
			, deposit_date
			, deposit_bank
			, message
			, comment
			, process_user
			, old_filename
			, new_filename
			, fee
			, err_flg
			, type
			, transaction_number
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, STR_TO_DATE('__ELEMENT04__', '%Y%m%d')
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
		)
	</INSERT_DEPOSIT>

	<!--
		入金の登録
		更新値：入金タイプ
		条　件：入金ID
	-->
	<UPDATE_DEPOSIT_TYPE>
		UPDATE
			t_deposit
		SET
			type			= '__ELEMENT02__'
			, deposit_date	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			d_id = '__ELEMENT01__'
	</UPDATE_DEPOSIT_TYPE>

	<!--
		入金の保留データの取得
		条　件：保留タイプ
				現在時刻より過去の分
	-->
	<SELECT_DEPOSIT_PENDING>
		SELECT
			d_id
			, user_account
			, amount
			, currency
			, method
			, deposit_date
			, deposit_bank
			, fee
			, message
			, comment
			, create_time
			, process_user
			, old_filename
			, new_filename
			, type
			, err_flg
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') AS cur_time
		FROM
			t_deposit
		WHERE
			type		= '2'
			AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')	> deposit_date
	</SELECT_DEPOSIT_PENDING>


	<!--
		入金コメントの更新
		更新値：コメント
		条　件：入金ID
	-->
	<UPDATE_DEPOSIT_COMMENT>
		UPDATE
			t_deposit
		SET
			comment = '__ELEMENT02__'
		WHERE
			d_id = '__ELEMENT01__'
	</UPDATE_DEPOSIT_COMMENT>

	<!--
		出金の取得
		条　件：なし
		
		2019/04/15
		anton
	-->
	<LIST_WITHDRAW>
		SELECT
			withdraw.w_id													AS w_id
			, users.user_name												AS user_name
			, users.user_account											AS user_account
			, users.mail													AS mail
			, users.tier_tag												AS tier_level
			, users.test_account_flg										AS test_account_flg
			, withdraw.currency												AS currency
			, withdraw.amount												AS amount
			, withdraw.account_name											AS account_name
			, withdraw.receipt_country										AS receipt_country
			, withdraw.receipt_address_1									AS receipt_address_1
			, withdraw.receipt_address_2									AS receipt_address_2
			, withdraw.receipt_message										AS receipt_message
			, withdraw.receipt_bank_name									AS receipt_bank_name
			, withdraw.receipt_branch_code									AS receipt_bank_branch_code
			, withdraw.receipt_branch_name									AS receipt_bank_branch_name
			, withdraw.receipt_bank_swift									AS receipt_bank_swift
			, withdraw.receipt_bank_country									AS receipt_bank_country
			, withdraw.receipt_bank_address_1								AS receipt_bank_address_1
			, withdraw.receipt_bank_address_2								AS receipt_bank_address_2
			, withdraw.account_number										AS account_number
			, withdraw.intermediary_flg										AS intermediary_flg
			, withdraw.intermediary_bank_name								AS intermediary_bank_name
			, withdraw.intermediary_bank_swift								AS intermediary_bank_swift
			, withdraw.intermediary_bank_country							AS intermediary_bank_country
			, withdraw.intermediary_bank_address_1							AS intermediary_bank_address_1
			, withdraw.intermediary_bank_address_2							AS intermediary_bank_address_2
			, withdraw.intermediary_bank_message							AS intermediary_bank_message
			, withdraw.status												AS status
			, withdraw.create_time											AS create_time
			, withdraw.process_user											AS process_user
			, CONCAT(users_admin.last_name, ' ', users_admin.first_name)	AS process_user_name
			, withdraw.process_time											AS process_time
			, DATE_FORMAT(withdraw.process_time, '%Y/%m/%d %H:%i:%s')		AS process_time_string
			, withdraw.create_time											AS create_time
			, withdraw.rate													AS rate
			, withdraw.fee													AS fee
			, withdraw.fee_refund											AS fee_refund
			, withdraw.debit_currency										AS debit_currency
			, withdraw.debit_amount											AS debit_amount
			, withdraw.transaction_number									AS transaction_number
			, withdraw.order_number											AS order_number
			, withdraw.note													AS note
            , withdraw.withdraw_solution                                    AS withdraw_solution
		FROM
			t_withdraw			AS withdraw
			INNER JOIN
				v_users_all	AS users
			ON(withdraw.user_account = users.user_account)
			LEFT OUTER JOIN
				v_users_admin	AS users_admin
			ON(withdraw.process_user = users_admin.user_account)
		WHERE
			true
			__ELEMENT01__
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
		ORDER BY
			withdraw.create_time DESC
	</LIST_WITHDRAW>

	<LIST_WITHDRAW_TOTAL>
		SELECT
			mst_currency.currency_name			AS currency
			, COUNT(withdraw.user_account)		AS user_account
			, IFNULL(SUM(withdraw.amount), 0)	AS amount
			, mst_currency.digit				AS digit
		FROM
			t_mst_currency AS mst_currency
			LEFT OUTER JOIN
				t_withdraw	AS withdraw
			ON(mst_currency.currency_name = withdraw.currency)
			INNER JOIN
				v_users_all	AS users
			ON(withdraw.user_account = users.user_account)
		WHERE
			mst_currency.c_id > 0
			__ELEMENT01__
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
		GROUP BY
			currency
		ORDER BY
			mst_currency.c_id
	</LIST_WITHDRAW_TOTAL>

	<!-- Mark -->
	<LIST_WITHDRAW_REVISED>
		SELECT
			withdraw.w_id 		 								AS w_id,
			users.user_account 									AS user_account,
			users.mail 											AS mail,
			t_login.user_name 									AS user_name,
			users.tier_tag 										AS tier_level,
			users.test_account_flg								AS test_account_flg,
			withdraw.currency 									AS currency,
			withdraw.amount 									AS amount,
			withdraw.account_name 								AS account_name,
			withdraw.receipt_country 							AS receipt_country,
			withdraw.receipt_address_1 							AS receipt_address_1,
			withdraw.receipt_address_2 							AS receipt_address_2,
			withdraw.receipt_message 							AS receipt_message,
			withdraw.receipt_bank_name 							AS receipt_bank_name,
			withdraw.receipt_branch_code 						AS receipt_bank_branch_code,
			withdraw.receipt_branch_name 						AS receipt_bank_branch_name,
			withdraw.receipt_bank_swift 						AS receipt_bank_swift,
			withdraw.receipt_bank_country 						AS receipt_bank_country,
			withdraw.receipt_bank_address_1 					AS receipt_bank_address_1,
			withdraw.receipt_bank_address_2 					AS receipt_bank_address_2,
			withdraw.account_number 							AS account_number,
			withdraw.intermediary_flg 							AS intermediary_flg,
			withdraw.intermediary_bank_name 					AS intermediary_bank_name,
			withdraw.intermediary_bank_swift					AS intermediary_bank_swift,
			withdraw.intermediary_bank_country					AS intermediary_bank_country,
			withdraw.intermediary_bank_address_1 				AS intermediary_bank_address_1,
			withdraw.intermediary_bank_address_2 				AS intermediary_bank_address_2,
			withdraw.intermediary_bank_message 					AS intermediary_bank_message,
			withdraw.status 									AS status,
			withdraw.create_time 								AS create_time,
			withdraw.process_user 								AS process_user,
			users_admin.process_user_name 						AS process_user_name,
			withdraw.process_time 								AS process_time, DATE_FORMAT(withdraw.process_time, '%Y/%m/%d %H:%i:%s') AS process_time_string,
			withdraw.rate 										AS rate,
			withdraw.fee 										AS fee,
			withdraw.fee_refund 								AS fee_refund,
			withdraw.debit_currency 							AS debit_currency,
			withdraw.debit_amount 								AS debit_amount,
			withdraw.transaction_number 						AS transaction_number,
			withdraw.order_number 								AS order_number,
			withdraw.note 										AS note,
			withdraw.withdraw_solution 							AS withdraw_solution
		FROM
			t_withdraw AS withdraw
		LEFT JOIN (
			SELECT
				user_account,
				CONCAT(t_user.last_name, ' ', t_user.first_name) AS process_user_name
			FROM t_user
			WHERE
				t_user.admin_flg = 1
				AND t_user.status = '2'
			) users_admin
			ON users_admin.user_account = withdraw.process_user
		INNER JOIN
			t_user AS users
			ON (
				withdraw.user_account = users.user_account AND users.admin_flg = 0 AND users.del_flg = 0
			)
		INNER JOIN
			t_login
			ON t_login.u_id = users.u_id
		WHERE
			TRUE
			__ELEMENT01__
			AND users.admin_flg = 0
			AND users.status IN (2, 3, 4, 5, 6, 7)
		ORDER BY
			__ELEMENT02__
	</LIST_WITHDRAW_REVISED>

	<!--
		出金の取得
		条　件：出金ID
		
		2019/04/15
		anton
	-->
	<SELECT_WITHDRAW>
		SELECT
			withdraw.w_id							AS w_id
			, users.user_name						AS user_name
			, withdraw.user_account					AS user_account
			, withdraw.currency						AS currency
			, withdraw.amount						AS amount
			, withdraw.account_name					AS account_name
			, withdraw.receipt_country				AS receipt_country
			, withdraw.receipt_address_1			AS receipt_address_1
			, withdraw.receipt_address_2			AS receipt_address_2
			, withdraw.receipt_message				AS receipt_message
			, withdraw.receipt_bank_name			AS receipt_bank_name
			, withdraw.receipt_branch_code			AS receipt_bank_branch_code
			, withdraw.receipt_branch_name			AS receipt_bank_branch_name
			, withdraw.receipt_bank_swift			AS receipt_bank_swift
			, withdraw.receipt_bank_country			AS receipt_bank_country
			, withdraw.receipt_bank_address_1		AS receipt_bank_address_1
			, withdraw.receipt_bank_address_2		AS receipt_bank_address_2
			, withdraw.account_number				AS account_number
			, withdraw.intermediary_flg				AS intermediary_flg
			, withdraw.intermediary_bank_name		AS intermediary_bank_name
			, withdraw.intermediary_bank_swift		AS intermediary_bank_swift
			, withdraw.intermediary_bank_country	AS intermediary_bank_country
			, withdraw.intermediary_bank_address_1	AS intermediary_bank_address_1
			, withdraw.intermediary_bank_address_2	AS intermediary_bank_address_2
			, withdraw.intermediary_bank_message	AS intermediary_bank_message
			, withdraw.status						AS status
			, withdraw.debit_currency				AS debit_currency
			, withdraw.debit_amount					AS debit_amount
			, withdraw.rate							AS rate
			, withdraw.fee							AS fee
			, withdraw.fee_refund					AS fee_refund
			, withdraw.order_number					AS order_number
			, withdraw.note							AS note
			, withdraw.create_time					AS create_time
			, withdraw.withdraw_solution		    AS withdraw_solution
			, withdraw.transaction_number 			AS transaction_number
		FROM
			t_withdraw	AS withdraw
			LEFT OUTER JOIN
				v_users_all	AS users
			ON(withdraw.user_account = users.user_account)
		WHERE
			w_id = '__ELEMENT01__'
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
	</SELECT_WITHDRAW>

	<LIST_FLAT3_PENDING_WITHDRAWALS>
		SELECT
			withdraw.w_id							AS w_id
			, users.user_name						AS user_name
			, withdraw.user_account					AS user_account
			, withdraw.currency						AS currency
			, withdraw.amount						AS amount
			, withdraw.account_name					AS account_name
			, withdraw.receipt_country				AS receipt_country
			, withdraw.receipt_address_1			AS receipt_address_1
			, withdraw.receipt_address_2			AS receipt_address_2
			, withdraw.receipt_message				AS receipt_message
			, withdraw.receipt_bank_name			AS receipt_bank_name
			, withdraw.receipt_branch_code			AS receipt_bank_branch_code
			, withdraw.receipt_branch_name			AS receipt_bank_branch_name
			, withdraw.receipt_bank_swift			AS receipt_bank_swift
			, withdraw.receipt_bank_country			AS receipt_bank_country
			, withdraw.receipt_bank_address_1		AS receipt_bank_address_1
			, withdraw.receipt_bank_address_2		AS receipt_bank_address_2
			, withdraw.account_number				AS account_number
			, withdraw.intermediary_flg				AS intermediary_flg
			, withdraw.intermediary_bank_name		AS intermediary_bank_name
			, withdraw.intermediary_bank_swift		AS intermediary_bank_swift
			, withdraw.intermediary_bank_country	AS intermediary_bank_country
			, withdraw.intermediary_bank_address_1	AS intermediary_bank_address_1
			, withdraw.intermediary_bank_address_2	AS intermediary_bank_address_2
			, withdraw.intermediary_bank_message	AS intermediary_bank_message
			, withdraw.status						AS STATUS
			, withdraw.debit_currency				AS debit_currency
			, withdraw.debit_amount					AS debit_amount
			, withdraw.rate							AS rate
			, withdraw.fee							AS fee
			, withdraw.fee_refund					AS fee_refund
			, withdraw.order_number					AS order_number
			, withdraw.note							AS note
			, withdraw.create_time					AS create_time
			, withdraw.withdraw_solution		    AS withdraw_solution
			, withdraw.transaction_number 			AS transaction_number
			, withdraw.status						AS status
		FROM
			t_withdraw	AS withdraw
			LEFT OUTER JOIN
				v_users_all	AS users
			ON(withdraw.user_account = users.user_account)
		WHERE
			withdraw.user_account = '__ELEMENT01__'
			AND withdraw.status IN (0,1,3)
			AND withdraw.withdraw_solution = 'Flat3'
	</LIST_FLAT3_PENDING_WITHDRAWALS>

	<!--
		出金の取得
		条　件：出金ID
	-->
	<SELECT_WITHDRAW_MAIL_ACCOUNT>
		SELECT
		    users.mail                             AS mail
		    ,withdraw.user_account                 AS user_account
		    ,withdraw.draw_currency                AS draw_currency
		    ,CONCAT(first_name,' ',last_name)      AS account_name
		    ,receipt_country                       AS receipt_country
		FROM
		    t_withdraw                             AS withdraw
        LEFT OUTER JOIN
            t_user                                 AS users
        ON
            (withdraw.user_account = users.user_account)
        WHERE
            transaction_number = '__ELEMENT01__';
	</SELECT_WITHDRAW_MAIL_ACCOUNT>

	<!--
		5分钟检测一次返回金额
	-->
	<SELECT_WITHDRAW_FIVE_MINITUS>
		SELECT
			transaction_number
		FROM
			t_withdraw_timer
		WHERE
			isDelete = '0'
		AND
			(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') - creat_time)>10800;
	</SELECT_WITHDRAW_FIVE_MINITUS>
	<!--
		出金の取得
		条　件：
	-->
	<SELECT_WITHDRAW_LOCAL_MAIL_ACCOUNT>
		SELECT
		    users.mail                             AS mail
		    ,withdraw.user_account                 AS user_account
		    ,withdraw.draw_currency                AS draw_currency
		    ,CONCAT(first_name,' ',last_name)      AS account_name
		    ,receipt_country                       AS receipt_country
		    ,users.use_langage                     AS lang
		FROM
		    t_withdraw                             AS withdraw
        LEFT OUTER JOIN
            t_user                                 AS users
        ON
            (withdraw.user_account = users.user_account)
        WHERE
            withdraw.transaction_number = '__ELEMENT01__';
	</SELECT_WITHDRAW_LOCAL_MAIL_ACCOUNT>
	<!--
		手动修改出金
		条　件：
	-->
	<SELECT_WITHDRAW_LOCAL_MAIL_MANUAL>
		SELECT
		    users.mail                             AS mail
		    ,withdraw.user_account                 AS user_account
		    ,withdraw.draw_currency                AS draw_currency
		    ,CONCAT(first_name,' ',last_name)      AS account_name
		    ,receipt_country                       AS receipt_country
		    ,withtimer.lang                        AS lang
		FROM
		    t_withdraw                             AS withdraw
        LEFT OUTER JOIN
            t_user                                 AS users
        ON
            (withdraw.user_account = users.user_account)
        LEFT OUTER JOIN
        	t_withdraw_timer                       AS withtimer
        ON
        	(withtimer.transaction_number = withdraw.transaction_number)
        WHERE
            withdraw.w_id = '__ELEMENT01__';
	</SELECT_WITHDRAW_LOCAL_MAIL_MANUAL>

	<SELECT_WITHDRAW_LOCAL_RETRUN>
		SELECT
			*
		FROM
			t_withdraw_timer
		WHERE
			transaction_number = '__ELEMENT01__'
		AND
			isDelete = '0';
	</SELECT_WITHDRAW_LOCAL_RETRUN>
	<!--
		出金の登録
		登録値：金額
				口座名義
				受取人国
				受取人住所1
				受取人住所2
				受取人メッセージ
				受取銀行名
				受取銀行SWIFT
				受取銀行国
				受取銀行住所1
				受取銀行住所2
				受取銀行口座番号
				中継銀行フラグ
				中継銀行名
				中継銀行SWIFT
				中継銀行国
				中継銀行住所1
				中継銀行住所2
				中継銀行メッセージ
	-->
	<INSERT_WITHDRAW>
		INSERT INTO t_withdraw (
			user_account
			, draw_currency
			, amount
			, currency
			, account_name
			, receipt_country
			, receipt_address_1
			, receipt_address_2
			, receipt_message
			, receipt_bank_name
			, receipt_branch_name
			, receipt_bank_swift
			, receipt_bank_country
			, receipt_bank_address_1
			, receipt_bank_address_2
			, account_number
			, intermediary_flg
			, intermediary_bank_name
			, intermediary_bank_swift
			, intermediary_bank_country
			, intermediary_bank_address_1
			, intermediary_bank_address_2
			, intermediary_bank_message
			, tel
			, debit_currency
			, debit_amount
			, rate
			, fee
			, draw_fee_currency
			, draw_fee
			, transaction_number
			, receipt_branch_code
			, withdraw_solution
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
			, '__ELEMENT16__'
			, '__ELEMENT17__'
			, '__ELEMENT18__'
			, '__ELEMENT19__'
			, '__ELEMENT20__'
			, '__ELEMENT21__'
			, '__ELEMENT22__'
			, '__ELEMENT23__'
			, '__ELEMENT24__'
			, '__ELEMENT25__'
			, '__ELEMENT26__'
			, '__ELEMENT27__'
			, '__ELEMENT28__'
			, '__ELEMENT29__'
			, '__ELEMENT30__'
			, '__ELEMENT31__'
			, '__ELEMENT32__'
			, '__ELEMENT33__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_WITHDRAW>
	<!--
		出金の登録
		登録値：金額
				口座名義
				受取人国
				受取人住所1
				受取人住所2
				受取人メッセージ
				受取銀行名
				受取銀行SWIFT
				受取銀行国
				受取銀行住所1
				受取銀行住所2
				受取銀行口座番号
				中継銀行フラグ
				中継銀行名
				中継銀行SWIFT
				中継銀行国
				中継銀行住所1
				中継銀行住所2
				中継銀行メッセージ
	-->
	<INSERT_WITHDRAW_LOCAL>
		INSERT INTO t_withdraw (
			user_account
			, draw_currency
			, amount
			, currency
			, account_name
			, receipt_country
			, receipt_address_1
			, receipt_address_2
			, receipt_message
			, receipt_bank_name
			, receipt_branch_name
			, receipt_bank_swift
			, receipt_bank_country
			, receipt_bank_address_1
			, receipt_bank_address_2
			, account_number
			, intermediary_flg
			, intermediary_bank_name
			, intermediary_bank_swift
			, intermediary_bank_country
			, intermediary_bank_address_1
			, intermediary_bank_address_2
			, intermediary_bank_message
			, tel
			, debit_currency
			, debit_amount
			, rate
			, fee
			, transaction_number
			, receipt_branch_code
			, withdraw_solution
			, create_time
			, status
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
			, '__ELEMENT16__'
			, '__ELEMENT17__'
			, '__ELEMENT18__'
			, '__ELEMENT19__'
			, '__ELEMENT20__'
			, '__ELEMENT21__'
			, '__ELEMENT22__'
			, '__ELEMENT23__'
			, '__ELEMENT24__'
			, '__ELEMENT25__'
			, '__ELEMENT26__'
			, '__ELEMENT27__'
			, '__ELEMENT28__'
			, '__ELEMENT29__'
			, '__ELEMENT30__'
			, '__ELEMENT31__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT32__'
		)
	</INSERT_WITHDRAW_LOCAL>
	<INSERT_WITHDRAW_H2P_TEMP>
		INSERT INTO t_withdraw_h2p_temporary (
			user_account
			, draw_currency
			, amount
			, currency
			, account_name
			, receipt_country
			, receipt_address_1
			, receipt_address_2
			, receipt_message
			, receipt_bank_name
			, receipt_branch_name
			, receipt_bank_swift
			, receipt_bank_country
			, receipt_bank_address_1
			, receipt_bank_address_2
			, account_number
			, intermediary_flg
			, intermediary_bank_name
			, intermediary_bank_swift
			, intermediary_bank_country
			, intermediary_bank_address_1
			, intermediary_bank_address_2
			, intermediary_bank_message
			, tel
			, debit_currency
			, debit_amount
			, rate
			, fee
			, transaction_number
			, receipt_branch_code
			, withdraw_solution
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
			, '__ELEMENT16__'
			, '__ELEMENT17__'
			, '__ELEMENT18__'
			, '__ELEMENT19__'
			, '__ELEMENT20__'
			, '__ELEMENT21__'
			, '__ELEMENT22__'
			, '__ELEMENT23__'
			, '__ELEMENT24__'
			, '__ELEMENT25__'
			, '__ELEMENT26__'
			, '__ELEMENT27__'
			, '__ELEMENT28__'
			, '__ELEMENT29__'
			, '__ELEMENT30__'
			, '__ELEMENT31__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_WITHDRAW_H2P_TEMP>


	<!--
		出金の登録
		登録値：金額
				口座名義
				受取人国
				受取人住所1
				受取人住所2
				受取人メッセージ
				受取銀行名
				受取銀行SWIFT
				受取銀行国
				受取銀行住所1
				受取銀行住所2
				受取銀行口座番号
				中継銀行フラグ
				中継銀行名
				中継銀行SWIFT
				中継銀行国
				中継銀行住所1
				中継銀行住所2
				中継銀行メッセージ
				結果コード
				結果データ
	-->
	<INSERT_WITHDRAW_CARD>
		INSERT INTO t_withdraw (
			user_account
			, draw_currency
			, amount
			, currency
			, account_number
			, account_name
			, debit_currency
			, debit_amount
			, rate
			, fee
			, transaction_number
			, status
			, type
			, receipt_bank_name
			, order_number
			, note
			, create_time
			, process_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
			, '__ELEMENT16__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_WITHDRAW_CARD>

	<UPDATE_FAIL_WITHDRAW_CARD>
		UPDATE
			t_withdraw
		SET
			note				= 'pending'
			, status			= 5
			, process_time		= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			transaction_number	= '__ELEMENT01__'
	</UPDATE_FAIL_WITHDRAW_CARD>

	<UPDATE_SUCCESS_WITHDRAW_CARD>
		UPDATE
			t_withdraw
		SET
			note				= 'success'
			, status			= 2
			, process_time		= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			transaction_number	= '__ELEMENT01__'
	</UPDATE_SUCCESS_WITHDRAW_CARD>

	<!--
		出金の更新
		更新値：ステータス
		条　件：出金ID
	-->
	<UPDATE_WITHDRAW_STATUS>
		UPDATE
			t_withdraw
		SET
			status			= '__ELEMENT02__'
			, process_user	= '__ELEMENT03__'
			, fee_refund	= '__ELEMENT04__'
			, process_time	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			w_id	= '__ELEMENT01__'
	</UPDATE_WITHDRAW_STATUS>
	<!--
		local 出金の更新
		更新値：ステータス
		条　件：出金ID
	-->
	<UPDATE_WITHDRAW_LOCAL_STATUS>
		UPDATE
			t_withdraw
		SET
			status			= '__ELEMENT02__'
			, note = CONCAT(note,'__ELEMENT03__')
			, process_time	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			transaction_number	= '__ELEMENT01__'
		AND
			order_number = '__ELEMENT04__'
	</UPDATE_WITHDRAW_LOCAL_STATUS>
	<!--
		local 出金の更新
		更新値：ステータス
		条　件：出金ID
	-->
	<UPDATE_WITHDRAW_LOCAL_LOSE>
		UPDATE
			t_withdraw
		SET
			note = CONCAT(note,'__ELEMENT03__')
		WHERE
			transaction_number	= '__ELEMENT01__'
		AND
			order_number = '__ELEMENT04__'
	</UPDATE_WITHDRAW_LOCAL_LOSE>
	<!--
		临时判断表更新
		更新値：ステータス
		条　件：出金ID
	-->
	<UPDATE_WITHDRAW_LOCAL_STATUS_RETURN>
		UPDATE
			t_withdraw_timer
		SET
			isDelete			= '1'
		WHERE
			transaction_number	= '__ELEMENT01__';
	</UPDATE_WITHDRAW_LOCAL_STATUS_RETURN>
	<!--
		临时判断表更新
		更新値：ステータス
		条　件：出金ID
	-->
	<UPDATE_WITHDRAW_LOCAL_STATUS_UNRETURN>
		UPDATE
			t_withdraw
		SET
			status = '3'
		WHERE
			transaction_number = '__ELEMENT01__'
	</UPDATE_WITHDRAW_LOCAL_STATUS_UNRETURN>
	<!--
		出金の更新
		更新値：注文番号
				備考
		条　件：出金ID
	-->
	<UPDATE_WITHDRAW_ORDER_NOTE>
		UPDATE
			t_withdraw
		SET
			order_number	= '__ELEMENT02__'
			, note			= '__ELEMENT03__'
		WHERE
			w_id	= '__ELEMENT01__'
	</UPDATE_WITHDRAW_ORDER_NOTE>
	<!--
		出金の更新
		更新値：注文番号
				備考
		条　件：出金ID
	-->
	<UPDATE_WITHDRAW_RETURN_NOCE>
		UPDATE
			t_withdraw
		SET
			order_number	= '__ELEMENT02__'
			, note			= '__ELEMENT03__'
			, status        = '__ELEMENT04__'
		WHERE
			transaction_number	= '__ELEMENT01__'
	</UPDATE_WITHDRAW_RETURN_NOCE>

	<!--
		口座振替の取得
		登録値：送金元口座番号
				送金先口座番号
				金額
				メッセージ
	-->
	<LIST_TRANSFER>
		SELECT
			transfer.t_id						AS t_id
			, transfer.transaction_number		AS transaction_number
			, transfer.from_account				AS from_account
			, IFNULL(from_user.user_name, '')	AS from_user_name
			, transfer.from_fee					AS from_fee
			, transfer.to_account				AS to_account
			, IFNULL(to_user.user_name, '')		AS to_user_name
			, transfer.transaction_number		AS transaction_number
			, transfer.to_fee					AS to_fee
			, transfer.amount					AS amount
			, transfer.message					AS message
			, transfer.create_time				AS create_time
			, transfer.from_currency			AS from_currency
			, transfer.to_currency				AS to_currency
			, transfer.debit_amount				AS debit_amount
			, transfer.debit_currency			AS debit_currency
			, transfer.transfer_currency		AS transfer_currency
			, transfer.transfer_amount			AS transfer_amount
			, transfer.rate						AS rate
			, transfer.process_type				AS process_type
			, transfer.process_status			AS process_status
			, transfer.admin_id					AS admin_id
			, transfer.old_filename				AS old_filename
			, transfer.new_filename				AS new_filename
			, transfer.err_flg					AS err_flg
		FROM
			t_transfer		AS transfer
			INNER JOIN
				v_users_active		AS from_user
			ON(transfer.from_account = from_user.user_account)
			INNER JOIN
				v_users_active		AS to_user
			ON(transfer.to_account = to_user.user_account)
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			transfer.create_time DESC
	</LIST_TRANSFER>

	<LIST_TRANSFER_TOTAL_FROM_TO>
		(SELECT
				mst_currency.currency_name				AS currency
				, COUNT(transfer.from_account)			AS from_account
				, IFNULL(SUM(transfer.debit_amount), 0)	AS from_amount
				, COUNT(transfer.to_account)			AS to_account
				, IFNULL(SUM(transfer.transfer_amount), 0)	AS to_amount
				, mst_currency.digit					AS digit
			FROM
				t_mst_currency AS mst_currency
				LEFT OUTER JOIN
					t_transfer	AS transfer
				ON(mst_currency.currency_name = transfer.debit_currency)
				INNER JOIN
					v_users_all	AS users
				ON(transfer.from_account = users.user_account)
			WHERE
				mst_currency.c_id > 0
				__ELEMENT01__
				AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
			GROUP BY
				currency)
	</LIST_TRANSFER_TOTAL_FROM_TO>

	<!--
		口座振替の取得
		登録値：送金元口座番号
				送金先口座番号
				金額
				メッセージ
	-->
	<LIST_TRANSFER_SIMPLE>
		SELECT
			transfer.t_id						AS t_id
			, transfer.transaction_number		AS transaction_number
			, transfer.from_account				AS from_account
			, transfer.from_fee					AS from_fee
			, transfer.to_account				AS to_account
			, transfer.transaction_number		AS transaction_number
			, transfer.to_fee					AS to_fee
			, transfer.amount					AS amount
			, transfer.message					AS message
			, transfer.create_time				AS create_time
			, transfer.from_currency			AS from_currency
			, transfer.to_currency				AS to_currency
			, transfer.debit_amount				AS debit_amount
			, transfer.debit_currency			AS debit_currency
			, transfer.transfer_currency		AS transfer_currency
			, transfer.transfer_amount			AS transfer_amount
			, transfer.rate						AS rate
			, transfer.process_type				AS process_type
			, transfer.process_status			AS process_status
			, transfer.admin_id					AS admin_id
			, transfer.old_filename				AS old_filename
			, transfer.new_filename				AS new_filename
			, transfer.err_flg					AS err_flg
		FROM
			t_transfer		AS transfer
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			transfer.create_time DESC
	</LIST_TRANSFER_SIMPLE>

	<!--
		口座振替の取得
		登録値：送金元口座番号
				送金先口座番号
				金額
				メッセージ
				
		2019/04/15
		anton		
	-->
	<LIST_TRANSFER_JOIN_USER>
		SELECT
			users.user_account			AS user_account
			, users.user_name			AS user_name
			, users.last_name			AS last_name
			, users.first_name			AS first_name
			, users.test_account_flg	AS test_account_flg
		FROM
			v_users_all		AS users
		WHERE
			user_account IN (__ELEMENT01__)
			__ELEMENT02__
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
	</LIST_TRANSFER_JOIN_USER>

	<!--
		口座振替の取得
		条件：トランザクションID
		
		2019/04/15
		anton
	-->

	<LIST_TRANSFER_TOTAL>
		SELECT
			mst_currency.currency_name			AS currency
			, COUNT((CASE WHEN (transfer.debit_currency = mst_currency.currency_name) THEN transfer.from_account ELSE NULL END))		AS from_account
			, (IFNULL(SUM((CASE WHEN (transfer.debit_currency = mst_currency.currency_name) THEN transfer.debit_amount ELSE 0 END)), 0))	AS from_amount
			, COUNT((CASE WHEN (transfer.transfer_currency = mst_currency.currency_name) THEN transfer.to_account ELSE NULL END))		AS to_account
			, (IFNULL(SUM((CASE WHEN (transfer.transfer_currency = mst_currency.currency_name) THEN transfer.transfer_amount ELSE 0 END)), 0))	AS to_amount
			, mst_currency.digit				AS digit
		FROM
			t_mst_currency AS mst_currency
			LEFT OUTER JOIN
				t_transfer	AS transfer
			ON(mst_currency.currency_name = transfer.debit_currency
				OR mst_currency.currency_name = transfer.transfer_currency)
			INNER JOIN
				v_users_all	AS from_user
			ON(transfer.from_account = from_user.user_account)
			INNER JOIN
				v_users_all	AS to_user
			ON(transfer.to_account = to_user.user_account)
        WHERE
        	mst_currency.c_id > 0
			__ELEMENT01__
			AND from_user.admin_flg = 0
			AND from_user.status in (2,3,4,5,6,7)
			AND to_user.admin_flg = 0
			AND to_user.status in (2,3,4,5,6,7)
		GROUP BY
			currency
	</LIST_TRANSFER_TOTAL>

	<LIST_TRANSFER_TOTAL_FROM>
		(SELECT
				mst_currency.currency_name				AS currency
				, COUNT(transfer.from_account)			AS from_account
				, IFNULL(SUM(transfer.debit_amount), 0)	AS from_amount
				, mst_currency.digit					AS digit
			FROM
				t_mst_currency AS mst_currency
				LEFT OUTER JOIN
					t_transfer	AS transfer
				ON(mst_currency.currency_name = transfer.debit_currency)
				INNER JOIN
					v_users_all	AS users
				ON(transfer.from_account = users.user_account)
			WHERE
				mst_currency.c_id > 0
				__ELEMENT01__
				AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
			GROUP BY
				currency)
	</LIST_TRANSFER_TOTAL_FROM>

	<LIST_TRANSFER_TOTAL_TO>
		(SELECT
			mst_currency.currency_name				AS currency
			, COUNT(transfer.to_account)			AS to_account
			, IFNULL(SUM(transfer.transfer_amount), 0)	AS to_amount
			, mst_currency.digit					AS digit
		FROM
			t_mst_currency AS mst_currency
			LEFT OUTER JOIN
				t_transfer	AS transfer
			ON(mst_currency.currency_name = transfer.transfer_currency)
			INNER JOIN
				v_users_all	AS users
			ON(transfer.to_account = users.user_account)
		WHERE
			mst_currency.c_id > 0
			__ELEMENT01__
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
		GROUP BY
			currency)
	</LIST_TRANSFER_TOTAL_TO>

	<SELECT_TRANSFER>
		SELECT
			transfer.t_id						AS t_id
			, transfer.from_account				AS from_account
			, from_user.account_type			AS from_account_type
			, IFNULL(from_user.user_name, '')	AS from_user_name
			, transfer.to_account				AS to_account
			, to_user.account_type				AS to_account_type
			, IFNULL(to_user.user_name, '')		AS to_user_name
			, transfer.amount					AS amount
			, transfer.message					AS message
			, transfer.create_time				AS create_time
			, transfer.from_currency			AS from_currency
			, transfer.to_currency				AS to_currency
			, transfer.debit_amount				AS debit_amount
			, transfer.debit_currency			AS debit_currency
			, transfer.transfer_amount			AS transfer_amount
			, transfer.transfer_currency		AS transfer_currency
			, transfer.process_type				AS process_type
			, transfer.admin_id					AS admin_id
			, transfer.rate						AS rate
			, transfer.new_filename				AS new_filename
			, transfer.old_filename				AS old_filename
            , transfer.note						AS note
            , transfer.transaction_number 		AS transaction_number
		FROM
			t_transfer		AS transfer
			LEFT OUTER JOIN
				v_users_all		AS from_user
			ON(transfer.from_account = from_user.user_account)
			LEFT OUTER JOIN
				v_users_all		AS to_user
			ON(transfer.to_account = to_user.user_account)
		WHERE
			t_id = __ELEMENT01__
			AND (from_user.admin_flg = 0 AND from_user.status in (2,3,4,5,6,7))
			AND (to_user.admin_flg = 0 AND to_user.status in (2,3,4,5,6,7))
	</SELECT_TRANSFER>

	<!--
		口座振替の登録
		登録値：送金元口座番号
				送金先口座番号
				金額
				メッセージ
	-->
	<INSERT_TRANSFER>
		INSERT INTO t_transfer (
			user_account
			, from_account
			, from_currency
			, from_fee
			, to_account
			, to_currency
			, to_fee
			, amount
			, transfer_type
			, message
			, debit_currency
			, debit_amount
			, transfer_currency
			, transfer_amount
			, rate
			, process_type
			, admin_id
			, process_status
			, transaction_number
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
			, '__ELEMENT16__'
			, '__ELEMENT17__'
			, '__ELEMENT18__'
			, '__ELEMENT19__'
			, '__ELEMENT20__'
		)
	</INSERT_TRANSFER>

    <!--
		口座振替の登録
		登録値：送金元口座番号
				送金先口座番号
				金額
				メッセージ
	-->
	<INSERT_TRANSFER_API>
		INSERT INTO t_transfer (
			user_account
			, from_account
			, from_currency
			, from_fee
			, to_account
			, to_currency
			, to_fee
			, amount
			, transfer_type
			, message
			, debit_currency
			, debit_amount
			, transfer_currency
			, transfer_amount
			, rate
			, process_type
			, admin_id
			, process_status
			, transaction_number
			, create_time
			, note
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
			, '__ELEMENT16__'
			, '__ELEMENT17__'
			, '__ELEMENT18__'
			, '__ELEMENT19__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT20__'
		)
	</INSERT_TRANSFER_API>


	<!--
		口座振替の登録（CSV）
		登録値：送金元口座番号
				送金先口座番号
				金額
				メッセージ
	-->
	<INSERT_TRANSFER_CSV>
		INSERT INTO t_transfer_batch_detail (
			user_account
			, from_account
			, from_currency
			, from_fee
			, to_account
			, to_currency
			, to_fee
			, amount
			, transfer_type
			, message
			, debit_currency
			, debit_amount
			, transfer_currency
			, transfer_amount
			, rate
			, process_type
			, admin_id
			, process_status
			, create_time
			, transaction_number
			, new_filename
			, old_filename
			, err_flg
			, transaction_id
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
			, '__ELEMENT13__'
			, '__ELEMENT14__'
			, '__ELEMENT15__'
			, '__ELEMENT16__'
			, '__ELEMENT17__'
			, '__ELEMENT18__'
			, '__ELEMENT19__'
			, '__ELEMENT20__'
			, '__ELEMENT21__'
			, '__ELEMENT22__'
			, '__ELEMENT23__'
			, '__ELEMENT24__'
		)
	</INSERT_TRANSFER_CSV>
	
	<INSERT_SETTLEMENT_FORM>
		INSERT INTO t_settlement_forms 
		(
			form_name,
			form_owner,
			form_data,
			create_time
		)
		VALUES
		(
			'__ELEMENT01__',
			'__ELEMENT02__',
			'__ELEMENT03__',
			CONVERT_TZ(NOW(), @@session.time_zone, "+09:00")
		)
	</INSERT_SETTLEMENT_FORM>

	<SELECT_SETTLEMENT_FORM>
		SELECT * FROM
			t_settlement_forms
		WHERE
			form_name = '__ELEMENT01__'
	</SELECT_SETTLEMENT_FORM>
	
	<UPDATE_SETTLEMENT_FORM>
		UPDATE t_settlement_forms
		SET
			is_paid = 1
		WHERE
			form_name = '__ELEMENT01__'
	</UPDATE_SETTLEMENT_FORM>
	
	<DELETE_SETTLEMENT_FORM>
		DELETE FROM 
			t_settlement_forms
		WHERE
			form_name = '__ELEMENT01__'
	</DELETE_SETTLEMENT_FORM>

	<!--
		処理履歴の件数取得
		条　件：なし
	-->
	<COUNT_TRANSACTION>
		SELECT
			COUNT(trans.transaction_number)	AS counter
		FROM (
				SELECT						/* 入金 */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '1'					AS transaction_type
					, ''					AS withdraw_account_name
					, ''					AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, ''					AS withdraw_amount
					, ''					AS withdraw_fee
					, amount				AS deposit_amount
					, fee					AS deposit_fee
					, ''					AS rate
					, currency				AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, type					AS type
					, 0						AS status
					, 0						AS process_status
				FROM
					t_deposit
				WHERE
					type != 1
				UNION ALL
				SELECT						/* 出金（処理中・成功） */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '2'					AS transaction_type
					, account_name			AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, ''					AS deposit_account_number
					, amount				AS withdraw_amount
					, fee					AS withdraw_fee
					, ''					AS deposit_amount
					, ''					AS deposit_fee
					, rate					AS rate
					, ''					AS deposit_currency
					, currency				AS withdraw_currency
					, debit_currency		AS debit_currency
					, debit_amount			AS debit_amount
					, type					AS type
					, status				AS status
					, 0						AS process_status
				FROM
					t_withdraw
				WHERE
					status			&lt;= '3'
					AND (type		= '0'
							OR type	= '3'
							OR type = '1')
				UNION ALL
				SELECT						/* 口座振替 */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '3'					AS transaction_type
					, ''					AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, to_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, from_fee				AS withdraw_fee
					, transfer_amount		AS deposit_amount
					, to_fee				AS deposit_fee
					, ''					AS rate
					, to_currency			AS deposit_currency
					, debit_currency		AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, 0						AS status
					, process_status		AS process_status
				FROM
					t_transfer
				UNION ALL
				SELECT						/* 通貨両替 */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '4'					AS transaction_type
					, ''					AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, 0						AS withdraw_fee
					, amount				AS deposit_amount
					, 0						AS deposit_fee
					, rate					AS rate
					, currency				AS deposit_currency
					, debit_currency		AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, 0						AS status
					, 0						AS process_status
				FROM
					t_exchange
				UNION ALL
				SELECT						/* 引き落とし */
					update_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '5'					AS transaction_type
					, ''					AS withdraw_account_name
					, from_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, to_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, from_fee				AS withdraw_fee
					, amount				AS deposit_amount
					, to_fee				AS deposit_fee
					, ''					AS rate
					, currency				AS deposit_currency
					, debit_currency		AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, 0						AS status
					, 0						AS process_status
				FROM
					t_request
				UNION ALL
				SELECT						/* 出金（組戻し） */
					process_time			AS transaction_time
					, transaction_number	AS transaction_number
					, '7'					AS transaction_type
					, ''					AS withdraw_account_name
					, ''					AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, ''					AS withdraw_amount
					, ''					AS withdraw_fee
					, debit_amount			AS deposit_amount
					, (fee + fee_refund)	AS deposit_fee
					, ''					AS rate
					, debit_currency		AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, status				AS status
					, 0						AS process_status
				FROM
					t_withdraw
				WHERE
					status = '4'
				UNION ALL
				SELECT						/* 出金（キャンセル） */
					process_time			AS transaction_time
					, transaction_number	AS transaction_number
					, '8'					AS transaction_type
					, ''					AS withdraw_account_name
					, ''					AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, ''					AS withdraw_fee
					, debit_amount			AS deposit_amount
					, (fee)					AS deposit_fee
					, ''					AS rate
					, debit_currency		AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, status				AS status
					, 0						AS process_status
				FROM
					t_withdraw
				WHERE
					status = '6'
				UNION ALL
				SELECT						/* 账户休止金 */
					process_time			AS transaction_time
					, transaction_number	AS transaction_number
					, '11'					AS transaction_type
					, ''					AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, ''					AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, (fee)					AS withdraw_fee
					, debit_amount			AS deposit_amount
					, ''					AS deposit_fee
					, ''					AS rate
					, debit_currency		AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, status				AS status
					, 0						AS process_status
				FROM
					t_withdraw
				WHERE
					status				= '2'
					<!--AND user_account	= '__ELEMENT01__'-->
					AND type 			= '11'
			)			AS trans
			LEFT OUTER JOIN
				t_user	AS deposit_users
			ON(trans.deposit_account_number = deposit_users.user_account)
			LEFT OUTER JOIN
				t_user	AS withdraw_users
			ON(trans.withdraw_account_number = withdraw_users.user_account)
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			transaction_time DESC
	</COUNT_TRANSACTION>

	<LIST_TRANSACTION>
		SELECT
				trans.transaction_time												AS transaction_time
				, trans.transaction_number											AS transaction_number
				, trans.transaction_type											AS transaction_type
				, CONCAT(withdraw_users.last_name, ' ', withdraw_users.first_name)	AS withdraw_account_name
				, withdraw_users.test_account_flg									AS withdraw_test_account_flg
				, trans.withdraw_account_number										AS withdraw_account_number
				, CONCAT(deposit_users.last_name, ' ', deposit_users.first_name)	AS deposit_account_name
				, deposit_users.test_account_flg									AS deposit_test_account_flg
				, trans.deposit_account_number										AS deposit_account_number
				, trans.withdraw_currency											AS withdraw_currency
				, trans.withdraw_amount												AS withdraw_amount
				, trans.withdraw_fee												AS withdraw_fee
				, trans.deposit_currency											AS deposit_currency
				, trans.deposit_amount												AS deposit_amount
				, trans.deposit_fee													AS deposit_fee
				, trans.rate														AS rate
				, trans.draw_fee													AS draw_fee
				, trans.draw_fee_currency											AS draw_fee_currency
				, trans.debit_currency												AS debit_currency
				, trans.debit_amount												AS debit_amount
				, trans.type														AS type
				, trans.status														AS status
				, process_status													AS process_status
				, trans.transaction_id 												AS transaction_id
		FROM (
				SELECT						/* 入金 */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '1'					AS transaction_type
					, ''					AS withdraw_account_name
					, ''					AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, ''					AS withdraw_amount
					, ''					AS withdraw_fee
					, amount				AS deposit_amount
					, fee					AS deposit_fee
					, 0						AS draw_fee
					, ''					AS draw_fee_currency
					, ''					AS rate
					, currency				AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, type					AS type
					, 0						AS status
					, 0						AS process_status
					, d_id 					AS transaction_id
				FROM
					t_deposit
				WHERE
					type != 1
				UNION ALL
				SELECT						/* 出金（処理中・成功） */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '2'					AS transaction_type
					, account_name			AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, ''					AS deposit_account_number
					, amount				AS withdraw_amount
					, fee					AS withdraw_fee
					, ''					AS deposit_amount
					, ''					AS deposit_fee
					, draw_fee				AS draw_fee
					, draw_fee_currency		AS draw_fee_currency
					, rate					AS rate
					, ''					AS deposit_currency
					, currency				AS withdraw_currency
					, debit_currency		AS debit_currency
					, debit_amount			AS debit_amount
					, type					AS type
					, status				AS status
					, 0						AS process_status
					, w_id 					AS transaction_id
				FROM
					t_withdraw
				WHERE
					status			&lt;= '3'
					AND (type		= '0'
							OR type	= '3'
							OR type = '1')
				UNION ALL
				SELECT						/* 口座振替 */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '3'					AS transaction_type
					, ''					AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, to_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, from_fee				AS withdraw_fee
					, transfer_amount		AS deposit_amount
					, to_fee				AS deposit_fee
					, 0						AS draw_fee
					, ''					AS draw_fee_currency
					, ''					AS rate
					, to_currency			AS deposit_currency
					, debit_currency		AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, 0						AS status
					, process_status		AS process_status
					, t_id 					AS transaction_id
				FROM
					t_transfer
					WHERE CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > t_transfer.create_time
				UNION ALL
				SELECT						/* 通貨両替 */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '4'					AS transaction_type
					, ''					AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, 0						AS withdraw_fee
					, amount				AS deposit_amount
					, 0						AS deposit_fee
					, 0						AS draw_fee
					, ''					AS draw_fee_currency
					, rate					AS rate
					, currency				AS deposit_currency
					, debit_currency		AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, 0						AS status
					, 0						AS process_status
					, e_id 					AS transaction_id
				FROM
					t_exchange
				UNION ALL
				SELECT						/* 引き落とし */
					update_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '5'					AS transaction_type
					, ''					AS withdraw_account_name
					, from_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, to_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, from_fee				AS withdraw_fee
					, amount				AS deposit_amount
					, to_fee				AS deposit_fee
					, 0						AS draw_fee
					, ''					AS draw_fee_currency
					, ''					AS rate
					, currency				AS deposit_currency
					, debit_currency		AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, 0						AS status
					, 0						AS process_status
					, r_id 					AS transaction_id
				FROM
					t_request
				UNION ALL
				SELECT						/* 出金（組戻し） */
					process_time			AS transaction_time
					, transaction_number	AS transaction_number
					, '7'					AS transaction_type
					, ''					AS withdraw_account_name
					, ''					AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, ''					AS withdraw_amount
					, ''					AS withdraw_fee
					, debit_amount			AS deposit_amount
					, (fee + fee_refund)	AS deposit_fee
					, draw_fee				AS draw_fee
					, draw_fee_currency		AS draw_fee_currency
					, ''					AS rate
					, debit_currency		AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, status				AS status
					, 0						AS process_status
					, w_id 					AS transaction_id
				FROM
					t_withdraw
				WHERE
					status = '4'
				UNION ALL
				SELECT						/* 出金（キャンセル） */
					process_time			AS transaction_time
					, transaction_number	AS transaction_number
					, '8'					AS transaction_type
					, ''					AS withdraw_account_name
					, ''					AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, ''					AS withdraw_fee
					, debit_amount			AS deposit_amount
					, (fee)					AS deposit_fee
					, draw_fee				AS draw_fee
					, draw_fee_currency		AS draw_fee_currency
					, ''					AS rate
					, debit_currency		AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, status				AS status
					, 0						AS process_status
					, w_id 					AS transaction_id
				FROM
					t_withdraw
				WHERE
					status = '6'
				UNION ALL
				SELECT						/* 账户休止金 */
					process_time			AS transaction_time
					, transaction_number	AS transaction_number
					, '11'					AS transaction_type
					, ''					AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, ''					AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, (fee)					AS withdraw_fee
					, debit_amount			AS deposit_amount
					, ''					AS deposit_fee
					, draw_fee				AS draw_fee
					, draw_fee_currency		AS draw_fee_currency
					, ''					AS rate
					, debit_currency		AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, status				AS status
					, 0						AS process_status
					, w_id 					AS transaction_id
				FROM
					t_withdraw
				WHERE
					status				= '2'
					<!--AND user_account	= '__ELEMENT01__'-->
					AND type 			= '11'
			)			AS trans
			LEFT OUTER JOIN
				t_user	AS deposit_users
			ON(trans.deposit_account_number = deposit_users.user_account)
			LEFT OUTER JOIN
				t_user	AS withdraw_users
			ON(trans.withdraw_account_number = withdraw_users.user_account)
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			__ELEMENT02__
		__ELEMENT03__
	</LIST_TRANSACTION>

	<LIST_DELETED_TRANSACTION>
		SELECT
				trans.transaction_time												AS transaction_time
				, trans.transaction_number											AS transaction_number
				, trans.transaction_type											AS transaction_type
				, CONCAT(withdraw_users.last_name, ' ', withdraw_users.first_name)	AS withdraw_account_name
				, trans.withdraw_account_number										AS withdraw_account_number
				, CONCAT(deposit_users.last_name, ' ', deposit_users.first_name)	AS deposit_account_name
				, trans.deposit_account_number										AS deposit_account_number
				, trans.withdraw_currency											AS withdraw_currency
				, trans.withdraw_amount												AS withdraw_amount
				, trans.withdraw_fee												AS withdraw_fee
				, trans.deposit_currency											AS deposit_currency
				, trans.deposit_amount												AS deposit_amount
				, trans.deposit_fee													AS deposit_fee
				, trans.rate														AS rate
				, trans.debit_currency												AS debit_currency
				, trans.debit_amount												AS debit_amount
				, trans.type														AS type
				, trans.status														AS status
				, process_status													AS process_status
				, trans.create_time 												AS create_time
				, trans.u_id 														AS u_id
		FROM (
				SELECT						/* 入金 */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '1'					AS transaction_type
					, ''					AS withdraw_account_name
					, ''					AS withdraw_account_number
					, ''					AS deposit_account_name
					, user_account			AS deposit_account_number
					, ''					AS withdraw_amount
					, ''					AS withdraw_fee
					, amount				AS deposit_amount
					, fee					AS deposit_fee
					, ''					AS rate
					, currency				AS deposit_currency
					, ''					AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, type					AS type
					, 0						AS status
					, 0						AS process_status
					, date_deleted 			AS create_time
					, u_id 					AS u_id
				FROM
					t_deposit_deleted 		AS t_deposit_deleted
				WHERE
					type != 1
				UNION ALL
				/* 出金 */ 
			    SELECT
					create_time AS transaction_time,
					transaction_number AS transaction_number,
					'2' AS transaction_type,
					'' AS withdraw_account_name,
					user_account AS withdraw_account_number, 
					'' AS deposit_account_name,
					'' AS deposit_account_number,
					debit_amount AS withdraw_amount,
					fee AS withdraw_fee, 
					'' AS deposit_amount, 
					'' AS deposit_fee,
					'' AS rate, 
					0 AS deposit_currency,
					debit_currency AS withdraw_currency,
					debit_currency AS debit_currency,
					0 AS debit_amount, 
					TYPE AS TYPE,
					0 AS STATUS,
					0 AS process_status,
					date_deleted AS create_time,
					u_id AS u_id
				FROM
					t_withdraw_deleted
			    UNION ALL
				SELECT						/* 口座振替 */
					create_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '3'					AS transaction_type
					, ''					AS withdraw_account_name
					, user_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, to_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, from_fee				AS withdraw_fee
					, transfer_amount		AS deposit_amount
					, to_fee				AS deposit_fee
					, ''					AS rate
					, to_currency			AS deposit_currency
					, debit_currency		AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, 0						AS status
					, process_status		AS process_status
					, date_deleted 			AS create_time
					, u_id 					AS u_id
				FROM
					t_transfer_deleted
				UNION ALL
				SELECT						/* 引き落とし */
					update_time				AS transaction_time
					, transaction_number	AS transaction_number
					, '5'					AS transaction_type
					, ''					AS withdraw_account_name
					, from_account			AS withdraw_account_number
					, ''					AS deposit_account_name
					, to_account			AS deposit_account_number
					, debit_amount			AS withdraw_amount
					, from_fee				AS withdraw_fee
					, amount				AS deposit_amount
					, to_fee				AS deposit_fee
					, ''					AS rate
					, currency				AS deposit_currency
					, debit_currency		AS withdraw_currency
					, 0						AS debit_currency
					, 0						AS debit_amount
					, 0						AS type
					, 0						AS status
					, 0						AS process_status
					, date_deleted 			AS create_time
					, u_id 					AS u_id
				FROM
					t_request_deleted
			)			AS trans
			LEFT OUTER JOIN
				t_user	AS deposit_users
			ON(trans.deposit_account_number = deposit_users.user_account)
			LEFT OUTER JOIN
				t_user	AS withdraw_users
			ON(trans.withdraw_account_number = withdraw_users.user_account)
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			create_time DESC
		__ELEMENT02__
	</LIST_DELETED_TRANSACTION>


	<COUNT_DELETED_TRANSACTION>
		SELECT
				trans.transaction_number											AS transaction_number
				, trans.withdraw_account_number										AS withdraw_account_number
				, trans.deposit_account_number										AS deposit_account_number

		FROM (
				SELECT						/* 入金 */
					 t_deposit_deleted.transaction_number	AS transaction_number
					, ''									AS withdraw_account_number
					, t_deposit_deleted.user_account		AS deposit_account_number

				FROM
					t_deposit_deleted
				UNION ALL
				SELECT						/* 口座振替 */
					t_transfer_deleted.transaction_number	AS transaction_number
					, t_transfer_deleted.user_account		AS withdraw_account_number
					, t_transfer_deleted.to_account			AS deposit_account_number

				FROM
					t_transfer_deleted
				UNION ALL
				SELECT						/* 引き落とし */
					t_request_deleted.transaction_number	AS transaction_number
					, t_request_deleted.from_account		AS withdraw_account_number
					, t_request_deleted.to_account			AS deposit_account_number
				FROM
					t_request_deleted
			)			AS trans
			LEFT OUTER JOIN
				t_user	AS deposit_users
			ON(trans.deposit_account_number = deposit_users.user_account)
			LEFT OUTER JOIN
				t_user	AS withdraw_users
			ON(trans.withdraw_account_number = withdraw_users.user_account)
		WHERE
			1
			__ELEMENT01__
	</COUNT_DELETED_TRANSACTION>

	<LIST_EXCHANGE>
		SELECT
			exchange.create_time AS transaction_time
			,exchange.transaction_number
			,exchange.user_account
			,exchange.debit_currency
			,exchange.debit_amount
			,exchange.currency
			,exchange.amount
			,exchange.rate
			,user.mail
		FROM
			t_exchange AS exchange
			INNER JOIN
				t_user AS user
			ON(exchange.user_account = user.user_account)
		WHERE
			1=1
			__ELEMENT01__
		ORDER BY
			exchange.create_time DESC
	</LIST_EXCHANGE>

	<!--
		処理履歴の取得
		条　件：ユーザアカウント
	-->
	<LIST_USER_TRANSACTION>
		SELECT
				trans.transaction_time																	AS transaction_time
				, trans.transaction_time_string															AS transaction_time_string
				, trans.process_time_string																AS process_time_string
				, trans.transaction_number																AS transaction_number
				, trans.message																			AS message
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN deposit_currency ELSE withdraw_currency END) AS currency
				, (CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN trans.deposit_amount ELSE (trans.deposit_amount / 100) END) 		AS deposit_amount
				, (CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN trans.withdraw_amount ELSE (trans.withdraw_amount / 100) END)		AS withdraw_amount
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN (CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN trans.deposit_fee ELSE (trans.deposit_fee / 100) END) ELSE (CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN trans.withdraw_fee ELSE (trans.withdraw_fee / 100) END) END) AS fee
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN withdraw_account_number ELSE deposit_account_number END) AS account_number
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN CONCAT(IFNULL(withdraw_user.first_name, ''), ' ', IFNULL(withdraw_user.last_name, '')) ELSE CONCAT(IFNULL(deposit_user.first_name, ''), ' ', IFNULL(deposit_user.last_name, '')) END) AS account_name
				, trans.transaction_type																	AS transaction_type
				, trans.type																				AS type
				, trans.status																			AS status
				, (SELECT
(CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN (sum(IFNULL(deposit_amount, 0))-sum(IFNULL(withdraw_amount, 0))-sum(IFNULL(fee, 0)))  ELSE ((sum(IFNULL(deposit_amount, 0))-sum(IFNULL(withdraw_amount, 0))-sum(IFNULL(fee, 0))) / 100) END)
FROM
(SELECT
				trans_in.transaction_time																	AS transaction_time
				, trans_in.msecond																			AS msecond
				, trans_in.deposit_amount																	AS deposit_amount
				, trans_in.withdraw_amount																	AS withdraw_amount
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN deposit_fee ELSE withdraw_fee END) AS fee
		FROM (
				SELECT										/* 通常入金 */
					create_time								AS transaction_time
					, deposit_date							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(deposit_date, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '1'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_deposit
				WHERE
					user_account		= '__ELEMENT01__'
					AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')			> deposit_date
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 通常出金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '2'									AS transaction_type
					, ''									AS withdraw_account_number
					, ''									AS deposit_account_number
					, debit_amount 		 					AS withdraw_amount
					, fee									AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, type									AS type
					, status								AS status
					, receipt_message						AS message
					, msecond								AS msecond
				FROM
					t_withdraw
				WHERE
					user_account	= '__ELEMENT01__'
					AND status		&lt;= '3'
					AND debit_currency = '__ELEMENT02__'
					AND (type		= '0'
							OR type	= '3'
							OR type = '1')
				UNION ALL
				SELECT										/* 両替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '3'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, 0										AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, 0										AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 両替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '4'									AS transaction_type
					, user_account							AS withdraw_account_number
					, 0										AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, 0										AS withdraw_fee
					, 0										AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '5'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_transfer
				WHERE
					user_account = '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '6'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, transfer_amount						AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, transfer_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_transfer
				WHERE
					to_account = '__ELEMENT01__'
					AND transfer_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 引き落し（出金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '7'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_request
				WHERE
					from_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND status		= 1
				UNION ALL
				SELECT										/* 引き落し（入金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '8'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_request
				WHERE
					to_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
					AND status	= 1
				UNION ALL
				SELECT										/* 出金（組戻し） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '9'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, (fee + fee_refund)					AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_withdraw
				WHERE
					status				= '4'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 出金（キャンセル） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '10'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_withdraw
				WHERE
					status				= '6'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 账户休止金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '11'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, fee									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_withdraw
				WHERE
					status				= '2'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND type 			= '11'
			)					AS trans_in
			LEFT OUTER JOIN
				v_users_all		AS withdraw_user
			ON(trans_in.withdraw_account_number = withdraw_user.user_account)
			LEFT OUTER JOIN
				v_users_all		AS deposit_user
			ON(trans_in.deposit_account_number = deposit_user.user_account)) t2
WHERE
		unix_timestamp(t2.transaction_time) &lt; unix_timestamp(trans.transaction_time) OR (unix_timestamp(t2.transaction_time) = unix_timestamp(trans.transaction_time) AND t2.msecond &lt;= trans.msecond)) AS balance
		FROM (
				SELECT										/* 通常入金 */
					create_time								AS transaction_time
					, deposit_date							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(deposit_date, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '1'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_deposit
				WHERE
					user_account		= '__ELEMENT01__'
					AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')			> deposit_date
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 通常出金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '2'									AS transaction_type
					, ''									AS withdraw_account_number
					, ''									AS deposit_account_number
					, debit_amount 		 					AS withdraw_amount
					, fee									AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, type									AS type
					, status								AS status
					, receipt_message						AS message
					, msecond								AS msecond
				FROM
					t_withdraw
				WHERE
					user_account	= '__ELEMENT01__'
					AND status		&lt;= '3'
					AND debit_currency = '__ELEMENT02__'
					AND (type		= '0'
							OR type	= '3'
							OR type = '1')
				UNION ALL
				SELECT										/* 両替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '3'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, 0										AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, 0										AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 両替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '4'									AS transaction_type
					, user_account							AS withdraw_account_number
					, 0										AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, 0										AS withdraw_fee
					, 0										AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '5'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_transfer
				WHERE
					user_account = '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '6'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, transfer_amount						AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, transfer_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_transfer
				WHERE
					to_account = '__ELEMENT01__'
					AND transfer_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 引き落し（出金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '7'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_request
				WHERE
					from_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND status		= 1
				UNION ALL
				SELECT										/* 引き落し（入金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '8'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, msecond								AS msecond
				FROM
					t_request
				WHERE
					to_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
					AND status	= 1
				UNION ALL
				SELECT										/* 出金（組戻し） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '9'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, (fee + fee_refund)					AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_withdraw
				WHERE
					status				= '4'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 出金（キャンセル） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '10'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, msecond								AS msecond
				FROM
					t_withdraw
				WHERE
					status				= '6'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
                UNION ALL
				SELECT										/* 账户休止金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '11'									AS transaction_type
					, ''									AS withdraw_account_number
					, ''									AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, fee									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, moneyout_solution						AS message
                    , msecond								AS msecond
				FROM
					t_withdraw
				WHERE
					status				= '2'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND type 			= '11'
			)					AS trans
			LEFT OUTER JOIN
				v_users_all		AS withdraw_user
			ON(trans.withdraw_account_number = withdraw_user.user_account)
			LEFT OUTER JOIN
				v_users_all		AS deposit_user
			ON(trans.deposit_account_number = deposit_user.user_account)
		WHERE
			1
			__ELEMENT03__
		ORDER BY
			cast(transaction_time as datetime)
			__ELEMENT04__
	</LIST_USER_TRANSACTION>

	<SELECT_USER_TRANSACTION_COUNT>
		SELECT 
		(remitter + receiver + deposit + withdrawal + benef_exchange 
		+ debit_exchange + from_request + to_request + with1 + with2 + with3 ) AS 'overall_total' 
		FROM (
		SELECT 
			(SELECT COUNT(*) FROM t_deposit WHERE user_account = '__ELEMENT01__' 
				AND currency = '__ELEMENT02__' __ELEMENT03__ AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > deposit_date) deposit,
				
			(SELECT COUNT(*) FROM t_withdraw WHERE user_account = '__ELEMENT01__' 
				AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS &lt;= 3 
								AND (TYPE = '0'
									OR TYPE	= '3'
									OR TYPE = '1')) withdrawal,
			(SELECT COUNT(*) FROM t_exchange WHERE user_account = '__ELEMENT01__'
				AND currency = '__ELEMENT02__' __ELEMENT03__) benef_exchange,
			(SELECT COUNT(*) FROM t_exchange WHERE user_account = '__ELEMENT01__'
				AND debit_currency = '__ELEMENT02__' __ELEMENT03__) debit_exchange,
		
			(SELECT COUNT(*) FROM t_transfer WHERE from_account = '__ELEMENT01__' 
				AND debit_currency = '__ELEMENT02__' __ELEMENT03__) remitter,
				
			(SELECT COUNT(*) FROM t_transfer WHERE to_account = '__ELEMENT01__' 
				AND transfer_currency = '__ELEMENT02__' __ELEMENT03__) receiver,
					
				
			(SELECT COUNT(*) FROM t_request WHERE from_account = '__ELEMENT01__'
				AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = 1) from_request,
				
			(SELECT COUNT(*) FROM t_request WHERE to_account = '__ELEMENT01__'
				AND currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = 1) to_request,
			
			(SELECT COUNT(*) FROM t_withdraw WHERE user_account = '__ELEMENT01__' 
				AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = '4') with1,	
				
			(SELECT COUNT(*) FROM t_withdraw WHERE user_account = '__ELEMENT01__' 
				AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = '6') with2,
				
			(SELECT COUNT(*) FROM t_withdraw WHERE user_account = '__ELEMENT01__' 
				AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = '2' AND TYPE = '11') with3
		) counts
	</SELECT_USER_TRANSACTION_COUNT>

	<LIST_USER_TRANSACTION_ADMIN_COUNT>
		SELECT
				count(*) total
		FROM (
				SELECT										/* 通常入金 */
					create_time								AS transaction_time
					, deposit_date							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(deposit_date, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '1'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_deposit
				WHERE
					user_account		= '__ELEMENT01__'
					AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')			> deposit_date
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 通常出金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '2'									AS transaction_type
					, ''									AS withdraw_account_number
					, ''									AS deposit_account_number
					, debit_amount 		 					AS withdraw_amount
					, fee									AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, type									AS type
					, status								AS status
					, receipt_message						AS message
				FROM
					t_withdraw
				WHERE
					user_account	= '__ELEMENT01__'
					AND status		&lt;= '3'
					AND debit_currency = '__ELEMENT02__'
					AND (type		= '0'
							OR type	= '3'
							OR type = '1')
				UNION ALL
				SELECT										/* 両替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '3'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, 0										AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, 0										AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 両替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '4'									AS transaction_type
					, user_account							AS withdraw_account_number
					, 0										AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, 0										AS withdraw_fee
					, 0										AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '5'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_transfer
				WHERE
					user_account = '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '6'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, transfer_amount						AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, transfer_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_transfer
				WHERE
					to_account = '__ELEMENT01__'
					AND transfer_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 引き落し（出金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '7'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_request
				WHERE
					from_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND status		= 1
				UNION ALL
				SELECT										/* 引き落し（入金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '8'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_request
				WHERE
					to_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
					AND status	= 1
				UNION ALL
				SELECT										/* 出金（組戻し） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '9'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, (fee + fee_refund)					AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
				FROM
					t_withdraw
				WHERE
					status				= '4'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 出金（キャンセル） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '10'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
				FROM
					t_withdraw
				WHERE
					status				= '6'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 账户休止金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '11'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, fee									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
				FROM
					t_withdraw
				WHERE
					status				= '2'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND type 			= '11'
			)					AS trans
			LEFT OUTER JOIN
				v_users_all		AS withdraw_user
			ON(trans.withdraw_account_number = withdraw_user.user_account)
			LEFT OUTER JOIN
				v_users_all		AS deposit_user
			ON(trans.deposit_account_number = deposit_user.user_account)
		WHERE
			1
			__ELEMENT03__
	</LIST_USER_TRANSACTION_ADMIN_COUNT>

	<LIST_USER_TRANSACTION_ADMIN_COUNT_REVISED>
		SELECT
		count(trans.currency) total,
		trans.currency as currency
		FROM
			(
					SELECT
						user_account,
						currency,
						transaction_number,
						create_time AS transaction_time,
						deposit_date AS process_time,
						DATE_FORMAT(create_time, '%Y/%m/%d') AS transaction_time_string,
						DATE_FORMAT(deposit_date, '%Y/%m/%d') AS process_time_string,
						'' AS withdraw_account_number,
						user_account AS deposit_account_number,
						'1' AS transaction_type,
						'' AS withdraw_amount,
						'' AS withdraw_fee,
						0 AS type,
						amount AS deposit_amount,
						fee AS deposit_fee,
						msecond
					FROM
						t_deposit
					WHERE CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > deposit_date AND user_account = '__ELEMENT01__'
				UNION ALL
					SELECT
						user_account,
						currency,
						transaction_number,
						create_time AS transaction_time,
						create_time AS process_time,
						DATE_FORMAT(create_time, '%Y/%m/%d') AS transaction_time_string,
						DATE_FORMAT(create_time, '%Y/%m/%d') AS process_time_string,
						user_account AS withdraw_account_number,
						0 AS deposit_account_number,
						'3' AS transaction_type,
						0 AS withdraw_amount,
						'' AS withdraw_fee,
						0 AS type,
						amount AS deposit_amount,
						0 AS deposit_fee,
						msecond
					FROM
						t_exchange
					WHERE
						user_account = '__ELEMENT01__'
					UNION ALL
						SELECT
							user_account,
							debit_currency AS currency,
							transaction_number,
							create_time AS transaction_time,
							create_time AS process_time,
							DATE_FORMAT(create_time, '%Y/%m/%d') AS transaction_time_string,
							DATE_FORMAT(create_time, '%Y/%m/%d') AS process_time_string,
							user_account AS withdraw_account_number,
							0 AS deposit_account_number,
							'4' AS transaction_type,
							debit_amount AS withdraw_amount,
							0 AS withdraw_fee,
							0 AS type,
							0 AS deposit_amount,
							'' AS deposit_fee,
							msecond
						FROM
							t_exchange
						WHERE
							user_account = '__ELEMENT01__'
					UNION ALL
						SELECT
							user_account,
							debit_currency AS currency,
							transaction_number,
							create_time AS transaction_time,
							create_time AS process_time,
							DATE_FORMAT(create_time, '%Y/%m/%d') AS transaction_time_string,
							DATE_FORMAT(create_time, '%Y/%m/%d') AS process_time_string,
							from_account AS withdraw_account_number,
							to_account AS deposit_account_number,
							'5' AS transaction_type,
							debit_amount AS withdraw_amount,
							from_fee AS withdraw_fee,
							0 AS type,
							'' AS deposit_amount,
							'' AS deposit_fee,
							msecond
						FROM
							t_transfer
						WHERE
							user_account = '__ELEMENT01__'
					UNION ALL
						SELECT
							to_account AS user_account,
							transfer_currency AS currency,
							transaction_number,
							create_time AS transaction_time,
							create_time AS process_time,
							DATE_FORMAT(create_time, '%Y/%m/%d') AS transaction_time_string,
							DATE_FORMAT(create_time, '%Y/%m/%d') AS process_time_string,
							from_account AS withdraw_account_number,
							to_account AS deposit_account_number,
							'6' AS transaction_type,
							'' AS withdraw_amount,
							'' AS withdraw_fee,
							0 AS type,
							transfer_amount AS deposit_amount,
							to_fee AS deposit_fee,
							msecond
						FROM
							t_transfer
						WHERE
							to_account = '__ELEMENT01__'
					UNION ALL
						SELECT
							to_account AS user_account,
							currency,
							transaction_number,
							transaction_time,
							process_time,
							transaction_time_string,
							process_time_string,
							withdraw_account_number,
							deposit_account_number,
							'8' AS transaction_type,
							'' AS withdraw_amount,
							'' AS withdraw_fee,
							0 AS type,
							deposit_amount,
							deposit_fee,
							msecond
						FROM
							v_request_unified_for_balance
						WHERE
							to_account = '__ELEMENT01__'
					UNION ALL
						SELECT
							from_account as user_account,
							debit_currency AS currency,
							transaction_number,
							transaction_time,
							process_time,
							transaction_time_string,
							process_time_string,
							withdraw_account_number,
							deposit_account_number,
							'7' AS transaction_type,
							withdraw_amount,
							withdraw_fee,
							0 AS type,
							'' AS deposit_amount,
							'' AS deposit_fee,
							msecond
						FROM
							v_request_unified_for_balance
						WHERE
							from_account = '__ELEMENT01__'
					UNION ALL
						SELECT
							user_account,
							debit_currency AS currency,
							transaction_number,
							transaction_time,
							process_time,
							transaction_time_string,
							process_time_string,
							withdraw_account_number,
							deposit_account_number,
							transaction_type,
							withdraw_amount,
							withdraw_fee,
							type AS type,
							deposit_amount,
							deposit_fee,
							msecond
						FROM
							v_withdrawal_unified_for_balance
						WHERE
							user_account = '__ELEMENT01__'
		) AS trans

		LEFT OUTER JOIN v_users_all AS withdraw_user ON (trans.withdraw_account_number = withdraw_user.user_account)
		LEFT OUTER JOIN v_users_all AS deposit_user ON (trans.deposit_account_number = deposit_user.user_account)
		WHERE 1
		__ELEMENT03__
		GROUP BY currency
		ORDER BY currency DESC

	</LIST_USER_TRANSACTION_ADMIN_COUNT_REVISED>

	<LIST_USER_TRANSACTION_ADMIN>
		SELECT
				trans.transaction_time																	AS transaction_time
				, trans.transaction_time_string															AS transaction_time_string
				, trans.process_time_string																AS process_time_string
				, trans.transaction_number																AS transaction_number
				, trans.message																			AS message
				, trans.method																			AS method
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN deposit_currency ELSE withdraw_currency END) AS currency
				, (CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN trans.deposit_amount ELSE (trans.deposit_amount / 100) END) 		AS deposit_amount
				, (CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN trans.withdraw_amount ELSE (trans.withdraw_amount / 100) END)		AS withdraw_amount
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN (CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN trans.deposit_fee ELSE (trans.deposit_fee / 100) END) ELSE (CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN trans.withdraw_fee ELSE (trans.withdraw_fee / 100) END) END) AS fee
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN withdraw_account_number ELSE deposit_account_number END) AS account_number
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN CONCAT(IFNULL(withdraw_user.first_name, ''), ' ', IFNULL(withdraw_user.last_name, '')) ELSE CONCAT(IFNULL(deposit_user.first_name, ''), ' ', IFNULL(deposit_user.last_name, '')) END) AS account_name
				, trans.transaction_type																	AS transaction_type
				, trans.type																				AS type
				, trans.status																			AS status
				, trans.process_status																		AS process_status
				, (SELECT
(CASE WHEN  ('__ELEMENT02__'='JPY' or '__ELEMENT02__'='PHP' or '__ELEMENT02__'='IDR' or '__ELEMENT02__'='MYR' or '__ELEMENT02__'='THB' or '__ELEMENT02__'='VND') THEN (sum(IFNULL(deposit_amount, 0))-sum(IFNULL(withdraw_amount, 0))-sum(IFNULL(fee, 0)))  ELSE ((sum(IFNULL(deposit_amount, 0))-sum(IFNULL(withdraw_amount, 0))-sum(IFNULL(fee, 0))) / 100) END)
FROM
(SELECT
				trans_in.transaction_time																	AS transaction_time
				, trans_in.msecond																			AS msecond
				, trans_in.deposit_amount																	AS deposit_amount
				, trans_in.withdraw_amount																	AS withdraw_amount
				, trans_in.process_status																	AS process_status
				, (CASE WHEN transaction_type in ('1','3','6','8','9','10') THEN deposit_fee ELSE withdraw_fee END) AS fee
		FROM (
				SELECT										/* 通常入金 */
					create_time								AS transaction_time
					, deposit_date							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(deposit_date, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '1'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, method								AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_deposit
				WHERE
					user_account		= '__ELEMENT01__'
					AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')			> deposit_date
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 通常出金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '2'									AS transaction_type
					, ''									AS withdraw_account_number
					, ''									AS deposit_account_number
					, debit_amount 		 					AS withdraw_amount
					, fee									AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, type									AS type
					, status								AS status
					, receipt_message						AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_withdraw
				WHERE
					user_account	= '__ELEMENT01__'
					AND status		&lt;= '3'
					AND debit_currency = '__ELEMENT02__'
					AND (type		= '0'
							OR type	= '3'
							OR type = '1')
				UNION ALL
				SELECT										/* 両替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '3'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, 0										AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, 0										AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 両替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '4'									AS transaction_type
					, user_account							AS withdraw_account_number
					, 0										AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, 0										AS withdraw_fee
					, 0										AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '5'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, ''									AS method
					, msecond								AS msecond
					, process_status						AS process_status
				FROM
					t_transfer
				WHERE
					user_account = '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '6'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, transfer_amount						AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, transfer_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, ''									AS method
					, msecond								AS msecond
					, process_status						AS process_status
				FROM
					t_transfer
				WHERE
					to_account = '__ELEMENT01__'
					AND transfer_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 引き落し（出金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '7'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_request
				WHERE
					from_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND status		= 1
				UNION ALL
				SELECT										/* 引き落し（入金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '8'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_request
				WHERE
					to_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
					AND status	= 1
				UNION ALL
				SELECT										/* 出金（組戻し） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '9'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, (fee + fee_refund)					AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_withdraw
				WHERE
					status				= '4'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 出金（キャンセル） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '10'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_withdraw
				WHERE
					status				= '6'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 账户休止金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '11'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, fee									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_withdraw
				WHERE
					status				= '2'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND type 			= '11'
			)					AS trans_in
			LEFT OUTER JOIN
				v_users_all		AS withdraw_user
			ON(trans_in.withdraw_account_number = withdraw_user.user_account)
			LEFT OUTER JOIN
				v_users_all		AS deposit_user
			ON(trans_in.deposit_account_number = deposit_user.user_account)) t2
WHERE
		unix_timestamp(t2.transaction_time) &lt; unix_timestamp(trans.transaction_time) OR (unix_timestamp(t2.transaction_time) = unix_timestamp(trans.transaction_time) AND t2.msecond &lt;= trans.msecond)) AS balance
		FROM (
				SELECT										/* 通常入金 */
					create_time								AS transaction_time
					, deposit_date							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(deposit_date, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '1'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, method								AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_deposit
				WHERE
					user_account		= '__ELEMENT01__'
					AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')			> deposit_date
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 通常出金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '2'									AS transaction_type
					, ''									AS withdraw_account_number
					, ''									AS deposit_account_number
					, debit_amount 		 					AS withdraw_amount
					, fee									AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, type									AS type
					, status								AS status
					, receipt_message						AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_withdraw
				WHERE
					user_account	= '__ELEMENT01__'
					AND status		&lt;= '3'
					AND debit_currency = '__ELEMENT02__'
					AND (type		= '0'
							OR type	= '3'
							OR type = '1')
				UNION ALL
				SELECT										/* 両替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '3'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, 0										AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, 0										AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 両替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '4'									AS transaction_type
					, user_account							AS withdraw_account_number
					, 0										AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, 0										AS withdraw_fee
					, 0										AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '5'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, ''									AS method
					, msecond								AS msecond
					, process_status						AS process_status
				FROM
					t_transfer
				WHERE
					user_account = '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 口座振替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '6'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, transfer_amount						AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, transfer_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, ''									AS method
					, msecond								AS msecond
					, process_status						AS process_status
				FROM
					t_transfer
				WHERE
					to_account = '__ELEMENT01__'
					AND transfer_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 引き落し（出金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '7'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_request
				WHERE
					from_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND status		= 1
				UNION ALL
				SELECT										/* 引き落し（入金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '8'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_request
				WHERE
					to_account	= '__ELEMENT01__'
					AND currency = '__ELEMENT02__'
					AND status	= 1
				UNION ALL
				SELECT										/* 出金（組戻し） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '9'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, (fee + fee_refund)					AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_withdraw
				WHERE
					status				= '4'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
				UNION ALL
				SELECT										/* 出金（キャンセル） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '10'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
					, ''									AS method
					, msecond								AS msecond
					, 0										AS process_status
				FROM
					t_withdraw
				WHERE
					status				= '6'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
                UNION ALL
				SELECT										/* 账户休止金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '11'									AS transaction_type
					, ''									AS withdraw_account_number
					, ''									AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, fee									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, moneyout_solution						AS message
					, ''									AS method
                    , msecond								AS msecond
					, 0										AS process_status
				FROM
					t_withdraw
				WHERE
					status				= '2'
					AND user_account	= '__ELEMENT01__'
					AND debit_currency = '__ELEMENT02__'
					AND type 			= '11'
			)					AS trans
			LEFT OUTER JOIN
				v_users_all		AS withdraw_user
			ON(trans.withdraw_account_number = withdraw_user.user_account)
			LEFT OUTER JOIN
				v_users_all		AS deposit_user
			ON(trans.deposit_account_number = deposit_user.user_account)
		WHERE
			1
			__ELEMENT03__
		ORDER BY
			transaction_time DESC, msecond DESC
		__ELEMENT04__
	</LIST_USER_TRANSACTION_ADMIN>

	<SELECT_USER_TRANSACTION_ADMIN_COUNT>
		SELECT COUNT(*) as overall_total FROM (
			SELECT										/* 通常入金 */
						create_time								AS transaction_time
						, deposit_date							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(deposit_date, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '1'									AS transaction_type
						, ''									AS withdraw_account_number
						, user_account							AS deposit_account_number
						, ''									AS withdraw_amount
						, ''									AS withdraw_fee
						, amount								AS deposit_amount
						, fee									AS deposit_fee
						, ''									AS rate
						, currency								AS deposit_currency
						, ''									AS withdraw_currency
						, ''									AS transfer_currency
						, ''									AS transfer_amount
						, 0										AS TYPE
						, 0										AS STATUS
						, message								AS message
						, method								AS method
						, msecond								AS msecond
						, 0										AS process_status
					FROM
						t_deposit 
					WHERE
						user_account		= '__ELEMENT01__'
						AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')			> deposit_date
						AND currency = '__ELEMENT02__'
					UNION
					SELECT										/* 両替（入金） */
						create_time								AS transaction_time
						, create_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '3'									AS transaction_type
						, ''									AS withdraw_account_number
						, user_account							AS deposit_account_number
						, 0										AS withdraw_amount
						, ''									AS withdraw_fee
						, amount								AS deposit_amount
						, 0										AS deposit_fee
						, ''									AS rate
						, currency								AS deposit_currency
						, ''									AS withdraw_currency
						, ''									AS transfer_currency
						, ''									AS transfer_amount
						, 0										AS TYPE
						, 0										AS STATUS
						, ''									AS message
						, ''									AS method
						, msecond								AS msecond
						, 0										AS process_status
					FROM
						t_exchange
					WHERE
						user_account	= '__ELEMENT01__'
						AND currency = '__ELEMENT02__'	
					UNION
					SELECT										/* 通常出金 */
						create_time								AS transaction_time
						, process_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '2'									AS transaction_type
						, ''									AS withdraw_account_number
						, ''									AS deposit_account_number
						, debit_amount 		 					AS withdraw_amount
						, fee									AS withdraw_fee
						, ''									AS deposit_amount
						, ''									AS deposit_fee
						, ''									AS rate
						, ''									AS deposit_currency
						, debit_currency						AS withdraw_currency
						, ''									AS transfer_currency
						, ''									AS transfer_amount
						, TYPE									AS TYPE
						, STATUS								AS STATUS
						, receipt_message						AS message
						, ''									AS method
						, msecond								AS msecond
						, 0										AS process_status
					FROM
							t_withdraw
					WHERE
						user_account	= '__ELEMENT01__'
						AND STATUS		&lt;= '3'
						AND debit_currency = '__ELEMENT02__'
						AND (TYPE		= '0'
								OR TYPE	= '3'
								OR TYPE = '1')
					UNION
					SELECT										/* 両替（出金） */
						create_time								AS transaction_time
						, create_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '4'									AS transaction_type
						, user_account							AS withdraw_account_number
						, 0										AS deposit_account_number
						, debit_amount							AS withdraw_amount
						, 0										AS withdraw_fee
						, 0										AS deposit_amount
						, ''									AS deposit_fee
						, ''									AS rate
						, ''									AS deposit_currency
						, debit_currency						AS withdraw_currency
						, ''									AS transfer_currency
						, ''									AS transfer_amount
						, 0										AS TYPE
						, 0										AS STATUS
						, ''									AS message
						, ''									AS method
						, msecond								AS msecond
						, 0										AS process_status
					FROM
						t_exchange
					WHERE
						user_account	= '__ELEMENT01__'
						AND debit_currency = '__ELEMENT02__'	
					UNION
					SELECT										/* 口座振替（出金） */
						create_time								AS transaction_time
						, create_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '5'									AS transaction_type
						, from_account							AS withdraw_account_number
						, to_account							AS deposit_account_number
						, debit_amount							AS withdraw_amount
						, from_fee								AS withdraw_fee
						, ''									AS deposit_amount
						, ''									AS deposit_fee
						, ''									AS rate
						, ''									AS deposit_currency
						, debit_currency						AS withdraw_currency
						, ''									AS transfer_currency
						, ''									AS transfer_amount
						, 0										AS TYPE
						, 0										AS STATUS
						, message								AS message
						, ''									AS method
						, msecond								AS msecond
						, process_status						AS process_status
					FROM
						t_transfer
					WHERE
						user_account = '__ELEMENT01__'
						AND debit_currency = '__ELEMENT02__'
					UNION	
					SELECT										/* 口座振替（入金） */
						create_time								AS transaction_time
						, create_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '6'									AS transaction_type
						, from_account							AS withdraw_account_number
						, to_account							AS deposit_account_number
						, ''									AS withdraw_amount
						, ''									AS withdraw_fee
						, transfer_amount						AS deposit_amount
						, to_fee								AS deposit_fee
						, ''									AS rate
						, transfer_currency						AS deposit_currency
						, ''									AS withdraw_currency
						, ''									AS transfer_currency
						, ''									AS transfer_amount
						, 0										AS TYPE
						, 0										AS STATUS
						, message								AS message
						, ''									AS method
						, msecond								AS msecond
						, process_status						AS process_status
					FROM
						t_transfer
					WHERE
						to_account = '__ELEMENT01__'
						AND transfer_currency = '__ELEMENT02__'	
					UNION
					SELECT										/* 引き落し（出金） */
						update_time								AS transaction_time
						, update_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '7'									AS transaction_type
						, from_account							AS withdraw_account_number
						, to_account							AS deposit_account_number
						, debit_amount							AS withdraw_amount
						, from_fee								AS withdraw_fee
						, ''									AS deposit_amount
						, ''									AS deposit_fee
						, ''									AS rate
						, ''									AS deposit_currency
						, debit_currency						AS withdraw_currency
						, ''									AS transfer_currency
						, ''									AS transfer_amount
						, 0										AS TYPE
						, 0										AS STATUS
						, message								AS message
						, ''									AS method
						, msecond								AS msecond
						, 0										AS process_status
					FROM
						t_request
					WHERE
						from_account	= '__ELEMENT01__'
						AND debit_currency = '__ELEMENT02__'
						AND STATUS		= 1
					UNION
					SELECT										/* 引き落し（入金） */
						update_time								AS transaction_time
						, update_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '8'									AS transaction_type
						, from_account							AS withdraw_account_number
						, to_account							AS deposit_account_number
						, ''									AS withdraw_amount
						, ''									AS withdraw_fee
						, amount								AS deposit_amount
						, to_fee								AS deposit_fee
						, ''									AS rate
						, currency								AS deposit_currency
						, ''									AS withdraw_currency
						, ''									AS transfer_currency
						, ''									AS transfer_amount
						, 0										AS TYPE
						, 0										AS STATUS
						, message								AS message
						, ''									AS method
						, msecond								AS msecond
						, 0										AS process_status
					FROM
						t_request
					WHERE
						to_account	= '__ELEMENT01__'
						AND currency = '__ELEMENT02__'
						AND STATUS	= 1	
					UNION
					SELECT										/* 出金（組戻し） */
						create_time								AS transaction_time
						, process_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '9'									AS transaction_type
						, ''									AS withdraw_account_number
						, user_account							AS deposit_account_number
						, debit_amount							AS withdraw_amount
						, ''									AS withdraw_fee
						, debit_amount							AS deposit_amount
						, (fee + fee_refund)					AS deposit_fee
						, ''									AS rate
						, debit_currency						AS deposit_currency
						, ''									AS withdraw_currency
						, 0										AS debit_currency
						, 0										AS debit_amount
						, 0										AS TYPE
						, STATUS								AS STATUS
						, ''									AS message
						, ''									AS method
						, msecond								AS msecond
						, 0										AS process_status
					FROM
						t_withdraw
					WHERE
						STATUS				= '4'
						AND user_account	= '__ELEMENT01__'
						AND debit_currency = '__ELEMENT02__'
					UNION
					SELECT										/* 出金（キャンセル） */
						create_time								AS transaction_time
						, process_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '10'									AS transaction_type
						, ''									AS withdraw_account_number
						, user_account							AS deposit_account_number
						, debit_amount							AS withdraw_amount
						, ''									AS withdraw_fee
						, debit_amount							AS deposit_amount
						, fee									AS deposit_fee
						, ''									AS rate
						, debit_currency						AS deposit_currency
						, ''									AS withdraw_currency
						, 0										AS debit_currency
						, 0										AS debit_amount
						, 0										AS TYPE
						, STATUS								AS STATUS
						, ''									AS message
						, ''									AS method
						, msecond								AS msecond
						, 0										AS process_status
					FROM
						t_withdraw
					WHERE
						STATUS				= '6'
						AND user_account	= '__ELEMENT01__'
						AND debit_currency = '__ELEMENT02__'
					UNION 
					SELECT										/* 账户休止金 */
						create_time								AS transaction_time
						, process_time							AS process_time
						, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
						, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
						, transaction_number					AS transaction_number
						, '11'									AS transaction_type
						, ''									AS withdraw_account_number
						, ''									AS deposit_account_number
						, debit_amount							AS withdraw_amount
						, fee									AS withdraw_fee
						, debit_amount							AS deposit_amount
						, ''									AS deposit_fee
						, ''									AS rate
						, ''									AS deposit_currency
						, debit_currency						AS withdraw_currency
						, 0										AS debit_currency
						, 0										AS debit_amount
						, 0										AS TYPE
						, STATUS								AS STATUS
						, moneyout_solution						AS message
						, ''									AS method
	                    , msecond								AS msecond
						, 0										AS process_status
					FROM
						t_withdraw
					WHERE
						STATUS				= '2'
						AND user_account	= '__ELEMENT01__'
						AND debit_currency = '__ELEMENT02__'
						AND TYPE 			= '11'		
	) AS trans
		LEFT OUTER JOIN v_users_all AS withdraw_user 
			ON (trans.withdraw_account_number = withdraw_user.user_account)
		LEFT OUTER JOIN v_users_all AS deposit_user 
			ON (trans.deposit_account_number = deposit_user.user_account)
		WHERE 1
		__ELEMENT03__
	</SELECT_USER_TRANSACTION_ADMIN_COUNT>

	<SELECT_DOMANT_BY_USER>
		SELECT
			w_id 													AS w_id
		FROM
			t_withdraw
		WHERE
			Type 		  = '11'
			And user_account = '__ELEMENT01__'
			__ELEMENT02__
	</SELECT_DOMANT_BY_USER>

	<UPDATE_DOMANT_BY_USER>
		UPDATE
			t_user
		SET
			status 			= '4',
			note 			= '__ELEMENT02__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_DOMANT_BY_USER>


	<!--
		引き落としの登録
		登録値：送金元口座番号
				送金先口座番号
				金額
				ステータス
	-->
	<INSERT_REQUEST>
		INSERT INTO t_request (
			from_account
			, to_account
			, currency
			, amount
			, status
			, message
			, transaction_number
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_REQUEST>

	<!--
		引き落としの更新
		更新値：ステータス
				引落通貨
				引落金額
		条　件：引落ID
	-->
	<UPDATE_REQUEST>
		UPDATE
			t_request
		SET
			debit_currency		= '__ELEMENT02__'
			, debit_amount		= '__ELEMENT03__'
			, status			= '__ELEMENT04__'
			, rate				= '__ELEMENT05__'
			, send_message		= '__ELEMENT06__'
			, from_fee			= '__ELEMENT07__'
			, to_fee			= '__ELEMENT08__'
			, update_time		= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			r_id = '__ELEMENT01__'
	</UPDATE_REQUEST>

	<!--
		引き落としの更新（ステータス）
		更新値：ステータス
		条　件：引落ID
	-->
	<UPDATE_REQUEST_STATUS>
		UPDATE
			t_request
		SET
			status			= '__ELEMENT02__'
			, update_time	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			r_id = '__ELEMENT01__'
	</UPDATE_REQUEST_STATUS>

	<!--
		引き落としの更新（否認時）
		更新値：ステータス
		条　件：引落ID
	-->
	<UPDATE_REQUEST_ROLL_BACK>
		UPDATE
			t_request
		SET
			status			= '__ELEMENT02__'
			, send_message	= '__ELEMENT03__'
			, update_time	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			r_id = '__ELEMENT01__'
	</UPDATE_REQUEST_ROLL_BACK>

	<!--
		引き落としの更新（表示・非表示）
		更新値：表示フラグ
		条　件：引落ID
	-->
	<UPDATE_REQUEST_HIDDEN_FLG>
		UPDATE
			t_request
		SET
			hidden_flg	= '__ELEMENT02__'
		WHERE
			r_id = '__ELEMENT01__'
	</UPDATE_REQUEST_HIDDEN_FLG>

	<!--
		ユーザプロフィールの更新
		更新値：国
				都道府県
				市町村
				郵便番号
				番地1
				番地2
				電話番号
				国
		条　件：ユーザ口座番号
	-->
	<UPDATE_USER_PROFILE>
		UPDATE
			t_user
		SET
			state					= '__ELEMENT02__'
			, city					= '__ELEMENT03__'
			, zip_code				= '__ELEMENT04__'
			, address				= '__ELEMENT05__'
			, address2				= '__ELEMENT06__'
			, tel					= '__ELEMENT07__'
			, country				= '__ELEMENT08__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_PROFILE>

	<!--
		ユーザプロフィールの更新
		更新値：国
				都道府県
				市町村
				郵便番号
				番地1
				番地2
				電話番号
				国
		条　件：ユーザ口座番号
	-->
	<UPDATE_USER_BANK_INFO>
		UPDATE
			t_user
		SET
			account_number			= '__ELEMENT16__'
			, account_name			= '__ELEMENT05__'
			, bank_name				= '__ELEMENT10__'
			, swift_code			= '__ELEMENT12__'
			, bank_country			= '__ELEMENT13__'
			, bank_address			= '__ELEMENT14__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_BANK_INFO>

	<!--
		ユーザメモの更新
		更新値：ユーザメモ
		条　件：ユーザ口座番号
	-->
	<UPDATE_USER_NOTE>
		UPDATE
			t_user
		SET
			note		= '__ELEMENT02__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_NOTE>
	<UPDATE_USER_RISK>
		UPDATE
			t_user
		SET
			risk		= '__ELEMENT02__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_RISK>

	<!--
		ユーザの削除
		更新値：ユーザメモ
		条　件：ユーザ口座番号
	-->
	<UPDATE_USER_DELETE>
		UPDATE
			t_user
		SET
			del_flg		= '__ELEMENT02__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_DELETE>

	<!--
		ユーザのメールアドレス変更
		更新値：メールアドレス
		条　件：ユーザ口座番号
	-->
	<UPDATE_USER_EMAIL>
		UPDATE
			t_user
		SET
			mail = '__ELEMENT02__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_EMAIL>

	<!--
		ユーザプロフィールの更新
		更新値：姓
				名
				国
				都道府県
				市町村
				郵便番号
				番地1
				番地2
				電話番号
		条　件：ユーザ口座番号
	-->
	<UPDATE_USER>
		UPDATE
			t_user
		SET
			last_name				= '__ELEMENT02__'
			, first_name			= '__ELEMENT03__'
			, country				= '__ELEMENT04__'
			, state					= '__ELEMENT05__'
			, city					= '__ELEMENT06__'
			, address				= '__ELEMENT07__'
			, address2				= '__ELEMENT08__'
			, zip_code				= '__ELEMENT09__'
			, tel					= '__ELEMENT10__'
			, mail					= '__ELEMENT11__'
			, birth					= '__ELEMENT12__-__ELEMENT13__-__ELEMENT14__'
			, account_type			= '__ELEMENT15__'
			, crm_id				= '__ELEMENT16__'
			, status				= '__ELEMENT17__'
			, parent_agent_code		= '__ELEMENT18__'
			, transfer_batch_flg	= '__ELEMENT19__'
			, risk_level			= '__ELEMENT20__' <!-- Mikko 2019: 3501 -->
			, tier_tag				= '__ELEMENT21__'
			, transfer_flg			= '__ELEMENT22__'
			, test_account_flg		= '__ELEMENT23__'
			, date_tagged			= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER>

	<!--
		ユーザ所属WLの変更
		更新値：WLID
		条　件：ユーザ口座番号
	-->
	<UPDATE_USER_WL_ID>
		UPDATE
			t_user
		SET
			wl_id = '__ELEMENT02__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_WL_ID>

	<!--
		ユーザプロフィールの更新
		更新値：国
				都道府県
				市町村
				郵便番号
				番地1
				番地2
				電話番号
		条　件：ユーザ口座番号
	-->
	<UPDATE_USER_PASSWORD>
		UPDATE
			t_login
		SET
			password	= '__ELEMENT02__'
		WHERE
			user_name	= '__ELEMENT01__'
	</UPDATE_USER_PASSWORD>

	<!--
		KYC確認書類の登録
		登録値：ユーザ口座番号
				旧ファイル名
				保存ファイル名
				書類種別
				ステータス
	-->
	<INSERT_KYC>
		INSERT INTO t_kyc (
			user_account
			, old_filename
			, save_filename
			, file_type
			, veri_flg
			, status
			, create_time
			, kyc_status_update_counter
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT07__'
		)
	</INSERT_KYC>

	<!--
		KYC確認書類の取得
		条　件：なし
	-->
	<LIST_KYC>
		SELECT
			users.u_id										AS u_id
			, users.wl_id									AS wl_id
			, users.wl_name									AS wl_name
			, users.user_name								AS user_name
			, users.password								AS password
			, users.mail									AS mail
			, users.account_type							AS account_type
			, users.user_account							AS user_account
			, currency										AS currency
			, users.tel										AS tel
			, users.last_name								AS last_name
			, users.first_name								AS first_name
			, users.birth									AS birth
			, users.country									AS country
			, users.state									AS state
			, users.city									AS city
			, users.zip_code								AS zip_code
			, users.address									AS address
			, users.address2								AS address2
			, users.bank_name								AS bank_name
			, users.branch_name								AS branch_name
			, users.branch_number							AS branch_number
			, users.account_number							AS account_number
			, users.account_name							AS account_name
			, users.admin_flg								AS admin_flg
			, users.status									AS user_status
			, users.kyc_flg									AS kyc_flg
			, agent_flg										AS agent_flg
			, agent_code									AS agent_code
			, users.create_time								AS create_time
			, DATE_FORMAT(users.create_time, '%Y/%m/%d')	AS create_time_string
			, users.apply_email								AS apply_email
			, users.apply_time								AS apply_time
			, users.veri_apply_flg							AS veri_apply_flg
			, users.veri_apply_time							AS veri_apply_time
			, users.mail_send_flg							AS mail_send_flg
			, COUNT(kyc.user_account)						AS counter
			, kyc.old_filename								AS old_filename
			, kyc.save_filename								AS save_filename
			, kyc.veri_flg									AS veri_flg
			, kyc.status									AS status
			, MAX(kyc.create_time)							AS max_create_time
		FROM
			v_users_active		AS users
			LEFT OUTER JOIN
				t_kyc	AS  kyc
			ON(users.user_account = kyc.user_account)
		WHERE
			kyc.user_account	IS NOT NULL
			AND kyc.status		= '0'
		GROUP BY
			users.user_account
		HAVING
			counter > 0
		ORDER BY
			max_create_time DESC
	</LIST_KYC>
	<LIST_KYC_ADMIN>
		SELECT
			users.u_id										AS u_id
			, users.user_name								AS user_name
			, users.password								AS password
			, users.mail									AS mail
			, users.account_type							AS account_type
			, users.user_account							AS user_account
			, currency										AS currency
			, users.tel										AS tel
			, users.last_name								AS last_name
			, users.first_name								AS first_name
			, users.birth									AS birth
			, users.country									AS country
			, users.state									AS state
			, users.city									AS city
			, users.zip_code								AS zip_code
			, users.address									AS address
			, users.address2								AS address2
			, users.bank_name								AS bank_name
			, users.branch_name								AS branch_name
			, users.branch_number							AS branch_number
			, users.account_number							AS account_number
			, users.account_name							AS account_name
			, users.admin_flg								AS admin_flg
			, users.status									AS user_status
			, users.kyc_flg									AS kyc_flg
			, agent_flg										AS agent_flg
			, agent_code									AS agent_code
			, users.create_time								AS create_time
			, DATE_FORMAT(users.create_time, '%Y/%m/%d')	AS create_time_string
			, users.apply_email								AS apply_email
			, users.apply_time								AS apply_time
			, users.veri_apply_flg							AS veri_apply_flg
			, users.veri_apply_time							AS veri_apply_time
			, users.mail_send_flg							AS mail_send_flg
			, COUNT(kyc.user_account)						AS counter
			, kyc.old_filename								AS old_filename
			, kyc.save_filename								AS save_filename
			, kyc.veri_flg									AS veri_flg
			, kyc.status									AS status
			, MAX(kyc.create_time)							AS max_create_time
			, users.process_time  							AS process_time
			, users.kyc_validate_status						AS validate_status
			, users.kyc_comment								AS comment
		FROM
			v_users_active		AS users
			LEFT OUTER JOIN
				t_kyc	AS  kyc
			ON(users.user_account = kyc.user_account)
		WHERE
			kyc.user_account	IS NOT NULL
			AND users.kyc_validate_status != '99'
			__ELEMENT01__
		GROUP BY
			users.user_account
		HAVING
			counter > 0
		ORDER BY
			MAX(kyc.create_time) DESC
			__ELEMENT02__
	</LIST_KYC_ADMIN>
	
	<COUNT_KYC_ADMIN>
		SELECT COUNT(*) as counter from (
		  SELECT 
		  	COUNT(kyc.user_account)           AS counter
				FROM 
		  	v_users_active AS users 
		  		LEFT OUTER JOIN t_kyc AS kyc ON(
		    		users.user_account = kyc.user_account
		  		) 
			WHERE 
		  		kyc.user_account IS NOT NULL 
		  		AND users.kyc_validate_status != '99' 
		  		__ELEMENT01__
			GROUP BY 
		  		users.user_account 
			HAVING 
		  		counter > 0 
		) as KYC_comp
	</COUNT_KYC_ADMIN>


	<!--
		KYC確認書類の取得（1件）
		条　件：ユーザ口座番号
	-->
	<SELECT_KYC_ADMIN>
		SELECT
			users.u_id										AS u_id
			, users.user_name								AS user_name
			, users.password								AS password
			, users.mail									AS mail
			, users.account_type							AS account_type
			, users.user_account							AS user_account
			, users.currency								AS currency
			, users.tel										AS tel
			, users.last_name								AS last_name
			, users.first_name								AS first_name
			, users.birth									AS birth
			, users.country									AS country
			, users.state									AS state
			, users.city									AS city
			, users.zip_code								AS zip_code
			, users.address									AS address
			, users.address2								AS address2
			, users.bank_name								AS bank_name
			, users.branch_name								AS branch_name
			, users.branch_number							AS branch_number
			, users.account_number							AS account_number
			, users.account_name							AS account_name
			, users.admin_flg								AS admin_flg
			, users.status									AS user_status
			, users.kyc_flg									AS kyc_flg
			, users.agent_flg								AS agent_flg
			, users.parent_agent_code						AS agent_code
			, DATE_FORMAT(users.create_time, '%Y/%m/%d')	AS create_time_string
			, users.apply_email								AS apply_email
			, users.apply_time								AS apply_time
			, users.veri_apply_flg							AS veri_apply_flg
			, users.veri_apply_time							AS veri_apply_time
			, users.mail_send_flg							AS mail_send_flg
			, kyc.k_id										AS k_id
			, kyc.old_filename								AS old_filename
			, kyc.save_filename								AS save_filename
			, kyc.file_type									AS file_type
			, kyc.veri_flg									AS veri_flg
			, kyc.status									AS status
			, kyc.create_time								AS create_time
			, users.kyc_validate_status						AS validate_status
			, users.kyc_comment								AS comment
			, users.note									AS note
			, users.crm_id 									AS crm_id
			, IFNULL(corporation.ceo_first_name, '')		AS ceo_first_name
			, IFNULL(corporation.ceo_last_name, '')			AS ceo_last_name
			, kyc.kyc_status_update_counter					AS kyc_status_update_counter
			, users.process_time 							AS process_time
		FROM
			t_kyc		AS  kyc
			LEFT OUTER JOIN
				v_users_active	AS users
			ON(users.user_account = kyc.user_account)
			LEFT OUTER JOIN
				t_corporation		AS corporation
			ON(users.u_id = corporation.u_id)
		WHERE
			kyc.user_account = '__ELEMENT01__'
			And users.kyc_validate_status != '99'
		ORDER BY
			kyc.create_time DESC
	</SELECT_KYC_ADMIN>
	<!--
		KYC確認書類の取得（1件）
		条　件：ユーザ口座番号
	-->
	<SELECT_KYC>
		SELECT
			users.u_id										AS u_id
			, users.wl_id									AS wl_id
			, users.wl_name									AS wl_name
			, users.user_name								AS user_name
			, users.password								AS password
			, users.mail									AS mail
			, users.account_type							AS account_type
			, users.user_account							AS user_account
			, currency										AS currency
			, users.tel										AS tel
			, users.last_name								AS last_name
			, users.first_name								AS first_name
			, users.birth									AS birth
			, users.country									AS country
			, users.state									AS state
			, users.city									AS city
			, users.zip_code								AS zip_code
			, users.address									AS address
			, users.address2								AS address2
			, users.bank_name								AS bank_name
			, users.branch_name								AS branch_name
			, users.branch_number							AS branch_number
			, users.account_number							AS account_number
			, users.account_name							AS account_name
			, users.admin_flg								AS admin_flg
			, users.status									AS status
			, users.kyc_flg									AS kyc_flg
			, agent_flg										AS agent_flg
			, agent_code									AS agent_code
			, DATE_FORMAT(users.create_time, '%Y/%m/%d')	AS create_time_string
			, users.apply_email								AS apply_email
			, users.apply_time								AS apply_time
			, users.veri_apply_flg							AS veri_apply_flg
			, users.veri_apply_time							AS veri_apply_time
			, users.mail_send_flg							AS mail_send_flg
			, kyc.k_id										AS k_id
			, kyc.old_filename								AS old_filename
			, kyc.save_filename								AS save_filename
			, kyc.file_type									AS file_type
			, kyc.veri_flg									AS veri_flg
			, kyc.status									AS status
			, kyc.create_time								AS create_time
		FROM
			t_kyc		AS  kyc
			LEFT OUTER JOIN
				v_users_active	AS users
			ON(users.user_account = kyc.user_account)
		WHERE
			kyc.user_account = '__ELEMENT01__'
		ORDER BY
			kyc.create_time DESC
	</SELECT_KYC>

	<!--
		KYC確認書類の取得（1件）
		条　件：KYC番号
	-->
	<SELECT_KYC_BY_K_ID>
		SELECT
			users.u_id										AS u_id
			, users.user_name								AS user_name
			, users.password								AS password
			, users.mail									AS mail
			, users.account_type							AS account_type
			, users.user_account							AS user_account
			, currency										AS currency
			, users.tel										AS tel
			, users.last_name								AS last_name
			, users.first_name								AS first_name
			, users.birth									AS birth
			, users.country									AS country
			, users.state									AS state
			, users.city									AS city
			, users.zip_code								AS zip_code
			, users.address									AS address
			, users.address2								AS address2
			, users.bank_name								AS bank_name
			, users.branch_name								AS branch_name
			, users.branch_number							AS branch_number
			, users.account_number							AS account_number
			, users.account_name							AS account_name
			, users.admin_flg								AS admin_flg
			, users.status									AS status
			, users.kyc_flg									AS kyc_flg
			, agent_flg										AS agent_flg
			, agent_code									AS agent_code
			, DATE_FORMAT(users.create_time, '%Y/%m/%d')	AS create_time_string
			, users.apply_email								AS apply_email
			, users.apply_time								AS apply_time
			, users.veri_apply_flg							AS veri_apply_flg
			, users.veri_apply_time							AS veri_apply_time
			, users.mail_send_flg							AS mail_send_flg
			, kyc.k_id										AS k_id
			, kyc.old_filename								AS old_filename
			, kyc.save_filename								AS save_filename
			, kyc.file_type									AS file_type
			, kyc.veri_flg									AS veri_flg
			, kyc.status									AS status
			, kyc.create_time								AS create_time
		FROM
			t_kyc		AS  kyc
			LEFT OUTER JOIN
				v_users_active	AS users
			ON(users.user_account = kyc.user_account)
		WHERE
			kyc.k_id = '__ELEMENT01__'
	</SELECT_KYC_BY_K_ID>
	<!--
		KYCステータスの更新
		更新値：KYCステータス
		条　件：KYCID
	-->
	<UPDATE_KYC_ADMIN_IMAGE_STATUS>
		UPDATE
			t_kyc
		SET
			status	= '__ELEMENT01__'
		WHERE
			k_id 	= '__ELEMENT02__'
	</UPDATE_KYC_ADMIN_IMAGE_STATUS>

	<!--
		KYCステータスの更新
		更新値：KYCステータス
		条　件：KYCID
	-->
	<DELETE_KYC_ADMIN_IMAGE_RECORDS>
		DELETE
		FROM
			t_kyc
		WHERE
			k_id 	= '__ELEMENT01__'
	</DELETE_KYC_ADMIN_IMAGE_RECORDS>

	<!--
		KYCステータスの更新
		更新値：KYCステータス
		条　件：KYCID
	-->
	<UPDATE_KYC_ADMIN_ALL_STATUS>
		UPDATE
			t_user
		SET
			kyc_validate_status	= '__ELEMENT01__'
			, process_time 		= '__ELEMENT03__'
		WHERE
			__ELEMENT02__
	</UPDATE_KYC_ADMIN_ALL_STATUS>
	<!--
		KYCステータスの更新
		更新値：KYCステータス
		条　件：KYCID
	-->
	<UPDATE_USER_VALIDATE_STATUS>
		UPDATE
			t_user
		SET
			kyc_validate_status	= '0'
			, process_time 		= '__ELEMENT01__'
		WHERE
			user_account 	 	= '__ELEMENT02__'
	</UPDATE_USER_VALIDATE_STATUS>

	<!--
		KYCステータスの更新
		更新値：KYCステータス
		条　件：KYCID
	-->
	<UPDATE_KYC_ADMIN_DETAIL_STATUS>
		UPDATE
			t_user
		SET
			kyc_validate_status			= '__ELEMENT01__'
			,kyc_comment 				= '__ELEMENT02__'
			, process_time 				= '__ELEMENT03__'
			, kyc_status_update_counter = kyc_status_update_counter + 1
		WHERE
			user_account 		= '__ELEMENT04__'
	</UPDATE_KYC_ADMIN_DETAIL_STATUS>

	<!--
		KYCステータスの更新
		更新値：KYCステータス
		条　件：KYCID
	-->
	<UPDATE_KYC_STATUS>
		UPDATE
			t_kyc
		SET
			status	= '__ELEMENT02__'
		WHERE
			k_id	= '__ELEMENT01__'
	</UPDATE_KYC_STATUS>

	<!--
		ユーザステータスの更新
		更新値：ユーザステータス
		条　件：口座番号
	-->
	<UPDATE_USER_STATUS>
		UPDATE
			t_user
		SET
			status				= '__ELEMENT02__',
			kyc_validate_status = '11'
		WHERE
			user_account	= '__ELEMENT01__'
	</UPDATE_USER_STATUS>

	<UPDATE_USER_LIFT_DATE>
		UPDATE
			t_user
		SET
			last_lift_date = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			user_account	= '__ELEMENT01__'
	</UPDATE_USER_LIFT_DATE>

	<SELECT_USER_STATUS>
		SELECT
			status
		FROM
			t_user
		WHERE
			user_account	= '__ELEMENT01__'
	</SELECT_USER_STATUS>

	<SELECT_USER_TRANSFER_FLG>
		SELECT
			transfer_flg
		FROM
			t_user
		WHERE
			user_account	= '__ELEMENT01__'
	</SELECT_USER_TRANSFER_FLG>

	<!--
		引き落しの取得
		条　件：なし
		
		2019/04/15
		anton
	-->
	<LIST_REQUEST>
		SELECT
			request.r_id					AS r_id
			, request.from_account			AS from_account
			, from_user.user_name			AS from_user_name
			, request.to_account			AS to_account
			, to_user.user_name				AS to_user_name
			, from_user.test_account_flg	AS from_test_account_flg
			, to_user.test_account_flg		AS to_test_account_flg
			, request.currency				AS currency
			, request.amount				AS amount
			, request.to_fee				AS to_fee
			, request.update_time			AS update_time
			, request.debit_currency		AS debit_currency
			, request.debit_amount			AS debit_amount
			, request.rate					AS rate
			, request.from_fee				AS from_fee
			, request.message				AS message
			, request.status				AS status
			, request.create_time			AS create_time
			, request.transaction_number	AS transaction_number
		FROM
			t_request	AS request
			INNER JOIN
				v_users_all	AS from_user
			ON(request.from_account = from_user.user_account)
			INNER JOIN
				v_users_all	AS to_user
			ON(request.to_account = to_user.user_account)
		WHERE
			1 __ELEMENT01__
			AND (from_user.admin_flg = 0 AND from_user.status in (2,3,4,5,6,7))
			AND (to_user.admin_flg = 0 AND to_user.status in (2,3,4,5,6,7))
		ORDER BY
			create_time DESC
			, update_time DESC
	</LIST_REQUEST>
    <!--
		引き落しの取得
		条　件：なし
	-->
	<LIST_REQUEST_LIMIT>
		SELECT
			request.r_id					AS r_id
			, request.from_account			AS from_account
			, from_user.user_name			AS from_user_name
			, request.to_account			AS to_account
			, to_user.user_name				AS to_user_name
			, request.currency				AS currency
			, request.amount				AS amount
			, request.to_fee				AS to_fee
			, request.update_time			AS update_time
			, request.debit_currency		AS debit_currency
			, request.debit_amount			AS debit_amount
			, request.rate					AS rate
			, request.from_fee				AS from_fee
			, request.message				AS message
			, request.status				AS status
			, request.create_time			AS create_time
			, request.transaction_number	AS transaction_number
		FROM
			t_request	AS request
			INNER JOIN
				v_users_all	AS from_user
			ON(request.from_account = from_user.user_account)
			INNER JOIN
				v_users_all	AS to_user
			ON(request.to_account = to_user.user_account)
		WHERE
			1 __ELEMENT01__
			AND (from_user.admin_flg = 0 AND from_user.status in (2,3,4,5,6,7))
			AND (to_user.admin_flg = 0 AND to_user.status in (2,3,4,5,6,7))
		ORDER BY

			create_time DESC
			, update_time DESC
			LIMIT __ELEMENT02__, __ELEMENT03__
	</LIST_REQUEST_LIMIT>

	<!-- 総数の引き落とし一覧 -->
	<LIST_REQUEST_COUNT>
		SELECT count(*) as 'listCount'
		FROM	
			t_request	AS request
			INNER JOIN
				v_users_all	AS from_user
			ON(request.from_account = from_user.user_account)
			INNER JOIN
				v_users_all	AS to_user
			ON(request.to_account = to_user.user_account) 
			WHERE
			1 __ELEMENT01__
			AND (from_user.admin_flg = 0 AND from_user.status in (2,3,4,5,6,7))
			AND (to_user.admin_flg = 0 AND to_user.status in (2,3,4,5,6,7))
	</LIST_REQUEST_COUNT>


	<!--
		引き落しの取得
		条　件：引き落としID
	-->
	<!--
		引き落しの取得
		条　件：引き落としID
		
		2019/04/15
		anton
	-->
	<SELECT_REQUEST>
		SELECT
			request.r_id				AS r_id
			, request.from_account		AS from_account
			, from_user.user_name		AS from_user_name
			, from_user.first_name		AS from_first_name
			, from_user.last_name		AS from_last_name
			, from_user.account_type	AS from_account_type
			, request.to_account		AS to_account
			, to_user.user_name			AS to_user_name
			, to_user.first_name		AS to_first_name
			, to_user.last_name			AS to_last_name
			, to_user.account_type		AS to_account_type
			, request.currency			AS currency
			, request.amount			AS amount
			, request.message			AS message
			, request.status			AS status
			, request.create_time		AS create_time
			, request.update_time		AS update_time
			, request.debit_currency	AS debit_currency
			, request.debit_amount		AS debit_amount
			, request.rate				AS rate
			, request.from_fee			AS from_fee
			, request.to_fee			AS to_fee
			, request.message			AS message
			, request.send_message		AS send_message
			, request.comment			AS comment
			, request.transaction_number AS transaction_number
		FROM
			t_request			AS request
			LEFT OUTER JOIN
				v_users_all	AS from_user
			ON(request.from_account = from_user.user_account)
			LEFT OUTER JOIN
				v_users_all	AS to_user
			ON(request.to_account = to_user.user_account)
		WHERE
			request.r_id = '__ELEMENT01__'
			AND (from_user.admin_flg = 0 AND from_user.status in (2,3,4,5,6,7))
			AND (to_user.admin_flg = 0 AND to_user.status in (2,3,4,5,6,7))
	</SELECT_REQUEST>

	<!--
		引き落しの管理者コメントを更新する
		更新値：管理者コメント
		条　件：引き落としID
	-->
	<UPDATE_REQUEST_COMMENT>
		UPDATE
			t_request
		SET
			comment = '__ELEMENT02__'
		WHERE
			r_id = '__ELEMENT01__'
	</UPDATE_REQUEST_COMMENT>

	<!--
		ログイン履歴の登録
		登録値：UID
				接続IPアドレス
				ユーザエージェント
	-->
	<INSERT_LOGIN_HIOSTORY>
		INSERT INTO t_login_history (
			u_id
			, ip_address
			, user_agent
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_LOGIN_HIOSTORY>

	<!--
		ログイン履歴の登録
		登録値：UID
				接続IPアドレス
				ユーザエージェント
	-->
	<INSERT_ACTIVITY>
		INSERT INTO t_login_history (
			u_id
			, ip_address
			, user_agent
			, transaction_type
			, create_time
			, details
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
		)
	</INSERT_ACTIVITY>

	<!--
		最終ログイン時間の更新
		更新値：なし
		条　件：UID
	-->
	<UPDATE_LAST_LOGIN_TIME>
		UPDATE
			t_user
		SET
			last_login_time = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			u_id = '__ELEMENT01__'
	</UPDATE_LAST_LOGIN_TIME>

	<!--
		国マスタの取得
		条　件：言語
	-->
	<LIST_MST_COUNTRY>
		SELECT
			c_id
			, country
			, langage
			, country_code
			, phone_code
		FROM
			t_mst_country
		WHERE
			langage = '__ELEMENT01__'
		ORDER BY
			country
	</LIST_MST_COUNTRY>

	<SELECT_MST_COUNTRY>
		SELECT
			c_id
			, country
			, langage
			, country_code
			, phone_code
		FROM
			t_mst_country
		WHERE
			country_code = '__ELEMENT01__'
		ORDER BY
			country
	</SELECT_MST_COUNTRY>

	<!--
		通貨マスタの取得
		条　件：なし
	-->
	<LIST_MST_CURRENCY_ACTIVE>
		SELECT
			c_id
			, currency_name
			, digit
		FROM
			t_mst_currency
		WHERE
			c_id > 0
	</LIST_MST_CURRENCY_ACTIVE>

	<!--
		WLマスタの取得
		条　件：なし
	-->
	<LIST_MST_WHITE_LABEL>
		SELECT
			wl_id
			, wl_name
		FROM
			t_mst_white_label
	</LIST_MST_WHITE_LABEL>

	<!--
		口座バランスを取得する
		条　件：ユーザ口座番号
	-->
	<SELECT_USER_BALANCES>
        SELECT
            data.user_account											AS user_account
            , data.from_currency										AS currency
            , SUM(data.deposit_amount)									AS deposit_amount
            , SUM(data.withdraw_amount)									AS withdraw_amount
            , (SUM(data.deposit_amount) - SUM(data.withdraw_amount))	AS balance
        FROM (
                SELECT												/* 入金 */
                    deposit.user_account							AS user_account
                    , deposit.currency								AS from_currency
                    , deposit.amount								AS deposit_amount
                    , fee											AS withdraw_amount
                FROM
                    t_deposit	AS deposit
                WHERE
                    CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > deposit_date
                    AND user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 通常出金 */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , 0 											AS deposit_amount
                    , (withdraw.debit_amount + fee)					AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status 		&lt;= '3'
                    AND (type = '0' OR type = '3' OR type = '1')
                    AND user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 両替（入金） */
                    exchange.user_account							AS user_account
                    , exchange.currency								AS from_currency
                    , (exchange.amount) 							AS deposit_amount
                    , 0												AS withdraw_amount
                FROM
                    t_exchange	AS exchange
                WHERE
                    user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 両替（出金） */
                    exchange.user_account							AS user_account
                    , exchange.debit_currency						AS from_currency
                    , 0												AS deposit_amount
                    , (exchange.debit_amount) 						AS withdraw_amount
                FROM
                    t_exchange	AS exchange
                WHERE
                    user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 口座振替（入金） */
                    transfer_deposit.to_account						AS user_account
                    , transfer_deposit.transfer_currency			AS from_currency
                    , transfer_deposit.transfer_amount				AS deposit_amount
                    , to_fee										AS withdraw_amount
                FROM
                    t_transfer	AS transfer_deposit
                WHERE
                    to_account = '__ELEMENT01__'
                    AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > transfer_deposit.create_time
                UNION ALL
                SELECT												/* 口座振替（出金） */
                    transfer_withdraw.user_account					AS user_account
                    , transfer_withdraw.debit_currency				AS from_currency
                    , 0												AS deposit_amount
                    , (transfer_withdraw.debit_amount + from_fee)	AS withdraw_amount
                FROM
                    t_transfer	AS transfer_withdraw
                WHERE
                    user_account = '__ELEMENT01__'
                    AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > transfer_withdraw.create_time
                UNION ALL
                SELECT												/* 引き落とし（入金） */
                    requestr_deposit.to_account						AS user_account
                    , requestr_deposit.currency						AS from_currency
                    , requestr_deposit.amount 						AS deposit_amount
                    , to_fee										AS withdraw_amount
                FROM
                    t_request	AS requestr_deposit
                WHERE
                    status = 1
                    AND to_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 引き落とし（出金） */
                    request_withdraw.from_account					AS user_account
                    , request_withdraw.debit_currency				AS from_currency
                    , 0												AS deposit_amount
                    , (request_withdraw.debit_amount + from_fee)	AS withdraw_amount
                FROM
                    t_request	AS request_withdraw
                WHERE
                    status = 1
                    AND from_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 出金（組戻し） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , (withdraw.debit_amount + fee + fee_refund)	AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '4'
                    AND user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 出金（キャンセル） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , (withdraw.debit_amount + fee)					AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '6'
                    AND user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 出金（キャンセル） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , fee											AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '2'
                    AND type = '11'
                    AND user_account = '__ELEMENT01__'
            ) AS data
        GROUP BY
            data.from_currency
	</SELECT_USER_BALANCES>

	<!--
		口座バランスを取得する（両替抜きバージョン）
		条　件：ユーザ口座番号
	-->
	<SELECT_USER_BALANCES_BY_WITHDRAW_LIMIT>
        SELECT
            data.user_account											AS user_account
            , data.from_currency										AS currency
            , SUM(data.deposit_amount)									AS deposit_amount
            , SUM(data.withdraw_amount)									AS withdraw_amount
            , (SUM(data.deposit_amount) - SUM(data.withdraw_amount))	AS balance
        FROM (
                SELECT												/* 入金 */
                    deposit.user_account							AS user_account
                    , deposit.currency								AS from_currency
                    , deposit.amount								AS deposit_amount
                    , 0												AS withdraw_amount
                FROM
                    t_deposit	AS deposit
                WHERE
                    user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 通常出金 */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , 0 											AS deposit_amount
                    , (withdraw.debit_amount)						AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status 		&lt;= '3'
                    AND (type = '0' OR type = '3' OR type = '1')
                    AND user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 口座振替（入金） */
                    transfer_deposit.to_account						AS user_account
                    , transfer_deposit.transfer_currency			AS from_currency
                    , transfer_deposit.transfer_amount				AS deposit_amount
                    , to_fee										AS withdraw_amount
                FROM
                    t_transfer	AS transfer_deposit
                WHERE
                    to_account = '__ELEMENT01__'
                    AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > transfer_deposit.create_time
                UNION ALL
                SELECT												/* 口座振替（出金） */
                    transfer_withdraw.user_account					AS user_account
                    , transfer_withdraw.debit_currency				AS from_currency
                    , 0												AS deposit_amount
                    , (transfer_withdraw.debit_amount)				AS withdraw_amount
                FROM
                    t_transfer	AS transfer_withdraw
                WHERE
                    user_account = '__ELEMENT01__'
                    AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > transfer_withdraw.create_time
                UNION ALL
                SELECT												/* 引き落とし（入金） */
                    requestr_deposit.to_account						AS user_account
                    , requestr_deposit.currency						AS from_currency
                    , requestr_deposit.amount 						AS deposit_amount
                    , 0												AS withdraw_amount
                FROM
                    t_request	AS requestr_deposit
                WHERE
                    status = 1
                    AND to_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 引き落とし（出金） */
                    request_withdraw.from_account					AS user_account
                    , request_withdraw.debit_currency				AS from_currency
                    , 0												AS deposit_amount
                    , (request_withdraw.debit_amount)				AS withdraw_amount
                FROM
                    t_request	AS request_withdraw
                WHERE
                    status = 1
                    AND from_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 出金（組戻し） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , (withdraw.debit_amount)						AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '4'
                    AND user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 出金（キャンセル） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , (withdraw.debit_amount)						AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '6'
                    AND user_account = '__ELEMENT01__'
                UNION ALL
                SELECT												/* 出金（キャンセル） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , fee											AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '2'
                    AND type = '11'
                    AND user_account = '__ELEMENT01__'
            ) AS data
        GROUP BY
            data.from_currency
	</SELECT_USER_BALANCES_BY_WITHDRAW_LIMIT>

	<!--
		口座バランスを取得する（通貨、期間指定バージョン）
		条　件：ユーザ口座番号
	-->
	<LIST_USER_BALANCE_FROM_CURRENCY_DATE>
        SELECT
            data.user_account											AS user_account
            , data.from_currency										AS currency
            , SUM(data.deposit_amount)									AS deposit_amount
            , SUM(data.withdraw_amount)									AS withdraw_amount
            , (SUM(data.deposit_amount) - SUM(data.withdraw_amount))	AS balance
        FROM (
                SELECT												/* 入金 */
                    deposit.user_account							AS user_account
                    , deposit.currency								AS from_currency
                    , deposit.amount								AS deposit_amount
                    , fee											AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_deposit	AS deposit
                WHERE
                    user_account = '__ELEMENT01__'
                    AND currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 通常出金 */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , 0 											AS deposit_amount
                    , (withdraw.debit_amount + fee)					AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status 		&lt;= '3'
                    AND (type		= '0'
                            OR type	= '3'
                            OR type = '1')
                    AND user_account = '__ELEMENT01__'
                    AND debit_currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 両替（入金） */
                    exchange.user_account							AS user_account
                    , exchange.currency								AS from_currency
                    , (exchange.amount) 							AS deposit_amount
                    , 0												AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_exchange	AS exchange
                WHERE
                    user_account = '__ELEMENT01__'
                    AND currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 両替（出金） */
                    exchange.user_account							AS user_account
                    , exchange.debit_currency						AS from_currency
                    , 0												AS deposit_amount
                    , (exchange.debit_amount) 						AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_exchange	AS exchange
                WHERE
                    user_account = '__ELEMENT01__'
                    AND debit_currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 口座振替（入金） */
                    transfer_deposit.to_account						AS user_account
                    , transfer_deposit.transfer_currency			AS from_currency
                    , transfer_deposit.transfer_amount				AS deposit_amount
                    , to_fee										AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_transfer	AS transfer_deposit
                WHERE
                    to_account = '__ELEMENT01__'
                    AND transfer_currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 口座振替（出金） */
                    transfer_withdraw.user_account					AS user_account
                    , transfer_withdraw.debit_currency				AS from_currency
                    , 0												AS deposit_amount
                    , (transfer_withdraw.debit_amount + from_fee)	AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_transfer	AS transfer_withdraw
                WHERE
                    user_account = '__ELEMENT01__'
                    AND debit_currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 引き落とし（入金） */
                    requestr_deposit.to_account						AS user_account
                    , requestr_deposit.currency						AS from_currency
                    , requestr_deposit.amount 						AS deposit_amount
                    , to_fee										AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_request	AS requestr_deposit
                WHERE
                    status = 1
                    AND to_account = '__ELEMENT01__'
                    AND currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 引き落とし（出金） */
                    request_withdraw.from_account					AS user_account
                    , request_withdraw.debit_currency				AS from_currency
                    , 0												AS deposit_amount
                    , (request_withdraw.debit_amount + from_fee)	AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_request	AS request_withdraw
                WHERE
                    status = 1
                    AND from_account = '__ELEMENT01__'
                    AND debit_currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 出金（組戻し） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , (withdraw.debit_amount + fee + fee_refund)	AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '4'
                    AND user_account = '__ELEMENT01__'
                    AND debit_currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 出金（キャンセル） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , (withdraw.debit_amount + fee)					AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '6'
                    AND user_account = '__ELEMENT01__'
                    AND debit_currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
                UNION ALL
                SELECT												/* 出金（キャンセル） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , (withdraw.debit_amount + fee)					AS withdraw_amount
                    , create_time									AS process_time
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '2'
                    AND type = '11'
                    AND user_account = '__ELEMENT01__'
                    AND debit_currency = '__ELEMENT02__'
                    AND '__ELEMENT03__' > create_time
            ) AS data
        GROUP BY
            data.from_currency
	</LIST_USER_BALANCE_FROM_CURRENCY_DATE>

	<!--
		口座履歴を取得する
		条　件：ユーザ口座番号
	-->
	<SELECT_USER_HISTORY>
		SELECT
			data.user_account		AS user_account
			, data.currency			AS currency
			, data.type				AS type
			, data.deposit_amount	AS deposit_amount
			, data.withdraw_amount	AS withdraw_amount
			, data.create_time		AS create_time
		FROM (
				SELECT
					user_account	AS user_account
					, currency		AS currency
					, '入金処理'	AS type
					, amount		AS deposit_amount
					, 0				AS withdraw_amount
					, create_time	AS create_time
				FROM
					t_deposit
				UNION ALL
				SELECT
					user_account	AS user_account
					, currency		AS currency
					, '出金処理'	AS type
					, 0				AS deposit_amount
					, amount		AS withdraw_amount
					, create_time	AS create_time
				FROM
					t_withdraw
			) AS data
		WHERE
			data.user_account = '__ELEMENT01__'
		ORDER BY
			currency
			, create_time DESC
	</SELECT_USER_HISTORY>

	<!--
		メールアドレスの存在確認
		条　件：メールアドレス
	-->
	<EXIST_SITE_USER_MAIL_ADDRESS>
		SELECT
			mails.user_name
		FROM (
			SELECT
				user_name AS user_name
			FROM
				t_login
			UNION ALL
			SELECT
				mail AS user_name
			FROM
				t_user
			) AS mails
		WHERE
			mails.user_name	= '__ELEMENT01__'
	</EXIST_SITE_USER_MAIL_ADDRESS>

	<!--
		メールアドレスの存在確認
		条　件：メールアドレス
	-->
	<EXIST_SITE_USER_MAIL_ADDRESS_ANOTHER>
		SELECT
			user_name
		FROM
			v_users_active
		WHERE
			(user_name	= '__ELEMENT01__'
				OR mail		= '__ELEMENT01__')
			AND user_account != '__ELEMENT02__'
	</EXIST_SITE_USER_MAIL_ADDRESS_ANOTHER>

	<!--
		為替レートの取得
		条　件：なし
	-->
	<SELECT_EXCHANGE_RATE>
		SELECT
			(original_rate - (original_rate * ((IFNULL(mst_exchange_fee.whole, 0) / 10000) + (IFNULL(mst_exchange_fee.markup, 0) / 10000))) )	AS rate
			, original_rate																														AS original_rate
			, mst_exchange_fee.whole																											AS whole
			, mst_exchange_fee.markup																											AS markup
		FROM
			t_exchange_rate			AS exchange_rate
			LEFT OUTER JOIN
				t_mst_exchange_fee	AS mst_exchange_fee
			ON(exchange_rate.from_currency = mst_exchange_fee.from_currency
				AND exchange_rate.to_currency = mst_exchange_fee.to_currency)
		WHERE
			exchange_rate.from_currency		= '__ELEMENT01__'
			AND exchange_rate.to_currency	= '__ELEMENT02__'
			AND mst_exchange_fee.m_f_id		= '__ELEMENT03__'
		LIMIT
			0, 1
	</SELECT_EXCHANGE_RATE>

	<!--
		為替履歴レートの取得
		条　件：なし
	-->
	<SELECT_EXCHANGE_RATE_HISTORY_DATETIME>
		SELECT
			(original_rate - (original_rate * ((IFNULL(mst_exchange_fee.whole, 0) / 10000) + (IFNULL(mst_exchange_fee.markup, 0) / 10000))))	AS rate
			, exchange_rate.original_rate																										AS original_rate
			, exchange_rate.create_time																											AS create_time
		FROM (
				SELECT
					from_currency
					, to_currency
					, rate
					, original_rate
					, create_time
				FROM
					t_exchange_rate
				UNION ALL
				SELECT
					from_currency
					, to_currency
					, rate
					, original_rate
					, create_time
				FROM
					t_exchange_rate_history

			) AS exchange_rate
			LEFT OUTER JOIN
				t_mst_exchange_fee	AS mst_exchange_fee
			ON(exchange_rate.from_currency = mst_exchange_fee.from_currency
				AND exchange_rate.to_currency = mst_exchange_fee.to_currency)
		WHERE
			exchange_rate.from_currency		= '__ELEMENT01__'
			AND exchange_rate.to_currency	= '__ELEMENT02__'
			AND mst_exchange_fee.m_f_id		= '__ELEMENT04__'
			AND '__ELEMENT03__' 			> exchange_rate.create_time
		ORDER BY
			exchange_rate.create_time DESC
		LIMIT
			0, 1
	</SELECT_EXCHANGE_RATE_HISTORY_DATETIME>

	<!--
		為替レートの削除
		条　件：なし
	-->
	<DELETE_EXCHANGE_RATE>
		DELETE
		FROM
			t_exchange_rate
	</DELETE_EXCHANGE_RATE>

	<!--
		為替レートの登録
		登録値：FROM通貨
				TO通貨
				レート
	-->
	<INSERT_EXCHANGE_RATE>
		INSERT INTO t_exchange_rate (
			from_currency
			, to_currency
			, rate
			, original_rate
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_EXCHANGE_RATE>

	<!--
		口座番号の存在チェック
		条　件：口座番号
	-->
	<CHECK_EXIST_ACCOUNT>
		SELECT
			user_account
		FROM
			v_users_active
		WHERE
			user_account = '__ELEMENT01__'
	</CHECK_EXIST_ACCOUNT>

	<!--
		SELEC PATTERN NAME
	-->
	<CHECK_EXIST_PATTERN>
		SELECT
			pattern_name
		FROM
			t_mst_exchange_fee
		WHERE
			pattern_name = '__ELEMENT01__'
	</CHECK_EXIST_PATTERN>

	<!--
		口座番号の存在チェック
		条　件：メールアドレス
	-->
	<CHECK_EXIST_ACCOUNT_FROM_MAIL_ADDRESS>
		SELECT
			user_account
			, account_type
			, CONCAT(first_name, ' ', last_name)	AS user_name
		FROM
			v_users_active
		WHERE
			mail = '__ELEMENT01__'
		OR
			user_account = '__ELEMENT01__'
	</CHECK_EXIST_ACCOUNT_FROM_MAIL_ADDRESS>

	<!--
		ユーザ情報の取得
		条　件：口座番号
		
		2019/04/15
		anton
	-->
	<SELECT_TRANSFER_ACCOUNT_INFO>
		SELECT
			user_account
			, account_number
			, user_name
		FROM
			v_users_all as users
		WHERE
			user_account = '__ELEMENT01__'
			AND users.admin_flg = 0 AND users.status in (2,3,4,5,6,7)
		UNION ALL
		SELECT
			user_account
			, account_number
			, user_name
		FROM
			v_users_all as users
		WHERE
			user_account = '__ELEMENT02__'
			AND admin_flg = 0 AND users.status in (2,3,4,5,6,7)
	</SELECT_TRANSFER_ACCOUNT_INFO>

	<!--
		引落履歴の取得
		条　件：口座番号
	-->
	<LIST_REQUEST_HISTORY>
		SELECT DISTINCT
			from_account
			, mail
		FROM
			t_request 	AS request
			LEFT OUTER JOIN
				t_user	AS users
			ON(request.from_account = users.user_account)
		WHERE
			to_account		= '__ELEMENT01__'
			AND users.u_id	IS NOT NULL
	</LIST_REQUEST_HISTORY>

	<!--
		引落の取得
		条　件：口座番号
	-->
	<LIST_REQUEST_BY_USER>
		SELECT
			request.r_id			AS r_id
			, request.from_account	AS from_account
			, request.to_account	AS to_account
			, request.currency		AS currency
			, request.amount		AS amount
			, request.message		AS message
			, request.status		AS status
			, request.create_time	AS create_time
			, users.mail			AS mail
			, users.last_name		AS last_name
			, users.first_name		AS first_name
		FROM
			t_request 	AS request
			LEFT OUTER JOIN
				t_user	AS users
			ON(request.from_account = users.user_account)
		WHERE
			to_account				= '__ELEMENT01__'
			AND users.u_id			IS NOT NULL
			AND request.hidden_flg	= '0'
		ORDER BY
			create_time DESC
	</LIST_REQUEST_BY_USER>

	<!--
		引落の取得（1件データ）
		条　件：引落番号
	-->
	<LIST_REQUEST_BY_R_ID>
		SELECT
			request.r_id											AS r_id
			, request.transaction_number 							AS transaction_number
			, request.from_account									AS from_account
			, request.to_account									AS to_account
			, request.currency										AS currency
			, request.amount										AS amount
			, request.message										AS message
			, request.status										AS status
			, request.create_time									AS create_time
			, DATE_FORMAT(request.create_time, '%Y/%m/%d %H:%i:%s')	AS create_time_string
			, request.update_time									AS update_time
			, request.debit_currency								AS debit_currency
			, request.debit_amount									AS debit_amount
			, request.rate											AS rate
			, request.send_message									AS send_message
			, request.from_fee										AS from_fee
			, request.to_fee										AS to_fee
			, from_user.account_type								AS from_account_type
			, from_user.mail										AS from_mail
			, from_user.last_name									AS from_last_name
			, from_user.first_name									AS from_first_name
			, to_user.account_type									AS to_account_type
			, to_user.mail											AS to_mail
			, to_user.last_name										AS to_last_name
			, to_user.first_name									AS to_first_name
		FROM
			t_request 	AS request
			LEFT OUTER JOIN
				t_user	AS from_user
			ON(request.from_account = from_user.user_account)
			LEFT OUTER JOIN
				t_user	AS to_user
			ON(request.to_account = to_user.user_account)
		WHERE
			r_id = '__ELEMENT01__'
	</LIST_REQUEST_BY_R_ID>

	<!--
		引落の取得（API用）
		条　件：引落番号
	-->
	<LIST_REQUEST_API_BY_R_ID>
		SELECT
			request.r_id											AS r_id
			, request.to_account									AS to_account
			, request.currency										AS currency
			, request.amount										AS amount
			, request.message										AS message
			, request.status										AS status
			, request.create_time									AS create_time
			, DATE_FORMAT(request.create_time, '%Y/%m/%d %H:%i:%s')	AS create_time_string
			, request.debit_currency								AS debit_currency
			, request.from_fee										AS from_fee
			, to_user.last_name										AS to_last_name
			, to_user.first_name									AS to_first_name
		FROM
			t_request 	AS request
			LEFT OUTER JOIN
				t_user	AS from_user
			ON(request.from_account = from_user.user_account)
			LEFT OUTER JOIN
				t_user	AS to_user
			ON(request.to_account = to_user.user_account)
		WHERE
			r_id = '__ELEMENT01__'
	</LIST_REQUEST_API_BY_R_ID>

	<!--
		引落の取得（申請されたデータ）
		条　件：口座番号
	-->
	<LIST_REQUEST_APPLY_BY_USER>
		SELECT
			request.r_id			AS r_id
			, request.from_account	AS from_account
			, request.to_account	AS to_account
			, request.currency		AS currency
			, request.amount		AS amount
			, request.message		AS message
			, request.status		AS status
			, request.create_time	AS create_time
			, users.mail			AS mail
			, users.last_name		AS last_name
			, users.first_name		AS first_name
		FROM
			t_request 	AS request
			LEFT OUTER JOIN
				t_user	AS users
			ON(request.to_account = users.user_account)
		WHERE
			from_account		= '__ELEMENT01__'
			AND users.u_id		IS NOT NULL
			AND request.status	= '0'
		ORDER BY
			create_time DESC
	</LIST_REQUEST_APPLY_BY_USER>

	<!--
		口座送金先口座履歴の取得
		条　件：口座番号
	-->
	<LIST_TRANSFER_HISTORY>
		SELECT
			COUNT(t_id)	AS counter
			, to_account
		FROM
			t_transfer
		WHERE
			from_account = '__ELEMENT01__'
		GROUP BY
			to_account
		ORDER BY
			counter DESC
	</LIST_TRANSFER_HISTORY>

	<!--
		口座送金先口座履歴の取得
		条　件：口座タイプ
	-->
	<SELECT_COMMISION_BY_ALL_APPLICATION>
		SELECT
			f_id
			, fee_type_name
			, fee_type
			, m_f_id
			, fee_name
			, wallet_type
			, app_flg
			, fee_flg
			, fix
			, percent
			, min_value
			, max_value
		FROM
			v_fees
		WHERE
			fee_type		= '0'
			AND m_f_id		= '__ELEMENT01__'
			AND wallet_type	= '__ELEMENT02__'
	</SELECT_COMMISION_BY_ALL_APPLICATION>

	<!--
		口座送金先口座履歴の取得
		条　件：口座タイプ
	-->
	<SELECT_COMMISION_BY_F_ID>
		SELECT
			f_id
			, fee_type_name
			, fee_type
			, m_f_id
			, fee_name
			, wallet_type
			, app_flg
			, fee_flg
			, fix
			, percent
			, min_value
			, max_value
		FROM
			v_fees
		WHERE
			f_id			= '__ELEMENT01__'
			AND m_f_id		= '__ELEMENT02__'
			AND wallet_type	= '__ELEMENT03__'
	</SELECT_COMMISION_BY_F_ID>

	<!--
		コミッションの登録
		登録値：エージェントコード
				通貨
				金額
	-->
	<INSERT_COMMISION>
		INSERT INTO t_commision (
			agent_code
			, type
			, currency
			, amount
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_COMMISION>

	<!--
		メール変更申請の登録
		登録値：チケット番号
				口座番号
				変更メールアドレス
	-->
	<INSERT_CHANGE_MAIL>
		INSERT INTO t_change_mail (
			chicket
			, user_account
			, mail
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_CHANGE_MAIL>

	<!--
		メール変更申請の取得
		条　件：チケット番号
	-->
	<SELECT_CHANGE_MAIL>
		SELECT
			chicket
			, user_account
			, mail
			, create_time
			, TIMESTAMPDIFF(SECOND, DATE_ADD(create_time, INTERVAL 1 HOUR), CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')) AS diff_time
		FROM
			t_change_mail
		WHERE
			chicket = '__ELEMENT01__'
	</SELECT_CHANGE_MAIL>

	<!--
		手数料を登録する
		登録値：口座番号
				通貨
				金額
				出金タイプ
	-->
	<INSERT_WITHDRAW_FEE>
		INSERT INTO t_withdraw (
			user_account
			, currency
			, fee
			, debit_currency
			, type
			, transaction_number
			, create_time
			, process_time
			, moneyout_solution
			, status
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT02__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT06__'
			, '__ELEMENT07__'
		)
	</INSERT_WITHDRAW_FEE>

	<!--
		出金 戻り時間のチェック
		登録値：
	-->
	<INSERT_WITHDRAW_TIMER>
		INSERT INTO `t_withdraw_timer` (
			`transaction_number`
			, `creat_time`
			, `lang`
		) VALUES (
			'__ELEMENT29__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT32__'
		)
	</INSERT_WITHDRAW_TIMER>

	<!--
		手数料を登録する
		登録値：口座番号
				通貨
				金額
				出金タイプ
	-->
	<INSERT_DEPOSIT_EXCHANGE>
		INSERT INTO t_deposit (
			user_account
			, currency
			, amount
			, type
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_DEPOSIT_EXCHANGE>

	<!--
		ログイン失敗回数を更新する
		条　件：ユーザ名
		更新値：カウンタ
	-->
	<UPDATE_LOGIN_FAIL_COUNT>
		UPDATE
			t_login
		SET
			fail_count = '__ELEMENT02__'
		WHERE
			user_name = '__ELEMENT01__'
	</UPDATE_LOGIN_FAIL_COUNT>

	<!--
		ユーザ名を更新する
		条　件：ユーザ名
		更新値：カウンタ
	-->
	<UPDATE_LOGIN_USER_NAME>
		UPDATE
			t_login
		SET
			user_name = '__ELEMENT02__'
		WHERE
			u_id = '__ELEMENT01__'
	</UPDATE_LOGIN_USER_NAME>

	<!--
		ログイン失敗リストの削除
		条　件：ユーザ名
	-->
	<DELETE_LOGIN_FAIL>
		DELETE
		FROM
			t_login_fail
		WHERE
			user_name = '__ELEMENT01__'
	</DELETE_LOGIN_FAIL>

	<!--
		ログイン失敗リストの取得
		条　件：ユーザ名
	-->
	<SELECT_LOGIN_FAIL>
		SELECT
			l_id																				AS l_id
			, user_name																			AS user_name
			, create_time																		AS create_time
			, TIMESTAMPDIFF(SECOND, create_time, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'))											AS diff_time
			, DATE_FORMAT(SUBTIME(ADDTIME(create_time, '24:00:00'), TIME(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'))), '%H:%i:%S')	AS diff_time_string
		FROM
			t_login_fail
		WHERE
			user_name = '__ELEMENT01__'
	</SELECT_LOGIN_FAIL>

	<!--
		ログイン失敗リストを登録
		登録値：ログインID
	-->
	<INSERT_LOGIN_FAIL>
		INSERT INTO t_login_fail (
			user_name
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_LOGIN_FAIL>

	<!--
		KYCフラグの変更
		変更値：KYCフラグ
		条　件：口座番号
	-->
	<UPDATE_KYC_FLG>
		UPDATE
			t_user
		SET
			kyc_flg = '__ELEMENT02__'
		WHERE
			user_account	= '__ELEMENT01__'
	</UPDATE_KYC_FLG>

	<!--
		KYCフラグの変更（差戻し）
		変更値：KYCフラグ
		条　件：口座番号
	-->
	<UPDATE_KYC_ROLL_BACK>
		UPDATE
			t_kyc
		SET
			status = '0'
		WHERE
			user_account	= '__ELEMENT01__'
			AND status		= '1'
	</UPDATE_KYC_ROLL_BACK>


	<!--
		引き落し申請の削除
		条　件：引き落し申請ID
	-->
	<DELETE_REQUEST>
		DELETE
		FROM
			t_request
		WHERE
			r_id = '__ELEMENT01__'
	</DELETE_REQUEST>

	<!--
		現在時刻の取得
		条　件：なし
	-->
	<SELECT_CURRENT_TIME>
		SELECT
			DATE_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), '%Y/%m/%d %H:%i:%s') AS cur_time
	</SELECT_CURRENT_TIME>

	<!--
		チケットの登録
		条　件：なし
	-->
	<INSERT_CHICKET>
		INSERT INTO t_chicket(
			c_id
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_CHICKET>

	<!--
		チケットの取得
		条　件：なし
	-->
	<SELECT_CHICKET>
		SELECT
			c_id
		FROM
			t_chicket
		WHERE
			c_id = '__ELEMENT01__'
	</SELECT_CHICKET>

	<!--
		チケットの削除
		条　件：なし
	-->
	<DELETE_CHICKET>
		DELETE
		FROM
			t_chicket
		WHERE
			c_id = '__ELEMENT01__'
	</DELETE_CHICKET>

	<!--
		口座開設認証用データの取得
		条　件：UID
	-->
	<SELECT_USER_OF_VERIFCATION>
		SELECT
			user_account								AS user_account
			, status									AS status
			, regist_time								AS regist_time
			, TIMESTAMPDIFF(HOUR, regist_time, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'))	AS diff_time
		FROM
			v_users_all
		WHERE
			u_id = '__ELEMENT01__'
	</SELECT_USER_OF_VERIFCATION>

	<!--
		会社情報の登録
		登録値：UID
				会社情報の登録
				UID
				代表者名
				会社URL
				サービス提供国
				サイト名・屋号
				サイトURL
				責任者名
				責任者メールアドレス
				責任者電話番号
	-->
	<INSERT_CORPORATION>
		INSERT INTO t_corporation (
			u_id
			, ceo_first_name
			, ceo_last_name
			, corp_url
			, target_country
			, site_name
			, site_url
			, manager_name
			, manager_email
			, manager_tel
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
		)
	</INSERT_CORPORATION>

	<!--
		パスワード変更申請の登録
		登録値：UID
				口座番号
				確認コード
	-->
	<INSERT_APPLY_PASSWORD>
		INSERT INTO t_apply_password (
			u_id
			, user_account
			, confirm_code
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_APPLY_PASSWORD>

	<!--
		パスワード変更申請の削除
		登録値：UID
	-->
	<DELETE_APPLY_PASSWORD>
		DELETE
		FROM
			t_apply_password
		WHERE
			u_id = '__ELEMENT01__'
	</DELETE_APPLY_PASSWORD>

	<!--
		パスワード申請データの取得
		条　件：口座番号
	-->
	<SELECT_APPLY_PASSWORD>
		SELECT
			apply_password.u_id											AS u_id
			, apply_password.user_account								AS user_account
			, apply_password.confirm_code								AS confirm_code
			, users.user_name											AS user_name
			, users.last_name											AS last_name
			, users.first_name											AS first_name
			, YEAR(users.birth)											AS birth_year
			, MONTH(users.birth)										AS birth_month
			, DAY(users.birth)											AS birth_day
			, apply_password.confirm_code								AS birth
			, apply_password.create_time								AS create_time
			, TIMESTAMPDIFF(DAY, apply_password.create_time, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'))	AS diff_time
		FROM
			t_apply_password	AS apply_password
			INNER JOIN
				v_users_all		AS users
			ON(apply_password.u_id = users.u_id)
		WHERE
			apply_password.u_id	= '__ELEMENT01__'
	</SELECT_APPLY_PASSWORD>

	<!--
		エージェントコード一覧の取得
		条　件：なし
	-->
	<LIST_AGENT_CODE>
		SELECT
			agent_code
			, user_account
			, mail
		FROM
			t_user
		WHERE
			agent_code				!= ''
			AND agent_code			!= '__ELEMENT01__'
			AND parent_agent_code	!= '__ELEMENT01__'
	</LIST_AGENT_CODE>

	<!--
		ユーザの口座閉鎖日時の更新
		条　件：口座番号
	-->
	<UPDATE_USER_CLOSE_DATE>
		UPDATE
			t_user
		SET
			close_time = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_CLOSE_DATE>

	<UPDATE_USER_SUSPENDED_DATE>
		UPDATE
			t_user
		SET
			suspension_time = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_SUSPENDED_DATE>

	<!--
		一括バッチフラグの更新
		条　件：口座番号
	-->
	<UPDATE_USER_TRANSFER_BATCH_FLG>
		UPDATE
			t_user
		SET
			transfer_batch_flg = '__ELEMENT02__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_TRANSFER_BATCH_FLG>

	<!--
		法人情報を更新する
		条　件：UID
	-->
	<UPDATE_CORPORATION>
		UPDATE
			t_corporation
		SET
			ceo_last_name		= '__ELEMENT02__'
			, ceo_first_name	= '__ELEMENT03__'
			, site_name			= '__ELEMENT04__'
			, site_url			= '__ELEMENT05__'
		WHERE
			u_id = '__ELEMENT01__'
	</UPDATE_CORPORATION>

	<!--
		法人情報を削除する
		条　件：UID
	-->
	<DELETE_CORPORATION>
		DELETE
		FROM
			t_corporation
		WHERE
			u_id = '__ELEMENT01__'
	</DELETE_CORPORATION>

	<!--
		法人情報を更新する
		登録値：UID
				代表者性
				代表者名
				サイト名・屋号
				URL
	-->
	<INSERT_CORPORATION_ADMIN>
		INSERT INTO t_corporation (
			u_id
			, registration_number
			, registration_date
			, ceo_last_name
			, ceo_first_name
			, site_name
			, site_url
			, type_of_usage
			, agreement_status
			, initial_contact_name
			, initial_email_address
			, skype_account
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, IF('__ELEMENT03__' = '', null, '__ELEMENT03__')
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, '__ELEMENT12__'
		)
	</INSERT_CORPORATION_ADMIN>

	<!--
		為替レートの履歴を取得する
		条　件：レートID
				FROM通貨
				TO通貨
				レート
				オリジナルレート
				作成日時
	-->
	<INSERT_EXCHANGE_RATE_HISTORY>
		INSERT INTO t_exchange_rate_history (
			SELECT
				e_id
				, from_currency
				, to_currency
				, rate
				, original_rate
				, create_time
			FROM
				t_exchange_rate
		)
	</INSERT_EXCHANGE_RATE_HISTORY>

	<!--
		為替を登録する
		登録値：口座番号
				FROM通貨
				FROM金額
				TO通貨
				TO金額
	-->
	<INSERT_EXCHANGE>
		INSERT INTO t_exchange (
			user_account
			, debit_currency
			, debit_amount
			, currency
			, amount
			, rate
			, transaction_number
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_EXCHANGE>

	<LIST_EXCHANGE_BY_E_ID>
		SELECT
			exchange.e_id												AS e_id
			, exchange.transaction_number 								AS transaction_number
			, exchange.user_account										AS from_account
			, exchange.debit_currency									AS from_currency
			, exchange.debit_amount										AS debit_amount
			, exchange.create_time										AS create_time
			, exchange.currency											AS to_currency
			, exchange.amount											AS to_amount
			, exchange.rate												AS rate
			, from_user.account_type									AS from_account_type
			, from_user.mail											AS from_mail
			, from_user.last_name										AS from_last_name
			, from_user.first_name										AS from_first_name
		FROM
			t_exchange 	AS exchange
			LEFT OUTER JOIN
				t_user	AS from_user
			ON(exchange.user_account = from_user.user_account)
		WHERE
			transaction_number = '__ELEMENT01__'
	</LIST_EXCHANGE_BY_E_ID>

	<!--
		告知一覧
	-->
	<LIST_NEWS>
		SELECT
			n_id
			, expose_time
			, title
			, body
			, langage
			, site_flg
			, update_time
			, create_time
		FROM
			t_news
		WHERE
			1
		ORDER BY
			expose_time DESC
			,create_time DESC
	</LIST_NEWS>
	<!--
		告知詳細
	-->
	<DETAIL_NEWS>
		SELECT
			n_id
			, expose_time
			, title
			, body
			, langage
			, site_flg
			, update_time
			, create_time
		FROM
			t_news
		WHERE
			n_id = '__ELEMENT01__'
	</DETAIL_NEWS>

	<!--
		告知登録
	-->
	<INSERT_NEWS>
		INSERT INTO t_news (
			expose_time
			, title
			, body
			, langage
			, site_flg
			, update_time
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_NEWS>

	<!--
		告知削除
	-->
	<DELETE_NEWS>
		DELETE FROM
			t_news
		WHERE
			n_id = '__ELEMENT01__'
	</DELETE_NEWS>

	<!--
		告知更新
	-->
	<UPDATE_NEWS>
		UPDATE
			t_news
		SET
			expose_time 	= '__ELEMENT02__'
			, title			= '__ELEMENT03__'
			, body			= '__ELEMENT04__'
			, langage		= '__ELEMENT05__'
			, site_flg		= '__ELEMENT06__'
			, update_time	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			n_id = '__ELEMENT01__'
	</UPDATE_NEWS>
<!-- FAQS -->

	<LIST_FAQS_LANG>
		SELECT 
			faq_id, 
			faq_title,
			faq_content, 
			faq_lang,
			create_time,
			update_time from t_faqs
		WHERE
			faq_lang = '__ELEMENT01__'
		ORDER BY faq_id ASC	 
	</LIST_FAQS_LANG>

	<LIST_FAQS_ALL>
		SELECT 
			faq_id, 
			faq_title,
			faq_content, 
			faq_lang,
			create_time,
			update_time from t_faqs
		ORDER BY faq_id ASC	 
	</LIST_FAQS_ALL>

	<DETAIL_FAQ>
		SELECT 
			faq_id, 
			faq_title,
			faq_content, 
			faq_lang,
			create_time,
			update_time from t_faqs
			where faq_id = '__ELEMENT01__'
	</DETAIL_FAQ>

	<INSERT_FAQ>
		INSERT INTO t_faqs (
			faq_title,
			faq_content,
			faq_lang,
			create_time,
			update_time
		) values (
			'__ELEMENT01__',
			'__ELEMENT02__',
			'__ELEMENT03__',
			CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'),
			CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_FAQ>

	<UPDATE_FAQ>
		UPDATE t_faqs
		SET
			faq_title = '__ELEMENT02__',
			faq_content = '__ELEMENT03__',
			faq_lang = '__ELEMENT04__',
			update_time = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		where
			faq_id = '__ELEMENT01__'	
	</UPDATE_FAQ>

	<DELETE_FAQ>
		DELETE from t_faqs 
		where faq_id = '__ELEMENT01__'
	</DELETE_FAQ>
	<!--
		告知一覧（ユーザ）
	-->
	<LIST_NEWS_USER>
		SELECT
			news.n_id									AS n_id
			, news.expose_time							AS expose_time
			, DATE_FORMAT(news.expose_time, '%Y-%m-%d')	AS expose_time_str
			, DATE_FORMAT(news.expose_time, '%Y-%m-%d')	AS expose_time_tag
			, news.title								AS title
			, news.body									AS body
			, status.read_flg							AS read_flg
		FROM(
			SELECT
				n_id
				, expose_time
				, title
				, body
				, site_flg
				, update_time
				, create_time
			FROM
				t_news
			WHERE
				langage = '__ELEMENT02__'
			ORDER BY
				expose_time DESC
		) AS news
		LEFT OUTER JOIN(
			SELECT
				ns_id
				, n_id
				, user_account
				, read_flg
			FROM
				t_news_status
			WHERE
				user_account = '__ELEMENT01__'
		) AS status
		ON(news.n_id = status.n_id)
		WHERE
			CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') >= news.expose_time
		AND
			news.site_flg = 0
		ORDER BY
			news.expose_time DESC
		LIMIT
			3
	</LIST_NEWS_USER>

	<!--
		告知一覧すべて（ユーザ）
	-->
	<LIST_NEWS_USER_ALL>
		SELECT
			news.n_id									AS n_id
			, news.expose_time							AS expose_time
			, DATE_FORMAT(news.expose_time, '%Y-%m-%d')	AS expose_time_str
			, DATE_FORMAT(news.expose_time, '%Y-%m-%d')	AS expose_time_tag
			, news.title								AS title
			, news.body									AS body
			, status.read_flg							AS read_flg
		FROM(
			SELECT
				n_id
				, expose_time
				, title
				, body
				, site_flg
				, update_time
				, create_time
			FROM
				t_news
			WHERE
				langage = '__ELEMENT02__'
			ORDER BY
				expose_time DESC
		) AS news
		LEFT OUTER JOIN(
			SELECT
				ns_id
				, n_id
				, user_account
				, read_flg
			FROM
				t_news_status
			WHERE
				user_account = '__ELEMENT01__'
		) AS status
		ON(news.n_id = status.n_id)
		WHERE
			CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') >= news.expose_time
		AND
			news.site_flg = 0
		ORDER BY
			news.expose_time DESC
	</LIST_NEWS_USER_ALL>

	<!--
		告知一覧（ユーザ）
	-->
	<CHECK_UNREAD_NEWS_USER>
		SELECT
			news.n_id									AS n_id
			, news.expose_time							AS expose_time
			, DATE_FORMAT(news.expose_time, '%m-%d')	AS expose_time_str
			, DATE_FORMAT(news.expose_time, '%Y-%m-%d')	AS expose_time_tag
			, news.title								AS title
			, news.body									AS body
			, status.read_flg							AS read_flg
		FROM(
			SELECT
				n_id
				, expose_time
				, title
				, body
				, update_time
				, create_time
				, langage
				, site_flg
			FROM
				t_news
			WHERE
				langage = '__ELEMENT02__'
			ORDER BY
				expose_time DESC
		) AS news
		LEFT OUTER JOIN(
			SELECT
				ns_id
				, n_id
				, user_account
				, read_flg
			FROM
				t_news_status
			WHERE
				user_account = '__ELEMENT01__'
		) AS status
		ON(news.n_id = status.n_id)
		WHERE
			status.read_flg IS NULL
		AND
			CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') >= news.expose_time
		AND
			news.langage = '__ELEMENT02__'
		AND
			news.site_flg = 0
		ORDER BY
			news.expose_time DESC
	</CHECK_UNREAD_NEWS_USER>

	<!--
		告知一覧バックナンバー（ユーザ）
	-->
	<LIST_NEWS_BACKNUMBER_USER>
		SELECT
			news.n_id									AS n_id
			, news.expose_time							AS expose_time
			, DATE_FORMAT(news.expose_time, '%Y-%m-%d')	AS expose_time_str
			, DATE_FORMAT(news.expose_time, '%Y-%m-%d')	AS expose_time_tag
			, news.title								AS title
			, news.body									AS body
			, IFNULL(status.read_flg, 0)				AS read_flg
		FROM(
			SELECT
				n_id
				, expose_time
				, title
				, body
				, site_flg
				, update_time
				, create_time
			FROM
				t_news
			WHERE
				langage = '__ELEMENT02__'
		) AS news
		INNER JOIN(
			SELECT
				ns_id
				, n_id
				, user_account
				, read_flg
			FROM
				t_news_status
			WHERE
				user_account = '__ELEMENT01__'
		) AS status
		ON(news.n_id = status.n_id)
		WHERE
			news.site_flg = 0
		ORDER BY
			news.expose_time DESC
	</LIST_NEWS_BACKNUMBER_USER>

	<!--
		未読告知確認（ユーザ）
	-->
	<CHECK_UNREAD_NEWS>
		SELECT
			news.n_id	AS n_id
		FROM(
			SELECT
				n_id
			FROM
				t_news
		) AS news
		INNER JOIN(
			SELECT
				ns_id
				, n_id
				, user_account
				, read_flg
			FROM
				t_news_status
			WHERE
				user_account = '__ELEMENT01__'
		) AS status
		ON(news.n_id = status.n_id)
	</CHECK_UNREAD_NEWS>

	<!--
		お知らせステータスを登録する
		登録値：口座番号
				ニュースID
				ユーザアカウント
				フラグ
	-->
	<INSERT_NEWS_STATUS>
		INSERT INTO t_news_status (
			n_id
			, user_account
			, read_flg
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_NEWS_STATUS>

	<!--
		バッチ集計の削除
		条　件：年
				月
				日
	-->
	<DELETE_TOTAL>
		DELETE
		FROM
			t_total
		WHERE
			YEAR(process_date) 		= '__ELEMENT01__'
			AND MONTH(process_date)	= '__ELEMENT02__'
			AND DAY(process_date)	= '__ELEMENT03__'
	</DELETE_TOTAL>

	<!--
		バッチ集計（入金）
		条　件：年
				月
				日
	-->
	<INSERT_TOTAL_DEPOSIT>
		INSERT INTO  t_total (
			process_date
			, wl_id
			, currency
			, deposit_count
			, deposit_total
		)  (
			SELECT
				CONCAT('__ELEMENT01__', '/', '__ELEMENT02__', '/', '__ELEMENT03__')	AS process_date
				, users.wl_id														AS wl_id
				, deposit.currency													AS currency
				, COUNT(deposit.amount)												AS deposit_count
				, SUM(deposit.amount)												AS deposit_total
			FROM
				t_deposit	AS deposit
				LEFT OUTER JOIN
					t_user	AS users
				ON(deposit.user_account = users.user_account)
			WHERE
				YEAR(deposit.deposit_date) 		= '__ELEMENT01__'
				AND MONTH(deposit.deposit_date)	= '__ELEMENT02__'
				AND DAY(deposit.deposit_date)	= '__ELEMENT03__'
			GROUP BY
				deposit.currency
				, users.wl_id
		)
	</INSERT_TOTAL_DEPOSIT>

	<!--
		バッチ集計（出金）
		条　件：年
				月
				日
	-->
	<INSERT_TOTAL_WITHDRAW_APPLY>
		INSERT INTO  t_total (
			process_date
			, wl_id
			, currency
			, withdraw_apply_count
			, withdraw_apply_total
		)  (
			SELECT
				CONCAT('__ELEMENT01__', '/', '__ELEMENT02__', '/', '__ELEMENT03__')	AS process_date
				, users.wl_id														AS wl_id
				, withdraw.debit_currency											AS currency
				, COUNT(withdraw.debit_amount)										AS withdraw_count
				, SUM(withdraw.debit_amount)										AS withdraw_total
			FROM
				t_withdraw	AS withdraw
				LEFT OUTER JOIN
					t_user	AS users
				ON(withdraw.user_account = users.user_account)
			WHERE
				YEAR(withdraw.process_time) 		= '__ELEMENT01__'
				AND MONTH(withdraw.process_time)	= '__ELEMENT02__'
				AND DAY(withdraw.process_time)		= '__ELEMENT03__'
				AND withdraw.status					= '0'
			GROUP BY
				withdraw.currency
				, users.wl_id
		)
	</INSERT_TOTAL_WITHDRAW_APPLY>

	<!--
		バッチ集計（出金）
		条　件：年
				月
				日
	-->
	<INSERT_TOTAL_WITHDRAW>
		INSERT INTO  t_total (
			process_date
			, wl_id
			, currency
			, withdraw_count
			, withdraw_total
		)  (
			SELECT
				CONCAT('__ELEMENT01__', '/', '__ELEMENT02__', '/', '__ELEMENT03__')	AS process_date
				, users.wl_id														AS wl_id
				, withdraw.debit_currency											AS currency
				, COUNT(withdraw.debit_amount)										AS withdraw_count
				, SUM(withdraw.debit_amount)										AS withdraw_total
			FROM
				t_withdraw	AS withdraw
				LEFT OUTER JOIN
					t_user	AS users
				ON(withdraw.user_account = users.user_account)
			WHERE
				YEAR(withdraw.process_time) 		= '__ELEMENT01__'
				AND MONTH(withdraw.process_time)	= '__ELEMENT02__'
				AND DAY(withdraw.process_time)		= '__ELEMENT03__'
				AND withdraw.status					!= '0'
			GROUP BY
				withdraw.debit_currency
				, users.wl_id
		)
	</INSERT_TOTAL_WITHDRAW>

	<!--
		バッチ集計（口座間送金）
		条　件：年
				月
				日
	-->
	<INSERT_TOTAL_TRANSFER>
		INSERT INTO  t_total (
			process_date
			, wl_id
			, currency
			, transfer_count
			, transfer_total
		)  (
			SELECT
				CONCAT('__ELEMENT01__', '/', '__ELEMENT02__', '/', '__ELEMENT03__')	AS process_date
				, users.wl_id														AS wl_id
				, data.to_currency													AS currency
				, COUNT(data.to_currency)											AS transfer_count
				, SUM(data.to_amount)												AS transfer_total
			FROM (
					SELECT
						transfer_currency		AS to_currency
						, transfer_amount		AS to_amount
						, to_account			AS user_account
					FROM
						t_transfer
					WHERE
						YEAR(create_time) 		= '__ELEMENT01__'
						AND MONTH(create_time)	= '__ELEMENT02__'
						AND DAY(create_time)	= '__ELEMENT03__'
					UNION ALL
					SELECT
						currency				AS to_currency
						, amount				AS to_amount
						, to_account			AS user_account
					FROM
						t_request
					WHERE
						YEAR(update_time) 		= '__ELEMENT01__'
						AND MONTH(update_time)	= '__ELEMENT02__'
						AND DAY(update_time)	= '__ELEMENT03__'
					UNION ALL
					SELECT
						debit_currency			AS to_currency
						, (debit_amount * -1)	AS to_amount
						, from_account			AS user_account
					FROM
						t_transfer
					WHERE
						YEAR(create_time) 		= '__ELEMENT01__'
						AND MONTH(create_time)	= '__ELEMENT02__'
						AND DAY(create_time)	= '__ELEMENT03__'
					UNION ALL
					SELECT
						debit_currency			AS to_currency
						, (debit_amount * -1)	AS to_amount
						, from_account			AS user_account
					FROM
						t_request
					WHERE
						YEAR(update_time) 		= '__ELEMENT01__'
						AND MONTH(update_time)	= '__ELEMENT02__'
						AND DAY(update_time)	= '__ELEMENT03__'
				) AS data
				LEFT OUTER JOIN
					t_user	AS users
				ON(data.user_account = users.user_account)
			GROUP BY
				data.to_currency
				, users.wl_id
		)
	</INSERT_TOTAL_TRANSFER>

	<!--
		バッチ集計（手数料）
		条　件：年
				月
				日
	-->
	<INSERT_TOTAL_FEE>
		INSERT INTO  t_total (
			process_date
			, wl_id
			, currency
			, fee_count
			, fee_total
		)  (
			SELECT
				CONCAT('__ELEMENT01__', '/', '__ELEMENT02__', '/', '__ELEMENT03__')	AS process_date
				, users.wl_id														AS wl_id
				, data.currency														AS currency
				, COUNT(data.currency)												AS fee_count
				, SUM(data.amount)													AS fee_total
			FROM (
					SELECT
						currency				AS currency
						, fee					AS amount
						, user_account			AS user_account
					FROM
						t_deposit
					WHERE
						YEAR(deposit_date) 		= '__ELEMENT01__'
						AND MONTH(deposit_date)	= '__ELEMENT02__'
						AND DAY(deposit_date)	= '__ELEMENT03__'
					UNION ALL
					SELECT
						debit_currency			AS currency
						, (fee + fee_refund)	AS amount
						, user_account			AS user_account
					FROM
						t_withdraw
					WHERE
						YEAR(process_time) 		= '__ELEMENT01__'
						AND MONTH(process_time)	= '__ELEMENT02__'
						AND DAY(process_time)	= '__ELEMENT03__'
					UNION ALL
					SELECT
						debit_currency			AS currency
						, (from_fee)			AS amount
						, from_account			AS user_account
					FROM
						t_transfer
					WHERE
						YEAR(create_time) 		= '__ELEMENT01__'
						AND MONTH(create_time)	= '__ELEMENT02__'
						AND DAY(create_time)	= '__ELEMENT03__'
					UNION ALL
					SELECT
						debit_currency			AS currency
						, (to_fee)				AS amount
						, to_account			AS user_account
					FROM
						t_transfer
					WHERE
						YEAR(create_time) 		= '__ELEMENT01__'
						AND MONTH(create_time)	= '__ELEMENT02__'
						AND DAY(create_time)	= '__ELEMENT03__'
					UNION ALL
					SELECT
						debit_currency			AS currency
						, (from_fee)			AS amount
						, from_account			AS user_account
					FROM
						t_request
					WHERE
						YEAR(update_time) 		= '__ELEMENT01__'
						AND MONTH(update_time)	= '__ELEMENT02__'
						AND DAY(update_time)	= '__ELEMENT03__'
						AND status				= '1'
					UNION ALL
					SELECT
						debit_currency			AS currency
						, (to_fee)				AS amount
						, to_account			AS user_account
					FROM
						t_request
					WHERE
						YEAR(update_time) 		= '__ELEMENT01__'
						AND MONTH(update_time)	= '__ELEMENT02__'
						AND DAY(update_time)	= '__ELEMENT03__'
						AND status				= '1'
				) AS data
				LEFT OUTER JOIN
					t_user	AS users
				ON(data.user_account = users.user_account)
			GROUP BY
				data.currency
				, users.wl_id
		)
	</INSERT_TOTAL_FEE>

	<!--
		バッチ集計（手数料）
		条　件：年
				月
				日
	-->
	<INSERT_TOTAL_EXCHANGE>
		INSERT INTO  t_total (
			process_date
			, wl_id
			, currency
			, exchange_count
			, exchange_total
			, exchange_fee
		)  (
			SELECT
				CONCAT('__ELEMENT01__', '/', '__ELEMENT02__', '/', '__ELEMENT03__')	AS process_date
				, users.wl_id														AS wl_id
				, data.currency														AS currency
				, COUNT(data.currency)												AS transfer_count
				, SUM(data.amount)													AS transfer_total
				, SUM(data.fee)														AS transfer_fee
			FROM (
					SELECT
						debit_currency					AS currency
						, debit_amount					AS amount
						, CASE
							WHEN rate > 1 THEN
								debit_amount - (debit_amount / 1.025)
							WHEN 1 > rate THEN
								(debit_amount / 0.975) - debit_amount
						END 							AS fee
						, user_account					AS user_account
					FROM
						t_exchange
					WHERE
						YEAR(create_time) 		= '__ELEMENT01__'
						AND MONTH(create_time)	= '__ELEMENT02__'
						AND DAY(create_time)	= '__ELEMENT03__'
				) AS data
				LEFT OUTER JOIN
					t_user	AS users
				ON(data.user_account = users.user_account)
			GROUP BY
				data.currency
				, users.wl_id
		)
	</INSERT_TOTAL_EXCHANGE>

	<!--
		バッチ集計の取得
		条　件：なし
	-->
	<LIST_TOTAL>
		SELECT
			process_date				AS process_date
			, currency					AS currency
			, SUM(deposit_count)		AS deposit_count
			, SUM(deposit_total)		AS deposit_total
			, SUM(withdraw_count)		AS withdraw_count
			, SUM(withdraw_apply_count)	AS withdraw_apply_count
			, SUM(withdraw_apply_total)	AS withdraw_apply_total
			, SUM(withdraw_total)		AS withdraw_total
			, SUM(transfer_count)		AS transfer_count
			, SUM(transfer_total)		AS transfer_total
			, SUM(fee_count)			AS fee_count
			, SUM(fee_total)			AS fee_total
			, SUM(exchange_count)		AS exchange_count
			, SUM(exchange_total)		AS exchange_total
			, SUM(exchange_fee)			AS exchange_fee
			, SUM(commision)			AS commision
		FROM
			t_total
		WHERE
			1
			AND currency != ''
		GROUP BY
			process_date
			, currency
		ORDER BY
			process_date DESC
			, currency
	</LIST_TOTAL>

	<!--
		バッチ集計の取得（日付指定）
		条　件：日付
	-->
	<LIST_TOTAL_BY_DATE>
		SELECT
			process_date				AS process_date
			, currency					AS currency
			, SUM(deposit_count)		AS deposit_count
			, SUM(deposit_total)		AS deposit_total
			, SUM(withdraw_count)		AS withdraw_count
			, SUM(withdraw_apply_count)	AS withdraw_apply_count
			, SUM(withdraw_apply_total)	AS withdraw_apply_total
			, SUM(withdraw_total)		AS withdraw_total
			, SUM(transfer_count)		AS transfer_count
			, SUM(transfer_total)		AS transfer_total
			, SUM(fee_count)			AS fee_count
			, SUM(fee_total)			AS fee_total
			, SUM(exchange_count)		AS exchange_count
			, SUM(exchange_total)		AS exchange_total
			, SUM(exchange_fee)			AS exchange_fee
			, SUM(commision)			AS commision
		FROM
			t_total
		WHERE
			1
			AND currency			!= ''
			AND DATE(process_date)	= '__ELEMENT01__'
		GROUP BY
			process_date
			, currency
		ORDER BY
			process_date DESC
			, currency
	</LIST_TOTAL_BY_DATE>

	<!--
		APIシグネチャの取得
		条　件：APIユーザ名
	-->
	<SELECT_API_SIGNATURE>
		SELECT
			a_id
			, user_account
			, user_name
			, password
			, ip_address
			, domain
			, whitelist_setting
		FROM
			t_api_signature
		WHERE
			user_name = '__ELEMENT01__'
	</SELECT_API_SIGNATURE>

	<!--
		APIシグネチャの取得
		条　件：APIユーザ名
	-->
	<SELECT_API_SIGNATURE_BY_USER_ACCOUNT>
		SELECT
			a_id
			, user_account
			, user_name
			, password
			, ip_address
			, domain
			, whitelist_setting
		FROM
			t_api_signature
		WHERE
			user_account = '__ELEMENT01__'
	</SELECT_API_SIGNATURE_BY_USER_ACCOUNT>

	<!--
		APIシグネチャの取得
		条　件：APIID
	-->
	<SELECT_API_SIGNATURE_BY_A_ID>
		SELECT
			a_id
			, user_account
			, user_name
			, password
			, ip_address
			, domains
			, whitelist_setting
		FROM
			t_api_signature
		WHERE
			a_id = '__ELEMENT01__'
	</SELECT_API_SIGNATURE_BY_A_ID>

	<!--
		エージェントコードの取得
		条　件：エージェントコード
	-->
	<SELECT_AGENT_CODE>
		SELECT
			agent_code
		FROM
			t_user
		WHERE
			agent_code = '__ELEMENT01__'
	</SELECT_AGENT_CODE>


	<!--
		口座間振替バッチリストの取得
		条　件：口座間振替バッチリスト
	-->
	<LIST_TRANSFER_BATCH>
		SELECT
			tb_id
			, transaction_id
			, transaction_time
			, create_time
			, old_filename
			, new_filename
			, fail_filename
		FROM
			t_transfer_batch
			WHERE 1 __ELEMENT01__
		ORDER BY
			create_time DESC
	</LIST_TRANSFER_BATCH>

	<!--
		口座間振替バッチリストの登録
		登録値：トランザクションID
				実行日
				アップロードファイル名
				ロードファイル名
	-->
	<INSERT_TRANSFER_BATCH>
		INSERT INTO t_transfer_batch (
			transaction_id
			, transaction_time
			, create_time
			, old_filename
			, new_filename
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT03__'
			, '__ELEMENT04__'
		)
	</INSERT_TRANSFER_BATCH>

	<!--
		口座間振替バッチリストの取得
		条　件：口座間振替バッチリスト
	-->
	<SELECT_TRANSFER_BATCH>
		SELECT
			tb_id
			, transaction_id
			, transaction_time
			, create_time
			, old_filename
			, new_filename
			, fail_filename
		FROM
			t_transfer_batch
		WHERE
			transaction_id = '__ELEMENT01__'
	</SELECT_TRANSFER_BATCH>

	<!--
		口座間振替バッチ実行リストの取得
		条　件：なし
	-->
	<LIST_TRANSFER_BATCH_PROCESS>
		SELECT
			transfer_batch.tb_id				AS tb_id
			, transfer_batch.transaction_id		AS transaction_id
			, transfer_batch.transaction_time	AS transaction_time
			, transfer_batch.create_time		AS create_time
			, transfer_batch.old_filename		AS old_filename
			, transfer_batch.new_filename		AS new_filename
			, transfer_batch.fail_filename		AS fail_filename
		FROM
			t_transfer_batch			AS transfer_batch
			LEFT OUTER JOIN
				t_transfer_batch_detail	AS transfer_batch_detail
			ON(transfer_batch.transaction_id = transfer_batch_detail.transaction_id)
		WHERE
			transfer_batch_detail.t_id IS NOT NULL
	</LIST_TRANSFER_BATCH_PROCESS>

	<!--
		口座間振替バッチ実行リストの取得
		条　件：なし
	-->
	<LIST_TRANSFER_BATCH_DETAIL>
		SELECT
			transfer_batch_detail.t_id					AS t_id
			, transfer_batch_detail.transaction_id		AS transaction_id
			, transfer_batch_detail.transaction_number	AS transaction_number
			, transfer_batch_detail.from_account		AS from_account
			, from_users.last_name						AS from_last_name
			, from_users.first_name						AS from_first_name
			, transfer_batch_detail.to_account			AS to_account
			, to_users.last_name						AS to_last_name
			, to_users.first_name						AS to_first_name
			, transfer_batch_detail.transfer_currency	AS transfer_currency
			, transfer_batch_detail.debit_currency		AS debit_currency
			, transfer_batch_detail.debit_amount		AS debit_amount
			, transfer_batch_detail.from_fee			AS from_fee
			, transfer_batch_detail.to_fee				AS to_fee
			, transfer_batch_detail.message				AS message
			, transfer_batch_detail.transaction_id		AS transaction_id
			, transfer_batch_detail.old_filename 		AS old_filename 
		FROM
			t_transfer_batch_detail	AS transfer_batch_detail
			LEFT OUTER JOIN
				v_users_all			AS from_users
			ON(transfer_batch_detail.user_account = from_users.user_account)
			LEFT OUTER JOIN
				v_users_all			AS to_users
			ON(transfer_batch_detail.to_account = to_users.user_account)
		WHERE
			transaction_id	= '__ELEMENT01__'
	</LIST_TRANSFER_BATCH_DETAIL>

	<!--
		口座間振替バッチ実行登録
		条　件：なし
	-->
	<INSERT_FROM_BATCH_TO_TRANSFER>
		INSERT INTO t_transfer (transaction_number
				, transaction_id
				, user_account
				, from_currency
				, from_account
				, from_fee
				, to_currency
				, to_account
				, to_fee
				, currency
				, amount
				, debit_currency
				, debit_amount
				, transfer_currency
				, transfer_amount
				, rate
				, transfer_type
				, process_type
				, process_status
				, admin_id
				, message
				, create_time
				, old_filename
				, new_filename
				, err_flg) 
			( SELECT
				transaction_number
				, transaction_id
				, user_account
				, from_currency
				, from_account
				, from_fee
				, to_currency
				, to_account
				, to_fee
				, currency
				, amount
				, debit_currency
				, debit_amount
				, transfer_currency
				, transfer_amount
				, rate
				, transfer_type
				, process_type
				, process_status
				, admin_id
				, message
				, create_time
				, old_filename
				, new_filename
				, err_flg
			FROM
				t_transfer_batch_detail
			WHERE
				t_id = '__ELEMENT01__'
		)
	</INSERT_FROM_BATCH_TO_TRANSFER>

	<!--
		口座間振替バッチ実行登録
		条　件：なし
	-->
	<DELETE_TRANSFER_BATCH_DETAIL>
		DELETE
		FROM
			t_transfer_batch_detail
		WHERE
			t_id = '__ELEMENT01__'
	</DELETE_TRANSFER_BATCH_DETAIL>

	<!--
		口座間振替バッチ削除
		条　件：なし
	-->
	<DLETE_TRANSFER_BATCH>
		DELETE
		FROM
			t_transfer_batch
		WHERE
			transaction_id = '__ELEMENT01__'
	</DLETE_TRANSFER_BATCH>

	<!--
		口座間振替バッチ削除（詳細）
		条　件：なし
	-->
	<DLETE_TRANSFER_DETAIL>
		DELETE
		FROM
			t_transfer_batch_detail
		WHERE
			transaction_id = '__ELEMENT01__'
	</DLETE_TRANSFER_DETAIL>

	<!--
		口座間振替バッチ削除（詳細）
		条　件：なし
	-->
	<UPDATE_TRANSFER_BATCH_ERROR_FILE>
		UPDATE
			t_transfer_batch
		SET
			fail_filename = '__ELEMENT02__'
		WHERE
			transaction_id = '__ELEMENT01__'
	</UPDATE_TRANSFER_BATCH_ERROR_FILE>

	<!--
		口座間振替更新（メッセージ）
		条　件：TID
	-->
	<UPDATE_TRANSFER_MESSAGE>
		UPDATE
			t_transfer
		SET
			note = '__ELEMENT02__'
		WHERE
			t_id = '__ELEMENT01__'
	</UPDATE_TRANSFER_MESSAGE>

	<!--
		管理者操作ログの取得
		条　件：なし
	-->
	<LIST_ADMIN_LOG>
		SELECT
			login_history.u_id					AS u_id
			, users_admin.user_account			AS user_account
			, users_admin.first_name			AS first_name
			, users_admin.last_name				AS last_name
			, login_history.ip_address			AS ip_address
			, login_history.user_agent			AS user_agent
			, login_history.transaction_type	AS transaction_type
			, login_history.create_time			AS create_time
			, login_history.details			    AS details
		FROM
			v_users_admin		AS users_admin
			INNER JOIN
				t_login_history	AS login_history
			ON(users_admin.u_id = login_history.u_id)
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			create_time DESC
			__ELEMENT02__
	</LIST_ADMIN_LOG>

	<!--
		エージェント手数料の登録
		登録値：エージェントコード
				手数料マスタID
				手数料タイプ
				エージェント
				マスター

	-->
	<INSERT_AGENT_COMMISION_FEE>
		INSERT INTO t_agent_commision (
			agent_code
			, m_f_id
			, wallet_type
			, currency
			, percent
			, fix
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_AGENT_COMMISION_FEE>

	<!--
		バッチ集計（コミッション）
		条　件：年
				月
				日
	-->
	<INSERT_TOTAL_COMMISION>
		INSERT INTO  t_total (
			process_date
			, currency
			, commision
		)  (
			SELECT
				CONCAT('__ELEMENT01__', '/', '__ELEMENT02__', '/', '__ELEMENT03__')	AS process_date
				, currency															AS currency
				, (SUM(percent) + SUM(fix))											AS deposit_total
			FROM
				t_agent_commision
			WHERE
				YEAR(create_time) 		= '__ELEMENT01__'
				AND MONTH(create_time)	= '__ELEMENT02__'
				AND DAY(create_time)	= '__ELEMENT03__'
			GROUP BY
				currency
		)
	</INSERT_TOTAL_COMMISION>

	<!--
		ユーザカードの取得
		条　件：口座番号
	-->
	<LIST_USER_CARDS>
		SELECT
			c_id
			, user_account
			, card_holder_id
			, card_number
			, digit
			, proxy
			, expire_date
			, create_time
		FROM
			t_user_cards
		WHERE
			user_account = '__ELEMENT01__'
		ORDER BY
			create_time
	</LIST_USER_CARDS>

	<!-- Mikko 2019 0312 start -->
	<SELECT_USER_LINK>
		SELECT
			  userlink.user_1 		AS user_1
			, userlink.user_2 		AS user_2
			, user_1.user_account	AS account_1
			, user_2.user_account	AS account_2
			, user_1.first_name		AS first_name
			, user_2.first_name		AS first_name_2
			, user_1.last_name		AS last_name
			, user_2.last_name		AS last_name_2
			, userlink.l_id			AS l_id
		FROM
			t_user_link				AS  userlink
		LEFT OUTER JOIN
			t_user 	  				AS 	user_1
		ON(userlink.user_1 = user_1.user_account)
		LEFT OUTER JOIN
			t_user 	  				AS 	user_2
		ON(userlink.user_2 = user_2.user_account)
		WHERE
			userlink.user_1 = '__ELEMENT01__'
		OR
			userlink.user_2 = '__ELEMENT01__'
	</SELECT_USER_LINK>

	<DELETE_USER_LINK>
		DELETE
		FROM
			t_user_link
		WHERE
			l_id = '__ELEMENT01__'
	</DELETE_USER_LINK>

	<SELECT_ACCOUNT_LINK>
		SELECT
			user_1
			, user_2
		FROM
			t_user_link
		WHERE

			(user_1 = '__ELEMENT01__'
		AND
			user_2 = '__ELEMENT02__')
		OR
			(user_1 = '__ELEMENT02__'
		AND
			user_2 = '__ELEMENT01__')

	</SELECT_ACCOUNT_LINK>

	<!-- Mikko 2019 0312 end-->

	<!--
		ユーザカードの取得
		条　件：口座番号
				カードID
	-->
	<LIST_USER_CARDS_BY_CARD_ID>
		SELECT
			c_id
			, user_account
			, card_holder_id
			, digit
			, proxy
			, expire_date
			, create_time
		FROM
			t_user_cards
		WHERE
			user_account		= '__ELEMENT01__'
			AND card_holder_id	= '__ELEMENT02__'
	</LIST_USER_CARDS_BY_CARD_ID>

	<!--
		ユーザカードの取得
		条　件：口座番号
	-->
	<SELECT_USER_CARDS>
		SELECT
			c_id
			, user_account
			, card_holder_id
			, card_number
			, digit
			, proxy
			, create_time
		FROM
			t_user_cards
		WHERE
			card_holder_id = '__ELEMENT01__'
	</SELECT_USER_CARDS>

	<!--
		ユーザカードの取得（CHIDとカード番号バージョン）
		条　件：口座番号
	-->
	<SELECT_USER_CARD_BY_CHID_CARD_NUMBER>
		SELECT
			c_id
			, user_account
			, card_holder_id
			, digit
			, create_time
		FROM
			t_user_cards
		WHERE
			card_holder_id	= '__ELEMENT01__'
			OR card_number	= '__ELEMENT02__'
	</SELECT_USER_CARD_BY_CHID_CARD_NUMBER>

	<!--
		ユーザカードの登録
		条　件：口座番号
				カードホルダーID
				カード下4桁
	-->
	<INSERT_USER_CARDS>
		INSERT INTO t_user_cards (
			user_account
			, card_holder_id
			, digit
			, card_number
			, proxy
			, expire_date
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_USER_CARDS>


	<!--Mikko 2019-->
	<INSERT_USER_LINK>
		INSERT INTO t_user_link (
			user_1
			, user_2
			, create_time
		) VALUES 
		__ELEMENT01__
	</INSERT_USER_LINK>

	<!--
		ユーザカードの削除
		条　件：カードホルダーID
	-->
	<DELETE_USER_CARDS>
		DELETE
		FROM
			t_user_cards
		WHERE
			card_holder_id = '__ELEMENT01__'
	</DELETE_USER_CARDS>

	<!--
		カード番号の取得
		条　件：カードホルダーID
	-->
	<SELECT_CARD_BY_CARD_HOLDER_ID>
		SELECT
			c_id
			, user_account
			, card_holder_id
			, card_number
			, digit
			, proxy
			, expire_date
			, create_time
		FROM
			t_user_cards
		WHERE
			card_holder_id = '__ELEMENT01__'
	</SELECT_CARD_BY_CARD_HOLDER_ID>

	<!--
		エージェントの登録（更新）
		更新値：エージェントコード
				親エージェントコード
		条　件：口座番号
	-->
	<UPDATE_AGENT_USER>
		UPDATE
			t_user
		SET
			agent_code			= '__ELEMENT02__'
			, parent_agent_code	= '__ELEMENT03__'
			, agent_flg			= '__ELEMENT04__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_AGENT_USER>

	<!--
		API利用ユーザの取得
		条　件：なし
	-->
	<LIST_API_SIGNATURE>
		SELECT
			api_signature.a_id					AS a_id
			, api_signature.user_name			AS user_name
			, api_signature.password			AS password
			, api_signature.user_account		AS user_account
			, IFNULL(users.first_name, '')		AS first_name
			, IFNULL(users.last_name, '')		AS last_name
			, api_signature.ip_address			AS ip_address
			, api_signature.create_time			AS create_time
			, api_signature.domains				AS domains
			, api_signature.whitelist_setting	AS whitelist_setting
		FROM
		t_api_signature AS api_signature
		LEFT OUTER JOIN
			(SELECT user_account, first_name, last_name FROM v_users_all) AS users
		ON(users.user_account = api_signature.user_account)
		ORDER BY `api_signature`.`a_id`
	</LIST_API_SIGNATURE>

	<!-- Mark -->
	<LIST_API_SIGNATURE_REVISED>
		SELECT
			api_signature.a_id 					AS a_id,
			api_signature.user_name 			AS user_name,
			api_signature.password 				AS password,
			api_signature.user_account 			AS user_account,
			IFNULL(users.first_name, '') 		AS first_name,
			IFNULL(users.last_name, '') 		AS last_name,
			api_signature.ip_address 			AS ip_address,
			api_signature.create_time 			AS create_time,
			api_signature.domains				AS domains,
			api_signature.whitelist_setting		AS whitelist_setting
		FROM
			t_api_signature AS api_signature
		INNER JOIN
			(
				SELECT
					user_account,
					first_name,
					last_name,
					admin_flg,
					del_flg
				FROM
					t_user
		  	) AS users
		 ON
		 	(
		 		users.user_account = api_signature.user_account
		  		AND admin_flg = 0
		  		AND del_flg = 0
		  	)
		ORDER BY api_signature.a_id
	</LIST_API_SIGNATURE_REVISED>

	<!--
		API利用ユーザの登録
		登録値：シーケンス番号
				口座番号
				ユーザ名
				パスワード
				IPアドレス
	-->
	<INSERT_API_SIGNATURE>
		INSERT INTO t_api_signature (
			a_id
			, user_account
			, user_name
			, password
			, ip_address
			, domains
			, whitelist_setting
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_API_SIGNATURE>

	<!--
		API利用ユーザの更新
		登録値：ユーザ名
				パスワード
				IPアドレス
		条　件：口座番号
	-->
	<UPDATE_API_SIGNATURE>
		UPDATE
			t_api_signature
		SET
			user_name				= '__ELEMENT02__'
			, password				= '__ELEMENT03__'
			, ip_address			= '__ELEMENT04__'
			, domains				= '__ELEMENT05__'
			, whitelist_setting		= '__ELEMENT06__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_API_SIGNATURE>

	<DELETE_API_SIGNATURE>
		DELETE from t_api_signature
		WHERE a_id = '__ELEMENT01__'
	</DELETE_API_SIGNATURE>

	<!--
		Postのログ登録
		登録値：ポストパラメータ
				IPアドレス
				リファラ
	-->
	<INSERT_LOG_POST>
		INSERT INTO t_log_post (
			ip_address
			, p_num
			, url
			, post
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_LOG_POST>

	<!--
		入金データの取得
		条　件：日付
				通貨
	-->
	<LIST_TOTAL_BY_DATE_CURRENCY_DEPOSIT>
		SELECT
			DATE_FORMAT(deposit_date, '%Y/%m/%d')	AS process_date
			, '0'									AS process_type
			, user_account							AS user_account
			, currency								AS currency
			, amount								AS amount
			, transaction_number					AS transaction_number
		FROM
			t_deposit
		WHERE
			DATE(deposit_date)	= '__ELEMENT01__'
			AND currency		= '__ELEMENT02__'
	</LIST_TOTAL_BY_DATE_CURRENCY_DEPOSIT>

	<!--
		出金申請データの取得
		条　件：日付
				通貨
	-->
	<LIST_TOTAL_BY_DATE_CURRENCY_WITHDRAW_APPLY>
		SELECT
			DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_date
			, '1'									AS process_type
			, user_account							AS user_account
			, currency								AS currency
			, amount								AS amount
			, transaction_number					AS transaction_number
		FROM
			t_withdraw
		WHERE
			DATE(process_time)	= '__ELEMENT01__'
			AND currency		= '__ELEMENT02__'
			AND status			= 0
	</LIST_TOTAL_BY_DATE_CURRENCY_WITHDRAW_APPLY>

	<!--
		出金データの取得
		条　件：日付
				通貨
	-->
	<LIST_TOTAL_BY_DATE_CURRENCY_WITHDRAW>
		SELECT
			DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_date
			, '2'									AS process_type
			, user_account							AS user_account
			, debit_currency						AS currency
			, debit_amount							AS amount
			, transaction_number					AS transaction_number
		FROM
			t_withdraw
		WHERE
			DATE(process_time)	= '__ELEMENT01__'
			AND debit_currency	= '__ELEMENT02__'
			AND status			!= 0
	</LIST_TOTAL_BY_DATE_CURRENCY_WITHDRAW>

	<!--
		口座振替データの取得
		条　件：日付
				通貨
	-->
	<LIST_TOTAL_BY_DATE_CURRENCY_TRANSFER>
		SELECT
			DATE_FORMAT(process_date, '%Y/%m/%d')	AS process_date
			, process_type							AS process_type
			, user_account							AS user_account
			, currency								AS currency
			, amount								AS amount
			, transaction_number					AS transaction_number
		FROM (
				SELECT
					transfer_currency		AS currency
					, transfer_amount		AS amount
					, '3'					AS process_type
					, create_time			AS process_date
					, user_account			AS user_account
					, transaction_number	AS transaction_number
				FROM
					t_transfer
				UNION ALL
				SELECT
					currency				AS currency
					, amount				AS amount
					, '4'					AS process_type
					, update_time			AS process_date
					, from_account			AS user_account
					, transaction_number	AS transaction_number
				FROM
					t_request
				WHERE
					status = '1'
				UNION ALL
				SELECT
					debit_currency			AS currency
					, (debit_amount * -1)	AS amount
					, '3'					AS process_type
					, create_time			AS process_date
					, user_account			AS user_account
					, transaction_number	AS transaction_number
				FROM
					t_transfer
				UNION ALL
				SELECT
					debit_currency			AS currency
					, (debit_amount * -1)	AS amount
					, '4'					AS process_type
					, update_time			AS process_date
					, from_account			AS user_account
					, transaction_number	AS transaction_number
				FROM
					t_request
				WHERE
					status = '1'
			) AS data
		WHERE
			DATE(data.process_date)	= '__ELEMENT01__'
			AND data.currency		= '__ELEMENT02__'
	</LIST_TOTAL_BY_DATE_CURRENCY_TRANSFER>

	<!--
		手数料データの取得
		条　件：日付
				通貨
	-->
	<LIST_TOTAL_BY_DATE_CURRENCY_FEE>
		SELECT
			DATE_FORMAT(process_date, '%Y/%m/%d')	AS process_date
			, process_type							AS process_type
			, user_account							AS user_account
			, currency								AS currency
			, amount								AS amount
			, transaction_number					AS transaction_number
		FROM (
				SELECT
					currency				AS currency
					, fee					AS amount
					, '0'					AS process_type
					, deposit_date			AS process_date
					, user_account			AS user_account
					, transaction_number	AS transaction_number
				FROM
					t_deposit
				UNION ALL
				SELECT
					debit_currency			AS currency
					, (fee + fee_refund)	AS amount
					, '2'					AS process_type
					, process_time			AS process_date
					, user_account			AS user_account
					, transaction_number	AS transaction_number
				FROM
					t_withdraw
				UNION ALL
				SELECT
					debit_currency			AS currency
					, (from_fee + to_fee)	AS amount
					, '3'					AS process_type
					, create_time			AS process_date
					, user_account			AS user_account
					, transaction_number	AS transaction_number
				FROM
					t_transfer
				UNION ALL
				SELECT
					debit_currency			AS currency
					, (from_fee + to_fee)	AS amount
					, '4'					AS process_type
					, update_time			AS process_date
					, from_account			AS user_account
					, transaction_number	AS transaction_number
				FROM
					t_request
				WHERE
					status = '1'
			) AS data
		WHERE
			DATE(data.process_date)	= '__ELEMENT01__'
			AND data.currency		= '__ELEMENT02__'
	</LIST_TOTAL_BY_DATE_CURRENCY_FEE>

	<!--
		通貨両替データの取得
		条　件：日付
				通貨
	-->
	<LIST_TOTAL_BY_DATE_CURRENCY_EXCHANGE>
		SELECT
			DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_date
			, '5'									AS process_type
			, user_account							AS user_account
			, debit_currency						AS currency
			, debit_amount							AS amount
			, transaction_number					AS transaction_number
		FROM
			t_exchange
		WHERE
			DATE(create_time)	= '__ELEMENT01__'
			AND debit_currency	= '__ELEMENT02__'
	</LIST_TOTAL_BY_DATE_CURRENCY_EXCHANGE>

	<!--
		両替手数料の設定データの取得
		条　件：なし
	-->
	<LIST_MST_EXCHANGE_FEE>
		SELECT
			pattern_name
			, from_currency
			, to_currency
			, whole
			, markup
		FROM
			t_mst_exchange_fee
		WHERE
			m_f_id = '__ELEMENT01__'
	</LIST_MST_EXCHANGE_FEE>
	
	<!--
		SELEC PATTERN NAME
	-->
	<CHECK_EXIST_PATTERN>
		SELECT
			pattern_name
		FROM
			t_mst_exchange_fee
		WHERE
			pattern_name = '__ELEMENT01__'
	</CHECK_EXIST_PATTERN>
	
	<!--
		エージェントに設定された為替手数料を取得する
		条　件：エージェントコード
	-->
	<LIST_COMMISION_EXCHANGE>
		SELECT
			c_id
			, agent_code
			, m_f_id
			, from_currency
			, to_currency
			, percent
			, children_percent
			, create_time
		FROM
			t_commision_exchange
		WHERE
			agent_code = '__ELEMENT01__'
	</LIST_COMMISION_EXCHANGE>

	<!--
		エージェントに設定された為替手数料を取得する
		条　件：エージェントコード
	-->
	<SELECT_COMMISION_EXCHANGE>
		SELECT
			c_id
			, agent_code
			, m_f_id
			, from_currency
			, to_currency
			, percent
			, children_percent
			, create_time
		FROM
			t_commision_exchange
		WHERE
			agent_code			= '__ELEMENT01__'
			AND from_currency	= '__ELEMENT02__'
			AND to_currency		= '__ELEMENT03__'
	</SELECT_COMMISION_EXCHANGE>

	<!--
		両替手数料の設定データの削除
		条　件：なし
	-->
	<DELETE_MST_EXCHANGE_FEE>
		DELETE
		FROM
			t_mst_exchange_fee
		WHERE
			m_f_id = '__ELEMENT01__'
	</DELETE_MST_EXCHANGE_FEE>

	<!--
		両替手数料の設定データの登録
		登録値：From通貨
				To通貨
				手数料
	-->
	<INSERT_MST_EXCHANGE_FEE>
		INSERT INTO t_mst_exchange_fee (
			m_f_id
			, pattern_name
			, from_currency
			, to_currency
			, whole
			, markup
			, create_time
			, created_by
		) VALUES
		__ELEMENT01__
	</INSERT_MST_EXCHANGE_FEE>

	<!--
		出金履歴の取得
		条　件：口座番号
	-->
	<LIST_WITHDRAW_HISTORY>
		SELECT DISTINCT
			w_id
			, account_name
			, receipt_country
			, receipt_address_1
			, receipt_address_2
			, tel
			, receipt_bank_name
			, receipt_branch_code
			, receipt_branch_name
			, receipt_bank_swift
			, receipt_bank_country
			, receipt_bank_address_1
			, receipt_bank_address_2
			, account_number
			, intermediary_flg
			, intermediary_bank_name
			, intermediary_bank_swift
			, intermediary_bank_country
			, intermediary_bank_address_1
			, intermediary_bank_address_2
		FROM
			t_withdraw
		WHERE
			receipt_bank_name	!= ''
			AND user_account	= '__ELEMENT01__'
			AND receipt_bank_name != 'Local Bank Transfer (China)'
		ORDER BY
			create_time DESC
	</LIST_WITHDRAW_HISTORY>
	<LIST_WITHDRAW_FLAT3_HISTORY>
		SELECT DISTINCT
			w_id
			, account_name
			, receipt_country
			, receipt_address_1
			, receipt_address_2
			, tel
			, receipt_bank_name
			, receipt_branch_code
			, receipt_branch_name
			, receipt_bank_swift
			, receipt_bank_country
			, receipt_bank_address_1
			, receipt_bank_address_2
			, account_number
			, intermediary_flg
			, intermediary_bank_name
			, intermediary_bank_swift
			, intermediary_bank_country
			, intermediary_bank_address_1
			, intermediary_bank_address_2
		FROM
			t_withdraw
		WHERE
			receipt_bank_name	!= ''
			AND user_account	= '__ELEMENT01__'
			AND receipt_bank_name != 'Local Bank Transfer (China)'
			AND withdraw_solution LIKE 'Flat3'
		ORDER BY
			create_time DESC
	</LIST_WITHDRAW_FLAT3_HISTORY>
	<!--
		出金履歴の取得
		条　件：口座番号
	-->
	<LIST_WITHDRAW_LOCAL_HISTORY>
		SELECT DISTINCT
			w_id
			, account_name
			, receipt_country
			, receipt_address_1
			, receipt_address_2
			, tel
			, receipt_bank_name
			, receipt_branch_code
			, receipt_branch_name
			, receipt_bank_swift
			, receipt_bank_country
			, receipt_bank_address_1
			, receipt_bank_address_2
			, account_number
			, intermediary_flg
			, intermediary_bank_name
			, intermediary_bank_swift
			, intermediary_bank_country
			, intermediary_bank_address_1
			, intermediary_bank_address_2
		FROM
			t_withdraw
		WHERE
			receipt_bank_name	!= ''
			AND user_account	= '__ELEMENT01__'
			AND receipt_bank_name = 'Local Bank Transfer (China)'
		ORDER BY
			create_time DESC
	</LIST_WITHDRAW_LOCAL_HISTORY>

	<LIST_WITHDRAW_H2P_HISTORY>
		SELECT DISTINCT
			w_id
			, account_name
			, receipt_country
			, receipt_address_1
			, receipt_address_2
			, tel
			, receipt_bank_name
			, receipt_branch_code
			, receipt_branch_name
			, receipt_bank_swift
			, receipt_bank_country
			, receipt_bank_address_1
			, receipt_bank_address_2
			, account_number
			, intermediary_flg
			, intermediary_bank_name
			, intermediary_bank_swift
			, intermediary_bank_country
			, intermediary_bank_address_1
			, intermediary_bank_address_2
		FROM
			t_withdraw
		WHERE
			receipt_bank_name	!= ''
			AND user_account	= '__ELEMENT01__'
			AND receipt_bank_name != 'Local Bank Transfer (China)'
			AND withdraw_solution LIKE 'H2P'
		ORDER BY
			create_time DESC
	</LIST_WITHDRAW_H2P_HISTORY>
	<!--
		パターンリストの取得
		条　件：なし
	-->
	<LIST_EXCHANGE_FEE_PATTERNS>
		SELECT DISTINCT
			m_f_id
			, if(m_f_id = 0, "__ELEMENT01__", pattern_name) as pattern_name
			, created_by
			, create_time
		FROM
			t_mst_exchange_fee
		WHERE
			pattern_name != '' OR m_f_id = 0
	</LIST_EXCHANGE_FEE_PATTERNS>

	<!-- anton X mikko -->
	<LIST_EXCHANGE_FEE>
		SELECT DISTINCT
			m_f_id
			, if(m_f_id = 0, "__ELEMENT02__", pattern_name) as pattern_name
			, created_by
			, create_time
		FROM
			t_mst_exchange_fee
		WHERE 1
			AND (pattern_name != '' OR m_f_id = 0) 
			__ELEMENT01__
	</LIST_EXCHANGE_FEE>

	<!-- anton X mikko -->
	<LIST_EXCHANGE_FEE_PATTERNS_NAME>
		SELECT DISTINCT
			m_f_id
			, if(m_f_id = 0, '__ELEMENT02__', pattern_name) as pattern_name
		FROM
			t_mst_exchange_fee
		WHERE
			m_f_id = '__ELEMENT01__'
	</LIST_EXCHANGE_FEE_PATTERNS_NAME>

	<!--
		為替手数料の削除
		条　件：エージェントコード
	-->
	<DELETE_COMMISION_EXCHANGE>
		DELETE
		FROM
			t_commision_exchange
		WHERE
			agent_code = '__ELEMENT01__'
	</DELETE_COMMISION_EXCHANGE>

	<!--
		為替手数料の登録
		登録値：エージェントコード
				手数料ID
				FROM通貨
				TO通貨
				取り分
				下への卸値
	-->
	<INSERT_COMMISION_EXCHANGE>
		INSERT INTO t_commision_exchange (
			agent_code
			, m_f_id
			, from_currency
			, to_currency
			, percent
			, children_percent
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_COMMISION_EXCHANGE>

	<!--
		カードコミッションの削除
		条　件：エージェントコード
	-->
	<DELETE_COMMISSION_CARD>
		DELETE
		FROM
			t_agent_commision_card
		WHERE
			agent_code				= '__ELEMENT01__'
			AND YEAR(process_date)	= '__ELEMENT02__'
			AND MONTH(process_date)	= '__ELEMENT03__'
	</DELETE_COMMISSION_CARD>

	<!--
		カードコミッションの登録
		登録値：エージェントコード
				金額
				タイプ
	-->
	<INSERT_COMMISSION_CARD>
		INSERT INTO t_agent_commision_card (
			agent_code
			, amount
			, type
			, process_date
		) VALUES __ELEMENT01__
	</INSERT_COMMISSION_CARD>

	<!--
		カードコミッションの取得
		条　件：エージェントコード
	-->
	<SELECT_AGENT_CARD_COMMISION>
		SELECT
			c_c_id
			, agent_code
			, amount
			, type
		FROM
			t_agent_commision_card
		WHERE
			agent_code				= '__ELEMENT01__'
			AND YEAR(process_date)	= '__ELEMENT02__'
			AND MONTH(process_date)	= '__ELEMENT03__'
	</SELECT_AGENT_CARD_COMMISION>

	<!--
		カード入金テーブルの登録
		登録値：pid
	-->
	<INSERT_PAYMENT_CARD>
		INSERT INTO t_payment_card (
			p_id
			, r1
			, r2
			, r3
			, r4
			, r5
			, r6
			, r7
			, r8
			, r9
			, r10
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, '__ELEMENT11__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_PAYMENT_CARD>

	<!--
		カード申請データの登録
		登録値：口座番号
				国
				県・州
				市区町村
				住所
				郵便番号
				電話番号
	-->
	<INSERT_USER_CARD_APPLY>
		INSERT INTO t_user_cards_apply (
			user_account
			, country
			, state
			, city
			, address
			, zip_code
			, tel
			, status
			, create_time
			, comment
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, ''
		)
	</INSERT_USER_CARD_APPLY>

	<!--
		カード申請データの取得
		条　件：検索条件
	-->
	<LIST_CARD_APPLY>
		SELECT
			user_cards_apply.a_id				AS a_id
			, user_cards_apply.user_account		AS user_account
			, user_cards_apply.country			AS country
			, user_cards_apply.state			AS state
			, user_cards_apply.city				AS city
			, user_cards_apply.address			AS address
			, user_cards_apply.zip_code			AS zip_code
			, user_cards_apply.tel				AS tel
			, user_cards_apply.card_type		AS card_type
			, user_cards_apply.card_number		AS card_number
			, user_cards_apply.pin				AS pin
			, user_cards_apply.card_holder_id	AS card_holder_id
			, user_cards_apply.status			AS status
			, user_cards_apply.create_time		AS create_time
			, user_cards_apply.update_time		AS update_time
			, user_cards_apply.process_user		AS process_user
			, user_cards_apply.comment			AS comment
			, users_active.user_name			AS user_name
			, users_active.first_name			AS first_name
			, users_active.last_name			AS last_name
			, users_active.kyc_flg				AS kyc_flg
		FROM
			t_user_cards_apply	AS user_cards_apply
			LEFT OUTER JOIN
				v_users_active	AS users_active
			ON(user_cards_apply.user_account = users_active.user_account)
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			create_time DESC
	</LIST_CARD_APPLY>

	<!--
		カード申請データの取得
		条　件：検索条件
	-->
	<SELECT_CARD_APPLY>
		SELECT
			user_cards_apply.a_id						AS a_id
			, user_cards_apply.user_account				AS user_account
			, user_cards_apply.country					AS country
			, user_cards_apply.state					AS state
			, user_cards_apply.city						AS city
			, user_cards_apply.address					AS address
			, user_cards_apply.zip_code					AS zip_code
			, user_cards_apply.tel						AS tel
			, user_cards_apply.card_type				AS card_type
			, user_cards_apply.card_number				AS card_number
			, user_cards_apply.pin						AS pin
			, user_cards_apply.card_holder_id			AS card_holder_id
			, user_cards_apply.status					AS status
			, user_cards_apply.create_time				AS create_time
			, user_cards_apply.update_time				AS update_time
			, user_cards_apply.process_user				AS process_user
			, user_cards_apply.comment					AS comment
			, TIMESTAMPDIFF(HOUR, confirm_time, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'))	AS diff_time
			, users_active.user_name					AS user_name
			, users_active.first_name					AS first_name
			, users_active.last_name					AS last_name
			, users_active.kyc_flg						AS kyc_flg
			, users_admin.last_name						AS admin_last_name
			, users_admin.first_name					AS admin_first_name
		FROM
			t_user_cards_apply	AS user_cards_apply
			LEFT OUTER JOIN
				v_users_active	AS users_active
			ON(user_cards_apply.user_account = users_active.user_account)
			LEFT OUTER JOIN
				v_users_admin	AS users_admin
			ON(user_cards_apply.process_user = users_admin.user_account)
		WHERE
			user_cards_apply.a_id = '__ELEMENT01__'
	</SELECT_CARD_APPLY>

	<!--
		カード申請データの取得（ユーザアカウントバージョン）
		条　件：検索条件
	-->
	<LIST_CARD_APPLY_ACTIVE>
		SELECT
			user_cards_apply.a_id				AS a_id
			, user_cards_apply.user_account		AS user_account
			, user_cards_apply.country			AS country
			, user_cards_apply.state			AS state
			, user_cards_apply.city				AS city
			, user_cards_apply.address			AS address
			, user_cards_apply.zip_code			AS zip_code
			, user_cards_apply.tel				AS tel
			, user_cards_apply.card_type		AS card_type
			, user_cards_apply.card_number		AS card_number
			, user_cards_apply.pin				AS pin
			, user_cards_apply.card_holder_id	AS card_holder_id
			, user_cards_apply.status			AS status
			, user_cards_apply.create_time		AS create_time
			, user_cards_apply.update_time		AS update_time
			, user_cards_apply.process_user		AS process_user
			, user_cards_apply.comment			AS comment
			, users_active.user_name			AS user_name
			, users_active.first_name			AS first_name
			, users_active.last_name			AS last_name
			, users_active.kyc_flg				AS kyc_flg
			, users_admin.last_name				AS admin_last_name
			, users_admin.first_name			AS admin_first_name
		FROM
			t_user_cards_apply	AS user_cards_apply
			LEFT OUTER JOIN
				v_users_active	AS users_active
			ON(user_cards_apply.user_account = users_active.user_account)
			LEFT OUTER JOIN
				v_users_admin	AS users_admin
			ON(user_cards_apply.process_user = users_admin.user_account)
		WHERE
			user_cards_apply.user_account	= '__ELEMENT01__'
			AND user_cards_apply.status		> '3'
			AND user_cards_apply.status		&lt; '6'
	</LIST_CARD_APPLY_ACTIVE>

	<!--
		カード申請データの取得（ユーザ所持枚数バージョン）
		条　件：検索条件
	-->
	<LIST_CARD_APPLY_USER>
		SELECT
			user_cards_apply.a_id				AS a_id
			, user_cards_apply.user_account		AS user_account
			, user_cards_apply.country			AS country
			, user_cards_apply.state			AS state
			, user_cards_apply.city				AS city
			, user_cards_apply.address			AS address
			, user_cards_apply.zip_code			AS zip_code
			, user_cards_apply.tel				AS tel
			, user_cards_apply.card_type		AS card_type
			, user_cards_apply.card_number		AS card_number
			, user_cards_apply.pin				AS pin
			, user_cards_apply.card_holder_id	AS card_holder_id
			, user_cards_apply.status			AS status
			, user_cards_apply.create_time		AS create_time
			, user_cards_apply.update_time		AS update_time
			, user_cards_apply.process_user		AS process_user
			, user_cards_apply.comment			AS comment
			, users_active.user_name			AS user_name
			, users_active.first_name			AS first_name
			, users_active.last_name			AS last_name
			, users_active.kyc_flg				AS kyc_flg
			, users_admin.last_name				AS admin_last_name
			, users_admin.first_name			AS admin_first_name
		FROM
			t_user_cards_apply	AS user_cards_apply
			LEFT OUTER JOIN
				v_users_active	AS users_active
			ON(user_cards_apply.user_account = users_active.user_account)
			LEFT OUTER JOIN
				v_users_admin	AS users_admin
			ON(user_cards_apply.process_user = users_admin.user_account)
		WHERE
			user_cards_apply.user_account	= '__ELEMENT01__'
			AND user_cards_apply.status		&lt; '6'
	</LIST_CARD_APPLY_USER>

	<!--
		カード申請データの更新
		条　件：カード申請ID
		更新値：カード番号
				CHID
				PIN
				ステータス
				コメント
				更新ユーザ
	-->
	<UPDATE_CARD_APPLY>
		UPDATE
			t_user_cards_apply
		SET
			card_type			= '__ELEMENT02__'
			, card_number		= '__ELEMENT03__'
			, card_holder_id	= '__ELEMENT04__'
			, pin				= '__ELEMENT05__'
			, status			= '__ELEMENT06__'
			, comment			= '__ELEMENT07__'
			, update_time		= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, process_user		= '__ELEMENT08__'
		WHERE
			a_id = '__ELEMENT01__'
	</UPDATE_CARD_APPLY>

	<!--
		カード申請データの更新
		条　件：カード申請ID
		更新値：コメント
				更新ユーザ
	-->
	<UPDATE_CARD_APPLY_COMMENT>
		UPDATE
			t_user_cards_apply
		SET
			comment			= '__ELEMENT02__'
			, process_user	= '__ELEMENT03__'
			, update_time	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			a_id = '__ELEMENT01__'
	</UPDATE_CARD_APPLY_COMMENT>

	<!--
		カード申請データの登録
		登録値：口座番号
				国
				州・県
				市区町村
				住所
				郵便番号
				電話番号
				操作ユーザ
				ステータス
	-->
	<INSERT_INTO_CARD_APPLY>
		INSERT INTO t_user_cards_apply (
			user_account
			, country
			, state
			, city
			, address
			, zip_code
			, tel
			, status
			, process_user
			, create_time
			, update_time
			, comment
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, ''
		)
	</INSERT_INTO_CARD_APPLY>

	<!--
		カード申請データの更新
		条　件：カード申請ID
		更新値：カード番号
				CHID
				PIN
				ステータス
				コメント
				更新ユーザ
	-->
	<UPDATE_CARD_PIN_TIME>
		UPDATE
			t_user_cards_apply
		SET
			confirm_time = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			a_id = '__ELEMENT01__'
	</UPDATE_CARD_PIN_TIME>

	<!--
		カード申請データの更新
		条　件：カード申請ID
	-->
	<SELECT_MST_MAIL_NAME>
		SELECT
			m_id
			, mail
			, name
		FROM
			t_mst_mail_name
		WHERE
			mail = '__ELEMENT01__'
	</SELECT_MST_MAIL_NAME>

	<!--
		口座バランスを取得する
		条　件：なし
	-->
	<SELECT_USER_BALANCES_API>
		SELECT
			data.user_account											AS user_account
			, data.from_currency										AS currency
			, SUM(data.deposit_amount)									AS deposit_amount
			, SUM(data.withdraw_amount)									AS withdraw_amount
			, (SUM(data.deposit_amount) - SUM(data.withdraw_amount))	AS balance
		FROM (
				SELECT												/* 入金 */
					deposit.user_account							AS user_account
					, deposit.currency								AS from_currency
					, deposit.amount								AS deposit_amount
					, fee											AS withdraw_amount
				FROM
					t_deposit	AS deposit
				WHERE
					CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > deposit_date
				UNION ALL
				SELECT												/* 通常出金 */
					withdraw.user_account							AS user_account
					, withdraw.debit_currency						AS from_currency
					, 0 											AS deposit_amount
					, (withdraw.debit_amount + fee)					AS withdraw_amount
				FROM
					t_withdraw	AS withdraw
				WHERE
					status 		&lt;= '3'
					AND (type = '0' OR type = '3' OR type = '1')
				UNION ALL
				SELECT												/* 両替（入金） */
					exchange.user_account							AS user_account
					, exchange.currency								AS from_currency
					, (exchange.amount) 							AS deposit_amount
					, 0												AS withdraw_amount
				FROM
					t_exchange	AS exchange
				UNION ALL
				SELECT												/* 両替（出金） */
					exchange.user_account							AS user_account
					, exchange.debit_currency						AS from_currency
					, 0												AS deposit_amount
					, (exchange.debit_amount) 						AS withdraw_amount
				FROM
					t_exchange	AS exchange
				UNION ALL
				SELECT												/* 口座振替（入金） */
					transfer_deposit.to_account						AS user_account
					, transfer_deposit.transfer_currency			AS from_currency
					, transfer_deposit.transfer_amount				AS deposit_amount
					, to_fee										AS withdraw_amount
				FROM
					t_transfer	AS transfer_deposit
					WHERE CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > transfer_deposit.create_time
				UNION ALL
				SELECT												/* 口座振替（出金） */
					transfer_withdraw.user_account					AS user_account
					, transfer_withdraw.debit_currency				AS from_currency
					, 0												AS deposit_amount
					, (transfer_withdraw.debit_amount + from_fee)	AS withdraw_amount
				FROM
					t_transfer	AS transfer_withdraw
					WHERE CONVERT_TZ(NOW(),@@session.time_zone,'+09:00') > transfer_withdraw.create_time
				UNION ALL
				SELECT												/* 引き落とし（入金） */
					requestr_deposit.to_account						AS user_account
					, requestr_deposit.currency						AS from_currency
					, requestr_deposit.amount 						AS deposit_amount
					, to_fee										AS withdraw_amount
				FROM
					t_request	AS requestr_deposit
				WHERE
					status = 1
				UNION ALL
				SELECT												/* 引き落とし（出金） */
					request_withdraw.from_account					AS user_account
					, request_withdraw.debit_currency				AS from_currency
					, 0												AS deposit_amount
					, (request_withdraw.debit_amount + from_fee)	AS withdraw_amount
				FROM
					t_request	AS request_withdraw
				WHERE
					status = 1
				UNION ALL
				SELECT												/* 出金（組戻し） */
					withdraw.user_account							AS user_account
					, withdraw.debit_currency						AS from_currency
					, withdraw.debit_amount							AS deposit_amount
					, (withdraw.debit_amount + fee + fee_refund)	AS withdraw_amount
				FROM
					t_withdraw	AS withdraw
				WHERE
					status = '4'
				UNION ALL
				SELECT												/* 出金（キャンセル） */
					withdraw.user_account							AS user_account
					, withdraw.debit_currency						AS from_currency
					, withdraw.debit_amount							AS deposit_amount
					, (withdraw.debit_amount + fee)					AS withdraw_amount
				FROM
					t_withdraw	AS withdraw
				WHERE
					status = '6'
                UNION ALL
                SELECT												/* 出金（キャンセル） */
                    withdraw.user_account							AS user_account
                    , withdraw.debit_currency						AS from_currency
                    , withdraw.debit_amount							AS deposit_amount
                    , fee											AS withdraw_amount
                FROM
                    t_withdraw	AS withdraw
                WHERE
                    status = '2'
                    AND type = '11'
			) AS data
		GROUP BY
			data.user_account, data.from_currency
	</SELECT_USER_BALANCES_API>

	<!--
		結果のレスポンスを登録する（GPaysafe用）
		条　件：transactionId
				referenceNo
				amount
				currency
				status
				message
				paymentMethod
				code
				voucherCode
				token
	-->
	<INSERT_RESPONSE_GPAYSAFE>
		INSERT INTO t_response_gpaysafe (
			transaction_id
			, reference_no
			, amount
			, currency
			, status
			, message
			, payment_method
			, code
			, voucher_code
			, token
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
			, '__ELEMENT09__'
			, '__ELEMENT10__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_RESPONSE_GPAYSAFE>

	<!--
		結果のレスポンスを登録する（GPaysafe初期登録用）
		条　件：referenceNo
				token
	-->
	<INSERT_RESPONSE_GPAYSAFE_SIMPLE>
		INSERT INTO t_response_gpaysafe (
			reference_no
			, token
			, amount
			, user_account
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_RESPONSE_GPAYSAFE_SIMPLE>

	<!--
		結果のレスポンスを更新する（GPaysafe結果更新用）
		条　件：referenceNo
				token
	-->
	<UPDATE_RESPONSE_GPAYSAFE>
		UPDATE
			t_response_gpaysafe
		SET
			transaction_id		= '__ELEMENT02__'
			, payment			= '__ELEMENT03__'
			, currency			= '__ELEMENT04__'
			, status			= '__ELEMENT05__'
			, message			= '__ELEMENT06__'
			, payment_method	= '__ELEMENT07__'
			, code				= '__ELEMENT08__'
			, voucher_code		= '__ELEMENT09__'
			, update_time		= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			reference_no = '__ELEMENT01__'
	</UPDATE_RESPONSE_GPAYSAFE>

	<INSERT_AAAA>
		INSERT INTO t_test_b (
			val_1
			, val_2
			, create_time
		) VALUE (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_AAAA>

	<!--
		オリジナル為替レートを取得する
		条　件：from
				to
	-->
	<SELECT_ORIGINAL_RATE>
		SELECT
			original_rate
		FROM
			t_exchange_rate
		WHERE
			from_currency = '__ELEMENT01__'
			AND to_currency = '__ELEMENT02__'
	</SELECT_ORIGINAL_RATE>

	<!--
		GPAYSAFE用の仮デポジット
		登録値：トランザクション番号
				トークン
				口座番号
	-->
	<INSERT_DEPOSIT_GPAYSAFE_SIMPLE>
		INSERT INTO t_deposit (
			transaction_number
			, comment
			, user_account
			, type
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, 2
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_DEPOSIT_GPAYSAFE_SIMPLE>

	<!--
		GPAYSAFE用のデポジット完了
		登録値：トランザクション番号
				トークン
				口座番号
	-->
	<UPDATE_DEPOSIT_GPAYSAFE>
		UPDATE
			t_deposit
		SET
			amount			= '__ELEMENT03__'
			, currency		= '__ELEMENT04__'
			, deposit_date	= __ELEMENT05__
			, type			= '__ELEMENT06__'
			, deposit_bank	= '__ELEMENT07__'
			, message		= '__ELEMENT07__'
			, comment		= '__ELEMENT08__'
		WHERE
			transaction_number	= '__ELEMENT01__'
	</UPDATE_DEPOSIT_GPAYSAFE>

	<!--
		GPAYSAFE用のレスポンスデータを取得
		条　件：トランザクション番号
	-->
	<SELECT_RESPONSE_GPS_BY_R_ID>
		SELECT
			r_id
			, user_account
			, transaction_id
			, reference_no
			, amount
			, payment
			, currency
			, status
			, message
			, payment_method
			, code
			, voucher_code
			, token
			, create_time
			, update_time
		FROM
			t_response_gpaysafe
		WHERE
			reference_no = '__ELEMENT01__'
	</SELECT_RESPONSE_GPS_BY_R_ID>

	<!--
		GPAYSAFE用のレスポンスデータを取得（24時間）
		条　件：口座番号
	-->
	<LIST_GPS_RESPONSE_24_HOUR>
		SELECT
			COUNT(r_id)			AS counter
			, user_account		AS user_account
			, transaction_id	AS transaction_id
			, reference_no		AS reference_no
			, SUM(amount)		AS amount
			, payment			AS payment
			, currency			AS currency
			, status			AS status
			, message			AS message
			, payment_method	AS payment_method
			, code				AS code
			, voucher_code		AS voucher_code
			, token				AS token
			, create_time		AS create_time
			, update_time		AS update_time
		FROM
			t_response_gpaysafe
		WHERE
			user_account	= '__ELEMENT01__'
			AND code		= '00'
			AND create_time BETWEEN DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -24 HOUR) AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		GROUP BY
			payment_method
	</LIST_GPS_RESPONSE_24_HOUR>

	<!--
		GPAYSAFE用のレスポンスデータを取得（15日）
		条　件：口座番号
	-->
	<LIST_GPS_RESPONSE_15_DAY>
		SELECT
			COUNT(r_id)			AS counter
			, user_account		AS user_account
			, transaction_id	AS transaction_id
			, reference_no		AS reference_no
			, SUM(amount)		AS amount
			, payment			AS payment
			, currency			AS currency
			, status			AS status
			, message			AS message
			, payment_method	AS payment_method
			, code				AS code
			, voucher_code		AS voucher_code
			, token				AS token
			, create_time		AS create_time
			, update_time		AS update_time
		FROM
			t_response_gpaysafe
		WHERE
			user_account	= '__ELEMENT01__'
			AND code		= '00'
			AND create_time BETWEEN DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -15 DAY) AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		GROUP BY
			payment_method
	</LIST_GPS_RESPONSE_15_DAY>

	<!--
		GPAYSAFE用のレスポンスデータを取得（30日）
		条　件：口座番号
	-->
	<LIST_GPS_RESPONSE_30_DAY>
		SELECT
			COUNT(r_id)			AS counter
			, user_account		AS user_account
			, transaction_id	AS transaction_id
			, reference_no		AS reference_no
			, SUM(amount)		AS amount
			, payment			AS payment
			, currency			AS currency
			, status			AS status
			, message			AS message
			, payment_method	AS payment_method
			, code				AS code
			, voucher_code		AS voucher_code
			, token				AS token
			, create_time		AS create_time
			, update_time		AS update_time
		FROM
			t_response_gpaysafe
		WHERE
			user_account	= '__ELEMENT01__'
			AND code		= '00'
			AND create_time BETWEEN DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -30 DAY) AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		GROUP BY
			payment_method
	</LIST_GPS_RESPONSE_30_DAY>

	<!--
		GPAYSAFEデータの更新
		更新値：口座種別
				決済種別
		条　件：口座番号

	-->
	<UPDATE_USER_GPS>
		UPDATE
			t_user
		SET
			gps_account_flg			= '__ELEMENT02__'
			, gps_kind_of_payment	= '__ELEMENT03__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_GPS>

	<!--
		ログの取得
		条　件：なし

	-->
	<LIST_POST_LOG>
		SELECT
			l_id
			, ip_address
			, url
			, post
			, create_time
		FROM
			t_log_post
		ORDER BY
			create_time DESC
	</LIST_POST_LOG>
	<!--
		ログの取得
		条　件：なし

	-->
	<LIST_LOG_POST>
		SELECT
			l_id
			, p_num
			, ip_address
			, url
			, post
			, create_time
		FROM
			t_log_post
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			create_time DESC
			__ELEMENT02__ 
	</LIST_LOG_POST>

	<COUNT_LOG_POST>
		SELECT
			count(*) as log_ctr
		FROM
			t_log_post
		WHERE
			1
			__ELEMENT01__
	</COUNT_LOG_POST>

	<!--
		入金フラグの修正
		変更値：フラグ1
				フラグ2
				フラグ3
				フラグ4
				フラグ5
				フラグ6
				フラグ7
				フラグ8
				フラグ9
				フラグ10
		条　件：口座番号
	-->
	<UPDATE_GPS_KIND_OF_PAYMENT>
		UPDATE
			t_user
		SET
			gps_kind_of_payment = '__ELEMENT02____ELEMENT03____ELEMENT04____ELEMENT05____ELEMENT06____ELEMENT07____ELEMENT08____ELEMENT09____ELEMENT10____ELEMENT11__'
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_GPS_KIND_OF_PAYMENT>

	<!--
		KYC書類の数を取得する
		条　件：口座番号

	-->
	<COUNT_KYC_DOCUMENT>
		SELECT
			user_account
			, status
		FROM
			t_kyc
		WHERE
			user_account = '__ELEMENT01__'
	</COUNT_KYC_DOCUMENT>

	<!--
		国の年齢制限を取得する
		条　件：国コード
	-->
	<SELECT_LIMIT_AGE_BY_COUNTRY_CODE>
		SELECT
			c_id
			, country
			, langage
			, country_code
			, limit_age
		FROM
			t_mst_country
		WHERE
			langage				= 'en'
			AND country_code	= '__ELEMENT01__'
	</SELECT_LIMIT_AGE_BY_COUNTRY_CODE>

	<!--
		年齢制限の差分を取得する
		条　件：年
				月
				日
				制限年
	-->
	<SELECT_LIMIT_YEAR_DIFF>
		SELECT
			DATE_ADD('__ELEMENT01__-__ELEMENT02__-__ELEMENT03__', INTERVAL __ELEMENT04__ YEAR)						AS limit_age
			, DATEDIFF(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), DATE_ADD('__ELEMENT01__-__ELEMENT02__-__ELEMENT03__', INTERVAL __ELEMENT04__ YEAR))	AS diff_time
	</SELECT_LIMIT_YEAR_DIFF>

	<!--
		ログイン履歴の取得
		条　件：
	-->
	<LIST_LOGIN_HIOSTORY>
		SELECT
			login_history.l_id					AS l_id
			, login_history.u_id				AS u_id
			, users.user_account				AS user_account
			, users.last_name					AS last_name
			, users.first_name					AS first_name
			, login_history.ip_address			AS ip_address
			, login_history.user_agent			AS user_agent
			, login_history.transaction_type	AS transaction_type
			, login_history.create_time			AS create_time
			, users.country						AS country
		FROM
			t_login_history AS login_history
			LEFT OUTER JOIN
				t_user AS users
			ON(login_history.u_id = users.u_id)
		WHERE
			users.u_id IS NOT NULL
			__ELEMENT01__
		AND 
			users.admin_flg != 1
		ORDER BY
			create_time DESC
		__ELEMENT02__
	</LIST_LOGIN_HIOSTORY>

	<LIST_LOGIN_HIOSTORY_COUNT>
		SELECT
			COUNT(login_history.l_id)	AS counter
		FROM
			t_login_history AS login_history
			LEFT OUTER JOIN
				t_user AS users
			ON(login_history.u_id = users.u_id)
		WHERE
			users.u_id IS NOT NULL
			__ELEMENT01__
		AND 
			users.admin_flg != 1
	</LIST_LOGIN_HIOSTORY_COUNT>

	<!-- lists t_user data -->
	<LIST_REGISTERED_ACCOUNTS_LTD>
		SELECT 
			create_time, 
			last_name,
			first_name,
			user_account,
			create_ip_address as 'ip_address',
			country FROM t_user where u_id IS NOT NULL
			__ELEMENT01__
			AND
				admin_flg != 1
			ORDER BY
				create_time DESC
		__ELEMENT02__
	</LIST_REGISTERED_ACCOUNTS_LTD>

	<LIST_REGISTERED_ACCOUNTS_LTD_COUNT>
		SELECT
			COUNT(u_id)	AS counter
		FROM
			t_user
		WHERE
			u_id IS NOT NULL
			__ELEMENT01__
		AND
			admin_flg != 1
	</LIST_REGISTERED_ACCOUNTS_LTD_COUNT>

	<!-- this-is-the-only-english-comment -->
	<LIST_LOGIN_HIOSTORY_EXPORT>
		SELECT
			login_history.l_id					AS l_id
			, login_history.u_id				AS u_id
			, users.user_account				AS user_account
			, users.last_name					AS last_name
			, users.first_name					AS first_name
			, login_history.ip_address			AS ip_address
			, login_history.user_agent			AS user_agent
			, login_history.transaction_type	AS transaction_type
			, login_history.create_time			AS create_time
		FROM
			t_login_history AS login_history
			LEFT OUTER JOIN
				t_user AS users
			ON(login_history.u_id = users.u_id)
		WHERE
			users.u_id IS NOT NULL
			__ELEMENT01__
		AND 
			users.admin_flg != 1
		ORDER BY
			create_time DESC
	</LIST_LOGIN_HIOSTORY_EXPORT>

	<SELECT_TEMP_CCDEPOSIT_BY>
		SELECT * 
			FROM t_deposit_credit_card_temporary 
		WHERE __ELEMENT01__ = __ELEMENT02__
	</SELECT_TEMP_CCDEPOSIT_BY>
	
	<INSERT_TEMP_CCDEPOSIT>
		INSERT INTO t_deposit_credit_card_temporary (
			transaction_number,
			user_account,
			invoice_num,
			amount,
			currency,
			fee,
			message,
			token,
			create_time
		) values (
			__ELEMENT01__,
			__ELEMENT02__,
			__ELEMENT03__,
			__ELEMENT04__,
			__ELEMENT05__,
			__ELEMENT06__,
			__ELEMENT07__,
			__ELEMENT08__,
			__ELEMENT09__
		)
	</INSERT_TEMP_CCDEPOSIT>
	
	<INSERT_WB_DEPOSIT_TRANSACTION>
		INSERT into t_deposit (
			transaction_number,
			user_account,
			amount,
			currency,
			method,
			deposit_bank,
			deposit_date,
			fee,
			comment,
			create_time,
			type,
			err_flg,
			message
		) values (
			'__ELEMENT01__',
			'__ELEMENT02__',
			'__ELEMENT03__',
			'__ELEMENT04__',
			'__ELEMENT05__',
			'__ELEMENT06__',
			'__ELEMENT07__',
			'__ELEMENT08__',
			'__ELEMENT09__',
			'__ELEMENT10__',
			'__ELEMENT11__',
			'__ELEMENT12__',
			'__ELEMENT13__'
		)
	</INSERT_WB_DEPOSIT_TRANSACTION>
	
	<UPDATE_TEMP_CCDEPOSIT>
		UPDATE t_deposit_credit_card_temporary 
		SET credited = '__ELEMENT02__' where invoice_num = __ELEMENT01__ 
	</UPDATE_TEMP_CCDEPOSIT>
	
	<INSERT_TRANSACTION_TOKEN>
		INSERT INTO t_transaction_token (
			token_value,
			token_status,
			token_owner,
			create_time
		) values (
			__ELEMENT01__,
			__ELEMENT02__,
			__ELEMENT03__,
			CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_TRANSACTION_TOKEN>
	
	<SELECT_TRANSACTION_TOKEN>
		SELECT * FROM t_transaction_token 
		WHERE token_value = __ELEMENT01__
	</SELECT_TRANSACTION_TOKEN>
	
	<LIST_DEV_CREDENTIALS>
		SELECT
			dev_id,
			dev_key,
			dev_secret_key,
			dev_expiration,
			dev_exec_counter,
			dev_last_exec,
			create_time,
			update_time
		FROM
		t_dev_tools_creds
		WHERE 1 __ELEMENT01__
	</LIST_DEV_CREDENTIALS>
	
	<COUNT_DEV_CREDENTIALS>
		SELECT count(*) AS creds_ctr 
		FROM
			t_dev_tools_creds
		WHERE 1 __ELEMENT01__
	</COUNT_DEV_CREDENTIALS>
	
	<SELECT_DEV_CREDENTIAL>
		SELECT 
			dev_secret_key,
			dev_passcode,
			dev_ip_addresses,
			dev_expiration
		FROM
		t_dev_tools_creds
		WHERE
			dev_key = '__ELEMENT01__'
	</SELECT_DEV_CREDENTIAL>
	
	<INSERT_DEV_CREDENTIAL>
		INSERT INTO t_dev_tools_creds (
				dev_key,
				dev_passcode,
				dev_ip_addresses,
				dev_expiration,
				dev_secret_key,
				dev_exec_counter,
				dev_last_exec,
				create_time,
				update_time
			) values (
				'__ELEMENT01__',
				'__ELEMENT02__',
				'__ELEMENT03__',
				'__ELEMENT04__',
				'__ELEMENT05__',
				'__ELEMENT06__',
				'__ELEMENT07__',
				'__ELEMENT08__',
				'__ELEMENT09__'
			)
	</INSERT_DEV_CREDENTIAL>
	
	<UPDATE_DEV_CREDENTIAL_DETAILS>
		UPDATE t_dev_tools_creds
		SET
			dev_expiration = '__ELEMENT02__',
			dev_ip_addresses = '__ELEMENT03__',
			update_time = '__ELEMENT04__'
		WHERE
			dev_key = '__ELEMENT01__'
	</UPDATE_DEV_CREDENTIAL_DETAILS>
	
	<UPDATE_DEV_CREDENTIAL_PASSCODE>
		UPDATE t_dev_tools_creds
		SET
			dev_passcode = '__ELEMENT02__',
			update_time = '__ELEMENT03__'
		WHERE
			dev_key = '__ELEMENT01__'
	</UPDATE_DEV_CREDENTIAL_PASSCODE>
	
	<UPDATE_DEV_CREDENTIAL_EXECUTION>
		UPDATE t_dev_tools_creds
		SET
			dev_exec_counter = dev_exec_counter + 1,
			dev_last_exec = '__ELEMENT02__'
		WHERE
			dev_key = '__ELEMENT01__'
	</UPDATE_DEV_CREDENTIAL_EXECUTION>
	
	<DELETE_DEV_CREDENTIAL>
		DELETE from t_dev_tools_creds
		WHERE dev_key = '__ELEMENT01__'
	</DELETE_DEV_CREDENTIAL>
	
	<SELECT_DEV_SETTING>
		SELECT 
			dev_setting_id,
			dev_setting_value,
			dev_setting_enabled
		FROM
			t_dev_tool_settings
		WHERE
			dev_setting_id = '__ELEMENT01__'	
	</SELECT_DEV_SETTING>
	
	<UPDATE_DEV_SETTING>
		UPDATE
			t_dev_tool_settings
		SET
			dev_setting_value = '__ELEMENT02__'
		WHERE
			dev_setting_id = '__ELEMENT01__'
	</UPDATE_DEV_SETTING>
	
	<!--
		CUP入金一時データの過去1時間データ
		条　件：口座番号
	-->
	<COUNT_CUP_DEPOSIT_TEMPORARY_1_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit_cup_temporary
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -1 HOUR)
	</COUNT_CUP_DEPOSIT_TEMPORARY_1_HOUR>


	<!--
		入金一時データの過去1日データ
		条　件：口座番号
	-->
	<COUNT_DEPOSIT_CUP_AMOUNT_1_DAY>
		SELECT
			SUM(amount) AS counter
		FROM
			t_deposit
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -24 HOUR)
			AND method 		= 'CUP'
	</COUNT_DEPOSIT_CUP_AMOUNT_1_DAY>

	<!--
		入金一時データの過去24時間データ
		条　件：口座番号
		条　件2：method
	-->
	<COUNT_DEPOSIT_CUP_24_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -24 HOUR)
			AND method 		= 'CUP'
	</COUNT_DEPOSIT_CUP_24_HOUR>

	<!--
		CASHFLOW入金一時データの過去1時間データ
		条　件：口座番号
	-->
	<COUNT_CASHFLOW_DEPOSIT_TEMPORARY_1_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit_cashflow_temporary
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> '__ELEMENT02__'
	</COUNT_CASHFLOW_DEPOSIT_TEMPORARY_1_HOUR>

	<!--
		入金一時データの過去24時間データ
		条　件：口座番号
	-->
	<COUNT_DEPOSIT_TEMPORARY_24_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit_cashflow_temporary
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -24 HOUR)
	</COUNT_DEPOSIT_TEMPORARY_24_HOUR>

	<!--
		入金一時データの過去30日データ
		条　件：口座番号
	-->
	<COUNT_DEPOSIT_TEMPORARY_30_DAY>
		SELECT
			SUM(amount) AS counter
		FROM
			t_deposit_cashflow_temporary
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -30 DAY)
	</COUNT_DEPOSIT_TEMPORARY_30_DAY>

	<!--
		入金の1件取得
		条　件：入金ID
	-->
	<SELECT_DEPOSIT_BY_TRANSACTION_NUMBER>
		SELECT
			deposit.d_id											AS d_id
			, deposit.transaction_number							AS transaction_number
			, deposit.user_account									AS user_account
			, deposit.amount										AS amount
			, deposit.currency										AS currency
			, deposit.deposit_date									AS deposit_date
			, deposit.deposit_bank									AS deposit_bank
			, deposit.message										AS message
			, deposit.comment										AS comment
			, deposit.create_time									AS create_time
			, DATE_FORMAT(deposit.create_time, '%Y/%m/%d %H:%i:%s')	AS create_time_string
			, deposit.method										AS method
			, deposit.isSendMail									AS isSendMail
			, deposit.fee											AS fee
			, deposit.process_user									AS process_user
			, deposit.old_filename									AS old_filename
			, deposit.new_filename									AS new_filename
		FROM
			t_deposit AS deposit
		WHERE
			deposit.transaction_number = '__ELEMENT01__'
	</SELECT_DEPOSIT_BY_TRANSACTION_NUMBER>


	<UPDATE_DEPOSIT_ISSENDMAIL>
		UPDATE
			t_deposit
		SET
			isSendMail = '1'
		WHERE
			transaction_number = '__ELEMENT01__'
	</UPDATE_DEPOSIT_ISSENDMAIL>

	<!--
		入金一時データの過去24時間データ
		条　件：口座番号
		条　件2：method
	-->
	<COUNT_DEPOSIT_CASHFLOW_24_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -24 HOUR)
			AND method 		= 'CASHFLOWVM'
	</COUNT_DEPOSIT_CASHFLOW_24_HOUR>

	<!--
		入金一時データの過去30日データ
		条　件：口座番号
		条　件2：method
	-->
	<COUNT_DEPOSIT_CASHFLOW_30_DAY>
		SELECT
			SUM(IF(currency="USD",amount,0)) AS "USD"
			,SUM(IF(currency="EUR",amount,0)) AS "EUR"
			,SUM(IF(currency="GBP",amount,0)) AS "GBP"
			,SUM(IF(currency="JPY",amount,0)) AS "JPY"
		FROM
			t_deposit
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -30 DAY)
			AND method 		= 'CASHFLOWVM'
	</COUNT_DEPOSIT_CASHFLOW_30_DAY>

	<SELECT_ACCOUNT_TYPE>
		SELECT
			account_type
		FROM
			`t_user`
		WHERE
			mail='__ELEMENT01__'
		AND
			account_type = '1'
	</SELECT_ACCOUNT_TYPE>

	<!--
		二阶段认证增加相关代码
	-->

	<!--
		查看是否给定权限
		条　件：邮箱
	-->
	<SELECT_2FA_USER_ACCOUNT>
		SELECT
			user_account
			,use_langage
		FROM
			`t_user`
		WHERE
			u_id = (SELECT
											 u_id
									 FROM
											 `t_login`
									 WHERE
											 user_name = '__ELEMENT01__')
		OR
	  	u_id = (SELECT
	     									u_id
								    FROM
								     `t_user`
								    WHERE
								     mail = '__ELEMENT01__');
	</SELECT_2FA_USER_ACCOUNT>

	<!--
		查看是否给定权限
		条　件：邮箱
	-->
	<SELECT_2FA_ENABLE>
		SELECT
			e.*
			, u.account_type
			, u.first_name
			, u.last_name
		FROM
			t_2fa_enable  AS e
		LEFT OUTER JOIN
			t_user  AS u
		ON (
			e.user_account = u.user_account
		)
		WHERE
			e.user_account = '__ELEMENT01__'
	</SELECT_2FA_ENABLE>

	<!--
		查看是否符合条件
		条　件：邮箱
	-->
	<SELECT_2FA_INSPECT>
		SELECT
			__ELEMENT01__                                           AS      code
			,TIMESTAMPDIFF( MINUTE, __ELEMENT04__, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')) 			AS   	minute_different
		FROM
			t_2fa_code
		WHERE
			user_account = '__ELEMENT02__'
		AND
			__ELEMENT03__ != '3' ;
	</SELECT_2FA_INSPECT>

	<!--
		查看是有24小时限制
		条　件：邮箱
	-->
	<SELECT_2FA_24_INSPECT>
		SELECT
			*
		FROM
			`t_2fa_code`
		WHERE
			user_account = '__ELEMENT01__'
		AND
		(
			__ELEMENT02__ &lt; '3'
		OR
			TIMESTAMPDIFF(HOUR,__ELEMENT03__,CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')) &gt;= 24
		);
	</SELECT_2FA_24_INSPECT>

	<!--
		插入新锁
		条　件：邮箱
	-->
	<INSERT_2FA_ENABLE>
		INSERT INTO `t_2fa_enable` (
			user_account
			, login
			, password
			, mail
			, withdrawal_international
			, withdrawal_sdpay
			, withdrawal_flat3
			, withdrawal_h2p
			, transfer
			, exchange
			, received
			, create_time
			, update_time
		)
		VALUES
		(
			'__ELEMENT01__'
			, '1'
			, '1'
			, '1'
			, '1'
			, '1'
			, '1'
			, '1'
			, '1'
			, '1'
			, '1'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_2FA_ENABLE>

	<INSERT_2FA_ENABLE_CORP>
		INSERT INTO `t_2fa_enable` (
			user_account
			, login
			, password
			, mail
			, withdrawal_international
			, withdrawal_sdpay
			, withdrawal_flat3
			, withdrawal_h2p
			, transfer
			, exchange
			, received
			, create_time
			, update_time
		)
		VALUES
		(
			'__ELEMENT01__'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_2FA_ENABLE_CORP>

	<!--
		插入新数据
		条　件：邮箱
	-->
	<INSERT_2FA_CODE>
		INSERT INTO `t_2fa_code` (
			 `user_account`
			, `login_code`
			, `login_status`
			, `password_code`
			, `password_status`
			, `mail_code`
			, `mail_status`
			, `withdrawal_international_code`
			, `withdrawal_international_status`
			, `withdrawal_sdpay_code`
			, `withdrawal_sdpay_status`
			, `withdrawal_flat3_code`
			, `withdrawal_flat3_status`
			, `withdrawal_h2p_code`
			, `withdrawal_h2p_status`
			, `transfer_code`
			, `transfer_status`
			, `exchange_code`
			, `exchange_status`
			, `received_code`
			, `received_status`
			, `create_time`
			, `update_time`
		)
		VALUES
		(
			'__ELEMENT01__'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, '0'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_2FA_CODE>

	<!--
		更新新邮件CODE
		条　件：邮箱
	-->
	<UPDATE_2FA_CODE>
		UPDATE t_2fa_code
		SET
			__ELEMENT02__
		WHERE
			user_account =  '__ELEMENT01__'
	</UPDATE_2FA_CODE>

	<!--
		更新status次数
		条　件：邮箱
	-->
	<UPDATE_2FA_CODE_STATUS>
		UPDATE t_2fa_code
		SET
			__ELEMENT01__ = __ELEMENT01__+1
			,__ELEMENT02__ = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			user_account = '__ELEMENT03__'
	</UPDATE_2FA_CODE_STATUS>

	<!--
		更新status次数
		条　件：邮箱
	-->
	<UPDATE_2FA_ZERO_STATUS>
		UPDATE t_2fa_code
		SET
			__ELEMENT01__ = '0'
		WHERE
			user_account = '__ELEMENT02__'
	</UPDATE_2FA_ZERO_STATUS>

	<!--
		更新enable表
		条　件：邮箱
	-->
	<UPDATE_2FA_ENABLE>
		UPDATE `t_2fa_enable`
		SET
			`login`							=		'__ELEMENT01__'
			, `password`					=		'__ELEMENT02__'
			, `mail`						=		'__ELEMENT02__'
			, `withdrawal_international`	=		'__ELEMENT03__'
			, `withdrawal_sdpay`			=		'__ELEMENT03__'
			, `withdrawal_flat3`			=		'__ELEMENT03__'
			, `withdrawal_h2p`				=		'__ELEMENT03__'
			, `transfer`					=		'__ELEMENT03__'
			, `exchange`					=		'__ELEMENT03__'
			, `received`					=		'__ELEMENT03__'
			,`update_time`					=		CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE (
			user_account 					= 		'__ELEMENT04__'
		)
	</UPDATE_2FA_ENABLE>
	<!--
		更新enable表首次登陆送信部分
		条　件：邮箱
	-->
	<UPDATE_2FA_ENABLE_MAIL>
		UPDATE `t_2fa_enable`
		SET
			`enablemail`					=		'__ELEMENT01__'
			,`lang`							=		'__ELEMENT03__'
		WHERE (
			user_account 					= 		'__ELEMENT02__'
		)
	</UPDATE_2FA_ENABLE_MAIL>
	<!--
		读取口座種別
		条　件：邮箱
	-->
	<SELECT_2FA_ACCOUNT_TYPE>
		SELECT
			account_type
		FROM
			`t_user`
		WHERE
			mail='__ELEMENT01__'
	</SELECT_2FA_ACCOUNT_TYPE>

	<SELECT_2FA_ACCOUNT_TYPE_VIA_USERID>
		SELECT
			account_type
		FROM
			`t_user`
		WHERE
			user_account ='__ELEMENT01__'
	</SELECT_2FA_ACCOUNT_TYPE_VIA_USERID>
	<SELECT_2FA_MAIL_VIA_USERID>
		SELECT
				mail
		FROM
			`t_user`
		WHERE
			user_account ='__ELEMENT01__'
	</SELECT_2FA_MAIL_VIA_USERID>

    <!-- insert into temporary Local Bank Transfer China table -->
    <INSERT_TEMP_DEPOSIT_LBTC>
        INSERT INTO  t_deposit_lbtc_temporary(
            transaction_number
            , user_account
            , user_fullname
            , deposit_bank
            , beneficiary_bank
            , beneficiary_bank_branch
            , account_name
            , account_number
            , deposit_amount
            , fee
            , iwallet_deposit_amount
            , comment
            , create_time
            , is_reflected
            , language
        ) VALUES (
            '__ELEMENT01__'
            , '__ELEMENT02__'
            , '__ELEMENT03__'
            , '__ELEMENT04__'
            , '__ELEMENT05__'
            , '__ELEMENT06__'
            , '__ELEMENT07__'
            , '__ELEMENT08__'
            , '__ELEMENT09__'
            , '__ELEMENT10__'
            , '__ELEMENT11__'
            , '__ELEMENT12__'
            , '__ELEMENT13__'
            , '__ELEMENT14__'
            , '__ELEMENT15__'
        )
    </INSERT_TEMP_DEPOSIT_LBTC>

    <!-- select from t_deposit_lbtc_temporary using transaction_number -->
    <SELECT_TEMP_DEPOSIT_LBTC>
        SELECT
            *
		FROM
			t_deposit_lbtc_temporary
		WHERE
			transaction_number	= '__ELEMENT01__'
    </SELECT_TEMP_DEPOSIT_LBTC>

    <!-- select from t_deposit_lbtc_temporary using transaction_number and not success -->
    <SELECT_TEMP_DEPOSIT_LBTC_NOT_SUCCESS>
        SELECT
            *
		FROM
			t_deposit_lbtc_temporary
		WHERE
			transaction_number	= '__ELEMENT01__'
        AND
            status != 1
    </SELECT_TEMP_DEPOSIT_LBTC_NOT_SUCCESS>

    <!-- update t_deposit_lbtc_temporary using transaction_number -->
    <UPDATE_TEMP_DEPOSIT_LBTC>
		UPDATE
			t_deposit_lbtc_temporary
		SET
            status	   = '__ELEMENT02__'
		WHERE
			transaction_number = '__ELEMENT01__'
	</UPDATE_TEMP_DEPOSIT_LBTC>
    <!-- select from t_deposit_cup_temporary using transaction_number -->
    <SELECT_TEMP_DEPOSIT_CUP_NOT_SUCCESS>
        SELECT
            *
		FROM
			t_deposit_cup_temporary
		WHERE
			transaction_number	= '__ELEMENT01__'
        AND
            status != 1
    </SELECT_TEMP_DEPOSIT_CUP_NOT_SUCCESS>

    <SELECT_TEMP_DEPOSIT_CUP>
        SELECT
            *
        FROM
            t_deposit_cup_temporary
        WHERE
            transaction_number	= '__ELEMENT01__'
    </SELECT_TEMP_DEPOSIT_CUP>

	<UPDATE_TEMP_DEPOSIT_CUP_FAIL_MAIL>
		UPDATE
            t_deposit_cup_temporary
        SET
            fail_email_flg	   = 1
        WHERE
            transaction_number = '__ELEMENT01__'
	</UPDATE_TEMP_DEPOSIT_CUP_FAIL_MAIL>

    <UPDATE_TEMP_DEPOSIT_CUP>
        UPDATE
            t_deposit_cup_temporary
        SET
            status	   = '__ELEMENT02__'
        WHERE
            transaction_number = '__ELEMENT01__'
    </UPDATE_TEMP_DEPOSIT_CUP>

    <!-- select from t_deposit_bit_temporary using bitcoin address -->
    <SELECT_TEMP_DEPOSIT_BIT>
        SELECT
            *
		FROM
			t_deposit_bit_temporary
		WHERE
			__ELEMENT01__	= '__ELEMENT02__'
			AND is_reflected	= 0
    </SELECT_TEMP_DEPOSIT_BIT>

    <!-- insert into temporary bit table -->
    <INSERT_TEMP_DEPOSIT_BIT>
        INSERT INTO  t_deposit_bit_temporary(
            transaction_number
            , user_account
            , user_fullname
            , bit_address
            , comment
            , create_time
            , language
        ) VALUES (
            '__ELEMENT01__'
            , '__ELEMENT02__'
            , '__ELEMENT03__'
            , '__ELEMENT04__'
            , '__ELEMENT05__'
            , '__ELEMENT06__'
            , '__ELEMENT07__'
        )
    </INSERT_TEMP_DEPOSIT_BIT>

    <!-- update temporary bit table -->
    <UPDATE_TEMP_DEPOSIT_BIT>
        UPDATE
			t_deposit_bit_temporary
		SET
            conversion_rate   = '__ELEMENT02__'
            ,converted_amount   = '__ELEMENT03__'
            , update_time       = '__ELEMENT04__'
            , is_reflected	   = '__ELEMENT05__'
		WHERE
			transaction_number = '__ELEMENT01__'
    </UPDATE_TEMP_DEPOSIT_BIT>

    <COUNT_DEPOSIT_CLEARSETTLE_30_DAY>
		SELECT
			SUM(IF(currency="EUR",amount,0)) AS "EUR"
		FROM
			t_deposit
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -30 DAY)
			AND method 		= 'CLEARSETTLE'
	</COUNT_DEPOSIT_CLEARSETTLE_30_DAY>

    <SELECT_TEMP_DEPOSIT_CLEARSETTLE>
        SELECT
            *
        FROM
            t_deposit_clearsettle_temporary
        WHERE
            __ELEMENT01__   = '__ELEMENT02__'
    </SELECT_TEMP_DEPOSIT_CLEARSETTLE>

    <UPDATE_TEMP_DEPOSIT_CLEARSETTLE>
        UPDATE
            t_deposit_clearsettle_temporary
        SET
            __ELEMENT01__ = '__ELEMENT02__'
        WHERE
            transaction_number = '__ELEMENT03__'
    </UPDATE_TEMP_DEPOSIT_CLEARSETTLE>

    <COUNT_CLEARSETTLE_DEPOSIT_TEMPORARY_1_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit_clearsettle_temporary
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> '__ELEMENT02__'
	</COUNT_CLEARSETTLE_DEPOSIT_TEMPORARY_1_HOUR>

    <COUNT_DEPOSIT_SUCCESS_LIMIT_24_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -24 HOUR)
			AND method 		= '__ELEMENT02__'
	</COUNT_DEPOSIT_SUCCESS_LIMIT_24_HOUR>
    <SELECT_ACTIVE_USERS_FOR_SUSPENSION_CHECKING>
        SELECT
            user_account
            , first_name
            , last_name
            , mail
            , status
            , last_lift_date
            , use_language
        FROM
            v_users_active
        WHERE
            DATEDIFF(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), create_time) >= 90
            AND account_type = 0
            AND status IN ('2','3')
    </SELECT_ACTIVE_USERS_FOR_SUSPENSION_CHECKING>
    <INSERT_INACTIVE_FEE>
        INSERT INTO t_withdraw (
            user_account
            , currency
            , fee
            , debit_currency
            , type
            , transaction_number
            , create_time
            , process_time
            , moneyout_solution
            , status
        ) VALUES (
            '__ELEMENT01__'
            , '__ELEMENT02__'
            , '__ELEMENT03__'
            , '__ELEMENT02__'
            , '__ELEMENT04__'
            , '__ELEMENT05__'
            , CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
            , CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
            , '__ELEMENT06__'
            , '__ELEMENT07__'
        )
    </INSERT_INACTIVE_FEE>
    <UPDATE_USER_STATUS_INACTIVE>
        UPDATE
            t_user
        SET
            status			= '__ELEMENT02__'
			,suspension_time = CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
        WHERE
            user_account	= '__ELEMENT01__'
    </UPDATE_USER_STATUS_INACTIVE>
	<LIST_DEPT>
		SELECT
			ad_id
			, name
			, function_list
		FROM
			t_admin_department
		WHERE
			1
	</LIST_DEPT>
	<!--
		告知詳細
	-->
	<DETAIL_DEPT>
		SELECT
			ad_id
			, name
			, function_list
		FROM
			t_admin_department
		WHERE
			ad_id = '__ELEMENT01__'
	</DETAIL_DEPT>

	<DETAIL_DEPT_BY_NAME>
		SELECT
			ad_id
			, name
			, function_list
		FROM
			t_admin_department
		WHERE
			name = '__ELEMENT01__'
	</DETAIL_DEPT_BY_NAME>

	<!--
		告知登録
	-->
	<INSERT_DEPT>
		INSERT INTO t_admin_department (
			name
			, function_list
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
		)
	</INSERT_DEPT>

	<UPDATE_DEPT>
		UPDATE
			t_admin_department
		SET
			name = '__ELEMENT02__'
			, function_list = '__ELEMENT03__'
		WHERE
			ad_id = '__ELEMENT01__'
	</UPDATE_DEPT>

	<LIST_FUNCTION>
		SELECT
			fl.fl_id AS function_id
			, fl.name AS function_name
			, fl.code AS function_code
			, fc.name AS category_name
			, fc.fc_id AS category_id
			, fc.code AS category_code
		FROM
			t_admin_function_list AS fl
			JOIN t_admin_function_category AS fc
		WHERE
			fl.fc_id = fc.fc_id
		ORDER BY
			fc.fc_id
			,fl.fl_id
	</LIST_FUNCTION>

	<LIST_DEPT_FUNCTION>
		SELECT
			fl.fl_id AS function_id
			, fl.name AS function_name
			, fl.code AS function_code
			, fc.name AS category_name
			, fc.fc_id AS category_id
			, fc.code AS category_code
			, fl.access as function_access
		FROM
			t_admin_function_list AS fl
			JOIN t_admin_function_category AS fc
		WHERE
			fl.fc_id = fc.fc_id
		AND fl.fl_id IN (__ELEMENT01__)
		ORDER BY
			fc.fc_id
			,fl.fl_id
	</LIST_DEPT_FUNCTION>

	<LIST_DEPT_USERS>
		SELECT
			 u.user_account AS user_account
			, u.last_name AS last_name
			, u.first_name AS first_name
			, l.user_name AS user_name

		FROM
			t_admin_user_access AS au
			JOIN t_user AS u ON au.u_id = u.u_id
			JOIN t_login AS l ON l.u_id = u.u_id
		WHERE
			au.department_id = '__ELEMENT01__'
			AND u.admin_flg = 1
			AND u.status = 2
	</LIST_DEPT_USERS>

	<DETAIL_FUNCTION>
		SELECT
			fl.fl_id AS function_id
			, fl.name AS function_name
			, fl.code AS function_code
			, fl.access AS function_access
			, fc.name AS category_name
			, fc.fc_id AS category_id
			, fc.code AS category_code
		FROM
			t_admin_function_list AS fl
			JOIN t_admin_function_category AS fc
		WHERE
			fl.fc_id = fc.fc_id
			AND fl.fl_id = '__ELEMENT01__'
		ORDER BY
			fc.fc_id
			,fl.fl_id
	</DETAIL_FUNCTION>

	<INSERT_FUNCTION>
		INSERT INTO t_admin_function_list (
			name
			, code
			, fc_id
			, access
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
		)
	</INSERT_FUNCTION>

	<UPDATE_FUNCTION>
		UPDATE
			t_admin_function_list
		SET
			name = '__ELEMENT02__'
			, code = '__ELEMENT03__'
			, fc_id = '__ELEMENT04__'
			, access = '__ELEMENT05__'
		WHERE
			fl_id = '__ELEMENT01__'
	</UPDATE_FUNCTION>
	<LIST_CATEGORY>
		SELECT
			fc_id AS category_id
			, name AS category_name
			, code AS category_code
		FROM
			t_admin_function_category
		WHERE
			1
	</LIST_CATEGORY>
	<DETAIL_CATEGORY>
		SELECT
			fc_id AS category_id
			, name AS category_name
			, code AS category_code
		FROM
			t_admin_function_category
		WHERE
			fc_id = '__ELEMENT01__'
	</DETAIL_CATEGORY>
	<LIST_CATEGORY_FUNCTIONS>
		SELECT
			fl.fl_id AS function_id
			, fl.name AS function_name
			, fl.code AS function_code
		FROM
			t_admin_function_list AS fl
		WHERE
			fl.fc_id = '__ELEMENT01__'
	</LIST_CATEGORY_FUNCTIONS>
	<INSERT_CATEGORY>
		INSERT INTO t_admin_function_category (
			name
			, code
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
		)
	</INSERT_CATEGORY>

	<UPDATE_CATEGORY>
		UPDATE
			t_admin_function_category
		SET
			name = '__ELEMENT02__'
			, code = '__ELEMENT03__'
		WHERE
			fc_id = '__ELEMENT01__'
	</UPDATE_CATEGORY>
	<LIST_ADMIN_USER>
		SELECT
			data.u_id										AS u_id
			, data.user_name								AS user_name
			, data.mail										AS mail
			, data.user_account								AS user_account
			, data.last_name								AS last_name
			, data.first_name								AS first_name
			, data.admin_flg								AS admin_flg
			, data.status									AS status
			, data.last_login_time							AS last_login_time
			, department.name								AS department_name
		FROM
			v_users_admin 								AS data
		INNER JOIN
			t_admin_user_access							AS admin_access
		ON (admin_access.user_account = data.user_account)
		INNER JOIN
			t_admin_department							AS department
		ON (department.ad_id = admin_access.department_id)
		WHERE
			1
			__ELEMENT01__
			__ELEMENT02__
	</LIST_ADMIN_USER>
	<COUNT_ADMIN_USER>
		SELECT
			count(*) AS admin_ctr
		FROM
			v_users_admin 								AS data
		INNER JOIN
			t_admin_user_access							AS admin_access
		ON (admin_access.user_account = data.user_account)
		INNER JOIN
			t_admin_department							AS department
		ON (department.ad_id = admin_access.department_id)
		WHERE 1
		__ELEMENT01__
	</COUNT_ADMIN_USER>
	<SELECT_ADMIN_USER>
		SELECT
			data.u_id										AS u_id
			, data.user_name								AS user_name
			, data.mail										AS mail
			, data.user_account								AS user_account
			, data.last_name								AS last_name
			, data.first_name								AS first_name
			, data.admin_flg								AS admin_flg
			, data.status									AS status
			, admin_access.password							AS password
			, department.name								AS department_name
			, admin_access.function_access					AS function_access
			, admin_access.department_id					AS department_id
		FROM
			v_users_admin 								AS data
		INNER JOIN
			t_admin_user_access							AS admin_access
		ON (admin_access.user_account = data.user_account)
		INNER JOIN
			t_admin_department							AS department
		ON (department.ad_id = admin_access.department_id)
		WHERE
			data.user_account = '__ELEMENT01__'
	</SELECT_ADMIN_USER>
	<SELECT_ADMIN_USER_BY_UID>
		SELECT
			data.u_id										AS u_id
			, data.last_name								AS last_name
			, data.first_name								AS first_name
		FROM
			v_users_admin 								AS data
		INNER JOIN
			t_admin_user_access							AS admin_access
		ON (admin_access.user_account = data.user_account)
		INNER JOIN
			t_admin_department							AS department
		ON (department.ad_id = admin_access.department_id)
		WHERE
			data.u_id = '__ELEMENT01__'
	</SELECT_ADMIN_USER_BY_UID>
	<UPDATE_LOGIN>
		UPDATE t_login
		SET
			user_name	= '__ELEMENT02__',
			password	= '__ELEMENT03__'
		WHERE
			u_id 		=  '__ELEMENT01__'
	</UPDATE_LOGIN>
	<UPDATE_ADMIN_USER>
		UPDATE t_user
		SET
			last_name		= '__ELEMENT02__',
			first_name		= '__ELEMENT03__',
			mail			= '__ELEMENT04__'
		WHERE
			user_account 	= '__ELEMENT01__'
	</UPDATE_ADMIN_USER>
	<UPDATE_ADMIN_ACCESS>
		UPDATE t_admin_user_access
		SET
			department_id		= '__ELEMENT02__',
			password			= '__ELEMENT03__',
			function_access		= '__ELEMENT04__'
		WHERE
			user_account 	= '__ELEMENT01__'
	</UPDATE_ADMIN_ACCESS>
	<DELETE_ADMIN_USER>
		DELETE
			t_user, t_login, t_admin_user_access
		FROM
			t_user
		INNER JOIN
			t_login
		ON (t_user.u_id = t_login.u_id)
		INNER JOIN
			t_admin_user_access
		ON (t_user.user_account = t_admin_user_access.user_account)
		WHERE
			t_user.user_account = '__ELEMENT01__'
	</DELETE_ADMIN_USER>
	<INSERT_ADMIN_USER>
		INSERT INTO t_user (
			u_id
			, mail
			, user_account
			, last_name
			, first_name
			, create_time
			, regist_time
			, admin_flg
			, status
			, gps_kind_of_payment
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, '__ELEMENT08__'
		)
	</INSERT_ADMIN_USER>
	<INSERT_ADMIN_ACCESS>
		INSERT INTO t_admin_user_access (
			u_id
			, user_account
			, department_id
			, function_access
			, password
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
		)
	</INSERT_ADMIN_ACCESS>
	<SELECT_ADMIN_FUNCTION_VIA_CODE>
		SELECT
			fl_id
			, name
			, fc_id
			, access
			, code
		FROM
			t_admin_function_list
		WHERE
			code = '__ELEMENT01__'
	</SELECT_ADMIN_FUNCTION_VIA_CODE>
	<SELECT_ADMIN_FUNCTION_VIA_ID>
		SELECT 
			fl.name as name
		FROM
			t_admin_function_list as fl
		JOIN
			t_admin_function_category as fc
		WHERE
			fl.fc_id = fc.fc_id
		AND
			(__ELEMENT01__)
		ORDER BY
			fc.fc_id, fl.fl_id
	</SELECT_ADMIN_FUNCTION_VIA_ID>
	<SELECT_ADMIN_FUNCTION_VIA_CATEGORY_CODE>
		SELECT
			fl.fl_id AS function_id
			, fl.name AS function_name
			, fl.code AS function_code
			, fc.name AS category_name
			, fc.fc_id AS category_id
			, fc.code AS category_code
			, fl.access as function_access
		FROM
			t_admin_function_list as fl
		INNER JOIN
			t_admin_function_category as fc
		ON (fl.fc_id = fc.fc_id)
		WHERE
			fc.code = '__ELEMENT01__'
	</SELECT_ADMIN_FUNCTION_VIA_CATEGORY_CODE>

	<SELECT_USER_BYPASS_SOLUTION>
		SELECT *
		FROM
			t_user_bypass
		WHERE
			method				= '__ELEMENT01__'
			AND solution	= '__ELEMENT02__'
			AND user_account	= '__ELEMENT03__'
	</SELECT_USER_BYPASS_SOLUTION>
	<LIST_USER_BYPASS_SOLUTION>
		SELECT *
		FROM
			t_user_bypass
		WHERE
			method				= '__ELEMENT01__'
			AND user_account	= '__ELEMENT02__'
	</LIST_USER_BYPASS_SOLUTION>
	<INSERT_USER_BYPASS_SOLUTION>
		INSERT INTO t_user_bypass (
			method
			, solution
			, user_account
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
		)
	</INSERT_USER_BYPASS_SOLUTION>
		<!-- Mikko 2019: 3501 -->
	<LIST_RISK_ACCOUNTS>
		SELECT
			user_account
			, last_name
			, first_name
			, status
			, risk_level
			, risk
			, date_tagged
		FROM
			t_user
		WHERE
			(risk_level			= '1'
		OR
			risk_level			= '2')
		__ELEMENT01__

	</LIST_RISK_ACCOUNTS>
	<DELETE_USER_BYPASS_SOLUTION>
		DELETE
		FROM
			t_user_bypass
		WHERE
			method				= '__ELEMENT01__'
			AND solution		= '__ELEMENT02__'
			AND user_account	= '__ELEMENT03__'
	</DELETE_USER_BYPASS_SOLUTION>
	<LIST_USER_TRANSACTION_FOR_SUSPENSION_CHECKING>
		SELECT
				trans.transaction_time																		AS transaction_time
				, trans.process_time																		AS process_time
				, trans.transaction_time_string																AS transaction_time_string
				, trans.process_time_string																	AS process_time_string
				, trans.transaction_number																	AS transaction_number
				, trans.transaction_type																	AS transaction_type
				, CONCAT(IFNULL(withdraw_user.first_name, ''), ' ', IFNULL(withdraw_user.last_name, ''))	AS withdraw_account_name
				, trans.withdraw_account_number																AS withdraw_account_number
				, CONCAT(IFNULL(deposit_user.first_name, ''), ' ', IFNULL(deposit_user.last_name, ''))		AS deposit_account_name
				, trans.deposit_account_number																AS deposit_account_number
				, trans.withdraw_amount																		AS withdraw_amount
				, trans.withdraw_fee																		AS withdraw_fee
				, trans.deposit_amount																		AS deposit_amount
				, trans.deposit_fee																			AS deposit_fee
				, trans.rate																				AS rate
				, trans.deposit_currency																	AS deposit_currency
				, trans.withdraw_currency																	AS withdraw_currency
				, trans.transfer_currency																	AS transfer_currency
				, trans.transfer_amount																		AS transfer_amount
				, trans.type																				AS type
				, trans.status																				AS status
				, trans.message																				AS message
		FROM (
				SELECT										/* 通常入金 */
					create_time								AS transaction_time
					, deposit_date							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(deposit_date, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '1'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_deposit
				WHERE
					user_account		= '__ELEMENT01__'
					AND CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')			> deposit_date
				UNION ALL
				SELECT										/* 通常出金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '2'									AS transaction_type
					, ''									AS withdraw_account_number
					, ''									AS deposit_account_number
					, debit_amount 		 					AS withdraw_amount
					, fee									AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, type									AS type
					, status								AS status
					, receipt_message						AS message
				FROM
					t_withdraw
				WHERE
					user_account	= '__ELEMENT01__'
					AND status		&lt;= '3'
					AND (type		= '0'
							OR type	= '3'
							OR type = '1')
				UNION ALL
				SELECT										/* 両替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '3'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, 0										AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, 0										AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
				UNION ALL
				SELECT										/* 両替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '4'									AS transaction_type
					, user_account							AS withdraw_account_number
					, 0										AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, 0										AS withdraw_fee
					, 0										AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, ''									AS message
				FROM
					t_exchange
				WHERE
					user_account	= '__ELEMENT01__'
				UNION ALL
				SELECT										/* 口座振替（出金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '5'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_transfer
				WHERE
					user_account = '__ELEMENT01__'
				UNION ALL
				SELECT										/* 口座振替（入金） */
					create_time								AS transaction_time
					, create_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '6'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, transfer_amount						AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, transfer_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_transfer
				WHERE
					to_account = '__ELEMENT01__'
				UNION ALL
				SELECT										/* 引き落し（出金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '7'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, from_fee								AS withdraw_fee
					, ''									AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_request
				WHERE
					from_account	= '__ELEMENT01__'
					AND status		= 1
				UNION ALL
				SELECT										/* 引き落し（入金） */
					update_time								AS transaction_time
					, update_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(update_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '8'									AS transaction_type
					, from_account							AS withdraw_account_number
					, to_account							AS deposit_account_number
					, ''									AS withdraw_amount
					, ''									AS withdraw_fee
					, amount								AS deposit_amount
					, to_fee								AS deposit_fee
					, ''									AS rate
					, currency								AS deposit_currency
					, ''									AS withdraw_currency
					, ''									AS transfer_currency
					, ''									AS transfer_amount
					, 0										AS type
					, 0										AS status
					, message								AS message
				FROM
					t_request
				WHERE
					to_account	= '__ELEMENT01__'
					AND status	= 1
				UNION ALL
				SELECT										/* 出金（組戻し） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '9'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, (fee + fee_refund)					AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
				FROM
					t_withdraw
				WHERE
					status				= '4'
					AND user_account	= '__ELEMENT01__'
				UNION ALL
				SELECT										/* 出金（キャンセル） */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '10'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, ''									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, fee									AS deposit_fee
					, ''									AS rate
					, debit_currency						AS deposit_currency
					, ''									AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
				FROM
					t_withdraw
				WHERE
					status				= '6'
					AND user_account	= '__ELEMENT01__'
				UNION ALL
				SELECT										/* 账户休止金 */
					create_time								AS transaction_time
					, process_time							AS process_time
					, DATE_FORMAT(create_time, '%Y/%m/%d')	AS transaction_time_string
					, DATE_FORMAT(process_time, '%Y/%m/%d')	AS process_time_string
					, transaction_number					AS transaction_number
					, '11'									AS transaction_type
					, ''									AS withdraw_account_number
					, user_account							AS deposit_account_number
					, debit_amount							AS withdraw_amount
					, fee									AS withdraw_fee
					, debit_amount							AS deposit_amount
					, ''									AS deposit_fee
					, ''									AS rate
					, ''									AS deposit_currency
					, debit_currency						AS withdraw_currency
					, 0										AS debit_currency
					, 0										AS debit_amount
					, 0										AS type
					, status								AS status
					, ''									AS message
				FROM
					t_withdraw
				WHERE
					status				= '2'
					AND user_account	= '__ELEMENT01__'
					AND type 			= '11'

			)					AS trans
			LEFT OUTER JOIN
				v_users_all		AS withdraw_user
			ON(trans.withdraw_account_number = withdraw_user.user_account)
			LEFT OUTER JOIN
				v_users_all		AS deposit_user
			ON(trans.deposit_account_number = deposit_user.user_account)
		WHERE
			1
			__ELEMENT02__
		ORDER BY
			transaction_time
	</LIST_USER_TRANSACTION_FOR_SUSPENSION_CHECKING>

	<SELECT_DEPOSIT_H2P_TEMP>
		SELECT
			*
		FROM
			t_deposit_help2pay_temporary
		WHERE
			transaction_number = '__ELEMENT01__'
	</SELECT_DEPOSIT_H2P_TEMP>	

	<INSERT_DEPOSIT_H2P_TEMP>
		INSERT INTO t_deposit_help2pay_temporary
		(
			transaction_number,
			user_account,
			amount,
			adjusted_amount,
			currency,
			method,
			deposit_date,
			deposit_bank,
			fee,
			message,
			comment,
			create_time,
			process_user,
			type,
			err_flg,
			status
		)
		values
		(
			'__ELEMENT01__',
			'__ELEMENT02__',
			'__ELEMENT03__',
			'__ELEMENT04__',
			'__ELEMENT05__',
			'__ELEMENT06__',
			'__ELEMENT07__',
			'__ELEMENT08__',
			'__ELEMENT09__',
			'__ELEMENT10__',
			'__ELEMENT11__',
			'__ELEMENT12__',
			'__ELEMENT13__',
			'__ELEMENT14__',
			'__ELEMENT15__',
			'__ELEMENT16__'
		)
	</INSERT_DEPOSIT_H2P_TEMP>

	<SELECT_WITHDRAW_H2P_TEMP>
		SELECT
			*
		FROM
			t_withdraw_h2p_temporary
		WHERE
			transaction_number = '__ELEMENT01__';
	</SELECT_WITHDRAW_H2P_TEMP>

	<UPDATE_WITHDRAW_H2P_STATUS>
		UPDATE
			t_withdraw
		SET
			status			= '__ELEMENT03__'
			, note = CONCAT(note,'__ELEMENT02__')
			, process_time	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			transaction_number	= '__ELEMENT01__'
	</UPDATE_WITHDRAW_H2P_STATUS>
	<UPDATE_WITHDRAW_H2P_TEMP_STATUS>
		UPDATE
			t_withdraw_h2p_temporary
		SET
			status			= '__ELEMENT03__'
			, note = CONCAT(note,'__ELEMENT02__')
			, process_time	= CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		WHERE
			transaction_number	= '__ELEMENT01__'
	</UPDATE_WITHDRAW_H2P_TEMP_STATUS>

	<UPDATE_WITHDRAW_H2P_KEY>
		UPDATE
			t_withdraw_h2p_temporary
		SET
			api_key			= '__ELEMENT02__'
			, language		= '__ELEMENT03__'
			, receipt_bank_name		= '__ELEMENT04__'
		WHERE
			transaction_number	= '__ELEMENT01__'
	</UPDATE_WITHDRAW_H2P_KEY>


	<SELECT_EXCHANGE_RATE_DISPLAY>
		SELECT *
		FROM
			(SELECT * FROM t_exchange_rate
			UNION ALL
			SELECT * FROM t_exchange_rate_history)
		AS a
		WHERE
			a.create_time IS NOT NULL
			__ELEMENT01__
		ORDER BY
			substring(a.create_time,1,15) DESC,
			a.to_currency ASC,
			a.from_currency ASC
	</SELECT_EXCHANGE_RATE_DISPLAY>

	<SELECT_WITHDRAW_BY_TRANSACTION_NUMBER>
		SELECT
			*
		FROM
			t_withdraw
		WHERE
			transaction_number	= '__ELEMENT01__'
	</SELECT_WITHDRAW_BY_TRANSACTION_NUMBER>
	

	<!-- ed -->
	<LIST_ACCOUNT_DUPLICATE>
		SELECT
			mail
			, user_account
			, last_name
			, first_name
			, birth
			, account_type
			, country
			, address
			, create_time
			, close_time
			, user_threshold
		FROM
			v_users_all
		WHERE
		user_threshold >= 3
		AND user_dup_source IS NOT NULL
		AND length(user_dup_source) > 0
		AND user_dup_source != '[]'
		__ELEMENT01__

	</LIST_ACCOUNT_DUPLICATE>
	
	<!-- anton -->
	<LIST_USERS_BASIC_DETAILS>
		SELECT 
			user_account,
			first_name, 
			last_name, 
			substring(mail, 1, position("@" in mail) - 1) as 'mail', 
			birth,
			status,
			DATE_FORMAT(create_time, '%Y/%m/%d %H:%i:%s')	AS create_time_string,
			address,
			user_threshold,
			create_ip_address,
			country
			FROM t_user
			WHERE 1
			__ELEMENT01__
	</LIST_USERS_BASIC_DETAILS>
	
	<!-- anton -->
	<UPDATE_USER_THRESHOLD>
		UPDATE t_user
			SET 
			user_threshold = __ELEMENT01__,
			user_dup_source = '__ELEMENT02__'
			WHERE 
			user_account = '__ELEMENT03__'
	</UPDATE_USER_THRESHOLD>
	
	<!-- anton [for JSON Enhancement] -->
	<UPDATE_USER_DUP_SOURCE>
		UPDATE t_user
			SET
			user_dup_source = '__ELEMENT01__'
			WHERE
			user_account = '__ELEMENT02__'
	</UPDATE_USER_DUP_SOURCE>
	
	<!-- anton [for JSON Enhancement] -->
	<SELECT_SPECIFIC_COLUMN_AND_TABLE>
		SELECT __ELEMENT01__ from __ELEMENT02__ 
		WHERE 1 
		__ELEMENT03__
	</SELECT_SPECIFIC_COLUMN_AND_TABLE>

	<UPDATE_CHILD_DUPLICATE>
		UPDATE t_user
			SET
			user_dup_source = '__ELEMENT01__'
			WHERE
			user_account = '__ELEMENT02__'
	</UPDATE_CHILD_DUPLICATE>

	<SELECT_TEMP_DEPOSIT_CPS>
        SELECT
            *
        FROM
            t_deposit_crypto_temporary
        WHERE
            transaction_number	= '__ELEMENT01__'
    </SELECT_TEMP_DEPOSIT_CPS>

    <UPDATE_TEMP_DEPOSIT_CPS_FAIL_MAIL>
		UPDATE
            t_deposit_crypto_temporary
        SET
            fail_email_flg	   = 1
        WHERE
            transaction_number = '__ELEMENT01__'
	</UPDATE_TEMP_DEPOSIT_CPS_FAIL_MAIL>

	<!-- insert into temporary cps table -->
    <INSERT_TEMP_DEPOSIT_CPS>
        INSERT INTO  t_deposit_crypto_temporary(
            transaction_number
            , user_account
            , user_fullname
            , currency
            , conversion_rate
            , amount
            , fee
            , crypto_value
            , crypto_currency
            , comment
            , create_time
            , update_time
            , language
            , is_reflected
        ) VALUES (
            '__ELEMENT01__'
            , '__ELEMENT02__'
            , '__ELEMENT03__'
            , '__ELEMENT04__'
            , '__ELEMENT05__'
            , '__ELEMENT06__'
            , '__ELEMENT07__'
            , '__ELEMENT08__'
            , '__ELEMENT09__'
            , '__ELEMENT10__'
            , '__ELEMENT11__'
            , '__ELEMENT12__'
            , '__ELEMENT13__'
            , '__ELEMENT14__'
        )
    </INSERT_TEMP_DEPOSIT_CPS>

		<SELECT_TEMP_DEPOSIT_CRYPTO>
		SELECT
			*
		FROM
			t_deposit_crypto_temporary
		WHERE
			transaction_number	= '__ELEMENT01__'
			AND is_reflected	= 0
	</SELECT_TEMP_DEPOSIT_CRYPTO>

	<!-- update t_deposit_crypto_temporary using transaction_number -->
	<UPDATE_TEMP_DEPOSIT_CRYPTO>
		UPDATE
			t_deposit_crypto_temporary
		SET
			crypto_currency		= '__ELEMENT02__'
			,crypto_value		= '__ELEMENT03__'
			,conversion_rate	= '__ELEMENT04__'
			,update_time		= '__ELEMENT05__'
			,is_reflected		= '__ELEMENT06__'
		WHERE
			transaction_number = '__ELEMENT01__'
	</UPDATE_TEMP_DEPOSIT_CRYPTO>
	<COPY_DEPOSIT_TRANSACTION>
		INSERT INTO t_deposit_deleted
			SELECT
				*, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), '__ELEMENT02__'
			FROM
				t_deposit
			WHERE
				d_id= '__ELEMENT01__'
	</COPY_DEPOSIT_TRANSACTION>
	<DELETE_DEPOSIT_TRANSACTION>
		DELETE
		FROM
			t_deposit
		WHERE
			d_id = '__ELEMENT01__'
	</DELETE_DEPOSIT_TRANSACTION>
	<COPY_REQUEST_TRANSACTION>
		INSERT INTO t_request_deleted
			SELECT
				*, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), '__ELEMENT02__'
			FROM
				t_request
			WHERE
				r_id= '__ELEMENT01__'
	</COPY_REQUEST_TRANSACTION>
	<DELETE_REQUEST_TRANSACTION>
		DELETE
		FROM
			t_request
		WHERE
			r_id = '__ELEMENT01__'
	</DELETE_REQUEST_TRANSACTION>
	<COPY_TRANSFER_TRANSACTION>
		INSERT INTO t_transfer_deleted
			SELECT
				*, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), '__ELEMENT02__'
			FROM
				t_transfer
			WHERE
				t_id= '__ELEMENT01__'
	</COPY_TRANSFER_TRANSACTION>
	<DELETE_TRANSFER_TRANSACTION>
		DELETE
		FROM
			t_transfer
		WHERE
			t_id = '__ELEMENT01__'
	</DELETE_TRANSFER_TRANSACTION>	
	<COPY_WITHDRAW_TRANSACTION>
		INSERT INTO t_withdraw_deleted
			SELECT
				*, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), '__ELEMENT02__'
			FROM
				t_withdraw
			WHERE
				w_id= '__ELEMENT01__'
	</COPY_WITHDRAW_TRANSACTION>
	<DELETE_WITHDRAW_TRANSACTION>
		DELETE
		FROM
			t_withdraw
		WHERE
			w_id = '__ELEMENT01__'
	</DELETE_WITHDRAW_TRANSACTION>
	<SELECT_DELETED_TRANSACTION>
		SELECT
			*
		FROM
			__ELEMENT02__
		WHERE
			transaction_number = '__ELEMENT01__'
	</SELECT_DELETED_TRANSACTION>
	<COPY_DELETED_TRANSACTION>
		INSERT INTO __ELEMENT03__ (__ELEMENT04__)
			SELECT
				__ELEMENT04__
			FROM
				__ELEMENT02__
			WHERE
				transaction_number = '__ELEMENT01__'
	</COPY_DELETED_TRANSACTION>
	<DELETE_DELETED_TRANSACTION>
		DELETE
		FROM
			__ELEMENT02__
		WHERE
			transaction_number = '__ELEMENT01__'
	</DELETE_DELETED_TRANSACTION>
	<SELECT_TRANSFER_NUMBER_BY_ID>
		SELECT
			transaction_number
		FROM
			t_transfer
		WHERE
			t_id = '__ELEMENT01__'
	</SELECT_TRANSFER_NUMBER_BY_ID>
	<SELECT_AGENT_CODE_BY_ACCOUNT>
		SELECT
			parent_agent_code
		FROM
			t_user
		WHERE
			user_account = '__ELEMENT01__'
	</SELECT_AGENT_CODE_BY_ACCOUNT>
	<SELECT_DEPOSIT_NUMBER_BY_ID>
		SELECT
			transaction_number
		FROM
			t_deposit
		WHERE
			d_id = '__ELEMENT01__'
	</SELECT_DEPOSIT_NUMBER_BY_ID>
	<SELECT_WITHDRAW_ID>
		SELECT
			transaction_number
			, status
			, note
			, order_number
		FROM
			t_withdraw
		WHERE
			w_id = '__ELEMENT01__'
	</SELECT_WITHDRAW_ID>
	<SELECT_ADMIN_BY_UID>
		SELECT
			last_name
			, first_name
		FROM
			t_user
		WHERE
			u_id = '__ELEMENT01__'
	</SELECT_ADMIN_BY_UID>
	<COUNT_HISTORY>
		SELECT
			COUNT(login_history.u_id)	AS counter
		FROM
			v_users_admin		AS users_admin
			INNER JOIN
				t_login_history	AS login_history
			ON(users_admin.u_id = login_history.u_id)
		WHERE
			1
			__ELEMENT01__
			AND transaction_type != 0
	</COUNT_HISTORY>

	<SELECT_REQUEST_BY_RID>
		SELECT
			r_id
			, transaction_number
		FROM
			t_request
		WHERE
			r_id = '__ELEMENT01__'
	</SELECT_REQUEST_BY_RID>

	<SELECT_KYC_DETAILS>
		SELECT
			kyc_validate_status
			, kyc_comment
		FROM
			t_user
		WHERE
			__ELEMENT01__
	</SELECT_KYC_DETAILS>

	<SELECT_USER_KYC>
		SELECT
			k_id
			, user_account
			, status
			, old_filename
		FROM
			t_kyc
		WHERE
			user_account = '__ELEMENT01__'
		ORDER BY
			create_time DESC
	</SELECT_USER_KYC>

	<SELECT_KYC_NAME_BY_KID>
		SELECT
			 old_filename
		FROM
			t_kyc
		WHERE
			k_id = '__ELEMENT01__'
	</SELECT_KYC_NAME_BY_KID>

	<UPDATE_USER_TRANSFER_FLG>
		UPDATE
			t_user
		SET
			transfer_flg	= '__ELEMENT01__'
		WHERE
			user_account	= '__ELEMENT02__'
	</UPDATE_USER_TRANSFER_FLG>

	<LIST_MST_NONDECIMAL_CURRENCY>
		SELECT
			c_id
			, currency_name
			, digit
		FROM
			t_mst_currency
		WHERE
			digit = 0
	</LIST_MST_NONDECIMAL_CURRENCY>

	<INSERT_CLICKED_ADS>
		INSERT INTO t_ads (
			ip_address
			, device
			, ads_id
			, ads_location
			, redirect_link
			, language
			, mail
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, '__ELEMENT07__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
		)
	</INSERT_CLICKED_ADS>

	<LIST_CLICKED_ADS>
		SELECT
			ip_address
			, device
			, ads_id
			, ads_location
			, redirect_link
			, language
			, details
			, create_time
			, mail
		FROM
			t_ads
		WHERE
			1
			__ELEMENT01__
			
		ORDER BY
			create_time DESC

	</LIST_CLICKED_ADS>

	<COUNT_ZANETAPAY_DEPOSIT_TEMPORARY_1_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit_zanetapay_temporary
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> '__ELEMENT02__'
	</COUNT_ZANETAPAY_DEPOSIT_TEMPORARY_1_HOUR>

	<COUNT_DEPOSIT_ZANETAPAY_24_HOUR>
		SELECT
			COUNT(user_account) AS counter
		FROM
			t_deposit
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -24 HOUR)
			AND method 		= 'ZANETAPAY'
	</COUNT_DEPOSIT_ZANETAPAY_24_HOUR>
	
	<COUNT_DEPOSIT_ZANETAPAY_30_DAY>
		SELECT
			SUM(IF(currency="USD",amount,0)) AS "USD"
			,SUM(IF(currency="EUR",amount,0)) AS "EUR"
			,SUM(IF(currency="GBP",amount,0)) AS "GBP"
			,SUM(IF(currency="JPY",amount,0)) AS "JPY"
		FROM
			t_deposit
		WHERE
			user_account	= '__ELEMENT01__'
			AND create_time	> DATE_ADD(CONVERT_TZ(NOW(),@@session.time_zone,'+09:00'), INTERVAL -30 DAY)
			AND method 		= 'ZANETAPAY'
	</COUNT_DEPOSIT_ZANETAPAY_30_DAY>

	<INSERT_ADS>
		INSERT INTO t_ads_files (
			a_id
			, file_name
			, ads_id
			, ads_location
			, redirect_link
			, language
			, create_time
			, created_by
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, CONVERT_TZ(NOW(),@@session.time_zone,'+09:00')
			, '__ELEMENT07__'
		)
	</INSERT_ADS>
	<LIST_IMAGES>
		SELECT
			*
		FROM
			t_ads_files
		WHERE
			1
			__ELEMENT01__
		ORDER BY
			sequence_id
	</LIST_IMAGES>
	<DISPLAY_IMAGES>
		SELECT
			*
		FROM
			t_ads_files
		WHERE
			ads_location 	= '__ELEMENT01__'
		AND
			language 		= '__ELEMENT02__'
		ORDER BY
			sequence_id
	</DISPLAY_IMAGES>
	<SELECT_AD_DETAILS>
		SELECT
			*
		FROM
			t_ads_files
		WHERE
			id = '__ELEMENT01__'
	</SELECT_AD_DETAILS>
	<UPDATE_AD_DETAILS>
		UPDATE
			t_ads_files
		SET
			ads_id 			= '__ELEMENT01__',
			redirect_link 	= '__ELEMENT02__',
			ads_location 	= '__ELEMENT03__',
			language 		= '__ELEMENT04__',
			file_name		= '__ELEMENT05__'
		WHERE
			id 				= '__ELEMENT06__'
	</UPDATE_AD_DETAILS>
	<UPDATE_AD_SEQUENCE>
		UPDATE
			t_ads_files
		SET
			sequence_id = CASE id
		WHEN
			__ELEMENT01__
		ELSE 
			sequence_id
		END
		WHERE
			id 
		IN(__ELEMENT02__)

	</UPDATE_AD_SEQUENCE>
	<DELETE_AD_FILE>
		DELETE
		FROM
			t_ads_files
		WHERE
			id = '__ELEMENT01__'
	</DELETE_AD_FILE>
	<CHECK_EXIST_AD>
		SELECT
			file_name
		FROM
			t_ads_files
		WHERE
			file_name = '__ELEMENT01__'
	</CHECK_EXIST_AD>


</SQLS>
