//using Muchinfo.ClientTerminal.Common.Data; //using Muchinfo.ClientTerminal.Common.Data.Models; //using Muchinfo.ClientTerminal.CustomException; //using Muchinfo.ClientTerminal.Data.Enums; //using Muchinfo.ClientTerminal.DataAdapter; //using Muchinfo.ClientTerminal.DeliveryData.Enums; //using Muchinfo.ClientTerminal.DeliveryData.Models; //using Muchinfo.ClientTerminal.Infrastructure.Cache; //using Muchinfo.ClientTerminal.Infrastructure.Utilities; //using Muchinfo.ClientTerminal.Communication; //using System; //using System.Collections.Generic; //using System.Collections.ObjectModel; //using System.Linq; //using Muchinfo.MTPClient.Service.Utilities; //using Tas.BusinessManager.DataContract.Entity; //using Tas.BusinessManager.DataContract.Enum; //using Tas.BusinessManager.DataContract.Request; //using Tas.BusinessManager.DataContract; //using Tas.BusinessManager.DataContract.Response; //namespace Muchinfo.ClientTerminal.BLL //{ // /// // /// 交收服务 // /// // public class DeliveryManageService : IDeliveryManageService // { // /// // /// 获取交收账号 // /// // /// // public AccountEntry GetAccountEntry() // { // var userAccount = UserManager.CurrentTradeAccount; // return new AccountEntry() // { // AccountCode = userAccount.TradeCode, // AccountName = userAccount.LoginCode, // AreaCode = userAccount.AreaCode, // AccountType = (Common.Data.Enums.AccountType)userAccount.AccountType, // }; // } // /// // /// 获取交收商品 // /// // /// // public List GetAllDeiveryGoodses() // { // var deliveries = new List(); // var goodses = CacheManager.CacheGoodsBaseInfos; // if (goodses == null || !goodses.Any()) return deliveries; // foreach (var quoteGoodse in goodses) // { // var goods = new DeliveryGoods() // { // GoodsCode = quoteGoodse.GoodsCode, // GoodsName = quoteGoodse.Name, // GoodsClassCode = quoteGoodse.GoodsClassCode, // GoodsClassName = quoteGoodse.GoodsClassName // }; // if (quoteGoodse.GoodsParameters != null) // { // goods.AgreeUnit = quoteGoodse.GoodsParameters.AgreeUnit; // goods.DelveryTradeMode = (DelveryTradeMode)quoteGoodse.GoodsParameters.TradeMode; // } // deliveries.Add(goods); // } // return deliveries; // } // /// // /// 获取持仓 // /// // /// // public System.Collections.Generic.List GetDeliveryDetails() // { // var userAccount = UserManager.CurrentTradeAccount; // var holders = UserManager.GetOpenOrders(userAccount); // if (holders == null || !holders.Any()) return new List(); // var deliveryAdapter = new DeliveryResponseAdapter(); // var listHolders = holders.ToList(); // if (userAccount.AccountType == ClientAccountType.MemberTradeAccount) //会员交收竞价商品 // listHolders = holders.Where( // (hold) => // hold.QuoteGoods != null && hold.QuoteGoods.GoodsParameters != null && // hold.QuoteGoods.GoodsParameters.TradeMode == TradeModeType.BidGoods).ToList(); // return deliveryAdapter.ConvertDeliveryHoldDetials(listHolders); // } // /// // /// 新增地址 // /// // /// 地址信息 // /// 返回错误码 // public int AddAddress(Muchinfo.ClientTerminal.Common.Data.Address address) // { // var userAccount = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(userAccount.LoginCode); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var adapter = new DeliveryResponseAdapter(); // var addressResquet = adapter.ConvertAddReceiptorInfo(address); // addressResquet.AccountCode = userAccount.TradeCode; // var result = proxy.AddReceiptor(addressResquet); // //if (result == null) return ExceptionManager.UnknownServiceErrorCode; // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // address.Number = result.ReceiptorSeq; // return result.ReturnCode; // } // /// // /// 查询交收参数,获取品种对应的转换后数值 // /// // /// 商品代码 // /// 转换后的品种代码 // /// 市场类型,目前交收做的是竞价的,所有为1;以后扩展再说 // /// // public List QueryDeliveryConfig(string goodCode, string AfterChangeGoods, int marketType) // { // var userAccount = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(userAccount.LoginCode); // if (proxy == null) return null; // var result = proxy.QueryDeliveryConfig( // new QueryDeliveryConfigRequest() // { // AreaCode = userAccount.AreaCode, // // AreaCode = "-1",//竞价的时候,都为-1,如果是即期,则会是具体的机构代码 // GoodsCode = goodCode, // AfterChangeGoods = AfterChangeGoods, // markettype = marketType // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // var deliveryAdapter = new DeliveryResponseAdapter(); // if (result.ReturnCode == 0) // { // return deliveryAdapter.CovertDeiveryConfigs(result.Rsps); // } // else // { // throw new MuchinfoException(result.ReturnCode); // } // } // /// // /// 查询交收价格,竞价交收,新增模块的功能,add by justin.huang // /// // /// 商品代码 // /// 品种代码 // /// // public decimal QueryDeliveryPrice(string goodsCode, string goodsclasscode) // { // decimal ret = 0; // var userAccount = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(userAccount.LoginCode); // if (proxy == null) return 0; // var result = proxy.QueryDeliveryPrice( // new QueryDeliveryPriceRequest // { // GoodsCode = goodsCode, // GoodsClassCode = goodsclasscode, // } // ); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryService)); // } // //if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode == 0) // { // if (result.Rsps != null && result.Rsps.Any()) // { // foreach (var deliveryPrice in result.Rsps) // { // ret = deliveryPrice.Price; // } // } // } // else // { // throw new MuchinfoException(result.ReturnCode); // } // return ret; // } // /// // /// 修改地址 // /// // /// 地址信息 // /// 返回错误码 // public int ModifyAddress(Muchinfo.ClientTerminal.Common.Data.Address address) // { // var userAccount = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(userAccount.LoginCode); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var adapter = new DeliveryResponseAdapter(); // var addressResquet = adapter.ConvertModifyReceiptorInfo(address); // addressResquet.AccountCode = userAccount.TradeCode; // var result = proxy.ModifyReceiptorInfo(addressResquet); // //if (result == null) return ExceptionManager.UnknownServiceErrorCode; // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // address.Number = result.ReceiptorSeq; // return result.ReturnCode; // } // /// // /// 删除地址 // /// // /// 要删除的地址信息 // /// 返回错误码 // public int DeleteAddress(Muchinfo.ClientTerminal.Common.Data.Address address) // { // // throw new System.NotImplementedException(); // var userAccount = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(userAccount.LoginCode); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var adapter = new DeliveryResponseAdapter(); // var result = proxy.DeleteReceiptor(new DeleteReceiptorInfoRequest() // { // ReceiptorSeq = address.Number, // }); // //if (result == null) return ExceptionManager.UnknownServiceErrorCode; // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // return result.ReturnCode; // } // /// // /// 查询提货人地址信息 // /// // /// // public System.Collections.Generic.List QueryAddresses(int takeDeliveryType) // { // var userAccount = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(userAccount.LoginCode); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var adapter = new DeliveryResponseAdapter(); // var result = proxy.QueryReceiptorAddrss(new QueryReceiptorInfoRequest() // { // AccountCode = userAccount.TradeCode, // TakeDeliveryType = (TakeDeliveryType)takeDeliveryType, // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // //if (result == null || result.ReturnCode != 0) // // throw new MuchinfoException(result == null ? ExceptionManager.UnknownServiceErrorCode : result.ReturnCode, result == null ? null : result.ReturnDesc); // var addresses = adapter.ConvertReceiptorAddresses(result.Rsps.ToList()); // return addresses; // } // #region 交收查询 // /// // /// 查询交收单 // /// // /// 开始日期 // /// 结束日期 // /// 交收方向 // /// 状态 // /// // public List QueryDeliveryDetails(DateTime startDate, DateTime endDate, // Common.Data.Enums.Direction direction, DeliveryApplyStatus status, bool IsQueryHistory) // { // var Rlt = new List(); // var account = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(account.LoginCode); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var adapter = new DeliveryResponseAdapter(); // BusinessResult deResult; // BusinessStep businessStep = ConvertDelivery(status, out deResult); // // var goodses = GetAllDeiveryGoodses(); // var request = new QueryDeliveryOrderRequest() // { // AccountCode = account.TradeCode, // DeliveryWay = (int)direction, // Status = (int)businessStep, // Result = (int)deResult, // }; // if (IsQueryHistory) // { // request.StartDate = startDate.ToString("yyyy-MM-dd HH:mm:ss"); // request.EndDate = endDate.ToString("yyyy-MM-dd HH:mm:ss"); // } // var result = proxy.QueryDeliveryOrder(request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // Rlt = new DeliveryResponseAdapter().ConverterApplyDetails(result.Rsps.ToList(), null); // return Rlt; // } // private BusinessStep ConvertDelivery(DeliveryApplyStatus status, out BusinessResult deliveryResult) // { // var businessStep = BusinessStep.Delivery2Step_Apply; // deliveryResult = BusinessResult.All; // switch (status) // { // case DeliveryApplyStatus.All: // deliveryResult = BusinessResult.All; // businessStep = BusinessStep.All; // break; // //case DeliveryApplyStatus.Audit: // // businessStep= // // break; // //case DeliveryApplyStatus.Trade_All: // // break; // //case DeliveryApplyStatus.Trade_Part: // // break; // //case DeliveryApplyStatus.Audit_refuse: // // break; // //case DeliveryApplyStatus.Cancel: // // break; // default: // deliveryResult = BusinessResult.All; // businessStep = BusinessStep.All; // break; // } // return businessStep; // } // /// // /// 交收申报 // /// // /// 交收委托单 // /// // public int DeliveryApplyOrder(EntrustDeliveryHold deliveryOrder) // { // var userAccount = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(userAccount.LoginCode); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var adapter = new DeliveryResponseAdapter(); // var entrustOrder = adapter.EntrustOrderConvert(deliveryOrder); // entrustOrder.MemberCode = userAccount.MemberCode; // entrustOrder.TradeCode = userAccount.TradeCode; // entrustOrder.OrderType = OrderTypeEnum.Delivery2; // entrustOrder.GoodsCode = deliveryOrder.GoodsClassCode; // entrustOrder.EntrustPrice = deliveryOrder.DeliveryPrice; // var userInfo = GetAccountEntry(); // entrustOrder.OperatorCode = userInfo.AccountCode; // entrustOrder.DeliveryOrderEntrust.DeliveryAccountCode = deliveryOrder.DelveryTradeMode == DelveryTradeMode.Bid // ? userAccount.MemberCode // : (deliveryOrder.TradeDirection == Muchinfo.ClientTerminal.Common.Data.Enums.Direction.Ask // ? userAccount.TradeCode // : ""); // entrustOrder.EntrustQuantity = deliveryOrder.DeliveryQty; // var result = proxy.EntrustOrder(entrustOrder); // if (result == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // return result.ReturnCode; // } // /// // /// 取消交收申请 // /// // /// 交收单 // /// // public int CancelDeliveryApply(DeliveryApplyDetail deliveryOrder) // { // var userAccount = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(userAccount.LoginCode); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var entrustOrder = new EntrustOrderRequest() // { // GoodsCode = deliveryOrder.GoodsCode, // BuyOrSell = (BuyOrSellType)deliveryOrder.Direction, // }; // entrustOrder.DeliveryOrderEntrust = new DeliveryOrderEntrust() // { // DeliveryType = (Delivery2_OrderType)deliveryOrder.DeliveryModeType, // DeliveryOrderType = DeliveryOrderType.DeliveryOrderType_Cancel, // // DeliveryOrderType = DeliveryOrderMode.DeliveryOrder_Hedge, // AccountCode = userAccount.TradeCode, // DeliveryID = deliveryOrder.DeliveryID, // }; // entrustOrder.MemberCode = userAccount.MemberCode; // entrustOrder.TradeCode = userAccount.TradeCode; // entrustOrder.OrderType = OrderTypeEnum.Delivery2; // entrustOrder.GoodsCode = deliveryOrder.GoodsCode; // entrustOrder.OperatorCode = userAccount.TradeCode; // entrustOrder.EntrustQuantity = deliveryOrder.DeliveryQty; // var result = proxy.EntrustOrder(entrustOrder); // return result.ReturnCode; // } // /// // /// 查询当前中间仓行情 // /// // /// 中间仓行情 // public List QueryDeliveryQuote() // { // var goodses = GetAllDeiveryGoodses(); // var account = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(account.LoginCode); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // //todo:交收行情查询 // var adapter = new DeliveryResponseAdapter(); // var result = proxy.QueryBidReceiptStats(new QueryBidReceiptStatsRequest() // { // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // //return new List(); // return adapter.ConvertDeliveryQuote(result.Rsps.ToList(), goodses); // } // /// // /// 申请提货预约 // /// // /// 提货信息 // /// // public int PickingGoodsOrder(PickGoodsApply goodsApply) // { // var account = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(account.LoginCode); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var adapter = new DeliveryResponseAdapter(); // var pickingGoodsReq = adapter.ConvertPickingGoodsOrderReq(goodsApply); // var result = proxy.PickingGoodsApply(pickingGoodsReq); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // return result.ReturnCode; // } // /// // /// 提货单查询 // /// // /// 开始时间 // /// 结束时间 // /// 提货方向 // /// // public List QueryPickingGoodsOrders(DateTime startDateTime, DateTime enDateTime, // ReceiveMode receiveMode, bool IsQueryHistory) // { // var Rlt = new List(); // var goodses = GetAllDeiveryGoodses(); // var account = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(account.LoginCode); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var Request = new QueryTakeDeliveryRequest() // { // AccountCode = account.TradeCode, // TakeDeliveryType = (int)receiveMode, // }; // if (IsQueryHistory) // { // Request.StartDate = startDateTime.ToString("yyyy-MM-dd HH:mm:ss"); // Request.EndDate = enDateTime.ToString("yyyy-MM-dd HH:mm:ss"); // } // var result = proxy.QueryPickingGoods(Request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // Rlt = new DeliveryResponseAdapter().ConvertPickingGoodsOrder(result.Rsps.ToList(), goodses); // return Rlt; // } // /// // /// 收货确认 // /// // /// 提货单 // /// // public int ConfirmPickingGoods(PickingGoodsOrder pickingGoodsOrder) // { // var adapter = new DeliveryResponseAdapter(); // return 0; // } // /// // /// 提货仓库查询 // /// // /// // /// // /// // public List QueryWarehouses() // { // var account = UserManager.CurrentTradeAccount; // var proxy = LinkerHelper.GetBizServiceProxy(account.LoginCode); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var result = proxy.QueryWarehouseParameters(new QueryWarehouseParameterRequest() // { // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // var adapter = new DeliveryResponseAdapter(); // //todo:调用服务查询仓库 // return adapter.ConvertWarehouse(result.Rsps.ToList()); // } // #endregion // //--------------------------------------------------------------------------------------------- // /// // /// 获取入库预约 // /// // /// 开始时间 // /// 结束时间 // /// 仓库 // /// 状态 // /// // public ObservableCollection GetStorageManagement(System.DateTime startTime, // System.DateTime endTime, string warehouse, int state, bool IsQueryHistory, DeliveryData.Enums.OperationType op = OperationType.Query) // { // var Rlt = new ObservableCollection(); // var userInfo = GetAccountEntry(); // var index = 1; // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var Request = new QueryDeclareStorageRequest() // { // Result = int.MinValue, // Status = int.MinValue, // AccountCode = userInfo.AccountCode, // WarehouseCode = warehouse // }; // if (IsQueryHistory) // { // Request.StartDate = startTime.ToString("yyyy-MM-dd HH:mm:ss"); // Request.EndDate = endTime.ToString("yyyy-MM-dd HH:mm:ss"); // } // var result = proxy.QueryDeclareStorage(Request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // foreach (var item in result.Rsps) // { // Rlt.Add(new StorageManagementModel() // { // GoodsName = item.GoodsName, // ReviewSate = (ReviewSate)item.AuditStatus, // StorageNumber = item.DeclareWeight, // WarehouseName = item.WarehouseName, // IntendedDateWarehousing = DateTime.Parse(item.DeclareDate), // ReservationNumber = item.StorageNo, // SerialNumber = index++, // DeclarationTime = DateTime.Parse(item.ApplyDate), // InStorageType = item.EntryType, // InStorageTypeName = item.EntryType == 0 ? "普通入库" : "发售入库"//入库类型中文名(0:普通入库,1:发售入库) // }); // } // return Rlt; // } // /// // /// 入库预约 操作 // /// // /// StorageManagementModel // /// 操作类型:更改(Update)、插入(Insert)、删除(Delete) // /// 是否成功 // public int OperationStorageManagement(Storage item, DeliveryData.Enums.OperationType op) // { // var RltCode = int.MinValue; // var userInfo = GetAccountEntry(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var adapter = new DeliveryResponseAdapter(); // switch (op) // { // case OperationType.Insert: // var result = proxy.BeginStorageEntryOrder(new StorageEntryOrderRequest() // { // AccountCode = userInfo.AccountCode, // DeclareWeight = item.StorageVolume, // GoodsCode = item.GoodsCode, // WarehouseCode = item.WarehouseCode, // WarehouseName = item.WarehouseName, // Guid = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0), // DeclareDate = item.StorageDate.ToString("yyyy-MM-dd HH:mm:ss"), // EntryType = item.InStorageTypeM // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // RltCode = result.ReturnCode; // break; // case OperationType.Update: // break; // case OperationType.Delete: // break; // } // return RltCode; // } // /// // /// 获取 仓单 // /// // /// 品种代码 // /// 仓单类型 // /// // public ObservableCollection getWarehouseReceiptManagement(string goodsCode, int WarehouseType) // { // var Rlt = new ObservableCollection(); // // var goodses = GetAllDeiveryGoodses(); // var userInfo = GetAccountEntry(); // var adapter = new DeliveryResponseAdapter(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // // goodsCode = goodsCode == int.MinValue.ToString() ? "" : goodsCode; // var RequestObj = new QueryGoodsBillRequest(); // RequestObj.AccountCode = userInfo.AccountCode; // RequestObj.GoodsCode = goodsCode; // RequestObj.GoodsBillType = WarehouseType; // var result = proxy.QueryGoodsBill(RequestObj); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // Rlt = new DeliveryResponseAdapter().ConvertQueryGoodsBillRequest(result); // return Rlt; // } // /// // /// 仓单转让 操作 // /// // /// WarehouseReceiptTransfereeModel // /// 操作类型:更改(Update)、插入(Insert)、删除(Delete) // /// 是否成功 // public int OperationWarehouseTransfer(WarehouseReceiptTransfereeModel item, OperationType op) // { // var RltCode = int.MinValue; // var userInfo = GetAccountEntry(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // // var AllWarehouse = getWarehouseReceiptManagement("", 1); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var adapter = new DeliveryResponseAdapter(); // //{"storagecode":"-1","warehousecode":"7"} // string JSON = "{\"storagecode\":\"-1\","; // JSON += "\"warehousecode\":\"" + item.WareHouseCode + "\"}"; // switch (op) // { // case OperationType.Insert: // // var storageCode = item.WarehouseType == 0 ? "-1" : item.StoreCode; // var result = proxy.BeginStorageAttorn(new StorageAttornRequest() // { // AccountCode = userInfo.AccountCode, // Guid = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0), // ApplyDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // AttornPrice = (decimal)item.TransferPrice, // GoodsCode = item.GoodsCode, // InAccountCode = item.TradersAccountTransfer, // AttornWeight = item.TransferNumber, // //利用已有的字段进行传仓库代码 StorageCode // StorageCode = JSON, // OutAccountCode = userInfo.AccountCode, // // 此处加仓库代码 // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // //if (result == null) return ExceptionManager.UnknownServiceErrorCode; // //var ErrorCode = result.ReturnCode != 0 ? result.ReturnCode : result.ReturnCode; // //if (result.ReturnCode != 0) throw new MuchinfoException(result.ReturnCode); // //if (result.ReturnCode != 0) throw new MuchinfoException(result.ReturnCode); // RltCode = result.ReturnCode; // break; // case OperationType.Update: // break; // case OperationType.Delete: // break; // } // return RltCode; // } // /// // /// 获取 仓单受让 // /// // /// // public ObservableCollection getWarehouseTransferee() // { // var Rlt = new ObservableCollection(); // var userInfo = GetAccountEntry(); // var goodses = GetAllDeiveryGoodses(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var result = proxy.QueryStorageAttorn(new QueryStorageAttornRequest() // { // AccountCode = userInfo.AccountCode, // Result = Delivery2_Result.All, // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // Rlt = new DeliveryResponseAdapter().ConvertQueryStorageAttornRequest( // result.Rsps.Where(x => x.InAccountCode == userInfo.AccountCode).ToList(), goodses); // return Rlt; // } // /// // /// 仓单流转 查询 // /// // /// // public ObservableCollection getWarehouseReceiptTransferee(DateTime startTime, DateTime endTime, TradeDirection td, bool IsQueryHistory) // { // var Rlt = new ObservableCollection(); // var goodses = GetAllDeiveryGoodses(); // var userInfo = GetAccountEntry(); // var index = 0; // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // //TODO:注册 // if (td == TradeDirection.All || td == TradeDirection.Register) // { // var Request = new QueryGoodsBillRegisterRequest() // { // AccountCode = userInfo.AccountCode, // }; // if (IsQueryHistory) // { // Request.StartDate = startTime.ToString("yyyy-MM-dd HH:mm:ss"); // Request.EndDate = endTime.ToString("yyyy-MM-dd HH:mm:ss"); // } // var result = proxy.QueryGoodsBillRegister(Request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // foreach (var item in result.Rsps) // { // var model = new WarehouseReceiptTransferModel() // { // SerialNumber = index++, // Time = DateTime.Parse(item.DeclareDate), // Number = (decimal)item.RegisterWeight, // GoodsCode = item.GoodsCode, // // State =item.Status, // }; // if (goodses != null) // { // var firstGoods = goodses.FirstOrDefault((good) => item.GoodsCode == good.GoodsCode); // model.GoodsName = firstGoods == null ? string.Empty : firstGoods.GoodsName; // } // Rlt.Add(model); // } // } // //TODO:转让 // if (td == TradeDirection.All || td == TradeDirection.Assignment) // { // var Request = new QueryStorageAttornRequest() // { // AccountCode = userInfo.AccountCode, // }; // if (IsQueryHistory) // { // Request.BeginTime = startTime.ToString("yyyy-MM-dd HH:mm:ss"); // Request.EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss"); // } // var result = proxy.QueryStorageAttorn(Request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // var receipts = result.Rsps.Where((atton) => atton.OutAccountCode == userInfo.AccountCode); //选择转让的 // foreach (var item in receipts) // { // var model = new WarehouseReceiptTransferModel() // { // SerialNumber = index++, // Time = DateTime.Parse(item.DeclareDate), // Number = (decimal)item.AttornWeight, // GoodsCode = item.GoodsCode, // // State =item.Status, // OtherTradersAccount = item.InAccountCode, // OtherTradersName = item.InCustomerName, // }; // if (goodses != null) // { // var firstGoods = goodses.FirstOrDefault((good) => item.GoodsCode == good.GoodsCode); // model.GoodsName = firstGoods == null ? string.Empty : firstGoods.GoodsName; // } // Rlt.Add(model); // } // } // //TODO:受让 // if (td == TradeDirection.All || td == TradeDirection.Transferee) // { // var Request = new QueryStorageAttornRequest() // { // AccountCode = userInfo.AccountCode, // }; // if (IsQueryHistory) // { // Request.BeginTime = startTime.ToString("yyyy-MM-dd HH:mm:ss"); // Request.EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss"); // } // var result = proxy.QueryStorageAttorn(Request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // var receipts = result.Rsps.Where((atton) => atton.InAccountCode.Equals(userInfo.AccountCode)); //选择转让的 // foreach (var item in receipts) // { // var model = new WarehouseReceiptTransferModel() // { // SerialNumber = index++, // Time = DateTime.Parse(item.DeclareDate), // Number = (decimal)item.AttornWeight, // GoodsCode = item.GoodsCode, // // State =item.Status, // OtherTradersAccount = item.InAccountCode, // OtherTradersName = item.InCustomerName, // }; // if (goodses != null) // { // var firstGoods = goodses.FirstOrDefault((good) => item.GoodsCode == good.GoodsCode); // model.GoodsName = firstGoods == null ? string.Empty : firstGoods.GoodsName; // } // Rlt.Add(model); // } // } // //TODO:注销 // if (td == TradeDirection.All || td == TradeDirection.Cancellation) // { // var Request = new QueryStorageWithdrawRequest() // { // AccountCode = userInfo.AccountCode, // }; // if (IsQueryHistory) // { // Request.StartDate = startTime.ToString("yyyy-MM-dd HH:mm:ss"); // Request.EndDate = endTime.ToString("yyyy-MM-dd HH:mm:ss"); // } // var result = proxy.QueryStorageWithdraw(Request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // foreach (var item in result.Rsps) // { // var model = new WarehouseReceiptTransferModel() // { // SerialNumber = index++, // Time = DateTime.Parse(item.ApplyDate), // // Number = (decimal)item., // // GoodsCode = item.GoodsCode, // // State =item.Status, // }; // if (goodses != null) // { // // var firstGoods = goodses.FirstOrDefault((good) => item.GoodsCode == good.GoodsCode); // // model.GoodsName = firstGoods == null ? string.Empty : firstGoods.GoodsName; // } // Rlt.Add(model); // } // } // return Rlt; // } // /// // /// 获取 中间仓 // /// // /// 开始时间 // /// 结束时间 // /// 方向 // /// // public ObservableCollection getIntermediateBinQuery(DateTime startTime, DateTime endTime, TradeDirection tradeDirection, bool IsQueryHistory) // { // var Rlt = new ObservableCollection(); // //var userInfo = GetAccountEntry(); // //var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // //if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // //var Request = new QueryGoodsBillRequest() // //{ // // AccountCode = userInfo.AccountCode, // //}; // //if (IsQueryHistory) // //{ // // Request.StartDate = startTime.ToString("yyyy-MM-dd HH:mm:ss"); // // Request.EndDate = endTime.ToString("yyyy-MM-dd HH:mm:ss"); // //} // ////var result = proxy.DeliveryApplyOrder(Request); // //if (result == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // //if (result.ReturnCode != 0) throw new MuchinfoException(result.ReturnCode); // //Rlt = new DeliveryResponseAdapter().ConvertIntermediateBinRequest(result); // return Rlt; // } // /// // /// 中间仓 操作 // /// // /// IntermediateBinQueryModel // /// 操作类型:更改(Update)、插入(Insert)、删除(Delete) // /// 是否成功 // public int OperationIntermediateBinQuery(IntermediateBinQueryModel item, OperationType op) // { // var RltCode = int.MinValue; // var userInfo = GetAccountEntry(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var adapter = new DeliveryResponseAdapter(); // switch (op) // { // case OperationType.Insert: // var result = proxy.EntrustOrder(new EntrustOrderRequest() // { // TradeCode = userInfo.AccountCode, // AccountType = (AccountType)((int)userInfo.AccountType), // GoodsCode = item.GoodsCode, // OperatorCode = userInfo.AccountCode, // OrderType = OrderTypeEnum.Delivery2, // BuyOrSell = (BuyOrSellType)item.DeclarationDirection, // EntrustQuantity = item.DeclarationNumber, // DeliveryOrderEntrust = new DeliveryOrderEntrust() // { // AccountCode = userInfo.AccountCode, // DeliveryType = Delivery2_OrderType.Delivery_ABMiddle, // DeliveryOrderType = DeliveryOrderType.DeliveryOrderType_Cancel, // //DeliveryOrderType = DeliveryOrderMode.DeliveryOrder_Hedge, // }, // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // RltCode = result.ReturnCode; // break; // case OperationType.Update: // break; // case OperationType.Delete: // break; // } // return RltCode; // } // /// // /// 仓单受让 操作 // /// // /// // /// // /// // /// // public int OperationStorageAttornPermit(long BusinessNo, int Result, OperationType op = OperationType.Update) // { // var RltCode = int.MinValue; // var userInfo = GetAccountEntry(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) return ExceptionManager.UnknownServiceErrorCode; // var adapter = new DeliveryResponseAdapter(); // switch (op) // { // case OperationType.Update: // var rqt = new StorageAttornPermitRequest() // { // AuditCode = userInfo.AccountCode, // Guid = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0), // ConfirmDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // AuditReqs = new ArrayStorageAttornPermitRequest[1], // }; // rqt.AuditReqs[0] = new ArrayStorageAttornPermitRequest() // { // BusinessNo = BusinessNo, // Result = Result, // }; // var result = proxy.StorageAttornPermit(rqt); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0 && result.ReturnCode != int.MinValue) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // RltCode = 0; // break; // case OperationType.Delete: // break; // } // return RltCode; // } // /// // /// 获取账户信息 // /// // /// // /// // public List getAccountInfo(string AccountCode) // { // var Rlt = new List(); // var userInfo = GetAccountEntry(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var Request = new QueryAccountInfoRequest() // { // AccountCode = userInfo.AccountCode, // // MemberCode = AccountCode, // }; // var result = proxy.QueryAccountInfo(Request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // Rlt = new DeliveryResponseAdapter().ConvertQueryAccountInfoResponse(result); // return Rlt; // } // /// // /// 仓单流转明细 查询 // /// // /// // /// // /// // /// // public ObservableCollection getWarehouseReceiptTransfereeDetail(DateTime startTime, DateTime endTime, Delivery2_Remark_TD td, bool IsQueryHistory) // { // var Rlt = new ObservableCollection(); // //var goodses = GetAllDeiveryGoodses(); // var userInfo = GetAccountEntry(); // var index = 1; // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var remark = (int)td; // var isSpecialRemark = remark < 0 && remark != int.MinValue; // var symbol = isSpecialRemark ? -1 : 1; // var Absremark = remark * symbol; // var Request = new QueryStorageLogRequest() // { // AccountCode = userInfo.AccountCode, // Remark = Absremark, // }; // if (IsQueryHistory) // { // Request.StartDate = startTime.ToString("yyyy-MM-dd HH:mm:ss"); // Request.EndDate = endTime.ToString("yyyy-MM-dd HH:mm:ss"); // } // var result = proxy.QueryStorageLog(Request); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // foreach (var item in result.Rsps) // { // if (td != Delivery2_Remark_TD.All) //(remark != int.MinValue) // { // item.Remark = remark; //没选择全部时,使用原来选择的类型。 // if (isSpecialRemark && item.ChangeQty >= 0) // { // continue; // } // else if ((!isSpecialRemark) && item.ChangeQty < 0) // { // continue; // } // } // else // { // switch ((Delivery2_Remark_TD)item.Remark) //客户端分转让、受让、卖交收与买交收。 // { // case Delivery2_Remark_TD.Delivery2_Transfer: // case Delivery2_Remark_TD.Delivery2_Delivery_Bid: // item.Remark = item.Remark * (item.ChangeQty > 0 ? 1 : -1); // break; // } // } // var model = new WarehouseReceiptTransferModel() // { // SerialNumber = index++, // Time = DateTime.Parse(item.HandleTime), // Number = (decimal)item.ChangeQty, // GoodsCode = item.GoodsCode, // Delivery2_Remark = (Delivery2_Remark_TD)item.Remark, // WarehouseType = (GoodsBillType)item.StorageType, // GoodsName = item.GoodsName, // WarehouseName=item.WarehouseName, // }; // if (model.Number < 0) // { // model.Number = Math.Abs((decimal)item.ChangeQty); // } // //if (goodses != null) // //{ // // var firstGoods = goodses.FirstOrDefault((good) => item.GoodsCode == good.GoodsCode); // // model.GoodsName = firstGoods == null ? string.Empty : firstGoods.GoodsName; // //} // Rlt.Add(model); // } // return Rlt; // } // /// // /// 获取 转让查询 // /// // /// // public ObservableCollection getWarehouseTransQuery() // { // var Rlt = new ObservableCollection(); // var goodses = GetAllDeiveryGoodses(); // var userInfo = GetAccountEntry(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // var index = 1; // var result = proxy.QueryStorageAttorn(new QueryStorageAttornRequest() // { // AccountCode = userInfo.AccountCode, // Result = Delivery2_Result.All, // }); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // foreach (var item in result.Rsps.Where(x => x.OutAccountCode == userInfo.AccountCode)) // { // var wrtm = new WarehouseReceiptTransfereeModel() // { // SerialNumber = index++, // GoodsCode = item.GoodsCode, // TransferLoan = item.AttornPayment, // TransferNumber = item.AttornWeight, // TransferPrice = item.AttornPrice, // bssid = item.BusinessNo, // TransferDate = DateTime.Parse(item.DeclareDate), // OtherTradersAccount = item.InAccountCode, // OtherTradersName = item.InCustomerName, // AuditStatus = (AuditStatus)item.ConfirmStatus, // GoodsClassName = item.GoodsClassName, // WareHouseName = item.WarehouseName, // // WareHouseName = "",//仓库名称 // }; // if (goodses != null) // { // var firstGoods = goodses.FirstOrDefault((good) => item.GoodsCode == good.GoodsCode); // wrtm.GoodsName = firstGoods == null ? string.Empty : firstGoods.GoodsName; // } // Rlt.Add(wrtm); // } // return Rlt; // } // /// // /// 更具商品代码获取对应的商品品种 add by justin.huang 2015-10-15 // /// // /// 商品代码 // /// 品种代码 // /// 查询类型,false:只查询信息,不查图片,true:查全部包括图片 // /// // public ObservableCollection getDeliveryGoodsClass(string GoodCode, string GoodsClassCode, bool QueryType) // { // var Rlt = new ObservableCollection(); // var userInfo = GetAccountEntry(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // QueryDeliveryVarietyRequest queryReq = new QueryDeliveryVarietyRequest(); // if (QueryType) // { // //查包含图片 // queryReq.QueryType = 1; // } // if (!string.IsNullOrEmpty(GoodCode)) // { // queryReq.GoodsCode = GoodCode; // } // if (!string.IsNullOrEmpty(GoodsClassCode)) // { // queryReq.GoodsClassCode = GoodsClassCode; // } // var result = proxy.QueryDeliveryVariety(queryReq); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // foreach (var item in result.Rsps) // { // DeliveryGoodsClass it = new DeliveryGoodsClass() { GoodsClassCode = item.GoodsClassCode, GoodsClassName = item.GoodsClassName, GoodsClassImage = item.Descpic, GoodsCode = item.GoodsCode }; // Rlt.Add(it); // } // return Rlt; // } // /// // /// 交收配对查询 // /// // /// // /// // /// // public List QueryDeliveryMatch(string startTime, string endTime) // { // var userInfo = GetAccountEntry(); // var proxy = LinkerHelper.GetBizServiceProxy(userInfo.AccountName); // if (proxy == null) throw new MuchinfoException(ExceptionManager.UnknownServiceErrorCode); // QueryDeliveryMatchRequest queryReq = new QueryDeliveryMatchRequest // { // AccountCode = userInfo.AccountCode, // //BeginTime = startTime, // //BeginTimeFlag=5, // //EndTime = endTime, // //EndTimeFlag=7, // SellAccountCode = userInfo.AccountCode, // BuyAccountCode = userInfo.AccountCode, // }; // var result = proxy.QueryDeliveryMatch(queryReq); // if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // if (result.ReturnCode != 0) // { // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(DeliveryManageService)); // } // var Rlt = new DeliveryResponseAdapter().ConvertDeliveryMatchRequest(result); // return Rlt; // } // } //}