ComplianceServer/oldcode/Core.BLL/Wx/Module_Price_BL.cs

62 lines
2.2 KiB
C#

using CRM.Core.DAL;
using CRM.Core.Model;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
namespace CRM.Core.BLL.Wx
{
public class Module_Price_BL : AuditContextRepository<Model.EntityAudit.Module_Price>
{
public List<ModulePriceDto> GetModulePrice(DateTime otime)
{
var sql = @"
select CONVERT(DATE_FORMAT(p.otime2,'%Y%m'), SIGNED INTEGER) oMonth, sum(p.modulePrice) modulePrice
from module_price p
where p.otime2 < @arg_otime
group by DATE_FORMAT(p.otime2,'%Y%m')";
var param = new List<MySqlParameter> {
new MySqlParameter { ParameterName = "arg_otime", DbType = DbType.DateTime, Value = otime }
};
var ds = MySqlDbHelper.DataQueray(ConStringHelper.AuditConn, System.Data.CommandType.Text, sql, param.ToArray());
//return ds.Tables[0].ToList<ModulePriceDto>();
var list = new List<ModulePriceDto>();
foreach (DataRow row in ds.Tables[0].Rows)
{
list.Add(new ModulePriceDto() { oMonth = Convert.ToInt32(row[0]), modulePrice = Convert.ToDouble(row[1]) });
}
return list;
}
public List<string> GetModuleIds()
{
var sql = @"select m.moduleid from module_price m where m.orderid in(
select m.orderid from(
select m.orderid,m.moduleid from module_price m group by m.orderid,m.moduleid
)m
group by m.orderid
having count(*)>1
)
group by m.moduleid";
var param = new List<MySqlParameter> { };
var ds = MySqlDbHelper.DataQueray(ConStringHelper.AuditConn, System.Data.CommandType.Text, sql, param.ToArray());
//return ds.Tables[0].ToList<ModulePriceDto>();
var list = new List<string>();
foreach (DataRow row in ds.Tables[0].Rows)
{
list.Add(row[0].ToString());
}
return list;
}
public class ModulePriceDto
{
public int oMonth { get; set; }
public double modulePrice { get; set; }
}
}
}