From 188836b06a3f20c86f1b1f2129f3d50bd40c89b7 Mon Sep 17 00:00:00 2001
From: 18650502300 <18650502300@163.com>
Date: Wed, 2 Oct 2024 18:33:10 +0800
Subject: [PATCH] =?UTF-8?q?1.=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/views/system/channel/index.vue       | 14 ++--
 src/views/system/device/index.vue        |  7 +-
 src/views/system/fee/index.vue           |  2 +-
 src/views/system/order/index.vue         | 86 ++++++++++++++++++++----
 src/views/system/withdrawAudit/index.vue |  2 +-
 5 files changed, 86 insertions(+), 25 deletions(-)

diff --git a/src/views/system/channel/index.vue b/src/views/system/channel/index.vue
index ab0f8e9..f364d1d 100644
--- a/src/views/system/channel/index.vue
+++ b/src/views/system/channel/index.vue
@@ -86,36 +86,36 @@
         <el-row>
           <el-col :span="12">
             <el-form-item label="商户号" prop="merchantId">
-              <el-input style="width: 100%" v-model="form.merchantId" placeholder="请输入商户号" />
+              <el-input style="width: 100%" v-model="form.merchantId" placeholder="请输入商户号" disabled />
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="apiV3密钥" prop="apiV3Key">
-              <el-input v-model="form.apiV3Key" placeholder="请输入apiV3密钥" />
+              <el-input v-model="form.apiV3Key" placeholder="请输入apiV3密钥" disabled />
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="12">
             <el-form-item label="通知回调地址" label-width="100" prop="notifyUrl">
-              <el-input style="width: 66%" v-model="form.notifyUrl" placeholder="请输入通知回调地址" />
+              <el-input style="width: 66%" v-model="form.notifyUrl" placeholder="请输入通知回调地址" disabled />
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="密钥所在位置" label-width="100" prop="privateKeyPath">
-              <el-input style="width: 70%" v-model="form.privateKeyPath" placeholder="请输入密钥所在位置" />
+              <el-input style="width: 70%" v-model="form.privateKeyPath" placeholder="请输入密钥所在位置" disabled />
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="12">
-            <el-form-item label="证书序列号" label-width="90"  prop="merchantSerialNumber">
-              <el-input style="width: 70%" v-model="form.merchantSerialNumber" placeholder="请输入证书序列号" />
+            <el-form-item label="证书序列号" label-width="90" prop="merchantSerialNumber">
+              <el-input style="width: 70%" v-model="form.merchantSerialNumber" placeholder="请输入证书序列号" disabled />
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="退款回调地址" label-width="100" prop="refundNotifyUrl">
-              <el-input style="width: 70%" v-model="form.refundNotifyUrl" placeholder="请输入退款回调地址" />
+              <el-input style="width: 70%" v-model="form.refundNotifyUrl" placeholder="请输入退款回调地址" disabled />
             </el-form-item>
           </el-col>
         </el-row>
diff --git a/src/views/system/device/index.vue b/src/views/system/device/index.vue
index c52a6c6..bb0aa01 100644
--- a/src/views/system/device/index.vue
+++ b/src/views/system/device/index.vue
@@ -6,16 +6,14 @@
       size="small"
       :inline="true"
       v-show="showSearch"
-      label-width="68px"
-    >
+      label-width="68px">
       <el-form-item label="代理商" prop="deptId" v-if="userName == 'admin'">
         <el-select
           v-model="queryParams.deptId"
           filterable
           placeholder="选择代理商"
           style="width: 120px"
-          clearable
-        >
+          clearable>
           <el-option
             v-for="item in deptOptions"
             :key="item.deptId"
@@ -615,6 +613,7 @@
             <el-select
               v-model="form.deptId"
               clearable
+              filterable
               placeholder="请选择代理商"
             >
               <el-option
diff --git a/src/views/system/fee/index.vue b/src/views/system/fee/index.vue
index ff01ae1..3b1528a 100644
--- a/src/views/system/fee/index.vue
+++ b/src/views/system/fee/index.vue
@@ -94,7 +94,7 @@
         <el-row>
           <el-col :span="12" v-if="userName == 'admin'">
             <el-form-item label="代理商" prop="deptId" >
