index.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import APP from "@/services";
  2. import { getSelectedAccountId, getUserId } from "@/services/bus/account";
  3. import { GldErmcpSpotContractOperateReq } from "@/services/proto/spotcontract/interface";
  4. import { buildProtoReq50, parseProtoRsp50 } from "@/services/socket/protobuf/buildReq";
  5. import { Callback } from "@/utils/websocket";
  6. import { v4 as uuidv4 } from 'uuid';
  7. /**(重点提醒 这里属于管理端接口,仅用于新增)以上来自android代码 回头需要确认
  8. * 新增 / 修改采购合同报文 (很多修改合同操作也在这)
  9. * @param
  10. * @param param
  11. */
  12. export const orderContract = (param: GldErmcpSpotContractOperateReq): Promise<any> => {
  13. const OperateSrc = 2; // uint32 操作来源-1:管理端2:终端
  14. const ClientTicket: string = uuidv4(); // 客户端流水号
  15. const UserID: number = getUserId(); // 用户id
  16. const reqParams = {
  17. ...param, OperateSrc, ClientTicket, UserID
  18. }
  19. return new Promise((resolve, reject) => {
  20. const params = {
  21. protobufName: 'GldErmcpSpotContractOperateReq',
  22. funCodeName: 'GldErmcpSpotContractOperateReq',
  23. reqParams: reqParams,
  24. msgHeadParams: {
  25. AccountID: getSelectedAccountId(),
  26. MarketID: 18,
  27. GoodsID: 0,
  28. }
  29. };
  30. const package50 = buildProtoReq50(params);
  31. APP.sendTradingServer(package50, undefined, {
  32. onSuccess: (res) => {
  33. const { isSuccess, result } = parseProtoRsp50(res, 'GldErmcpSpotContractOperateRsp');
  34. if (isSuccess) {
  35. resolve(result);
  36. } else {
  37. reject(result);
  38. }
  39. },
  40. onFail: (err) => reject(err.message),
  41. } as Callback);
  42. });
  43. }