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()
// {
// };
//}
///
/// 交割申报-请求转换
///
///
///
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);
}
///
/// 交割申报-应答转换
///
///
///
public override ResponeEntity ToDeliveryApplyRspOrder(object responeData)
{
var buffer = responeData as byte[];
if (buffer == null)
{
throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
}
var deliveryOrderRsp = ProtoBufHelper.EntityDeSerialize(buffer);
return new ResponeEntity()
{
RetCode = deliveryOrderRsp.RetCode,
RetMessage = deliveryOrderRsp.RetDesc,
Entity = new DeliveryOrderRspModel()
{
ClientSerialNo=deliveryOrderRsp.ClientSerialNo,
OrderTime=deliveryOrderRsp.OrderTime,
wrDetails=ToLocalWRDetails(deliveryOrderRsp.DeliveryOrderDetails)
}
};
}
private List ToLocalWRDetails(List tasDetails)
{
List wrdetails = new List();
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;
}
///
/// 提交-仓单配对-请求转换
///
///
///
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);
}
///
/// 提交-仓单配对-应答转换
///
///
///
public override ResponeEntity 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(buffer);
//return new ResponeEntity()
//{
// RetCode = itemRsp.RetCode,
// RetMessage = itemRsp.RetDesc,
// Entity = new DeliveryOrderMatchRspModel()
// {
// OrderId = itemRsp.OrderId,
// ////todo:生成委托
// }
//};
}
///
/// 提交-提货申请-请求转换
///
///
///
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);
}
///
/// 提交-提货申请-应答转换
///
///
///
public override ResponeEntity 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(buffer);
//return new ResponeEntity()
//{
// RetCode = itemRsp.RetCode,
// RetMessage = itemRsp.RetDesc,
// Entity = new OutStoreRspModel()
// {
// AccountID = itemRsp.AccountID,
// OperatorID=itemRsp.OperatorID
// ////todo:生成委托
// }
//};
}
///
/// 交收现货付款-请求转换
///
///
///
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);
}
///
/// 交收现货付款-应答转换
///
///
///
public override ResponeEntity 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(buffer);
//return new ResponeEntity()
//{
// RetCode = itemRsp.RetCode,
// RetMessage = itemRsp.RetDesc,
// Entity = new ReceiveConfirmRspModel()
// {
// DeliveryId = itemRsp.DeliveryId,
// ////todo:生成委托
// }
//};
}
///
/// 查询配对仓单-请求转换
///
///
///
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);
}
///
/// 交割提货个人信息查询请求-请求转换
///
///
///
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);
}
///
/// 查询配对仓单-应答转换
///
///
///
public override ResponeEntity 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(buffer);
//var wrPairDetails = new List();
//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()
//{
// RetCode = itemRsp.RetCode,
// RetMessage = itemRsp.RetDesc,
// Entity = new WrPairRspModel()
// {
// TradeGoodsId = itemRsp.TradeGoodsId,
// WrPairDetails = wrPairDetails,
// ////todo:生成委托
// }
//};
}
///
/// 交割提货个人信息查询应答-应答转换
///
///
///
public override ResponeEntity 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(buffer);
//return new ResponeEntity()
//{
// 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 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(buffer);
//var goodsdryPriceLst = new List();
//var tradeWRPostionLst = new List();
//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()
//{
// RetCode = itemRsp.RetCode,
// RetMessage = itemRsp.RetDesc,
// Entity = new DeliveryWRRspModel()
// {
// GoodsDeliveryPriceList=goodsdryPriceLst,
// TradeWRPositionList=tradeWRPostionLst,
// }
//};
}
}
}