圣珀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

801 lines
39 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.Data;
using ICS.WCF.Base;
using ICSSoft.Entity;
using www.ufida.org.EntityData;
using UFSoft.UBF.Util.Context;
using System.Configuration;
using System.ServiceModel;
using UFSoft.UBF.Service;
namespace ICS.CreateU9Customer
{
public class CreateU9Customer
{
public OperationResult CustCreateU9Customer(CustomerInsertDataClass CusList)
{
OperationResult result = new OperationResult();
//U9.PM.PO.POShipLine.CreatePOShipLineDefault();
#region 服务调用框架结构
//实例化代理类 UFIDAU9ISVItemIBatchCreateItemByDTOSRVClient
UFIDAU9ISVCustomerIBatchCreateCustomerByDTOSVClient client = new UFIDAU9ISVCustomerIBatchCreateCustomerByDTOSVClient();
//服务返回结果
UFIDAU9CBOSCMCustomerCustomerData[] returnCustomers;
//返回异常信息,目前还没有使用此属性
UFSoft.UBF.Exceptions.MessageBase[] returnMsg;
//上下文信息
object context;
//传入 参数
string[] splitBy = new string[] { };
try
{
context = CreateContextObj();
StringBuilder beginstr = new StringBuilder();
beginstr.AppendLine("-----------------------传入数据验证开始-----------------------------");
beginstr.AppendLine("创建U9客户信息");
beginstr.AppendLine("组织:" + CusList.OrgCode);
//beginstr.AppendLine("客户区号:" + CusList.CustomerCode);
beginstr.AppendLine("客户名称:" + CusList.CustomerName);
beginstr.AppendLine("客户简称:" + CusList.ShrotName);
beginstr.AppendLine("客户分类:" + CusList.CustomerType);
beginstr.AppendLine("业务员:" + CusList.CustomerUser);
beginstr.AppendLine("行业:" + CusList.TradeCategory);
beginstr.AppendLine("工商注册码:" + CusList.CorpUnifyCode);
beginstr.AppendLine("-----------------------传入数据验证结束-----------------------------");
Appconfig.WriteLogFile(beginstr.ToString(), "创建U9客户信息");
//if (CusList.OrgCode != "01")
//{
// result.MESSAGE = "组织不为苏州伟创时不能新建客户,只能下发!";
// result.IsSuccess = false;
// return result;
//}
#region 获取组织ID
string OrgID = "";
string orgsql = @"select ID from Base_Organization
where Code='{0}'";
orgsql = string.Format(orgsql, CusList.OrgCode);
DataTable orgdt = DBhlper.Query(orgsql, Appconfig.GetU9ConnStr());
if (orgdt.Rows.Count != 0)
{
OrgID = orgdt.Rows[0]["ID"].ToString();
}
else
{
result.MESSAGE = "组织编码:'" + CusList.OrgCode + "'不存在!";
result.IsSuccess = false;
return result;
}
#endregion
//验证客户是否已经存在(如果组织为苏州伟创则查询流水号,否则直接查询苏州伟创相同的客户,没有则报错)
string checksql = "";
string CusCode = "";
checksql = @"select * from CBO_Customer A
LEFT JOIN CBO_Customer_Trl B
ON B.ID=A.ID
WHERE B.Name='{0}'
AND A.Org='{1}'";
checksql = string.Format(checksql, CusList.CustomerName, OrgID);
DataTable checkdt = DBhlper.Query(checksql, Appconfig.GetU9ConnStr());
if (checkdt.Rows.Count == 0)
{
string SerialNo = "";
//if (CusList.OrgCode == "01")
//{
#region 查询客户编码流水号
// string areasql = @"select Code from Base_DefineValue
// where ValueSetDef='1001912240122432'
// AND Code='{0}'";
// areasql = string.Format(areasql, CusList.CustomerCode);
// DataTable areadt = DBhlper.Query(areasql, Appconfig.GetU9ConnStr());
// if (areadt.Rows.Count == 0)
// {
// result.MESSAGE = "区号:'" + CusList.CustomerCode + "'不存在!";
// result.IsSuccess = false;
// return result;
// }
// string serialsql = @"select TOP 1 Code from CBO_Customer
// where Org='" + OrgID + "' and code < '999999' and code not like'%[a-z]%' order by Code DESC";
// serialsql = string.Format(serialsql, OrgID);
// //serialsql = string.Format(serialsql, CusList.CustomerCode, OrgID);
// DataTable serialdt = DBhlper.Query(serialsql, Appconfig.GetU9ConnStr());
// if (serialdt.Rows.Count == 0)
// {
// SerialNo = "0001";
// }
// else
// {
// //string BaseNo = serialdt.Rows[0]["Code"].ToString().Split('-')[1];
// string BaseNo = serialdt.Rows[0]["Code"].ToString();
// SerialNo = (Convert.ToInt32(BaseNo) + 1).ToString().PadLeft(4, '0');
// }
SerialNo = CusList.CustomerNo;
#endregion
//}
//给传入参数赋值
UFIDAU9ISVCustomerCustomerDTOData[] customerDatas = setDataForCustomer(CusList, SerialNo, OrgID, CusCode);
UFIDAU9CBOPubControllerContextDTOData custContext = CreateContextDto();
//服务调用
(client.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
(client.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;
returnCustomers = client.Do(out returnMsg, context, customerDatas.ToArray(), custContext);
StringBuilder str = new StringBuilder();
str.AppendLine("创建U9客户信息");
str.AppendLine("组织:" + CusList.OrgCode);
//str.AppendLine("客户区号:" + CusList.CustomerCode);
str.AppendLine("客户名称:" + CusList.CustomerName);
str.AppendLine("客户简称:" + CusList.ShrotName);
str.AppendLine("客户分类:" + CusList.CustomerType);
str.AppendLine("业务员:" + CusList.CustomerUser);
str.AppendLine("行业:" + CusList.TradeCategory);
str.AppendLine("工商注册码:" + CusList.CorpUnifyCode);
str.AppendLine("结果:" + "True");
Appconfig.WriteLogFile(str.ToString(), "创建U9客户信息");
result.MESSAGE = "客户" + SerialNo + "创建成功";
result.IsSuccess = true;
result.CustomerCode = returnCustomers[0].m_code;
result.CustomerID = returnCustomers[0].m_iD;
if (result.IsSuccess)
{
string Updatesql = @"UPDATE CBO_Customer SET IsTaxPrice=1 WHERE Code='" + SerialNo + "' ";
Updatesql = string.Format(Updatesql);
DBhlper.Query(Updatesql, Appconfig.GetU9ConnStr());
}
return result;
}
else
{
StringBuilder str = new StringBuilder();
str.AppendLine("创建U9客户信息");
str.AppendLine("组织:" + CusList.OrgCode);
//str.AppendLine("客户区号:" + CusList.CustomerCode);
str.AppendLine("客户名称:" + CusList.CustomerName);
str.AppendLine("客户简称:" + CusList.ShrotName);
str.AppendLine("客户分类:" + CusList.CustomerType);
str.AppendLine("业务员:" + CusList.CustomerUser);
str.AppendLine("行业:" + CusList.TradeCategory);
str.AppendLine("工商注册码:" + CusList.CorpUnifyCode);
str.AppendLine("结果:" + "客户已存在");
Appconfig.WriteLogFile(str.ToString(), "创建U9客户信息");
result.CustomerCode = checkdt.Rows[0]["Code"].ToString();
result.CustomerID = long.Parse(checkdt.Rows[0]["ID"].ToString());
result.MESSAGE = "客户" + CusList.CustomerName + "已存在";
result.IsSuccess = true;
return result;
}
}
catch (Exception ex)
{
//异常信息捕获
string Message = GetExceptionMessage(ex);
StringBuilder str = new StringBuilder();
str.AppendLine("创建U9客户信息");
str.AppendLine("组织:" + CusList.OrgCode);
//str.AppendLine("客户区号:" + CusList.CustomerCode);
str.AppendLine("客户名称:" + CusList.CustomerName);
str.AppendLine("客户简称:" + CusList.ShrotName);
str.AppendLine("客户分类:" + CusList.CustomerType);
str.AppendLine("业务员:" + CusList.CustomerUser);
str.AppendLine("行业:" + CusList.TradeCategory);
str.AppendLine("工商注册码:" + CusList.CorpUnifyCode);
str.AppendLine("结果:" + "False");
str.AppendLine("错误:" + GetExceptionMessage(ex));
Appconfig.WriteLogFile(str.ToString(), "创建U9客户信息");
result.MESSAGE = Message;
result.IsSuccess = false;
return result;
}
}
#endregion
#region 提取异常信息
/// <summary>
/// 提取异常信息
/// </summary>
/// <param name="ex"></param>
private string GetExceptionMessage(Exception ex)
{
string faultMessage = "未知错误,请查看ERP日志!";
System.TimeoutException timeoutEx = ex as System.TimeoutException;
if (timeoutEx != null)
{
faultMessage = "访问服务超时,请修改配置信息!";
}
else
{
FaultException<ServiceException> faultEx = ex as FaultException<ServiceException>;
if (faultEx == null)
{
faultMessage = ex.Message;
}
else
{
ServiceException serviceEx = faultEx.Detail;
if (serviceEx != null && !string.IsNullOrEmpty(serviceEx.Message)
&& !serviceEx.Message.Equals("fault", StringComparison.OrdinalIgnoreCase))
{
// 错误信息在faultEx.Message中,请提取,
// 格式为"Fault:料品不能为空,请录入\n 在....."
int startIndex = serviceEx.Message.IndexOf(":");
int endIndex = serviceEx.Message.IndexOf("\n");
if (endIndex == -1)
endIndex = serviceEx.Message.Length;
if (endIndex > 0 && endIndex > startIndex + 1)
{
faultMessage = serviceEx.Message.Substring(startIndex + 1, endIndex - startIndex - 1);
}
else
{
faultMessage = serviceEx.Message;
}
}
}
}
return faultMessage;
}
#endregion
#region 给上下文信息赋值
/// <summary>
/// 给上下文信息赋值
/// </summary>
/// <returns></returns>
private UFIDAU9CBOPubControllerContextDTOData CreateContextDto()
{
// 实例化应用上下文对象
UFIDAU9CBOPubControllerContextDTOData thContext = new UFIDAU9CBOPubControllerContextDTOData();
thContext.m_orgID = long.Parse(ConfigurationManager.AppSettings["orgID"].ToString());
thContext.m_cultureName = ConfigurationManager.AppSettings["cultureName"].ToString();
thContext.m_entCode = ConfigurationManager.AppSettings["enterpriseID"].ToString();
thContext.m_orgCode = ConfigurationManager.AppSettings["orgCode"].ToString();
thContext.m_userCode = ConfigurationManager.AppSettings["userCode"].ToString();
thContext.m_userID = long.Parse(ConfigurationManager.AppSettings["userID"].ToString());
return thContext;
}
#endregion
#region 给上下文信息赋值1
/// <summary>
/// 给上下文信息赋值
/// </summary>
/// <returns></returns>
private ThreadContext CreateContextObj()
{
// 实例化应用上下文对象
ThreadContext thContext = new ThreadContext();
System.Collections.Generic.Dictionary<object, object> ns = new Dictionary<object, object>();
ns.Add("OrgID", ConfigurationManager.AppSettings["orgID"].ToString());
ns.Add("UserID", ConfigurationManager.AppSettings["userID"].ToString());
ns.Add("UserCode", ConfigurationManager.AppSettings["userCode"].ToString());
ns.Add("Datetime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
ns.Add("CultureName", ConfigurationManager.AppSettings["cultureName"].ToString());
ns.Add("EnterpriseID", ConfigurationManager.AppSettings["enterpriseID"].ToString());
ns.Add("DefaultCultureName", ConfigurationManager.AppSettings["cultureName"].ToString());
thContext.nameValueHas = ns;
return thContext;
}
#endregion
private UFIDAU9ISVCustomerCustomerDTOData[] setDataForCustomer(CustomerInsertDataClass datas, string SerialNo, string OrgID, string CusCode)
{
try
{
List<UFIDAU9ISVCustomerCustomerDTOData> customers = new List<UFIDAU9ISVCustomerCustomerDTOData>();
UFIDAU9ISVCustomerCustomerDTOData customer = new UFIDAU9ISVCustomerCustomerDTOData();
if (CusCode == "")
{
//customer.m_code = datas.CustomerCode + "-" + SerialNo;
customer.m_code = SerialNo;
}
else
{
customer.m_code = CusCode;
}
customer.Name = datas.CustomerName;
customer.m_shortName = datas.CustomerName;
//customer.m_shortName = datas.ShrotName;
#region 获取客户分类ID
string infosql = @"select B.ID,B.Code from CBO_CustomerCategory_Trl A
LEFT JOIN CBO_CustomerCategory B
ON B.ID=A.ID
where B.Code='{0}' AND B.Org='{1}' ";
infosql = string.Format(infosql, datas.CustomerType, OrgID);
DataTable infodt = DBhlper.Query(infosql, Appconfig.GetU9ConnStr());
if (infodt.Rows.Count != 0)
{
customer.m_customerCategory = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_customerCategory.m_code = infodt.Rows[0]["Code"].ToString();
customer.m_customerCategory.m_iD = long.Parse(infodt.Rows[0]["ID"].ToString());
}
else
{
throw new Exception("未获取到客户分类:" + datas.CustomerType + "对应编码");
}
#endregion
#region 获取交易币种ID
string tcurrencysql = @"select A.ID from Base_Currency_Trl a
left join Base_Currency b on a.id=b.id
where SysMLFlag='zh-CN' AND b.code='{0}'";
tcurrencysql = string.Format(tcurrencysql, datas.TradeCurrencyName);
DataTable tcurrencydt = DBhlper.Query(tcurrencysql, Appconfig.GetU9ConnStr());
if (tcurrencydt.Rows.Count == 0)
{
throw new Exception("未获取到交易币种编码:" + datas.TradeCurrencyName + "对应ID");
}
else
{
customer.m_tradeCurrency = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_tradeCurrency.m_iD = long.Parse(tcurrencydt.Rows[0]["ID"].ToString());
}
#endregion
#region 获取收款币种ID
datas.ReceiveCurrencyName = datas.TradeCurrencyName;//收款币种选择和交易币种一致
string rcurrencysql = @"select A.ID from Base_Currency_Trl a
left join Base_Currency b on a.id=b.id
where SysMLFlag='zh-CN' AND b.code='{0}'";
rcurrencysql = string.Format(rcurrencysql, datas.ReceiveCurrencyName);
DataTable rcurrencydt = DBhlper.Query(rcurrencysql, Appconfig.GetU9ConnStr());
if (rcurrencydt.Rows.Count == 0)
{
throw new Exception("未获取到收款币种编码:" + datas.ReceiveCurrencyName + "对应ID");
}
else
{
customer.m_payCurrency = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_payCurrency.m_iD = long.Parse(rcurrencydt.Rows[0]["ID"].ToString());
}
#endregion
#region 获取供应组织
string SupplyOrgID = "";
string orgsql = @"select ID from Base_Organization
where Code='{0}'";
orgsql = string.Format(orgsql, datas.OrgCode);
DataTable orgdt = DBhlper.Query(orgsql, Appconfig.GetU9ConnStr());
if (orgdt.Rows.Count != 0)
{
SupplyOrgID = orgdt.Rows[0]["ID"].ToString();
}
else
{
throw new Exception("未获取到供应组织:" + datas.OrgCode + "对应ID");
}
#endregion
#region 获取税组合ID
string TaxRuleID = "";
string taxsql = @"select ID from CBO_TaxSchedule
where Code='{0}'";
taxsql = string.Format(taxsql, datas.TaxScheduleCode);
DataTable taxdt = DBhlper.Query(taxsql, Appconfig.GetU9ConnStr());
if (taxdt.Rows.Count != 0)
{
TaxRuleID = taxdt.Rows[0]["ID"].ToString();
}
else
{
throw new Exception("未获取到税组合编码:" + datas.TaxScheduleCode + "对应ID");
}
#endregion
#region 获取收款条件ID
string RecervalTermID = "";
datas.RecervalTermCode = "YZ01";
if (datas.RecervalTermCode != "" && datas.RecervalTermCode != null)
{
string rtermsql = @"select ID from CBO_ReceivalTerm
where Code='{0}' and Org='{1}'";
rtermsql = string.Format(rtermsql, datas.RecervalTermCode, OrgID);
DataTable rtermdt = DBhlper.Query(rtermsql, Appconfig.GetU9ConnStr());
if (rtermdt.Rows.Count != 0)
{
RecervalTermID = rtermdt.Rows[0]["ID"].ToString();
}
else
{
throw new Exception("未获取到收款条件编码:" + datas.RecervalTermCode + "对应ID");
}
}
#endregion
#region 获取立账条件ID
string ARConfirmTermID = "";
string ctermsql = @"select ID from CBO_ARConfirmTerm
where Code='{0}' AND Org='{1}'";
ctermsql = string.Format(ctermsql, datas.ARConfirmTerm, OrgID);
DataTable ctermdt = DBhlper.Query(ctermsql, Appconfig.GetU9ConnStr());
if (ctermdt.Rows.Count != 0)
{
ARConfirmTermID = ctermdt.Rows[0]["ID"].ToString();
}
else
{
throw new Exception("未获取到立账条件编码:" + datas.ARConfirmTerm + "对应ID");
}
#endregion
#region 获取立账条件名称
string ARConfirmTermName = "";
string ctermrsql = @"select a.Code,b.Name from CBO_ARConfirmTerm a
left join CBO_ARConfirmTerm_Trl b on a.id=b.id
where a.Code='{0}' AND a.Org='{1}'";
ctermrsql = string.Format(ctermrsql, datas.ARConfirmTerm, OrgID);
DataTable ctermdt2 = DBhlper.Query(ctermrsql, Appconfig.GetU9ConnStr());
if (ctermdt2.Rows.Count != 0)
{
ARConfirmTermName = ctermdt2.Rows[0]["Name"].ToString();
}
else
{
throw new Exception("未获取到立账条件名称:" + datas.ARConfirmTerm + "对应ID");
}
#endregion
#region 获取收货地址ID
// string OfficialLocationID = "";
// if (datas.OfficialLocation != "" && datas.OfficialLocation != null)
// {
// string Officialsql = @"select ID from Base_Location_trl
// where Name='{0}'";
// Officialsql = string.Format(Officialsql, datas.OfficialLocation);
// DataTable Officialdt = DBhlper.Query(Officialsql, Appconfig.GetU9ConnStr());
// if (Officialdt.Rows.Count != 0)
// {
// OfficialLocationID = Officialdt.Rows[0]["ID"].ToString();
// }
// else
// {
// throw new Exception("未获取到收货地址编码:" + datas.OfficialLocation + "对应ID");
// }
// }
#endregion
#region 获取价目表ID
string PriceListID = "";
//if (datas.CustomerType == "01")
//{
// datas.PriceListCode = "SPL2021100002";
// //datas.PriceListCode = "SPL2021110001";
//}
//else if (datas.CustomerType == "02")
//{
// datas.PriceListCode = "SPL2021100003";
//}
//if (datas.TradeCurrencyName == "C001")
//{
// datas.PriceListCode = "SPL2021100002";
//}
//else if (datas.TradeCurrencyName == "C009")
//{
// datas.PriceListCode = "SPL2021100003";
//}
//else if (datas.TradeCurrencyName == "C005")
//{
// datas.PriceListCode = "SPL2021110001";
//}
#region MyRegion
// string pricesql = @"select ID from SPR_SalePriceList
// where Code='{0}' AND Org='{1}'";
// pricesql = string.Format(pricesql, datas.PriceListCode, OrgID);
// DataTable pricedt = DBhlper.Query(pricesql, Appconfig.GetU9ConnStr());
// if (pricedt.Rows.Count != 0)
// {
// PriceListID = pricedt.Rows[0]["ID"].ToString();
// }
// else
// {
// throw new Exception("未获取到价目表编码:" + datas.PriceListCode + "对应ID");
// }
#endregion
// else
// {
// string pricesql = @"select ID from SPR_SalePriceList
// where Code='{0}' AND Org='{1}'";
// pricesql = string.Format(pricesql, datas.PriceListCode, OrgID);
// DataTable pricedt = DBhlper.Query(pricesql, Appconfig.GetU9ConnStr());
// if (pricedt.Rows.Count != 0)
// {
// PriceListID = pricedt.Rows[0]["ID"].ToString();
// }
// else
// {
// PriceListID = "0";
// }
// }
#endregion
#region 获取存储地点ID
string WHID = "";
if (datas.WHCode != "" && datas.WHCode != null)
{
string whsql = @"select ID from CBO_WH
where Code='{0}' AND Org='{1}'";
whsql = string.Format(whsql, datas.WHCode, OrgID);
DataTable whdt = DBhlper.Query(whsql, Appconfig.GetU9ConnStr());
if (whdt.Rows.Count != 0)
{
WHID = whdt.Rows[0]["ID"].ToString();
}
else
{
WHID = "0";
throw new Exception("未获取到仓库编码:" + datas.WHCode + "对应ID");
}
}
#endregion
#region 获取注册地址ID
// string LocationID = "";
// if (datas.WHCode != "" && datas.WHCode != null)
// {
// string whsql = @"select ID from CBO_WH
// where Code='{0}' AND Org='{1}'";
// whsql = string.Format(whsql, datas.WHCode, OrgID);
// DataTable whdt = DBhlper.Query(whsql, Appconfig.GetU9ConnStr());
// if (whdt.Rows.Count != 0)
// {
// LocationID = whdt.Rows[0]["ID"].ToString();
// }
// else
// {
// LocationID = "0";
// throw new Exception("未获取到注册地址:" + datas.WHCode + "对应ID");
// }
// }
#endregion
customer.m_saleser = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_saleser.m_code = datas.CustomerUser;
customer.CorpUnifyCode = datas.CorpUnifyCode;
customer.m_stateTaxNo = datas.StateTaxNo;
#region 默认值
customer.m_saleType = 0;
customer.m_priceListCode = datas.PriceListCode;
//customer.m_priceListID = long.Parse(PriceListID);
customer.m_isPriceListModify = true;
customer.m_isFromCRM = true;
if (datas.SupplySource == "供应商")
{
customer.m_supplySource = 0;
}
else if (datas.SupplySource == "内部组织")
{
customer.m_supplySource = 1;
}
else if (datas.SupplySource == "转生产制造")
{
customer.m_supplySource = 2;
}
else if (datas.SupplySource == "当前组织")
{
customer.m_supplySource = 3;
}
customer.m_supplySource = 3;//供应来源(默认 3)
if (datas.DemandTransType == "转当前组织采购")
{
customer.m_demandTransType = 0;
}
else if (datas.DemandTransType == "跨组织出货")
{
customer.m_demandTransType = 1;
}
else if (datas.DemandTransType == "转制令")
{
customer.m_demandTransType = 2;
}
else if (datas.DemandTransType == "当前组织出货")
{
customer.m_demandTransType = 3;
}
else if (datas.DemandTransType == "转外协")
{
customer.m_demandTransType = 4;
}
customer.m_demandTransType = 3;//供应类型 (默认 3)
if (WHID != "0" && WHID != "")
{
customer.m_wH = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
//if (datas.OrgCode == "02" || datas.OrgCode == "01")
//{
// customer.m_wH.m_code = "CP01";
// customer.m_wH.m_iD = 1001912020027545;
//}
customer.m_wH.m_code = datas.WHCode;
customer.m_wH.m_iD = long.Parse(WHID);
}
customer.m_supplyOrg = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_supplyOrg.m_iD = 1002303100000860;
customer.m_supplyOrg.m_code = datas.SupplyOrgCode;
customer.m_shippmentRule = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_shippmentRule.m_iD = 1002303100150515;
customer.m_isShipmentModify = true;
customer.m_taxSchedule = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_taxSchedule.m_iD = long.Parse(TaxRuleID);
customer.m_taxSchedule.m_code = datas.TaxScheduleCode;
customer.m_bargain = -1;
if (datas.RecervalTermCode != "" && datas.RecervalTermCode != null)
{
customer.m_recervalTerm = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_recervalTerm.m_iD = long.Parse(RecervalTermID);
customer.m_recervalTerm.m_code = datas.RecervalTermCode;
}
customer.m_isRecTermModify = true;
customer.m_qualityPledge = 0;
customer.m_aRConfirmTerm = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_aRConfirmTerm.m_iD = long.Parse(ARConfirmTermID);
customer.m_aRConfirmTerm.m_code = datas.ARConfirmTerm;
customer.m_isARCfmModify = true;
//customer.m_registerLocation = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
//customer.m_registerLocation.m_name=datas.CusAddress;//注册地址
//if (datas.OfficialLocation != "" && datas.OfficialLocation !=null)
//{
// customer.m_OfficialLocation = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// customer.m_OfficialLocation.m_iD = long.Parse(OfficialLocationID);
// customer.m_OfficialLocation.m_code = datas.OfficialLocation;
//}
if (datas.InvoiceVerificationOrder == "后进先出")
{
customer.m_invoiceVerificationOrder = 0;
}
else if (datas.InvoiceVerificationOrder == "先进先出")
{
customer.m_invoiceVerificationOrder = 1;
}
else if (datas.InvoiceVerificationOrder == "从大到小")
{
customer.m_invoiceVerificationOrder = 2;
}
else if (datas.InvoiceVerificationOrder == "从小到大")
{
customer.m_invoiceVerificationOrder = 3;
}
else if (datas.InvoiceVerificationOrder == "优先等级")
{
customer.m_invoiceVerificationOrder = 4;
}
customer.m_invoiceVerificationOrder = 1;//核销顺序(默认 1)
if (datas.VerificationMode == "按客户")
{
customer.m_verificationMode = 0;
}
else if (datas.VerificationMode == "按单")
{
customer.m_verificationMode = 1;
}
else if (datas.VerificationMode == "按行")
{
customer.m_verificationMode = 2;
}
else if (datas.VerificationMode == "按分期收款行")
{
customer.m_verificationMode = 3;
}
customer.m_verificationMode = 0;
customer.m_isByAccountAge = true;//按账龄催款(默认为True)
customer.m_checkAccountPeriod = 3;//对账期间(默认为3)
customer.m_commissionType = 0;
customer.m_commissionCurrency = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
customer.m_commissionCurrency.m_iD = 1;
customer.m_commission = 1000;
customer.m_descFlexField = new UFIDAU9BaseFlexFieldDescFlexFieldDescFlexSegmentsData();
customer.m_descFlexField.m_privateDescSeg1 = "0";//欠回单数
customer.m_descFlexField.m_privateDescSeg3 = "02";//是否逾期
customer.m_descFlexField.m_privateDescSeg4 = "01";//是否拆分
customer.m_descFlexField.m_privateDescSeg2 = datas.OfficialLocation;//默认发货地址
customer.m_descFlexField.m_privateDescSeg7 = datas.customertype;//客户类型
customer.m_descFlexField.m_privateDescSeg8 = datas.areaDivision;//地区划分
customer.m_descFlexField.m_privateDescSeg11 = datas.emterritory;//所属大区
if (ARConfirmTermName == "月结30天")
{
customer.m_descFlexField.m_privateDescSeg6 = "30";//信用期限
}
else if (ARConfirmTermName == "月结60天")
{
customer.m_descFlexField.m_privateDescSeg6 = "60";
}
else if (ARConfirmTermName == "月结90天")
{
customer.m_descFlexField.m_privateDescSeg6 = "90";
}
else if (ARConfirmTermName == "月结360天")
{
customer.m_descFlexField.m_privateDescSeg6 = "360";
}
else
{
customer.m_descFlexField.m_privateDescSeg6 = "0";
}
customer.m_effective = new UFIDAU9BasePropertyTypesEffectiveData();
customer.m_effective.m_effectiveDate = datas.EfftiveDate;
//customer.m_effective.m_effectiveDate = DateTime.Now.AddDays(-1);
customer.m_effective.m_disableDate = Convert.ToDateTime("9999.12.31");
customer.m_effective.m_isEffective = true;
#endregion
customer.m_tradeCategory = datas.TradeCategory;
customers.Add(customer);
return customers.ToArray();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
#region 时间戳方法
private DateTime TimestampToDateTime(long timestamp)
{
DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = timestamp * 10000000;
TimeSpan nowTimeSpan = new TimeSpan(lTime);
DateTime resultDateTime = dateTimeStart.Add(nowTimeSpan);
return resultDateTime;
}
#endregion
/// <summary>
/// 返回值
/// </summary>
public class FormICSCreatedArrivalNoticeModel
{
//0 :正常数据,-1:失败。
public int Code { get; set; }
public string ResMsg { get; set; }
public object ResData { get; set; }
public bool IsCompress { get; set; }
public bool IsSuccess { get; set; }
}
public class OperationResult
{
/// <summary>
/// 结果状态,默认值false
/// </summary>
public bool IsSuccess { get; set; }
/// <summary>
///处理消息
/// </summary>
public string MESSAGE { get; set; }
/// <summary>
/// 输出客户编码
/// </summary>
public string CustomerCode { get; set; }
/// <summary>
/// 客户ID
/// </summary>
public long CustomerID { get; set; }
}
}
}