100 lines
3.9 KiB
C#
100 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.QH;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
|
|
namespace WX.CRM.BLL.QH
|
|
{
|
|
public class QH_CUSTOMER_BL : DbContextRepository<QH_CUSTOMER>, IQH_CUSTOMER
|
|
{
|
|
/// <summary>
|
|
/// 客户信息列表
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="userAccount"></param>
|
|
/// <param name="name"></param>
|
|
/// <param name="resId"></param>
|
|
/// <param name="starttime"></param>
|
|
/// <param name="endtime"></param>
|
|
/// <returns></returns>
|
|
public List<QH_CUSTOMER> GetList(ref Pager pager, string userAccount, string name, string resId, DateTime? starttime, DateTime? endtime)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
IQueryable<QH_CUSTOMER> queryable = db.QH_CUSTOMER.AsQueryable();
|
|
if (!string.IsNullOrEmpty(userAccount))
|
|
{
|
|
queryable = queryable.Where(p => p.USERACCOUNT == userAccount);
|
|
}
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
queryable = queryable.Where(p => p.USERNAME.Contains(name));
|
|
}
|
|
if (!string.IsNullOrEmpty(resId))
|
|
{
|
|
queryable = queryable.Where(p => p.RESID == resId);
|
|
}
|
|
if (starttime.HasValue)
|
|
{
|
|
queryable = queryable.Where(p => p.RQ >= starttime);
|
|
}
|
|
if (endtime.HasValue)
|
|
{
|
|
endtime = endtime.Value.AddDays(1);
|
|
queryable = queryable.Where(p => p.RQ < endtime);
|
|
}
|
|
queryable = queryable.OrderByDescending(p => p.CTIME);
|
|
PagerUtil.SetPager(ref queryable, ref pager);
|
|
return queryable.ToList();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 我的客户信息列表
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="InnerUserId">我的id</param>
|
|
/// <param name="userAccount"></param>
|
|
/// <param name="name"></param>
|
|
/// <param name="organType"></param>
|
|
/// <param name="starttime"></param>
|
|
/// <param name="endtime"></param>
|
|
/// <returns></returns>
|
|
public List<QH_CUSTOMER> GetList(ref Pager pager, decimal InnerUserId, string userAccount, string name, string resId, DateTime? starttime, DateTime? endtime)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
IQueryable<QH_CUSTOMER> queryable = db.QH_CUSTOMER.AsQueryable();
|
|
queryable = queryable.Where(p => db.QH_CUSTOMER_SALEUSER.Where(a => a.INNERUSERID == InnerUserId).Select(a => a.USERACCOUNT).Contains(p.USERACCOUNT));
|
|
if (!string.IsNullOrEmpty(userAccount))
|
|
{
|
|
queryable = queryable.Where(p => p.USERACCOUNT.Contains(userAccount));
|
|
}
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
queryable = queryable.Where(p => p.USERNAME.Contains(name));
|
|
}
|
|
if (!string.IsNullOrEmpty(resId))
|
|
{
|
|
queryable = queryable.Where(p => p.RESID == resId);
|
|
}
|
|
if (starttime.HasValue)
|
|
{
|
|
queryable = queryable.Where(p => p.RQ >= starttime);
|
|
}
|
|
if (endtime.HasValue)
|
|
{
|
|
endtime = endtime.Value.AddDays(1);
|
|
queryable = queryable.Where(p => p.RQ < endtime);
|
|
}
|
|
queryable = queryable.OrderByDescending(p => p.CTIME);
|
|
PagerUtil.SetPager(ref queryable, ref pager);
|
|
return queryable.ToList();
|
|
}
|
|
}
|
|
}
|
|
} |