-              <el-select v-model="form.deptId" placeholder="请选择运营区">
+              <el-select v-model="form.deptId" filterable placeholder="请选择代理商">
                 <el-option
                   v-for="item in deptOptions"
                   :key="item.deptId"
diff --git a/src/views/system/order/index.vue b/src/views/system/order/index.vue
index 9bca6f4..d47a9d5 100644
--- a/src/views/system/order/index.vue
+++ b/src/views/system/order/index.vue
@@ -1,6 +1,21 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="代理商" prop="deptId" v-if="userName == 'admin'">
+        <el-select
+          v-model="queryParams.deptId"
+          filterable
+          placeholder="选择代理商"
+          style="width: 120px"
+          clearable>
+          <el-option
+            v-for="item in deptOptions"
+            :key="item.deptId"
+            :label="item.deptName"
+            :value="item.deptId"
+          ></el-option>
+        </el-select>
+      </el-form-item>
       <el-form-item label="运营区" prop="areaId" v-if="userName == 'admin'">
         <el-select v-model="queryParams.areaId" filterable placeholder="请选择运营区" clearable>
           <el-option
@@ -194,8 +209,12 @@
 <!--      <el-table-column label="金额(元)" align="center" prop="totalFee" width="70"/>-->
       <el-table-column label="费用详情" header-align="center" align="left" width="200">
         <template slot-scope="scope">
-          <div>
-            <template >
+<!--          {{scope.row.status}}-->
+<!--          <div v-if="scope.row.status == '2'"> &lt;!&ndash; 如果状态是骑行中 &ndash;&gt;-->
+<!--            <span>预估金额:{{ calculateEstimateFee(scope.row) }}</span><br />-->
+<!--          </div>-->
+          <div> <!-- 其他状态下显示费用详情 -->
+            <template>
               <span>结算金额:{{ formatFee(calculateSettlementAmount(scope.row)) }}</span><br />
             </template>
             <template v-if="scope.row.appointmentFee > 0">
@@ -210,13 +229,13 @@
             <template v-if="scope.row.manageFee > 0">
               <span>停车点外调度费:{{ formatFee(scope.row.manageFee) }}</span><br />
             </template>
-            <template v-if="scope.row.manageFee > 0">
-              <span >订单金额:{{ formatFee(scope.row.payFee) }}</span><br />
+            <template v-if="scope.row.payFee > 0">
+              <span>订单金额:{{ formatFee(scope.row.payFee) }}</span><br />
             </template>
             <template v-if="scope.row.totalRefundFee > 0">
-              <span>退款金额:
-                <span  style="font-weight: bold;color: red">{{ formatFee(scope.row.totalRefundFee) }}</span>
-              </span><br />
+        <span>退款金额:
+          <span style="font-weight: bold;color: red">{{ formatFee(scope.row.totalRefundFee) }}</span>
+        </span><br />
             </template>
           </div>
         </template>
@@ -225,7 +244,7 @@
       <el-table-column label="备注" align="center" prop="mark" width="140"/>
 <!--      <el-table-column label="交易金额" align="center" prop="amount" :formatter="formatAmount"/>-->
       <el-table-column label="手续费" align="center" prop="handlingCharge" :formatter="formatAmount"/>
-      <el-table-column label="成本" align="center" prop="handlingCharge" :formatter="formatAmount"/>
+      <el-table-column label="成本" align="center" prop="cost" :formatter="formatAmount"/>
       <el-table-column label="服务费" align="center" prop="platformServiceFee" :formatter="formatAmount"/>
 <!--      <el-table-column label="到账金额" align="center" prop="platformServiceFee" :formatter="formatAmount"/>-->
 <!--      <el-table-column label="订单时长" align="center" prop="duration" :formatter="formatDuration"/>-->
@@ -535,6 +554,8 @@
   } from '@/api/system/order'
 import TrajectoryMap from '@/components/Map/TrajectoryMap'
   import { getArea, optionselect as getAreaOptionselect } from '@/api/system/area'
