index.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <el-col :span="12">
  5. <el-card class="box-card custom-card">
  6. <div slot="header" class="clearfix">
  7. <span>选择客户</span>
  8. <el-button type="primary" style="float: right" plain icon="el-icon-plus" @click="handleAdd" v-if="userInfoVO.userType == '02'">新建客户 </el-button>
  9. </div>
  10. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px" @submit.native.prevent>
  11. <el-form-item label="手机号" prop="phoneNumber">
  12. <el-input v-model="queryParams.phoneNumber" placeholder="请输入手机号" clearable maxlength="11" @change="searchUser" @keyup.enter.native="searchUser" />
  13. </el-form-item>
  14. <el-form-item>
  15. <!-- <el-button type="primary" icon="el-icon-full-screen" @click="qrcodeSearchUser">扫码</el-button>-->
  16. <el-button type="primary" icon="el-icon-search" @click="searchUser">查询</el-button>
  17. </el-form-item>
  18. </el-form>
  19. <el-descriptions title="用户信息" v-if="appUserInfo" :column="2">
  20. <el-descriptions-item label="用户名" span="2">{{ appUserInfo.realName }}</el-descriptions-item>
  21. <el-descriptions-item label="手机号" span="2">{{ appUserInfo.phoneNumber }} </el-descriptions-item>
  22. <el-descriptions-item label="现金余额">
  23. {{ (appUserInfo.rechargeBalance * 100) / 100 }}
  24. </el-descriptions-item>
  25. <el-descriptions-item label="赠送余额">
  26. {{ (appUserInfo.giveBalance * 100) / 100 }}
  27. </el-descriptions-item>
  28. <el-descriptions-item label="福利金">
  29. {{ (appUserInfo.welfareBalance * 100) / 100 }}
  30. </el-descriptions-item>
  31. <el-descriptions-item label="积分">
  32. {{ appUserInfo.pointBalance }}
  33. </el-descriptions-item>
  34. <el-descriptions-item label="等级">{{ appUserInfo.level }}</el-descriptions-item>
  35. </el-descriptions>
  36. <Page uri="/mapi/recharge/card/list" :request-params="cardParams" ref="pagination" v-if="appUserInfo" :page-size="5">
  37. <el-table-column label="卡号" align="center" prop="cardNo" width="100" />
  38. <el-table-column label="储值门店" align="center" prop="rechargeStoreName" width="100">
  39. <template slot-scope="scope">
  40. {{ scope.row.useBindStoreName == null ? '--' : scope.row.useBindStoreName }}
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="充值金额(元)" align="center" prop="rechargeAmount" width="120" />
  44. <el-table-column label="卡内余额(元)" align="center" prop="rechargeAmount" width="120">
  45. <template slot-scope="scope">
  46. <span style="display: block; text-align: left">现金金额: {{ scope.row.rechargeBalance }}</span>
  47. <span style="display: block; text-align: left">赠送金额: {{ scope.row.giveBalance }}</span>
  48. <span style="display: block; text-align: left">福利金额: {{ scope.row.welfareBalance }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="充值时间" align="center" prop="rechargeTime" width="100">
  52. <template slot-scope="scope">
  53. {{ scope.row.rechargeTime == null ? '--' : scope.row.rechargeTime }}
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="状态" align="center" prop="rechargeStatus">
  57. <template slot-scope="scope">
  58. <dict-tag :options="dict.type.recharge_use_status" :value="scope.row.rechargeStatus" />
  59. </template>
  60. </el-table-column>
  61. </Page>
  62. </el-card>
  63. </el-col>
  64. <!-- 充值类型 -->
  65. <el-col :span="12">
  66. <el-card class="box-card">
  67. <div slot="header" class="clearfix">
  68. <span>充值信息</span>
  69. </div>
  70. <el-form ref="rechargeFrom" :model="rechargeFrom" :rules="rules" label-width="160px" @submit.native.prevent>
  71. <el-col :span="24">
  72. <el-form-item label="请选择充值类型" label-width="120px" prop="rechargeType">
  73. <el-col :span="18">
  74. <el-radio-group v-model="rechargeFrom.rechargeType" style="width: 500px" @input="clearData">
  75. <el-radio-button label="3">自定义充值</el-radio-button>
  76. <el-radio-button label="0">套餐充值</el-radio-button>
  77. <el-radio-button label="1">福利金额充值</el-radio-button>
  78. <!-- <el-radio-button label="2">卡密充值</el-radio-button>-->
  79. </el-radio-group>
  80. </el-col>
  81. </el-form-item>
  82. <el-form-item label="请选择充值套餐" label-width="120px" prop="rechargeMealId" v-if="rechargeFrom.rechargeType == 0">
  83. <el-col :span="18">
  84. <el-select v-model="rechargeFrom.rechargeMealId" placeholder="请选择充值套餐" style="width: 300px" clearable @input="getActivityInfo(rechargeFrom.rechargeMealId)">
  85. <el-option v-for="recharge in rechargeList" :key="recharge.id" :label="recharge.title" :value="recharge.id" />
  86. </el-select>
  87. </el-col>
  88. </el-form-item>
  89. <el-form-item label="自定义金额" label-width="120px" prop="customAmount" v-if="rechargeFrom.rechargeType == 3">
  90. <el-col :span="18">
  91. <el-input-number v-model="rechargeFrom.customAmount" :controls="false" :min="0" :max="10000" style="width: 300px"></el-input-number>
  92. </el-col>
  93. </el-form-item>
  94. <el-form-item label="福利金额(元)" label-width="120px" prop="welfareAmount" v-if="rechargeFrom.rechargeType == 1">
  95. <el-col :span="18">
  96. <el-input-number v-model="rechargeFrom.welfareAmount" :controls="false" :min="0" :max="999999" style="width: 300px"></el-input-number>
  97. </el-col>
  98. </el-form-item>
  99. <el-form-item label="卡号" label-width="120px" v-if="rechargeFrom.rechargeType == 2" required>
  100. <el-col :span="18">
  101. <el-input v-model="rechargeFrom.rechargeCardNo" style="width: 300px"></el-input>
  102. </el-col>
  103. </el-form-item>
  104. <el-form-item label="密码" label-width="120px" v-if="rechargeFrom.rechargeType == 2" required>
  105. <el-col :span="18">
  106. <el-input v-model="rechargeFrom.rechargeCardPassword" style="width: 300px"></el-input>
  107. </el-col>
  108. </el-form-item>
  109. <el-form-item label="充值备注" label-width="120px" prop="remark">
  110. <el-col :span="18">
  111. <el-input type="textarea" placeholder="请输入充值备注" v-model="rechargeFrom.remark" style="width: 300px"></el-input>
  112. </el-col>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="24">
  116. <el-card style="width: 430px" v-if="rechargeFrom.rechargeType == 0">
  117. <el-descriptions title="充值活动信息" :column="1" :label-style="{ 'text-align': 'center' }" :contentStyle="{ 'text-align': 'center' }">
  118. <el-descriptions-item label="本次充值金额" style="width: 100px" v-if="activityAmount != null && activityAmount != ''">
  119. {{ getRechargeTypeInfo == '' ? '--' : getRechargeTypeInfo.rechargeAmount }}
  120. </el-descriptions-item>
  121. <el-descriptions-item label="原赠送金额" v-if="activityAmount != null && activityAmount != ''">
  122. {{ getRechargeTypeInfo == '' ? '--' : getRechargeTypeInfo.giveAmount }}
  123. </el-descriptions-item>
  124. <el-descriptions-item label="活动赠送金额" v-if="activityAmount != null && activityAmount != ''">
  125. {{ activityAmount }}
  126. </el-descriptions-item>
  127. <el-descriptions-item label="参与活动" v-if="activityAmount == null || activityAmount == ''"> 此套餐暂未参与活动 </el-descriptions-item>
  128. </el-descriptions>
  129. </el-card>
  130. </el-col>
  131. <!-- <el-col :span="24">-->
  132. <!-- <el-card class="box-card" shadow="hover" style="width: 150px" @click.native="clickRecharge">-->
  133. <!-- <div slot="header" class="clearfix">-->
  134. <!-- <span></span>-->
  135. <!-- <span style="float: right">赠送500元</span>-->
  136. <!-- </div>-->
  137. <!-- <div class="text item">-->
  138. <!-- <span>{{'充值金额 ' + "1" }}</span>-->
  139. <!-- <span>{{'充值金额 ' + "1" }}</span>-->
  140. <!-- </div>-->
  141. <!-- </el-card>-->
  142. <!-- </el-col>-->
  143. </el-form>
  144. <div>
  145. <el-button type="primary" @click="submitCash" style="margin-left: 3%; margin-top: 20px">收银 </el-button>
  146. </div>
  147. </el-card>
  148. </el-col>
  149. </el-row>
  150. <el-dialog title="确认充值" :visible.sync="openWelfareRecharge" width="400px" append-to-body>
  151. <el-form ref="payFrom" :model="rechargeInfo" label-width="100px" style="margin-top: 20px" @submit.native.prevent>
  152. <el-form-item label="充值金额:">
  153. <span style="font-size: 16px; font-weight: bold">¥{{ rechargeInfo.welfareAmount }}</span>
  154. </el-form-item>
  155. <el-form-item label="备注:">
  156. <span style="font-size: 16px; font-weight: bold">{{ rechargeInfo.remark }}</span>
  157. </el-form-item>
  158. </el-form>
  159. <el-button type="primary" @click="submitSettlement" style="margin: 20px 80px 0; width: 200px; height: 40px">确认</el-button>
  160. </el-dialog>
  161. <!-- 支付方式 -->
  162. <el-dialog :title="rechargeTitle" :visible.sync="openRecharge" width="800px" :close-on-click-modal="false" class="cashier-dialog" :before-close="checkClosePay" append-to-body>
  163. <!-- 订单信息 -->
  164. <div class="order-info">
  165. <div class="amount-section">
  166. <div class="total-amount">
  167. <span class="label">应付金额</span>
  168. <span class="value">¥{{ getOrderNeedAmount }}</span>
  169. </div>
  170. <div class="detail-list">
  171. <div class="detail-item">
  172. <span class="label">充值金额:</span>
  173. <span class="value">¥{{ rechargeInfo.rechargeAmount }}</span>
  174. </div>
  175. <div class="detail-item">
  176. <span class="label">赠送金额:</span>
  177. <span class="value">¥{{ activityAmount || rechargeInfo.giveAmount }}</span>
  178. </div>
  179. <div class="detail-item">
  180. <span class="label">赠送积分:</span>
  181. <span class="value">{{ rechargeInfo.givePointAmount }}</span>
  182. </div>
  183. <div class="detail-item">
  184. <span class="label">福利金额:</span>
  185. <span class="value">¥{{ rechargeInfo.welfareAmount }}</span>
  186. </div>
  187. </div>
  188. </div>
  189. <!-- 支付方式选择 -->
  190. <div class="payment-section">
  191. <div class="section-title">支付方式</div>
  192. <div class="payment-methods">
  193. <div v-for="(method, index) in paymentMethods" :key="index" :class="['payment-method', { 'is-active': payFrom.payType === method.value }]" @click="selectPaymentMethod(method.value)">
  194. <i :class="method.icon"></i>
  195. <span>{{ method.label }}</span>
  196. </div>
  197. </div>
  198. <!-- 支付金额输入区域 -->
  199. <div class="payment-input" v-if="payFrom.payType === '0'">
  200. <div class="input-group">
  201. <div class="input-item">
  202. <span class="label">微信/支付宝</span>
  203. <div class="readonly-value">¥{{ getOrderNeedAmount }}</div>
  204. </div>
  205. </div>
  206. <!-- 增加条形码扫描框 -->
  207. <div class="scan-input">
  208. <el-input v-model="payFrom.wxBarcode" placeholder="请扫描付款码" prefix-icon="el-icon-camera" clearable autofocus> </el-input>
  209. </div>
  210. </div>
  211. <!-- 支付金额输入区域 -->
  212. <div class="payment-input" v-if="payFrom.payType === '2'">
  213. <div class="input-group">
  214. <div class="input-item">
  215. <span class="label">现金支付</span>
  216. <div class="readonly-value">¥{{ getOrderNeedAmount }}</div>
  217. </div>
  218. </div>
  219. </div>
  220. <!-- 组合支付时显示输入框 -->
  221. <div v-if="payFrom.payType === '9'">
  222. <div class="payment-input">
  223. <div class="input-group">
  224. <div class="input-item">
  225. <span class="label">现金支付</span>
  226. <el-input v-model="payFrom.cashPayAmount" placeholder="请输入现金金额" @input="changeCashPayAmount">
  227. <template slot="prepend">¥</template>
  228. </el-input>
  229. </div>
  230. <div class="input-item">
  231. <span class="label">电子支付</span>
  232. <div class="readonly-value">¥{{ payFrom.otherPayAmount || 0 }}</div>
  233. </div>
  234. </div>
  235. <!-- 增加条形码扫描框 -->
  236. <div class="scan-input">
  237. <el-input v-model="payFrom.wxBarcode" placeholder="请扫描付款码" prefix-icon="el-icon-camera" clearable autofocus> </el-input>
  238. </div>
  239. </div>
  240. </div>
  241. </div>
  242. </div>
  243. <!-- 底部操作区 -->
  244. <div slot="footer" class="dialog-footer">
  245. <div class="payment-summary">
  246. <span class="label">应收</span>
  247. <span class="amount">¥{{ getOrderNeedAmount }}</span>
  248. </div>
  249. <el-button type="primary" size="large" :loading="isSubmitting" @click="submitSettlement"> 确认收款 </el-button>
  250. </div>
  251. </el-dialog>
  252. <el-dialog title="选择优惠券" :visible.sync="openCoupon" width="60%">
  253. <template>
  254. <el-table :data="couponList" style="width: 100%" @selection-change="handleSelectionChange">
  255. <el-table-column type="selection" width="55" align="center" fixed="left" />
  256. <el-table-column label="优惠券" align="center" prop="couponTypeTitle" />
  257. <el-table-column label="优惠内容" align="center">
  258. <template slot-scope="scope">
  259. <span>抵扣充值金额:{{ scope.row.deductRechargeAmount }}元</span>
  260. </template>
  261. </el-table-column>
  262. </el-table>
  263. <el-row>
  264. <div style="margin-top: 30px">
  265. <el-button @click="submitAlreadySelectCouponList" size="small" type="primary" style="float: right"> 确定 </el-button>
  266. </div>
  267. </el-row>
  268. </template>
  269. </el-dialog>
  270. <!-- 添加用户对话框 -->
  271. <el-dialog :title="title" :visible.sync="open" size="30%" append-to-body :before-close="checkCloseUserPage">
  272. <el-row :gutter="15">
  273. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  274. <el-col :span="24">
  275. <el-form-item label="昵称" prop="nickName">
  276. <el-input v-model="form.nickName" placeholder="请输入昵称" maxlength="50" show-word-limit clearable />
  277. </el-form-item>
  278. <el-form-item label="真实姓名" prop="realName">
  279. <el-input v-model="form.realName" placeholder="请输入真实姓名" maxlength="5" show-word-limit clearable />
  280. </el-form-item>
  281. <el-form-item label="手机号" prop="phoneNumber">
  282. <el-input v-model="form.phoneNumber" placeholder="请输入手机号" maxlength="11" show-word-limit clearable />
  283. </el-form-item>
  284. <el-form-item label="性别" prop="sex">
  285. <el-select v-model="form.sex" placeholder="请选择性别" clearable>
  286. <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
  287. </el-select>
  288. </el-form-item>
  289. <el-form-item label="生日" prop="birthday" clearable>
  290. <el-date-picker clearable v-model="form.birthday" type="date" value-format="yyyy-MM-dd" placeholder="请选择生日"></el-date-picker>
  291. </el-form-item>
  292. <el-form-item label="头像地址" prop="avatarUrl">
  293. <image-upload v-model="form.avatarUrl" :limit="1" />
  294. </el-form-item>
  295. <el-form-item label="客户等级" prop="level">
  296. <el-input-number v-model="form.level" :min="1" :max="50" label="请输入客户等级"></el-input-number>
  297. </el-form-item>
  298. <el-form-item label="备注" prop="remark">
  299. <el-input v-model="form.remark" placeholder="请输入备注" maxlength="50" show-word-limit />
  300. </el-form-item>
  301. </el-col>
  302. </el-form>
  303. </el-row>
  304. <div slot="footer" class="dialog-footer">
  305. <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>
  306. <el-button @click="cancel">取 消</el-button>
  307. </div>
  308. </el-dialog>
  309. <pay-status-popup ref="payStatusPopup" hidePointer hideUser @paySuccess="checkIsAllPay"></pay-status-popup>
  310. </div>
  311. </template>
  312. <script>
  313. import { listType } from '@/api/recharge/type'
  314. import { addUser, findUserByPhoneNumber, getMemberCouponInfoByRecharge, updateUser } from '@/api/app/user'
  315. import { addOrder, getOrderIsAllPayByOrderNo, getOrderStatusByOrderNo, morePay } from '@/api/recharge/order'
  316. import { getRechargeTypeRelationActivityInfo } from '@/api/activity/rechargeItem'
  317. import payStatusPopup from '@/components/payStatusPopup'
  318. export default {
  319. name: 'workRecharge',
  320. dicts: ['recharge_use_status', 'sys_user_sex'],
  321. components: { payStatusPopup },
  322. data() {
  323. return {
  324. alreadyPayTotal: 0,
  325. orderNeedPayAmount: 0,
  326. couponAmount: 0,
  327. alreadyPayInfo: {},
  328. payConfirm: false,
  329. payFrom: {},
  330. userInfoVO: null,
  331. orderNo: null,
  332. // 优惠卷
  333. // couponInfo:null,
  334. couponList: [],
  335. // 客户信息
  336. appUserInfo: null,
  337. rechargeList: null,
  338. rechargeInfo: {},
  339. // 充值类型参数
  340. rechargeFrom: {
  341. rechargeType: '3',
  342. // 充值套餐id
  343. rechargeMealId: null,
  344. // 自定义金额
  345. customAmount: null,
  346. remark: '',
  347. // 福利金额
  348. welfareAmount: null,
  349. // 卡号
  350. rechargeCardNo: null,
  351. // 密码
  352. rechargeCardPassword: null
  353. },
  354. // 遮罩层
  355. loading: true,
  356. // 选中数组
  357. ids: [],
  358. // 非单个禁用
  359. single: true,
  360. // 非多个禁用
  361. multiple: true,
  362. // 显示搜索条件
  363. showSearch: true,
  364. // 总条数
  365. total: 0,
  366. // 弹出层标题
  367. title: '',
  368. rechargeTitle: '',
  369. // 是否显示弹出层
  370. open: false,
  371. openRecharge: false,
  372. openWelfareRecharge: false,
  373. openCoupon: false,
  374. // 查询参数
  375. queryParams: {
  376. pageNum: 1,
  377. pageSize: 10
  378. },
  379. cardParams: {
  380. rechargeUserId: 0
  381. },
  382. couponParams: {
  383. pageNum: 1,
  384. pageSize: 999,
  385. appUserId: null
  386. },
  387. // 表单参数
  388. form: {},
  389. // 表单校验
  390. rules: {
  391. rechargeCardNo: [
  392. {
  393. pattern: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/,
  394. required: true,
  395. message: '请输入正整数类型',
  396. trigger: 'blur'
  397. }
  398. ],
  399. rechargeCardPassword: [
  400. {
  401. pattern: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/,
  402. required: true,
  403. message: '请输入正整数类型',
  404. trigger: 'blur'
  405. }
  406. ],
  407. nickName: [
  408. {
  409. required: true,
  410. message: '昵称不能为空',
  411. trigger: 'blur'
  412. }
  413. ],
  414. realName: [
  415. {
  416. required: true,
  417. message: '真实姓名不能为空',
  418. trigger: 'blur'
  419. }
  420. ],
  421. phoneNumber: [
  422. {
  423. required: true,
  424. message: '手机号不能为空',
  425. trigger: 'blur'
  426. },
  427. {
  428. pattern: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/,
  429. required: true,
  430. message: '请输入数量,且为正整数类型',
  431. trigger: 'blur'
  432. },
  433. { min: 11, max: 11, message: '手机号至少11位', trigger: 'blur' }
  434. ],
  435. sex: [
  436. {
  437. required: true,
  438. message: '性别不能为空',
  439. trigger: 'blur'
  440. }
  441. ],
  442. birthday: [
  443. {
  444. required: true,
  445. message: '生日不能为空',
  446. trigger: 'blur'
  447. }
  448. ]
  449. },
  450. authCode: null,
  451. activityAmount: null,
  452. alreadySelectCouponList: [],
  453. //支付检测
  454. isPaying: false,
  455. isSubmitting: false,
  456. paymentMethods: [
  457. { label: '现金支付', value: '2', icon: 'el-icon-money' },
  458. { label: '微信/支付宝', value: '0', icon: 'el-icon-mobile-phone' },
  459. { label: '组合支付', value: '9', icon: 'el-icon-wallet' }
  460. ],
  461. quickAmounts: ['100', '200', '500', '1000']
  462. }
  463. },
  464. created() {
  465. this.handleUser()
  466. this.getRechargeList()
  467. },
  468. computed: {
  469. getRechargeTypeInfo() {
  470. if (this.rechargeFrom.rechargeMealId != null) {
  471. return this.rechargeList.find((item) => item.id == this.rechargeFrom.rechargeMealId)
  472. } else {
  473. return ''
  474. }
  475. },
  476. getCouponAmount() {
  477. this.couponAmount = 0
  478. if (this.alreadySelectCouponList.length == 0) {
  479. return this.couponAmount
  480. }
  481. if (this.alreadySelectCouponList.length > 0) {
  482. this.alreadySelectCouponList.forEach((coupon) => {
  483. this.couponAmount = this.couponAmount + parseFloat(coupon.deductRechargeAmount)
  484. })
  485. }
  486. return this.couponAmount
  487. },
  488. getOrderNeedAmount() {
  489. this.orderNeedPayAmount = parseFloat(this.rechargeInfo.rechargeAmount) - parseFloat(this.couponAmount) > 0 ? parseFloat(this.rechargeInfo.rechargeAmount) - parseFloat(this.couponAmount) : 0
  490. return this.orderNeedPayAmount
  491. }
  492. },
  493. methods: {
  494. changeCashPayAmount(value) {
  495. this.payFrom.cashPayAmount = value.replace(/[^\d]/g, '')
  496. this.payFrom.otherPayAmount = Math.round((Number(this.orderNeedPayAmount) - Number(this.payFrom.cashPayAmount)) * 100) / 100
  497. },
  498. clickRecharge(done) {
  499. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  500. .then(function () {
  501. done()
  502. })
  503. .then(() => {})
  504. .catch(() => {})
  505. },
  506. getActivityInfo(rechargeTypeId) {
  507. if (rechargeTypeId != null && rechargeTypeId != '') {
  508. getRechargeTypeRelationActivityInfo(rechargeTypeId, this.userInfoVO.storeId).then((response) => {
  509. this.activityAmount = response.data
  510. })
  511. } else {
  512. this.activityAmount = null
  513. }
  514. },
  515. clearData() {
  516. this.rechargeFrom.rechargeMealId = null
  517. this.rechargeFrom.customAmount = null
  518. this.rechargeFrom.welfareAmount = null
  519. this.rechargeFrom.rechargeCardNo = null
  520. this.rechargeFrom.rechargeCardPassword = null
  521. this.activityAmount = null
  522. },
  523. openCouponList() {
  524. this.getCouponList()
  525. this.openCoupon = true
  526. },
  527. // 获取优惠券集合
  528. getCouponList() {
  529. if (this.appUserInfo == null) {
  530. this.couponList = []
  531. return
  532. }
  533. this.couponParams.appUserId = this.appUserInfo.id
  534. getMemberCouponInfoByRecharge(this.couponParams).then((response) => {
  535. this.couponList = response.data.records
  536. })
  537. },
  538. // 获取登录人信息
  539. handleUser() {
  540. this.userInfoVO = this.getUserInfo()
  541. },
  542. //搜索用户
  543. searchUser() {
  544. this.$refs['queryForm'].validate((valid) => {
  545. if (valid) {
  546. findUserByPhoneNumber(this.queryParams).then((res) => {
  547. this.appUserInfo = res.data
  548. if (this.appUserInfo) {
  549. this.cardParams.rechargeUserId = this.appUserInfo.id
  550. this.$nextTick(() => {
  551. this.$refs.pagination.handleSearch(true)
  552. })
  553. }
  554. })
  555. }
  556. })
  557. },
  558. //条码搜索用户
  559. qrcodeSearchUser() {},
  560. // 获取 充值套餐集合
  561. getRechargeList() {
  562. listType().then((response) => {
  563. this.rechargeList = response.rows
  564. })
  565. },
  566. // 关闭用户新建页面 二次确认
  567. checkCloseUserPage(done) {
  568. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  569. .then(function () {
  570. done()
  571. })
  572. .then(() => {})
  573. .catch(() => {})
  574. },
  575. // 关闭支付页面 二次确认
  576. checkClosePay(done) {
  577. this.$confirm('是否确定取消支付?')
  578. .then(function () {
  579. done()
  580. })
  581. .then(() => {})
  582. .catch(() => {})
  583. },
  584. // 创建用户
  585. submitForm() {
  586. this.$refs['form'].validate((valid) => {
  587. if (valid) {
  588. if (this.form.id != null) {
  589. updateUser(this.form).then((response) => {
  590. this.$modal.msgSuccess('修改成功')
  591. this.open = false
  592. })
  593. } else {
  594. addUser(this.form).then((response) => {
  595. this.$modal.msgSuccess('新增成功')
  596. this.open = false
  597. })
  598. }
  599. }
  600. })
  601. },
  602. // 收银
  603. submitCash() {
  604. if (this.appUserInfo == null) {
  605. this.$message.error('请选择客户')
  606. return
  607. }
  608. // 重置
  609. this.resetPayInfo()
  610. this.rechargeInfo.remark = this.rechargeFrom.remark
  611. // 自定义充值
  612. if (this.rechargeFrom.rechargeType == '3') {
  613. if (this.rechargeFrom.customAmount == '0') {
  614. this.$message.error('充值金额不能为0元')
  615. return
  616. }
  617. this.rechargeInfo.rechargeAmount = this.rechargeFrom.customAmount
  618. this.rechargeInfo.giveAmount = 0
  619. this.rechargeInfo.givePointAmount = 0
  620. this.rechargeInfo.welfareAmount = 0
  621. this.rechargeInfo.rechargeType = this.rechargeFrom.rechargeType
  622. this.rechargeInfo.rechargeTypeId = null
  623. }
  624. // 套餐充值
  625. if (!this.rechargeFrom.rechargeType || this.rechargeFrom.rechargeType == '0') {
  626. if (this.rechargeFrom.rechargeMealId == null) {
  627. this.$message.error('充值套餐不能为空')
  628. return
  629. }
  630. let recharge
  631. recharge = this.rechargeList.find((item) => item.id == this.rechargeFrom.rechargeMealId)
  632. this.rechargeInfo.rechargeAmount = recharge.rechargeAmount
  633. this.rechargeInfo.giveAmount = recharge.giveAmount
  634. this.rechargeInfo.givePointAmount = recharge.givePointAmount
  635. this.rechargeInfo.welfareAmount = 0
  636. this.rechargeInfo.rechargeType = this.rechargeFrom.rechargeType
  637. this.rechargeInfo.rechargeTypeId = recharge.id
  638. }
  639. // 福利金额充值
  640. if (this.rechargeFrom.rechargeType == '1') {
  641. if (!this.rechargeFrom.rechargeType || this.rechargeFrom.welfareAmount == '0') {
  642. this.$message.error('充值金额不能为0元')
  643. return
  644. }
  645. if (!this.rechargeFrom.remark) {
  646. this.$message.error('请输入备注')
  647. return
  648. }
  649. this.rechargeInfo.rechargeAmount = 0
  650. this.rechargeInfo.giveAmount = 0
  651. this.rechargeInfo.givePointAmount = 0
  652. this.rechargeInfo.welfareAmount = this.rechargeFrom.welfareAmount
  653. this.rechargeInfo.rechargeType = this.rechargeFrom.rechargeType
  654. this.rechargeInfo.rechargeTypeId = null
  655. this.rechargeInfo.remark = this.rechargeFrom.remark
  656. this.openWelfareRecharge = true
  657. this.orderNo = null
  658. return
  659. }
  660. // 卡密充值
  661. if (this.rechargeFrom.rechargeType == '2') {
  662. if (this.rechargeFrom.rechargeCardNo == null || this.rechargeFrom.rechargeCardPassword == null) {
  663. this.$message.error('卡号/密码,不能为空')
  664. return
  665. }
  666. const orderRechargePayDTO = {
  667. appUserId: this.appUserInfo.id,
  668. rechargeType: this.rechargeFrom.rechargeType,
  669. cardNo: this.rechargeFrom.rechargeCardNo,
  670. password: this.rechargeFrom.rechargeCardPassword,
  671. remark: this.rechargeFrom.remark
  672. }
  673. addOrder(orderRechargePayDTO).then((response) => {
  674. if (response.data.isAllPayEnd == true) {
  675. this.$modal.msgSuccess('充值成功')
  676. this.searchUser()
  677. this.clearData()
  678. }
  679. })
  680. return
  681. }
  682. this.rechargeTitle = '支付方式选择'
  683. this.openRecharge = true
  684. this.orderNo = null
  685. },
  686. // 结算
  687. submitSettlement() {
  688. const orderRechargePayDTO = {
  689. orderNo: this.orderNo,
  690. appUserId: this.appUserInfo.id,
  691. payType: this.payFrom.payType,
  692. isInstalment: this.payFrom.isInstalment,
  693. couponIds: [],
  694. remark: this.rechargeInfo.remark,
  695. rechargeAmount: this.rechargeInfo.rechargeAmount,
  696. giveAmount: this.rechargeInfo.giveAmount,
  697. givePointAmount: this.rechargeInfo.givePointAmount,
  698. rechargeTypeId: this.rechargeInfo.rechargeTypeId,
  699. welfareAmount: this.rechargeInfo.welfareAmount,
  700. rechargeType: this.rechargeInfo.rechargeType,
  701. payAmount: this.orderNeedPayAmount
  702. }
  703. if (this.alreadySelectCouponList.length > 0) {
  704. this.alreadySelectCouponList.forEach((vo) => {
  705. orderRechargePayDTO.couponIds.push(vo.id)
  706. })
  707. } else {
  708. orderRechargePayDTO.couponIds = []
  709. }
  710. if (this.payFrom.isInstalment == 'N') {
  711. orderRechargePayDTO.thisPayAmount = this.orderNeedPayAmount
  712. }
  713. if (this.payFrom.isInstalment == 'Y') {
  714. orderRechargePayDTO.thisPayAmount = this.payFrom.thisPayMoney
  715. }
  716. // 现金支付
  717. if (this.payFrom.payType == 2) {
  718. orderRechargePayDTO.thisPayAmount = this.orderNeedPayAmount
  719. }
  720. // 微信支付
  721. if (this.payFrom.payType == 0) {
  722. orderRechargePayDTO.authCode = this.payFrom.wxBarcode
  723. }
  724. // 支付宝支付
  725. if (this.payFrom.payType == 1) {
  726. orderRechargePayDTO.authCode = this.payFrom.aliPayBarcode
  727. }
  728. if (this.payFrom.payType == 9) {
  729. if (!this.payFrom.cashPayAmount) {
  730. this.$message.error('请输入现金支付金额')
  731. return
  732. }
  733. if (Number(this.payFrom.cashPayAmount) >= Number(this.orderNeedPayAmount)) {
  734. this.$message.error('现金支付金额必须小于还需支付金额')
  735. return
  736. }
  737. orderRechargePayDTO.cashPayAmount = this.payFrom.cashPayAmount || 0
  738. orderRechargePayDTO.otherPayAmount = this.payFrom.otherPayAmount || 0
  739. orderRechargePayDTO.authCode = this.payFrom.wxBarcode
  740. }
  741. this.$confirm('确定进行支付结算吗?')
  742. .then(() => {
  743. const loading = this.$loading({
  744. lock: true,
  745. text: 'Loading',
  746. spinner: 'el-icon-loading',
  747. background: 'rgba(0, 0, 0, 0.7)'
  748. })
  749. addOrder(orderRechargePayDTO).then(
  750. (response) => {
  751. loading.close()
  752. this.orderNo = response.data.orderNo
  753. if (response.data.payResult == 100) {
  754. this.$refs.payStatusPopup.open(5, response.data)
  755. var intervalId = setInterval(() => {
  756. this.intervalCheckOrderStatus(intervalId, this.orderNo)
  757. }, 4000)
  758. }
  759. if (response.data.payResult == 200) {
  760. this.$refs.payStatusPopup.open(1, response.data)
  761. this.checkIsAllPay(this.orderNo)
  762. }
  763. if (response.data.payResult == 101 || response.data.payResult == 0) {
  764. this.$refs.payStatusPopup.open(4, response.data)
  765. }
  766. },
  767. (err) => {
  768. loading.close()
  769. }
  770. )
  771. })
  772. .catch(() => {})
  773. },
  774. intervalCheckOrderStatus(intervalId, orderNo) {
  775. getOrderStatusByOrderNo({ orderNo: orderNo })
  776. .then((response) => {
  777. if (response.data.payResult == '100') {
  778. return
  779. }
  780. if (response.data.payResult == 101 || response.data.payResult == 0) {
  781. this.$refs.payStatusPopup.open(4, response.data)
  782. clearInterval(intervalId)
  783. return
  784. }
  785. this.$refs.payStatusPopup.open(1, response.data)
  786. this.checkIsAllPay(this.orderNo)
  787. clearInterval(intervalId)
  788. })
  789. .catch((e) => {
  790. this.$refs.payStatusPopup.open(4, e.data)
  791. })
  792. },
  793. checkIsAllPay(orderNo) {
  794. this.openRecharge = false
  795. this.openWelfareRecharge = false
  796. this.searchUser()
  797. },
  798. // 保存临时的 支付金额 用于取消支付提示信息
  799. saveAlreadyPayAmount() {
  800. // 微信
  801. if (this.payFrom.payType == '0') {
  802. this.alreadyPayInfo.alreadyPayWX = this.alreadyPayInfo.alreadyPayWX + parseFloat(this.payFrom.thisPayMoney)
  803. }
  804. // 支付宝
  805. if (this.payFrom.payType == '1') {
  806. this.alreadyPayInfo.alreadyPayAli = this.alreadyPayInfo.alreadyPayAli + parseFloat(this.payFrom.thisPayMoney)
  807. }
  808. // 现金
  809. if (this.payFrom.payType == '2') {
  810. this.alreadyPayInfo.alreadyPayCash = this.alreadyPayInfo.alreadyPayCash + parseFloat(this.payFrom.thisPayMoney)
  811. }
  812. },
  813. // 支付页面 确认按钮
  814. submitConfirm() {
  815. this.payConfirm = true
  816. },
  817. // 切换支付方式
  818. changePayType() {
  819. this.payConfirm = false
  820. this.payFrom.thisPayMoney = null
  821. this.payFrom.aliPayBarcode = null
  822. this.payFrom.wxBarcode = null
  823. },
  824. // 取消按钮
  825. cancel() {
  826. this.open = false
  827. this.reset()
  828. },
  829. // 表单重置
  830. reset() {
  831. this.form = {
  832. id: null,
  833. phoneNumber: null,
  834. nickName: null,
  835. realName: null,
  836. sex: null,
  837. birthday: null,
  838. avatarUrl: null,
  839. unionId: null,
  840. createTime: null,
  841. payPassword: null,
  842. isUsePayPassword: null,
  843. status: '0',
  844. level: null
  845. }
  846. this.resetForm('form')
  847. },
  848. resetPayInfo() {
  849. this.alreadyPayTotal = 0
  850. this.couponAmount = 0
  851. this.payConfirm = false
  852. this.rechargeInfo = {}
  853. this.alreadySelectCouponList = []
  854. this.payFrom = {
  855. payType: '2',
  856. isInstalment: 'N',
  857. wxBarcode: null,
  858. aliPayBarcode: null,
  859. thisPayMoney: 0,
  860. isUsedCoupon: false
  861. }
  862. this.alreadyPayInfo = {
  863. alreadyPayWX: 0,
  864. alreadyPayCash: 0,
  865. alreadyPayAli: 0
  866. }
  867. },
  868. /** 新增按钮操作 */
  869. handleAdd() {
  870. this.reset()
  871. this.open = true
  872. this.title = '添加用户'
  873. },
  874. // 多选框选中数据
  875. handleSelectionChange(selection) {
  876. this.ids = selection.map((item) => item.id)
  877. this.single = selection.length !== 1
  878. this.multiple = !selection.length
  879. },
  880. submitAlreadySelectCouponList() {
  881. this.alreadySelectCouponList = []
  882. this.ids.forEach((id) => {
  883. const vo = this.couponList.find((item) => item.id == id)
  884. this.alreadySelectCouponList.push(vo)
  885. })
  886. this.openCoupon = false
  887. },
  888. handleDelete(row) {
  889. this.alreadySelectCouponList = this.alreadySelectCouponList.filter((item) => item.id != row.id)
  890. this.$forceUpdate()
  891. },
  892. // 选择支付方式
  893. selectPaymentMethod(type) {
  894. this.payFrom.payType = type
  895. this.payFrom.wxBarcode = ''
  896. // 现金支付时,直接设置支付金额为应付金额
  897. if (type === '2') {
  898. this.payFrom.cashPayAmount = this.getOrderNeedAmount
  899. this.payFrom.otherPayAmount = 0
  900. } else {
  901. this.payFrom.cashPayAmount = ''
  902. this.payFrom.otherPayAmount = ''
  903. }
  904. },
  905. // 选择快捷金额
  906. selectQuickAmount(amount) {
  907. // 确保快捷金额不超过应付金额
  908. if (Number(amount) > Number(this.getOrderNeedAmount)) {
  909. this.payFrom.cashPayAmount = this.getOrderNeedAmount
  910. } else {
  911. this.payFrom.cashPayAmount = amount
  912. }
  913. // 计算电子支付金额
  914. this.payFrom.otherPayAmount = Math.round((Number(this.getOrderNeedAmount) - Number(this.payFrom.cashPayAmount)) * 100) / 100
  915. }
  916. }
  917. }
  918. </script>
  919. <style lang="scss" scoped>
  920. .cashier-dialog {
  921. :deep(.el-dialog__body) {
  922. padding: 0;
  923. }
  924. .order-info {
  925. background: #f8f9fb;
  926. padding: 24px;
  927. .amount-section {
  928. text-align: center;
  929. margin-bottom: 24px;
  930. padding-bottom: 24px;
  931. border-bottom: 1px solid #ebeef5;
  932. .total-amount {
  933. margin-bottom: 16px;
  934. .label {
  935. font-size: 16px;
  936. color: #606266;
  937. margin-right: 8px;
  938. }
  939. .value {
  940. font-size: 32px;
  941. font-weight: bold;
  942. color: #f56c6c;
  943. }
  944. }
  945. .detail-list {
  946. display: flex;
  947. justify-content: center;
  948. flex-wrap: wrap;
  949. gap: 24px;
  950. .detail-item {
  951. .label {
  952. color: #909399;
  953. }
  954. .value {
  955. color: #606266;
  956. font-weight: 500;
  957. }
  958. }
  959. }
  960. }
  961. .payment-section {
  962. .section-title {
  963. font-size: 16px;
  964. font-weight: 500;
  965. margin-bottom: 16px;
  966. }
  967. .payment-methods {
  968. display: grid;
  969. grid-template-columns: repeat(4, 1fr);
  970. gap: 16px;
  971. margin-bottom: 24px;
  972. .payment-method {
  973. height: 80px;
  974. display: flex;
  975. flex-direction: column;
  976. align-items: center;
  977. justify-content: center;
  978. gap: 8px;
  979. border: 1px solid #dcdfe6;
  980. border-radius: 4px;
  981. cursor: pointer;
  982. transition: all 0.3s;
  983. i {
  984. font-size: 24px;
  985. color: #909399;
  986. }
  987. &:hover {
  988. border-color: #409eff;
  989. }
  990. &.is-active {
  991. border-color: #409eff;
  992. background: #ecf5ff;
  993. i,
  994. span {
  995. color: #409eff;
  996. }
  997. }
  998. }
  999. }
  1000. .payment-input {
  1001. margin-bottom: 24px;
  1002. .input-group {
  1003. display: grid;
  1004. grid-template-columns: repeat(2, 1fr);
  1005. gap: 16px;
  1006. .input-item {
  1007. .label {
  1008. display: block;
  1009. margin-bottom: 8px;
  1010. color: #606266;
  1011. }
  1012. .readonly-value {
  1013. height: 40px;
  1014. line-height: 40px;
  1015. padding: 0 16px;
  1016. background: #f5f7fa;
  1017. border: 1px solid #dcdfe6;
  1018. border-radius: 4px;
  1019. color: #606266;
  1020. font-weight: bold;
  1021. }
  1022. }
  1023. }
  1024. }
  1025. .scan-input {
  1026. margin-top: 16px;
  1027. }
  1028. }
  1029. }
  1030. .quick-amount {
  1031. padding: 24px 0;
  1032. .section-title {
  1033. font-size: 14px;
  1034. color: #606266;
  1035. margin-bottom: 16px;
  1036. }
  1037. .amount-buttons {
  1038. display: grid;
  1039. grid-template-columns: repeat(4, 1fr);
  1040. gap: 16px;
  1041. .amount-btn {
  1042. height: 40px;
  1043. &.is-active {
  1044. color: #409eff;
  1045. border-color: #409eff;
  1046. background: #ecf5ff;
  1047. }
  1048. }
  1049. }
  1050. }
  1051. .dialog-footer {
  1052. display: flex;
  1053. justify-content: space-between;
  1054. align-items: center;
  1055. padding: 16px 24px;
  1056. background: #f8f9fb;
  1057. border-top: 1px solid #ebeef5;
  1058. .payment-summary {
  1059. .label {
  1060. font-size: 16px;
  1061. color: #606266;
  1062. margin-right: 8px;
  1063. }
  1064. .amount {
  1065. font-size: 24px;
  1066. font-weight: bold;
  1067. color: #f56c6c;
  1068. }
  1069. }
  1070. .el-button {
  1071. width: 160px;
  1072. height: 48px;
  1073. }
  1074. }
  1075. }
  1076. </style>