li.shaoyi пре 1 месец
родитељ
комит
89f80dc782

+ 1 - 1
app/package.json

@@ -1,6 +1,6 @@
 {
   "name": "trading",
-  "version": "1.0.5",
+  "version": "1.0.7",
   "main": "main.js",
   "dependencies": {
     "electron-updater": "^6.1.4",

+ 261 - 0
public/proto/mtp.js

@@ -4083,6 +4083,10 @@ var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $pr
       DigitalAccountID: {
         type: "uint64",
         id: 3
+      },
+      TaAccountDigitalInfo: {
+        type: "TaAccountDigitalChange",
+        id: 4
       }
     }
   },
@@ -4099,6 +4103,106 @@ var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $pr
       DigitalAccountID: {
         type: "uint64",
         id: 3
+      },
+      TaAccountDigitalInfo: {
+        type: "TaAccountDigitalChange",
+        id: 4
+      }
+    }
+  },
+  TaAccountDigitalChange: {
+    fields: {
+      DigitalAccountID: {
+        type: "uint64",
+        id: 1
+      },
+      CurrencyID: {
+        type: "uint32",
+        id: 2
+      },
+      UserID: {
+        type: "uint32",
+        id: 3
+      },
+      CurrentBalance: {
+        type: "double",
+        id: 4
+      },
+      UsedMargin: {
+        type: "double",
+        id: 5
+      },
+      FreezeMargin: {
+        type: "double",
+        id: 6
+      },
+      FreezeTradeCharge: {
+        type: "double",
+        id: 7
+      },
+      FreezeTransfer: {
+        type: "double",
+        id: 8
+      },
+      FreezeInOut: {
+        type: "double",
+        id: 9
+      },
+      TotalTradeAdd: {
+        type: "double",
+        id: 10
+      },
+      TotalTradeReduce: {
+        type: "double",
+        id: 11
+      },
+      TotalTradeCharge: {
+        type: "double",
+        id: 12
+      },
+      TotalTransferIn: {
+        type: "double",
+        id: 13
+      },
+      TotalTransferOut: {
+        type: "double",
+        id: 14
+      },
+      TotalTransferInCharge: {
+        type: "double",
+        id: 15
+      },
+      TotalTransferOutCharge: {
+        type: "double",
+        id: 16
+      },
+      TotalIn: {
+        type: "double",
+        id: 17
+      },
+      TotalOut: {
+        type: "double",
+        id: 18
+      },
+      TotalInInCharge: {
+        type: "double",
+        id: 19
+      },
+      TotalInOutCharge: {
+        type: "double",
+        id: 20
+      },
+      SignedData: {
+        type: "string",
+        id: 21
+      },
+      TradeStatus: {
+        type: "uint32",
+        id: 22
+      },
+      Timestamp: {
+        type: "uint64",
+        id: 23
       }
     }
   },
@@ -52417,6 +52521,163 @@ var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $pr
         id: 7
       }
     }
