コード例 #1
0
        // 平台商操作运营商
        public void FutuoOperator(string fromTenantCode, string toTenantCode, decimal money,int operatorType,EnumConsumeType consumeType,string remark)
        {
            // 0为充值,1为扣款

            //decimal balance = QueryBalance(toTenantCode);

            //using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(ConnectionString))
            //{
            //    conn.Open();
            //    var tran = conn.BeginTransaction();
            //    string sql = "";

            //    EMTenantAccountDetailService serv = new EMTenantAccountDetailService();

            //    if (operatorType == 0)
            //    {
            //        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 = consumeType,
            //            OperateType = EnumOperateType.Income,
            //            CreateTime = DateTime.Now,
            //            TargetTenantCode = null,
            //            TenantCode = toTenantCode,
            //            Remark = remark,
            //            OperatorTenantCode = fromTenantCode,
            //        };
                    
            //        serv.Insert(conn, fromTenantDetail);

            //    }
            //    else
            //    {
            //        if (balance < money)
            //            throw new Exception("对不起,余额不足,扣款失败!");

            //        sql = string.Format(@"update movo_tenant_account set Balance = Balance - {0}  where TenantCode = '{1}';",
            //            money, toTenantCode);
            //        MySqlHelper.ExecuteNonQuery(conn, sql);

            //        EMTenantAccountDetail toTenantDetail = new EMTenantAccountDetail()
            //        {
            //            ConsumeMoney = money,
            //            ConsumeType = consumeType,
            //            OperateType = EnumOperateType.Outlay,
            //            TargetTenantCode = null,
            //            CreateTime = DateTime.Now,
            //            TenantCode = toTenantCode,
            //            Remark = remark,
            //            OperatorTenantCode = fromTenantCode,                         
            //        };
            //        serv.Insert(conn, toTenantDetail);
            //    }               
                
            //    tran.Commit();
            //}
            TenantCountDetailDAL dal = new TenantCountDetailDAL();
            dal.FutuoOperator(fromTenantCode, toTenantCode, money, operatorType, consumeType, remark);
        }
コード例 #2
0
        public IList<EMTenantAccountDetail> Select(List<string> tenantCodeList, DateTime StartTime, DateTime EndTime, EnumConsumeType? consumeType, int rowIndex, int pageSize, ref int rowCount, ref int IncomeRowCount, ref decimal IncomeAccount, ref int OutlayRowCount, ref decimal OutlayAccount)
        {
            IList<EMTenantAccountDetail> list = new List<EMTenantAccountDetail>();
            if (tenantCodeList == null || tenantCodeList.Count == 0)
                return list;
            StringBuilder strTenantCode = new StringBuilder();
            for (int i = 1, i_count = tenantCodeList.Count; i <= i_count; i++)
            {
                if (i == i_count)
                    strTenantCode.Append(string.Format("'{0}'", tenantCodeList[i - 1].ToString()));
                else
                    strTenantCode.Append(string.Format("'{0}',", tenantCodeList[i - 1].ToString()));
            }

            TenantCountDetailDAL dal = new TenantCountDetailDAL();
            #region 查询所有存入金额
//            string sqlIncome = string.Format(@"select ConsumeMoney from movo_tenantaccount_detail where TenantCode in ({0})
// and CreateTime between '{1}' and '{2}' and OperateType=0;", strTenantCode, StartTime, EndTime);
//            DataSet ds = MySqlHelper.ExecuteDataSet(ConnectionString, sqlIncome, null);
//            if (ds == null || ds.Tables[0].Rows.Count == 0)
//            {
//                IncomeRowCount = 0;
//                IncomeAccount = 0;
//            }
//            else
//            {
//                IncomeAccount = 0;
//                IncomeRowCount = ds.Tables[0].Rows.Count;
//                for (int i = 0, i_Count = ds.Tables[0].Rows.Count; i < i_Count; i++)
//                {
//                    IncomeAccount += Convert.ToDecimal(ds.Tables[0].Rows[i]["ConsumeMoney"]);
//                }
//            }
            
            dal.SelectIncomeAccount(strTenantCode.ToString(), StartTime, EndTime, ref IncomeRowCount, ref IncomeAccount);
            #endregion

            #region 查询所有扣款金额
             
//            string sqlOutlay = string.Format(@"select ConsumeMoney from movo_tenantaccount_detail where TenantCode in ({0})
// and CreateTime between '{1}' and '{2}' and OperateType=1;", strTenantCode, StartTime, EndTime);
//            ds = MySqlHelper.ExecuteDataSet(ConnectionString, sqlOutlay, null);
//            if (ds == null || ds.Tables[0].Rows.Count == 0)
//            {
//                OutlayRowCount = 0;
//                OutlayAccount = 0;
//            }
//            else
//            {
//                OutlayAccount = 0;
//                OutlayRowCount = ds.Tables[0].Rows.Count;
//                for (int i = 0, i_Count = ds.Tables[0].Rows.Count; i < i_Count; i++)
//                {
//                    OutlayAccount += Convert.ToDecimal(ds.Tables[0].Rows[i]["ConsumeMoney"]);
//                }
//            }
            dal.SelectOutlayAccount(strTenantCode.ToString(), StartTime, EndTime, ref OutlayRowCount, ref OutlayAccount);
            #endregion

            //string consumeTypeCondition = consumeType.HasValue ? "and ConsumeType=" + Convert.ToInt32(consumeType.Value) : "";
            
            //查询总数据笔数
//            string sqlAll = string.Format(@"select count(*) from movo_tenantaccount_detail where TenantCode in ({0})
// and CreateTime between '{1}' and '{2}' {3};", strTenantCode, StartTime, EndTime, consumeTypeCondition);
//            ds = MySqlHelper.ExecuteDataSet(ConnectionString, sqlAll, null);
//            if (ds == null || ds.Tables[0].Rows.Count == 0)
//            {
//                rowCount = 0;
//            }
//            else
//            {
//                rowCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
//            }

//            string sql = string.Format(@"select * from movo_tenantaccount_detail where TenantCode in ({0})
// and CreateTime between '{1}' and '{2}' {5} order by CreateTime desc limit {3},{4};", strTenantCode, StartTime, EndTime, rowIndex, pageSize, consumeTypeCondition);
//            ds = MySqlHelper.ExecuteDataSet(ConnectionString, sql, null);
//            if (ds == null || ds.Tables[0].Rows.Count == 0)
//                return list;
//            for (int i = 0, i_Count = ds.Tables[0].Rows.Count; i < i_Count; i++)
//            {
//                list.Add(ConvertInfo(ds.Tables[0].Rows[i]));
//            }
            //代码优化
            
            list = dal.SelectTenantCountDetail(strTenantCode.ToString(), StartTime, EndTime, consumeType, rowIndex, pageSize, ref rowCount);
            return list;
        }