public void DecuntMoney(string tenantCode, string opratorTenantCode, EnumConsumeType type, decimal money, string remark)
 {
     using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(ConnectionString))
     {
         conn.Open();
         var tran = conn.BeginTransaction();
         string sql = string.Format(@"update movo_tenant_account set Balance = Balance - {0}  where TenantCode = '{1}';",
            money, tenantCode);
         MySqlHelper.ExecuteNonQuery(conn, sql);
         EMTenantAccountDetail detail = new EMTenantAccountDetail()
         {
             ConsumeMoney = money,
             ConsumeType = type,
             OperateType = EnumOperateType.Outlay,
             CreateTime = DateTime.Now,
             TenantCode = tenantCode, 
             Remark = remark,
             OperatorTenantCode = opratorTenantCode, 
         };
         IEMTenantAccountDetailService serv = new EMTenantAccountDetailService();
         serv.Insert(conn, detail);
         tran.Commit();
     }
 }
 public void TopUpCustomer(string fromTenantCode, string toTenantCode, decimal money)
 {
     using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(ConnectionString))
     {
         conn.Open();
         var tran = conn.BeginTransaction();
         string sql = string.Format(@"update movo_tenant_account set Balance = Balance - {0}  where TenantCode = '{1}';",
             money, fromTenantCode);
         sql += string.Format(@" update movo_tenant_account set Balance = Balance + {0}  where TenantCode = '{1}';",
             money, toTenantCode);
         MySqlHelper.ExecuteNonQuery(conn, sql);
         EMTenantAccountDetail fromTenantDetail = new EMTenantAccountDetail()
         {
             ConsumeMoney = money,
             ConsumeType = EnumConsumeType.RechargeToCustomer,
             OperateType = EnumOperateType.Outlay,
             CreateTime = DateTime.Now,
             TargetTenantCode = toTenantCode,
             TenantCode = fromTenantCode,
             OperatorTenantCode = fromTenantCode,
         };
         IEMTenantAccountDetailService serv = new EMTenantAccountDetailService();
         serv.Insert(conn,fromTenantDetail);
         EMTenantAccountDetail toTenantDetail = new EMTenantAccountDetail()
         {
             ConsumeMoney = money,
             ConsumeType = EnumConsumeType.AccountIncome,
             OperateType = EnumOperateType.Income,
             CreateTime = DateTime.Now,
             TenantCode = toTenantCode,
             OperatorTenantCode = fromTenantCode,
         };
         serv.Insert(conn,toTenantDetail);
         tran.Commit();
     }
 }
示例#3
0
        public EMAccountDetailWithCount GetAccountDetailBalance(AccountDetailParam param)
        {
            EMAccountDetailWithCount model = new EMAccountDetailWithCount();
            IEMTenantAccountDetailService service = new EMTenantAccountDetailService();
  
            decimal balance = decimal.Zero;
            IList<EMTenantAccountDetail> list = service.Select(param.TenantCode, param.PageSize, out balance);
            model.Balance = balance;

            IList<EMAccountDetailViewModel> viewList = new List<EMAccountDetailViewModel>();

            for (int i = 0; i < list.Count; i++)
            {
                EMAccountDetailViewModel em = new EMAccountDetailViewModel();
                em.Index = i + 1;
                em.ConsumeMoney = list[i].ConsumeMoney;
                em.ConsumeType = list[i].ConsumeType;
                em.CreateTime = list[i].CreateTime;
                em.OperateType = list[i].OperateType;
                em.Remark = list[i].Remark;
                em.TargetTenantCode = list[i].TargetTenantCode;
                em.TargetTenantName = list[i].TargetTenantName;
                em.TenantCode = list[i].TenantCode;
                viewList.Add(em);
            }

            model.listModel = viewList;

            return model;
        }
示例#4
0
        public EMAccountDetailWithCount SearchAccountDetail(AccountDetailParam param)
        {
            EMAccountDetailWithCount model = new EMAccountDetailWithCount();
            EMTenantAccountDetailService service = new EMTenantAccountDetailService();
            int rowcount = 0;
            IList<EMTenantAccountDetail> list = service.Select(param.TenantCode, param.beginDate, param.endDate, param.consumeType, param.RowIndex, param.PageSize, ref rowcount);

            IList<EMAccountDetailViewModel> viewList = new List<EMAccountDetailViewModel>();
            
            for(int i = 0;i<list.Count;i++)
            {
                EMAccountDetailViewModel em = new EMAccountDetailViewModel();
                em.Index = i + 1;
                em.ConsumeMoney = list[i].ConsumeMoney;
                em.ConsumeType = list[i].ConsumeType;
                em.CreateTime = list[i].CreateTime;
                em.OperateType = list[i].OperateType;
                em.Remark = list[i].Remark;
                em.TargetTenantCode = list[i].TargetTenantCode;
                em.TenantCode = list[i].TenantCode;
                viewList.Add(em);
            }

            model.RowCount = rowcount;
            model.listModel = viewList;

            return model;
        }
示例#5
0
 public UserCenterAccountViewModel SearchTenantAccount(SearchAccountViewModel model)
 {
     UserCenterAccountViewModel accountViewModel = new UserCenterAccountViewModel();
     try
     {
         IEMTenantAccountDetailService detailService = new EMTenantAccountDetailService();
         //IEMTenantAccountService service = new EMTenantAccountService();
         //accountViewModel.Balance = service.QueryBalance(tenantCode);
         int rouCount = 0;
         IList<EMTenantAccountDetail> list = detailService.Select(model.TenantCode,model.BeginTime,model.EndTime,model.ConsumeType, model.RouIndex, model.PageSize, ref rouCount);
         List<UserCenterAccountDetailViewModel> detailList = new List<UserCenterAccountDetailViewModel>();
         foreach (EMTenantAccountDetail entity in list)
         {
             detailList.Add(ConvertToAccountViewModel(entity));
         }
         accountViewModel.list = detailList;
         accountViewModel.RowCount = rouCount;
         return accountViewModel;
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         return accountViewModel;
     }
 }
示例#6
0
 public UserCenterAccountViewModel GetTenantAccount(string tenantCode, int rowNumber)
 {
     UserCenterAccountViewModel model = new UserCenterAccountViewModel();
     try
     {
         EMTenantAccountDetailService detailService = new EMTenantAccountDetailService();
         EMTenantAccountService service = new EMTenantAccountService();
         model.Balance = service.QueryBalance(tenantCode);
         IList<EMTenantAccountDetail> list = detailService.SelectRecent(tenantCode, rowNumber);
         List<UserCenterAccountDetailViewModel> detailList = new List<UserCenterAccountDetailViewModel>();
         foreach (EMTenantAccountDetail entity in list)
         {
             detailList.Add(ConvertToAccountViewModel(entity));
         }
         model.list = detailList;
         return model;
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         return model;
     }
 }
        public List<EMAccountDetailViewModel> SelectAccountDetailRecentRecord(string tenantCode, int rowNumber)
        {
            try
            {
                EMTenantAccountDetailService serv = new EMTenantAccountDetailService();
                var list = serv.SelectRecent(tenantCode, rowNumber);
                if (list.IsNullOrEmpty())
                {
                    return null;
                }
                return ConvertHelper.ConvertList<EMTenantAccountDetail, EMAccountDetailViewModel>(list.ToList());
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex); 
                return null;
            }

        }