+  },
+  DigitalAccountActivateReq: {
+    fields: {
+      Header: {
+        type: "MessageHead",
+        id: 1
+      },
+      UserID: {
+        rule: "required",
+        type: "uint32",
+        id: 2
+      },
+      CurrencyID: {
+        rule: "required",
+        type: "uint32",
+        id: 3
+      },
+      OperateSrc: {
+        rule: "required",
+        type: "uint32",
+        id: 4
+      },
+      ClientTicket: {
+        rule: "required",
+        type: "string",
+        id: 5
+      },
+      Remark: {
+        type: "string",
+        id: 6
+      }
+    }
+  },
+  DigitalAccountActivateRsp: {
+    fields: {
+      Header: {
+        type: "MessageHead",
+        id: 1
+      },
+      RetCode: {
+        type: "int32",
+        id: 2
+      },
+      RetDesc: {
+        type: "string",
+        id: 3
+      },
+      DigitalAccountID: {
+        type: "uint64",
+        id: 4
+      },
+      TaAccountDigitalInfo: {
+        type: "TaAccountDigital",
+        id: 5
+      },
+      ClientTicket: {
+        rule: "required",
+        type: "string",
+        id: 6
+      }
+    }
+  },
+  TaAccountDigital: {
+    fields: {
+      DigitalAccountID: {
+        type: "uint64",
+        id: 1
+      },
+      CurrencyID: {
+        type: "uint32",
+        id: 2
+      },
+      UserID: {
+        type: "uint32",
+        id: 3
+      },
+      CurrentBalance: {
+        type: "double",
+        id: 4
+      },
+      UsedMargin: {
+        type: "double",
+        id: 5
+      },
+      FreezeMargin: {
+        type: "double",
+        id: 6
+      },
+      FreezeTradeCharge: {
+        type: "double",
+        id: 7
+      },
+      FreezeTransfer: {
+        type: "double",
+        id: 8
+      },
+      FreezeInOut: {
+        type: "double",
+        id: 9
+      },
+      TotalTradeAdd: {
+        type: "double",
+        id: 10
+      },
+      TotalTradeReduce: {
+        type: "double",
+        id: 11
+      },
+      TotalTradeCharge: {
+        type: "double",
+        id: 12
+      },
+      TotalTransferIn: {
+        type: "double",
+        id: 13
+      },
+      TotalTransferOut: {
+        type: "double",
+        id: 14
+      },
+      TotalTransferInCharge: {
+        type: "double",
+        id: 15
+      },
+      TotalTransferOutCharge: {
+        type: "double",
+        id: 16
+      },
+      TotalIn: {
+        type: "double",
+        id: 17
+      },
+      TotalOut: {
+        type: "double",
+        id: 18
+      },
+      TotalInInCharge: {
+        type: "double",
+        id: 19
+      },
+      TotalInOutCharge: {
+        type: "double",
+        id: 20
+      },
+      SignedData: {
+        type: "string",
+        id: 21
+      },
+      TradeStatus: {
+        type: "uint32",
+        id: 22
+      },
+      Timestamp: {
+        type: "uint64",
+        id: 23
+      }
+    }
   }
 });
 

+ 75 - 3
public/proto/mtp.proto

