li.shaoyi 3 vuotta sitten
vanhempi
commit
3a3912c49c

+ 2 - 2
src/business/account/index.ts

@@ -1,10 +1,10 @@
 import { ref, reactive } from 'vue'
+import { v4 } from 'uuid'
 import { useRoute, useRouter } from 'vue-router'
-import cryptojs from 'crypto-js'
 import { sessionCache } from '@/store'
 import { initBaseData } from '@/business/common'
 import { login, queryLoginId } from '@/services/api/account'
-import { v4 } from 'uuid'
+import cryptojs from 'crypto-js'
 import eventBus from '@/services/bus'
 
 export function useAccount() {

+ 34 - 7
src/business/common/index.ts

@@ -1,9 +1,28 @@
 import { useRoute } from 'vue-router'
-import eventBus from '@/services/bus'
 import { queryGoodsList } from '@/services/api/goods'
+import { queryTaAccounts } from '@/services/api/account'
 import { globalState, sessionCache, localCache } from '@/store'
+import eventBus from '@/services/bus'
 import socket from '@/services/socket'
 
+export const business = new (class {
+    logoutNotify;
+    moneyChangedNotify;
+
+    constructor() {
+        // 接收用户登出通知
+        this.logoutNotify = eventBus.$on('logoutNotify', () => {
+            socket.closeQuoteServer();
+            socket.closeTradeServer();
+        })
+
+        // 接收资金变动通知
+        this.moneyChangedNotify = eventBus.$on('moneyChangedNotify', () => {
+            getTaAccounts();
+        })
+    }
+})
+
 /**
  * 初始化业务数据
  * @param callback 
@@ -19,14 +38,22 @@ export async function initBaseData(callback?: () => void) {
     })
 
     await Promise.all([getGoodsList]);
+    callback && callback();
+}
 
-    // 接收用户登出通知
-    eventBus.$on('logoutNotify', () => {
-        socket.closeQuoteServer();
-        socket.closeTradeServer();
+/**
+ * 获取资金账户列表
+ * @returns 
+ */
+export function getTaAccounts() {
+    return queryTaAccounts({
+        data: {
+            loginID: getLoginInfo('LoginID')
+        },
+        success: (res) => {
+            globalState.setValue('accountList', res.data);
+        }
     })
-
-    callback && callback();
 }
 
 /**

+ 79 - 74
src/business/quote/index.ts

@@ -5,18 +5,18 @@ import moment from 'moment'
 import eventBus from '@/services/bus'
 import socket from '@/services/socket'
 
-export default new (class {
+/**
+ * 行情订阅
+ */
+export const quote = new (class {
     /** 订阅列表 */
-    private subscribeMap = new Map<string, string[]>();
+    subscribeMap = new Map<string, string[]>();
+    quotePushNotify;
+    quoteServerReconnectNotify;
 
     constructor() {
-        // 接收行情服务断线重连成功通知
-        eventBus.$on('quoteServerReconnectNotify', () => {
-            this.startSubscribe();
-        })
-
         // 接收行情推送通知
-        eventBus.$on('quotePushNotify', (res) => {
+        this.quotePushNotify = eventBus.$on('quotePushNotify', (res) => {
             const tmpList = <Proto.GoodsQuote[]>res;
 
             tmpList.forEach((item) => {
@@ -181,81 +181,86 @@ export default new (class {
                 }
             })
         })
+
+        // 接收行情服务断线重连成功通知
+        this.quoteServerReconnectNotify = eventBus.$on('quoteServerReconnectNotify', () => {
+            startSubscribe();
+        })
     }
+})
 
-    /**
-     * 开始订阅
-     */
-    startSubscribe() {
-        const subscribeData: Proto.GoodsQuoteReq[] = [];
+/**
+ * 开始订阅
+ */
+export function startSubscribe() {
+    const subscribeData: Proto.GoodsQuoteReq[] = [];
 
-        this.subscribeMap.forEach((value) => {
-            const item = value.map((code) => ({
-                goodsCode: code,
-                exchangeCode: 250,
-                subState: 0
-            }))
-            subscribeData.push(...item);
-        })
+    quote.subscribeMap.forEach((value) => {
+        const item = value.map((code) => ({
+            goodsCode: code,
+            exchangeCode: 250,
+            subState: 0
+        }))
+        subscribeData.push(...item);
+    })
 
-        if (subscribeData.length) {
-            console.log('开始行情订阅', subscribeData)
-            quoteServerRequest({
-                data: subscribeData,
-                success: (res) => {
-                    if (res.length) {
-                        console.log('行情订阅成功', res)
-                    } else {
-                        console.error('行情订阅失败')
-                    }
-                },
-                fail: (err) => {
-                    console.error('行情订阅失败', err)
+    if (subscribeData.length) {
+        console.log('开始行情订阅', subscribeData)
+        quoteServerRequest({
+            data: subscribeData,
+            success: (res) => {
+                if (res.length) {
+                    console.log('行情订阅成功', res)
+                } else {
+                    console.error('行情订阅失败')
                 }
-            })
-        } else {
-            // 没有订阅商品的时候,断开连接
-            socket.closeQuoteServer();
-        }
+            },
+            fail: (err) => {
+                console.error('行情订阅失败', err)
+            }
+        })
+    } else {
+        // 没有订阅商品的时候,断开连接
+        socket.closeQuoteServer();
     }
+}
 
-    /**
-     * 添加订阅
-     * @param goodsCodes 
-     * @param key 
-     * @returns 
-     */
-    addSubscribe(goodsCodes: string[], key?: string) {
-        const uuid = key ?? v4();
-        const value = this.subscribeMap.get(uuid) ?? [];
+/**
+ * 添加订阅
+ * @param goodsCodes 
+ * @param key 
+ * @returns 
+ */
+export function addSubscribe(goodsCodes: string[], key?: string) {
+    const uuid = key ?? v4();
+    const value = quote.subscribeMap.get(uuid) ?? [];
 
-        // 对相同 key 订阅的商品进行合并处理
-        this.subscribeMap.set(uuid, [...value, ...goodsCodes]);
-        this.startSubscribe();
+    // 对相同 key 订阅的商品进行合并处理
+    quote.subscribeMap.set(uuid, [...value, ...goodsCodes]);
+    startSubscribe();
 
-        return {
-            uuid,
-            stop: () => {
-                console.log('删除订阅', uuid);
-                this.subscribeMap.delete(uuid);
-                this.startSubscribe();
-            },
-        }
+    return {
+        uuid,
+        stop: () => {
+            console.log('删除订阅', uuid);
+            quote.subscribeMap.delete(uuid);
+            startSubscribe();
+        },
     }
+}
 
-    /**
-     * 删除订阅
-     * @param keys 
-     */
-    removeSubscribe(...keys: string[]) {
-        if (keys.length) {
-            console.log('删除订阅', keys);
-            keys.forEach((key) => {
-                this.subscribeMap.delete(key);
-            })
-        } else {
-            this.subscribeMap.clear();
-        }
-        this.startSubscribe();
+/**
+ * 删除订阅
+ * @param keys 
+ */
+export function removeSubscribe(...keys: string[]) {
+    if (keys.length) {
+        console.log('删除订阅', keys);
+        keys.forEach((key) => {
+            quote.subscribeMap.delete(key);
+        })
+    } else {
+        quote.subscribeMap.clear();
     }
-})
+    startSubscribe();
+}

+ 4 - 2
src/packages/mobile/views/account/login/index.vue

@@ -5,8 +5,10 @@
       <div class="login-logo">用户登录</div>
       <Form @submit="loginAction">
         <CellGroup inset>
-          <Field v-model="account.LoginID" name="account" label="用户名" placeholder="请输入用户名" :rules="[{ required: true, message: '随便输入' }]" />
-          <Field v-model="account.LoginPWD" name="password" type="password" label="密码" placeholder="请输入密码" :rules="[{ required: true, message: '随便输入' }]" autocomplete />
+          <Field v-model="account.LoginID" name="account" label="用户名" placeholder="请输入用户名"
+            :rules="[{ required: true, message: '随便输入' }]" />
+          <Field v-model="account.LoginPWD" name="password" type="password" label="密码" placeholder="请输入密码"
+            :rules="[{ required: true, message: '随便输入' }]" autocomplete />
         </CellGroup>
         <div class="login-button">
           <Button type="primary" :loading="loading" loading-text="正在登录..." native-type="submit" round block>登录</Button>

+ 2 - 2
src/packages/pc/views/market/quote/index.vue

@@ -28,7 +28,7 @@ import AppContextmenu from '@pc/components/base/contextmenu/index.vue'
 import AppButtonGroup from '@pc/components/modules/button-group/index.vue'
 import AppFilter from './components/filter/index.vue'
 import socket from '@/services/socket'
-import quote from '@/business/quote'
+import { addSubscribe } from '@/business/quote'
 
 const components = {
   trade: defineAsyncComponent(() => import('@pc/components/modules/trade/index.vue')),
@@ -71,7 +71,7 @@ const handleButton = (item?: Ermcp.Goods) => {
   }
 }
 
-const subscribe = quote.addSubscribe(['pp2205', 'pp2206', 'b2205', 'b2206']);
+const subscribe = addSubscribe(['pp2205', 'pp2206', 'b2205', 'b2206']);
 
 queryGoodsList({
   success: (res) => {

+ 9 - 2
src/services/api/account/index.ts

@@ -11,15 +11,22 @@ export function login(params: TradeRequest<Proto.LoginReq, Proto.LoginRsp>) {
 }
 
 /**
- * 获取账户菜单
+ * 查询账户菜单
  */
 export function queryAccountMenu(params: HttpRequest<unknown, Ermcp.AccountMenu[]>) {
     return httpRequest('/account/menu', 'get', params);
 }
 
 /**
- * 获取登录ID
+ * 查询登录ID
  */
 export function queryLoginId(params: HttpRequest<{ username: string }, string>) {
     return httpRequest('/User/GetLoginID', 'get', params);
+}
+
+/**
+ * 查询资金账户信息
+ */
+export function queryTaAccounts(params: HttpRequest<Ermcp.TaAccountsReq, Ermcp.TaAccountsRsp[]>) {
+    return httpRequest('/TaAccount/GetTaAccounts', 'get', params);
 }

+ 1 - 1
src/services/bus/interface.ts

@@ -5,7 +5,7 @@ export enum EventKey {
     quotePushNotify, // 行情推送通知
     quoteServerReconnectNotify, // 行情服务重连成功通知
     logoutNotify, // 用户登出通知
-    MoneyChangedNotify, // 资金变动通知
+    moneyChangedNotify, // 资金变动通知
 }
 
 /**

+ 1 - 1
src/services/socket/index.ts

@@ -38,7 +38,7 @@ export default new (class {
                 case FunCode.MoneyChangedNotify: {
                     timerInterceptor.debounce(() => {
                         // 通知上层 资金变动
-                        eventBus.$emit('MoneyChangedNotify');
+                        eventBus.$emit('moneyChangedNotify');
                     }, delay, funCode.toString())
                     break;
                 }

+ 1 - 0
src/store/state/index.ts

@@ -8,6 +8,7 @@ const source: Store.GlobalState = {
     isMobile: false,
     goodsList: [],
     quoteList: [],
+    accountList: [],
     serviceConfig: {
         commSearchUrl: '',
         goCommonSearchUrl: '',

+ 63 - 0
src/types/ermcp/account.d.ts

@@ -24,4 +24,67 @@ declare namespace Ermcp {
             className?: string;
         }
     }
+
+    /** 查询资金账户信息 请求 */
+    interface TaAccountsReq {
+        loginID: number; // 登录账户
+        taAccountType?: number; // 账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号
+    }
+
+    /** 查询资金账户信息 响应 */
+    interface TaAccountsRsp {
+        accountflag: number; // 账户标识 - 0\1 (默认为0, 当上级账户与本账户的关联用户均为自己时更新为1)
+        accountid: number; // 资金账户ID
+        accountname: string; // 账户名称
+        balance: number; // 期初余额
+        capitalbalance: number; // 本金余额[外部子账户实际出入金余额]
+        changeflag: number; // 变动标志(当前账户资金有任何变动更新为1系统结算时更新0;供清算时使用) 0:无变动 1:有变动
+        changetime: string; // 账户状态变更时间
+        closepl: number; // 今日平仓盈亏
+        creditdecrease: number; // 今日授信减少
+        creditincrease: number; // 今日授信增加
+        curamount: number; // 总市值(从持仓中统计)
+        currencyid: number; // 货币ID
+        currentbalance: number; // 期末余额
+        freezecharge: number; // 手续费冻结
+        freezemargin: number; // 冻结保证金
+        fromaccountid: number; // 所属上级账户
+        inamount: number; // 今日入金金额(包括三方入金)
+        ismain: number; // 是否母账号 0:不是母账户 1:是母账户
+        ismarketaccount: number; // 是否机构接单账号 0:不是 1:是
+        isreckonaccount: number; // 是否机构分润账号 0:不是 1:是
+        mortgagecredit: number; // 授信金额
+        orifreezecharge: number; // 期初手续费冻结
+        orifreezemargin: number; // 期初冻结保证金
+        orimortgagecredit: number; // 期初授信金额
+        oriothercredit: number; // 期初其它授信金额
+        oriotherfreezemargin: number; // 期初其他冻结保证金(出金冻结资金 交割买方冻结 申购冻结 全款买入 商城买入)
+        orioutamountfreeze: number; // 期初出金冻结
+        oriusedmargin: number; // 期初占用保证金
+        othercredit: number; // 其它授信金额
+        othercreditdecrease: number; // 今日其它授信减少
+        othercreditincrease: number; // 今日其它授信增加
+        otherfreezemargin: number; // 其他冻结保证金(交割买方冻结 申购冻结 全款买入 商城买入)
+        otherincome: number; // 其他收入(交割收款 申购收款 全款卖出 商城卖出 买家退货 会员手续费收入)
+        otherpay: number; // 其他支出(交割付款 申购付款 全款买入 商城买入 卖家退货)
+        outamount: number; // 今日出金金额(包括三方出金)
+        outamountfreeze: number; // 出金冻结
+        outthreshold: number; // 出金阈值
+        parentaccountid: number; // 所属根账号
+        paycharge: number; // 今日手续费支出
+        relatedaccountstatus: number; // 关联用户交易权限状态 - 1:正常(可交易) 2:受限(可平仓,不可建仓) 3:冻结(不可交易)
+        relateduserid: number; // 关联用户
+        remainamount: number; // 融资额(从融资合同中统计)
+        serivcegroup: number; // 服务分组
+        signstatus: number; // 签约状态 - 1:未签约 2:签约待审核 3:签约中 4:已签约 5:解约待审核 6:解约中 7:已解约 8:已解绑 9:绑卡中
+        sublevelpath: number; // 账号层级路径(逗号分隔,首尾加逗号)
+        taaccounttype: number; // 账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号
+        thirdinamount: number; // 今日三方入金
+        thirdoutamount: number; // 今日三方出金
+        tradestatus: number; // 交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销
+        tradestatuschangetime: string; // 激活时间
+        transferamount: number; // 今日划转金额(母子账号资金划转,从划入账号为正,从账号划出为负)
+        usedmargin: number; // 占用保证金
+        userid: number; // 用户ID
+    }
 }

+ 1 - 0
src/types/store/state.d.ts

@@ -4,6 +4,7 @@ declare namespace Store {
         isMobile: boolean;
         goodsList: Ermcp.Goods[]; // 商品列表
         quoteList: Ermcp.QuoteDay[]; // 盘面列表
+        accountList: Ermcp.TaAccountsRsp[]; // 资金账号列表
         serviceConfig: App.ServiceConfig; // 服务配置信息
     }
 }