public void DecuntMoney(string tenantCode, string opratorTenantCode, EnumConsumeType type, decimal money, string remark)
        {
            var detail = new ETenantAccountDetail()
            {
                TenantCode = tenantCode,
                ConsumeMoney = money,
                OperateType = EnumOperateType.Outlay,
                ConsumeType = type,
                Remark = remark,
                CreateTime = DateTime.Now,
                OperatorTenantCode = opratorTenantCode,
            };

            using (var trans = DACFacade.Movo.TenantAccountDAC.BeginTransaction())
            {
                try
                {
                    DACFacade.Movo.TenantAccountDAC.UpdateBalance(trans, tenantCode, -money);

                    DACFacade.Movo.TenantAccountDetailDAC.Insert(trans, detail);

                    DACFacade.Movo.TenantAccountDetailDAC.CommitTransaction(trans);
                }
                catch
                {
                    DACFacade.Movo.TenantAccountDetailDAC.RollbackTransaction(trans);
                    throw;
                }
            }
        }
        public void TopUpCustomer(string fromTenantCode, string toTenantCode, decimal money)
        {
            var fromTenantDetail = new ETenantAccountDetail()
            {
                ConsumeMoney = money,
                OperateType = EnumOperateType.Outlay,
                ConsumeType = EnumConsumeType.RechargeToCustomer,
                CreateTime = DateTime.Now,
                TargetTenantCode = toTenantCode,
                TenantCode = fromTenantCode,               
                Remark = string.Empty,               
                OperatorTenantCode = fromTenantCode,
            };

            var toTenantDetail = new ETenantAccountDetail()
            {
                TenantCode = toTenantCode,
                ConsumeMoney = money,
                OperateType = EnumOperateType.Income,
                ConsumeType = EnumConsumeType.AccountIncome,
                Remark = string.Empty,
                CreateTime = DateTime.Now,
                OperatorTenantCode = fromTenantCode,
            };

            using (var trans = DACFacade.Movo.TenantAccountDAC.BeginTransaction())
            {
                try
                {
                    DACFacade.Movo.TenantAccountDAC.UpdateBalance(trans, fromTenantCode, -money);
                    DACFacade.Movo.TenantAccountDAC.UpdateBalance(trans, toTenantCode, money);

                    DACFacade.Movo.TenantAccountDetailDAC.Insert(trans, fromTenantDetail);
                    DACFacade.Movo.TenantAccountDetailDAC.Insert(trans, toTenantDetail);

                    DACFacade.Movo.TenantAccountDetailDAC.CommitTransaction(trans);
                }
                catch
                {
                    DACFacade.Movo.TenantAccountDetailDAC.RollbackTransaction(trans);
                    throw;
                }
            }
        }
Beispiel #3
0
        //私有方法
        /// <summary>
        /// 对象转换处理
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private VUserAccountDetail ConvertToAccountViewModel(ETenantAccountDetail entity)
        {
            VUserAccountDetail mode = null;
            if (entity != null)
            {
                mode = new VUserAccountDetail();
                string userName = null;
                string tenantName = string.Empty;
                mode.OperateType = entity.OperateType;
                mode.CreateTime = entity.CreateTime;
                mode.ConsumeType = entity.ConsumeType;
                mode.ConsumeTypeName = ConvertToConsumeType(entity.ConsumeType);
                mode.TargetTenantCode = entity.TargetTenantCode;

                ETenant tenant = DACFacade.Movo.TenantDAC.Select(entity.TargetTenantCode);
                if (tenant != null)
                {
                    userName = tenant.RegisterUserName;
                    tenantName = tenant.TenantName;
                }
                mode.ConsumeMoney = entity.ConsumeMoney;
                mode.Remark = entity.Remark;
                mode.UserName = userName;
                mode.TenantName = tenantName;
            }
            return mode;
        }