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 => { 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 => { 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 => { 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); }); }