+  import { getFee } from '@/api/system/fee'
+  import { listDept2 } from '@/api/system/dept'
 
 export default {
   name: "Order",
@@ -556,6 +577,7 @@ export default {
       // 通过key重新渲染area-map组件
       key: 0,
       areaOptions: [],
+      deptOptions: [],
       // 总条数
       total: 0,
       view: false,
@@ -656,6 +678,7 @@ export default {
     this.reset2();
     this.getList();
     this.getAreaList();
+    this.getDeptList();
   },
   watch: {
     open(val) {
@@ -669,6 +692,11 @@ export default {
     }
   },
   methods: {
+    getDeptList() {
+      listDept2({ status: "0", pageNum: 1, pageSize: 999 }).then((response) => {
+        this.deptOptions = response.rows;
+      });
+    },
     formatAmount(row, column) {
       const key = column.property;
       return parseFloat(row[key] || 0).toFixed(2);
@@ -846,6 +874,7 @@ export default {
     },
     //金额格式化,如果金额是null,则返回0.00,如果本来就是两位小数则直接返回,否则保留两位小数
     formatFee(fee){
+      console.log("formatFee:"+fee)
       if (!fee) return '0.00元';
       const feeStr = fee.toString();
       const twoDecimalPattern = /^\d+(\.\d{2})?$/;
@@ -855,6 +884,42 @@ export default {
       const formattedFee = parseFloat(fee).toFixed(2);
       return `${formattedFee}元`;
     },
+
+    calculateEstimateFee(row) {
+      const ridingRule = JSON.parse( row.ridingRuleJson);
+      console.log("ridingRule",ridingRule)
+      const startingPrice = parseFloat(ridingRule.startingPrice);
+      const startingTime = parseInt(ridingRule.startingTime);
+      const timeoutPrice = parseFloat(ridingRule.timeoutPrice);
+      const timeoutTime = parseInt(ridingRule.timeoutTime);
+
+      console.log("ridingRule:" + JSON.stringify(ridingRule));
+
+      const createTime = new Date(row.createTime);
+      const currentTime = new Date();
+      const durationMinutes = Math.floor((currentTime - createTime) / (1000 * 60)); // 骑行时长(分钟)
+
+      // 计算预估费用
+      let estimatedFee = startingPrice;
+      if (durationMinutes > startingTime) {
+        const extraTime = durationMinutes - startingTime;
+        const extraCharges = Math.ceil(extraTime / timeoutTime) * timeoutPrice;
+        estimatedFee += extraCharges;
+      }
+      console.log("durationMinutes:" + durationMinutes);
+      console.log("estimatedFee:" + estimatedFee);
+      // 格式化费用
+      if (!estimatedFee) return '0.00元';
+      const feeStr = estimatedFee.toString();
+      const twoDecimalPattern = /^\d+(\.\d{2})?$/;
+      console.log("feeStr:" + feeStr)
+      if (twoDecimalPattern.test(feeStr)) {
+        return `${feeStr}元`;
+      }
+      const formattedFee = parseFloat(estimatedFee).toFixed(2);
+      console.log("formattedFee:" + formattedFee)
+      return `${formattedFee}元`;
+    },
     calculateSettlementAmount(row) {
       // 计算结算金额 = 总费用 - 退款金额
       const payFee = row.payFee || 0;
@@ -901,10 +966,7 @@ export default {
     },
     formatDuration(row) {
       const createTime = new Date(row.createTime);
-      const endTime = new Date(row.returnTime);
-      if (!row.returnTime) {
-        return "未结束";
-      }
+      const endTime = row.returnTime ? new Date(row.returnTime) : new Date(); // 如果未结束,则使用当前时间
       const durationMilliseconds = endTime - createTime;
       // 计算小时、分钟和秒
       const hours = Math.floor(durationMilliseconds / (1000 * 60 * 60));
diff --git a/src/views/system/withdrawAudit/index.vue b/src/views/system/withdrawAudit/index.vue
index a531749..ea6fda9 100644
--- a/src/views/system/withdrawAudit/index.vue
+++ b/src/views/system/withdrawAudit/index.vue
@@ -136,7 +136,7 @@
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="120px">
           <el-form-item label="代理商" prop="operator" v-if="userName == 'admin'">
-            <el-select v-model="form.deptId" clearable placeholder="请选择代理商">
+            <el-select v-model="form.deptId" clearable filterable placeholder="请选择代理商">
               <el-option
                 v-for="item in deptOptions"
                 :key="item.deptId"