Handy_Cao 2 年 前
コミット
9b8131b2d8

+ 29 - 2
src/business/trade/index.ts

@@ -18,7 +18,8 @@ import {
     spotPresalePointPrice,
     cancelOrder,
     holderClose,
-    order
+    order,
+    offlineDelivery
 } from '@/services/api/trade'
 import { formatDate } from "@/filters";
 import Long from 'long'
@@ -585,4 +586,30 @@ export function useOrder() {
         formData,
         formSubmit
     }
-}
+}
+
+// 线下交收
+export function useOfflineDelivery() {
+    const loading = shallowRef(false)
+    const formData = reactive<Partial<Proto.OfflineDeliveryReq>>({})
+    /// 提交
+    const formSubmit = async () => {
+        try {
+            loading.value = true
+
+            return await offlineDelivery({
+                data: {
+                    ...formData
+                }
+            })
+        } finally {
+            loading.value = false
+        }
+    }
+
+    return {
+        loading,
+        formData,
+        formSubmit
+    }
+}

+ 2 - 0
src/constants/funcode.ts

@@ -102,4 +102,6 @@ export enum FunCode {
     MakeUpDepositRsp = 196716, // 补足定金应答
     HoldAppendDepositReq = 196719, // 持仓追加定金接口请求
     HoldAppendDepositRsp = 196720, // 持仓追加定金接口应答
+    OfflineDeliveryReq = 196723,   // 线下交收申请请求
+    OfflineDeliveryRsp = 196724,   // 线下交收申请请求
 } 

+ 6 - 5
src/packages/mobile/views/goods/detail/components/delisting/Index.vue

@@ -97,14 +97,15 @@ const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
     }],
 }
 