@@ -1215,12 +1215,40 @@ message DigitalAccountChangedNtf {
 	optional MessageHead Header = 1; // 消息头
 		optional NotifyHead NtfHeader = 2; // NotifyHead 公共消息头
 		optional uint64 DigitalAccountID = 3; // uint64 数字账户ID
+		optional TaAccountDigitalChange TaAccountDigitalInfo = 4; // TaAccountDigitalChange 数字账户信息
 }
 // 数字账户资金变化通知
 message DigitalAccountFundsChangedNtf {
 	optional MessageHead Header = 1; // 消息头
 		optional NotifyHead NtfHeader = 2; // NotifyHead 公共消息头
 		optional uint64 DigitalAccountID = 3; // uint64 数字账户ID
+		optional TaAccountDigitalChange TaAccountDigitalInfo = 4; // TaAccountDigitalChange 数字账户信息
+}
+// 数字账户信息
+message TaAccountDigitalChange {
+		optional uint64 DigitalAccountID = 1; // 数字账户ID
+		optional uint32 CurrencyID = 2; // 币种ID
+			optional uint32 UserID = 3; // 用户ID
+		optional double CurrentBalance = 4; // 期末余额
+		optional double UsedMargin = 5; // 占用保证金(交易)-正
+		optional double FreezeMargin = 6; // 冻结保证金(交易)-正
+		optional double FreezeTradeCharge = 7; // 交易手续费冻结-正
+		optional double FreezeTransfer = 8; // 转入转出冻结-正
+		optional double FreezeInOut = 9; // 充值提现冻结-正
+		optional double TotalTradeAdd = 10; // 累计交易增加-正
+		optional double TotalTradeReduce = 11; // 累计交易减少-负
+		optional double TotalTradeCharge = 12; // 累计交易手续费-负
+		optional double TotalTransferIn = 13; // 累计转入(合约与现货账户)-正
+		optional double TotalTransferOut = 14; // 累计转出(合约与现货账户)-负
+		optional double TotalTransferInCharge = 15; // 累计转入手续费-负
+		optional double TotalTransferOutCharge = 16; // 累计转出手续费-负
+		optional double TotalIn = 17; // 累计充值(现货账户与外部钱包)-正
+		optional double TotalOut = 18; // 累计提现(现货账户与外部钱包)-负
+		optional double TotalInInCharge = 19; // 累计充值手续费-负
+		optional double TotalInOutCharge = 20; // 累计提现手续费-负
+		optional string SignedData = 21; // SignedData
+		optional uint32 TradeStatus = 22; // 交易状态-1:正常
+		optional uint64 Timestamp = 23; // 时间戳
 }
 // 交易委托请求
 message OrderReq {
@@ -15665,7 +15693,7 @@ message DigitalAccountTransferApplyReq {
 			required uint32 UserID = 3; // 用户ID
 		required uint32 CurrencyID = 4; // 币种ID
 		optional uint32 DigitalTransferType = 5; // 划转类型-枚举"digitaltransfertype"(3:转入,4:转出)
-		required double Amount = 6; // 转入转出金额
+		required double Amount = 6; // 转入转出金额(正值)
 			required uint32 OperateSrc = 7; // 操作来源-枚举"operatesrc"(1:管理端,2:终端)
 		required string ClientTicket = 8; // 客户端流水号
 		optional string Remark = 9; // 备注
@@ -15709,7 +15737,7 @@ message DigitalAccountWithdrawApplyReq {
 		required uint32 CurrencyID = 3; // 币种ID
 		required uint32 WalletID = 4; // 钱包ID
 		required uint64 DigitalAccountID = 5; // 数字账户ID
-		required double Amount = 6; // 金额
+		required double Amount = 6; // 金额(正值)
 			required uint32 OperateSrc = 7; // 操作来源-枚举"operatesrc"(1:管理端,2:终端)
 		required string ClientTicket = 8; // 客户端流水号
 		optional string Remark = 9; // 备注
@@ -15790,9 +15818,53 @@ message DigitalSubCommand {
 message DigitalFundOperationCmd {
 		required uint32 DigitalOperateType = 1; // 变更类型(枚举"digitaloperatetype")
 		optional uint32 DigitalBusinessCode = 2; // 业务编号(枚举"digitalbusinesscode")
-		required double ChangeAmount = 3; // 变更金额
+		required double ChangeAmount = 3; // 变更金额(正值)
 		optional uint32 RelatedGoodsID = 4; // 关联商品ID
 		optional uint32 RelatedMarketID = 5; // 关联市场
 		optional uint64 SubOrderIndex = 6; // 子指令序号
 		required uint64 DigitalAccountID = 7; // 数字账户ID
 }
+// 数字账户激活请求
+message DigitalAccountActivateReq {
+	optional MessageHead Header = 1;
+			required uint32 UserID = 2; // 用户ID
+		required uint32 CurrencyID = 3; // 币种ID
+			required uint32 OperateSrc = 4; // 操作来源-枚举"operatesrc"(1:管理端,2:终端)
+		required string ClientTicket = 5; // 客户端流水号
+		optional string Remark = 6; // 备注
+}
+// 数字账户激活应答
+message DigitalAccountActivateRsp {
+	optional MessageHead Header = 1; // 消息头
+	optional int32 RetCode = 2; // 返回码
+	optional string RetDesc = 3; // 描述信息
+		optional uint64 DigitalAccountID = 4; // 数字账户ID
+		optional TaAccountDigital TaAccountDigitalInfo = 5; // 数字账户信息
+		required string ClientTicket = 6; // 客户端流水号
+}
+// 数字账户信息
+message TaAccountDigital {
+		optional uint64 DigitalAccountID = 1; // 数字账户ID
+		optional uint32 CurrencyID = 2; // 币种ID
+			optional uint32 UserID = 3; // 用户ID
+		optional double CurrentBalance = 4; // 期末余额
+		optional double UsedMargin = 5; // 占用保证金(交易)-正
+		optional double FreezeMargin = 6; // 冻结保证金(交易)-正
+		optional double FreezeTradeCharge = 7; // 交易手续费冻结-正
+		optional double FreezeTransfer = 8; // 转入转出冻结-正
+		optional double FreezeInOut = 9; // 充值提现冻结-正
+		optional double TotalTradeAdd = 10; // 累计交易增加-正
+		optional double TotalTradeReduce = 11; // 累计交易减少-负
+		optional double TotalTradeCharge = 12; // 累计交易手续费-负
+		optional double TotalTransferIn = 13; // 累计转入(合约与现货账户)-正
+		optional double TotalTransferOut = 14; // 累计转出(合约与现货账户)-负
+		optional double TotalTransferInCharge = 15; // 累计转入手续费-负
+		optional double TotalTransferOutCharge = 16; // 累计转出手续费-负
+		optional double TotalIn = 17; // 累计充值(现货账户与外部钱包)-正
+		optional double TotalOut = 18; // 累计提现(现货账户与外部钱包)-负
+		optional double TotalInInCharge = 19; // 累计充值手续费-负
+		optional double TotalInOutCharge = 20; // 累计提现手续费-负
+		optional string SignedData = 21; // SignedData
+		optional uint32 TradeStatus = 22; // 交易状态-1:正常
+		optional uint64 Timestamp = 23; // 时间戳
+}

+ 2 - 1
src/constants/funcode.ts

@@ -164,7 +164,8 @@ export enum FunCode {
 
     DigitalAccountTransferApplyReq = 3014657, // 数字账户转入转出申请请求
     DigitalAccountTransferApplyRsp = 3014658, // 数字账户转入转出申请应答
-
     DigitalOrderReq = 196771, // 数字交易委托请求
     DigitalOrderRsp = 196772, // 数字交易委托应答
+    DigitalAccountActivateReq = 3014671, // 数字账户激活请求
+    DigitalAccountActivateRsp = 3014672, // 数字账户激活应答
 } 

+ 55 - 0
src/packages/digital/views/spot/components/account/activate/index.vue

@@ -0,0 +1,55 @@
+<template>
+    <Dialog v-model:show="showDialog" title="提示" show-cancel-button :before-close="onBeforeClose" @closed="onClosed"
+        message="是否激活当前账户?">
+    </Dialog>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef, onMounted, PropType } from 'vue'
+import { Dialog } from 'vant'
+import { fullloading } from '@/utils/vant'
+import { digitalAccountActivate } from '@/services/api/digital'
+import { useSpotAccountStore } from '../../../../wallet/components/spot/composables'
+
+const props = defineProps({
+    selectedRow: {
+        type: Object as PropType<Model.TaaccountDigitalsRsp>,
+        required: true
+    }
+})
+
+const emit = defineEmits(['closed'])
+
+const spotAccountStore = useSpotAccountStore()
+const showDialog = shallowRef(false)
+const refresh = shallowRef(false) // 是否刷新父组件数据
+
+const onBeforeClose = (action: string) => {
+    if (action === 'confirm') {
+        fullloading((hideLoading) => {
+            digitalAccountActivate({
+                data: {
+                    CurrencyID: props.selectedRow.currencyid
+                }
+            }).then(() => {
+                hideLoading('账户已激活', 'success')
+                spotAccountStore.fetchTaaccountDigitals()
+                refresh.value = true
+            }).catch((err) => {
+                hideLoading(err, 'fail')
+            }).finally(() => {
+                showDialog.value = false
+            })
+        })
+    }
+    return true
+}
+
+const onClosed = () => {
+    emit('closed', refresh.value)
+}
+
+onMounted(() => {
+    showDialog.value = true
+})
+</script>

+ 18 - 2
src/packages/digital/views/spot/components/account/index.vue

@@ -27,19 +27,22 @@
             <tfoot>
                 <tr>
                     <td colspan="2">
-                        <Button type="primary" size="small" v-if="!item.digitalaccountid">激活</Button>
+                        <Button type="primary" size="small" @click="activate(item)" v-if="!item.digitalaccountid">激活</Button>
                         <Button size="small" @click="navigateTo('wallet-deposit', item.digitalaccountid)">充值</Button>
                         <Button size="small" @click="navigateTo('wallet-withdraw', item.digitalaccountid)">提现</Button>
                     </td>
                 </tr>
             </tfoot>
         </table>
+        <component ref="componentRef" v-bind="{ selectedRow }" :is="componentMap.get(componentId)"
+            @closed="closeComponent" v-if="componentId" />
     </div>
 </template>
 
 <script lang="ts" setup>
-import { computed } from 'vue'
+import {shallowRef, computed, defineAsyncComponent } from 'vue'
 import { Button } from 'vant'
+import { useComponent } from '@/hooks/component'
 import { useNavigation } from '@mobile/router/navigation'
 import { getDigitalCurrencyName } from '@/constants/order'
 import { useFuturesStore } from '@/stores'
@@ -52,14 +55,27 @@ const props = defineProps({
     }
 })
 
+const componentMap = new Map<string, unknown>([
+    ['Activate', defineAsyncComponent(() => import('./activate/index.vue'))], // 激活
+])
+
+const { componentRef, componentId, openComponent, closeComponent } = useComponent()
+
 const { router } = useNavigation()
 const futuresStore = useFuturesStore()
 const spotAccountStore = useSpotAccountStore()
+const selectedRow = shallowRef<Model.TaaccountDigitalsRsp>()
 
 const { currencyid = 0, goodscurrencyid = 0 } = futuresStore.getQuoteInfo({ goodsid: props.goodsId }) ?? {}
 
 const accountList = computed(() => spotAccountStore.filterAccountsByCurrencyId(currencyid, goodscurrencyid))
 
+// 激活
+const activate = (item: Model.TaaccountDigitalsRsp) => {
+    selectedRow.value = item
+    openComponent('Activate')
+}
+
 const navigateTo = (name: string, accountId: string) => {
     router.push({
         name,

+ 22 - 8
src/services/api/digital/index.ts

@@ -2,11 +2,9 @@ import { v4 } from 'uuid'
 import { formatDate } from '@/filters'
 import { ClientType, OrderSrc } from '@/constants/client'
 import { RequestConfig } from '@/services/http/types'
-import { useLoginStore } from '@/stores'
+import { getUserId, getLoginId } from '@/services/methods/user'
 import http from '@/services/http'
 
-const loginStore = useLoginStore()
-
 /**
  * 获取用户现货账户列表
  */
@@ -15,7 +13,7 @@ export function queryTaaccountDigitals() {
         url: '/Digital/QueryTaaccountDigitals',
         method: 'post',
         params: {
-            userid: loginStore.userId
+            userid: getUserId()
         },
     })
 }
@@ -28,7 +26,7 @@ export function queryDigitalTradeOrderDetails(config: RequestConfig<Model.Digita
         url: '/Digital/QueryDigitalTradeOrderDetails',
         method: 'post',
         params: {
-            userid: loginStore.userId,
+            userid: getUserId(),
             ...config.data
         },
     })
@@ -42,7 +40,7 @@ export function queryDigitalTradeTradeDetails(config: RequestConfig<Model.Digita
         url: '/Digital/QueryDigitalTradeTradeDetails',
         method: 'post',
         params: {
-            userid: loginStore.userId,
+            userid: getUserId(),
             ...config.data
         },
     })
@@ -79,8 +77,8 @@ export function digitalOrder(config: RequestConfig<Partial<Proto.DigitalOrderReq
             ClientSerialNo: v4(),
             ClientType: ClientType.Web,
             OrderSrc: OrderSrc.ORDERSRC_CLIENT,
-            LoginID: loginStore.loginId,
-            OperatorID: loginStore.loginId,
+            LoginID: getLoginId(),
+            OperatorID: getLoginId(),
             ClientOrderTime: formatDate(new Date().toISOString()),
             ...config.data
         },
@@ -88,4 +86,20 @@ export function digitalOrder(config: RequestConfig<Partial<Proto.DigitalOrderReq
         responseCode: 'DigitalOrderRsp',
         marketId: config.data?.MarketID
     })
