/// <summary> /// 通过地址信息查询出客户,并赋值地址表至客户 /// </summary> /// <param name="ctx"></param> /// <returns></returns> public static List <K3CustomerInfo> GetK3CustomerInfoByExcelAddress(Context ctx) { List <K3CustomerInfo> custs = null; List <K3CustContactInfo> contacts = GetK3CustContactInfoByExcel(ctx); if (contacts != null && contacts.Count > 0) { var c = from l in contacts group l by l.FCustNo into g select g; if (c != null && c.Count() > 0) { custs = new List <K3CustomerInfo>(); foreach (var item in c) { K3CustomerInfo cust = GetCustomerByNo(ctx, item.Key); if (cust != null) { cust.lstCustCtaInfo = item.ToList <K3CustContactInfo>(); custs.Add(cust); } } } } return(custs); }
private void WriteDiscountRateLog(Context ctx, IEnumerable <AbsSynchroDataInfo> datas) { if (datas != null && datas.Count() > 0) { foreach (var data in datas) { if (data != null) { K3CustomerInfo cust = data as K3CustomerInfo; if (cust.F_HS_FixedFreightDiscount != cust.F_HS_OldFixedFreightDiscount) { LogHelper.WriteSynchroLog_Succ(ctx, this.DataType, string.Format("客户编码【{0}】:固定运费折扣率由{1}变更为{2},变更原因:{3}", cust.FNumber, cust.F_HS_OldFixedFreightDiscount, cust.F_HS_FixedFreightDiscount, cust.F_HS_DiscountChangeRemark)); } if (cust.F_HS_IntegralReturnRate != cust.F_HS_OldIntegralReturnRate) { LogHelper.WriteSynchroLog_Succ(ctx, this.DataType, string.Format("客户编码【{0}】:固定积分返点率由{1}变更为{2},变更原因:{3}", cust.FNumber, cust.F_HS_OldIntegralReturnRate, cust.F_HS_IntegralReturnRate, cust.F_HS_DiscountChangeRemark)); } if (cust.F_HS_TTDiscount != cust.F_HS_OldTTDISCOUNT) { LogHelper.WriteSynchroLog_Succ(ctx, this.DataType, string.Format("客户编码【{0}】:固定TT折扣率由{1}变更为{2},变更原因:{3}", cust.FNumber, cust.F_HS_OldTTDISCOUNT, cust.F_HS_TTDiscount, cust.F_HS_DiscountChangeRemark)); } if (cust.F_HS_OnlineDiscount != cust.F_HS_OldOnlineDiscount) { LogHelper.WriteSynchroLog_Succ(ctx, this.DataType, string.Format("客户编码【{0}】:固定产品折扣率由{1}变更为{2},变更原因:{3}", cust.FNumber, cust.F_HS_OldOnlineDiscount, cust.F_HS_OnlineDiscount, cust.F_HS_DiscountChangeRemark)); } } } } }
/// <summary> /// 将需要同步的客户转化为JSON格式(客户集合) /// </summary> /// <param name="sourceDatas"></param> /// <param name="operationType"></param> /// <returns></returns> public override JObject BuildSynchroDataJsons(IEnumerable <AbsSynchroDataInfo> sourceDatas, SynOperationType operationType) { JObject root = null; int batchCount = BatchCount(sourceDatas); JArray jArr = ConvertSynObjToJObj(sourceDatas, operationType); //数据更新时的Json格式 if (operationType == SynOperationType.SAVE) { //更新单据时,表体信息必须填写明细表体的主键 root = new JObject(); root.Add("NeedUpDateFields", new JArray("")); root.Add("NeedReturnFields", new JArray("FNumber")); root.Add("IsDeleteEntry", "false"); root.Add("SubSystemId", ""); root.Add("IsVerifyBaseDataField", "true"); root.Add("BatchCount", batchCount); if (sourceDatas != null) { if (sourceDatas.Count() > 0) { JArray model = new JArray(); for (int i = 0; i < sourceDatas.Count(); i++) { K3CustomerInfo custData = sourceDatas.ElementAt(i) as K3CustomerInfo; string sFCustId = string.Format(@"/*dialect*/ select FCUSTID,FUseOrgId from T_BD_CUSTOMER where FNumber = '{0}'", custData.FNumber); DynamicObjectCollection coll = SQLUtils.GetObjects(this.K3CloudContext, sFCustId); if (coll.Count > 0) { foreach (var c in coll) { if (c["FCUSTID"] != null) { JObject baseData = ConvertSynObjToJObj(sourceDatas.ElementAt(i), operationType); //主组织记录 if (Convert.ToInt32(SQLUtils.GetFieldValue(c, "FUseOrgId")) == 1) { baseData.Add("FCUSTID", Convert.ToInt32(SQLUtils.GetFieldValue(c, "FCUSTID"))); model.Add(baseData); } } } } } if (model != null && model.Count > 0) { root.Add("Model", model); return(root); } } } } return(null); }
public override AbsSynchroDataInfo BuildSynchroData(Context ctx, string json, AbsSynchroDataInfo data = null) { JArray jArr = JArray.Parse(json); List <K3CustContactInfo> contacts = null; K3CustContactInfo contact = null; K3CustomerInfo k3Cust = null; List <string> addrNos = null; if (jArr != null && jArr.Count > 0) { addrNos = jArr.Select(j => JsonUtils.GetFieldValue(j, "address_book_id")).ToList(); } if (addrNos != null && addrNos.Count > 0) { string sql = string.Format(@"/*dialect*/ select a.FNUMBER as CUSTNO,b.FNUMBER as ADDRNO from T_BD_CUSTOMER a inner join T_BD_CUSTLOCATION b on a.FCUSTID = b.FCUSTID where b.FNUMBER in( '{0}') ", string.Join("','", addrNos)); DynamicObjectCollection coll = SQLUtils.GetObjects(ctx, sql); var group = from o in coll group o by SQLUtils.GetFieldValue(o, "CUSTNO") into c select c; if (group != null && group.Count() > 0) { foreach (var g in group) { if (g != null) { contacts = new List <K3CustContactInfo>(); k3Cust = new K3CustomerInfo(); k3Cust.FNumber = SQLUtils.GetFieldValue(g.ElementAt(0), "CUSTNO"); foreach (var s in g) { if (s != null) { contact = new K3CustContactInfo(); contact.FNUMBER1 = SQLUtils.GetFieldValue(s, "ADDRNO"); contacts.Add(contact); } } k3Cust.lstCustCtaInfo = contacts; } } } } return(k3Cust); }
/// <summary> /// 将需要同步的会员(用户)数据进行打包(单个客户) /// </summary> /// <param name="sourceData"></param> /// <param name="log"></param> /// <param name="operationType"></param> /// <returns></returns> public override JObject BuildSynchroDataJson(AbsSynchroDataInfo sourceData, SynchroLog log, SynOperationType operationType) { JObject root = new JObject(); root.Add("NeedUpDateFields", new JArray("")); root.Add("IsDeleteEntry", "false"); root.Add("SubSystemId", ""); root.Add("IsVerifyBaseDataField", "true"); if (operationType == SynOperationType.SAVE) { root.Add("Model", ConvertSynObjToJObj(sourceData, operationType)); return(root); } //数据更新时的Json格式 else { //更新单据时,表体信息必须填写明细表体的主键 K3CustomerInfo custData = sourceData as K3CustomerInfo; string sFCustId = string.Format(@"/*dialect*/ select FCUSTID from T_BD_CUSTOMER where FNumber = '{0}'", custData.FNumber); string sMainFCustId = string.Format(@"/*dialect*/ select FCUSTID from T_BD_CUSTOMER where FNumber = '{0}' and FUseOrgId != 1", custData.FNumber); int subFCustId = Convert.ToInt32(JsonUtils.ConvertObjectToString(SQLUtils.GetObject(this.K3CloudContext, sMainFCustId, "FCUSTID"))); DynamicObjectCollection coll = SQLUtils.GetObjects(this.K3CloudContext, sFCustId); JArray model = new JArray(); if (coll.Count > 0) { foreach (var item in coll) { if (item["FCUSTID"] != null) { JObject baseData = ConvertSynObjToJObj(sourceData, operationType); baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FCUSTID"]))); if (subFCustId != Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FCUSTID"]))) { K3CustomerInfo soData = sourceData as K3CustomerInfo; baseData = ConvertSynObjToJObj(soData, operationType); baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FCUSTID"]))); } model.Add(baseData); } } } root.Add("Model", model); return(root); } }
public override IEnumerable <AbsSynchroDataInfo> GetK3Datas(Context ctx, FormOperation oper = null) { List <K3CustomerInfo> custs = null; K3CustomerInfo cust = null; if (SelectedNos != null && SelectedNos.Count() > 0) { string sql = string.Format(@"/*dialect*/ select b.FNUMBER as FUseOrgId,a.FNUMBER,a.F_HS_FixedFreightDiscount,a.F_HS_IntegralReturnRate ,a.F_HS_OnlineDiscount,a.F_HS_TTDiscount ,a.F_HS_DiscountChangeRemark,a.F_HS_OldOnlineDiscount,a.F_HS_OldTTDISCOUNT,a.F_HS_OldFixedFreightDiscount ,a.F_HS_OldIntegralReturnRate from T_BD_CUSTOMER a inner join T_ORG_ORGANIZATIONS b on a.FUSEORGID = b.FORGID where a.FNUMBER in ('{0}') and b.FNUMBER = '{1}'", string.Join("','", SelectedNos), "100.01"); DynamicObjectCollection coll = SQLUtils.GetObjects(ctx, sql); if (coll != null && coll.Count > 0) { custs = new List <K3CustomerInfo>(); foreach (var item in coll) { if (item != null) { cust = new K3CustomerInfo(); cust.FUseOrgId = SQLUtils.GetFieldValue(item, "FUseOrgId"); cust.FNumber = SQLUtils.GetFieldValue(item, "FNUMBER"); cust.SrcNo = cust.FNumber; cust.F_HS_FixedFreightDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_FixedFreightDiscount")); cust.F_HS_IntegralReturnRate = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_IntegralReturnRate")); cust.F_HS_OnlineDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OnlineDiscount")); cust.F_HS_TTDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_TTDiscount")); cust.F_HS_DiscountChangeRemark = SQLUtils.GetFieldValue(item, "F_HS_DiscountChangeRemark"); cust.F_HS_OldOnlineDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldOnlineDiscount")); cust.F_HS_OldTTDISCOUNT = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldTTDISCOUNT")); cust.F_HS_OldFixedFreightDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldFixedFreightDiscount")); cust.F_HS_OldIntegralReturnRate = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldIntegralReturnRate")); custs.Add(cust); } } } } return(custs); }
public static List <K3CustomerInfo> BuildSynObjByCollection_(Context ctx, DynamicObjectCollection coll) { List <K3CustomerInfo> custs = null; K3CustomerInfo cust = null; if (coll != null) { if (coll.Count > 0) { custs = new List <K3CustomerInfo>(); foreach (var item in coll) { cust = new K3CustomerInfo(); cust.FCreateOrgId = "100"; cust.FUseOrgId = "100"; cust.FNumber = JsonUtils.ConvertObjectToString(item["FNumber"]); cust.FShortName = JsonUtils.ConvertObjectToString(item["FShortName"]); cust.FName = JsonUtils.ConvertObjectToString(item["FName"]); if (string.IsNullOrWhiteSpace(cust.FName)) { cust.FName = "None Name"; } cust.FFCOUNTRY = JsonUtils.ConvertObjectToString(item["FCOUNTRY"]).CompareTo("NULL") == 0 ? "US" : JsonUtils.ConvertObjectToString(item["FCOUNTRY"]); cust.FAddress = JsonUtils.ConvertObjectToString(item["FAddress"]); cust.FZIP = JsonUtils.ConvertObjectToString(item["FZIP"]); cust.FTEL = JsonUtils.ConvertObjectToString(item["FTEL"]); cust.FSELLER = JsonUtils.ConvertObjectToString(item["FSELLER"]); cust.FSALDEPTID = JsonUtils.ConvertObjectToString(item["FSALDEPTID"]); cust.FTaxType = JsonUtils.ConvertObjectToString(item["FTaxType"]); cust.FTaxRate = JsonUtils.ConvertObjectToString(item["FTaxRate"]); cust.FPriority = JsonUtils.ConvertObjectToString(item["FPriority"]); cust.FIsTrade = Convert.ToBoolean(Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FIsTrade"])) == 1 ? true : false); custs.Add(cust); } } } return(custs); }
/// <summary> /// 客户地址信息 /// </summary> /// <param name="cust"></param> /// <returns></returns> public JArray BuildK3CustContactJsons(K3CustomerInfo cust) { JArray FT_BD_CUSTCONTACT = null; JObject contactObj = null; if (cust != null) { FT_BD_CUSTCONTACT = new JArray(); if (cust.lstCustCtaInfo != null && cust.lstCustCtaInfo.Count > 0) { for (int i = 0; i < cust.lstCustCtaInfo.Count; i++) { contactObj = new JObject(); K3CustContactInfo contactData = cust.lstCustCtaInfo.ElementAt(i); contactObj.Add("FNUMBER1", contactData.FNUMBER1); //地址编码 contactObj.Add("FNAME1", contactData.FNAME1); //地点名称 contactObj.Add("FADDRESS1", contactData.FADDRESS1); //详细地址 //contactObj.Add("FTTel", contactData.FTTel);//移动电话 contactObj.Add("FMOBILE", contactData.FMOBILE); contactObj.Add("F_HS_DeliveryName", contactData.F_HS_DeliveryName); //交货联系人 contactObj.Add("F_HS_PostCode", contactData.F_HS_PostCode); //交货邮编 contactObj.Add("F_HS_DeliveryCity", contactData.F_HS_DeliveryCity); //交货城市 contactObj.Add("F_HS_DeliveryProvinces", contactData.F_HS_DeliveryProvinces); //交货省份 if (string.IsNullOrWhiteSpace(contactData.F_HS_RecipientCountry)) { string errorInfo = "客户地址同步,客户编码为:[" + contactData.FCustNo + "]的信息国家编码为空!"; LogUtils.WriteSynchroLog(this.K3CloudContext, SynchroDataType.CustomerAddress, errorInfo); } JObject F_HS_RecipientCountry = new JObject();//国家 F_HS_RecipientCountry.Add("FNumber", contactData.F_HS_RecipientCountry); contactObj.Add("F_HS_RecipientCountry", F_HS_RecipientCountry); FT_BD_CUSTCONTACT.Add(contactObj); } } } return(FT_BD_CUSTCONTACT); }
/// <summary> /// 将抽象类转换为具体的客户对象 /// </summary> /// <param name="sourceDatas"></param> /// <returns></returns> public List <K3CustomerInfo> ConvertAbsSynchroObject(IEnumerable <AbsSynchroDataInfo> sourceDatas) { if (sourceDatas != null) { if (sourceDatas.Count() > 0) { List <K3CustomerInfo> customers = new List <K3CustomerInfo>(); foreach (var item in sourceDatas) { if (item != null) { K3CustomerInfo customer = item as K3CustomerInfo; customers.Add(customer); } } return(customers); } } return(null); }
/// <summary> /// 是否取消同步操作 /// </summary> /// <param name="srcData"></param> /// <returns></returns> public override bool IsCancelSynchro(AbsSynchroDataInfo srcData) { K3CustomerInfo cust = srcData as K3CustomerInfo; if (SynSuccList != default(List <string>)) { if (SynSuccList.Count > 0) { foreach (var item in SynSuccList) { if (item.CompareTo(cust.FNumber) == 0) { return(false); } } } } QueryBuilderParemeter para = new QueryBuilderParemeter(); para.FormId = this.FormKey; para.SelectItems = SelectorItemInfo.CreateItems("FNumber"); if (cust != null) { para.FilterClauseWihtKey = " FNumber='" + cust.FNumber + "' "; } var k3Data = Kingdee.BOS.App.ServiceHelper.GetService <IQueryService>().GetDynamicObjectCollection(this.K3CloudContext, para); if (k3Data == null || k3Data.Count == 0) { return(false); } return(true); }
/// <summary> /// 客户地址信息 /// </summary> /// <param name="cust"></param> /// <returns></returns> public JArray BuildK3CustContactJsons(K3CustomerInfo cust) { JArray FT_BD_CUSTCONTACT = null; JObject contactObj = null; if (cust != null) { FT_BD_CUSTCONTACT = new JArray(); if (cust.lstCustCtaInfo != null && cust.lstCustCtaInfo.Count > 0) { for (int i = 0; i < cust.lstCustCtaInfo.Count; i++) { contactObj = new JObject(); K3CustContactInfo contactData = cust.lstCustCtaInfo.ElementAt(i); contactObj.Add("FNUMBER1", contactData.FNUMBER1); //地址编码 contactObj.Add("FNAME1", contactData.FNAME1); //地点名称 contactObj.Add("FADDRESS1", contactData.FADDRESS1); //详细地址 contactObj.Add("FTTel", contactData.FMOBILE); //移动电话 contactObj.Add("F_HS_DeliveryName", contactData.F_HS_DeliveryName); //交货联系人 contactObj.Add("F_HS_PostCode", contactData.F_HS_PostCode); //交货邮编 contactObj.Add("F_HS_DeliveryCity", contactData.F_HS_DeliveryCity); //交货城市 contactObj.Add("F_HS_DeliveryProvinces", contactData.F_HS_DeliveryProvinces); //交货省份 JObject F_HS_RecipientCountry = new JObject(); //国家 F_HS_RecipientCountry.Add("FNumber", contactData.F_HS_RecipientCountry); contactObj.Add("F_HS_RecipientCountry", F_HS_RecipientCountry); FT_BD_CUSTCONTACT.Add(contactObj); } } } return(FT_BD_CUSTCONTACT); }
/// <summary> /// 数据库查询的结果集封装成List<K3CustomerInfo>对象 /// </summary> /// <param name="ctx"></param> /// <param name="coll"></param> /// <returns></returns> public static List <K3CustomerInfo> BuildSynObjByCollection(Context ctx, DynamicObjectCollection coll) { List <K3CustomerInfo> custs = null; K3CustomerInfo cust = null; if (coll != null) { if (coll.Count > 0) { custs = new List <K3CustomerInfo>(); foreach (var item in coll) { cust = new K3CustomerInfo(); cust.FCreateOrgId = "100"; cust.FUseOrgId = "100"; cust.FNumber = JsonUtils.ConvertObjectToString(item["customers_id"]); cust.FShortName = JsonUtils.ConvertObjectToString(item["customers_firstname"]); cust.FName = JsonUtils.ConvertObjectToString(item["customers_firstname"]) + " " + JsonUtils.ConvertObjectToString(item["customers_lastname"]); if (string.IsNullOrWhiteSpace(cust.FName)) { cust.FName = "None Name"; } string sConutry = string.Format(@"/*dialect*/ select FNUMBER from VW_BAS_ASSISTANTDATA_CountryName where CountryName = '{0}'", JsonUtils.ConvertObjectToString(item["delivery_country"])); cust.FFCOUNTRY = JsonUtils.ConvertObjectToString(item["delivery_country"]).CompareTo("NULL") == 0 ? "US" : JsonUtils.ConvertObjectToString(item["delivery_country"]); string sProvincial = string.Format(@"/*dialect*/ select a.FNUMBER,b.FDATAVALUE from T_ECC_LOGISTICSAREADETAIL a inner join T_ECC_LOGISTICSAREADETAIL_L b on a.FDETAILID = b.FDETAILID where b.FDATAVALUE like N'%{0}%'", JsonUtils.ConvertObjectToString(item["entry_state"])); cust.FAddress = JsonUtils.ConvertObjectToString(item["entry_street_address"]) + " " + JsonUtils.ConvertObjectToString(item["entry_city"]) + " " + JsonUtils.ConvertObjectToString(item["entry_state"]) + " " + JsonUtils.ConvertObjectToString(item["delivery_country"]); cust.FZIP = JsonUtils.ConvertObjectToString(item["entry_postcode"]); cust.FTEL = JsonUtils.ConvertObjectToString(item["customers_telephone"]); string custLevel = JsonUtils.ConvertObjectToString(item["customers_whole"]); cust.FGroup = ServiceHelper.SetCustomerLevel(custLevel); cust.FCustTypeId = ServiceHelper.SetCustomerLevel(custLevel); cust.FTRADINGCURRID = "USD"; string sellerNo = JsonUtils.ConvertObjectToString(item["account_manager_id"]); sellerNo = sellerNo.CompareTo("null") == 0 ? "" : sellerNo; cust.FSELLER = sellerNo; string sDeptNo = string.Format(@"/*dialect*/ select b.FNUMBER from T_BD_STAFFTEMP a inner join T_BD_DEPARTMENT b on a.FDEPTID=b.FDEPTID inner join T_BD_STAFF c on a.FSTAFFID=c.FSTAFFID where c.FNUMBER='{0}'", cust.FSELLER); cust.FSALDEPTID = JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sDeptNo, "FNUMBER")); cust.FTaxType = "SFL02_SYS"; cust.FTaxRate = "SL04_SYS"; cust.FPriority = "1"; cust.FIsTrade = true; custs.Add(cust); } } } return(custs); }
/// <summary> /// 将需要同步的客户转换为JSON格式对象(单个客户) /// </summary> /// <param name="sourceData"></param> /// <param name="opreationType"></param> /// <returns></returns> private JObject ConvertSynObjToJObj(AbsSynchroDataInfo sourceData, SynOperationType opreationType) { K3CustomerInfo cust = sourceData as K3CustomerInfo; JObject baseData = default(JObject); if (cust != null) { baseData = new JObject(); //创建组织为必填项 JObject FCreateOrgId = new JObject(); FCreateOrgId.Add("FNumber", cust.FCreateOrgId); baseData.Add("FCreateOrgId", FCreateOrgId); if (opreationType == SynOperationType.SAVE) { baseData.Add("FNumber", cust.FNumber); //组织内编码不允许变更 JObject FUseOrgId = new JObject(); FUseOrgId.Add("FNumber", cust.FUseOrgId); baseData.Add("FUseOrgId", FUseOrgId); } if (opreationType == SynOperationType.UPDATE) { baseData.Add("FT_BD_CUSTCONTACT", BuildK3CustContactJsons(cust)); //客户地址信息 } baseData.Add("FName", cust.FName); //客户名称 baseData.Add("FShortName", cust.FShortName); JObject FCOUNTRY = new JObject();//国家 FCOUNTRY.Add("FNumber", cust.FFCOUNTRY); baseData.Add("FCOUNTRY", FCOUNTRY); baseData.Add("FADDRESS", cust.FAddress);//通讯地址 baseData.Add("FZIP", cust.FZIP); baseData.Add("FTEL", cust.FTEL); //JObject FGroup = new JObject();//客户分组 //FGroup.Add("FNumber", cust.FGroup); //baseData.Add("FGroup", FGroup); JObject FCustTypeId = new JObject();//客户类别 FCustTypeId.Add("FNumber", cust.FCustTypeId); baseData.Add("FCustTypeId", FCustTypeId); JObject FTRADINGCURRID = new JObject();//结算币别 FTRADINGCURRID.Add("FNumber", cust.FTRADINGCURRID); baseData.Add("FTRADINGCURRID", FTRADINGCURRID); baseData.Add("FInvoiceType", cust.FInvoiceType); //发票类型 JObject FTaxType = new JObject(); //税率类别 FTaxType.Add("FNumber", cust.FTaxType); baseData.Add("FTaxType", FTaxType); JObject FTaxRate = new JObject();//默认税率 FTaxRate.Add("FNumber", cust.FTaxRate); baseData.Add("FTaxRate", FTaxRate); baseData.Add("FPriority", cust.FPriority); //客户优先级 baseData.Add("FIsTrade", cust.FIsTrade); //是否交易客户 baseData.Add("F_HS_CustomerRegisteredMail", cust.F_HS_CustomerRegisteredMail); //客户电子邮箱 } return(baseData); }
/// <summary> /// 将需要同步的客户转化为JSON格式(客户集合) /// </summary> /// <param name="sourceDatas"></param> /// <param name="operationType"></param> /// <returns></returns> public override JObject BuildSynchroDataJsons(IEnumerable <AbsSynchroDataInfo> sourceDatas, SynOperationType operationType) { JObject root = null; int batchCount = BatchCount(sourceDatas); if (operationType == SynOperationType.SAVE) { root = new JObject(); root.Add("NeedUpDateFields", new JArray("")); root.Add("NeedReturnFields", new JArray("FNumber")); root.Add("IsDeleteEntry", "false"); root.Add("SubSystemId", ""); root.Add("IsVerifyBaseDataField", "true"); //root.Add("BatchCount", batchCount); root.Add("Model", ConvertSynObjToJObj(sourceDatas, operationType)); return(root); } //数据更新时的Json格式 else if (operationType == SynOperationType.UPDATE) { //更新单据时,表体信息必须填写明细表体的主键 root = new JObject(); root.Add("NeedUpDateFields", new JArray("")); root.Add("NeedReturnFields", new JArray("FNumber")); root.Add("IsDeleteEntry", "false"); root.Add("SubSystemId", ""); root.Add("IsVerifyBaseDataField", "true"); root.Add("BatchCount", batchCount); if (sourceDatas != null) { if (sourceDatas.Count() > 0) { JArray model = new JArray(); for (int i = 0; i < sourceDatas.Count(); i++) { K3CustomerInfo custData = sourceDatas.ElementAt(i) as K3CustomerInfo; string sFCustId = string.Format(@"/*dialect*/ select FCUSTID,FUseOrgId from T_BD_CUSTOMER where FNumber = '{0}'", custData.FNumber); DynamicObjectCollection coll = SQLUtils.GetObjects(this.K3CloudContext, sFCustId); if (coll.Count > 0) { foreach (var c in coll) { if (c["FCUSTID"] != null) { JObject baseData = ConvertSynObjToJObj(sourceDatas.ElementAt(i), operationType); //主组织记录 if (Convert.ToInt32(JsonUtils.ConvertObjectToString(c["FUseOrgId"])) == 1) { //主组织记录中的销售员和销售部门不能被更新 baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertObjectToString(c["FCUSTID"]))); //baseData.Add("FT_BD_CUSTCONTACT", BuildK3CustContactJsons(custData));//客户地址信息 } //else //{ // baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertJObjectToString(c["FCUSTID"]))); // JObject FSELLER = new JObject(); // FSELLER.Add("FNumber", custData.FSELLER); // baseData.Add("FSELLER", FSELLER); // JObject FSALDEPTID = new JObject(); // FSALDEPTID.Add("FNumber", custData.FSALDEPTID); // baseData.Add("FSALDEPTID", FSALDEPTID); //} model.Add(baseData); } } } } root.Add("Model", model); return(root); } } } return(null); }
public override AbsSynchroDataInfo BuildSynchroData(Context ctx, string json, AbsSynchroDataInfo data = null) { JArray jArr = JArray.Parse(json); List <K3CustContactInfo> contacts = null; K3CustContactInfo contact = null; if (jArr != null && jArr.Count > 0) { contacts = new List <K3CustContactInfo>(); for (int i = 0; i < jArr.Count; i++) { JObject jObj = jArr[i] as JObject; contact = new K3CustContactInfo(); contact.FCustNo = JsonUtils.GetFieldValue(jObj, "customers_id"); contact.FNUMBER1 = JsonUtils.GetFieldValue(jObj, "address_book_id"); contact.FNAME1 = JsonUtils.GetFieldValue(jObj, "entry_street_address") + " " + JsonUtils.GetFieldValue(jObj, "entry_city") + " " + JsonUtils.GetFieldValue(jObj, "entry_state") + " " + JsonUtils.GetFieldValue(jObj, "countries_iso_code_2"); contact.FADDRESS1 = JsonUtils.GetFieldValue(jObj, "entry_street_address") + System.Environment.NewLine + JsonUtils.GetFieldValue(jObj, "entry_suburb"); //contact.FTTel = JsonUtils.GetFieldValue(jObj, "entry_telephone"); contact.FMOBILE = JsonUtils.GetFieldValue(jObj, "entry_telephone"); contact.F_HS_DeliveryName = JsonUtils.GetFieldValue(jObj, "entry_firstname") + " " + JsonUtils.GetFieldValue(jObj, "entry_lastname"); contact.F_HS_PostCode = JsonUtils.GetFieldValue(jObj, "entry_postcode"); contact.F_HS_DeliveryCity = JsonUtils.GetFieldValue(jObj, "entry_city"); contact.F_HS_DeliveryProvinces = JsonUtils.GetFieldValue(jObj, "entry_state"); contact.F_HS_RecipientCountry = JsonUtils.GetFieldValue(jObj, "countries_iso_code_2"); if (string.IsNullOrWhiteSpace(contact.F_HS_RecipientCountry)) { string errorInfo = "客户地址同步,客户编码为:[" + contact.FCustNo + "]的信息国家编码为空!"; LogUtils.WriteSynchroLog(ctx, SynchroDataType.CustomerAddress, errorInfo); } contacts.Add(contact); } } if (contacts != null && contacts.Count > 0) { K3CustomerInfo k3Cust = GetCustomerByNo(ctx, contacts.ElementAt(0).FCustNo); if (k3Cust != null) { if (string.IsNullOrWhiteSpace(k3Cust.FFCOUNTRY)) { k3Cust.FFCOUNTRY = contacts.Select(c => c.F_HS_RecipientCountry).ToList().ElementAt(0); } k3Cust.lstCustCtaInfo = contacts; return(k3Cust); } else { k3Cust = new K3CustomerInfo(); k3Cust.lstCustCtaInfo = contacts; return(k3Cust); } } return(null); }
/// <summary> /// 数据库查询的结果集封装成List<K3CustomerInfo>对象 /// </summary> /// <param name="ctx"></param> /// <param name="coll"></param> /// <returns></returns> public List <K3CustomerInfo> BuildSynObjByCollection(Context ctx, DynamicObjectCollection coll) { List <K3CustomerInfo> custs = null; K3CustomerInfo cust = null; if (coll != null) { if (coll.Count > 0) { custs = new List <K3CustomerInfo>(); foreach (var item in coll) { cust = new K3CustomerInfo(); cust.FCreateOrgId = "100"; cust.FUseOrgId = "100"; cust.FNumber = SQLUtils.GetFieldValue(item, "FNumber"); cust.FShortName = SQLUtils.GetFieldValue(item, "FShortName"); cust.FName = SQLUtils.GetFieldValue(item, "FName"); if (string.IsNullOrWhiteSpace(cust.FName)) { cust.FName = "None Name"; } string sConutry = string.Format(@"/*dialect*/ select FNUMBER from VW_BAS_ASSISTANTDATA_CountryName where FCountry = '{0}'", SQLUtils.GetFieldValue(item, "FCOUNTRY")); cust.FFCOUNTRY = JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sConutry, "FNUMBER")); cust.FAddress = SQLUtils.GetFieldValue(item, "FAddress"); cust.FZIP = SQLUtils.GetFieldValue(item, "FZIP"); cust.FTEL = SQLUtils.GetFieldValue(item, "FTEL"); cust.F_HS_CustomerRegisteredMail = SQLUtils.GetFieldValue(item, "F_HS_CustomerRegisteredMail"); cust.FCustTypeId = SQLUtils.GetCustTypeNo(ctx, item, "FCustTypeId"); cust.FTRADINGCURRID = SQLUtils.GetSettleCurrNo(ctx, item, "FTRADINGCURRID"); cust.FSELLER = string.IsNullOrWhiteSpace(SQLUtils.GetSellerNo(ctx, item, "FSELLER")) ? "NA" : SQLUtils.GetSellerNo(ctx, item, "FSELLER"); string sDeptNo = string.Format(@"/*dialect*/ select b.FNUMBER from T_BD_STAFFTEMP a inner join T_BD_DEPARTMENT b on a.FDEPTID=b.FDEPTID inner join T_BD_STAFF c on a.FSTAFFID=c.FSTAFFID where c.FNUMBER='{0}'", cust.FSELLER); cust.FSALDEPTID = JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sDeptNo, "FNUMBER")); cust.F_HS_Grade = SQLUtils.GetFieldValue(item, "F_HS_Grade"); cust.F_HS_SpecialDemand = SQLUtils.GetFieldValue(item, "F_HS_SpecialDemand"); cust.F_HS_TaxNum = SQLUtils.GetFieldValue(item, "F_HS_TaxNum"); cust.FPRICELISTID = SQLUtils.GetFieldValue(item, "FPRICELISTID"); cust.F_HS_CustomerPurchaseMail = SQLUtils.GetFieldValue(item, "F_HS_CustomerPurchaseMail"); cust.FSETTLETYPEID = "JSFS01_SYS"; cust.FTaxType = "SZ01_SYS"; cust.FTaxRate = "SL04_SYS"; cust.FPriority = "1"; cust.FRECEIVECURRID = "PRE001"; cust.FISCREDITCHECK = false; cust.FIsTrade = true; custs.Add(cust); } } } return(custs); }
/// <summary> /// 5、客户审核时: ///5.1 校验信用额度的调整:若客户.原信用额度 - 客户.信用额度>客户.剩余信用额度,校验不通过,审核失败 ///5.2 若客户.信用额度<> 客户.原信用额度,更新客户.剩余信用额度: ///客户.剩余信用额度 +=客户.信用额度 - 客户.原信用额度 /// </summary> /// <param name="ctx"></param> /// <param name="objs"></param> /// <param name="result"></param> /// <returns></returns> public override IEnumerable <AbsSynchroDataInfo> GetK3Datas(Context ctx, List <DynamicObject> objs, ref HttpResponseResult result) { List <K3CustomerInfo> custs = null; K3CustomerInfo cust = null; decimal oldCreditLineUSD = 0; decimal creditLineUSD = 0; decimal surplusCreditUSD = 0; result = new HttpResponseResult(); result.Success = true; if (objs != null && objs.Count > 0) { custs = new List <K3CustomerInfo>(); foreach (var item in objs) { if (item != null) { oldCreditLineUSD = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldCreditLineUSD")); creditLineUSD = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_CreditLineUSD")); surplusCreditUSD = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_SurplusCreditUSD")); if (oldCreditLineUSD - creditLineUSD <= surplusCreditUSD) { DynamicObject useOrgId = item["UseOrgId"] as DynamicObject; string useOrgNo = SQLUtils.GetFieldValue(useOrgId, "Number"); if (useOrgNo.CompareTo("100.01") == 0) { cust = new K3CustomerInfo(); cust.FUseOrgId = useOrgNo; cust.SrcNo = SQLUtils.GetFieldValue(item, "Number"); cust.FNumber = cust.SrcNo; cust.FDocumentStatus = SQLUtils.GetFieldValue(item, "DocumentStatus"); cust.F_HS_IntegralReturnRate = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_IntegralReturnRate")); cust.F_HS_FixedFreightDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_FixedFreightDiscount")); cust.F_HS_IntegralReturnRate = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_IntegralReturnRate")); cust.F_HS_OnlineDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OnlineDiscount")); cust.F_HS_TTDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_TTDiscount")); cust.F_HS_DiscountChangeRemark = SQLUtils.GetFieldValue(item, "F_HS_DiscountChangeRemark"); cust.F_HS_OldOnlineDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldOnlineDiscount")); cust.F_HS_OldTTDISCOUNT = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldTTDISCOUNT")); cust.F_HS_OldFixedFreightDiscount = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldFixedFreightDiscount")); cust.F_HS_OldIntegralReturnRate = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldIntegralReturnRate")); cust.F_HS_OldCreditLineUSD = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_OldCreditLineUSD")); cust.F_HS_CreditLineUSD = Convert.ToDecimal(SQLUtils.GetFieldValue(item, "F_HS_CreditLineUSD")); cust.F_HS_OldDiscountChangeRemark = SQLUtils.GetFieldValue(item, "F_HS_OldDiscountChangeRemark"); cust.F_HS_SurplusCreditUSD = surplusCreditUSD; custs.Add(cust); } } else { result = new HttpResponseResult(); result.Success = false; result.Message = "客户原信用额度不能大于客户信用额度!" + Environment.NewLine; } } } } return(custs.Where(c => { return c.FUseOrgId.CompareTo("100.01") == 0 && (c.F_HS_FixedFreightDiscount > 0 || c.F_HS_IntegralReturnRate > 0 || c.F_HS_OnlineDiscount > 0 || c.F_HS_TTDiscount > 0 ); }).ToList <AbsSynchroDataInfo>());; }
/// <summary> /// 客户分配完后所做的操作,更新--提交--审核 /// </summary> /// <param name="ctx"></param> /// <param name="sourceDatas"></param> /// <param name="operationType"></param> /// <returns></returns> public JObject BuildSyschroDataJsonForAfterAllot(Context ctx, List <AbsSynchroDataInfo> sourceDatas, SynOperationType operationType) { JObject root = null; if (operationType == SynOperationType.SAVE) { root = new JObject(); root.Add("NeedUpDateFields", new JArray("")); root.Add("NeedReturnFields", new JArray("FNumber")); root.Add("IsDeleteEntry", "false"); root.Add("SubSystemId", ""); root.Add("IsVerifyBaseDataField", "true"); root.Add("Model", ConvertSynObjToJObj(sourceDatas, operationType)); return(root); } //数据更新时的Json格式 else if (operationType == SynOperationType.UPDATE) { //更新单据时,表体信息必须填写明细表体的主键 root = new JObject(); root.Add("NeedUpDateFields", new JArray("")); root.Add("NeedReturnFields", new JArray("FNumber")); root.Add("IsDeleteEntry", "false"); root.Add("SubSystemId", ""); root.Add("IsVerifyBaseDataField", "true"); if (sourceDatas != null) { if (sourceDatas.Count > 0) { JArray model = new JArray(); for (int i = 0; i < sourceDatas.Count; i++) { K3CustomerInfo custData = sourceDatas[i] as K3CustomerInfo; string sFCustId = string.Format(@"/*dialect*/ select FCUSTID,FUseOrgId from T_BD_CUSTOMER where FNumber = '{0}' and FUseOrgId = {1}", custData.FNumber, ORGID); DynamicObjectCollection coll = SQLUtils.GetObjects(this.K3CloudContext, sFCustId); if (coll.Count > 0) { foreach (var c in coll) { if (c["FCUSTID"] != null) { JObject baseData = ConvertSynObjToJObj(sourceDatas[i], operationType); baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertObjectToString(c["FCUSTID"]))); JObject FSELLER = new JObject(); FSELLER.Add("FNumber", string.IsNullOrEmpty(custData.FSELLER) ? "NA" : custData.FSELLER); baseData.Add("FSELLER", FSELLER); JObject FSALDEPTID = new JObject(); FSALDEPTID.Add("FNumber", string.IsNullOrEmpty(custData.FSALDEPTID) ? "BM000001" : custData.FSALDEPTID); baseData.Add("FSALDEPTID", FSALDEPTID); model.Add(baseData); } } } } root.Add("Model", model); return(root); } } } return(null); }