-// 提交
+// 提交
 const onSubmit = () => {
-    const { goodsid, orderid } = props.selectedRow
+    const { goodsid, orderid, orderprice, buyorsell} = props.selectedRow
     /// 获取对应的市场ID
     formData.MarketID = useFuturesStore().getGoods(goodsid).value?.marketid ?? 0
-    formData.PriceMode = EPriceMode.PRICEMODE_MARKET
+    formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
     formData.RelatedID = orderid
-    formData.BuyOrSell = props.selectedRow.buyorsell,
+    formData.OrderPrice = orderprice
+    formData.BuyOrSell = buyorsell === 0 ? 1 : 0,
     formData.GoodsID = goodsid
     formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTING
     formData.DelistingType = EDelistingType.DELISTINGTYPE_SELECTED
@@ -119,7 +120,7 @@ const onSubmit = () => {
     fullloading((hideLoading) => {
         formSubmit().then(() => {
             hideLoading()
-            dialog('牌提交成功。').then(() => closed(true))
+            dialog('牌提交成功。').then(() => closed(true))
         }).catch((err) => {
             hideLoading(err, 'fail')
         })

+ 1 - 1
src/packages/mobile/views/goods/detail/components/listing/Index.vue

@@ -86,7 +86,7 @@ const onSubmit = () => {
         formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
     formData.MarketMaxSub = 0.0
     formData.GoodsID = goodsid
-    formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_LISTING
+    formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
     formData.DelistingType = EDelistingType.DELISTINGTYPE_SELECTED
     formData.BuildType = EBuildType.BUILDTYPE_OPEN
     formData.ValidType = EValidType.VALIDTYPE_DR

+ 2 - 1
src/packages/mobile/views/order/list/components/goodsorder/list/Index.vue

@@ -101,7 +101,8 @@ const onCancelSumit = (item: Model.TradeOrderDetailRsp) => {
         message: '确认要撤销吗?',
         showCancelButton: true,
     }).then(() => {
-        formData.Header = { MarketID: item.marketid }
+
+        formData.Header = { MarketID: item.marketid, GoodsID: item.goodsid }
         formData.OldOrderId = item.orderid
 
         /// loding....

+ 114 - 0
src/packages/mobile/views/order/position/components/goods/close/Index.vue

@@ -0,0 +1,114 @@
+<!-- 我的订单- 订单持仓 - 平仓 -->
+<template>
+    <app-modal direction="right" height="100%" v-model:show="showModal" :refresh="refresh">
+        <app-view class="g-form">
+            <template #header>
+                <app-navbar title="订单持仓 - 平仓" @back="closed" />
+            </template>
+            <div v-if="props" class="order-detail__container g-form__container">
+                <CellGroup title="持仓信息">
+                    <Cell title="商品代码/名称" :value="selectedRow.goodscode + '/' + selectedRow.goodsname" />
+                    <Cell title="持仓方向" :value="getBuyOrSellName(selectedRow.buyorsell)" />
+                    <Cell title="持仓金额" :value="formatDecimal(selectedRow.holderamount)" />
+                    <Cell title="持仓数量" :value="formatDecimal(selectedRow.curpositionqty)" />
+                    <Cell title="冻结数量" :value="formatDecimal(selectedRow.frozenqty)" />
+                    <Cell title="可用数量" :value="formatDecimal(selectedRow.enableqty)" />
+                    <Cell title="持仓均价" :value="formatDecimal(selectedRow.averageprice)" />
+                    <Cell title="参考损益" :value="'--'" />
+                </CellGroup>
+                <CellGroup title="平仓信息">
+                    <Cell title="当前价" :value="'--'" />
+                    <Form class="goods-close__form" ref="formRef" @submit="onCloseSumit" v-if="props">
+                        <Field name="OrderQty" :rules="formRules.OrderQty" label="平仓数量">
+                            <template #input>
+                                <Stepper v-model="formData.OrderQty" input-width="100" theme="round" button-size="22" :min="0" :step="0.01" :max="selectedRow.enableqty" :auto-fixed="false" />
+                            </template>
+                        </Field>
+                    </Form>
+                </CellGroup>
+            </div>
+            <template #footer>
+                <Button type="primary" block round @click="onCloseSumit">平仓</Button>
+            </template>
+        </app-view>
+    </app-modal>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef, PropType } from 'vue'
+import AppModal from '@/components/base/modal/index.vue'
+import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper } from 'vant'
+import { getBuyOrSellName } from '@/constants/order'
+import { formatDecimal } from '@/filters'
+import { useOrder } from '@/business/trade'
+import { dialog, fullloading } from '@/utils/vant'
+import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
+
+const showModal = shallowRef(true)
+// 是否刷新父组件数据
+const refresh = shallowRef(false)
+const { formSubmit, formData } = useOrder()
+
+const props = defineProps({
+    selectedRow: {
+        type: Object as PropType<Model.TradePositionRsp>,
+        required: true,
+    }
+})
+
+// 表单验证规则
+const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
+    OrderQty: [{
+        message: '请输入平仓数量',
+        validator: () => {
+            return !!formData.OrderQty
+        }
+    }],
+}
+
+const onCloseSumit = () => {
+    dialog({
+        message: '确认要撤销吗?',
+        showCancelButton: true,
+    }).then(() => {
+
+        const { marketid, goodsid, buyorsell, averageprice} = props.selectedRow
+        /// 市场ID
+        formData.Header = { MarketID: marketid, GoodsID: goodsid }
+        formData.MarketID = marketid
+        formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
+        formData.OrderPrice = averageprice
+        formData.BuyOrSell = buyorsell === 0 ? 1 : 0,
+        formData.GoodsID = goodsid
+        formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTING
+        formData.DelistingType = EDelistingType.DELISTINGTYPE_PRICE
+        formData.BuildType = EBuildType.BUILDTYPE_CLOSE
+        formData.ValidType = EValidType.VALIDTYPE_DR
+        formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
+        formData.TriggerType = 0
+        formData.ServiceTime = ""
+        formData.ValidTime = ""
+
+        /// loding....
+        fullloading((hideLoading) => {
+            formSubmit().then(() => {
+                hideLoading('平仓成功')
+                closed(true)
+            }).catch((err) => {
+                hideLoading(err, 'fail')
+            })
+        })
+    })
+}
+
+// 关闭弹窗
+const closed = (isRefresh = false) => {
+    refresh.value = isRefresh
+    showModal.value = false
+}
+
+// 暴露组件属性给父组件调用
+defineExpose({
+    closed,
+})
+</script>

+ 110 - 0
src/packages/mobile/views/order/position/components/goods/delivery/Index.vue

@@ -0,0 +1,110 @@
+<!-- 我的订单- 订单持仓 - 交收 -->
+<template>
+    <app-modal direction="right" height="100%" v-model:show="showModal" :refresh="refresh">
+        <app-view class="g-form">
+            <template #header>
+                <app-navbar title="订单持仓 - 交收" @back="closed" />
+            </template>
+            <div v-if="props" class="order-detail__container g-form__container">
+                <CellGroup title="持仓信息">
+                    <Cell title="商品代码/名称" :value="selectedRow.goodscode + '/' + selectedRow.goodsname" />
+                    <Cell title="持仓方向" :value="getBuyOrSellName(selectedRow.buyorsell)" />
+                    <Cell title="持仓金额" :value="formatDecimal(selectedRow.holderamount)" />
+                    <Cell title="持仓数量" :value="formatDecimal(selectedRow.curpositionqty)" />
+                    <Cell title="冻结数量" :value="formatDecimal(selectedRow.frozenqty)" />
+                    <Cell title="可用数量" :value="formatDecimal(selectedRow.enableqty)" />
+                    <Cell title="持仓均价" :value="formatDecimal(selectedRow.averageprice)" />
+                    <Cell title="参考损益" :value="'--'" />
+                </CellGroup>
+                <CellGroup title="交收信息">
+                    <Cell title="交收对手方" :value="'--'" />
+                    <Form class="goods-close__form" ref="formRef" @submit="onDeliverySumit" v-if="props">
+                        <Field name="DeliveryLot" :rules="formRules.DeliveryLot" label="交收数量">
+                            <template #input>
+                                <Stepper v-model="formData.DeliveryLot" input-width="100" theme="round" button-size="22" :min="0" :step="0.01" :max="selectedRow.enableqty" :auto-fixed="false" />
+                            </template>
+                        </Field>
+                        <Field name="DeliveryInfo" :rules="formRules.DeliveryLot" label="交收信息" placeholder="请输入交收信息">
+                        </Field>
+                    </Form>
+                </CellGroup>
+            </div>
+            <template #footer>
+                <Button type="primary" block round @click="onDeliverySumit">交收</Button>
+            </template>
+        </app-view>
+    </app-modal>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef, PropType } from 'vue'
+import AppModal from '@/components/base/modal/index.vue'
+import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper} from 'vant'
+import { getBuyOrSellName } from '@/constants/order'
+import { formatDecimal } from '@/filters'
+import { useOfflineDelivery } from '@/business/trade'
+import { dialog, fullloading } from '@/utils/vant'
+
+const showModal = shallowRef(true)
+// 是否刷新父组件数据
+const refresh = shallowRef(false)
+const { formSubmit, formData } = useOfflineDelivery()
+
+const props = defineProps({
+    selectedRow: {
+        type: Object as PropType<Model.TradePositionRsp>,
+        required: true,
+    }
+})
+
+// 表单验证规则
+const formRules: { [key in keyof Proto.OfflineDeliveryReq]?: FieldRule[] } = {
+    DeliveryLot: [{
+        message: '请输入交收数量',
+        validator: () => {
+            return !!formData.DeliveryLot
+        }
+    }],
+    DeliveryInfo: [{
+        message: '请输入交收信息',
+        validator: () => {
+            return !!formData.DeliveryInfo
+        }
+    }],
+}
+
+const onDeliverySumit = () => {
+    dialog({
+        message: '确认要交收吗?',
+        showCancelButton: true,
+    }).then(() => {
+        const { marketid, goodsid, goodscode, buyorsell }  = props.selectedRow
+        /// 市场ID
+        formData.Header = { MarketID: marketid, GoodsID: goodsid }
+        formData.GoodsCode = goodscode
+        formData.GoodsID = goodsid
+        formData.BuyOrSell = buyorsell
+	
+        /// loding....
+        fullloading((hideLoading) => {
+            formSubmit().then(() => {
+                hideLoading('交收成功')
+                closed(true)
+            }).catch((err) => {
+                hideLoading(err, 'fail')
+            })
+        })
+    })
+}
+
+// 关闭弹窗
+const closed = (isRefresh = false) => {
+    refresh.value = isRefresh
+    showModal.value = false
+}
+
+// 暴露组件属性给父组件调用
+defineExpose({
+    closed,
+})
+</script>

+ 18 - 1
src/services/api/trade/index.ts

@@ -2,7 +2,7 @@ import { v4 } from 'uuid'
 import http from '@/services/http'
 import { RequestConfig } from '@/services/http/types'
 import { ClientType } from '@/constants/client'
-import { useLoginStore, useAccountStore } from '@/stores'
+import { useLoginStore, useAccountStore,useUserStore } from '@/stores'
 
 const loginStore = useLoginStore()
 const accountStore = useAccountStore()
@@ -251,4 +251,21 @@ export function holdAppendDeposit(config: RequestConfig<Partial<Proto.HoldAppend
         responseCode: 'HoldAppendDepositRsp',
         marketId: 49201
     })