+}
+
+/**
+ * 数字账户激活请求
+ */
+export function digitalAccountActivate(config: RequestConfig<Partial<Proto.DigitalAccountActivateReq>>) {
+    return http.mqRequest<Proto.DigitalAccountActivateRsp>({
+        data: {
+            UserID: getUserId(),
+            ClientTicket: v4(),
+            OperateSrc: 2,
+            ...config.data
+        },
+        requestCode: 'DigitalAccountActivateReq',
+        responseCode: 'DigitalAccountActivateRsp'
+    })
 }

+ 47 - 0
src/types/proto/digital.d.ts

@@ -61,5 +61,52 @@ declare global {
             OrderID: number; // 一级生成的订单号
             OrderTime: string; // 接收委托交易的时间
         }
+
+        /** 数字账户激活请求 */
+        interface DigitalAccountActivateReq {
+            Header?: IMessageHead;
+            UserID: number; // 用户ID
+            CurrencyID: number; // 币种ID
+            OperateSrc: number; // 操作来源-枚举"operatesrc"(1:管理端,2:终端)
+            ClientTicket: string; // 客户端流水号
+            Remark?: string; // 备注
+        }
+        
+        /** 数字账户激活应答 */
+        interface DigitalAccountActivateRsp {
+            Header: IMessageHead;
+            RetCode: number; // 返回码
+            RetDesc: string; // 描述信息
+            DigitalAccountID: number; // 数字账户ID
+            TaAccountDigitalInfo: TaAccountDigital; // 数字账户信息
+            ClientTicket: string; // 客户端流水号
+        }
+
+        /** 数字账户信息 */
+        interface TaAccountDigital {
+            DigitalAccountID: number; // 数字账户ID
+            CurrencyID: number; // 币种ID
+            UserID: number; // 用户ID
+            CurrentBalance: number; // 期末余额
+            UsedMargin: number; // 占用保证金(交易)-正
+            FreezeMargin: number; // 冻结保证金(交易)-正
+            FreezeTradeCharge: number; // 交易手续费冻结-正
+            FreezeTransfer: number; // 转入转出冻结-正
+            FreezeInOut: number; // 充值提现冻结-正
+            TotalTradeAdd: number; // 累计交易增加-正
+            TotalTradeReduce: number; // 累计交易减少-负
+            TotalTradeCharge: number; // 累计交易手续费-负
+            TotalTransferIn: number; // 累计转入(合约与现货账户)-正
+            TotalTransferOut: number; // 累计转出(合约与现货账户)-负
+            TotalTransferInCharge: number; // 累计转入手续费-负
+            TotalTransferOutCharge: number; // 累计转出手续费-负
+            TotalIn: number; // 累计充值(现货账户与外部钱包)-正
+            TotalOut: number; // 累计提现(现货账户与外部钱包)-负
+            TotalInInCharge: number; // 累计充值手续费-负
+            TotalInOutCharge: number; // 累计提现手续费-负
+            SignedData: string; // SignedData
+            TradeStatus: number; // 交易状态-1:正常
+            Timestamp: number; // 时间戳
+        }
     }
 }