using HH.MData;
using HH.WMS.Common;
using HH.WMS.Entitys.Basic;
using HH.WMS.Entitys.Common;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HH.WMS.DAL.Basic
{
public class TN_AB_CUSTOMERDAL : BaseDAL
{
#region 客户分页查询
///
/// 客户分页查询
///
///
///
///
///
public List GetCustomList(SearchModel searchModel, out int total)
{
List queryList = new List();
if (searchModel.SearchCondition != null)
{
string customerName = Util.ToString(searchModel.SearchCondition.CustomerName);
if (!string.IsNullOrEmpty(customerName))
queryList.Add(Query.Matches("CN_S_CUSTOMER_NAME", "/" + customerName + "/"));
}
IMongoQuery query = null;
if (queryList.Any())
query = Query.And(queryList);
total = Convert.ToInt32(MongoDBSingleton.Instance.FindCount(query, "TN_AB_CUSTOMER"));
return MongoDBSingleton.Instance.Find(query, searchModel.PageIndex, searchModel.PageSize, null, "TN_AB_CUSTOMER");
}
#endregion
#region 获取客户
///
/// 获取客户
///
///
///
public TN_AB_CUSTOMEREntity GetSingleCustom(string customCode)
{
IMongoQuery query = Query.EQ("CN_S_CUSTOMER_CODE", customCode);
return MongoDBSingleton.Instance.FindOne(query, "TN_AB_CUSTOMER");
}
#endregion
#region 客户地址
///
/// 客户地址
///
///
///
public List GetCustomerAddress(string customCode)
{
IMongoQuery query = Query.EQ("CN_S_CODE", customCode);
return MongoDBSingleton.Instance.Find(query, "TN_AB_B_ADDRESS_INFO");
}
#endregion
#region 默认地址
///
/// 默认地址
///
///
///
public TN_AB_B_ADDRESS_INFOEntity GetDefaultAddress(string customCode)
{
List querys = new List();
querys.Add(Query.EQ("CN_S_CODE", customCode));
querys.Add(Query.EQ("CN_C_IS_DEFAULT", Constants.Y));
IMongoQuery query = null;
if (querys.Any())
query = Query.And(querys);
return MongoDBSingleton.Instance.FindOne(query, "TN_AB_B_ADDRESS_INFO");
}
#endregion
}
}