using System;
using MessagePack;
#if GameClient
using GameFramework;
#endif

namespace GameMessage
{
    /// <summary>
    /// 商品请求
    /// </summary>
    [Message(MessageCode.CommodityRequest)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class CommodityRequest : MessageData
    {
        /// <summary>
        /// 数据版本
        /// </summary>
        [Key(0)] public long Ver;

        /// <summary>
        /// 商品类型
        /// </summary>
        [Key(1)] public int MallType;

        /// <summary>
        /// 商店类型
        /// </summary>
        [Key(2)] public int StoreType;

#if GameClient
        public static CommodityRequest Create()
        {
            return ReferencePool.Acquire<CommodityRequest>();
        }

        public override void Clear()
        {
            Ver = 0;
            MallType = 0;
            StoreType = 0;
        }
#endif
    }

    /// <summary>
    /// 商品响应
    /// </summary>
    [Message(MessageCode.CommodityResponse)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class CommodityResponse : MessageData
    {
        /// <summary>
        /// 商品类型
        /// </summary>
        [Key(0)] public int MallType;

        /// <summary>
        /// 数据版本
        /// </summary>
        [Key(1)] public long Ver;

        /// <summary>
        /// 商品数据
        /// </summary>
        [Key(2)] public CommodityData[] CommodityDatas;
    }

    /// <summary>
    /// 请求实体商品列表
    /// </summary>
    [Message(MessageCode.EntityCommodityRequest)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class EntityCommodityRequest : MessageData
    {
        [Key(0)] public long Ver;

#if GameClient
        public static EntityCommodityRequest Create()
        {
            return ReferencePool.Acquire<EntityCommodityRequest>();
        }

        public override void Clear()
        {
            Ver = 0;
        }
#endif
    }

    /// <summary>
    /// 请求实体商品响应
    /// </summary>
    [Message(MessageCode.EntityCommodityResponse)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class EntityCommodityResponse : MessageData
    {
        /// <summary>
        /// 版本
        /// </summary>
        [Key(0)] public long Ver;

        [Key(1)] public EntityCommodityData[] CommodityDatas;
    }

    /// <summary>
    /// 兑换实体商品请求
    /// </summary>
    [Message(MessageCode.ExChangeEntityCommodityRequest)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class ExChangeEntityCommodityRequest : MessageData
    {
        /// <summary>
        /// 要兑换的实体商品ID
        /// </summary>
        [Key(0)] public int Id;

#if GameClient
        public static ExChangeEntityCommodityRequest Create(int id)
        {
            ExChangeEntityCommodityRequest request = ReferencePool.Acquire<ExChangeEntityCommodityRequest>();
            request.Id = id;
            return request;
        }
#endif
    }

    /// <summary>
    /// 兑换实体商品响应
    /// </summary>
    [Message(MessageCode.ExChangeEntityCommodityResponse)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class ExChangeEntityCommodityResponse : MessageData
    {
        /// <summary>
        /// 兑换的实体商品ID
        /// </summary>
        [Key(0)] public int Id;

        /// <summary>
        /// 兑换结果
        /// </summary>
        [Key(1)] public int ResultCode;
    }

    /// <summary>
    /// 兑换实体商品记录请求
    /// </summary>
    [Message(MessageCode.ExChangeEntityRecordRequest)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class ExChangeEntityRecordRequest : MessageData
    {
#if GameClient
        public static ExChangeEntityRecordRequest Create()
        {
            return ReferencePool.Acquire<ExChangeEntityRecordRequest>();
        }
#endif
    }

    /// <summary>
    /// 兑换实体商品记录响应
    /// </summary>
    [Message(MessageCode.ExChangeEntityRecordResponse)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class ExChangeEntityRecordResponse : MessageData
    {
        [Key(0)] public ExChangeEntityRecord[] Records;
    }

    /// <summary>
    /// 兑换商品请求
    /// </summary>
    [Message(MessageCode.ExchangeCommodityRequest)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class ExchangeCommodityRequest : MessageData
    {
        /// <summary>
        /// 兑换的商品ID
        /// </summary>
        [Key(0)] public int Id;

#if GameClient
        public static ExchangeCommodityRequest Create(int id)
        {
            ExchangeCommodityRequest request = ReferencePool.Acquire<ExchangeCommodityRequest>();
            request.Id = id;
            return request;
        }
#endif
    }

    /// <summary>
    /// 兑换商品响应
    /// </summary>
    [Message(MessageCode.ExchangeCommodityResponse)]
    [MessagePackObject()]
    [Obsolete("版本50以上过时")]
    public class ExchangeCommodityResponse : MessageData
    {
        /// <summary>
        /// 兑换的商品ID
        /// </summary>
        [Key(0)] public int Id;

        /// <summary>
        /// 兑换结果
        /// </summary>
        [Key(1)] public int ResultCode;
    }

    /// <summary>
    /// AppStore 票据核销请求
    /// </summary>
    [Message(MessageCode.AppStorePayVerifyRequest)]
    [MessagePackObject()]
    public class AppStorePayVerifyRequest : MessageData
    {
        /// <summary>
        /// 票据字符串
        /// </summary>
        [Key(0)] public string ReceiptStr;

#if GameClient
        public static AppStorePayVerifyRequest Create(string receiptStr)
        {
            AppStorePayVerifyRequest request = ReferencePool.Acquire<AppStorePayVerifyRequest>();
            request.ReceiptStr = receiptStr;
            return request;
        }

        public override void Clear()
        {
            ReceiptStr = null;
        }
#endif
    }

    /// <summary>
    /// AppStore 票据核销响应
    /// </summary>
    [Message(MessageCode.AppStorePayVerifyResponse)]
    [MessagePackObject()]
    public class AppStorePayVerifyResponse : MessageData
    {
        /// <summary>
        /// 核销状态
        /// </summary>
        [Key(0)] public int Statue;

        /// <summary>
        /// 票据字符串
        /// </summary>
        [Key(1)] public string ReceiptStr;

        [Key(2)] public AppStoreProductBuyData[] Data;
    }

    [MessagePackObject()]
    public class AppStoreProductBuyData
    {
        /// <summary>
        /// 商品Id
        /// </summary>
        [Key(0)] public string ProductId;

        /// <summary>
        /// 价格
        /// </summary>
        [Key(1)] public int Price;

        /// <summary>
        /// 钻石数量
        /// </summary>
        [Key(2)] public int DiamondNum;
    }

    [MessagePackObject()]
    public class CommodityData
    {
        /// <summary>
        /// 商品Id
        /// </summary>
        [Key(0)] public int Id;

        /// <summary>
        /// 标题
        /// </summary>
        [Key(1)] public string Title;

        /// <summary>
        /// 价值
        /// </summary>
        [Key(2)] public int Cost;

        /// <summary>
        /// 可获得金币的数量
        /// </summary>
        [Key(3)] public long CoinNum;

        /// <summary>
        /// 可获得参赛券的数量
        /// </summary>
        [Key(4)] public int CanSaiJuanNum;

        /// <summary>
        /// 获得复活卡的数量
        /// </summary>
        [Key(5)] public int FuHuoKaNum;

        /// <summary>
        /// 钻石数量
        /// </summary>
        [Key(6)] public int DiamondNum;

        /// <summary>
        /// 可获得VIP天数
        /// </summary>
        [Key(7)] public int VipDays;

        /// <summary>
        /// 可获得房卡的数量
        /// </summary>
        [Key(8)] public int FangKaNum;

        /// <summary>
        /// 需要支付的钻石数量
        /// </summary>
        [Key(9)] public int PayDiamond;

        /// <summary>
        /// 需要支付的礼券数量
        /// </summary>
        [Key(10)] public int PayLiJuan;

        /// <summary>
        /// 需要支付的人民币数量
        /// </summary>
        [Key(11)] public int PayRMB;

        /// <summary>
        /// 需要支付的红包券数量
        /// </summary>
        [Key(12)] public int PayHonBaoJuan;

        /// <summary>
        /// 是否是实物
        /// </summary>
        [Key(13)] public bool IsEntity;

        /// <summary>
        /// 商品新Id 对于ProductionConfig
        /// </summary>
        [Key(14)] public int NewId;
    }

    public enum MallType
    {
        /// <summary>
        /// 默认 推荐
        /// </summary>
        Default = 1,

        /// <summary>
        /// 默认 钻石
        /// </summary>
        Diamond = 2,

        /// <summary>
        /// 金币
        /// </summary>
        Coin = 3,

        /// <summary>
        /// 道具
        /// </summary>
        Prop = 4,

        /// <summary>
        /// 兑换
        /// </summary>
        Item = 5,

        /// <summary>
        /// 实物
        /// </summary>
        Entity = 6,

        /// <summary>
        /// 房卡
        /// </summary>
        FangKa = 7
    }

    public static class MallStoreType
    {
        /// <summary>
        /// 微信小程序
        /// </summary>
        public const int WXMiniGame = 1;

        /// <summary>
        /// 应用宝
        /// </summary>
        public const int YingYongBao = 2;

        /// <summary>
        /// AppStore
        /// </summary>
        public const int AppStore = 3;

        /// <summary>
        /// 默认的
        /// </summary>
        public const int Default = 4;

        /// <summary>
        /// 华为
        /// </summary>
        public const int Huawei = 5;

        /// <summary>
        /// 公众号
        /// </summary>
        public const int OfficialAccount = 6;

        /// <summary>
        /// 小米
        /// </summary>
        public const int XiaoMi = 7;

        /// <summary>
        /// Vivo
        /// </summary>
        public const int Vivo = 8;
    }

    [MessagePackObject()]
    public class EntityCommodityData
    {
        /// <summary>
        /// 商品ID
        /// </summary>
        [Key(0)] public int Id;

        /// <summary>
        /// 商品类型 0游戏币 2房卡 3比赛卷 5都市放心购电子卷 20实物  4都市放心购电子卷 小程序使用.........
        /// </summary>
        [Key(1)] public int Sty;

        /// <summary>
        /// 单价
        /// </summary>
        [Key(2)] public int Money;

        /// <summary>
        /// 商品名称
        /// </summary>
        [Key(3)] public string Title;

        /// <summary>
        /// 价值 如果是游戏 内的物体表示的是游戏内物品的数量
        /// </summary>
        [Key(4)] public int Cost;

        /// <summary>
        /// 商品描述
        /// </summary>
        [Key(5)] public string Node;

        /// <summary>
        /// 商品状态
        /// </summary>
        [Key(6)] public int State;

        /// <summary>
        /// 商品图片数量
        /// </summary>
        [Key(7)] public int ImgCount;

        /// <summary>
        /// 商品库存
        /// </summary>
        [Key(8)] public int Quantity;

        /// <summary>
        /// 商品其他描述 key_keyValue 配套使用
        /// </summary>
        [Key(9)] public string[] Key;

        [Key(10)] public string[] KeyValue;
    }

    [MessagePackObject()]
    public class ExChangeEntityRecord
    {
        /// <summary>
        /// 玩家userid
        /// </summary>
        [Key(0)] public int UserId;

        /// <summary>
        /// 商品数量
        /// </summary>
        [Key(1)] public int MallCount;

        /// <summary>
        /// 购买时间
        /// </summary>
        [Key(2)] public string ShipTime;

        /// <summary>
        /// 收货信息
        /// </summary>
        [Key(3)] public ShippingAddress Address;

        /// <summary>
        /// 数量
        /// </summary>
        [Key(4)] public int Count;

        /// <summary>
        /// 商品Id
        /// </summary>
        [Key(5)] public int CommodityId;

        /// <summary>
        /// 商品名称
        /// </summary>
        [Key(6)] public string CommodityName;

        /// <summary>
        /// 商品类型
        /// </summary>
        [Key(7)] public int Sty;

        /// <summary>
        /// 商品价值
        /// </summary>
        [Key(8)] public int Cost;

        /// <summary>
        /// 商品单价
        /// </summary>
        [Key(9)] public int Money;

        /// <summary>
        /// 商品描述
        /// </summary>
        [Key(10)] public string Desc;

        /// <summary>
        /// 状态 1表示等待发货  2表示发货中  3表示交易完成
        /// </summary>
        [Key(11)] public int State;

        /// <summary>
        /// 邮件单号
        /// </summary>
        [Key(12)] public string EmlCode;
    }

    [MessagePackObject()]
    public class ShippingAddress
    {
        /// <summary>
        /// 电话
        /// </summary>
        [Key(0)] public string Phone;

        /// <summary>
        /// 收货人名字
        /// </summary>
        [Key(1)] public string Name;

        /// <summary>
        /// 邮政编码
        /// </summary>
        [Key(2)] public string Postalcode;

        /// <summary>
        /// 用户地址
        /// </summary>
        [Key(3)] public string Address;
    }
}