diff --git a/src/api/order.js b/src/api/order.js index 99b0ac9..f0d3ac2 100644 --- a/src/api/order.js +++ b/src/api/order.js @@ -207,3 +207,16 @@ export function orderPrint(data) { data, }); } + +/** + * 查询会员充值支付状态 + * @param {*} data + * @returns + */ +export function queryPayStatus(params) { + return request({ + method: "get", + url: "/order/pay/queryPayStatus", + params, + }); +} diff --git a/src/components/payCard/couponModal.vue b/src/components/payCard/couponModal.vue index c77da5b..cc6597d 100644 --- a/src/components/payCard/couponModal.vue +++ b/src/components/payCard/couponModal.vue @@ -171,7 +171,7 @@ async function findCouponAjax() { } else { let arr = [] let ids = props.orderList.map(item => item.productId) - res.map(item => { + res && res.map(item => { if (ids.includes(item.proId)) { let pro = props.orderList.find(val => val.productId == item.proId) arr.push({ @@ -193,9 +193,7 @@ function show(userId) { showDialog.value = true query.value.userId = userId findCouponAjax() - console.log('couponModal.orderList===', props.orderList); - } defineExpose({ diff --git a/src/components/payCard/payCard.vue b/src/components/payCard/payCard.vue index 7e5e1b3..2ef7f89 100644 --- a/src/components/payCard/payCard.vue +++ b/src/components/payCard/payCard.vue @@ -69,36 +69,6 @@ - - - - - - - 搜索 - 重置 - - - - - - - - - - - - - - - - - @@ -362,10 +332,10 @@ async function payCreditPayHandle(row) { buyerTable.loading = false; emit("paySuccess"); } catch (error) { - buyerTable.loading = false; - payLoading.value = false; console.log(error); } + buyerTable.loading = false; + payLoading.value = false; } // 显示选择挂账人 end @@ -374,6 +344,27 @@ function scanCodeSuccess() { emit("paySuccess"); } +// 会员支付 +async function vipPayAjax(row) { + try { + if (row.amount < money.value) { + ElMessage.error('余额不足') + return + } + + payData.value.payType = 'userPay' + payData.value.shopUserId = row.id + payData.value.checkOrderPay.userId = row.userId + payLoading.value = true; + + await vipPay(payData.value) + emit("paySuccess"); + } catch (error) { + console.log(error); + } + payLoading.value = false; +} + // 切换支付类型 async function payTypeChange(index, item) { try { @@ -384,9 +375,12 @@ async function payTypeChange(index, item) { if (item.payType == "scanCode") { scanModalRef.value.show(); } - if (item.payType == "vipPay") { - showDialog.value = true; - getMemberList(); + if (item.payType == "member-account") { + if (goodsStore.vipUserInfo.id) { + // await vipPayAjax(goodsStore.vipUserInfo) + } else { + SelectVipUserRef.value.show() + } } if (item.payType == "buyer") { showBuyerHandle(); @@ -434,11 +428,14 @@ async function confirmOrder() { } else { } break - case "vipPay": + case "member-account": // 会员支付 - console.log("使用会员id支付"); payLoading.value = false; - showDialog.value = true; + if (goodsStore.vipUserInfo.id) { + await vipPayAjax(goodsStore.vipUserInfo) + } else { + SelectVipUserRef.value.show() + } return; default: break; @@ -500,66 +497,6 @@ async function queryPayTypeAjax() { } } -const showDialog = ref(false); -const tableData = reactive({ - phone: "", - loading: false, - list: [], - page: 1, - size: 10, - total: 0, -}); - -// 重置表格 -function resetTable() { - tableData.phone = ""; - tableData.page = 1; - getMemberList(); -} - -// 获取会员列表 -async function getMemberList() { - try { - tableData.loading = true; - const res = await queryMembermember({ - shopId: store.userInfo.shopId, - phone: tableData.phone, - page: tableData.page, - pageSize: tableData.size, - isFlag: 1, - }); - tableData.loading = false; - tableData.list = res.list; - tableData.total = res.total; - } catch (error) { - console.log(error); - } -} - -// 选择会员去下单 -async function toHomeMember(row) { - try { - showDialog.value = false; - payLoading.value = true; - const res = await vipPay({ - orderId: props.orderId, - vipUserId: row.id, - payAmount: props.discount > 0 ? money.value : "", - discountAmount: - props.discount > 0 ? formatDecimal(props.amount - money.value) : "", - }); - global.setOrderTable(); - global.setOrderMember(); - - payLoading.value = false; - ElMessage.success("支付成功"); - emit("paySuccess"); - } catch (error) { - payLoading.value = false; - console.log(error); - } -} - // 取消折扣 function cancelDiscount() { discountRateVlaue.value = 0 @@ -607,31 +544,29 @@ function clearCouponUser() { } // 折扣格式化 -function discountInput(e) { +const discountInput = _.debounce(function (e) { couponForm.value.amount = couponForm.value.originAmount - setTimeout(() => { - couponForm.value.discountRatio = inputFilterFloat(e) - if (couponForm.value.discountRatio > 9.9) { - couponForm.value.discountRatio = 9.9 - } - if (couponForm.value.discountRatio < 0.1) { - couponForm.value.discountRatio = 0.1 - } + couponForm.value.discountRatio = inputFilterFloat(e) + if (couponForm.value.discountRatio > 9.9) { + couponForm.value.discountRatio = 9.9 + } + if (couponForm.value.discountRatio < 0.1) { + couponForm.value.discountRatio = 0.1 + } - if (couponForm.value.discountRatio) { - couponForm.value.amount = formatDecimal(couponForm.value.amount * (couponForm.value.discountRatio / couponFormDiscountRate.value)) - } else { - couponForm.value.amount = formatDecimal(+couponForm.value.originAmount) - } + if (couponForm.value.discountRatio) { + couponForm.value.amount = formatDecimal(couponForm.value.amount * (couponForm.value.discountRatio / couponFormDiscountRate.value)) + } else { + couponForm.value.amount = formatDecimal(+couponForm.value.originAmount) + } - // 将优惠券/积分所有设置初始化 - couponResList1.value = [] - couponResList2.value = [] + // 将优惠券/积分所有设置初始化 + couponResList1.value = [] + couponResList2.value = [] - couponForm.value.pointsNum = '' - pointOptions.value.amount = 0 - }, 50) -} + couponForm.value.pointsNum = '' + pointOptions.value.amount = 0 +}, 500) // 积分输入格式化 function pointInput(e) { @@ -704,19 +639,29 @@ function resetCouponFormHandle() { } // 选择会员完成后 -function selectUserHandle(row) { - couponFormUserList.value = [ - { - id: row.userId, - nickName: row.nickName, - } - ] - couponFormUser.value = row - pointOptionsAjax() +async function selectUserHandle(row) { + try { + if (showCoupon.value) { + couponFormUserList.value = [ + { + id: row.userId, + nickName: row.nickName, + } + ] + couponFormUser.value = row + pointOptionsAjax() - // 已存在选择的用户,并且切换了不通用户 - if (couponFormUser.id && row.userId != couponFormUser.value.userId) { - resetCoupon() + // 已存在选择的用户,并且切换了不通用户 + if (couponFormUser.id && row.userId != couponFormUser.value.userId) { + resetCoupon() + } + } + + if (payList.value[payActive.value].payType == 'member-account') { + vipPayAjax(row) + } + } catch (error) { + console.log(error); } } @@ -859,7 +804,7 @@ function reset() { buyerRemark: "", // 订单备注 checkOrderPay: { orderId: goodsStore.orderListInfo.id, - vipPrice: store.shopInfo.isMemberPrice || goodsStore.showVipPrice, // 是否使用会员价 + vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价 allPack: goodsStore.allSelected, // 是否整单打包 userId: goodsStore.vipUserInfo.id, seatNum: goodsStore.tableInfo.num, // 用餐人数 diff --git a/src/components/payCard/scanModal.vue b/src/components/payCard/scanModal.vue index 76e4a9d..4e7a4bd 100644 --- a/src/components/payCard/scanModal.vue +++ b/src/components/payCard/scanModal.vue @@ -58,7 +58,7 @@ import { scanpay, queryOrder, quickPay, queryQuickPayStatus, accountPay, querySc import { useUser } from "@/store/user.js"; import { useGlobal } from '@/store/global.js' import { formatDecimal } from '@/utils' -import { microPay, queryOrderStatus, microPayVip, vipPay } from '@/api/order.js' +import { microPay, queryOrderStatus, microPayVip, vipPay, queryPayStatus } from '@/api/order.js' const store = useUser(); const global = useGlobal() @@ -113,6 +113,7 @@ const userPayWait = ref(false); const checkPayStatusLoading = ref(false); const fastOrder = ref('') +const vipPayOrder = ref('') // 提交扫码支付 async function submitHandle() { @@ -210,8 +211,11 @@ async function checkPayStauts(tips = true) { try { if (props.selecttype == 1) { // 会员扫码充值 - const res = await queryScanPay({ flowId: fastOrder.value.id }); - if (res.status == 0) { + const res = await queryPayStatus({ + shopId: store.shopInfo.id, + payOrderNo: fastOrder.value.payOrderNo, + }); + if (res == 'TRADE_SUCCESS') { userPayWait.value = false loading.value = false; scanCode.value = ""; @@ -220,8 +224,7 @@ async function checkPayStauts(tips = true) { clearAutoCheckOrder() emits("success"); return; - } - if (res.status == 7) { + } else if (res == 'TRADE_AWAIT') { if (tips) { ElMessage.warning("用户支付中..."); } @@ -263,7 +266,6 @@ async function checkPayStauts(tips = true) { userPayWait.value = false loading.value = false; scanCode.value = ""; - ElMessage.success("支付成功"); dialogVisible.value = false; clearAutoCheckOrder() emits("success"); @@ -276,7 +278,7 @@ async function checkPayStauts(tips = true) { return; } else { clearAutoCheckOrder() - ElMessage.error(res.msg); + ElMessage.error(res.msg || ''); return; } } @@ -292,7 +294,9 @@ function resetScanCode() { userPayWait.value = false; loading.value = false; scanCode.value = ""; - inputRef.value.focus(); + setTimeout(() => { + inputRef.value.focus(); + }, 500) } // 输入 diff --git a/src/components/selectVipUser.vue b/src/components/selectVipUser.vue index 7dd6e12..c5095f5 100644 --- a/src/components/selectVipUser.vue +++ b/src/components/selectVipUser.vue @@ -17,9 +17,9 @@ - + - + @@ -27,7 +27,7 @@ ¥{{ formatDecimal(scope.row.amount) }} - + diff --git a/src/store/global.js b/src/store/global.js index 16329ed..08d32a2 100644 --- a/src/store/global.js +++ b/src/store/global.js @@ -109,6 +109,10 @@ export const useGlobal = defineStore("global", { type: "cash_pay", label: "现金支付", }, + { + type: "credit_pay", + label: "挂账支付", + }, ], bizCodes: [ { diff --git a/src/store/goods.js b/src/store/goods.js index e75cd58..083d743 100644 --- a/src/store/goods.js +++ b/src/store/goods.js @@ -12,7 +12,7 @@ import { ElMessage } from "element-plus"; // 商品store + 购物车store export const useGoods = defineStore("goods", { state: () => ({ - showVipPrice: false, + showVipPrice: 0, allSelected: 0, // 是否整单打包 vipUserInfo: {}, // 会员信息 // tableInfo: { @@ -444,6 +444,7 @@ export const useGoods = defineStore("goods", { item.packFee = val.packFee; item.unitName = val.unitName; } + item.pack_number = item.packNumber; item.product_name = item.productName; item.number = item.num; }); diff --git a/src/views/home/components/cartOperation.vue b/src/views/home/components/cartOperation.vue index 46ba763..ed9a0ef 100644 --- a/src/views/home/components/cartOperation.vue +++ b/src/views/home/components/cartOperation.vue @@ -203,13 +203,15 @@
- - - + +
@@ -347,12 +349,17 @@ async function returnOrderItemAjax(num = 1) { function packHandle() { let item = goodsStore.cartList[goodsStore.cartActiveIndex] if (item && item.id) { - if (item.number > 1) { - // 大于1时需要编辑 - showPackModal.value = true + if (!item.pack_number || item.pack_number <= 0) { + if (item.number > 1) { + // 大于1时需要编辑 + showPackModal.value = true + } else { + // 小于1时直接提交 + goodsStore.operateCart({ ...item, pack_number: item.number }, 'edit') + } } else { - // 小于1时直接提交 - goodsStore.operateCart({ ...item, pack_number: item.number }, 'edit') + // 取消打包 + goodsStore.operateCart({ ...item, pack_number: 0 }, 'edit') } } } @@ -576,14 +583,9 @@ function validatePackNumber(rule, value, callback) { } } -function packNumberInput(e) { - setTimeout(() => { - packNumberForm.value.number = inputFilterFloat(e) - }, 50) -} - // modal打开时 function packModalOpen() { + packNumberForm.value.number = 1 packItem.value = goodsStore.cartList[goodsStore.cartActiveIndex] } @@ -616,6 +618,10 @@ function packFormSubmit() { background-color: #efefef; border-radius: 6px; + &:active { + background-color: #d3d3d3; + } + &.disabled { .t { diff --git a/src/views/home/components/pendingCartModal.vue b/src/views/home/components/pendingCartModal.vue index ff446ea..bac725b 100644 --- a/src/views/home/components/pendingCartModal.vue +++ b/src/views/home/components/pendingCartModal.vue @@ -31,8 +31,8 @@ const dialogVisible = ref(false) // 恢复挂单 async function select(item) { - await goodsStore.recoverPending(item) dialogVisible.value = false + await goodsStore.recoverPending(item) } function show() { diff --git a/src/views/home/components/settleAccount.vue b/src/views/home/components/settleAccount.vue index 144085f..f492901 100644 --- a/src/views/home/components/settleAccount.vue +++ b/src/views/home/components/settleAccount.vue @@ -190,7 +190,10 @@ async function printOrderLable(isBefore = false) { if (printStore.deviceNoteList.length) { // 使用本地打印机打印 const data = await getOrderByIdAjax(goodsStore.orderListInfo.id); - printStore.labelPrint(commOrderPrintData(data)) + if (!isBefore) { + // 预结算不打印标签 + printStore.labelPrint(commOrderPrintData(data)) + } printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore })); } else { // 本地没有可用打印机使用云打印机 diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 2d6ee9d..1a291b5 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -225,7 +225,7 @@ const createOrderLoading = ref(false); function selectUser(row) { goodsStore.vipUserInfo = { ...row } if (store.shopInfo.isMemberPrice && row.isVip) { - goodsStore.showVipPrice = true + goodsStore.showVipPrice = 1 goodsStore.calcCartInfo() } } @@ -339,7 +339,7 @@ function showTableMerging() { // 清除会员与会员价 function clearVipUserHandle() { goodsStore.vipUserInfo = '' - goodsStore.showVipPrice = false + goodsStore.showVipPrice = 0 goodsStore.calcCartInfo() } diff --git a/src/views/member/components/recordDialog.vue b/src/views/member/components/recordDialog.vue index c8a0520..5f32143 100644 --- a/src/views/member/components/recordDialog.vue +++ b/src/views/member/components/recordDialog.vue @@ -17,9 +17,9 @@
- - + @click="showRefundHandle(item)" :disabled="item.amount == item.refundAmount"> + +
@@ -221,7 +221,7 @@ async function passwordSuccess(e = '') { showDialog.value = false loading.value = false emits('refund') - // memberqueryMemberAccountAjax() + memberqueryMemberAccountAjax() } catch (error) { loading.value = false console.log(error); diff --git a/src/views/member/index.vue b/src/views/member/index.vue index c17d51b..d0f6b06 100644 --- a/src/views/member/index.vue +++ b/src/views/member/index.vue @@ -31,7 +31,7 @@
- + diff --git a/src/views/order/components/refundDrawer.vue b/src/views/order/components/refundDrawer.vue index 913019e..f16d7bc 100644 --- a/src/views/order/components/refundDrawer.vue +++ b/src/views/order/components/refundDrawer.vue @@ -4,34 +4,34 @@

订单号:{{ item.orderNo }}

@@ -98,7 +99,7 @@
- +
@@ -122,6 +123,7 @@