huangbin há 4 anos atrás
pai
commit
a7de5bd71e
1 ficheiros alterados com 14 adições e 0 exclusões
  1. 14 0
      src/services/socket/quota/adapter/index.ts

+ 14 - 0
src/services/socket/quota/adapter/index.ts

@@ -1,4 +1,5 @@
 import APP from '@/services';
+import { getGoodsByCode } from '@/services/bus/goods';
 import { getLongTypeLoginID, isLogin } from '@/services/bus/login';
 import { getToken } from '@/services/bus/token';
 import { funCode } from '@/services/funcode/index';
@@ -120,6 +121,19 @@ export function parseReceivePush(quotationData: any) {
         const quoteDayInfo = APP.getRef('quoteDayInfo');
         const itemQuote = quoteDayInfo.value.find((el: QueryQuoteDayRsp) => el.goodscode === goodsQuoteTik.goodscode);
         if (itemQuote) {
+            const goods = getGoodsByCode(itemQuote.goodscode);
+            if (goods) {
+                // 处理报价小数为
+                const decimalplace = goods.decimalplace
+                const num = Math.pow(10, decimalplace)
+                const fn = (value: number) => +(value / num).toFixed(decimalplace)
+                goodsQuoteTik.last && (goodsQuoteTik.last = fn(goodsQuoteTik.last))
+                goodsQuoteTik.settle && (goodsQuoteTik.settle = fn(goodsQuoteTik.settle))
+                goodsQuoteTik.presettle && (goodsQuoteTik.presettle = fn(goodsQuoteTik.presettle))
+            } else {
+                console.warn(`行情推送的商品goods:${itemQuote.goodscode}在商品列表里不存在`)
+            }
+
             // 注意:此处已 go 服务查询出来的盘面数据为基准,查询盘面 先修改成go 服务,第一次进入项目时候回查询一次所有盘面
             // 之前是 通过 websocket 查询的,故 可能存在字段发生变化问题,如遇到,则进行优化处理
             mergeObj(itemQuote, goodsQuoteTik);