|
/**
|
* OA_CorporateClientsBLL.cs
|
*
|
* 功 能: 合作客户业务逻辑类
|
* 类 名: OA_CorporateClientsBLL
|
*
|
* Ver 变更日期 负责人 变更内容
|
* ───────────────────────────────────
|
* V0.01 2013-4-2 15:11 吴辉 初版
|
* V0.02 2013-5-29 17:43 吴崎均 增加转换在线会员为厂商客户方法
|
*
|
*
|
*
|
*
|
*
|
*
|
*/
|
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
|
{
|
/// <summary>
|
/// 合作客户的业务逻辑类
|
/// </summary>
|
public class OA_CorporateClientsBLL
|
{
|
IOA_CorporateClientsDAL _IOA_CorporateClientsDal = null;
|
IEC_AcceptWayByCustomersDAL _IEC_AcceptWayByCustomersDal = null;
|
IOA_CustomerCommunicationsDAL _IOA_CustomerCommunicationsDal = null;
|
/// <summary>
|
/// 初始化构造
|
/// </summary>
|
public OA_CorporateClientsBLL()
|
{
|
//获取OA_CorporateClients DAL实现
|
_IOA_CorporateClientsDal = Factory.GetDALByInterfaceName(DALInterface.IOA_CorporateClientsDAL) as IOA_CorporateClientsDAL;
|
|
_IEC_AcceptWayByCustomersDal = Factory.GetDALByInterfaceName(DALInterface.IEC_AcceptWayByCustomersDAL) as IEC_AcceptWayByCustomersDAL;
|
|
_IOA_CustomerCommunicationsDal = Factory.GetDALByInterfaceName(DALInterface.IOA_CustomerCommunicationsDAL) as IOA_CustomerCommunicationsDAL;
|
}
|
|
/// <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.OA_CorporateClients m_OA_CorporateClients, OA_CustomerCommunications m_OA_CustomerCommunications, EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.InsertModel(m_OA_CorporateClients, m_OA_CustomerCommunications, m_EC_AcceptWayByCustomers);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 修改合作客户
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <returns></returns>
|
public bool UpdateModel(CY.Model.OA_CorporateClients m_OA_CorporateClients)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.UpdateModel(m_OA_CorporateClients);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 设置自动外协
|
/// </summary>
|
/// <param name="Keyid"></param>
|
/// <param name="i"></param>
|
/// <returns></returns>
|
public bool EditModel(Guid Keyid, string i)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.EditModel(Keyid, i);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 修改合作客户
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <returns></returns>
|
public bool UpdateModel(CY.Model.OA_CorporateClients m_OA_CorporateClients, OA_CustomerCommunications m_OA_CustomerCommunications, EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.UpdateModel(m_OA_CorporateClients, m_OA_CustomerCommunications, m_EC_AcceptWayByCustomers);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 删除合作客户
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <returns></returns>
|
public bool DeleteModel(CY.Model.OA_CorporateClients rType)
|
{
|
try
|
{
|
_IOA_CorporateClientsDal.DeleteModel(rType);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 查询合作客户分页列表 所有非必要参数设置默认值
|
/// //廖 新增加是否需要例行维护,是否需要节假日维护两个字段查询 20210913
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> GetModelPageListEx(Pagination pa, Guid FirmId, string UserName = "", DateTime? beginTime = null,
|
DateTime? endTime = null, string AccountManagerId = "", string BusinessManagerId = "", string CustomerIndustriesId = "", string CustomerTypeId = "", string DegreeImportanId = "", string LastOrderTime = "", string selOrderCount = "", string selOrderMoney = "", string SourcesInfoId = "", string TurnoverIntentionId = "",
|
string OrderCount = "", string OrderMoney = "", string UserNum = "", string selLastOrderTime = "", string Province = "", string City = "", string County = "", bool IsStaff = true, Guid? StaffMemberId = null, int? StaffId = null, string Shifouwanjie = null,
|
bool? NeedWeifu = null, bool? NeedJiejiaRiWeiFu = null)
|
{
|
string Condition = " and a.FirmId ='" + FirmId + "'";
|
|
if (!string.IsNullOrEmpty(UserNum))
|
Condition += " and CustomerId = " + UserNum;
|
|
//廖 新增加是否需要例行维护,是否需要节假日维护两个字段查询 20210913
|
if (NeedWeifu != null)
|
|
Condition += string.Format(" and NeedWiHu='{0}'", NeedWeifu);
|
|
if (NeedJiejiaRiWeiFu != null)
|
|
Condition += string.Format(" and JieJiaRiWiHu='{0}'", NeedJiejiaRiWeiFu);
|
|
|
|
|
if (!string.IsNullOrEmpty(UserName))
|
Condition += " and CompanyName like '%" + UserName + "%'";
|
|
if (beginTime.HasValue)
|
Condition += string.Format(" and CAST(CreateTime AS DATE) >='{0}'", beginTime);
|
|
if (endTime.HasValue)
|
Condition += string.Format(" and CAST(CreateTime AS DATE) <='{0}'", endTime);
|
|
if (!string.IsNullOrEmpty(SourcesInfoId))
|
Condition += string.Format(" and SourcesInfoId='{0}'", SourcesInfoId);
|
|
if (!string.IsNullOrEmpty(CustomerIndustriesId))
|
Condition += string.Format(" and CustomerIndustriesId='{0}'", CustomerIndustriesId);
|
|
if (!string.IsNullOrEmpty(AccountManagerId))
|
Condition += string.Format(" and AccountManagerId='{0}'", AccountManagerId);
|
|
if (!string.IsNullOrEmpty(Shifouwanjie))
|
Condition += string.Format(" and Shifouwanjie='{0}'", Shifouwanjie);
|
|
if (!string.IsNullOrEmpty(BusinessManagerId))
|
Condition += string.Format(" and BusinessManagerId='{0}'", BusinessManagerId);
|
|
if (!string.IsNullOrEmpty(CustomerTypeId))
|
Condition += string.Format(" and CustomerTypeId='{0}'", CustomerTypeId);
|
|
if (!string.IsNullOrEmpty(TurnoverIntentionId))
|
Condition += string.Format(" and CreditId='{0}'", TurnoverIntentionId);
|
|
if (!string.IsNullOrEmpty(DegreeImportanId))
|
Condition += string.Format(" and DegreeImportanId='{0}'", DegreeImportanId);
|
|
if (!string.IsNullOrEmpty(selOrderCount) && !string.IsNullOrEmpty(OrderCount))
|
Condition += string.Format(" and OrderCount{0}'{1}'", selOrderCount, OrderCount);
|
|
if (!string.IsNullOrEmpty(selOrderMoney) && !string.IsNullOrEmpty(OrderMoney))
|
Condition += string.Format(" and OrderMoney{0}'{1}'", selOrderMoney, OrderMoney);
|
|
if (!string.IsNullOrEmpty(selLastOrderTime) && !string.IsNullOrEmpty(LastOrderTime))
|
Condition += string.Format(" and CAST(LastOrderTime AS DATE) {0} CAST(getdate()-{1} AS date)", LastOrderTime, selLastOrderTime);
|
|
if (IsStaff)
|
{
|
if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City) && !string.IsNullOrEmpty(County))
|
Condition += string.Format(" and Province='{0}' and City='{1}' and County='{2}'", Province, City, County);
|
else if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City))
|
Condition += string.Format(" and Province='{0}' and City='{1}' and (( ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{2}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{2}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{3}' or BusinessManagerId='{3}' )", Province, City, StaffMemberId, StaffId);
|
else if (!string.IsNullOrEmpty(Province))
|
Condition += string.Format(" and Province='{0}' and (( City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) and ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{2}' or BusinessManagerId='{2}' )", Province, StaffMemberId, StaffId);
|
else
|
Condition += string.Format(" and (( Province IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageProvince FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{1}' or BusinessManagerId='{1}' ) ", StaffMemberId, StaffId);
|
}
|
else
|
{
|
if (!string.IsNullOrEmpty(Province))
|
Condition += string.Format(" and Province='{0}'", Province);
|
|
if (!string.IsNullOrEmpty(City))
|
Condition += string.Format(" and City='{0}'", City);
|
|
if (!string.IsNullOrEmpty(County))
|
Condition += string.Format(" and County='{0}'", County);
|
}
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy"," CustomerId DESC ")
|
};
|
query.Criteria = criterias;
|
return _IOA_CorporateClientsDal.SelectModelPage(query, pa);
|
}
|
|
|
/// <summary>
|
/// 查询合作客户分页列表
|
/// //廖 新增加是否需要例行维护,是否需要节假日维护两个字段查询 20210913
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> GetModelPageList(Pagination pa, Guid FirmId, string UserName, DateTime? beginTime,
|
DateTime? endTime, string AccountManagerId, string BusinessManagerId, string CustomerIndustriesId, string CustomerTypeId, string DegreeImportanId,string LastOrderTime, string selOrderCount, string selOrderMoney, string SourcesInfoId, string TurnoverIntentionId,
|
string OrderCount, string OrderMoney, string UserNum, string selLastOrderTime, string Province, string City, string County, bool IsStaff, Guid StaffMemberId,int? StaffId,string Shifouwanjie=null,
|
bool? NeedWeifu=null,bool?NeedJiejiaRiWeiFu=null, string selHetongshangchuan = null)
|
{
|
string Condition = " and a.FirmId ='" + FirmId + "'";
|
|
if (!string.IsNullOrEmpty(UserNum))
|
Condition += " and CustomerId = " + UserNum;
|
|
//廖 新增加是否需要例行维护,是否需要节假日维护两个字段查询 20210913
|
if (NeedWeifu!=null)
|
|
Condition += string.Format(" and NeedWiHu='{0}'", NeedWeifu);
|
|
if (NeedJiejiaRiWeiFu != null)
|
|
Condition += string.Format(" and JieJiaRiWiHu='{0}'", NeedJiejiaRiWeiFu);
|
|
|
|
|
if (!string.IsNullOrEmpty(UserName))
|
Condition += " and CompanyName like '%" + UserName + "%'";
|
|
if (beginTime.HasValue)
|
Condition += string.Format(" and CAST(CreateTime AS DATE) >='{0}'", beginTime);
|
|
if (endTime.HasValue)
|
Condition += string.Format(" and CAST(CreateTime AS DATE) <='{0}'", endTime);
|
|
if (!string.IsNullOrEmpty(SourcesInfoId))
|
Condition += string.Format(" and SourcesInfoId='{0}'", SourcesInfoId);
|
|
if (!string.IsNullOrEmpty(CustomerIndustriesId))
|
Condition += string.Format(" and CustomerIndustriesId='{0}'", CustomerIndustriesId);
|
|
if (!string.IsNullOrEmpty(AccountManagerId))
|
Condition += string.Format(" and AccountManagerId='{0}'", AccountManagerId);
|
|
if (!string.IsNullOrEmpty(Shifouwanjie))
|
Condition += string.Format(" and Shifouwanjie='{0}'", Shifouwanjie);
|
|
if (!string.IsNullOrEmpty(BusinessManagerId))
|
Condition += string.Format(" and BusinessManagerId='{0}'", BusinessManagerId);
|
|
if (!string.IsNullOrEmpty(CustomerTypeId))
|
Condition += string.Format(" and CustomerTypeId='{0}'", CustomerTypeId);
|
|
if (!string.IsNullOrEmpty(TurnoverIntentionId))
|
Condition += string.Format(" and CreditId='{0}'", TurnoverIntentionId);
|
|
if (!string.IsNullOrEmpty(DegreeImportanId))
|
Condition += string.Format(" and DegreeImportanId='{0}'", DegreeImportanId);
|
|
if (!string.IsNullOrEmpty(selOrderCount) && !string.IsNullOrEmpty(OrderCount))
|
Condition += string.Format(" and OrderCount{0}'{1}'", selOrderCount, OrderCount);
|
|
if (!string.IsNullOrEmpty(selOrderMoney) && !string.IsNullOrEmpty(OrderMoney))
|
Condition += string.Format(" and OrderMoney{0}'{1}'", selOrderMoney, OrderMoney);
|
|
if (!string.IsNullOrEmpty(selHetongshangchuan))
|
{
|
if (selHetongshangchuan == "1")
|
{
|
Condition += string.Format(" and EXISTS ( select CorporateClientsid from [dbo].[OA_CorporateClientContract] where CorporateClientsid=a.Keyid ) ");
|
}
|
else
|
{
|
Condition += string.Format(" and NOT EXISTS ( select CorporateClientsid from [dbo].[OA_CorporateClientContract] where CorporateClientsid=a.Keyid ) ");
|
}
|
}
|
|
|
|
if (!string.IsNullOrEmpty(selLastOrderTime) && !string.IsNullOrEmpty(LastOrderTime))
|
Condition += string.Format(" and CAST(LastOrderTime AS DATE) {0} CAST(getdate()-{1} AS date)", LastOrderTime, selLastOrderTime);
|
|
if (IsStaff)
|
{
|
if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City) && !string.IsNullOrEmpty(County))
|
Condition += string.Format(" and Province='{0}' and City='{1}' and County='{2}'", Province, City, County);
|
else if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City))
|
Condition += string.Format(" and Province='{0}' and City='{1}' and (( ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{2}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{2}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{3}' or BusinessManagerId='{3}' )", Province, City, StaffMemberId, StaffId);
|
else if (!string.IsNullOrEmpty(Province))
|
Condition += string.Format(" and Province='{0}' and (( City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) and ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{2}' or BusinessManagerId='{2}' )", Province, StaffMemberId, StaffId);
|
else
|
Condition += string.Format(" and (( Province IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageProvince FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{1}' or BusinessManagerId='{1}' ) ", StaffMemberId, StaffId);
|
}
|
else
|
{
|
if (!string.IsNullOrEmpty(Province))
|
Condition += string.Format(" and Province='{0}'", Province);
|
|
if (!string.IsNullOrEmpty(City))
|
Condition += string.Format(" and City='{0}'", City);
|
|
if (!string.IsNullOrEmpty(County))
|
Condition += string.Format(" and County='{0}'", County);
|
}
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy"," CustomerId DESC ")
|
};
|
query.Criteria = criterias;
|
return _IOA_CorporateClientsDal.SelectModelPage(query, pa);
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
/// 查询客户预付款列表
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> GetModelPageListForPrepayments(Pagination pa, Guid FirmId, string UserName, DateTime? beginTime, DateTime? endTime, string AccountManagerId, string BusinessManagerId, string CustomerIndustriesId, string CustomerTypeId, string DegreeImportanId, string LastOrderTime, string selOrderCount, string selOrderMoney, string SourcesInfoId, string TurnoverIntentionId, string OrderCount, string OrderMoney, string UserNum, string selLastOrderTime, string Province, string City, string County, string selPrepaidBalance, string PrepaidBalance, bool IsStaff, Guid StaffMemberId,int? StaffId)
|
{
|
string Condition = " and a.FirmId ='" + FirmId + "'";
|
|
if (!string.IsNullOrEmpty(UserNum))
|
{
|
Condition += " and CustomerId = " + UserNum;
|
}
|
|
if (!string.IsNullOrEmpty(UserName))
|
{
|
Condition += " and CompanyName like '%" + UserName + "%'";
|
}
|
if (beginTime.HasValue)
|
{
|
Condition += string.Format(" and CAST(CreateTime AS DATE) >='{0}'", beginTime);
|
}
|
|
if (endTime.HasValue)
|
{
|
Condition += string.Format(" and CAST(CreateTime AS DATE) <='{0}'", endTime);
|
}
|
|
if (!string.IsNullOrEmpty(SourcesInfoId))
|
{
|
Condition += string.Format(" and SourcesInfoId='{0}'", SourcesInfoId);
|
}
|
if (!string.IsNullOrEmpty(CustomerIndustriesId))
|
{
|
Condition += string.Format(" and CustomerIndustriesId='{0}'", CustomerIndustriesId);
|
}
|
if (!string.IsNullOrEmpty(AccountManagerId))
|
{
|
Condition += string.Format(" and AccountManagerId='{0}'", AccountManagerId);
|
}
|
if (!string.IsNullOrEmpty(BusinessManagerId))
|
{
|
Condition += string.Format(" and BusinessManagerId='{0}'", BusinessManagerId);
|
}
|
if (!string.IsNullOrEmpty(CustomerTypeId))
|
{
|
Condition += string.Format(" and CustomerTypeId='{0}'", CustomerTypeId);
|
}
|
if (!string.IsNullOrEmpty(TurnoverIntentionId))
|
{
|
Condition += string.Format(" and CreditId='{0}'", TurnoverIntentionId);
|
}
|
if (!string.IsNullOrEmpty(DegreeImportanId))
|
{
|
Condition += string.Format(" and DegreeImportanId='{0}'", DegreeImportanId);
|
}
|
if (!string.IsNullOrEmpty(selOrderCount) && !string.IsNullOrEmpty(OrderCount))
|
{
|
Condition += string.Format(" and OrderCount{0}'{1}'", selOrderCount, OrderCount);
|
}
|
if (!string.IsNullOrEmpty(selOrderMoney) && !string.IsNullOrEmpty(OrderMoney))
|
{
|
Condition += string.Format(" and OrderMoney{0}'{1}'", selOrderMoney, OrderMoney);
|
}
|
if (!string.IsNullOrEmpty(selLastOrderTime) && !string.IsNullOrEmpty(LastOrderTime))
|
{
|
Condition += string.Format("and CAST(LastOrderTime AS DATE) {0} CAST(getdate()-{1} AS date)", LastOrderTime, selLastOrderTime);
|
}
|
|
//if (IsStaff)
|
//{
|
// if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City) && !string.IsNullOrEmpty(County))
|
// Condition += string.Format(" and Province='{0}' and City='{1}' and County='{2}'", Province, City, County);
|
// else if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City))
|
// Condition += string.Format(" and Province='{0}' and City='{1}' and (( County IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'')+ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{3}' or AccountManagerId='{3}' )", Province, City, StaffMemberId, StaffId);
|
// else if (!string.IsNullOrEmpty(Province))
|
// Condition += string.Format(" and Province='{0}' and (( City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) and County IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'')+ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{2}' or AccountManagerId='{2}' )", Province, StaffMemberId, StaffId);
|
// else
|
// Condition += string.Format(" and (( Province IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageProvince FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and County IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'')+ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{1}' or AccountManagerId='{1}' ) ", StaffMemberId, StaffId);
|
//}
|
if (IsStaff)
|
{
|
if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City) && !string.IsNullOrEmpty(County))
|
Condition += string.Format(" and Province='{0}' and City='{1}' and County='{2}'", Province, City, County);
|
else if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City))
|
Condition += string.Format(" and Province='{0}' and City='{1}' and (( ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{2}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{2}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{3}' or BusinessManagerId='{3}' )", Province, City, StaffMemberId, StaffId);
|
else if (!string.IsNullOrEmpty(Province))
|
Condition += string.Format(" and Province='{0}' and (( City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) and ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{2}' or BusinessManagerId='{2}' )", Province, StaffMemberId, StaffId);
|
else
|
Condition += string.Format(" and (( Province IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageProvince FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and ((SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1)) OR (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=County AND CityId = (SELECT TOP(1) Keyid FROM dbo.Sys_CitySite WHERE Name=City )) IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{1}' or BusinessManagerId='{1}' ) ", StaffMemberId, StaffId);
|
}
|
else
|
{
|
if (!string.IsNullOrEmpty(Province))
|
Condition += string.Format(" and Province='{0}'", Province);
|
|
if (!string.IsNullOrEmpty(City))
|
Condition += string.Format(" and City='{0}'", City);
|
|
if (!string.IsNullOrEmpty(County))
|
Condition += string.Format(" and County='{0}'", County);
|
}
|
|
if (!string.IsNullOrEmpty(selPrepaidBalance) && !string.IsNullOrEmpty(PrepaidBalance))
|
{
|
Condition += string.Format(" and Prepayments{0}'{1}'", selPrepaidBalance, PrepaidBalance);
|
}
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy"," CustomerId ASC ")
|
};
|
query.Criteria = criterias;
|
return _IOA_CorporateClientsDal.SelectModelPage(query, pa);
|
}
|
|
/// <summary>
|
/// 获取全部合作客户
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> GetModelList()
|
{
|
Query query = new Query();
|
return _IOA_CorporateClientsDal.SelectAllModel(query);
|
}
|
|
/// <summary>
|
/// 根据厂商编号查询全部会员
|
/// </summary>
|
/// <param name="FirmId">编号</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> SelectListByFirmId(Guid FirmId)
|
{
|
IEnumerable<OA_CorporateClients> result = null;
|
try
|
{
|
result = _IOA_CorporateClientsDal.SelectListByFirmId(FirmId);//执行查询
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return result;//返回结果
|
}
|
|
/// <summary>
|
/// 根据编号获取单个合作客户
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public OA_CorporateClients GetModel(Guid Keyid)
|
{
|
OA_CorporateClients result = null;
|
try
|
{
|
result = _IOA_CorporateClientsDal.SelectModelByKeyid(Keyid) as OA_CorporateClients;//执行查询
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return result;//返回结果
|
}
|
|
/// <summary>
|
/// 获取单个合作客户详细信息
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public OA_CorporateClients GetModelDetail(Guid Keyid)
|
{
|
OA_CorporateClients result = null;
|
try
|
{
|
result = _IOA_CorporateClientsDal.SelectModelDetailByKeyid(Keyid) as OA_CorporateClients;//执行查询
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return result;//返回结果
|
}
|
|
/// <summary>
|
/// 获取单个合作客户通讯信息
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public OA_CustomerCommunications GetModel_CustomerCommunications(Guid Keyid)
|
{
|
OA_CustomerCommunications result = null;
|
try
|
{
|
result = _IOA_CustomerCommunicationsDal.SelectModelByKeyid(Keyid) as OA_CustomerCommunications;//执行查询
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return result;//返回结果
|
}
|
|
/// <summary>
|
/// 获取单个合作客户收货地址
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public EC_AcceptWayByCustomers GetModel_AcceptWayByCustomers(Guid TargetId)
|
{
|
EC_AcceptWayByCustomers result = null;
|
try
|
{
|
result = _IEC_AcceptWayByCustomersDal.SelectModelByTargetId(TargetId) as EC_AcceptWayByCustomers;//执行查询
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return result;//返回结果
|
}
|
|
/// <summary>
|
/// 获取单个合作客户通讯信息
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public OA_CustomerCommunications GetModel_CustomerCommunications(Guid FirmId, Guid MemberId)
|
{
|
OA_CustomerCommunications result = null;
|
try
|
{
|
result = _IOA_CustomerCommunicationsDal.SelectModelByKeyid(SelectModelByFirmIdandMemberId(FirmId, MemberId).Keyid) as OA_CustomerCommunications;//执行查询
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return result;//返回结果
|
}
|
|
/// <summary>
|
/// 获取单个合作客户收货地址
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public EC_AcceptWayByCustomers GetModel_AcceptWayByCustomers(Guid FirmId, Guid MemberId)
|
{
|
EC_AcceptWayByCustomers result = null;
|
try
|
{
|
result = _IEC_AcceptWayByCustomersDal.SelectModelByTargetId(SelectModelByFirmIdandMemberId(FirmId, MemberId).Keyid) as EC_AcceptWayByCustomers;//执行查询
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return result;//返回结果
|
}
|
|
/// <summary>
|
/// 根据厂商ID获取客户编号
|
/// </summary>
|
/// <param name="FirmId"></param>
|
/// <returns></returns>
|
public int GetLastIdByFirmId(Guid FirmId)
|
{
|
int result = 0;
|
OA_CorporateClients m_OA_CorporateClients = null;
|
try
|
{
|
m_OA_CorporateClients = _IOA_CorporateClientsDal.SelectModelByFirmId(FirmId) as OA_CorporateClients;//执行查询
|
if (m_OA_CorporateClients != null)
|
{
|
result = m_OA_CorporateClients.CustomerId ?? 10000;
|
}
|
else
|
{
|
result = 10000;
|
}
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return result;
|
}
|
|
/// <summary>
|
/// 获取询价编号
|
/// </summary>
|
/// <param name="FirmId"></param>
|
/// <param name="CustormId"></param>
|
/// <returns></returns>
|
public Guid GetInquiryId(Guid FirmId, Guid CustormId)
|
{
|
return _IOA_CorporateClientsDal.GetInquiryId(FirmId, CustormId);
|
}
|
|
/// <summary>
|
/// 根据会员id和厂商id获取客户编号
|
/// </summary>
|
/// <param name="FirmId"></param>
|
/// <param name="MemberId"></param>
|
/// <returns></returns>
|
public Guid GetCustormId(Guid FirmId, Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.GetCustormId(FirmId, MemberId);
|
}
|
|
/// <summary>
|
/// 根据厂商以及会员编号查询客户信息
|
/// </summary>
|
/// <param name="Keyid">编号</param>
|
/// <returns></returns>
|
public OA_CorporateClients SelectModelByFirmIdandMemberId(Guid FirmId, Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.SelectModelByFirmIdandMemberId(FirmId, MemberId);
|
}
|
|
/// <summary>
|
/// 判断会员是否是厂商的客户
|
/// </summary>
|
/// <param name="FirmId"></param>
|
/// <param name="MemberId"></param>
|
/// <returns></returns>
|
public bool IsCustormByFirmIdandMemberId(Guid FirmId, Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.IsCustormByFirmIdandMemberId(FirmId, MemberId);
|
}
|
|
/// <summary>
|
/// 分页查询外协厂商
|
/// </summary>
|
/// <param name="pagination"></param>
|
/// <param name="MemberId"></param>
|
/// <param name="OutVendorName"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.OA_CorporateClients> SelectModelPage(Infrastructure.Query.Pagination pagination, Guid MemberId, string OutVendorName)
|
{
|
return _IOA_CorporateClientsDal.SelectModelPage(pagination, MemberId, OutVendorName);
|
}
|
|
/// <summary>
|
/// 模糊查询外协公司名称
|
/// </summary>
|
/// <param name="CompanyName">公司名称</param>
|
/// <param name="MemberId">会员id</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> SelectListListByName(string CompanyName, Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.SelectListListByName(CompanyName, MemberId);
|
}
|
|
/// <summary>
|
/// 模糊查询客户公司名称
|
/// </summary>
|
/// <param name="CompanyName"></param>
|
/// <param name="MemberId"></param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> SelectCustomListByName(string CompanyName, Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.SelectCustomListByName(CompanyName, MemberId);
|
}
|
|
/// <summary>
|
/// 转化在线用户为某厂商客户方法
|
/// </summary>
|
/// <param name="firmId">厂商编号</param>
|
/// <param name="memberId">会员编号</param>
|
/// <param name="theOperator">操作人</param>
|
/// <returns></returns>
|
public int ConvertToCorporateClient(Guid firmId, Guid memberId, string theOperator)
|
{
|
return _IOA_CorporateClientsDal.ConvertToCorporateClient(firmId, memberId, theOperator);
|
}
|
|
/// <summary>
|
/// 判断企业网站能否登陆成功
|
/// </summary>
|
/// <param name="LoginPhone"></param>
|
/// <param name="PwdNum"></param>
|
/// <param name="MemberId"></param>
|
/// <returns></returns>
|
public OA_CorporateClients IfHasMember(string LoginPhone, string PwdNum, Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.IfHasMember(LoginPhone, PwdNum, MemberId);
|
}
|
|
/// <summary>
|
/// 根据客户编号获取客户
|
/// </summary>
|
/// <param name="CustomId">客户编号</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> SelectListListByCustomId(string CustomId, Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.SelectListListByCustomId(CustomId, MemberId);
|
}
|
|
/// <summary>
|
/// 意向客户导入合作客户
|
/// </summary>
|
/// <param name="m_OA_CorporateClients"></param>
|
/// <param name="m_OA_CustomerCommunications"></param>
|
/// <param name="m_EC_AcceptWayByCustomers"></param>
|
/// <param name="m_OA_IntentionCustomer"></param>
|
/// <returns></returns>
|
public bool IntIntoModel(OA_CorporateClients m_OA_CorporateClients, OA_CustomerCommunications m_OA_CustomerCommunications, EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers, OA_IntentionCustomer m_OA_IntentionCustomer)
|
{
|
return _IOA_CorporateClientsDal.IntIntoModel(m_OA_CorporateClients, m_OA_CustomerCommunications, m_EC_AcceptWayByCustomers, m_OA_IntentionCustomer);
|
}
|
|
/// <summary>
|
/// 获取总的预付款余额
|
/// </summary>
|
/// <param name="MemberId"></param>
|
/// <returns></returns>
|
public decimal GetAllPrepayments(Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.GetAllPrepayments(MemberId);
|
}
|
|
/// <summary>
|
/// 转移客户
|
/// </summary>
|
/// <param name="BussinessManager"></param>
|
/// <param name="CostomManager"></param>
|
/// <param name="type"></param>
|
/// <param name="keyids"></param>
|
/// <returns></returns>
|
public bool ShiftIntOrCus(int? BussinessManager, int? CostomManager, string type, string keyids)
|
{
|
return _IOA_CorporateClientsDal.ShiftIntOrCus(BussinessManager, CostomManager, type, keyids);
|
}
|
|
/// <summary>
|
/// 检测厂商是否存在
|
/// </summary>
|
/// <param name="CompanyName"></param>
|
/// <param name="FirmId"></param>
|
/// <param name="Keyid"></param>
|
/// <returns></returns>
|
public bool isExistCompanyName(String CompanyName, Guid FirmId, Guid Keyid)
|
{
|
return _IOA_CorporateClientsDal.isExistCompanyName(CompanyName, FirmId, Keyid);
|
}
|
|
/// <summary>
|
/// 根据厂商以及会员编号查询外协厂商
|
/// </summary>
|
/// <param name="FirmId"></param>
|
/// <param name="MemberId"></param>
|
/// <returns></returns>
|
public OA_CorporateClients SelectOutsourceByFirmIdandMemberId(Guid FirmId, Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.SelectOutsourceByFirmIdandMemberId(FirmId, MemberId);
|
}
|
|
/// <summary>
|
/// 合并客户
|
/// </summary>
|
/// <param name="DefaultId"></param>
|
/// <param name="DelId"></param>
|
/// <param name="InquiryId"></param>
|
/// <returns></returns>
|
public bool MergerCustom(Guid DefaultId, Guid DelId, Guid InquiryId)
|
{
|
return _IOA_CorporateClientsDal.MergerCustom(DefaultId, DelId, InquiryId);
|
}
|
|
/// <summary>
|
/// 根据个人网店编号查询自动外协厂商
|
/// </summary>
|
/// <param name="MemberId"></param>
|
/// <returns></returns>
|
public OA_CorporateClients GetDefaultOutFirm(Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.GetDefaultOutFirm(MemberId);
|
}
|
|
public OA_CorporateClients GetModelByMemberIdAndName(Guid MemberId, string OutVendorName)
|
{
|
return _IOA_CorporateClientsDal.GetModelByMemberIdAndName(MemberId, OutVendorName);
|
}
|
|
/// <summary>
|
/// 统计金额
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <param name="FirmId"></param>
|
/// <param name="UserName"></param>
|
/// <param name="beginTime"></param>
|
/// <param name="endTime"></param>
|
/// <param name="AccountManagerId"></param>
|
/// <param name="BusinessManagerId"></param>
|
/// <param name="CustomerIndustriesId"></param>
|
/// <param name="CustomerTypeId"></param>
|
/// <param name="DegreeImportanId"></param>
|
/// <param name="LastOrderTime"></param>
|
/// <param name="selOrderCount"></param>
|
/// <param name="selOrderMoney"></param>
|
/// <param name="SourcesInfoId"></param>
|
/// <param name="TurnoverIntentionId"></param>
|
/// <param name="OrderCount"></param>
|
/// <param name="OrderMoney"></param>
|
/// <param name="UserNum"></param>
|
/// <param name="selLastOrderTime"></param>
|
/// <param name="Province"></param>
|
/// <param name="City"></param>
|
/// <param name="County"></param>
|
/// <param name="selPrepaidBalance"></param>
|
/// <param name="PrepaidBalance"></param>
|
/// <returns></returns>
|
public Model.OA_CorporateClients SumRecordMoney(Pagination pa, Guid FirmId, string UserName, DateTime? beginTime, DateTime? endTime, string AccountManagerId, string BusinessManagerId, string CustomerIndustriesId, string CustomerTypeId, string DegreeImportanId, string LastOrderTime, string selOrderCount, string selOrderMoney, string SourcesInfoId, string TurnoverIntentionId, string OrderCount, string OrderMoney, string UserNum, string selLastOrderTime, string Province, string City, string County, string selPrepaidBalance, string PrepaidBalance, bool IsStaff, Guid StaffMemberId,int? StaffId)
|
{
|
string Condition = " and a.FirmId ='" + FirmId + "'";
|
|
if (!string.IsNullOrEmpty(UserNum))
|
{
|
Condition += " and CustomerId = " + UserNum;
|
}
|
|
if (!string.IsNullOrEmpty(UserName))
|
{
|
Condition += " and CompanyName like '%" + UserName + "%'";
|
}
|
if (beginTime.HasValue)
|
{
|
Condition += string.Format(" and CAST(CreateTime AS DATE) >='{0}'", beginTime);
|
}
|
|
if (endTime.HasValue)
|
{
|
Condition += string.Format(" and CAST(CreateTime AS DATE) <='{0}'", endTime);
|
}
|
|
if (!string.IsNullOrEmpty(SourcesInfoId))
|
{
|
Condition += string.Format(" and SourcesInfoId='{0}'", SourcesInfoId);
|
}
|
if (!string.IsNullOrEmpty(CustomerIndustriesId))
|
{
|
Condition += string.Format(" and CustomerIndustriesId='{0}'", CustomerIndustriesId);
|
}
|
if (!string.IsNullOrEmpty(AccountManagerId))
|
{
|
Condition += string.Format(" and AccountManagerId='{0}'", AccountManagerId);
|
}
|
if (!string.IsNullOrEmpty(BusinessManagerId))
|
{
|
Condition += string.Format(" and BusinessManagerId='{0}'", BusinessManagerId);
|
}
|
if (!string.IsNullOrEmpty(CustomerTypeId))
|
{
|
Condition += string.Format(" and CustomerTypeId='{0}'", CustomerTypeId);
|
}
|
if (!string.IsNullOrEmpty(TurnoverIntentionId))
|
{
|
Condition += string.Format(" and CreditId='{0}'", TurnoverIntentionId);
|
}
|
if (!string.IsNullOrEmpty(DegreeImportanId))
|
{
|
Condition += string.Format(" and DegreeImportanId='{0}'", DegreeImportanId);
|
}
|
if (!string.IsNullOrEmpty(selOrderCount) && !string.IsNullOrEmpty(OrderCount))
|
{
|
Condition += string.Format(" and OrderCount{0}'{1}'", selOrderCount, OrderCount);
|
}
|
if (!string.IsNullOrEmpty(selOrderMoney) && !string.IsNullOrEmpty(OrderMoney))
|
{
|
Condition += string.Format(" and OrderMoney{0}'{1}'", selOrderMoney, OrderMoney);
|
}
|
if (!string.IsNullOrEmpty(selLastOrderTime) && !string.IsNullOrEmpty(LastOrderTime))
|
{
|
Condition += string.Format("and CAST(LastOrderTime AS DATE) {0} CAST(getdate()-{1} AS date)", LastOrderTime, selLastOrderTime);
|
}
|
|
if (IsStaff)
|
{
|
if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City) && !string.IsNullOrEmpty(County))
|
Condition += string.Format(" and Province='{0}' and City='{1}' and County='{2}'", Province, City, County);
|
else if (!string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(City))
|
Condition += string.Format(" and Province='{0}' and City='{1}' and (( County IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'')+ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{3}' or AccountManagerId='{3}' )", Province, City, StaffMemberId, StaffId);
|
else if (!string.IsNullOrEmpty(Province))
|
Condition += string.Format(" and Province='{0}' and (( City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) and County IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'')+ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{1}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{2}' or AccountManagerId='{2}' )", Province, StaffMemberId, StaffId);
|
else
|
Condition += string.Format(" and (( Province IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageProvince FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and City IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ManageCity FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) and County IN (SELECT Name FROM dbo.Sys_CitySite WHERE Keyid IN (SELECT value FROM dbo.SplitString(CAST((SELECT ISNULL(ManageCountry,'')+ISNULL(ManageCountry1,'') FROM dbo.OA_Staff WHERE MemberId='{0}') AS VARCHAR(MAX)),',',1))) ) or AccountManagerId='{1}' or AccountManagerId='{1}' ) ", StaffMemberId, StaffId);
|
}
|
else
|
{
|
if (!string.IsNullOrEmpty(Province))
|
Condition += string.Format(" and Province='{0}'", Province);
|
|
if (!string.IsNullOrEmpty(City))
|
Condition += string.Format(" and City='{0}'", City);
|
|
if (!string.IsNullOrEmpty(County))
|
Condition += string.Format(" and County='{0}'", County);
|
}
|
|
if (!string.IsNullOrEmpty(selPrepaidBalance) && !string.IsNullOrEmpty(PrepaidBalance))
|
{
|
Condition += string.Format(" and Prepayments{0}'{1}'", selPrepaidBalance, PrepaidBalance);
|
}
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy"," CustomerId ASC ")
|
};
|
query.Criteria = criterias;
|
return _IOA_CorporateClientsDal.SumRecordMoney(query, pa);
|
}
|
|
/// <summary>
|
/// 根据会员编号查询所有已添加我为客户的厂商
|
/// </summary>
|
/// <param name="MemberId">编号</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> SelectListByMyId(Guid MemberId)
|
{
|
return _IOA_CorporateClientsDal.SelectListByMyId(MemberId);
|
}
|
|
|
|
/// <summary>
|
/// 新增合作客户拜访
|
/// </summary>
|
/// <param name="trueModel"></param>
|
/// <returns></returns>
|
public bool InsertModelVisit(CY.Model.OA_CorporateClientsVisit trueModel)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.InsertModelVisit(trueModel);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 修改合作客户拜访
|
/// </summary>
|
/// <param name="trueModel"></param>
|
/// <returns></returns>
|
public bool UpdateModelVisit(CY.Model.OA_CorporateClientsVisit trueModel)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.UpdateModelVisit(trueModel);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 根据客户id查询拜访记录
|
/// </summary>
|
/// <param name="CustomId">客户id</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClientsVisit> SelectVisitListByCorId( Guid CustomId)
|
{
|
return _IOA_CorporateClientsDal.SelectVisitListByCorId(CustomId);
|
}
|
|
|
|
/// <summary>
|
/// 新增合作客户订单需求
|
/// </summary>
|
/// <param name="trueModel"></param>
|
/// <returns></returns>
|
public bool InsertModelPrint(CY.Model.OA_CorporateClientsPrint trueModel)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.InsertModelPrint(trueModel);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 修改合作客户订单需求
|
/// </summary>
|
/// <param name="trueModel"></param>
|
/// <returns></returns>
|
public bool UpdateModelPrint(CY.Model.OA_CorporateClientsPrint trueModel)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.UpdateModelPrint(trueModel);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 根据客户id查询拜访订单需求
|
/// </summary>
|
/// <param name="CustomId">客户id</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClientsPrint> SelectPrintListByCorId(Guid CustomId)
|
{
|
return _IOA_CorporateClientsDal.SelectPrintListByCorId(CustomId);
|
}
|
|
|
/// <summary>
|
/// 根据客户id查询拜访订单需求
|
/// </summary>
|
/// <param name="CustomId">客户id</param>
|
/// <returns></returns>
|
public OA_CorporateClientsPrint SelectPrintListByPrintId(int Keyid)
|
{
|
return _IOA_CorporateClientsDal.SelectPrintListByPrintId(Keyid);
|
}
|
|
|
/// <summary>
|
/// 根据订单ID获取其印刷参数
|
/// </summary>
|
/// <param name="orderId"></param>
|
/// <returns></returns>
|
public OA_CorporateClientsParameter GetModelParameter(int orderId)
|
{
|
OA_CorporateClientsPrint oA_CorporateClientsPrint = _IOA_CorporateClientsDal.SelectPrintListByPrintId(orderId);
|
OA_CorporateClientsParameter oA_CorporateClientsParameter = new OA_CorporateClientsParameter();
|
oA_CorporateClientsParameter.TargetId = oA_CorporateClientsPrint.Keyid;
|
oA_CorporateClientsParameter.PrintParameter = oA_CorporateClientsPrint.PrintParameter;
|
return oA_CorporateClientsParameter;
|
}
|
|
|
/// <summary>
|
/// 新增合作客户印刷要求
|
/// </summary>
|
/// <param name="trueModel"></param>
|
/// <returns></returns>
|
public bool InsertModelParameter(CY.Model.OA_CorporateClientsParameter trueModel)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.InsertModelParameter(trueModel);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 修改合作客户印刷要求
|
/// </summary>
|
/// <param name="trueModel"></param>
|
/// <returns></returns>
|
public bool UpdateModelParameter(CY.Model.OA_CorporateClientsParameter trueModel)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.UpdateModelParameter(trueModel);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
|
/// <summary>
|
/// 新增合作客户印刷要求
|
/// </summary>
|
/// <param name="trueModel"></param>
|
/// <returns></returns>
|
public bool InsertModelBiddingcompany(CY.Model.OA_CorporateClients trueModel)
|
{
|
try
|
{
|
return _IOA_CorporateClientsDal.InsertModelBiddingcompany(trueModel);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
/// <summary>
|
/// 根据客户id查询拜访订单需求
|
/// </summary>
|
/// <param name="CustomId">客户id</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClients> SelectBiddingcompanyByFirmId(Guid FirmId)
|
{
|
return _IOA_CorporateClientsDal.SelectBiddingcompanyByFirmId(FirmId);
|
}
|
/// <summary>
|
/// 根据客户id查询拜访订单需求
|
/// </summary>
|
/// <param name="CustomId">客户id</param>
|
/// <returns></returns>
|
public IEnumerable<OA_CorporateClientsVisit> SelectVisitListByBuzAndTime(int? BusinessManagerId, string chaxuntime)
|
{
|
return _IOA_CorporateClientsDal.SelectVisitListByBuzAndTime(BusinessManagerId, chaxuntime);
|
}
|
}
|
}
|