using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using CY.IDAL;
|
using CY.Model;
|
using AbstractFactory;
|
using CY.IBaseDAL;
|
using CY.Infrastructure.DESEncrypt;
|
using CY.Infrastructure.Query;
|
|
namespace CY.BLL
|
{
|
public class CoreDeliverOrderBLL
|
{
|
ICoreDeliverOrderDAL _ICoreDeliverOrderDAL = null;
|
OA_StaffBLL staffBLL = null;
|
|
/// <summary>
|
/// 初始化构造
|
/// </summary>
|
public CoreDeliverOrderBLL()
|
{
|
//获取CoreDeliverOrder DAL实现
|
_ICoreDeliverOrderDAL = Factory.GetDALByInterfaceName(DALInterface.ICoreDeliverOrderDAL) as ICoreDeliverOrderDAL;
|
staffBLL = new OA_StaffBLL();
|
|
|
}
|
|
/// <summary>
|
/// 新增送货安排
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <param name="m_OA_CustomerCommunications"></param>
|
/// <param name="m_EC_AcceptWayByCustomers"></param>
|
/// <returns></returns>
|
public bool InsertModel(CY.Model.CoreDeliverOrder m_CoreDeliverOrder)
|
{
|
try
|
{
|
|
return _ICoreDeliverOrderDAL.InserModel(m_CoreDeliverOrder);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 新增送货安排
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <param name="m_OA_CustomerCommunications"></param>
|
/// <param name="m_EC_AcceptWayByCustomers"></param>
|
/// <returns></returns>
|
public int InsertModelIden(CY.Model.CoreDeliverOrder m_CoreDeliverOrder)
|
{
|
try
|
{
|
|
return _ICoreDeliverOrderDAL.InsertModelIden(m_CoreDeliverOrder);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
|
|
|
/// <summary>
|
/// 修改送货安排
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <returns></returns>
|
public bool UpdateModel(CY.Model.CoreDeliverOrder m_CoreDeliverOrder)
|
{
|
try
|
{
|
return _ICoreDeliverOrderDAL.UpdateModel(m_CoreDeliverOrder);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
|
|
|
|
|
/// <summary>
|
/// 获取全部合作客户
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public IEnumerable<CoreDeliverOrder> GetModelList()
|
{
|
Query query = new Query();
|
return _ICoreDeliverOrderDAL.SelectAllModel(query);
|
}
|
|
|
/// <summary>
|
/// 根据formid获得信息
|
/// </summary>
|
/// <param name="Keyid">编号</param>
|
/// <returns></returns>
|
public IEnumerable<Model.CoreDeliverOrder> GetModelByformid(Guid formid)
|
{
|
|
return _ICoreDeliverOrderDAL.GetModelByformid(formid);
|
}
|
|
|
/// <summary>
|
/// 根据formid获得信息
|
/// </summary>
|
/// <param name="Keyid">编号</param>
|
/// <returns></returns>
|
public IEnumerable<Model.CoreDeliverOrder> GetModelByorderid(int orderid)
|
{
|
|
return _ICoreDeliverOrderDAL.GetModelByorderid(orderid);
|
}
|
|
|
/// <summary>
|
/// 获取全部合作客户
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public CoreDeliverOrder GetModelByKeyid(string keyid)
|
{
|
|
return _ICoreDeliverOrderDAL.GetModelByKeyid(keyid);
|
}
|
|
/// <summary>
|
/// 删除合作客户
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <returns></returns>
|
public bool DeleteModel(CY.Model.CoreDeliverOrder rType)
|
{
|
try
|
{
|
_ICoreDeliverOrderDAL.DeleteModel(rType);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 查询合作客户分页列表
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <returns></returns>
|
public IEnumerable<CoreDeliverOrder> SelectModelPage(Pagination pa, Guid FirmId, int? DriverId, string shipAddress,
|
string BuyerName, string createTimeStart, string createTimeEnd)
|
{
|
string Condition = " and b.FirmId ='" + FirmId + "' and a.OrderState = 0 ";
|
if (DriverId.HasValue)
|
{
|
var oA_Staff = staffBLL.GetModelByKeyid(DriverId);
|
Condition += " and ( a.DeliveryMoble = '" + oA_Staff.MobieNum + "' or a.DriverId = '" + DriverId + "' )";
|
}
|
|
if (!string.IsNullOrEmpty(shipAddress))
|
Condition += " and b.shipAddress = '" + shipAddress + "'";
|
|
if (!string.IsNullOrEmpty(BuyerName))
|
Condition += " and c.BuyerName like '%" + BuyerName + "%'";
|
|
|
if (!string.IsNullOrEmpty(createTimeStart))
|
Condition += " and DATEDIFF(day,a.[MakeTime],'" + createTimeStart + "')<=0 ";
|
|
if (!string.IsNullOrEmpty(createTimeEnd))
|
Condition += " and DATEDIFF(day,a.[MakeTime],'" + createTimeEnd + "')>=0 ";
|
|
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy"," MakeTime desc ")
|
};
|
query.Criteria = criterias;
|
return _ICoreDeliverOrderDAL.SelectModelPage(query, pa);
|
}
|
|
|
|
/// <summary>
|
/// 查询合作客户分页列表
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <returns></returns>
|
public IEnumerable<CoreDeliverOrder> SelectModelPageLishi(Pagination pa, Guid FirmId, int? DriverId, string shipAddress,
|
string BuyerName, string createTimeStart, string createTimeEnd,string OrderState,string shifou)
|
{
|
string Condition = " and b.FirmId ='" + FirmId + "' ";
|
|
if (!string.IsNullOrEmpty(OrderState))
|
{
|
Condition += " and a.OrderState = " + OrderState + " ";
|
}
|
else
|
{
|
if (!string.IsNullOrEmpty(shifou))
|
{
|
Condition += " and a.OrderState in( 0,1 ) ";
|
}
|
else
|
{
|
Condition += " and a.OrderState in( 0,1,2 ) ";
|
}
|
|
|
}
|
if (DriverId.HasValue)
|
{
|
var oA_Staff = staffBLL.GetModelByKeyid(DriverId);
|
Condition += " and ( a.DeliveryMoble = '" + oA_Staff.MobieNum + "' or a.DriverId = '" + DriverId + "' )";
|
}
|
|
if (!string.IsNullOrEmpty(shipAddress))
|
Condition += " and b.shipAddress = '" + shipAddress + "'";
|
|
if (!string.IsNullOrEmpty(BuyerName))
|
Condition += " and c.BuyerName like '%" + BuyerName + "%'";
|
|
|
if (!string.IsNullOrEmpty(createTimeStart))
|
Condition += " and DATEDIFF(day,a.[MakeTime],'" + createTimeStart + "')<=0 ";
|
|
if (!string.IsNullOrEmpty(createTimeEnd))
|
Condition += " and DATEDIFF(day,a.[MakeTime],'" + createTimeEnd + "')>=0 ";
|
|
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy"," MakeTime desc ")
|
};
|
query.Criteria = criterias;
|
return _ICoreDeliverOrderDAL.SelectModelPage(query, pa);
|
}
|
|
|
}
|
}
|