index.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import APP from "@/services";
  2. import { getSelectedAccountId, getUserId } from '@/services/bus/account';
  3. import { getLongTypeLoginID } from '@/services/bus/login';
  4. import {
  5. DeliveryGoodsApplyReq,
  6. DeliveryGoodsCancelReq,
  7. ErmsMiddelGoodsEditReq
  8. } from "@/services/proto/delivery/interface";
  9. import { buildProtoReq50, parseProtoRsp50 } from "@/services/socket/protobuf/buildReq";
  10. import { Callback } from "@/utils/websocket";
  11. /**
  12. * 现货品种申请请求
  13. * @param param DeliveryGoodsApplyReq
  14. */
  15. export const addDeliveryGoodsApply = (param: DeliveryGoodsApplyReq): Promise<any> => {
  16. return new Promise((resolve, reject) => {
  17. const req = {
  18. version: "3.2",
  19. userid: getUserId(),
  20. loginid: getLongTypeLoginID() ,
  21. };
  22. const params = {
  23. protobufName: 'DeliveryGoodsApplyReq',
  24. funCodeName: 'DeliveryGoodsApplyReq',
  25. reqParams: Object.assign(req, param),
  26. msgHeadParams: {
  27. AccountID: getSelectedAccountId() === null ? 0 : getSelectedAccountId(),
  28. MarketID: 18, // 目前写死
  29. GoodsID: 0, // 目前写死
  30. }
  31. };
  32. const package50 = buildProtoReq50(params);
  33. APP.sendTradingServer(package50, undefined, {
  34. onSuccess: (res) => {
  35. const { isSuccess, result } = parseProtoRsp50(res, 'DeliveryGoodsApplyRsp');
  36. if (isSuccess) {
  37. resolve(result);
  38. } else {
  39. reject(result);
  40. }
  41. },
  42. onFail: (err) => reject(err.message),
  43. } as Callback);
  44. });
  45. }
  46. /**
  47. * 修改套保品种请求 ErmsMiddelGoodsEditReq 只能修改比率 但是其它参数也必须传
  48. */
  49. export const ermsMiddelGoodsEdit = (param: ErmsMiddelGoodsEditReq): Promise<any> => {
  50. param.areauserid = APP.get('userInfo').MemberUserid // 机构用户id
  51. return new Promise((resolve, reject) => {
  52. const req = {
  53. version: "3.2",
  54. userid: getUserId(),
  55. loginid: getLongTypeLoginID() ,
  56. };
  57. const params = {
  58. protobufName: 'ErmsMiddelGoodsEditReq',
  59. funCodeName: 'ErmsMiddelGoodsEditReq',
  60. reqParams: Object.assign(req, param),
  61. msgHeadParams: {
  62. AccountID: getSelectedAccountId() === null ? 0 : getSelectedAccountId(),
  63. MarketID: 18, // 目前写死
  64. GoodsID: 0, // 目前写死
  65. }
  66. };
  67. const package50 = buildProtoReq50(params);
  68. APP.sendTradingServer(package50, undefined, {
  69. onSuccess: (res) => {
  70. const { isSuccess, result } = parseProtoRsp50(res, 'ErmsMiddelGoodsEditRsp');
  71. if (isSuccess) {
  72. resolve(result);
  73. } else {
  74. reject(result);
  75. }
  76. },
  77. onFail: (err) => reject(err.message),
  78. } as Callback);
  79. });
  80. }
  81. /**
  82. * 现货品种停用请求
  83. */
  84. export const deliveryGoodsCancel = (param: DeliveryGoodsCancelReq): Promise<any> => {
  85. return new Promise((resolve, reject) => {
  86. const req = {
  87. version: "3.2",
  88. userid: getUserId(),
  89. loginid: getLongTypeLoginID() ,
  90. };
  91. const params = {
  92. protobufName: 'DeliveryGoodsCancelReq',
  93. funCodeName: 'DeliveryGoodsCancelReq',
  94. reqParams: Object.assign(req, param),
  95. msgHeadParams: {
  96. AccountID: getSelectedAccountId() === null ? 0 : getSelectedAccountId(),
  97. MarketID: 18, // 目前写死
  98. GoodsID: 0, // 目前写死
  99. }
  100. };
  101. const package50 = buildProtoReq50(params);
  102. APP.sendTradingServer(package50, undefined, {
  103. onSuccess: (res) => {
  104. const { isSuccess, result } = parseProtoRsp50(res, 'DeliveryGoodsCancelRsp');
  105. if (isSuccess) {
  106. resolve(result);
  107. } else {
  108. reject(result);
  109. }
  110. },
  111. onFail: (err) => reject(err.message),
  112. } as Callback);
  113. });
  114. }