/*
 Navicat Premium Data Transfer

 Source Server         : aws-预发布
 Source Server Type    : MySQL
 Source Server Version : 80026
 Source Host           : fhq-game-mysql001.cuas8fqr6b4u.ap-northeast-1.rds.amazonaws.com:3306
 Source Schema         : incubator_game_dev

 Target Server Type    : MySQL
 Target Server Version : 80026
 File Encoding         : 65001

 Date: 26/08/2022 12:49:21
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Procedure structure for user_register
-- ----------------------------
DROP PROCEDURE IF EXISTS `user_register`;
delimiter ;;
CREATE PROCEDURE `user_register`(IN inUid BIGINT, IN inPlayerId VARCHAR(50), IN inPlatformId INT, IN inChannelId INT, IN inSubChannelId INT, IN inGameId INT, IN inPhoneNumber VARCHAR(50), IN inEmailAddress VARCHAR(50), IN inWalletAddress VARCHAR(50), IN inWalletChain VARCHAR(50), IN inShareCode VARCHAR(50), IN inLastGameId INT, IN inLastLoginIp VARCHAR(50), IN inLastLoginTime VARCHAR(50), IN inToken VARCHAR(50))
BEGIN
	IF NOT EXISTS (SELECT * FROM account_info WHERE uid = inUid) THEN
		INSERT INTO account_info(player_id, platform_id, channel_id, subchannel_id, game_id, phone_number, email_address, wallet_address, wallet_chain, share_code, last_game_id,last_login_ip, last_login_time, token)
		VALUES(inPlayerId, inPlatformId, inChannelId, inSubChannelId, inGameId, inPhoneNumber, inEmailAddress, inWalletAddress, inWalletChain, inShareCode, inLastGameId, inLastLoginIp, inLastLoginTime, inToken);
		
		IF ROW_COUNT() > 0 THEN
			SELECT uid AS resValue FROM account_info WHERE player_id = inPlayerId;
		ELSE
			SELECT -1 AS resValue;
		END IF;
	ELSE
		SELECT -2 AS resValue;
	END IF;
	
END
;;
delimiter ;

SET FOREIGN_KEY_CHECKS = 1;
