| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- import APP from "@/services";
- import { getSelectedAccountId, getUserId } from '@/services/bus/account';
- import { getLongTypeLoginID } from '@/services/bus/login';
- import {
- DeliveryGoodsApplyReq,
- DeliveryGoodsCancelReq,
- ErmsMiddelGoodsEditReq
- } from "@/services/proto/delivery/interface";
- import { buildProtoReq50, parseProtoRsp50 } from "@/services/socket/protobuf/buildReq";
- import { Callback } from "@/utils/websocket";
- /**
- * 现货品种申请请求
- * @param param DeliveryGoodsApplyReq
- */
- export const addDeliveryGoodsApply = (param: DeliveryGoodsApplyReq): Promise<any> => {
- return new Promise((resolve, reject) => {
- const req = {
- version: "3.2",
- userid: getUserId(),
- loginid: getLongTypeLoginID() ,
- };
- const params = {
- protobufName: 'DeliveryGoodsApplyReq',
- funCodeName: 'DeliveryGoodsApplyReq',
- reqParams: Object.assign(req, param),
- msgHeadParams: {
- AccountID: getSelectedAccountId() === null ? 0 : getSelectedAccountId(),
- MarketID: 18, // 目前写死
- GoodsID: 0, // 目前写死
- }
- };
- const package50 = buildProtoReq50(params);
- APP.sendTradingServer(package50, undefined, {
- onSuccess: (res) => {
- const { isSuccess, result } = parseProtoRsp50(res, 'DeliveryGoodsApplyRsp');
- if (isSuccess) {
- resolve(result);
- } else {
- reject(result);
- }
- },
- onFail: (err) => reject(err.message),
- } as Callback);
- });
- }
- /**
- * 修改套保品种请求 ErmsMiddelGoodsEditReq 只能修改比率 但是其它参数也必须传
- */
- export const ermsMiddelGoodsEdit = (param: ErmsMiddelGoodsEditReq): Promise<any> => {
- param.areauserid = APP.get('userInfo').MemberUserid // 机构用户id
- return new Promise((resolve, reject) => {
- const req = {
- version: "3.2",
- userid: getUserId(),
- loginid: getLongTypeLoginID() ,
- };
- const params = {
- protobufName: 'ErmsMiddelGoodsEditReq',
- funCodeName: 'ErmsMiddelGoodsEditReq',
- reqParams: Object.assign(req, param),
- msgHeadParams: {
- AccountID: getSelectedAccountId() === null ? 0 : getSelectedAccountId(),
- MarketID: 18, // 目前写死
- GoodsID: 0, // 目前写死
- }
- };
- const package50 = buildProtoReq50(params);
- APP.sendTradingServer(package50, undefined, {
- onSuccess: (res) => {
- const { isSuccess, result } = parseProtoRsp50(res, 'ErmsMiddelGoodsEditRsp');
- if (isSuccess) {
- resolve(result);
- } else {
- reject(result);
- }
- },
- onFail: (err) => reject(err.message),
- } as Callback);
- });
- }
- /**
- * 现货品种停用请求
- */
- export const deliveryGoodsCancel = (param: DeliveryGoodsCancelReq): Promise<any> => {
- return new Promise((resolve, reject) => {
- const req = {
- version: "3.2",
- userid: getUserId(),
- loginid: getLongTypeLoginID() ,
- };
- const params = {
- protobufName: 'DeliveryGoodsCancelReq',
- funCodeName: 'DeliveryGoodsCancelReq',
- reqParams: Object.assign(req, param),
- msgHeadParams: {
- AccountID: getSelectedAccountId() === null ? 0 : getSelectedAccountId(),
- MarketID: 18, // 目前写死
- GoodsID: 0, // 目前写死
- }
- };
- const package50 = buildProtoReq50(params);
- APP.sendTradingServer(package50, undefined, {
- onSuccess: (res) => {
- const { isSuccess, result } = parseProtoRsp50(res, 'DeliveryGoodsCancelRsp');
- if (isSuccess) {
- resolve(result);
- } else {
- reject(result);
- }
- },
- onFail: (err) => reject(err.message),
- } as Callback);
- });
- }
|