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

	<!--
		シーケンスの取得
		条　件：シーケンスキー
	-->
	<SELECT_SEQUENCE>
		SELECT
			seq_key
			, seq_param
		FROM
			t_sequence
		WHERE
			seq_key = '__ELEMENT01__'
	</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
			, 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
			, 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
		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
		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 = NOW()
		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.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
		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>

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

	<!--
		エージェントの一覧
		条　件：なし
	-->
	<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.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>

	<!--
		エージェントコミッション取得
		条　件：エージェントコード
	-->
	<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__'
			, NOW()
		)
	</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__'
			, NOW()
			, NOW()
			, '__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>

	<!--
		手数料の取得（ターゲット別）
		条　件：なし
	-->
	<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>

	<!--
		入金の取得
		条　件：なし
	-->
	<LIST_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
			, 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_active			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__

		ORDER BY
			deposit.create_time DESC
	</LIST_DEPOSIT>

	<!--
		入金の取得（通貨別）
		条　件：なし
	-->
	<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_active	AS users
			ON(deposit.user_account = users.user_account)
		WHERE
			mst_currency.c_id > 0
			__ELEMENT01__
		GROUP BY
			currency
	</LIST_DEPOSIT_TOTAL>

	<!--
		入金の1件取得
		条　件：入金ID
	-->
	<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
		FROM
			t_deposit			AS deposit
			LEFT OUTER JOIN
				v_users_active			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__'
	</SELECT_DEPOSIT>

	<!--
		入金の登録
		登録値：口座番号
				数量
				通貨
				入金日
				入金銀行
				メッセージ
				コメント
	-->
	<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__'
			, NOW()
		)
	</INSERT_DEPOSIT>

	<!--
		入金の登録
		更新値：入金タイプ
		条　件：入金ID
	-->
	<UPDATE_DEPOSIT_TYPE>
		UPDATE
			t_deposit
		SET
			type			= '__ELEMENT02__'
			, deposit_date	= NOW()
		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
			, NOW() AS cur_time
		FROM
			t_deposit
		WHERE
			type		= '2'
			AND NOW()	> deposit_date
	</SELECT_DEPOSIT_PENDING>


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

	<!--
		出金の取得
		条　件：なし
	-->
	<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
			, 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
		FROM
			t_withdraw			AS withdraw
			INNER JOIN
				v_users_active	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__
		ORDER BY
			withdraw.create_time DESC
	</LIST_WITHDRAW>

	<!--
		出金の取得
		条　件：出金ID
	-->
	<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
		FROM
			t_withdraw	AS withdraw
			LEFT OUTER JOIN
				v_users_active	AS users
			ON(withdraw.user_account = users.user_account)
		WHERE
			w_id = '__ELEMENT01__'
	</SELECT_WITHDRAW>

	<!--
		出金の登録
		登録値：金額
				口座名義
				受取人国
				受取人住所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
			, transaction_number
			, receipt_branch_code
			, 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__'
			, NOW()
		)
	</INSERT_WITHDRAW>

	<!--
		出金の登録
		登録値：金額
				口座名義
				受取人国
				受取人住所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__'
			, NOW()
			, NOW()
		)
	</INSERT_WITHDRAW_CARD>

	<UPDATE_FAIL_WITHDRAW_CARD>
		UPDATE
			t_withdraw
		SET
			note				= 'pending'
			, status			= 5
			, process_time		= NOW()
		WHERE
			transaction_number	= '__ELEMENT01__'
	</UPDATE_FAIL_WITHDRAW_CARD>

	<UPDATE_SUCCESS_WITHDRAW_CARD>
		UPDATE
			t_withdraw
		SET
			note				= 'success'
			, status			= 2
			, process_time		= NOW()
		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	= NOW()
		WHERE
			w_id	= '__ELEMENT01__'
	</UPDATE_WITHDRAW_STATUS>

	<!--
		出金の更新
		更新値：注文番号
				備考
		条　件：出金ID
	-->
	<UPDATE_WITHDRAW_ORDER_NOTE>
		UPDATE
			t_withdraw
		SET
			order_number	= '__ELEMENT02__'
			, note			= '__ELEMENT03__'
		WHERE
			w_id	= '__ELEMENT01__'
	</UPDATE_WITHDRAW_ORDER_NOTE>

	<!--
		口座振替の取得
		登録値：送金元口座番号
				送金先口座番号
				金額
				メッセージ
	-->
	<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_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>

	<!--
		口座振替の取得
		登録値：送金元口座番号
				送金先口座番号
				金額
				メッセージ
	-->
	<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
		FROM
			v_users_active		AS users
		WHERE
			user_account IN (__ELEMENT01__)
			__ELEMENT02__
	</LIST_TRANSFER_JOIN_USER>

	<!--
		口座振替の取得
		条件：トランザクションID
	-->
	<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
		FROM
			t_transfer		AS transfer
			LEFT OUTER JOIN
				v_users_active		AS from_user
			ON(transfer.from_account = from_user.user_account)
			LEFT OUTER JOIN
				v_users_active		AS to_user
			ON(transfer.to_account = to_user.user_account)
		WHERE
			t_id = __ELEMENT01__
	</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__'
			, NOW()
		)
	</INSERT_TRANSFER>


	<!--
		口座振替の登録（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>

	<!--
		処理履歴の件数取得
		条　件：なし
	-->
	<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'
			)			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
				, 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
		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
					, ''					AS withdraw_account_number
					, ''					AS deposit_account_name
					, 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
					, 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
		__ELEMENT02__
	</LIST_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.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 NOW()			> 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>

	<!--
		処理履歴の取得
		条　件：ユーザアカウント
	-->
	<LIST_USER_TRANSACTION_FOR_PAGER>
		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 NOW()			> 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 DESC
		LIMIT
			0, 50
	</LIST_USER_TRANSACTION_FOR_PAGER>
	
	<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 NOW()			> 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)
				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										/* 引き落し（出金） */
					create_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 debit_currency = '__ELEMENT02__'
					AND status		= 1
				UNION ALL
				SELECT										/* 引き落し（入金） */
					create_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 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__'
			)					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>
		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' THEN trans.deposit_amount ELSE (trans.deposit_amount / 100) END) 		AS deposit_amount
				, (CASE WHEN  '__ELEMENT02__'='JPY' 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' THEN trans.deposit_fee ELSE (trans.deposit_fee / 100) END) ELSE (CASE WHEN  '__ELEMENT02__'='JPY' 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' 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 NOW()			> 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)
				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										/* 引き落し（出金） */
					create_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										/* 引き落し（入金） */
					create_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__'
			)					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 NOW()			> 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)
				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										/* 引き落し（出金） */
					create_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										/* 引き落し（入金） */
					create_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__'
			)					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_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__'
			, NOW()
		)
	</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		= NOW()
		WHERE
			r_id = '__ELEMENT01__'
	</UPDATE_REQUEST>

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

	<!--
		引き落としの更新（否認時）
		更新値：ステータス
		条　件：引落ID
	-->
	<UPDATE_REQUEST_ROLL_BACK>
		UPDATE
			t_request
		SET
			status			= '__ELEMENT02__'
			, send_message	= '__ELEMENT03__'
			, update_time	= NOW()
		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_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__'
		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
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, '__ELEMENT06__'
			, NOW()
		)
	</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
	</LIST_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
		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__'
		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>

	<!--
		引き落しの取得
		条　件：なし
	-->
	<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
			, 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_active	AS from_user
			ON(request.from_account = from_user.user_account)
			INNER JOIN
				v_users_active	AS to_user
			ON(request.to_account = to_user.user_account)
		WHERE
			1 __ELEMENT01__
		ORDER BY

			create_time DESC
			, update_time DESC
	</LIST_REQUEST>

	<!--
		引き落しの取得
		条　件：引き落としID
	-->
	<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
		FROM
			t_request			AS request
			LEFT OUTER JOIN
				v_users_active	AS from_user
			ON(request.from_account = from_user.user_account)
			LEFT OUTER JOIN
				v_users_active	AS to_user
			ON(request.to_account = to_user.user_account)
		WHERE
			request.r_id = '__ELEMENT01__'
	</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__'
			, NOW()
		)
	</INSERT_LOGIN_HIOSTORY>

	<!--
		最終ログイン時間の更新
		更新値：なし
		条　件：UID
	-->
	<UPDATE_LAST_LOGIN_TIME>
		UPDATE
			t_user
		SET
			last_login_time = NOW()
		WHERE
			u_id = '__ELEMENT01__'
	</UPDATE_LAST_LOGIN_TIME>

	<!--
		国マスタの取得
		条　件：言語
	-->
	<LIST_MST_COUNTRY>
		SELECT
			c_id
			, country
			, langage
			, country_code
		FROM
			t_mst_country
		WHERE
			langage = '__ELEMENT01__'
		ORDER BY
			country
	</LIST_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
					NOW() > 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
				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
				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'
			) AS data
		WHERE
			data.user_account = '__ELEMENT01__'
		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
				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')
				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
				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
				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
				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
				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'
				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'
			) AS data
		WHERE
			data.user_account = '__ELEMENT01__'
		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
				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')
				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
				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
				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
				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
				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
				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
				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'
				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'
			) AS data
		WHERE
			data.user_account		= '__ELEMENT01__'
			AND data.from_currency	= '__ELEMENT02__'
			AND '__ELEMENT03__'		> data.process_time
		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__'
			, NOW()
		)
	</INSERT_EXCHANGE_RATE>

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

	<!--
		口座番号の存在チェック
		条　件：メールアドレス
	-->
	<CHECK_EXIST_ACCOUNT_FROM_MAIL_ADDRESS>
		SELECT
			user_account
			, 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>

	<!--
		ユーザ情報の取得
		条　件：口座番号
	-->
	<SELECT_TRANSFER_ACCOUNT_INFO>
		SELECT
			user_account
			, account_number
			, user_name
		FROM
			v_users_active
		WHERE
			user_account = '__ELEMENT01__'
		UNION ALL
		SELECT
			user_account
			, account_number
			, user_name
		FROM
			v_users_active
		WHERE
			user_account = '__ELEMENT02__'
	</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__'
			, NOW()
		)
	</INSERT_COMMISION>

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

	<!--
		メール変更申請の取得
		条　件：チケット番号
	-->
	<SELECT_CHANGE_MAIL>
		SELECT
			chicket
			, user_account
			, mail
			, create_time
			, TIMESTAMPDIFF(SECOND, DATE_ADD(create_time, INTERVAL 1 HOUR), NOW()) 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
			, moneyout_solution
			, status
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT02__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
			, NOW()
			, '__ELEMENT06__'
			, '__ELEMENT07__'
		)
	</INSERT_WITHDRAW_FEE>

	<!--
		手数料を登録する
		登録値：口座番号
				通貨
				金額
				出金タイプ
	-->
	<INSERT_DEPOSIT_EXCHANGE>
		INSERT INTO t_deposit (
			user_account
			, currency
			, amount
			, type
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, NOW()
		)
	</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, NOW())											AS diff_time
			, DATE_FORMAT(SUBTIME(ADDTIME(create_time, '24:00:00'), TIME(NOW())), '%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__'
			, NOW()
		)
	</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(NOW(), '%Y/%m/%d %H:%i:%s') AS cur_time
	</SELECT_CURRENT_TIME>

	<!--
		チケットの登録
		条　件：なし
	-->
	<INSERT_CHICKET>
		INSERT INTO t_chicket(
			c_id
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, NOW()
		)
	</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, NOW())	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__'
			, NOW()
		)
	</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, NOW())	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 = NOW()
		WHERE
			user_account = '__ELEMENT01__'
	</UPDATE_USER_CLOSE_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
			, ceo_last_name
			, ceo_first_name
			, site_name
			, site_url
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, '__ELEMENT04__'
			, '__ELEMENT05__'
		)
	</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__'
			, NOW()
		)
	</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
	</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__'
			, NOW()
			, NOW()
		)
	</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	= NOW()
		WHERE
			n_id = '__ELEMENT01__'
	</UPDATE_NEWS>

	<!--
		告知一覧（ユーザ）
	-->
	<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
			NOW() >= 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
			NOW() >= 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
			NOW() >= 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__'
			, NOW()
		)
	</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
		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
		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
		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
		ORDER BY
			transaction_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__'
			, NOW()
			, '__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
		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__'
			AND NOW()		>= transfer_batch_detail.create_time
	</LIST_TRANSFER_BATCH_DETAIL>

	<!--
		口座間振替バッチ実行登録
		条　件：なし
	-->
	<INSERT_FROM_BATCH_TO_TRANSFER>
		INSERT INTO t_transfer (
			SELECT
				NULL
				, 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
				, NOW()
				, 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
			message = '__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
			, 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
			v_users_admin		AS users_admin
			LEFT OUTER JOIN
				t_login_history	AS login_history
			ON(users_admin.u_id = login_history.u_id)
		ORDER BY
			create_time DESC
	</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__'
			, NOW()
		)
	</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>

	<!--
		ユーザカードの取得
		条　件：口座番号
				カード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__'
			, NOW()
		)
	</INSERT_USER_CARDS>

	<!--
		ユーザカードの削除
		条　件：カードホルダー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
		FROM
			t_api_signature AS api_signature
			LEFT OUTER JOIN
				v_users_all AS users
			ON(users.user_account = api_signature.user_account)
	</LIST_API_SIGNATURE>

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

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

	<!--
		Postのログ登録
		登録値：ポストパラメータ
				IPアドレス
				リファラ
	-->
	<INSERT_LOG_POST>
		INSERT INTO t_log_post (
			ip_address
			, url
			, post
			, create_time
		) VALUES (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, '__ELEMENT03__'
			, NOW()
		)
	</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
			from_currency
			, to_currency
			, whole
			, markup
		FROM
			t_mst_exchange_fee
		WHERE
			m_f_id = '__ELEMENT01__'
	</LIST_MST_EXCHANGE_FEE>

	<!--
		エージェントに設定された為替手数料を取得する
		条　件：エージェントコード
	-->
	<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
		) 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__'
		ORDER BY
			create_time DESC
	</LIST_WITHDRAW_HISTORY>

	<!--
		パターンリストの取得
		条　件：なし
	-->
	<LIST_EXCHANGE_FEE_PATTERNS>
		SELECT DISTINCT
			m_f_id
			, pattern_name
		FROM
			t_mst_exchange_fee
		WHERE
			pattern_name != ''
	</LIST_EXCHANGE_FEE_PATTERNS>

	<!--
		為替手数料の削除
		条　件：エージェントコード
	-->
	<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__'
			, NOW()
		)
	</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__'
			, NOW()
		)
	</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__'
			, NOW()
			, ''
		)
	</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, NOW())	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		= NOW()
			, 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	= NOW()
		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__'
			, NOW()
			, NOW()
			, ''
		)
	</INSERT_INTO_CARD_APPLY>

	<!--
		カード申請データの更新
		条　件：カード申請ID
		更新値：カード番号
				CHID
				PIN
				ステータス
				コメント
				更新ユーザ
	-->
	<UPDATE_CARD_PIN_TIME>
		UPDATE
			t_user_cards_apply
		SET
			confirm_time = NOW()
		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
					NOW() > 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
				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
				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'
			) 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__'
			, NOW()
		)
	</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__'
			, NOW()
		)
	</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		= NOW()
		WHERE
			reference_no = '__ELEMENT01__'
	</UPDATE_RESPONSE_GPAYSAFE>

	<INSERT_AAAA>
		INSERT INTO t_test_b (
			val_1
			, val_2
			, create_time
		) VALUE (
			'__ELEMENT01__'
			, '__ELEMENT02__'
			, NOW()
		)
	</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
			, NOW()
		)
	</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(NOW(), INTERVAL -24 HOUR) AND NOW()
		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(NOW(), INTERVAL -15 DAY) AND NOW()
		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(NOW(), INTERVAL -30 DAY) AND NOW()
		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>

	<!--
		入金フラグの修正
		変更値：フラグ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(NOW(), 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
		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__
		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__
	</LIST_LOGIN_HIOSTORY_COUNT>


	<!--
		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	> '__ELEMENT02__'
	</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(NOW(), 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(NOW(), 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(NOW(), 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(NOW(), 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(NOW(), 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(NOW(), INTERVAL -30 DAY)
			AND method 		= 'CASHFLOWVM'
	</COUNT_DEPOSIT_CASHFLOW_30_DAY>
</SQLS>
