Exemple #1
0
        /// <summary>
        /// 增加指定类型金额
        /// </summary>
        /// <param name="context"></param>
        /// <param name="customerId"></param>
        /// <param name="amountType"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public static PlatformAmount IncreasePlatformAmount(this DbContext context, PlatformAmountType amountType, long amount, string logTitle, string logDetail, PlatformFinaceType logFinaceType)
        {
            var model          = context.GetSingleOrNewPlatformAmount(amountType);
            var originalAmount = model.Amount;

            model.Amount += amount;
            var nowAmount = model.Amount;

            context.AddToPlatformAmountChangeLog(new PlatformAmountChangeLog()
            {
                AddTime        = DateTime.Now,
                Amount         = amount,
                Detail         = logDetail,
                NowAmount      = nowAmount,
                OriginalAmount = originalAmount,
                Title          = logTitle,
                Type           = logFinaceType
            });

            return(model);
        }
Exemple #2
0
        public static PlatformAmount GetSingleOrNewPlatformAmount(this DbContext context, PlatformAmountType amountType)
        {
            var model = context.Set <PlatformAmount>().Where(m => m.AmountType == amountType).FirstOrDefault();

            if (model == null)
            {
                model = new PlatformAmount
                {
                    Amount     = 0,
                    AmountType = amountType
                };
                context.AddToPlatformAmount(model);
            }
            return(model);
        }