/* ==============================================================================
 * 功能描述：ZiChanMingXi  
 * 创 建 者：徐高庆
 * 创建日期：2023/6/8 15:42:55
 * CLR Version :4.0.30319.42000
 * ==============================================================================*/
using System;
using System.Data;

namespace ObjectModel.User
{
    /// <summary>
    /// 资产明细
    /// </summary>
    public class ZiChanMingXi
    {
        /// <summary>
        /// 玩家Id
        /// </summary>
        public int userid;

        /// <summary>
        /// 物品Id   1钻石 2礼券 3参赛卷 4门票 5复活卡 6金币（数量比较大，放入redis集合）7红包券
        /// </summary>
        public int wuId;
        /// <summary>
        /// 变更类型
        /// 钻石 1充值添加+*、 2活动赠送+（人工添加）、3比赛奖励+、4兑换金币-*、5兑换复活卡-*、6兑换装饰-、7兑换房卡、8道具消耗
        /// 礼券：1活动赠送+（人工添加）、2比赛奖励+*、3兑换道具-*、4兑换礼品
        /// 红包券：1比赛奖励+、 2兑换红包-
        /// 金币：1兑换添加+*、2活动赠送+（人工添加）、3比赛奖励+*、4娱乐馆服务费-*、5娱乐馆输赢-*、6竞赛馆报名费-*、7保险柜操作
        /// 参赛券：1、活动赠送+（人工添加）、2比赛奖励+、3比赛报名-、4兑换赠送*
        /// 门票：1、活动赠送+（人工添加）、2比赛奖励+、3比赛报名-
        /// 复活卡：1、兑换添加+*、2活动赠送+（人工添加）、3比赛奖励+、4竞赛馆消费-
        /// 房卡：1、充值添加 2、充值赠送 3、转入公会
        /// </summary>
        public int chType;
        /// <summary>
        /// 变更时间
        /// </summary>
        public DateTime createTime;
        /// <summary>
        /// 变更数量
        /// </summary>
        public long num;
        /// <summary>
        /// 余额
        /// </summary>
        public long yuE;

        public ZiChanMingXi() { }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_userid"></param>
        /// <param name="_wuid">物品Id   1钻石 2礼券 3参赛卷 4门票 5复活卡 6金币（数量比较大，放入redis集合）7红包券 8道具 9房卡</param>
        /// <param name="ct">变更类型</param>
        /// <param name="_num">变更数量</param>
        /// <param name="yue">余额</param>
        public ZiChanMingXi(int _userid, int _wuid, int ct, long _num, long yue)
        {
            this.userid = _userid;
            this.wuId = _wuid;
            this.chType = ct;
            this.num = _num;
            this.yuE = yue;
            this.createTime = DateTime.Now;
        }

        public override string ToString()
        {
            return $"userid:{userid} t:{chType} num:{num} yue:{yuE} time:{createTime.ToString("yyyy-dd-MM HH:mm:sss")}";
        }

        /// <summary>
        /// 获取插入Sql
        /// </summary>
        /// <returns></returns>
        public string GetSaveSql()
        {
            return $"insert into zichanMX(userid,wuId,chType,num,yuE) values({userid},{wuId},{chType},{num},{yuE})";
        }

        public static string GetInsertSql(int userid, int wupid, int ct, long num, long yue)
        {
            return $"insert into zichanMX(userid,wuId,chType,num,yuE) values({userid},{wupid},{ct},{num},{yue})";
        }

        public static string GetInsertSql(int userid, int wupid, int ct, long num, long yue,DateTime time)
        {
            return $"insert into zichanMX(userid,wuId,chType,num,yuE, createTime) values({userid},{wupid},{ct},{num},{yue},'{time}')";
        }

        public static ZiChanMingXi GetInstance(DataRow row)
        {
            return new ZiChanMingXi()
            {
                userid = (int)row["userid"],
                wuId = (int)row["wuId"],
                chType = (int)row["chType"],
                num = (long)row["num"],
                yuE = (long)row["yuE"],
                createTime = (DateTime)row["createTime"]
            };
        }
    }

    public class ZiChanMingXiDto : ZiChanMingXi
    {
        public int TotalCount { get; set; }
    }
}

