huangbin 4 年 前
コミット
f465ea80b4

+ 15 - 15
src/services/proto/warehousetrade/interface.ts

@@ -203,7 +203,7 @@ export interface PaymentArrearsRsp {
 // 融资申请撤单请求 0 22 22
 export interface WRTradeFinanceBuyCancelReq {
     AccountID: number // uint64 资金账号
-    FinanceApplyID : number // uint64 融资申请单ID
+    FinanceApplyID: number // uint64 融资申请单ID
     ClientSerialNo: string // string 客户端流水号
 }
 // 融资申请撤单应答 0 22 23
@@ -211,7 +211,7 @@ export interface WRTradeFinanceBuyCancelRsp {
     RetCode: number // int32 返回码
     RetDesc: string // string 描述信息
     FinanceApplyID: number // uint64 融资申请单ID
-    ClientSerialNo : string // string 客户端流水号
+    ClientSerialNo: string // string 客户端流水号
 }
 
 // 仓单出入库注销请求 0 29 110
@@ -260,18 +260,18 @@ export interface DeliveryOrderReq {
     AccountID: number // uint64 交易账号
     XGoodsID: number // uint32 主商品ID(交割合约)
     PGoodsID: number // uint32 辅助商品ID(辅助合约)
-    P2GoodsID: number // uint32 辅助商品ID(辅助合约2)
+    P2GoodsID?: number // uint32 辅助商品ID(辅助合约2)
     DeliveryGoodsID: number // uint32 交割商品ID
     XQty: number // uint64 交割合约数量
     PQty: number // uint64 辅助合约数量
-    P2Qty: number // uint64 辅助合约2数量
+    P2Qty?: number // uint64 辅助合约2数量
     DeliveryQty: number // uint64 交割商品仓单数量
     OperateType: number // uint32 操作类型:
     OrderSrc: number // uint32 单据来源
     OperatorID: number // uint32 操作员账号ID
     DeliveryOrderDetail: DeliveryOrderDetail // DeliveryOrderDetail 关联仓单头寸
-    TakeMode: number // uint32 提货方式
-    ReceiverAddress: string // string 提货地址
+    TakeMode?: number // uint32 提货方式
+    ReceiverAddress?: string // string 提货地址
 }
 // 交割申报应答 0 6 2
 export interface DeliveryOrderRsp {
@@ -286,15 +286,15 @@ export interface DeliveryOrderRsp {
 export interface DeliveryOrderDetail {
     AccountID: number // uint64 对手方账号
     Qty: number // uint64 点选数量
-    BrandID : number // uint32 品牌
-    QualityID : number // uint32 品质
-    StandardID: number // uint32 规格
-    WarehouseID: number // uint32 仓库
-    DeliveryMonthID: number // uint32 月份
-    ReceiverAddress: string // string 提货地址
-    TakeMode : number // uint32 提货方式
+    BrandID?: number // uint32 品牌
+    QualityID?: number // uint32 品质
+    StandardID?: number // uint32 规格
+    WarehouseID?: number // uint32 仓库
+    DeliveryMonthID?: number // uint32 月份
+    ReceiverAddress?: string // string 提货地址
+    TakeMode?: number // uint32 提货方式
     LadingBillID: number // uint64 提单ID
-    SubNum : number // uint64 提单子单号
+    SubNum: number // uint64 提单子单号
     WRFactorTypeID: number // uint64 仓单要素类型ID
 }
 
@@ -308,7 +308,7 @@ export interface WrBargainNoAgreeReq {
 }
 // 议价申请审核响应 0 29 60
 export interface WrBargainNoAgreeRsp {
-    RetCode : number // int32 返回码
+    RetCode: number // int32 返回码
     RetDesc: string // string 描述信息
 }
 

+ 73 - 17
src/views/order/commodity_contract/components/commodity_contract_summary/components/commodity_contract_summary_settlement/index.vue

@@ -70,7 +70,8 @@
               </div>
               <div class="yellow">升贴水1100</div>
             </div>
-            <div class="line2">
+            <div class="line2"
+                 v-if="isBaseSpread()">
               <div>点价合约</div>
               <div class="right">
                 <div>{{selectedRow.goodscode}}</div>
@@ -117,6 +118,13 @@ import { queryWrDeliveryAvalidHoldLB } from '@/services/go/wrtrade';
 import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
 import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue';
 import { handleCheck, getTableList, handleCalculation } from './setup';
+import { DeliveryOrder } from '@/services/proto/warehousetrade';
+import { handleDeliveryRelation } from '@/common/setup/deliveryRelation';
+import { v4 } from 'uuid';
+import moment from 'moment';
+import { DeliveryOrderReq } from '@/services/proto/warehousetrade/interface';
+import { getLongTypeLoginID } from '@/services/bus/login';
+import { message } from 'ant-design-vue';
 
 export default defineComponent({
     name: ModalEnum.commodity_contract_summary_settlement,
@@ -135,25 +143,65 @@ export default defineComponent({
     setup(props, context) {
         const { visible, cancel } = _closeModal(context);
         const loading = ref<boolean>(false);
+        const { goodsid } = props.selectedRow;
         // 合约交收可点选仓单
-        const { tableList } = getTableList(props.selectedRow.goodsid);
+        const { tableList } = getTableList(goodsid);
         // check 是否选中逻辑
-        const { checked, selected, checkGroupChange, isChecked, checkboxChange } = handleCheck();
+        const { checked, selected, deliveryGoods, checkGroupChange, isChecked, checkboxChange, isBaseSpread } = handleCheck();
+        // 各种计算
+        const { getStepValue, getCanSettlementNum, getNeedContractNum, getEstimatedPayment, XQty, PQty, getDeliveryGoodsPrice, increase, decrease, selctedNum } = handleCalculation(props.selectedRow);
 
         function submit() {
-            // validateAction<FormState>(formRef, formState).then((param) => {
-            //     // 违约申请
-            //     const paramReq: PerformanceContractedApplyReq = {
-            //         PerformancePlanID: Long.fromString(props.selectedRow.performanceplanid), // uint64 履约计划ID
-            //         BreachType: props.selectedRow.buyaccountid === getSelectedAccountId() ? 2 : 1, // uint32 违约方类型 买履约是2 卖履约是1 (刘工说是黄工说的 )
-            //         Applicant: getUserId(), // uint64 违约申请人
-            //         ApplyRemark: param.remark, // string 申请备注
-            //         Attachment: '', // string 附件
-            //     };
-            //     requestResultLoadingAndInfo(performanceContractedApply, paramReq, loading, ['申请违约成功', '申请违约失败:']).then(() => {
-            //         cancel(true);
-            //     });
-            // });
+            if (!selected.value) {
+                message.warn('请选择合约');
+                return;
+            }
+            if (!selected.value.num) {
+                message.warn('请输入选择数量');
+                return;
+            }
+
+            if (deliveryGoods.value) {
+                loading.value = true;
+                console.log(deliveryGoods.value);
+                const param: DeliveryOrderReq = {
+                    ClientSerialNo: v4(), // 客户端流水号
+                    ClientOrderTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), // 客户端委托时间
+                    ClientType: 4, // 终端类型
+                    // goodsID: goodsid,
+                    // marketid,
+                    AccountID: getSelectedAccountId(),
+                    XGoodsID: goodsid,
+                    PGoodsID: deliveryGoods.value.pgoodsid,
+                    DeliveryGoodsID: deliveryGoods.value.deliverygoodsid,
+                    XQty: Long.fromNumber(XQty()),
+                    PQty: Long.fromNumber(PQty()),
+                    OperateType: 0,
+                    OrderSrc: 0,
+                    OperatorID: Number(getLongTypeLoginID()),
+                    DeliveryQty: selected.value.num,
+                    DeliveryOrderDetail: {
+                        AccountID: getSelectedAccountId(),
+                        Qty: selected.value.num,
+                        LadingBillID: Long.fromNumber(selected.value.ladingbillid),
+                        WRFactorTypeID: Long.fromNumber(selected.value.wrfactortypeid),
+                        SubNum: selected.value.subnum,
+                    },
+                };
+                console.log('param', param);
+                DeliveryOrder(param)
+                    .then((res) => {
+                        message.success('提交成功');
+                    })
+                    .catch((err) => {
+                        console.log('err', err);
+                    })
+                    .finally(() => {
+                        loading.value = false;
+                    });
+            } else {
+                message.warn('未找到对应的交割商品');
+            }
         }
         return {
             visible,
@@ -165,7 +213,15 @@ export default defineComponent({
             checkboxChange,
             checked,
             isChecked,
-            ...handleCalculation(props.selectedRow),
+            isBaseSpread,
+            getStepValue,
+            getCanSettlementNum,
+            getNeedContractNum,
+            getEstimatedPayment,
+            getDeliveryGoodsPrice,
+            increase,
+            decrease,
+            selctedNum,
         };
     },
 });

+ 64 - 21
src/views/order/commodity_contract/components/commodity_contract_summary/components/commodity_contract_summary_settlement/setup.ts

@@ -1,32 +1,50 @@
 import { handleDeliveryRelation } from "@/common/setup/deliveryRelation";
 import { getSelectedAccountId } from "@/services/bus/account";
 import { getQuoteDayInfoByCode } from "@/services/bus/goods";
+import { QueryDeliveryRelationRsp } from "@/services/go/delivery/interface";
 import { QueryTradePositionRsp } from "@/services/go/ermcp/order/interface";
 import { queryWrDeliveryAvalidHoldLB } from "@/services/go/wrtrade";
 import { QueryWrDeliveryAvalidHoldLBReq } from "@/services/go/wrtrade/interface";
 import { ref } from "vue";
 import { DBType } from "./interface";
 
+// 选中的交收合约
+const selected = ref<DBType>()
+const checked = ref<string>();
+// 交割商品
+const deliveryGoods = ref<QueryDeliveryRelationRsp | undefined>();
+
 // 查询合约交收可点选仓单
 export function getTableList(goodsid: number) {
+    // 交割商品
+    const { getItemDeliveryRelationByGoodsId } = handleDeliveryRelation()
     const param: QueryWrDeliveryAvalidHoldLBReq = {
         goodsid,
         accountid: getSelectedAccountId(),
     };
     const tableList = ref<DBType[]>([]);
     queryWrDeliveryAvalidHoldLB(param).then((res) => {
-        tableList.value = res.map((e) => {
-            return { ...e, checked: false, num: 0 };
+        tableList.value = res.map((e, i) => {
+            if (i) {
+                return { ...e, checked: false, num: 0 };
+            } else {
+                // 默认勾选第一个
+                checked.value = e.ladingbillid
+                const result = { ...e, checked: true, num: 0 };
+                selected.value = result
+                deliveryGoods.value = getItemDeliveryRelationByGoodsId(e.goodsid).value
+                return result
+            }
         });
     });
     return { tableList }
 }
 
-// 选中的交收合约
-const selected = ref<DBType>()
+
 
 export function handleCheck() {
-    const checked = ref<string>();
+    // 交割商品
+    const { getItemDeliveryRelationByGoodsId } = handleDeliveryRelation()
 
     function checkGroupChange(checkedValue: string[]) {
         checked.value = checkedValue[checkedValue.length - 1];
@@ -36,23 +54,32 @@ export function handleCheck() {
     }
     function checkboxChange(item: DBType) {
         selected.value = item;
+        deliveryGoods.value = getItemDeliveryRelationByGoodsId(item.goodsid).value
     }
-    return { checked, selected, checkGroupChange, isChecked, checkboxChange }
+    // true 基差点价; false 挂牌点选
+    function isBaseSpread() {
+        if (deliveryGoods.value) {
+            // 1和3是订单交易 挂牌转让
+            // 2和4是基差点价
+            const arr = [2, 3]
+            return arr.includes(deliveryGoods.value.deliverytype)
+        } else {
+            return false
+        }
+    }
+    return { checked, selected, deliveryGoods, checkGroupChange, isChecked, checkboxChange, isBaseSpread }
 }
 
 export function handleCalculation(selectedRow: QueryTradePositionRsp) {
     // 商品合约单位
-    const { agreeunit, goodsid, goodscode, decimalplace, enableqty } = selectedRow
-    // 交割商品
-    const { getItemDeliveryRelationByGoodsId } = handleDeliveryRelation()
-    const deliveryRetation = getItemDeliveryRelationByGoodsId(goodsid)
+    const { agreeunit, goodscode, decimalplace, enableqty } = selectedRow
     function selctedNum() {
         return selected.value ? selected.value.num : '--'
     }
     // 选中数量的 最小变动值 = 合约单位 * 最小交割系数 * 仓单商品的单位r2
     function getStepValue() {
-        if (deliveryRetation.value) {
-            const { rratio2, mindeliveryqty } = deliveryRetation.value
+        if (deliveryGoods.value) {
+            const { rratio2, mindeliveryqty } = deliveryGoods.value
             return agreeunit * mindeliveryqty * rratio2
         } else {
             return agreeunit
@@ -60,23 +87,39 @@ export function handleCalculation(selectedRow: QueryTradePositionRsp) {
     }
     // 可交收数量 = 合约可用手数 * 合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1)
     function getCanSettlementNum() {
-        if (deliveryRetation.value) {
-            const { rratio1, rratio2, mindeliveryqty } = deliveryRetation.value
+        if (deliveryGoods.value) {
+            const { rratio1, rratio2, mindeliveryqty } = deliveryGoods.value
             const result = enableqty * agreeunit * mindeliveryqty * (rratio2 / rratio1)
             return result.toFixed(2)
         } else {
             return '--'
         }
     }
-    // 需要合约手数 = (选中的数量 / (合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1))) / (p1合约系数 / x合约系数)
-    function getNeedContractNum() {
+    // (选中的数量 / (合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1)))
+    function XQty() {
         let result = 0
         if (selected.value?.num) {
-            if (deliveryRetation.value) {
-                const { rratio1, rratio2, mindeliveryqty, xdeliveryratio, pdeliveryratio } = deliveryRetation.value
-                result = selected.value.num / (agreeunit * mindeliveryqty * (rratio2 / rratio1)) / pdeliveryratio / xdeliveryratio
+            if (deliveryGoods.value) {
+                const { rratio1, rratio2, mindeliveryqty, xdeliveryratio, pdeliveryratio } = deliveryGoods.value
+                result = selected.value.num / (agreeunit * mindeliveryqty * (rratio2 / rratio1))
+            }
+        }
+        return result
+    }
+    // 需要合约手数 = (选中的数量 / (合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1))) / (p1合约系数 / x合约系数)
+    function PQty() {
+        let result = XQty()
+        if (result) {
+            if (deliveryGoods.value) {
+                const { xdeliveryratio, pdeliveryratio } = deliveryGoods.value
+                result = result / pdeliveryratio / xdeliveryratio
             }
         }
+        return result
+    }
+    // 需要合约手数 = (选中的数量 / (合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1))) / (p1合约系数 / x合约系数)
+    function getNeedContractNum() {
+        const result = PQty()
         return result ? result.toFixed(decimalplace) : '--'
     }
     // 预估货款 = 需要合约手数  * 合约交割价 * 合约单位 + 升贴水
@@ -86,7 +129,7 @@ export function handleCalculation(selectedRow: QueryTradePositionRsp) {
         let result = 0
         if (selected.value) {
             if (num !== '--' && price !== '--') {
-                if (deliveryRetation.value) {
+                if (deliveryGoods.value) {
                     result = (+num) * (+price) * agreeunit + selected.value.pricemove
                 }
             }
@@ -134,5 +177,5 @@ export function handleCalculation(selectedRow: QueryTradePositionRsp) {
             value.num = +value.num.toFixed(decimalplace)
         }
     }
-    return { getStepValue, getCanSettlementNum, getNeedContractNum, getEstimatedPayment, getDeliveryGoodsPrice, increase, decrease, selctedNum }
+    return { getStepValue, getCanSettlementNum, getNeedContractNum, getEstimatedPayment, XQty, PQty, getDeliveryGoodsPrice, increase, decrease, selctedNum }
 }