PayOrRefund.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model
  5. ref="form"
  6. :model="model"
  7. :rules="validatorRules"
  8. slot="detail"
  9. >
  10. <a-row>
  11. <!-- <a-col :span="12">
  12. </a-col> -->
  13. <div class="crad_style">
  14. <a-col :span="8" class="refund_style" v-show="showYinshou">
  15. <!-- <a-form-model-item
  16. :label="&quot;结账应&quot; + (model.money < 0 ? &quot;退&quot; : &quot;收&quot;)"
  17. :labelCol="labelCol"
  18. :wrapperCol="wrapperCol"
  19. prop="money"
  20. > -->
  21. <span>{{ &quot;应&quot; + (model.money < 0 ? &quot;退&quot; : &quot;收&quot;) }}: {{ Math.abs(model.money.toFixed(2)) }}元</span>
  22. <!-- </a-form-model-item> -->
  23. </a-col>
  24. <a-col :span="16">
  25. <a-form-model-item
  26. label="收款金额"
  27. :labelCol="labelCol"
  28. :wrapperCol="wrapperCol"
  29. >
  30. {{ model.collection.toFixed(2) }}元
  31. </a-form-model-item>
  32. <a-form-model-item
  33. label="消费金额"
  34. :labelCol="labelCol"
  35. :wrapperCol="wrapperCol"
  36. >
  37. {{ model.consumption.toFixed(2) }}元
  38. <a-switch v-model="model.coupon" />优惠
  39. <a-radio-group v-if='model.coupon' v-model="model.preferentialType">
  40. <a-radio :value="1"> 抹零 </a-radio>
  41. <a-radio :value="2"> 减现 </a-radio>
  42. <a-radio :value="3"> 打折 </a-radio>
  43. </a-radio-group>
  44. <template
  45. v-if="model.preferentialType === 3"
  46. >打<a-input-number
  47. style="width: 50px"
  48. v-model="model.discount"
  49. :min="1"
  50. :max="9"
  51. ></a-input-number
  52. >折
  53. </template>
  54. </a-form-model-item>
  55. <!-- <a-col :span="24" v-if="model.preferentialType == 2"> -->
  56. <div v-if="model.preferentialType == 2">
  57. <a-form-model-item
  58. label="优惠金额"
  59. :labelCol="labelCol"
  60. :wrapperCol="wrapperCol"
  61. prop="couponFirstAmount"
  62. >
  63. <a-input-number
  64. style="width: 100px"
  65. :min="0"
  66. v-model="model.couponFirstAmount"
  67. placeholder="请输入优惠金额"
  68. ></a-input-number
  69. >元
  70. </a-form-model-item>
  71. </div>
  72. <a-form-model-item
  73. label="优惠券"
  74. :labelCol="labelCol"
  75. :wrapperCol="wrapperCol"
  76. prop="refund"
  77. >
  78. <a-select
  79. v-if="model.couponCard"
  80. v-model="model.couponId"
  81. style="width: 200px"
  82. placeholder="优惠券"
  83. :allowClear="true"
  84. >
  85. <a-select-option
  86. :value="couponItem.id"
  87. v-for="couponItem in memeberCouponList"
  88. :key="couponItem.id"
  89. >{{ couponItem.couponsName }}</a-select-option
  90. >
  91. </a-select>
  92. <a-switch v-model="model.couponCard" />使用优惠券
  93. </a-form-model-item>
  94. <a-form-model-item
  95. label="惠后金额"
  96. :labelCol="labelCol"
  97. :wrapperCol="wrapperCol"
  98. >
  99. {{ couponAmount.toFixed(2) }}元
  100. </a-form-model-item>
  101. <!-- </a-col> -->
  102. <template v-if="model.coupon">
  103. <!-- <a-col :span="24">
  104. <a-form-model-item
  105. label="优惠方式"
  106. :labelCol="labelCol"
  107. :wrapperCol="wrapperCol"
  108. prop="refund"
  109. >
  110. <a-radio-group v-model="model.preferentialType">
  111. <a-radio :value="1"> 抹零 </a-radio>
  112. <a-radio :value="2"> 减现 </a-radio>
  113. <a-radio :value="3"> 打折 </a-radio>
  114. </a-radio-group>
  115. <template
  116. v-if="model.preferentialType === 3"
  117. >打<a-input-number
  118. style="width: 50px"
  119. v-model="model.discount"
  120. :min="1"
  121. :max="9"
  122. ></a-input-number
  123. >折
  124. </template>
  125. </a-form-model-item>
  126. </a-col> -->
  127. <!-- <a-col :span="24">
  128. <a-col :span="24">
  129. </a-col>
  130. </a-col> -->
  131. </template>
  132. <!-- <a-form-model-item
  133. :label="&quot;实&quot; + (this.isRefund ? &quot;退&quot; : &quot;收&quot;) + &quot;金额&quot;"
  134. :labelCol="labelCol"
  135. :wrapperCol="wrapperCol"
  136. >
  137. {{ realityAmount.toFixed(2) }}元
  138. </a-form-model-item>
  139. </a-col>
  140. <a-col :span="24">
  141. </a-col> -->
  142. <!-- <a-col :span="24">-->
  143. </a-col>
  144. </div>
  145. <div class="presentation_style" v-if="model.money > 0">应收金额=消费合计/惠后金额-已收合计</div>
  146. <a-col :span="14" class="receipt_style" v-if="model.money > 0">
  147. <a-form-model-item
  148. :label="(this.isRefund ? &quot;退&quot; : &quot;收&quot;) + &quot;款金额&quot;"
  149. :labelCol="labelCol"
  150. :wrapperCol="wrapperCol"
  151. >
  152. <div v-for="(item, index) in payList" :key="index">
  153. <a-row type="flex" :key="index">
  154. <a-col :span="6">
  155. <a-input-number
  156. style="width: 100px"
  157. v-model="item.money"
  158. :min="0"
  159. ></a-input-number>
  160. </a-col>
  161. <a-col :span="6">
  162. <a-select
  163. v-model="item.payType"
  164. @change="(event) => onChange(event, item)"
  165. >
  166. <a-select-option
  167. :value="item2.id"
  168. v-for="item2 in payTypeList"
  169. :key="item2.id"
  170. :disabled="item2.delFlag == 99"
  171. >
  172. {{ item2.name }}
  173. </a-select-option>
  174. </a-select></a-col
  175. >
  176. <a-col :span="6">
  177. <a-icon
  178. v-if="index == payList.length - 1"
  179. type="plus-circle"
  180. class="dynamic-delete-button"
  181. @click="puls()" />
  182. <a-icon
  183. v-if="payList.length > 1"
  184. type="minus-circle"
  185. style="color: #f56c6c"
  186. class="dynamic-delete-button"
  187. @click="() => remove(index)"
  188. /></a-col>
  189. </a-row>
  190. <a-row type="flex" v-if="item.isVipMemmber">
  191. <a-col :span="12"> 姓名:{{ memberCard.name }} </a-col>
  192. <a-col :span="12"> 卡号:{{ memberCard.cardNo }} </a-col>
  193. <a-col :span="12">
  194. 会员级别: {{ memberCard.gradeName }}</a-col
  195. >
  196. <a-col :span="12"> 余额:{{ memberCard.balance }} </a-col>
  197. <a-col :span="12"> 积分:{{ memberCard.integral }} </a-col>
  198. <!-- <a-col :span="12"> 本次扣后剩余: </a-col>
  199. <a-col :span="12"> 本次新增积分: </a-col> -->
  200. </a-row>
  201. <a-row type="flex" v-if="item.isDanwei">
  202. <a-col :span="12">
  203. 协议单位:{{ agreementUnitData.customerName }}
  204. </a-col>
  205. <a-col :span="12">
  206. 签约开始日期:{{ danwei.signTime }}
  207. </a-col>
  208. <a-col :span="12">
  209. 签约结束日期: {{ danwei.effective }}</a-col
  210. >
  211. <a-col :span="12">
  212. 可用额度:{{ agreementUnitData.balance || 0 }}
  213. </a-col>
  214. </a-row>
  215. </div>
  216. </a-form-model-item>
  217. </a-col>
  218. <a-col :span="14" class="settle_style" v-if="model.money > 0">
  219. <a-form-model-item
  220. :label="&quot;实&quot; + (this.isRefund ? &quot;退&quot; : &quot;收&quot;) + &quot;合计&quot;"
  221. :labelCol="labelCol"
  222. :wrapperCol="wrapperCol"
  223. >
  224. {{ Math.abs(sumAmount.toFixed(2)) }}元
  225. </a-form-model-item>
  226. </a-col>
  227. <div class="presentation_style_two" v-if="model.money < 0">退款:</div>
  228. <a-col :span="24" v-if="model.money < 0">
  229. <a-table :columns="columns" :data-source="feeList" bordered>
  230. <template slot="payType" slot-scope="text, record, index">
  231. {{ getPayTypeText(text) }}
  232. </template>
  233. <template slot="subjectType" slot-scope="text, record, index">
  234. {{ getSubjectTypeText(text,record) }}
  235. </template>
  236. <template slot="roomId" slot-scope="text, record, index">
  237. {{ getRoomName(text) }}
  238. </template>
  239. <template slot="payType" slot-scope="text, record, index">
  240. <a-select style="width: 100px" v-model="record.payType">
  241. <a-select-option v-for="(item, key) in payTypeList" :key="key" :value="item.id" :disabled="item.disable">{{ item.name }}</a-select-option>
  242. </a-select>
  243. </template>
  244. <template slot="prerefund" slot-scope="text, record, index">
  245. <a-input-number :max="record.money - record.returnMoney" v-model="record.prerefund"></a-input-number>
  246. </template>
  247. </a-table>
  248. </a-col>
  249. <a-col :span="24" style="text-align: end">
  250. <a-checkbox default-checked>打印结账单</a-checkbox>
  251. <a-checkbox default-checked>打印发票二维码</a-checkbox>
  252. </a-col>
  253. </a-row>
  254. </a-form-model>
  255. </j-form-container>
  256. </a-spin>
  257. </template>
  258. <script>
  259. import { httpAction, getAction,postAction } from '@/api/manage'
  260. import { validateDuplicateValue } from '@/utils/util'
  261. import moment from 'moment/moment'
  262. export default {
  263. name: 'PayOrRefund',
  264. components: {},
  265. props: {
  266. // 表单禁用
  267. disabled: {
  268. type: Boolean,
  269. default: false,
  270. required: false
  271. },
  272. showYinshou: {
  273. type: Boolean,
  274. default: true,
  275. required: false
  276. }
  277. },
  278. data() {
  279. return {
  280. feeList: [],
  281. isRefund: false,
  282. model: {
  283. coupon: false,
  284. discount: 1,
  285. couponCard: false,
  286. couponType: 1,
  287. couponFirstAmount: 0,
  288. billAmount: 0,
  289. selectedFeeIds: []
  290. },
  291. labelCol: {
  292. xs: { span: 24 },
  293. sm: { span: 5 }
  294. },
  295. wrapperCol: {
  296. xs: { span: 24 },
  297. sm: { span: 16 }
  298. },
  299. confirmLoading: false,
  300. validatorRules: {
  301. mobile: [
  302. {
  303. required: true,
  304. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  305. message: '请输入手机号!'
  306. }
  307. ],
  308. cardNo: [{ required: true, message: '请输入会员卡号!' }],
  309. gradeId: [{ required: true, message: '请输入等级类型!' }],
  310. payType: [{ required: true, message: '请输入付款类型!' }],
  311. paymentMethod: [{ required: true, message: '请输入付款方式!' }],
  312. customerName: [{ required: true, message: '请输入会员姓名!' }],
  313. sex: [{ required: true, message: '请输入性别!' }],
  314. certificateType: [{ required: true, message: '请输入证件类型!' }],
  315. validity: [{ required: true, message: '请输入有效期!' }]
  316. },
  317. url: {
  318. add: '/business/busRoomBookingOrders/booking-to-live',
  319. edit: '/business/busMemberCard/edit',
  320. queryById: '/business/busMemberCard/queryById'
  321. },
  322. gradeList: [],
  323. paymentMethodList: [],
  324. staffList: [],
  325. customerList: [],
  326. oldcustomerList: [],
  327. payTypeList: [],
  328. memberCard: {},
  329. danwei: {},
  330. isVipMemmber: false,
  331. isDanwei: false,
  332. payList: [],
  333. memeberCouponList: [],
  334. agreementUnitData: {},
  335. copyRealityAmount: '', // 原本值
  336. allFeeMoney: 0,
  337. allReturnFee: 0,
  338. columns: [
  339. {
  340. title: '收款时间',
  341. dataIndex: 'createTime',
  342. width: '25%',
  343. },
  344. {
  345. title: '收款金额(元)',
  346. dataIndex: 'id',
  347. width: '15%',
  348. customRender: function (text, record) {
  349. return record.money
  350. }
  351. },
  352. {
  353. title: '退款方式',
  354. dataIndex: 'payType',
  355. // width: '40%',
  356. scopedSlots: { customRender: 'payType' }
  357. },
  358. {
  359. title: '退款金额(元)',
  360. dataIndex: 'prerefund',
  361. scopedSlots: { customRender: 'prerefund' }
  362. },
  363. {
  364. title: '已退金额(元)',
  365. dataIndex: 'returnMoney',
  366. },
  367. ],
  368. // [
  369. // {
  370. // title: '房间号',
  371. // dataIndex: 'roomName',
  372. // width: 80,
  373. // align: 'center',
  374. // // scopedSlots: { customRender: 'roomId' }
  375. // },
  376. // {
  377. // title: '支付类型',
  378. // dataIndex: 'payType',
  379. // align: 'center',
  380. // width: 80,
  381. // scopedSlots: { customRender: 'payType' }
  382. // },
  383. // {
  384. // title: '费项',
  385. // dataIndex: 'subjectType',
  386. // align: 'center',
  387. // width: 100,
  388. // scopedSlots: { customRender: 'subjectType' }
  389. // },
  390. // {
  391. // title: '入账日期',
  392. // dataIndex: 'dayTime',
  393. // align: 'center',
  394. // width: 110,
  395. // customRender: function (text, record) {
  396. // return record.createTime.substring(0, 10)
  397. // }
  398. // },
  399. // {
  400. // title: '支付金额',
  401. // dataIndex: 'id',
  402. // align: 'center',
  403. // width: 90,
  404. // customRender: function (text, record) {
  405. // return record.money
  406. // }
  407. // },
  408. // {
  409. // title: '退款方式',
  410. // // dataIndex: 'id',
  411. // align: 'center',
  412. // width: 130,
  413. // scopedSlots: { customRender: 'refundType' }
  414. // },
  415. // {
  416. // title: '本次退款',
  417. // dataIndex: 'prerefund',
  418. // align: 'center',
  419. // scopedSlots: { customRender: 'prerefund' }
  420. // },
  421. // {
  422. // title: '已退款',
  423. // align: 'center',
  424. // dataIndex: 'returnMoney',
  425. // }
  426. // ]
  427. }
  428. },
  429. computed: {
  430. formDisabled() {
  431. return this.disabled
  432. },
  433. sumAmount() {
  434. var sum = this.payList.reduce(function (total, item) {
  435. return total + item.money
  436. }, 0)
  437. return sum
  438. },
  439. couponAmount() {
  440. var sum = 0
  441. if (this.model.coupon) {
  442. if (this.model.preferentialType == 1) {
  443. sum = Math.floor(this.model.consumption)
  444. } else if (this.model.preferentialType == 2) {
  445. sum = this.model.consumption - (this.model.couponFirstAmount || 0)
  446. } else if (this.model.preferentialType == 3) {
  447. sum = parseFloat(
  448. ((this.model.consumption * this.model.discount) / 10).toFixed(2)
  449. )
  450. }
  451. } else {
  452. sum = this.model.consumption
  453. }
  454. return sum
  455. },
  456. realityAmount() {
  457. // 实际要收的钱,为负表示要退的钱
  458. let relMoney = this.couponAmount.toFixed(2) - this.model.collection
  459. this.isRefund = relMoney < 0
  460. let result = 0
  461. if (this.model.couponCard) {
  462. var find = this.memeberCouponList.find(
  463. (t) => t.id == this.model.couponId
  464. )
  465. if (find) {
  466. this.isRefund = relMoney - find.cost < 0
  467. result = Math.abs(relMoney - find.cost)
  468. }
  469. }
  470. result = Math.abs(relMoney)
  471. if (this.payList && this.payList.length > 0 && this.copyRealityAmount != result) {
  472. this.payList = [this.payList[0]]
  473. this.payList[0].money = result
  474. }
  475. this.copyRealityAmount = result
  476. return result
  477. }
  478. },
  479. created() {
  480. var _info = JSON.parse(localStorage.getItem('storeInfo'))
  481. if (_info) {
  482. this.model.hotelId = _info.id
  483. }
  484. // 备份model原始值
  485. this.modelDefault = JSON.parse(JSON.stringify(this.model))
  486. // this.refundRequest()
  487. // getAction("/business/busRoomPayType/list", {
  488. // pageSize: 99999,
  489. // pageNo: 1,
  490. // }).then((res) => {
  491. // if (res.success) {
  492. // this.payTypeList = res.result.records;
  493. // }
  494. // });
  495. },
  496. methods: {
  497. getbusRoomPayType() {
  498. getAction('/business/busRoomPayType/list', {
  499. pageSize: 99999,
  500. pageNo: 1
  501. }).then((res) => {
  502. console.log(res);
  503. if (res.success) {
  504. this.payTypeList = res.result.records
  505. if (this.payTypeList && this.payTypeList.length > 0) {
  506. if (
  507. !this.model.vipCustomerId ||
  508. this.model.vipCustomerId.length == 0
  509. ) {
  510. var index = this.payTypeList.findIndex((t) =>
  511. t.name.includes('会员')
  512. )
  513. if (index >= 0) {
  514. this.payTypeList[index].delFlag = 99
  515. }
  516. }
  517. if (
  518. !this.model.contractTeamId ||
  519. this.model.contractTeamId.length == 0 ||
  520. !this.model.contractTeamProtocolId ||
  521. this.model.contractTeamProtocolId.length == 0
  522. ) {
  523. var index = this.payTypeList.findIndex((t) =>
  524. t.name.includes('单位')
  525. )
  526. if (index >= 0) {
  527. this.payTypeList[index].delFlag = 99
  528. }
  529. }
  530. this.$set(this.model, 'payType', this.payTypeList[0].id)
  531. this.payList = [
  532. {
  533. money: this.realityAmount,
  534. payType: this.payTypeList[0].id,
  535. isVipMemmber: false,
  536. isDanwei: false
  537. }
  538. ]
  539. }
  540. }
  541. })
  542. },
  543. puls() {
  544. var sum = this.payList.reduce(function (total, item) {
  545. return total + item.money
  546. }, 0)
  547. var money = this.realityAmount - sum
  548. if (money < 0) {
  549. money = 0
  550. }
  551. this.payList.push({
  552. money: money,
  553. payType: this.payTypeList[0].id,
  554. isVipMemmber: false,
  555. isDanwei: false
  556. })
  557. },
  558. remove(index) {
  559. this.payList.splice(index, 1)
  560. },
  561. onChange(e, value) {
  562. console.log('value', value)
  563. console.log('e', e)
  564. var find = this.payTypeList.find((t) => t.id == value.payType)
  565. value.isVipMemmber = find && find.name.includes('会员')
  566. value.isDanwei = find && find.name.includes('单位')
  567. },
  568. handleSearch(value) {
  569. let result
  570. if (!value) {
  571. result = this.oldcustomerList
  572. } else {
  573. result = this.oldcustomerList.filter((t) => t.name.includes(value))
  574. }
  575. this.customerList = result
  576. },
  577. handleSelectMember(e) {
  578. var find = this.customerList.find((t) => t.id === e)
  579. this.model.phone = find.phone
  580. this.model.customerName = find.name
  581. this.model.customerId = find.id
  582. },
  583. getMemeberCouponList() {
  584. getAction('/business/busMarketCouponsCashUsed/memeberCouponList', {
  585. pageNo: 1,
  586. pageSize: 99,
  587. conditions: 900,
  588. mobile: this.model.vipCustomerId
  589. }).then((res) => {
  590. if (res.success) {
  591. this.memeberCouponList = res.result.records
  592. }
  593. })
  594. },
  595. add(livingOrderId, roomId) {
  596. this.modelDefault.livingOrderId = livingOrderId
  597. this.modelDefault.roomId = roomId
  598. this.edit(this.modelDefault)
  599. },
  600. edit(record) {
  601. // console.log(record);
  602. this.model = Object.assign({}, record)
  603. // console.log(this.model);
  604. this.isRefund = this.model.isRefund
  605. // if (record.preferentialMoney !== 0 && record.preferentialMoney !== null) {
  606. // console.log(record.preferentialMoney)
  607. // debugger
  608. // this.model.coupon = true
  609. // this.model.preferentialType = 2
  610. // this.model.couponFirstAmount = record.preferentialMoney
  611. // }
  612. this.getbusRoomPayType()
  613. this.refundRequest()
  614. if (this.model.vipCustomerId) {
  615. this.getMemeberCouponList()
  616. }
  617. if (this.model.vipCustomerId) {
  618. getAction('/business/busMemberCard/list', {
  619. id: this.model.vipCustomerId
  620. }).then((res) => {
  621. if (res.success) {
  622. if (res.result.records && res.result.records.length > 0) {
  623. this.memberCard = res.result.records[0]
  624. }
  625. }
  626. })
  627. }
  628. if (this.model.contractTeamId && this.model.contractTeamProtocolId) {
  629. getAction('/business/busMarketAgreementUnit/list', {
  630. id: this.model.contractTeamId
  631. }).then((res) => {
  632. if (res.success) {
  633. var list = res.result.records
  634. if (list.length > 0) {
  635. this.agreementUnitData = list[0]
  636. getAction('/business/busMarketAgreementCustomer/list', {
  637. agreementId: this.model.contractTeamId
  638. }).then((res2) => {
  639. if (res2.success) {
  640. var list2 = res2.result.records
  641. if (list2 && list2.length > 0) {
  642. this.danwei = list2.find(
  643. (t) => t.id == this.model.contractTeamProtocolId
  644. )
  645. }
  646. }
  647. })
  648. }
  649. }
  650. })
  651. }
  652. this.visible = true
  653. },
  654. submitForm() {
  655. const that = this
  656. // 触发表单验证
  657. this.$refs.form.validate((valid) => {
  658. if (valid) {
  659. if (this.model.couponFirstAmount > this.model.consumption.toFixed(2)) {
  660. this.model.couponFirstAmount = 0
  661. this.$message.warning('优惠金额不能大于消费')
  662. return
  663. }
  664. if (this.realityAmount != this.sumAmount) {
  665. that.$message.warning('实收金额和实收合计必须相等')
  666. return
  667. }
  668. console.log(this.model);
  669. // return
  670. var obj = {}
  671. var fees = []
  672. if (this.model.coupon) {
  673. fees.push({
  674. feeType: this.model.feeType,
  675. preferentialType: this.model.preferentialType,
  676. money: this.couponAmount.toFixed(2) - this.model.consumption.toFixed(2),
  677. custorerOrderRemark: '优惠金额',
  678. isPreferential: true
  679. })
  680. }
  681. console.log(fees, 'fees')
  682. if (this.model.couponCard && this.model.couponId) {
  683. var find = this.memeberCouponList.find(
  684. (t) => t.id === this.model.couponId
  685. )
  686. if (find) {
  687. fees.push({
  688. feeType: this.model.feeType,
  689. money: -find.cost.toFixed(2),
  690. custorerOrderRemark: '优惠券',
  691. isPreferential: true,
  692. couponscashId: find.id
  693. })
  694. }
  695. }
  696. // this.payList.forEach((item) => {
  697. // let remark = '结账收款'
  698. // let money = item.money.toFixed(2)
  699. // if (this.isRefund) {
  700. // remark = '结账退款'
  701. // money = -money
  702. // }
  703. // fees.push({
  704. // feeType: this.model.feeType,
  705. // money,
  706. // payType: item.payType,
  707. // custorerOrderRemark: remark,
  708. // isPreferential: this.model.isPreferential,
  709. // preferentialMoney: this.model.preferentialMoney
  710. // })
  711. // })
  712. if (this.isRefund) {
  713. this.feeList.forEach((item) => {
  714. let remark =
  715. // let money = -money
  716. fees.push({
  717. feeType: this.model.feeType,
  718. money: -item.prerefund,
  719. payType: item.payType,
  720. custorerOrderRemark: '结账退款',
  721. isPreferential: this.model.isPreferential,
  722. preferentialMoney: this.model.preferentialMoney
  723. })
  724. })
  725. } else {
  726. this.payList.forEach((item) => {
  727. let remark = '结账收款'
  728. let money = item.money.toFixed(2)
  729. fees.push({
  730. feeType: this.model.feeType,
  731. money,
  732. payType: item.payType,
  733. custorerOrderRemark: remark,
  734. isPreferential: this.model.isPreferential,
  735. preferentialMoney: this.model.preferentialMoney
  736. })
  737. })
  738. }
  739. that.confirmLoading = true
  740. var url =
  741. '/business/busRoomBookingOrders/settle-checkout?bookingOrderId=' +
  742. this.model.bookingOrderId
  743. if (this.model.livingOrderId) {
  744. url =
  745. '/business/busRoomBookingOrders/living-settle-checkout?livingOrderId=' +
  746. this.model.livingOrderId
  747. }
  748. if (
  749. this.model.selectedFeeIds &&
  750. this.model.selectedFeeIds.length > 0
  751. ) {
  752. url = '/business/busRoomBookingOrders/partial-settle'
  753. // 部分
  754. obj = {
  755. fees: fees,
  756. livingOrderId: this.model.livingOrderId,
  757. selectedFeeIds: this.model.selectedFeeIds
  758. }
  759. }
  760. httpAction(
  761. url,
  762. this.model.selectedFeeIds && this.model.selectedFeeIds.length > 0
  763. ? obj
  764. : fees,
  765. 'post'
  766. )
  767. .then((res) => {
  768. if (res.success) {
  769. that.$message.success('结账成功')
  770. that.$emit('ok')
  771. } else {
  772. that.$message.warning(res.message)
  773. }
  774. })
  775. .finally(() => {
  776. that.confirmLoading = false
  777. })
  778. }
  779. })
  780. },
  781. // 退款列表请求数据
  782. refundRequest() {
  783. let returnFeeList = []
  784. // let feeList = []
  785. console.log(this.model);
  786. let livingOrderIds = this.model.livingOrderId
  787. console.log(livingOrderIds);
  788. if (this.model.money < 0) {
  789. postAction('/business/busOrderFee/refundList', livingOrderIds
  790. // pageNo: 1,
  791. // pageSize: 99,
  792. // conditions: 900,
  793. // mobile: this.model.vipCustomerId
  794. ).then((res) => {
  795. if (res.success) {
  796. this.feeList = res.result
  797. }
  798. let templist = this.feeList
  799. templist.forEach(e => {
  800. if (e.returnItem == true) {
  801. e.money = -e.money;
  802. returnFeeList.push(e)
  803. }
  804. })
  805. console.log(templist);
  806. console.log(returnFeeList);
  807. templist.forEach(e => {
  808. let returnMoney = returnFeeList.filter(ele => e.id === ele.returnFeeId).reduce((accumulator, ele) => accumulator + ele.money, 0)
  809. e.returnMoney = returnMoney;
  810. })
  811. templist.forEach(cust => [
  812. // let tempfeelist = returnFeeList.filter(curr => {curr.returnFeeId == cust.id})
  813. // let tempfeelist = returnFeeList.filter(function(item, index, array) {
  814. // return curr.returnFeeId == cust.id
  815. // })
  816. // console.log(tempfeelist);
  817. returnFeeList.forEach(curr => {
  818. if (cust.returnFeeId == curr.returnFeeId) {
  819. let tempindex = templist.findIndex(temp => temp == cust)
  820. templist.splice(tempindex,1)
  821. }
  822. })
  823. ])
  824. console.log(returnFeeList);
  825. // templist.forEach(e => {
  826. // if (e.returnItem == true) {
  827. // e.money = -e.money;
  828. // returnFeeList.push(e)
  829. // } else {
  830. // // 如果是收款
  831. // // e.returnMoney = 0
  832. // // e.prerefund = 0
  833. // // var room = this.model.filter(room => room.roomId === e.roomId)
  834. // // e.roomName = room[0].roomName
  835. // // this.$set(e, 'refundType', e.payType)
  836. // // let payTypeList = JSON.parse(JSON.stringify(this.payTypeList));
  837. // // console.log(room[0].livingOrder.vipCustomerId)
  838. // // console.log(room[0].livingOrder.contractTeamId)
  839. // // console.log(vipIndex)
  840. // // console.log(danweiIndex)
  841. // // this.$set(payTypeList[vipIndex], 'disable', room[0].livingOrder.vipCustomerId == null || room[0].livingOrder.vipCustomerId === '')
  842. // // this.$set(payTypeList[danweiIndex], 'disable', room[0].livingOrder.contractTeamId == null)
  843. // // this.$set(e, 'payTypeList', payTypeList)
  844. // // feeList.push(e)
  845. // }
  846. // })
  847. // this.feeList = feeList
  848. // this.allFeeMoney = 0
  849. // this.allReturnFee = 0
  850. // this.feeList.forEach(e => {
  851. // // 当前收款对象下所有的退款记录
  852. // let returnMoney = returnFeeList.filter(ele => e.id === ele.returnFeeId).reduce((accumulator, ele) => accumulator + ele.money, 0)
  853. // e.returnMoney = returnMoney;
  854. // this.allFeeMoney += e.money;
  855. // this.allReturnFee += returnMoney;
  856. // // console.log(returnMoney);
  857. // })
  858. // console.log(this.feeList);
  859. // console.log(this.templist);
  860. // this.feeList.forEach(index => {
  861. // templist.forEach(item => {
  862. // if (index.id == item.returnFeeId) {
  863. // let tempindex = this.feeList.findIndex(item)
  864. // this.feeList.slice(tempindex,1)
  865. // }
  866. // })
  867. // })
  868. // this.feeList.forEach(item => {
  869. // })
  870. })
  871. }
  872. },
  873. }
  874. }
  875. </script>
  876. <style scoped>
  877. .dynamic-delete-button {
  878. cursor: pointer;
  879. position: relative;
  880. /* top: 4px; */
  881. margin-left: 5px;
  882. font-size: 18px;
  883. color: #1890ff;
  884. transition: all 0.3s;
  885. }
  886. .dynamic-delete-button:hover {
  887. color: #777;
  888. }
  889. .dynamic-delete-button[disabled] {
  890. cursor: not-allowed;
  891. opacity: 0.5;
  892. }
  893. .refund_style {
  894. font-size: 32px;
  895. color: red;
  896. text-align: center;
  897. padding-top: 7%;
  898. /* margin: 0 auto; */
  899. /* display: inline-block; */
  900. /* margin-top: 60px; */
  901. }
  902. .crad_style {
  903. display: flex;
  904. background-color: #fcfcfc;
  905. width: 100%;
  906. border-radius: 5%;
  907. }
  908. .ant-col-16 {
  909. border-left: 2px solid #fc9424;
  910. }
  911. .ant-form-item {
  912. margin-bottom: 16px;
  913. }
  914. .presentation_style {
  915. /* font-size: ; */
  916. color: #fc9424;
  917. padding-left: 25px;
  918. padding-bottom: 5px;
  919. border-bottom: 1px solid #fc9424;
  920. padding-top: 10px;
  921. }
  922. .presentation_style_two {
  923. /* padding-left: 25px; */
  924. /* padding-bottom: 5px; */
  925. border-top: 1px solid #fc9424;
  926. margin-top: 10px;
  927. padding: 20px 0px 5px 25px;
  928. }
  929. .receipt_style {
  930. margin-top: 30px;
  931. }
  932. .settle_style {
  933. color: red !important;
  934. }
  935. </style>