gqx 2 jaren geleden
bovenliggende
commit
84a0270106

+ 2 - 1
src/views/room/fangtailive.vue

@@ -401,7 +401,8 @@
                               <span
                                 v-if="
                                   roomLive.bookingData &&
-                                  roomLive.bookingData.bookingOrder
+                                  roomLive.bookingData.bookingOrder &&
+                                  roomLive.bookingData.bookingCustomer
                                 "
                               >
                                 {{ roomLive.bookingData.bookingCustomer.name }}

+ 246 - 35
src/views/room/modules/checkIn/BillRoomInfo.vue

@@ -23,17 +23,39 @@
               <a-icon
                 type="compass"
                 style="color: rgba(255, 141, 26, 1); font-size: 18px"
-              /><a-button type="link"> 拆分房间 </a-button>
+              /><a-button
+                type="link"
+                :disabled="selectRoomId == '1'"
+                @click="splitLiving"
+              >
+                拆分房间
+              </a-button>
             </div>
           </div>
         </div>
         <a-divider />
-        <a-tabs>
+        <a-tabs @change="tabChange">
           <a-tab-pane
-            :key="item.id"
-            :tab="item.roomName"
+            :key="item.roomId"
             v-for="(item, livingIndex) in model.livingRoomIds"
           >
+            <span slot="tab">
+              {{ item.roomName }}
+              <a-badge
+                dot
+                :number-style="{ backgroundColor: '#52c41a' }"
+                v-if="item.livingOrder.settleType == 1"
+              >
+                <span style="font-size: 12px">已结退房</span>
+              </a-badge>
+              <a-badge
+                dot
+                :number-style="{ backgroundColor: '#52c41a' }"
+                v-if="item.livingOrder.settleType == 2"
+              >
+                <span style="font-size: 12px">未结退房</span>
+              </a-badge>
+            </span>
             <a-descriptions :column="2">
               <a-descriptions-item label="主客姓名">
                 {{ item.livingCustomers[0].customerName }}
@@ -251,7 +273,13 @@
               <a-icon
                 type="property-safety"
                 style="color: rgba(255, 141, 26, 1); font-size: 18px"
-              /><a-button type="link"> 部分结账 </a-button>
+              /><a-button
+                type="link"
+                :disabled="selectedRowKeys1.length == 0 || selectRoomId == '1'"
+                @click="partialSettle"
+              >
+                部分结账
+              </a-button>
             </div>
           </div>
         </div>
@@ -262,10 +290,7 @@
           :pagination="false"
           :scroll="{ y: 160 }"
           rowKey="id"
-          :rowSelection="{
-            selectedRowKeys: selectedRowKeys,
-            onChange: onSelectChange,
-          }"
+          :row-selection="rowSelection"
         >
           <template slot="subjectType" slot-scope="text, record, index">
             {{ getSubjectTypeText(text) }}
@@ -336,7 +361,7 @@
             {{ getPayTypeText(text) }}
           </template>
           <template slot="subjectType" slot-scope="text, record, index">
-            {{ getSubjectTypeText(text) }}
+            {{ getSubjectTypeText(record.subjectType) }}
           </template>
         </a-table>
         <div
@@ -359,14 +384,33 @@
           <a-descriptions-item label="合计消费"
             >-{{ feesAmount.toFixed(2) }}
           </a-descriptions-item>
-          <a-descriptions-item label="结账应退">
-            {{ (feesAmount - paymentAmount).toFixed(2) }}
+          <a-descriptions-item
+            label="结账应退"
+            v-if="paymentAmount - feesAmount > 0"
+          >
+            {{ (paymentAmount - feesAmount).toFixed(2) }}
+          </a-descriptions-item>
+          <a-descriptions-item label="结账应收" v-else>
+            {{ (paymentAmount - feesAmount).toFixed(2) }}
           </a-descriptions-item>
         </a-descriptions>
 
-        <a-button @click="handleAdd" type="danger" style="margin-left: 100px"
+        <a-button
+          v-if="paymentAmount - feesAmount > 0"
+          @click="handleAdd"
+          type="danger"
+          style="margin-left: 100px"
+          :disabled="btnSisabled"
           >结账退款</a-button
         >
+        <a-button
+          v-else
+          @click="handleAdd"
+          type="danger"
+          style="margin-left: 100px"
+          :disabled="btnSisabled"
+          >结账收款</a-button
+        >
       </div>
     </div>
     <customer-modal ref="modalCustomerForm" @ok="modalFormOk"></customer-modal>
