DeliveryProtoBufAdapter.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. using Muchinfo.MTPClient.Adapter.Abstract;
  2. using Muchinfo.MTPClient.Adapter.Utilities;
  3. using Muchinfo.MTPClient.Data;
  4. using Muchinfo.MTPClient.Data.Enums;
  5. using Muchinfo.MTPClient.Data.Model.Delivery;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using tas;
  11. namespace Muchinfo.MTPClient.Adapter.ProtoBuf
  12. {
  13. public class DeliveryProtoBufAdapter : DeliveryAdapter
  14. {
  15. //private OrderHead ToOrderHead(DeliveryOrderReqModel deliveryOrder)
  16. //{
  17. // return new OrderHead()
  18. // {
  19. // };
  20. //}
  21. /// <summary>
  22. /// 交割申报-请求转换
  23. /// </summary>
  24. /// <param name="deliveryOrder"></param>
  25. /// <returns></returns>
  26. public override byte[] ToDeliveryApplyReqOrder(DeliveryOrderReqModel deliveryOrder)
  27. {
  28. return null;
  29. var marketOrder = new DeliveryOrderReq()
  30. {
  31. AccountID=deliveryOrder.AccountID,
  32. ClientOrderTime = deliveryOrder.EntrustTime.ToString("yyyy-MM-dd HH:mm:ss"),
  33. ClientSerialNo = Guid.NewGuid().ToString(),
  34. ClientType = (uint)eClientType.CLIENTTYPE_PC_TRADE_CLIENT,
  35. DeliveryQty=deliveryOrder.DeliveryQty,
  36. DeliveryGoodsID=deliveryOrder.DeliveryGoodsID,
  37. OperateType = (uint)eOrderOperateType.ORDEROPERATETYPE_NORMAL,
  38. OperatorID=deliveryOrder.OperatorID,
  39. OrderSrc = (uint)eOrderSrc.ORDERSRC_CLIENT,
  40. P2GoodsID=deliveryOrder.P2GoodsID,
  41. P2Qty=deliveryOrder.P2Qty,
  42. PGoodsID=deliveryOrder.PGoodsID,
  43. PQty=deliveryOrder.PQty,
  44. XGoodsID=deliveryOrder.XGoodsID,
  45. XQty=deliveryOrder.XQty,
  46. };
  47. if (deliveryOrder.wrDetail != null)
  48. {
  49. var model = new DeliveryOrderDetail()
  50. {
  51. AccountID=deliveryOrder.wrDetail.AccountID,
  52. BrandID=deliveryOrder.wrDetail.BrandID,
  53. DeliveryMonthID=deliveryOrder.wrDetail.DeliveryMonthID,
  54. Qty=deliveryOrder.wrDetail.Qty,
  55. QualityID=deliveryOrder.wrDetail.QualityID,
  56. StandardID=deliveryOrder.wrDetail.StandardID,
  57. WarehouseID=deliveryOrder.wrDetail.WarehouseID
  58. };
  59. marketOrder.DeliveryOrderDetail = model;
  60. }
  61. marketOrder.Header = new MessageHead() { UUID = Guid.NewGuid().ToString() };
  62. return ProtoBufHelper.EntitySerialize(marketOrder, false);
  63. }
  64. /// <summary>
  65. /// 交割申报-应答转换
  66. /// </summary>
  67. /// <param name="responeData"></param>
  68. /// <returns></returns>
  69. public override ResponeEntity<DeliveryOrderRspModel> ToDeliveryApplyRspOrder(object responeData)
  70. {
  71. var buffer = responeData as byte[];
  72. if (buffer == null)
  73. {
  74. throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
  75. }
  76. var deliveryOrderRsp = ProtoBufHelper.EntityDeSerialize<DeliveryOrderRsp>(buffer);
  77. return new ResponeEntity<DeliveryOrderRspModel>()
  78. {
  79. RetCode = deliveryOrderRsp.RetCode,
  80. RetMessage = deliveryOrderRsp.RetDesc,
  81. Entity = new DeliveryOrderRspModel()
  82. {
  83. ClientSerialNo=deliveryOrderRsp.ClientSerialNo,
  84. OrderTime=deliveryOrderRsp.OrderTime,
  85. wrDetails=ToLocalWRDetails(deliveryOrderRsp.DeliveryOrderDetails)
  86. }
  87. };
  88. }
  89. private List<WrDetailModel> ToLocalWRDetails(List<DeliveryOrderDetail> tasDetails)
  90. {
  91. List<WrDetailModel> wrdetails = new List<WrDetailModel>();
  92. if (tasDetails != null)
  93. {
  94. foreach (var tasItem in tasDetails)
  95. {
  96. var wrdetail = new WrDetailModel()
  97. {
  98. AccountID = tasItem.AccountID,
  99. BrandID = tasItem.BrandID,
  100. DeliveryMonthID = tasItem.DeliveryMonthID,
  101. Qty = tasItem.Qty,
  102. QualityID = tasItem.QualityID,
  103. StandardID = tasItem.StandardID,
  104. WarehouseID = tasItem.WarehouseID,
  105. };
  106. wrdetails.Add(wrdetail);
  107. }
  108. }
  109. return wrdetails;
  110. }
  111. /// <summary>
  112. /// 提交-仓单配对-请求转换
  113. /// </summary>
  114. /// <param name="deliveryMatchOrder"></param>
  115. /// <returns></returns>
  116. public override byte[] ToDeliveryMatchReqOrder(DeliveryOrderMatchReqModel itemReq)
  117. {
  118. return null;
  119. //var marketOrder = new DeliveryOrderMatchReq()
  120. //{
  121. // OrderId = itemReq.OrderId,///交割委托单号
  122. // MatchType = (int)itemReq.MatchType,///配对类型
  123. // OperatorID=itemReq.OperatorID,///操作员账号ID
  124. //};
  125. //foreach (var item in itemReq.matchDetails)///配对明细-实体转换
  126. //{
  127. // var model = new OrderMatchDetail()
  128. // {
  129. // WRId = (long)item.WRId,
  130. // DeliveryQty = (double)item.DeliveryQty,
  131. // DeliverySellOrderId =item.DeliverySellOrderId
  132. // };
  133. // marketOrder.matchDetails.Add(model);
  134. //}
  135. //marketOrder.Header = new MessageHead() { AccountID = itemReq.AccountId, GoodsID = itemReq.GoodsId, UUID = Guid.NewGuid().ToString() };
  136. //return ProtoBufHelper.EntitySerialize(marketOrder, false);
  137. }
  138. /// <summary>
  139. /// 提交-仓单配对-应答转换
  140. /// </summary>
  141. /// <param name="responeData"></param>
  142. /// <returns></returns>
  143. public override ResponeEntity<DeliveryOrderMatchRspModel> ToDeliveryMatchRspOrder(object responeData)
  144. {
  145. return null;
  146. //var buffer = responeData as byte[];
  147. //if (buffer == null)
  148. //{
  149. // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
  150. //}
  151. //var itemRsp = ProtoBufHelper.EntityDeSerialize<DeliveryOrderMatchRsp>(buffer);
  152. //return new ResponeEntity<DeliveryOrderMatchRspModel>()
  153. //{
  154. // RetCode = itemRsp.RetCode,
  155. // RetMessage = itemRsp.RetDesc,
  156. // Entity = new DeliveryOrderMatchRspModel()
  157. // {
  158. // OrderId = itemRsp.OrderId,
  159. // ////todo:生成委托
  160. // }
  161. //};
  162. }
  163. /// <summary>
  164. /// 提交-提货申请-请求转换
  165. /// </summary>
  166. /// <param name="deliveryMatchOrder"></param>
  167. /// <returns></returns>
  168. public override byte[] ToOutStoreReq(OutStoreReqModel itemReq)
  169. {
  170. return null;
  171. //var outStoreOrder = new OutStoreReq()
  172. //{
  173. // //AccountID = itemReq.AccountID,
  174. // //OperatorID = itemReq.OperatorID,
  175. // OperateType=itemReq.OperateType,
  176. // StoreOutId=itemReq.StoreOutId,
  177. // PhoneNum=itemReq.PhoneNum,
  178. // RecieveAddress=itemReq.RecieveAddress,
  179. // RecievePerson=itemReq.RecievePerson,
  180. // CardNum = itemReq.IdCardNum,
  181. // TakeType =(int) itemReq.TakeGoodsWay,
  182. //};
  183. //if (itemReq.OutStoreDetail!=null)
  184. //{
  185. // foreach (var item in itemReq.OutStoreDetail)///提货明细-实体转换
  186. // {
  187. // var model = new OutStoreReqDetail()
  188. // {
  189. // WRId = item.WRId,
  190. // StoreOutQty = (double)item.StoreOutQty,
  191. // };
  192. // outStoreOrder.Details.Add(model);
  193. // }
  194. //}
  195. //outStoreOrder.Header = new MessageHead() { AccountID = itemReq.AccountId, GoodsID = itemReq.GoodsId, UUID = Guid.NewGuid().ToString() };
  196. //return ProtoBufHelper.EntitySerialize(outStoreOrder, false);
  197. }
  198. /// <summary>
  199. /// 提交-提货申请-应答转换
  200. /// </summary>
  201. /// <param name="responeData"></param>
  202. /// <returns></returns>
  203. public override ResponeEntity<OutStoreRspModel> ToOutStoreRsp(object responeData)
  204. {
  205. return null;
  206. //var buffer = responeData as byte[];
  207. //if (buffer == null)
  208. //{
  209. // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
  210. //}
  211. //var itemRsp = ProtoBufHelper.EntityDeSerialize<OutStoreRsp>(buffer);
  212. //return new ResponeEntity<OutStoreRspModel>()
  213. //{
  214. // RetCode = itemRsp.RetCode,
  215. // RetMessage = itemRsp.RetDesc,
  216. // Entity = new OutStoreRspModel()
  217. // {
  218. // AccountID = itemRsp.AccountID,
  219. // OperatorID=itemRsp.OperatorID
  220. // ////todo:生成委托
  221. // }
  222. //};
  223. }
  224. /// <summary>
  225. /// 交收现货付款-请求转换
  226. /// </summary>
  227. /// <param name="deliveryMatchOrder"></param>
  228. /// <returns></returns>
  229. public override byte[] ToReceiveConfirmReq(ReceiveConfirmReqModel itemReq)
  230. {
  231. return null;
  232. //var req = new ReceiveConfirmReq()
  233. //{
  234. // DeliveryId = itemReq.DeliveryId,
  235. // OperatorID = (long)itemReq.OperatorID,
  236. // ConfirmType=itemReq.ConfirmType,
  237. // PlanDetailId = itemReq.PlanDetailID,
  238. //};
  239. //req.Header = new MessageHead() { AccountID = itemReq.AccountId, GoodsID = itemReq.GoodsId, UUID = Guid.NewGuid().ToString() };
  240. //return ProtoBufHelper.EntitySerialize(req, false);
  241. }
  242. /// <summary>
  243. /// 交收现货付款-应答转换
  244. /// </summary>
  245. /// <param name="responeData"></param>
  246. /// <returns></returns>
  247. public override ResponeEntity<ReceiveConfirmRspModel> ToReceiveConfirmRsp(object responeData)
  248. {
  249. return null;
  250. //var buffer = responeData as byte[];
  251. //if (buffer == null)
  252. //{
  253. // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
  254. //}
  255. //var itemRsp = ProtoBufHelper.EntityDeSerialize<ReceiveConfirmRsp>(buffer);
  256. //return new ResponeEntity<ReceiveConfirmRspModel>()
  257. //{
  258. // RetCode = itemRsp.RetCode,
  259. // RetMessage = itemRsp.RetDesc,
  260. // Entity = new ReceiveConfirmRspModel()
  261. // {
  262. // DeliveryId = itemRsp.DeliveryId,
  263. // ////todo:生成委托
  264. // }
  265. //};
  266. }
  267. /// <summary>
  268. /// 查询配对仓单-请求转换
  269. /// </summary>
  270. /// <param name="deliveryMatchOrder"></param>
  271. /// <returns></returns>
  272. public override byte[] ToWrPairReq(WrPairReqModel itemReq)
  273. {
  274. return null;
  275. //var req = new WrPairReq()
  276. //{
  277. // OperatorId=itemReq.OperatorId,
  278. // TradeGoodsId=itemReq.TradeGoodsId,
  279. //};
  280. //req.Header = new MessageHead() { AccountID = itemReq.AccountId, GoodsID = (uint)itemReq.TradeGoodsId, UUID = Guid.NewGuid().ToString() };
  281. //return ProtoBufHelper.EntitySerialize(req, false);
  282. }
  283. /// <summary>
  284. /// 交割提货个人信息查询请求-请求转换
  285. /// </summary>
  286. /// <param name="deliveryMatchOrder"></param>
  287. /// <returns></returns>
  288. public override byte[] ToDepositPersonalInfoReq(DepositPersonalInfoReqModel reqModel)
  289. {
  290. return null;
  291. //var req = new DepositPersonalInfoReq()
  292. //{
  293. // accountId = reqModel.accountId,
  294. //};
  295. //req.Header = new MessageHead() { AccountID = (uint)reqModel.accountId, UUID = Guid.NewGuid().ToString() };
  296. //return ProtoBufHelper.EntitySerialize(req, false);
  297. }
  298. /// <summary>
  299. /// 查询配对仓单-应答转换
  300. /// </summary>
  301. /// <param name="responeData"></param>
  302. /// <returns></returns>
  303. public override ResponeEntity<WrPairRspModel> ToWrPairRsp(object responeData)
  304. {
  305. return null;
  306. //var buffer = responeData as byte[];
  307. //if (buffer == null)
  308. //{
  309. // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
  310. //}
  311. //var itemRsp = ProtoBufHelper.EntityDeSerialize<WrPairRsp>(buffer);
  312. //var wrPairDetails = new List<WrPairDetailModel>();
  313. //foreach (var item in itemRsp.WrPairDetails)///查询配对明细-实体转换
  314. //{
  315. // var model = new WrPairDetailModel()
  316. // {
  317. // WrId = item.WrId,
  318. // WrCode=item.WrCode,
  319. // Brand=item.Brand,
  320. // Rank=item.Rank,
  321. // DeliveryPriceMove=item.DeliveryPriceMove,
  322. // GoodsUnitId=item.GoodsUnitId,
  323. // DeliverySellOrderId =item.DeliverySellOrderId,
  324. // DeliveryGoodsId=item.DeliveryGoodsId,
  325. // DeliveryGoodsName=item.DeliveryGoodsName,
  326. // EnableQty=item.EnableQty,
  327. // RetCode=item.RetCode,
  328. // StorePlace=item.StorePlace,
  329. // ProvinceId =item.ProvinceId,
  330. // ProvinceName=item.ProvinceName,
  331. // CityId=item.CityId,
  332. // CityName=item.CityName
  333. // };
  334. // wrPairDetails.Add(model);
  335. //}
  336. //return new ResponeEntity<WrPairRspModel>()
  337. //{
  338. // RetCode = itemRsp.RetCode,
  339. // RetMessage = itemRsp.RetDesc,
  340. // Entity = new WrPairRspModel()
  341. // {
  342. // TradeGoodsId = itemRsp.TradeGoodsId,
  343. // WrPairDetails = wrPairDetails,
  344. // ////todo:生成委托
  345. // }
  346. //};
  347. }
  348. /// <summary>
  349. /// 交割提货个人信息查询应答-应答转换
  350. /// </summary>
  351. /// <param name="responeData"></param>
  352. /// <returns></returns>
  353. public override ResponeEntity<DepositPersonalInfoRspModel> ToDepositPersonalInfoRsp(object responeData)
  354. {
  355. return null;
  356. //var buffer = responeData as byte[];
  357. //if (buffer == null)
  358. //{
  359. // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
  360. //}
  361. //var itemRsp = ProtoBufHelper.EntityDeSerialize<DepositPersonalInfoRsp>(buffer);
  362. //return new ResponeEntity<DepositPersonalInfoRspModel>()
  363. //{
  364. // RetCode = itemRsp.RetCode,
  365. // RetMessage = itemRsp.RetDesc,
  366. // Entity = new DepositPersonalInfoRspModel()
  367. // {
  368. // accountId = itemRsp.accountId,
  369. // address = itemRsp.address,
  370. // personName = itemRsp.personName,
  371. // telphone = itemRsp.telphone,
  372. // IdCardNum = itemRsp.cardNum,
  373. // ////todo:生成委托
  374. // }
  375. //};
  376. }
  377. public override byte[] ToDeliveryWRReq(uint goodsId, uint deliveryGoodsId, uint tradeProperty)
  378. {
  379. var req = new DeliveryWRReq()
  380. {
  381. GoodId=goodsId,
  382. DeliveryGoodsId=deliveryGoodsId,
  383. TradeProperty=tradeProperty
  384. };
  385. return ProtoBufHelper.EntitySerialize(req, true);
  386. }
  387. public override ResponeEntity<DeliveryWRRspModel> ToDeliveryWRRsp(object responeData)
  388. {
  389. return null;
  390. //var buffer = responeData as byte[];
  391. //if (buffer == null)
  392. //{
  393. // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
  394. //}
  395. //var itemRsp = ProtoBufHelper.EntityDeSerialize<DeliveryWRRsp>(buffer);
  396. //var goodsdryPriceLst = new List<GoodsDryPriceModel>();
  397. //var tradeWRPostionLst = new List<TradeWRPositionModel>();
  398. //if (itemRsp.GoodsDeliveryPriceList != null)
  399. //{
  400. // foreach (var item in itemRsp.GoodsDeliveryPriceList)
  401. // {
  402. // var itemPrice = new GoodsDryPriceModel()
  403. // {
  404. // PriceMoveID=item.PriceMoveID,
  405. // PriceMoveDesc=item.PriceMoveDesc,
  406. // PriceMoveType=item.PriceMoveType,
  407. // PriceMoveValue=(decimal)item.PriceMoveValue
  408. // };
  409. // goodsdryPriceLst.Add(itemPrice);
  410. // }
  411. //}
  412. //if (itemRsp.TradeWRPositionList != null)
  413. //{
  414. // foreach (var item in itemRsp.TradeWRPositionList)
  415. // {
  416. // var itemPosition = new TradeWRPositionModel()
  417. // {
  418. // AccountID=item.AccountID,
  419. // BrandID=item.BrandID,
  420. // DeliveryGoodsID=item.DeliveryGoodsID,
  421. // DeliveryMonthID=item.DeliveryMonthID,
  422. // QualityID=item.QualityID,
  423. // RestQty=item.RestQty,
  424. // SpecID=item.SpecID,
  425. // WarehouseID=item.WarehouseID,
  426. // WRPositionID=item.WRPositionID,
  427. // WRUserID=item.WRUserID,
  428. // WRUserName=item.WRUserName
  429. // };
  430. // tradeWRPostionLst.Add(itemPosition);
  431. // }
  432. //}
  433. //return new ResponeEntity<DeliveryWRRspModel>()
  434. //{
  435. // RetCode = itemRsp.RetCode,
  436. // RetMessage = itemRsp.RetDesc,
  437. // Entity = new DeliveryWRRspModel()
  438. // {
  439. // GoodsDeliveryPriceList=goodsdryPriceLst,
  440. // TradeWRPositionList=tradeWRPostionLst,
  441. // }
  442. //};
  443. }
  444. }
  445. }