| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491 |
- using Muchinfo.MTPClient.Adapter.Abstract;
- using Muchinfo.MTPClient.Adapter.Utilities;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model.Delivery;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using tas;
- namespace Muchinfo.MTPClient.Adapter.ProtoBuf
- {
- public class DeliveryProtoBufAdapter : DeliveryAdapter
- {
- //private OrderHead ToOrderHead(DeliveryOrderReqModel deliveryOrder)
- //{
- // return new OrderHead()
- // {
-
- // };
- //}
- /// <summary>
- /// 交割申报-请求转换
- /// </summary>
- /// <param name="deliveryOrder"></param>
- /// <returns></returns>
- public override byte[] ToDeliveryApplyReqOrder(DeliveryOrderReqModel deliveryOrder)
- {
- return null;
- var marketOrder = new DeliveryOrderReq()
- {
- AccountID=deliveryOrder.AccountID,
- ClientOrderTime = deliveryOrder.EntrustTime.ToString("yyyy-MM-dd HH:mm:ss"),
- ClientSerialNo = Guid.NewGuid().ToString(),
- ClientType = (uint)eClientType.CLIENTTYPE_PC_TRADE_CLIENT,
- DeliveryQty=deliveryOrder.DeliveryQty,
- DeliveryGoodsID=deliveryOrder.DeliveryGoodsID,
- OperateType = (uint)eOrderOperateType.ORDEROPERATETYPE_NORMAL,
- OperatorID=deliveryOrder.OperatorID,
- OrderSrc = (uint)eOrderSrc.ORDERSRC_CLIENT,
- P2GoodsID=deliveryOrder.P2GoodsID,
- P2Qty=deliveryOrder.P2Qty,
- PGoodsID=deliveryOrder.PGoodsID,
- PQty=deliveryOrder.PQty,
- XGoodsID=deliveryOrder.XGoodsID,
- XQty=deliveryOrder.XQty,
- };
- if (deliveryOrder.wrDetail != null)
- {
- var model = new DeliveryOrderDetail()
- {
- AccountID=deliveryOrder.wrDetail.AccountID,
- BrandID=deliveryOrder.wrDetail.BrandID,
- DeliveryMonthID=deliveryOrder.wrDetail.DeliveryMonthID,
- Qty=deliveryOrder.wrDetail.Qty,
- QualityID=deliveryOrder.wrDetail.QualityID,
- StandardID=deliveryOrder.wrDetail.StandardID,
- WarehouseID=deliveryOrder.wrDetail.WarehouseID
- };
- marketOrder.DeliveryOrderDetail = model;
- }
- marketOrder.Header = new MessageHead() { UUID = Guid.NewGuid().ToString() };
- return ProtoBufHelper.EntitySerialize(marketOrder, false);
- }
- /// <summary>
- /// 交割申报-应答转换
- /// </summary>
- /// <param name="responeData"></param>
- /// <returns></returns>
- public override ResponeEntity<DeliveryOrderRspModel> ToDeliveryApplyRspOrder(object responeData)
- {
- var buffer = responeData as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- var deliveryOrderRsp = ProtoBufHelper.EntityDeSerialize<DeliveryOrderRsp>(buffer);
- return new ResponeEntity<DeliveryOrderRspModel>()
- {
- RetCode = deliveryOrderRsp.RetCode,
- RetMessage = deliveryOrderRsp.RetDesc,
- Entity = new DeliveryOrderRspModel()
- {
- ClientSerialNo=deliveryOrderRsp.ClientSerialNo,
- OrderTime=deliveryOrderRsp.OrderTime,
- wrDetails=ToLocalWRDetails(deliveryOrderRsp.DeliveryOrderDetails)
- }
- };
- }
- private List<WrDetailModel> ToLocalWRDetails(List<DeliveryOrderDetail> tasDetails)
- {
- List<WrDetailModel> wrdetails = new List<WrDetailModel>();
- if (tasDetails != null)
- {
- foreach (var tasItem in tasDetails)
- {
- var wrdetail = new WrDetailModel()
- {
- AccountID = tasItem.AccountID,
- BrandID = tasItem.BrandID,
- DeliveryMonthID = tasItem.DeliveryMonthID,
- Qty = tasItem.Qty,
- QualityID = tasItem.QualityID,
- StandardID = tasItem.StandardID,
- WarehouseID = tasItem.WarehouseID,
- };
- wrdetails.Add(wrdetail);
- }
- }
- return wrdetails;
- }
- /// <summary>
- /// 提交-仓单配对-请求转换
- /// </summary>
- /// <param name="deliveryMatchOrder"></param>
- /// <returns></returns>
- public override byte[] ToDeliveryMatchReqOrder(DeliveryOrderMatchReqModel itemReq)
- {
- return null;
- //var marketOrder = new DeliveryOrderMatchReq()
- //{
- // OrderId = itemReq.OrderId,///交割委托单号
- // MatchType = (int)itemReq.MatchType,///配对类型
- // OperatorID=itemReq.OperatorID,///操作员账号ID
- //};
- //foreach (var item in itemReq.matchDetails)///配对明细-实体转换
- //{
- // var model = new OrderMatchDetail()
- // {
- // WRId = (long)item.WRId,
- // DeliveryQty = (double)item.DeliveryQty,
- // DeliverySellOrderId =item.DeliverySellOrderId
- // };
- // marketOrder.matchDetails.Add(model);
- //}
- //marketOrder.Header = new MessageHead() { AccountID = itemReq.AccountId, GoodsID = itemReq.GoodsId, UUID = Guid.NewGuid().ToString() };
- //return ProtoBufHelper.EntitySerialize(marketOrder, false);
- }
- /// <summary>
- /// 提交-仓单配对-应答转换
- /// </summary>
- /// <param name="responeData"></param>
- /// <returns></returns>
- public override ResponeEntity<DeliveryOrderMatchRspModel> ToDeliveryMatchRspOrder(object responeData)
- {
- return null;
- //var buffer = responeData as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var itemRsp = ProtoBufHelper.EntityDeSerialize<DeliveryOrderMatchRsp>(buffer);
- //return new ResponeEntity<DeliveryOrderMatchRspModel>()
- //{
- // RetCode = itemRsp.RetCode,
- // RetMessage = itemRsp.RetDesc,
- // Entity = new DeliveryOrderMatchRspModel()
- // {
- // OrderId = itemRsp.OrderId,
- // ////todo:生成委托
- // }
- //};
- }
- /// <summary>
- /// 提交-提货申请-请求转换
- /// </summary>
- /// <param name="deliveryMatchOrder"></param>
- /// <returns></returns>
- public override byte[] ToOutStoreReq(OutStoreReqModel itemReq)
- {
- return null;
- //var outStoreOrder = new OutStoreReq()
- //{
- // //AccountID = itemReq.AccountID,
- // //OperatorID = itemReq.OperatorID,
- // OperateType=itemReq.OperateType,
- // StoreOutId=itemReq.StoreOutId,
- // PhoneNum=itemReq.PhoneNum,
- // RecieveAddress=itemReq.RecieveAddress,
- // RecievePerson=itemReq.RecievePerson,
- // CardNum = itemReq.IdCardNum,
- // TakeType =(int) itemReq.TakeGoodsWay,
-
- //};
- //if (itemReq.OutStoreDetail!=null)
- //{
- // foreach (var item in itemReq.OutStoreDetail)///提货明细-实体转换
- // {
- // var model = new OutStoreReqDetail()
- // {
- // WRId = item.WRId,
- // StoreOutQty = (double)item.StoreOutQty,
- // };
- // outStoreOrder.Details.Add(model);
- // }
- //}
-
- //outStoreOrder.Header = new MessageHead() { AccountID = itemReq.AccountId, GoodsID = itemReq.GoodsId, UUID = Guid.NewGuid().ToString() };
- //return ProtoBufHelper.EntitySerialize(outStoreOrder, false);
- }
- /// <summary>
- /// 提交-提货申请-应答转换
- /// </summary>
- /// <param name="responeData"></param>
- /// <returns></returns>
- public override ResponeEntity<OutStoreRspModel> ToOutStoreRsp(object responeData)
- {
- return null;
- //var buffer = responeData as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var itemRsp = ProtoBufHelper.EntityDeSerialize<OutStoreRsp>(buffer);
- //return new ResponeEntity<OutStoreRspModel>()
- //{
- // RetCode = itemRsp.RetCode,
- // RetMessage = itemRsp.RetDesc,
- // Entity = new OutStoreRspModel()
- // {
- // AccountID = itemRsp.AccountID,
- // OperatorID=itemRsp.OperatorID
- // ////todo:生成委托
- // }
- //};
- }
- /// <summary>
- /// 交收现货付款-请求转换
- /// </summary>
- /// <param name="deliveryMatchOrder"></param>
- /// <returns></returns>
- public override byte[] ToReceiveConfirmReq(ReceiveConfirmReqModel itemReq)
- {
- return null;
- //var req = new ReceiveConfirmReq()
- //{
- // DeliveryId = itemReq.DeliveryId,
- // OperatorID = (long)itemReq.OperatorID,
- // ConfirmType=itemReq.ConfirmType,
- // PlanDetailId = itemReq.PlanDetailID,
- //};
- //req.Header = new MessageHead() { AccountID = itemReq.AccountId, GoodsID = itemReq.GoodsId, UUID = Guid.NewGuid().ToString() };
- //return ProtoBufHelper.EntitySerialize(req, false);
- }
- /// <summary>
- /// 交收现货付款-应答转换
- /// </summary>
- /// <param name="responeData"></param>
- /// <returns></returns>
- public override ResponeEntity<ReceiveConfirmRspModel> ToReceiveConfirmRsp(object responeData)
- {
- return null;
- //var buffer = responeData as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var itemRsp = ProtoBufHelper.EntityDeSerialize<ReceiveConfirmRsp>(buffer);
- //return new ResponeEntity<ReceiveConfirmRspModel>()
- //{
- // RetCode = itemRsp.RetCode,
- // RetMessage = itemRsp.RetDesc,
- // Entity = new ReceiveConfirmRspModel()
- // {
- // DeliveryId = itemRsp.DeliveryId,
-
- // ////todo:生成委托
- // }
- //};
- }
- /// <summary>
- /// 查询配对仓单-请求转换
- /// </summary>
- /// <param name="deliveryMatchOrder"></param>
- /// <returns></returns>
- public override byte[] ToWrPairReq(WrPairReqModel itemReq)
- {
- return null;
- //var req = new WrPairReq()
- //{
- // OperatorId=itemReq.OperatorId,
- // TradeGoodsId=itemReq.TradeGoodsId,
- //};
- //req.Header = new MessageHead() { AccountID = itemReq.AccountId, GoodsID = (uint)itemReq.TradeGoodsId, UUID = Guid.NewGuid().ToString() };
- //return ProtoBufHelper.EntitySerialize(req, false);
- }
- /// <summary>
- /// 交割提货个人信息查询请求-请求转换
- /// </summary>
- /// <param name="deliveryMatchOrder"></param>
- /// <returns></returns>
- public override byte[] ToDepositPersonalInfoReq(DepositPersonalInfoReqModel reqModel)
- {
- return null;
- //var req = new DepositPersonalInfoReq()
- //{
- // accountId = reqModel.accountId,
- //};
- //req.Header = new MessageHead() { AccountID = (uint)reqModel.accountId, UUID = Guid.NewGuid().ToString() };
- //return ProtoBufHelper.EntitySerialize(req, false);
- }
- /// <summary>
- /// 查询配对仓单-应答转换
- /// </summary>
- /// <param name="responeData"></param>
- /// <returns></returns>
- public override ResponeEntity<WrPairRspModel> ToWrPairRsp(object responeData)
- {
- return null;
- //var buffer = responeData as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var itemRsp = ProtoBufHelper.EntityDeSerialize<WrPairRsp>(buffer);
- //var wrPairDetails = new List<WrPairDetailModel>();
- //foreach (var item in itemRsp.WrPairDetails)///查询配对明细-实体转换
- //{
- // var model = new WrPairDetailModel()
- // {
- // WrId = item.WrId,
- // WrCode=item.WrCode,
- // Brand=item.Brand,
- // Rank=item.Rank,
- // DeliveryPriceMove=item.DeliveryPriceMove,
- // GoodsUnitId=item.GoodsUnitId,
- // DeliverySellOrderId =item.DeliverySellOrderId,
- // DeliveryGoodsId=item.DeliveryGoodsId,
- // DeliveryGoodsName=item.DeliveryGoodsName,
- // EnableQty=item.EnableQty,
- // RetCode=item.RetCode,
- // StorePlace=item.StorePlace,
- // ProvinceId =item.ProvinceId,
- // ProvinceName=item.ProvinceName,
- // CityId=item.CityId,
- // CityName=item.CityName
-
- // };
- // wrPairDetails.Add(model);
- //}
- //return new ResponeEntity<WrPairRspModel>()
- //{
- // RetCode = itemRsp.RetCode,
- // RetMessage = itemRsp.RetDesc,
- // Entity = new WrPairRspModel()
- // {
- // TradeGoodsId = itemRsp.TradeGoodsId,
- // WrPairDetails = wrPairDetails,
- // ////todo:生成委托
- // }
- //};
- }
- /// <summary>
- /// 交割提货个人信息查询应答-应答转换
- /// </summary>
- /// <param name="responeData"></param>
- /// <returns></returns>
- public override ResponeEntity<DepositPersonalInfoRspModel> ToDepositPersonalInfoRsp(object responeData)
- {
- return null;
- //var buffer = responeData as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var itemRsp = ProtoBufHelper.EntityDeSerialize<DepositPersonalInfoRsp>(buffer);
- //return new ResponeEntity<DepositPersonalInfoRspModel>()
- //{
- // RetCode = itemRsp.RetCode,
- // RetMessage = itemRsp.RetDesc,
- // Entity = new DepositPersonalInfoRspModel()
- // {
- // accountId = itemRsp.accountId,
- // address = itemRsp.address,
- // personName = itemRsp.personName,
- // telphone = itemRsp.telphone,
- // IdCardNum = itemRsp.cardNum,
- // ////todo:生成委托
- // }
- //};
- }
- public override byte[] ToDeliveryWRReq(uint goodsId, uint deliveryGoodsId, uint tradeProperty)
- {
- var req = new DeliveryWRReq()
- {
- GoodId=goodsId,
- DeliveryGoodsId=deliveryGoodsId,
- TradeProperty=tradeProperty
- };
- return ProtoBufHelper.EntitySerialize(req, true);
- }
- public override ResponeEntity<DeliveryWRRspModel> ToDeliveryWRRsp(object responeData)
- {
- return null;
- //var buffer = responeData as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var itemRsp = ProtoBufHelper.EntityDeSerialize<DeliveryWRRsp>(buffer);
- //var goodsdryPriceLst = new List<GoodsDryPriceModel>();
- //var tradeWRPostionLst = new List<TradeWRPositionModel>();
- //if (itemRsp.GoodsDeliveryPriceList != null)
- //{
- // foreach (var item in itemRsp.GoodsDeliveryPriceList)
- // {
- // var itemPrice = new GoodsDryPriceModel()
- // {
- // PriceMoveID=item.PriceMoveID,
- // PriceMoveDesc=item.PriceMoveDesc,
- // PriceMoveType=item.PriceMoveType,
- // PriceMoveValue=(decimal)item.PriceMoveValue
- // };
- // goodsdryPriceLst.Add(itemPrice);
- // }
- //}
- //if (itemRsp.TradeWRPositionList != null)
- //{
- // foreach (var item in itemRsp.TradeWRPositionList)
- // {
- // var itemPosition = new TradeWRPositionModel()
- // {
- // AccountID=item.AccountID,
- // BrandID=item.BrandID,
- // DeliveryGoodsID=item.DeliveryGoodsID,
- // DeliveryMonthID=item.DeliveryMonthID,
- // QualityID=item.QualityID,
- // RestQty=item.RestQty,
- // SpecID=item.SpecID,
- // WarehouseID=item.WarehouseID,
- // WRPositionID=item.WRPositionID,
- // WRUserID=item.WRUserID,
- // WRUserName=item.WRUserName
- // };
- // tradeWRPostionLst.Add(itemPosition);
- // }
- //}
- //return new ResponeEntity<DeliveryWRRspModel>()
- //{
- // RetCode = itemRsp.RetCode,
- // RetMessage = itemRsp.RetDesc,
- // Entity = new DeliveryWRRspModel()
- // {
- // GoodsDeliveryPriceList=goodsdryPriceLst,
- // TradeWRPositionList=tradeWRPostionLst,
- // }
- //};
- }
- }
- }
|