Пример #1
0
        /// <summary>
        /// 购物消费,更新用户余额
        /// </summary>
        /// <param name="model"></param>
        /// <param name="tx"></param>
        internal void UpdateZJ_UserBalance(ZJ_UserBalanceModel model, dynamic tx)
        {
            if (model.UserID != 0 && model.AddOrCutType != 0)
            {
                //ZJ_UserBalanceChangeLog【用户账户金额异动记录表】(资金流水账)

                #region 给流水账添加信息

                ZJ_UserBalanceChangeLogModel ulogModel = new ZJ_UserBalanceChangeLogModel();
                ulogModel.Account        = model.Account;
                ulogModel.AddOrCutAmount = model.AddOrCutAmount;
                ulogModel.AddOrCutType   = model.AddOrCutType;
                ulogModel.CreateBy       = model.CreateBy;
                ulogModel.CreateDT       = DateTime.Now;
                if (model.AddOrCutAmount >= 0)
                {
                    ulogModel.IsAddOrCut = 1;
                }
                else
                {
                    ulogModel.IsAddOrCut = 0;
                }
                ulogModel.IsDisplay = model.IsDisplay == 0 ? 0 : model.IsDisplay;
                //ulogModel.NewAmount = model.ConsumeBalance + model.AddOrCutAmount;
                //ulogModel.OldAmount = model.ConsumeBalance;
                ulogModel.OrderNo  = model.OrderNo == null ? "" : model.OrderNo;
                ulogModel.Phone    = model.Phone;
                ulogModel.RealName = model.RealName;
                ulogModel.Remark   = model.Remark;
                ulogModel.UserID   = model.UserID;

                #endregion

                //model.ConsumeBalance = model.ConsumeBalance + model.AddOrCutAmount;
                model.UpdateBy = model.CreateBy;
                model.UpdateDT = DateTime.Now;
                ZJ_UserBalanceService _zjUserBalanceService = new ZJ_UserBalanceService();
                _zjUserBalanceService.UpdateZJ_UserBalances(model, ulogModel, tx);
            }
        }
Пример #2
0
        /// <summary>
        /// 更新用户余额信息表(前台and后台)
        /// </summary>
        /// <param name="model">用户余额信息表模型</param>
        /// <returns>是否修改成功</returns>
        public void UpdateZJ_UserBalance(ZJ_UserBalanceModel model, ZJ_UserBalanceChangeLogModel ulogModel, dynamic tx)
        {
            model.IsDisplay     = 1;//默认显示
            ulogModel.IsDisplay = 1;
            ZJ_UserBalanceService zjubs = new ZJ_UserBalanceService();

            HKTHMall.Domain.AdminModel.Models.User.SearchZJ_UserBalanceModel szjub = new Domain.AdminModel.Models.User.SearchZJ_UserBalanceModel();
            szjub.UserID     = model.UserID;
            szjub.PagedIndex = 0;
            szjub.PagedSize  = 100;
            //List<HKTHMall.Domain.AdminModel.Models.User.ZJ_UserBalanceModel> list = zjubs.GetZJ_UserBalanceList(szjub).Data;
            HKTHMall.Domain.AdminModel.Models.User.ZJ_UserBalanceModel newmodel = zjubs.GetZJ_UserBalanceById(model.UserID).Data;
            //if (list!=null&&list.Count>0)
            //{
            //    model.ConsumeBalance = list[0].ConsumeBalance + ulogModel.AddOrCutAmount;
            //    ulogModel.NewAmount = model.ConsumeBalance;
            //    ulogModel.OldAmount = list[0].ConsumeBalance;
            //    tx.ZJ_UserBalance.UpdateByUserID(UserID: model.UserID, ConsumeBalance: model.ConsumeBalance, UpdateBy: model.UpdateBy, UpdateDT: model.UpdateDT);
            //}
            if (newmodel != null)
            {
                model.ConsumeBalance = newmodel.ConsumeBalance + ulogModel.AddOrCutAmount; //用户余额
                ulogModel.NewAmount  = model.ConsumeBalance;                               //用户新增的金额
                ulogModel.OldAmount  = newmodel.ConsumeBalance;                            //用户原来金额
                tx.ZJ_UserBalance.UpdateByUserID(UserID: model.UserID, ConsumeBalance: model.ConsumeBalance, UpdateBy: model.UpdateBy, UpdateDT: model.UpdateDT);
            }
            else
            {
                model.ConsumeBalance = ulogModel.AddOrCutAmount;
                ulogModel.NewAmount  = model.ConsumeBalance;
                ulogModel.OldAmount  = 0;
                model.UpdateBy       = "";
                model.UpdateDT       = DateTime.Now;
                tx.ZJ_UserBalance.Insert(model);
            }

            InsertZJ_UserBalanceChangeLog(ulogModel, tx);
        }