/// <summary> /// 销售退货 /// </summary> /// <param name="model">退货明细</param> /// <param name="customer">分销商erp编号</param> /// <param name="description">单据摘要(商城订单号/升舱订单号)</param> /// <param name="flowIdentify"></param> /// <returns></returns> /// <remarks>2013-9-27 杨浩 添加</remarks> public Result SaleInStock(List <SaleInfo> model, string customer, string description, string flowIdentify) { var datajson = new SaleInfoWraper { Model = model, Type = 出库状态.退货, Customer = customer, Description = description }.ToJson(); var easModel = new Hyt.Model.EasSyncLog { Data = datajson, FlowIdentify = flowIdentify }; var status = KisCore.SaleIssueBillFacade(easModel); //同步兴业嘉仓数据 if (model.First().WarehouseSysNo == 59 || model.First().WarehouseSysNo == 61 || model.First().WarehouseSysNo == 4 || model.First().WarehouseSysNo == 30 || model.First().WarehouseSysNo == 41) { XingYe.XingYeProviderFactory.CreateProvider().SaleInStock(model, customer, description, flowIdentify); } //同步利嘉 LiJia.LiJiaProviderFactory.CreateProvider().SaleInStock(model, customer, description, flowIdentify); return(status); }
/// <summary> /// 获取Kis同步数据 /// </summary> /// <param name="model">Kis</param> /// <returns></returns> /// <remarks>2013-9-27 杨浩 添加</remarks> public Result <string> GetData(CBEasSyncLog model) { var easModel = new Hyt.Model.EasSyncLog { SysNo = model.SysNo, Data = model.Data, DataMd5 = model.DataMd5, FlowIdentify = model.FlowIdentify, }; var iType = (接口类型)(model.InterfaceType); var result = new Result <string> { }; switch (iType) { case 接口类型.配送员借货还货: var borrow = model.Data.ToObject <BorrowInfoWraper>(); result = KisCore.OtherIssueBillFacade(borrow.Model, borrow.Type, borrow.Description, "", model.DataMd5, true, true, true); break; case 接口类型.销售出库退货: //var sale = model.Data.ToObject<SaleInfoWraper>(); result = KisCore.SaleIssueBillFacade(easModel, false, true, true, true); break; case 接口类型.采购入库退货: result = KisCore.PurchaseIssueBillFacade(easModel, false, true, true, true); break; case 接口类型.调拨单据导入: result = KisCore.TransferStockIssueBillFacade(easModel, false, true, true, true); break; case 接口类型.收款单据导入: var receiving = model.Data.ToObject <ReceivingInfoWraper>(); result = KisCore.ReceivingBillFacade(0, receiving.Model, receiving.ReceivingType, receiving.Customer, receiving.Description, "", model.DataMd5, true, true, true); break; } return(result); }
/// <summary> /// 重新同步数据 /// </summary> /// <param name="sysNo">Eas同步系统编号</param> /// <param name="isSave">销售出库单是否传保存状态</param> /// <returns></returns> /// <remarks>2013-9-27 杨浩 添加</remarks> public Result Resynchronization(int sysNo, bool isSave = false) { //string key = "Hyt.EasLog." + sysNo; lock (_lockThis) { //判断是否有锁 if (_synclist.Contains(sysNo)) { return new Result { Status = false, Message = "正在同步,请稍后再试..." } } ; //加锁 _synclist.Add(sysNo); } var model = Hyt.DataAccess.Sys.IEasDao.Instance.GetEntity(sysNo); if (model.Status == (int)步状态.成功) { return(new Result { Message = "此信息已同步成功!", Status = false }); } //收款单 bool isFull = false; int warehouseSysNo = 0; // var iType = (接口类型)(model.InterfaceType); var result = new Result <string> { }; var watch = new Stopwatch(); watch.Start(); switch (iType) { case 接口类型.配送员借货还货: var borrow = model.Data.ToObject <BorrowInfoWraper>(); result = KisCore.OtherIssueBillFacade(borrow.Model, borrow.Type, borrow.Description, model.FlowIdentify, model.DataMd5, true); break; case 接口类型.销售出库退货: //var sale = model.Data.ToObject<SaleInfoWraper>(); result = KisCore.SaleIssueBillFacade(model, isSave, true); break; case 接口类型.采购入库退货: result = KisCore.PurchaseIssueBillFacade(model, isSave, true); break; case 接口类型.调拨单据导入: result = KisCore.TransferStockIssueBillFacade(model, isSave, true); break; case 接口类型.收款单据导入: #region 收款单据导入 var receiving = model.Data.ToObject <ReceivingInfoWraper>(); if (model.Message.StartsWith(EasConstant.Information)) { isFull = true; foreach (var item in receiving.Model) { if (item.WarehouseSysNo == 0) { int orderSysNo = 0; int.TryParse(item.OrderSysNo, out orderSysNo); var wh = IOutStockDao.Instance.GetWhStockOutListByOrderID(orderSysNo, true); if (wh != null && wh.Count > 0) { item.Remark = ""; item.WarehouseSysNo = wh.FirstOrDefault().WarehouseSysNo; warehouseSysNo = item.WarehouseSysNo; var warehouse = IWhWarehouseDao.Instance.GetWarehouse(warehouseSysNo); //地区仓库 if (warehouse != null) { item.WarehouseNumber = warehouse.ErpCode; } } } var oraganization = IOrganizationDao.Instance.GetOrganization(item.WarehouseSysNo); if (oraganization != null) { item.OrganizationCode = oraganization.Code; } if (item.PayeeAccount != EasConstant.PayeeAccount && string.IsNullOrEmpty(item.PayeeAccount)) { var pa = IFnReceiptTitleAssociationDao.Instance.GetList(item.WarehouseSysNo, PaymentType.现金) .OrderByDescending(m => m.IsDefault) .FirstOrDefault(); if (pa != null) { item.PayeeAccount = pa.EasReceiptCode; } } } } result = KisCore.ReceivingBillFacade(model.SysNo, receiving.Model, receiving.ReceivingType, receiving.Customer, receiving.Description, model.FlowIdentify, model.DataMd5, true); break; #endregion } watch.Stop(); if (result.Status || result.StatusCode == "105")// || result.StatusCode == "9999" || result.Message.Contains("当前单据已经同步成功")) { model.Status = (int)步状态.成功; model.VoucherNo = result.Data; model.Message = "同步成功"; //消息特殊处理:销售出库单,外部系统id:1e65059916eb765b4b7d17496589c904,已经同步过,对应EAS单据ID为:XSCK2014052905193353,请不要重复同步... if (result.StatusCode == "105" && !string.IsNullOrEmpty(result.Message)) { var reg = new Regex(@"XSCK(\d*)"); var m = reg.Match(result.Message); model.VoucherNo = m.Value; } //消息特殊处理:当前单据已经同步成功,kis单据号为:XSCK2014081907917302 else if (!string.IsNullOrEmpty(result.Message) && result.Message.Contains("单据重复")) { Regex reg = new Regex(@"XSCK(\d*)"); var m = reg.Match(result.Message); model.VoucherNo = m.Value; } } else { model.Status = (int)步状态.失败; model.Message = result.Message; } model.SyncNumber = model.SyncNumber + 1; model.StatusCode = result.StatusCode; model.ElapsedTime = (int)watch.ElapsedMilliseconds; model.LastsyncTime = DateTime.Now; model.LastupdateDate = DateTime.Now; model.LastupdateBy = Hyt.Model.SystemPredefined.User.SystemUser; //收款单资料不全,重新读取并更新 if (isFull && warehouseSysNo != 0) { model.WarehouseSysNo = warehouseSysNo; } Hyt.DataAccess.Sys.IEasDao.Instance.Update(model); _synclist.Remove(sysNo); return(result); }