@@ -381,7 +425,9 @@ import { validateDuplicateValue } from "@/utils/util";
 import moment from "moment";
 import CustomerModal from "./CustomerModal.vue";
 import RefundModal from "./RefundModal.vue";
-import paymentModal from "./paymentModal.vue";
+import PaymentModal from "./PaymentModal.vue";
+import { match } from "assert";
+import { postAction } from "../../../../api/manage";
 const columns = [
   // {
   //     title: "",
@@ -482,7 +528,7 @@ const date = new Date();
 const endDate = new Date(date.setDate(date.getDate() + 1));
 export default {
   name: "BusMeetingRoomForm",
-  components: { CustomerModal, RefundModal, paymentModal },
+  components: { CustomerModal, RefundModal, PaymentModal },
   props: {
     //表单禁用
     disabled: {
@@ -531,9 +577,13 @@ export default {
       warranterList: [],
       key: 0,
       feesList: [],
+      oldfeesList: [],
       paymentList: [],
+      oldpaymentList: [],
       payTypeList: [],
       vipCustomer: {},
+      selectRoomId: "1",
+      selectedRowKeys1: [],
     };
   },
   computed: {
@@ -546,9 +596,44 @@ export default {
       }, 0);
     },
     paymentAmount() {
-      return this.paymentList.reduce(function (total, item) {
+      var list = this.paymentList.filter((t) => t.subjectType !== 5);
+      var amount = list.reduce(function (total, item) {
+        return total + item.money;
+      }, 0);
+
+      var list2 = this.paymentList.filter((t) => t.subjectType == 5);
+      var amount2 = list2.reduce(function (total, item) {
         return total + item.money;
       }, 0);
+      return amount - amount2;
+    },
+    btnSisabled() {
+      var index = this.model.livingRoomIds.findLastIndex(
+        (t) => t.roomId == this.selectRoomId
+      );
+      var find = this.model.livingRoomIds[index];
+      if (find) {
+        return find.livingOrder.settleType == 1;
+      }
+      return false;
+    },
+    rowSelection() {
+      return {
+        onChange: (selectedRowKeys, selectedRows) => {
+          // console.log(
+          //   `selectedRowKeys: ${selectedRowKeys}`,
+          //   "selectedRows: ",
+          //   selectedRows
+          // );
+          this.selectedRowKeys1 = selectedRowKeys;
+        },
+        getCheckboxProps: (record) => ({
+          props: {
+            disabled: record.preferentialStatus === 2,
+            id: record.id,
+          },
+        }),
+      };
     },
   },
   created() {
@@ -577,8 +662,80 @@ export default {
     });
   },
   methods: {
+    splitLiving() {
+      var that = this;
+      this.$confirm({
+        title: "提示",
+        content: "确认要拆分房间?",
+        onOk: function () {
+          var index = that.model.livingRoomIds.findLastIndex(
+            (t) => t.roomId == that.selectRoomId
+          );
+          var livingRoom = that.model.livingRoomIds[index];
+          httpAction(
+            "business/busRoomBookingOrders/split-living?livingOrderId=" +
+              livingRoom.livingOrder.id,
+            {},
+            "post"
+          )
+            .then((res) => {
+              if (res.success) {
+                that.$message.success("拆分成功");
+                that.getBookingOrderInfo();
+                that.$emit("ok");
+              } else {
+                that.$message.warning(res.message);
+              }
+            })
+            .finally(() => {
+              that.confirmLoading = false;
+            });
+        },
+      });
+    },
+    partialSettle() {
+      var list2 = this.feesList.filter((t) =>
+        this.selectedRowKeys1.includes(t.id)
+      );
+      console.log(list2);
+      var amount = list2.reduce(function (total, item) {
+        return total + item.money;
+      }, 0);
+      var index = this.model.livingRoomIds.findLastIndex(
+        (t) => t.roomId == this.selectRoomId
+      );
+      var livingRoom = this.model.livingRoomIds[index];
+      this.$refs.modalPaymentForm.edit({
+        billAmount: parseFloat(amount.toFixed(2)),
+        deposit: 0,
+        roomFee: parseFloat(amount.toFixed(2)),
+        subjectType: 5,
+        feeType: 2,
+        bookingOrderId: this.model.orderInfo.id,
+        livingOrderId:
+          livingRoom.roomId != "1" ? livingRoom.livingOrder.id : "",
+        preferentialType: 1,
+        couponFirstAmount: 0,
+        discount: 9,
+        vipCustomerId: this.model.orderInfo.vipCustomerId,
+        selectedFeeIds: this.selectedRowKeys1,
+      });
+      this.$refs.modalPaymentForm.title = "部分结账收款";
+      this.$refs.modalPaymentForm.disableSubmit = false;
+    },
+    tabChange(e) {
+      console.log(e);
+      this.selectRoomId = e;
+      if (e == "1") {
+        this.feesList = this.oldfeesList;
+        this.paymentList = this.oldpaymentList;
+      } else {
+        this.feesList = this.oldfeesList.filter((t) => t.roomId == e);
+        this.paymentList = this.oldpaymentList.filter((t) => t.roomId == e);
+      }
+    },
     getPayTypeText(text) {
-      var find = this.payTypeList.find((t) => (t.id = text));
+      var find = this.payTypeList.find((t) => t.id == text);
       return find ? find.name : "";
     },
     getRoomName(id) {
@@ -587,7 +744,19 @@ export default {
       return find ? find.roomName : "";
     },
     getSubjectTypeText(text) {
-      return text == 1 ? "押金" : "房费";
+      var msg = "";
+      if (text == 1) {
+        msg = "押金";
+      } else if (text == 2) {
+        msg = "预收房费";
+      } else if (text == 3) {
+        msg = "每日房费";
+      } else if (text == 4) {
+        msg = "优惠金额";
+      } else if (text == 5) {
+        msg = "结账收款";
+      }
+      return msg;
     },
     async getbusRoomPayType() {
       await getAction("/business/busRoomPayType/list", {
@@ -616,6 +785,7 @@ export default {
     },
     modalFormOk(e) {
       this.getBookingOrderInfo();
+      this.$emit("ok");
     },
     customerTypeName(customerType) {
       switch (customerType) {
@@ -667,7 +837,7 @@ export default {
           var livingRoomId = JSON.parse(
             JSON.stringify(res.result.livingRoomIds[0])
           );
-          livingRoomId.id = "1";
+          livingRoomId.roomId = "1";
           livingRoomId.roomName = "全部";
           var list = [];
           res.result.livingRoomIds.forEach((t) => {
@@ -682,7 +852,11 @@ export default {
             if (res.success) {
               if (res.result && res.result.length > 0) {
                 this.feesList = res.result.filter((t) => t.feeType === 1);
+                this.oldfeesList = JSON.parse(JSON.stringify(this.feesList));
                 this.paymentList = res.result.filter((t) => t.feeType === 2);
+                this.oldpaymentList = JSON.parse(
+                  JSON.stringify(this.paymentList)
+                );
               }
             }
           });
@@ -697,23 +871,60 @@ export default {
       this.selectionRows = selectionRows;
     },
     handleAdd() {
-      // this.$refs.modalRefundForm.edit({
-      //   billRefund: 100,
-      //   deposit: 50,
-      //   roomFee: 80,
-      //   refund: 130,
-      // });
-      // this.$refs.modalRefundForm.title = "结账退款";
-      // this.$refs.modalRefundForm.disableSubmit = false;
+      var list = this.paymentList.filter((t) => t.subjectType === 1);
+      var deposit = list.reduce(function (total, item) {
+        return total + item.money;
+      }, 0);
 
-      this.$refs.modalPaymentForm.edit({
-        billRefund: 100,
-        deposit: 50,
-        roomFee: 80,
-        refund: 130,
-      });
-      this.$refs.modalPaymentForm.title = "结账收款";
-      this.$refs.modalPaymentForm.disableSubmit = false;
+      var list2 = this.paymentList.filter((t) => t.subjectType === 2);
+      var sum = list2.reduce(function (total, item) {
+        return total + item.money;
+      }, 0);
+
+      var list3 = this.feesList.filter((t) => t.subjectType === 3);
+      var sum2 = list3.reduce(function (total, item) {
+        return total + item.money;
+      }, 0);
+      var index = this.model.livingRoomIds.findLastIndex(
+        (t) => t.roomId == this.selectRoomId
+      );
+      var livingRoom = this.model.livingRoomIds[index];
+      if (this.paymentAmount - this.feesAmount > 0) {
+        this.$refs.modalRefundForm.edit({
+          billRefund: this.paymentAmount - this.feesAmount,
+          deposit: deposit - (sum - sum2),
+          roomFee: sum - sum2,
+          money: this.paymentAmount - this.feesAmount,
+          subjectType: 5,
+          feeType: 2,
+          bookingOrderId: this.model.orderInfo.id,
+          livingOrderId:
+            livingRoom.roomId != "1" ? livingRoom.livingOrder.id : "",
+        });
+        this.$refs.modalRefundForm.title = "结账退款";
+        this.$refs.modalRefundForm.disableSubmit = false;
+      } else {
+        this.$refs.modalPaymentForm.edit({
+          billAmount: parseFloat(
+            Math.abs(this.paymentAmount - this.feesAmount).toFixed(2)
+          ),
+          deposit: deposit - (sum - sum2),
+          roomFee: parseFloat(
+            Math.abs(this.paymentAmount - this.feesAmount).toFixed(2)
+          ),
+          subjectType: 5,
+          feeType: 2,
+          bookingOrderId: this.model.orderInfo.id,
+          livingOrderId:
+            livingRoom.roomId != "1" ? livingRoom.livingOrder.id : "",
+          preferentialType: 1,
+          couponFirstAmount: 0,
+          discount: 9,
+          vipCustomerId: this.model.orderInfo.vipCustomerId,
+        });
+        this.$refs.modalPaymentForm.title = "结账收款";
+        this.$refs.modalPaymentForm.disableSubmit = false;
+      }
     },
     puls() {
       this.wakeList.push({});

+ 62 - 24
src/views/room/modules/checkIn/Refund.vue

@@ -39,13 +39,17 @@
               ></a-input
               >元
               <a-select
-                v-model="model.certType"
+                v-model="model.payType"
                 style="width: 200px"
-                placeholder="证件类型"
+                placeholder="支付类型"
                 :allowClear="true"
               >
-                <a-select-option :value="1">原路退款</a-select-option>
-                <a-select-option :value="2">现金</a-select-option>
+                <a-select-option
+                  :value="item.id"
+                  v-for="item in payTypeList"
+                  :key="item.id"
+                  >{{ item.name }}</a-select-option
+                >
               </a-select>
             </a-form-model-item>
           </a-col>
@@ -64,13 +68,17 @@
               ></a-input
               >元
               <a-select
-                v-model="model.certType"
+                v-model="model.payType"
                 style="width: 200px"
-                placeholder="证件类型"
+                placeholder="支付类型"
                 :allowClear="true"
               >
-                <a-select-option :value="1">原路退款</a-select-option>
-                <a-select-option :value="2">现金</a-select-option>
+                <a-select-option
+                  :value="item.id"
+                  v-for="item in payTypeList"
+                  :key="item.id"
+                  >{{ item.name }}</a-select-option
+                >
               </a-select>
             </a-form-model-item>
           </a-col>
@@ -79,12 +87,12 @@
               label="实退合计"
               :labelCol="labelCol"
               :wrapperCol="wrapperCol"
-              prop="refund"
+              prop="money"
             >
               <a-input
                 style="width: 100px"
                 disabled
-                v-model="model.refund"
+                v-model="model.money"
                 placeholder="请输入实退合计"
               ></a-input>
             </a-form-model-item>
@@ -100,7 +108,7 @@ import { httpAction, getAction } from "@/api/manage";
 import { validateDuplicateValue } from "@/utils/util";
 
 export default {
-  name: "结账退款",
+  name: "Refund",
   components: {},
   props: {
     //表单禁用
@@ -112,7 +120,14 @@ export default {
   },
   data() {
     return {
-      model: { payType: 1, livingOrderId: "", certType: 1, gender: 1 },
+      model: {
+        payType: "",
+        payType2: "",
+        livingOrderId: "",
+        certType: 1,
+        gender: 1,
+        bookingOrderId: "",
+      },
       labelCol: {
         xs: { span: 24 },
         sm: { span: 5 },
@@ -149,6 +164,7 @@ export default {
       staffList: [],
       customerList: [],
       oldcustomerList: [],
+      payTypeList: [],
     };
   },
   computed: {
@@ -166,6 +182,19 @@ export default {
     this.getbusCustomer();
   },
   methods: {
+    getbusRoomPayType() {
+      getAction("/business/busRoomPayType/list", {
+        pageSize: 99999,
+        pageNo: 1,
+      }).then((res) => {
+        if (res.success) {
+          this.payTypeList = res.result.records;
+          if (this.payTypeList && this.payTypeList.length > 0) {
+            this.$set(this.model, "payType", this.payTypeList[0].id);
+          }
+        }
+      });
+    },
     handleSearch(value) {
       let result;
       if (!value) {
@@ -196,6 +225,8 @@ export default {
     },
     edit(record) {
       this.model = Object.assign({}, record);
+
+      this.getbusRoomPayType();
       this.visible = true;
     },
     submitForm() {
@@ -204,20 +235,27 @@ export default {
       this.$refs.form.validate((valid) => {
         if (valid) {
           that.confirmLoading = true;
-          // var customers = [];
-          // customers.push({
-          //   certNo: this.model.certNo,
-          //   certType: this.model.certType,
-          //   customerId: this.model.customerId,
-          //   customerName: this.model.customerName,
-          //   gender: this.model.gender,
-          //   phone: this.model.phone,
-          //   roomId: this.model.roomId,
-          // });
-          httpAction("/business/busLivingCustomer/add", this.model, "post")
+          var fees = [];
+          fees.push({
+            feeType: this.model.feeType,
+            money: this.model.money,
+            payType: this.model.payType,
+            custorerOrderRemark: "结账退款",
+            isPreferential: false,
+            livingOrderId: this.model.livingOrderId,
+          });
+          var url =
+            "/business/busRoomBookingOrders/settle-checkout?bookingOrderId=" +
+            this.model.bookingOrderId;
+          if (this.model.livingOrderId) {
+            url =
+              "/business/busRoomBookingOrders/living-settle-checkout?livingOrderId=" +
+              this.model.livingOrderId;
+          }
+          httpAction(url, fees, "post")
             .then((res) => {
               if (res.success) {
-                that.$message.success("入住成功");
+                that.$message.success("结账成功");
                 that.$emit("ok");
               } else {
                 that.$message.warning(res.message);

+ 225 - 103
src/views/room/modules/checkIn/payment.vue

@@ -13,15 +13,10 @@
               label="结账应收"
               :labelCol="labelCol"
               :wrapperCol="wrapperCol"
-              prop="billRefund"
+              prop="billAmount"
             >
-              <a-input
-                style="width: 100px"
-                disabled
-                v-model="model.billAmount"
-                placeholder="请输入结账应收"
-              ></a-input
-              >元 <a-switch v-model="model.coupon" />优惠
+              {{ model.billAmount.toFixed(2) }}元
+              <a-switch v-model="model.coupon" />优惠
             </a-form-model-item>
           </a-col>
           <template v-if="model.coupon">
@@ -32,33 +27,33 @@
                 :wrapperCol="wrapperCol"
                 prop="refund"
               >
-                <a-radio-group v-model="model.couponType">
+                <a-radio-group v-model="model.preferentialType">
                   <a-radio :value="1"> 抹零 </a-radio>
                   <a-radio :value="2"> 减现 </a-radio>
                   <a-radio :value="3"> 打折 </a-radio>
                 </a-radio-group>
-                <template v-if="model.couponType === 3"
+                <template v-if="model.preferentialType === 3"
                   >打<a-input-number
                     style="width: 50px"
                     v-model="model.discount"
                     :min="1"
-                    :max="10"
+                    :max="9"
                   ></a-input-number
                   >折
                 </template>
               </a-form-model-item>
             </a-col>
-            <a-col :span="24" v-if="model.couponType !== 3">
+            <a-col :span="24" v-if="model.preferentialType == 2">
               <a-form-model-item
                 label="优惠金额"
                 :labelCol="labelCol"
                 :wrapperCol="wrapperCol"
-                prop="deposit"
+                prop="couponFirstAmount"
               >
                 <a-input-number
                   style="width: 100px"
                   :min="0"
-                  v-model="model.deposit"
+                  v-model="model.couponFirstAmount"
                   placeholder="请输入优惠金额"
                 ></a-input-number
                 >元
@@ -69,15 +64,8 @@
                 label="惠后金额"
                 :labelCol="labelCol"
                 :wrapperCol="wrapperCol"
-                prop="roomFee"
               >
-                <a-input-number
-                  style="width: 100px"
-                  disabled
-                  v-model="model.roomFee"
-                  placeholder="请输入惠后金额"
-                ></a-input-number
-                >元
+                {{ couponAmount.toFixed(2) }}元
               </a-form-model-item>
             </a-col>
             <a-col :span="24">
@@ -89,13 +77,17 @@
               >
                 <a-select
                   v-if="model.couponCard"
-                  v-model="model.certType"
+                  v-model="model.couponId"
                   style="width: 200px"
                   placeholder="优惠券"
                   :allowClear="true"
                 >
-                  <a-select-option :value="1">原路退款</a-select-option>
-                  <a-select-option :value="2">现金</a-select-option>
+                  <a-select-option
+                    :value="couponItem.id"
+                    v-for="couponItem in memeberCouponList"
+                    :key="couponItem.id"
+                    >{{ couponItem.couponsName }}</a-select-option
+                  >
                 </a-select>
                 <a-switch v-model="model.couponCard" />使用优惠券
               </a-form-model-item>
@@ -106,14 +98,8 @@
               label="实收金额"
               :labelCol="labelCol"
               :wrapperCol="wrapperCol"
-              prop="roomFee"
             >
-              <a-input-number
-                style="width: 100px"
-                v-model="model.roomFee"
-                placeholder="请输入实收金额"
-              ></a-input-number
-              >元
+              {{ realityAmount.toFixed(2) }}元
             </a-form-model-item>
           </a-col>
           <a-col :span="24">
@@ -121,53 +107,58 @@
               label="收款金额"
               :labelCol="labelCol"
               :wrapperCol="wrapperCol"
-              prop="roomFee"
             >
-              <a-row type="flex">
-                <a-col :span="6">
-                  <a-input-number
-                    style="width: 100px"
-                    v-model="model.roomFee"
-                    :min="0"
-                  ></a-input-number>
-                </a-col>
-                <a-col :span="6">
-                  <a-select
-                    v-model="model.orderFees"
-                    placeholder="收款方式"
-                    @change="onChange"
-                  >
-                    <a-select-option
-                      :value="item.id"
-                      v-for="item in payTypeList"
-                      :key="item.id"
+              <div v-for="(item, index) in payList" :key="index">
+                <a-row type="flex" :key="index">
+                  <a-col :span="6">
+                    <a-input-number
+                      style="width: 100px"
+                      v-model="item.money"
+                      :min="0"
+                    ></a-input-number>
+                  </a-col>
+                  <a-col :span="6">
+                    <a-select
+                      v-model="item.payType"
+                      placeholder="收款方式"
+                      @change="(event) => onChange(event, item)"
                     >
-                      {{ item.name }}
-                    </a-select-option>
-                  </a-select></a-col
-                >
-                <a-col :span="6">
-                  <a-icon
-                    type="plus-circle"
-                    class="dynamic-delete-button"
-                    @click="puls()" />
-                  <a-icon
-                    type="minus-circle"
-                    style="color: #f56c6c"
-                    class="dynamic-delete-button"
-                    @click="() => remove(room, index)"
-                /></a-col>
-              </a-row>
+                      <a-select-option
+                        :value="item2.id"
+                        v-for="item2 in payTypeList"
+                        :key="item2.id"
+                      >
+                        {{ item2.name }}
+                      </a-select-option>
+                    </a-select></a-col
+                  >
+                  <a-col :span="6">
+                    <a-icon
+                      v-if="index == payList.length - 1"
+                      type="plus-circle"
+                      class="dynamic-delete-button"
+                      @click="puls()" />
+                    <a-icon
+                      v-if="payList.length > 1"
+                      type="minus-circle"
+                      style="color: #f56c6c"
+                      class="dynamic-delete-button"
+                      @click="() => remove(index)"
+                  /></a-col>
+                </a-row>
 
-              <a-row type="flex">
-                <a-col :span="12"> 姓名:{{ memberCard.name }} </a-col>
-                <a-col :span="12"> 卡号:{{ memberCard.cardNo }} </a-col>
-                <a-col :span="12"> 会员级别: {{ memberCard.gradeName }}</a-col>
-                <a-col :span="12"> 余额:{{ memberCard.balance }} </a-col>
-                <a-col :span="12"> 积分:{{ memberCard.integral }} </a-col>
-                <a-col :span="12"> 本次扣后剩余: </a-col>
-                <a-col :span="12"> 本次新增积分: </a-col>
-              </a-row>
+                <a-row type="flex" v-if="item.isVipMemmber">
+                  <a-col :span="12"> 姓名:{{ memberCard.name }} </a-col>
+                  <a-col :span="12"> 卡号:{{ memberCard.cardNo }} </a-col>
+                  <a-col :span="12">
+                    会员级别: {{ memberCard.gradeName }}</a-col
+                  >
+                  <a-col :span="12"> 余额:{{ memberCard.balance }} </a-col>
+                  <a-col :span="12"> 积分:{{ memberCard.integral }} </a-col>
+                  <!-- <a-col :span="12"> 本次扣后剩余: </a-col>
+                <a-col :span="12"> 本次新增积分: </a-col> -->
+                </a-row>
+              </div>
             </a-form-model-item>
           </a-col>
           <a-col :span="24">
@@ -175,14 +166,8 @@
               label="实收合计"
               :labelCol="labelCol"
               :wrapperCol="wrapperCol"
-              prop="roomFee"
             >
-              <a-input-number
-                style="width: 100px"
-                v-model="model.roomFee"
-                placeholder="请输入实收合计"
-              ></a-input-number
-              >元
+              {{ sumAmount.toFixed(2) }}元
             </a-form-model-item>
           </a-col>
         </a-row>
@@ -196,7 +181,7 @@ import { httpAction, getAction } from "@/api/manage";
 import { validateDuplicateValue } from "@/utils/util";
 
 export default {
-  name: "结账退款",
+  name: "Payment",
   components: {},
   props: {
     //表单禁用
@@ -208,7 +193,15 @@ export default {
   },
   data() {
     return {
-      model: { coupon: false, discount: 1, couponCard: false, couponType: 1 },
+      model: {
+        coupon: false,
+        discount: 1,
+        couponCard: false,
+        couponType: 1,
+        couponFirstAmount: 0,
+        billAmount: 0,
+        selectedFeeIds: [],
+      },
       labelCol: {
         xs: { span: 24 },
         sm: { span: 5 },
@@ -246,13 +239,50 @@ export default {
       customerList: [],
       oldcustomerList: [],
       payTypeList: [],
-      memberCard:{},
+      memberCard: {},
+      isVipMemmber: false,
+      payList: [],
+      memeberCouponList: [],
     };
   },
   computed: {
     formDisabled() {
       return this.disabled;
     },
+    sumAmount() {
+      var sum = this.payList.reduce(function (total, item) {
+        return total + item.money;
+      }, 0);
+      return sum;
+    },
+    couponAmount() {
+      var sum = 0;
+      if (this.model.coupon) {
+        if (this.model.preferentialType == 1) {
+          sum = Math.floor(this.model.billAmount);
+        } else if (this.model.preferentialType == 2) {
+          sum = this.model.billAmount - (this.model.couponFirstAmount || 0);
+        } else if (this.model.preferentialType == 3) {
+          sum = parseFloat(
+            ((this.model.billAmount * this.model.discount) / 10).toFixed(2)
+          );
+        }
+      } else {
+        sum = this.model.billAmount;
+      }
+      return sum;
+    },
+    realityAmount() {
+      if (this.model.couponCard) {
+        var find = this.memeberCouponList.find(
+          (t) => t.id == this.model.couponId
+        );
+        if (find) {
+          return this.couponAmount - find.cost;
+        }
+      }
+      return this.couponAmount;
+    },
   },
   created() {
     var _info = JSON.parse(localStorage.getItem("storeInfo"));
@@ -261,7 +291,6 @@ export default {
     }
     //备份model原始值
     this.modelDefault = JSON.parse(JSON.stringify(this.model));
-    this.getMemeberCouponList();
     getAction("/business/busRoomPayType/list", {
       pageSize: 99999,
       pageNo: 1,
@@ -281,8 +310,42 @@ export default {
     });
   },
   methods: {
-    onChange(checked) {
-      console.log(`a-switch to ${checked}`);
+    getbusRoomPayType() {
+      getAction("/business/busRoomPayType/list", {
+        pageSize: 99999,
+        pageNo: 1,
+      }).then((res) => {
+        if (res.success) {
+          this.payTypeList = res.result.records;
+          if (this.payTypeList && this.payTypeList.length > 0) {
+            this.$set(this.model, "payType", this.payTypeList[0].id);
+
+            this.payList = [
+              {
+                money: this.realityAmount,
+                payType: this.payTypeList[0].id,
+                isVipMemmber: false,
+              },
+            ];
+          }
+        }
+      });
+    },
+    puls() {
+      this.payList.push({
+        money: 0,
+        payType: this.payTypeList[0].id,
+        isVipMemmber: false,
+      });
+    },
+    remove(index) {
+      this.payList.splice(index, 1);
+    },
+    onChange(e, value) {
+      console.log("value", value);
+      console.log("e", e);
+      var find = this.payTypeList.find((t) => t.id == value.payType);
+      value.isVipMemmber = find && find.name == "会员卡";
     },
     handleSearch(value) {
       let result;
@@ -304,10 +367,10 @@ export default {
         pageNo: 1,
         pageSize: 99,
         conditions: 900,
-        mobile: "15802576620",
+        mobile: this.model.vipCustomerId,
       }).then((res) => {
         if (res.success) {
-          this.customerList = res.result.records;
+          this.memeberCouponList = res.result.records;
         }
       });
     },
@@ -318,6 +381,10 @@ export default {
     },
     edit(record) {
       this.model = Object.assign({}, record);
+      this.getbusRoomPayType();
+      if (this.model.vipCustomerId) {
+        this.getMemeberCouponList();
+      }
       this.visible = true;
     },
     submitForm() {
@@ -325,21 +392,76 @@ export default {
       // 触发表单验证
       this.$refs.form.validate((valid) => {
         if (valid) {
+          console.log("this.realityAmount ", this.realityAmount);
+          console.log("this.sumAmount ", this.sumAmount);
+          if (this.realityAmount != this.sumAmount) {
+            that.$message.warning("实收金额和实收合计必须相等");
+            return;
+          }
+          var obj = {};
+          var fees = [];
+          if (this.model.coupon) {
+            fees.push({
+              feeType: this.model.feeType,
+              preferentialType: this.model.preferentialType,
+              money: this.couponAmount.toFixed(2),
+              custorerOrderRemark: "优惠金额",
+              isPreferential: true,
+            });
+          }
+          if (this.model.couponCard && this.model.couponId) {
+            var find = this.memeberCouponList.find(
+              (t) => t.id == this.model.couponId
+            );
+            if (find) {
+              fees.push({
+                feeType: this.model.feeType,
+                money: find.cost.toFixed(2),
+                custorerOrderRemark: "优惠券",
+                isPreferential: true,
+              });
+            }
+          }
+          this.payList.forEach((item) => {
+            fees.push({
+              feeType: this.model.feeType,
+              money: item.money.toFixed(2),
+              payType: item.payType,
+              custorerOrderRemark: "结账退房",
+              isPreferential: false,
+            });
+          });
+
           that.confirmLoading = true;
-          // var customers = [];
-          // customers.push({
-          //   certNo: this.model.certNo,
-          //   certType: this.model.certType,
-          //   customerId: this.model.customerId,
-          //   customerName: this.model.customerName,
-          //   gender: this.model.gender,
-          //   phone: this.model.phone,
-          //   roomId: this.model.roomId,
-          // });
-          httpAction("/business/busLivingCustomer/add", this.model, "post")
+          var url =
+            "/business/busRoomBookingOrders/settle-checkout?bookingOrderId=" +
+            this.model.bookingOrderId;
+          if (this.model.livingOrderId) {
+            url =
+              "/business/busRoomBookingOrders/living-settle-checkout?livingOrderId=" +
+              this.model.livingOrderId;
+          }
+          if (
+            this.model.selectedFeeIds &&
+            this.model.selectedFeeIds.length > 0
+          ) {
+            url = "/business/busRoomBookingOrders/partial-settle";
+            obj = {
+              fees: fees,
+              livingOrderId: this.model.livingOrderId,
+              selectedFeeIds: this.model.selectedFeeIds,
+            };
+          }
+          httpAction(
+            url,
+            this.model.selectedFeeIds && this.model.selectedFeeIds.length > 0
+              ? obj
+              : fees,
+            "post"
+          )
             .then((res) => {
               if (res.success) {
-                that.$message.success("入住成功");
+                that.$message.success("结账成功");
                 that.$emit("ok");
               } else {
                 that.$message.warning(res.message);

+ 2 - 2
src/views/room/modules/checkIn/paymentModal.vue

@@ -14,9 +14,9 @@
 
 <script>
 
-  import payment from './payment'
+  import payment from './Payment'
   export default {
-    name: 'RefundModal',
+    name: 'PaymentModal',
     components: {
       payment
     },