MixPayTradeViewModel.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. //----------------------------------------------------------------
  6. //Module Name: $safeprojectname$
  7. //Purpose:
  8. //CopyRight: Muchinfo
  9. //History:
  10. //----------------------------------------------------------------
  11. //DateTime 2016/7/27 20:28:55
  12. //Author
  13. //Description Create
  14. //----------------------------------------------------------------
  15. using Muchinfo.MTPClient.Data;
  16. using Muchinfo.MTPClient.Data.Enums;
  17. using Muchinfo.MTPClient.Data.Model;
  18. using Muchinfo.MTPClient.Data.Model.Account;
  19. using Muchinfo.MTPClient.Infrastructure.Utilities;
  20. namespace Muchinfo.MTPClient.Trade.ViewModels
  21. {
  22. public class MixPayTradeViewModel:MixTradeViewModel
  23. {
  24. public MixPayTradeViewModel(QuoteGoods goods, Direction direction)
  25. : base(goods, direction)
  26. {
  27. OpenCloseMode = OpenCloseMode.BUILDTYPE_OPEN;
  28. }
  29. public MixPayTradeViewModel(QuoteGoods goods, OrderBase orderBase)
  30. : base(goods, orderBase)
  31. {
  32. }
  33. public override bool IsSellEnable
  34. {
  35. get
  36. {
  37. var holdingOrders = UserManager.GetCacheOrders<HoldingOrder>();
  38. if (holdingOrders == null || !holdingOrders.Any())
  39. {
  40. return false;
  41. }
  42. //全款划扣商品-》只有买入方向的平仓单
  43. return holdingOrders.Where((item) => item.GoodsId == _currentGoods.GoodsId && item.Direction == Direction.Bid).ToList().Any();
  44. }
  45. }
  46. /// <summary>
  47. /// 按单、寸头是否可见
  48. /// </summary>
  49. public override bool IsCloseTypeVsb
  50. {
  51. get
  52. {
  53. //卖方向的时候可见
  54. return Direction == Direction.Ask;
  55. }
  56. }
  57. public override void PostOrder(Action<OrderDetail> successAction, Action<ErrorEntity> errorAction)
  58. {
  59. var entrustOrder = BuildEntrustOrder();
  60. entrustOrder.BuildType = Direction == Direction.Ask ? OpenCloseMode.BUILDTYPE_CLOSE : OpenCloseMode.BUILDTYPE_OPEN;
  61. ////按单平
  62. if (Direction == Direction.Ask && GoodsOrderMode == GoodsOrderMode.Order)
  63. {
  64. //entrustOrder.RelationTicket = SelectOrder == null ? 0 : SelectOrder.OrderID;
  65. }
  66. _orderService.MixMarketEntrustOrder(entrustOrder, successAction, errorAction);
  67. }
  68. protected override void SetMinMaxQtyVaule()
  69. {
  70. if (this.Direction == Direction.Bid)
  71. {
  72. SetOpenQty(); //设置建仓最大最小数量
  73. }
  74. else
  75. {
  76. SetCloseQty();//设置平仓最大最小数量
  77. }
  78. }
  79. }
  80. }