+}
+
+/**
+ * 线下交收申请请求
+ */
+export function offlineDelivery(config: RequestConfig<Partial<Proto.OfflineDeliveryReq>>) {
+    return http.mqRequest<Proto.OfflineDeliveryRsp>({
+        data: {
+            AccountID: accountStore.accountId,
+            ClientTicket: v4(),
+            UserID: loginStore.userId,
+            ...config.data
+        },
+        requestCode: 'OfflineDeliveryReq',
+        responseCode: 'OfflineDeliveryRsp',
+        marketId: 49201
+    })
 }

+ 23 - 0
src/types/proto/trade.d.ts

@@ -577,5 +577,28 @@ declare global {
             AccountID: number; // 交易账号,必填
             ClientSerialNo: string; // 客户端流水号
         }
+
+        // 线下交收申请请求
+        interface OfflineDeliveryReq {
+            Header?: IMessageHead; // 消息头
+			AccountID?: number; // 账号ID
+			UserID?: number; // 用户ID
+			GoodsCode?: string; // 商品代码
+            GoodsID?: number; // 商品ID
+			BuyOrSell?: number; // 方向
+			DeliveryLot?: number; // 交收手数
+			DeliveryInfo?: string; // 交收信息
+			ClientTicket?: string; // 客户端流水号
+        }
+        // 线下交收申请请求
+        interface OfflineDeliveryRsp {
+            Header?: IMessageHead; // 消息头
+            RetCode: number; // 返回码
+            RetDesc: string; // 描述信息
+            AccountID: number; // 交易账号,必填
+            UserID: number; // 用户ID
+            ApplyID: number; // 申请ID
+            ClientTicket: string; // 客户端流水号
+        }
     }
 }