using System; using System.IO; using System.Xml.Serialization; using WX.CRM.BLL.Base; using WX.CRM.BLL.Res; using WX.CRM.BLL.Wx; using WX.CRM.Common; using WX.CRM.DataSynFactory.Templates; using WX.CRM.Model.Entity; namespace WX.CRM.DataSynFactory.Cmd { public class Client_Order_IMP : Interfaces.IDataImportSvr { private WX_SZZYORDER_BL _order = new WX_SZZYORDER_BL(); private WX_ORDEREXT_BL _orderExtend = new WX_ORDEREXT_BL(); RES_CUSTOMER_BL res_Customer_BL = new RES_CUSTOMER_BL(); private BAS_INNERUSER_BL _user = new BAS_INNERUSER_BL(); private WX_SZZYSUBPRODUCT_BL _subProduct = new WX_SZZYSUBPRODUCT_BL(); public bool GenerateBusinessOne(Client_Order t) { try { var order = _order.Get(p => p.SZZYORDERID == t.SZZYORDERID); if (order == null) { decimal? userId = null; if (t.eid.HasValue) { userId = _user.GetModelByEid(t.eid.Value).PKID; } else { var midProduct = _subProduct.Get(p => p.SUBPRODUCTID == t.SUBPRODUCTID); if (midProduct != null) { var midProductId = midProduct.MIDPRODUCTID; if (midProductId == 100900305) { userId = _user.GetModelByEid(3900).PKID; } } } _order.Add(new WX_SZZYORDER() { ORDERID = t.ORDERID, EMPLOYEEID = t.EMPLOYEEID, PASSWORD = t.PASSWORD, USERID = t.USERID, PRODUCTID = t.PRODUCTID, PRODUCTNAME = t.PRODUCTNAME, SUBPRODUCTID = t.SUBPRODUCTID, SUBPRODUCTNAME = t.SUBPRODUCTNAME, ORDERTYPE = t.ORDERTYPE, UPGRADEORDERIDS = t.UPGRADEORDERIDS, TOTALUPGRADEVALUE = t.TOTALUPGRADEVALUE, NEEDPAY = t.NEEDPAY, OPENORDER = t.OPENORDER, SZZYORDERID = t.SZZYORDERID, CTIME = t.CTIME, RETURNNEEDPAY = t.RETURNNEEDPAY, CONTRACTCODE = t.CONTRACTCODE, RET = t.RET, MSG = t.MSG, RETURNDETAIL = t.RETURNDETAIL, INNERUSERID = userId, OTIME = t.OTIME, RESID = t.RESID, REQUESTSTATUS = t.REQUESTSTATUS, ISFINANCEPAY = t.ISFINANCEPAY, FINACEPAYDATE = t.FINACEPAYDATE, REMARK = t.REMARK, FINALPAY = t.FINALPAY, ORDERSTATUS = t.ORDERSTATUS, ORDERSTATUSNAME = t.ORDERSTATUSNAME, OPERATETIME = t.OPERATETIME, STIME = t.STIME, ETIME = t.ETIME, SUSPENDCOMMENT = t.SUSPENDCOMMENT, UPDATEORDERTIME = t.UPDATEORDERTIME, ISOPEN = t.ISOPEN, ENDTIME = t.ENDTIME, TEAMSERVE = t.TEAMSERVE, CUSTOMERUSERNAME = t.CUSTOMERUSERNAME, ARRIVALPAY = t.ARRIVALPAY, ARRIVALTIME = t.ARRIVALTIME, SOURCE = t.SOURCE, CNAME = t.CNAME, OPENDAYS = t.OPENDAYS, CUSTOMERCLASSIFY = t.CUSTOMERCLASSIFY, SALEDEPTID = t.SALEDEPTID, ACTIVEPRODUCTCODE = t.activeproductcode, ACTIVEPRODUCTEXT = t.activeproductext, ISTEST = t.ISTEST, OUTORDERO = t.OUTORDERO//***第三方平台订单号*** }); _orderExtend.Add(new WX_ORDEREXT() { ORDERID = t.ORDERID, NAME = t.CNAME, SOFTUSERNAME = t.SOFTUSERNAME, ISPAYED = t.ISPAYED, PAYTYPE = t.PAYTYPE, OPENDAYS = t.OPENDAYS, APPUSERNAME = t.APPUSERNAME, PRODUCTID = t.SUBPRODUCTID, PRODUCTCODE = t.PRODUCTCODE, BIGPRODUCTCODE = t.BIGPRODUCTCODE, CHANNEL = t.CHANNEL, BOOKNUM = t.BOOKNUM, ORDERSTATUS = int.Parse(t.ORDERSTATUS) }); if (!string.IsNullOrEmpty(t.mb)) { var resid = WX.CRM.Common.ResUtil.CreateResId(t.mb); if (res_Customer_BL.getResCustomerByResId(resid) == null) { var customerDetail = new RES_CUSTOMERDETAIL(); customerDetail.CNAME = t.CNAME; var xmls = new XmlSerializer(typeof(RES_CUSTOMERDETAIL)); var sw = new StringWriter(); xmls.Serialize(sw, customerDetail); res_Customer_BL.ResgisterCustomer(t.mb, resid, "orderres", sw.ToString());//注册资源 } new RES_CUSTOMERUSER_BL().ContractUser(resid, t.SOFTUSERNAME);//关联用户 } return true; } else { LogHelper.Info("已经存在的订单order:" + order.ToJson()); //LogHelper.Info("请求数据:" + t.ToJson()); order.ORDERID = t.ORDERID; order.EMPLOYEEID = t.EMPLOYEEID; order.PASSWORD = t.PASSWORD; order.USERID = t.USERID; order.PRODUCTID = t.PRODUCTID; order.PRODUCTNAME = t.PRODUCTNAME; order.SUBPRODUCTID = t.SUBPRODUCTID; order.SUBPRODUCTNAME = t.SUBPRODUCTNAME; order.ORDERTYPE = t.ORDERTYPE; order.UPGRADEORDERIDS = t.UPGRADEORDERIDS; order.TOTALUPGRADEVALUE = t.TOTALUPGRADEVALUE; order.NEEDPAY = t.NEEDPAY; order.OPENORDER = t.OPENORDER; order.SZZYORDERID = t.SZZYORDERID; order.CTIME = t.CTIME; order.RETURNNEEDPAY = t.RETURNNEEDPAY; order.CONTRACTCODE = t.CONTRACTCODE; order.RET = t.RET; order.MSG = t.MSG; order.RETURNDETAIL = t.RETURNDETAIL; //order.INNERUSERID = userId; order.OTIME = t.OTIME; order.RESID = t.RESID; order.REQUESTSTATUS = t.REQUESTSTATUS; order.ISFINANCEPAY = t.ISFINANCEPAY; order.FINACEPAYDATE = t.FINACEPAYDATE; order.REMARK = t.REMARK; order.FINALPAY = t.FINALPAY; order.ORDERSTATUS = t.ORDERSTATUS; order.ORDERSTATUSNAME = t.ORDERSTATUSNAME; order.OPERATETIME = t.OPERATETIME; order.STIME = t.STIME; order.ETIME = t.ETIME; order.SUSPENDCOMMENT = t.SUSPENDCOMMENT; order.UPDATEORDERTIME = t.UPDATEORDERTIME; order.ISOPEN = t.ISOPEN; order.ENDTIME = t.ENDTIME; order.TEAMSERVE = t.TEAMSERVE; order.CUSTOMERUSERNAME = t.CUSTOMERUSERNAME; order.ARRIVALPAY = t.ARRIVALPAY; order.ARRIVALTIME = t.ARRIVALTIME; order.SOURCE = t.SOURCE; order.CNAME = t.CNAME; order.OPENDAYS = t.OPENDAYS; order.CUSTOMERCLASSIFY = t.CUSTOMERCLASSIFY; order.SALEDEPTID = t.SALEDEPTID; order.ACTIVEPRODUCTCODE = t.activeproductcode; order.ACTIVEPRODUCTEXT = t.activeproductext; order.ISTEST = t.ISTEST; order.OUTORDERO = t.OUTORDERO;//***第三方平台订单号*** order.RISKCTRLSTATUS = t.RISKCTRLSTATUS; _order.Update(order); return true; } } catch (Exception ex) { LogHelper.Error(ex.ToString()); LogHelper.Error("错误的json:" + t.ToJson()); return false; } } } }