diff --git a/src/api/account/shopMerchant.ts b/src/api/account/shopMerchant.ts index 561e836..b2739c0 100644 --- a/src/api/account/shopMerchant.ts +++ b/src/api/account/shopMerchant.ts @@ -1,10 +1,11 @@ import request from "@/utils/request"; -import { Account_BaseUrl } from "@/api/config"; +import { Account_BaseUrl, Order_BaseUrl } from "@/api/config"; const baseURL = Account_BaseUrl + "/admin/shopMerchant"; +const orderURL = Order_BaseUrl + "/admin/shopMerchant"; const API = { get(shopId: string | number) { return request({ - url: `${baseURL}`, + url: `${orderURL}`, method: "get", params: { shopId: shopId @@ -14,7 +15,7 @@ const API = { edit(shopId: string | number, data: shopMerchantType) { delete data.id return request({ - url: `${baseURL}`, + url: `${orderURL}`, method: "put", data: { ...data, shopId }, }); diff --git a/src/api/common/index.ts b/src/api/common/index.ts index 57055a4..eeac0be 100644 --- a/src/api/common/index.ts +++ b/src/api/common/index.ts @@ -124,4 +124,43 @@ export const queryEntry = (params: Object) => { method: "get", params }); -} \ No newline at end of file +} + +/** + * 商户支付信息获取 + * @data { params } + * @returns + */ +export const shopMerchantGet = (params: Object) => { + return request({ + url: `/order/admin/shopMerchant`, + method: "get", + params + }); +} + +/** + * 商户支付信息修改 修改聚合支付信息 + * @data { params } + * @returns + */ +export const shopMerchantPut = (data: Object) => { + return request({ + url: `/order/admin/shopMerchant`, + method: "put", + data + }); +} + +/** + * 获取当前店铺的主店进件信息 + * @data { params } + * @returns + */ +export const getMainMerchant = (params: Object) => { + return request({ + url: `/order/admin/shopMerchant/getMainMerchant`, + method: "get", + params + }); +} diff --git a/src/api/coup/group.js b/src/api/coup/group.js index 4fccbd6..e843ced 100644 --- a/src/api/coup/group.js +++ b/src/api/coup/group.js @@ -10,7 +10,7 @@ export function searchstorestatus(type) { return request_php({ method: "post", headers: { - clint_type: type + 'ClintType': type }, url: "/meituan/searchstorestatus" }); @@ -79,7 +79,7 @@ export function getuisdk(data) { return request_php({ method: "post", headers: { - clint_type: 2 + 'ClintType': 2 }, url: "/douyin/getuisdk", data, @@ -214,7 +214,7 @@ export function thirdPartyCoupon_bindUrl(data) { return request_php({ method: "post", headers: { - clint_type: 1 + 'ClintType': 1 }, url: "/meituan/getuisdkurl", data, diff --git a/src/api/order/pay.ts b/src/api/order/pay.ts index 57419ae..9879f16 100644 --- a/src/api/order/pay.ts +++ b/src/api/order/pay.ts @@ -3,7 +3,6 @@ import { Order_BaseUrl } from "@/api/config"; const baseURL = Order_BaseUrl + "/pay"; const Api = { // h5支付 - h5Pay(data: h5PayRequest) { return request({ url: `${baseURL}/h5Pay`, @@ -67,7 +66,6 @@ const Api = { params }); }, - }; export default Api; diff --git a/src/utils/request.ts b/src/utils/request.ts index 651dc5e..33e9e8a 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -91,7 +91,7 @@ service.interceptors.response.use( return; } ElMessage.error(formatErrorMsg(msg || "Error")); - return Promise.reject(new Error(formatErrorMsg(msg || "Error"))); + return Promise.reject(response.data); }, async (error: any) => { diff --git a/src/views/applyments/applyment_in.vue b/src/views/applyments/applyment_in.vue index 12e0131..7fb03bc 100644 --- a/src/views/applyments/applyment_in.vue +++ b/src/views/applyments/applyment_in.vue @@ -311,13 +311,14 @@ const longTime = ref('2099-12-31') const wxProvinceCode = ref('') // 获取进件详情 -async function getDetailAjax(shopId: string, licenceNo: string) { +async function getDetailAjax(shopId: string) { try { const res: any = await entryManagerDetail({ - shopId: shopId, - licenceNo: licenceNo + shopId: shopId }) - form.value = res + if (res && res.shopId) { + form.value = res + } } catch (error) { console.log(error); } @@ -325,8 +326,6 @@ async function getDetailAjax(shopId: string, licenceNo: string) { // 获取containerDomInfo信息 function getContainerDomInfo() { - console.log('getContainerDomInfo'); - containerDomInfo.value = containerRef.value?.getBoundingClientRect() ?? {} } @@ -336,14 +335,18 @@ onMounted(() => { getContainerDomInfo() window.addEventListener('resize', debouncedCheckWidth) + const type = route.query.type const shopId: string = String(route.query.shopId ?? '') const licenceNo: string = String(route.query.licenceNo ?? '') - if (shopId && licenceNo) { - formType.value = 'editor' - getDetailAjax(shopId, licenceNo) + + if (shopId) { + getDetailAjax(shopId) + } + + if (licenceNo && type && type == 'editor') { + formType.value = 'editor' } - const type = route.query.type if (type && type == 'check') { formType.value = 'check' } diff --git a/src/views/online-shop/index.vue b/src/views/online-shop/index.vue index dd790dd..76e6694 100644 --- a/src/views/online-shop/index.vue +++ b/src/views/online-shop/index.vue @@ -233,7 +233,7 @@ import shopExtendApi from "@/api/account/shopExtend"; export default { data() { return { - tableActive: "", + tableActive: "ticket_logo", tableData: [], selectItem: {}, imageUrl: "", @@ -248,7 +248,10 @@ export default { methods: { // 刷新列表数据 async doSubmit() { - this.selectItem.value = JSON.stringify(this.imgList) + // console.log('this.selectItem.value', this.selectItem.value); + // return + + // this.selectItem.value = JSON.stringify(this.imgList) await shopExtendApi.edit({ ...this.selectItem, autokey: this.selectItem.autoKey, diff --git a/src/views/order/group-purchase.vue b/src/views/order/group-purchase.vue index a2da669..220f2b9 100644 --- a/src/views/order/group-purchase.vue +++ b/src/views/order/group-purchase.vue @@ -7,8 +7,8 @@ - - + + @@ -135,11 +135,11 @@ export default { }, payTypes: [ { - value: "wechatPay", + value: "WECHAT", label: "微信支付" }, { - value: "aliPay", + value: "ALIPAY", label: "支付宝支付" } ], diff --git a/src/views/order/index/components/detail.vue b/src/views/order/index/components/detail.vue index 7ebb59a..f22ec88 100644 --- a/src/views/order/index/components/detail.vue +++ b/src/views/order/index/components/detail.vue @@ -33,7 +33,7 @@
订单类型
- {{ sendTypeFilter(detail.sendType) }} + {{ sendTypeFilter(detail.dineMode) }}
@@ -46,12 +46,12 @@
下单时间
-
{{ timeFilter(detail.createdAt) }}
+
{{ timeFilter(detail.createTime) }}
支付时间
- {{ timeFilter(detail.createdAt) }} + {{ timeFilter(detail.paidTime) }}
diff --git a/src/views/order/index/components/orderEnum.js b/src/views/order/index/components/orderEnum.js index 6724cf7..43e8e95 100644 --- a/src/views/order/index/components/orderEnum.js +++ b/src/views/order/index/components/orderEnum.js @@ -51,15 +51,15 @@ export default { label: "快递", }, { - key: "takeaway", + key: "take-away", label: "外卖", }, { - key: "takeself", + key: "take-out", label: "自提", }, { - key: "table", + key: "dine-in", label: "堂食", }, ], diff --git a/src/views/shop/groupBuying/index.vue b/src/views/shop/groupBuying/index.vue index 32e6a7b..2aa56de 100644 --- a/src/views/shop/groupBuying/index.vue +++ b/src/views/shop/groupBuying/index.vue @@ -245,8 +245,8 @@ const tableData = reactive({ // 支付方式类型 function payTypeFilter(t) { const m = { - wechatPay: '微信支付', - aliPay: '支付宝支付' + WECHAT: '微信支付', + ALIPAY: '支付宝支付' } return m[t] } diff --git a/src/views/shop/list/components/detailModal.vue b/src/views/shop/list/components/detailModal.vue index da4a678..222e555 100644 --- a/src/views/shop/list/components/detailModal.vue +++ b/src/views/shop/list/components/detailModal.vue @@ -1,156 +1,110 @@ - + \ No newline at end of file diff --git a/src/views/shop/list/components/payStatusCard.vue b/src/views/shop/list/components/payStatusCard.vue new file mode 100644 index 0000000..6c43596 --- /dev/null +++ b/src/views/shop/list/components/payStatusCard.vue @@ -0,0 +1,325 @@ + + + + + \ No newline at end of file diff --git a/src/views/shop/list/index.vue b/src/views/shop/list/index.vue index 03c9ba7..3269628 100644 --- a/src/views/shop/list/index.vue +++ b/src/views/shop/list/index.vue @@ -25,7 +25,7 @@ 添加店铺
- + + - + - + diff --git a/src/views/tool/Instead/components/order.vue b/src/views/tool/Instead/components/order.vue index 8aca734..b5851fe 100644 --- a/src/views/tool/Instead/components/order.vue +++ b/src/views/tool/Instead/components/order.vue @@ -220,6 +220,25 @@ + + +
+
+
+ + {{ closeStateTime }}秒后可重新扫码 + 重新扫码 + +
+
+ + {{ closeStateTime }}秒后可关闭 + 关闭 + +
+
+
@@ -243,6 +262,7 @@ import discount from "./discount.vue"; import { ElLoading } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus"; import { BigNumber } from "bignumber.js"; +import { onUnmounted } from 'vue' // 配置BigNumber精度 BigNumber.set({ @@ -439,11 +459,17 @@ async function pointsInit() { // 保险取值 const eq = pointsConfig?.equivalentPoints || 0; - const maxRatio = pointsConfig?.maxDeductionRatio || 0; + const rawMaxRatio = pointsConfig?.maxDeductionRatio || 0; + // 兼容后端返回的百分比或小数两种形式:如果大于1,则视为百分比(如100表示100%),需除以100 + const maxRatio = rawMaxRatio > 1 ? rawMaxRatio / 100 : rawMaxRatio; const minPay = pointsConfig?.minPaymentAmount || 0; // 计算当前订单可抵扣金额上限(元) + // 使用“抵扣前实付金额”作为门槛判断(即把当前已应用的积分抵扣金额加回), + // 避免在已经抵扣导致 finalPay 变小后错误地判定为不可用。 let finalPay = Number(carts.orderCostSummary.finalPayAmount) || 0; + const currentPointDeduction = Number(carts.orderCostSummary.pointDeductionAmount) || 0; + const basePay = finalPay + currentPointDeduction; const res = { usable: true, @@ -455,8 +481,9 @@ async function pointsInit() { unusableReason: "", }; - // 如果订单实付低于最小使用门槛,则不可用 - if (finalPay <= 0 || (minPay > 0 && finalPay < minPay)) { + // 如果订单实付低于最小使用门槛,则不可用(门槛仅作为启用条件) + // 这里使用 basePay(抵扣前实付)进行判断,确保已填写积分后不会回退为不可用 + if (basePay <= 0 || (minPay > 0 && basePay < minPay)) { res.usable = false; res.unusableReason = `订单实付金额低于 ${minPay} 元,无法使用积分抵扣`; } else if (eq <= 0) { @@ -464,23 +491,22 @@ async function pointsInit() { res.unusableReason = `积分换算比例配置错误,无法使用积分抵扣`; } else { // 计算基于比例限制的最大抵扣金额(元) - let maxByRatio = finalPay * maxRatio; - // 保证抵扣后剩余金额 >= minPaymentAmount - if (minPay > 0) { - const allowed = finalPay - minPay; - if (allowed <= 0) { - res.usable = false; - res.unusableReason = `抵扣后实付金额必须大于等于 ${minPay} 元,当前不可使用积分`; - } else { - maxByRatio = Math.min(maxByRatio, allowed); - } - } + // 注意:此处不再减少 minPaymentAmount,minPaymentAmount 仅用作是否可用的门槛; + // 真正的最大抵扣由 maxRatio(抵扣比例)与用户积分数量共同决定。 + // 计算基于比例限制的最大抵扣金额(元),基于抵扣前实付金额 + let maxByRatio = basePay * maxRatio; if (res.usable) { - // 可用积分上限(向下取整为 eq 的倍数) + // 可用积分上限(按等价积分步长对齐到 eq 的倍数) const maxByMoney = Math.floor(maxByRatio * eq); const userPoints = carts.vipUser.pointBalance || 0; - res.maxUsablePoints = Math.min(userPoints, maxByMoney); + let computedMax = Math.min(userPoints, maxByMoney); + // 对齐到等价积分步长,保证输入步长生效 + if (eq > 0) { + computedMax = Math.floor(computedMax / eq) * eq; + } + res.maxUsablePoints = computedMax; + console.debug("pointsInit debug:", { finalPay: finalPay, basePay: basePay, eq, rawMaxRatio, maxRatio, maxByMoney, userPoints, computedMax }); // 最小抵扣积分为配置值或等于换算比 res.minDeductionPoints = pointsConfig?.minDeductionPoints || eq; if (res.maxUsablePoints < res.minDeductionPoints) { @@ -498,8 +524,20 @@ async function pointsInit() { return res; } - // 如果可用则默认填充可用最大值,否则清零 - usePointsNumber.value = res.usable ? res.maxUsablePoints : 0; + // 如果可用则默认填充可用最大值(对齐步长),否则清零 + if (res.usable) { + // 计算默认填充值:基于抵扣前实付的比例上限与等价比计算需要的积分数 + const defaultMaxByMoney = Math.floor(basePay * res.maxDeductionRatio * res.equivalentPoints); + let defaultPts = Math.min(res.maxUsablePoints || 0, defaultMaxByMoney || 0); + if (res.equivalentPoints > 0) { + defaultPts = Math.floor(defaultPts / res.equivalentPoints) * res.equivalentPoints; + } + // 最终确保不超过用户积分 + const userPts = carts.vipUser.pointBalance || 0; + usePointsNumber.value = Math.min(defaultPts, userPts); + } else { + usePointsNumber.value = 0; + } if (!res.usable) score.sel = -1; return res; @@ -532,17 +570,15 @@ function pointsToMoney(val) { // 再次校验不超过允许的最大抵扣金额(基于比例或门槛) let finalPay = Number(carts.orderCostSummary.finalPayAmount) || 0; let maxByRatio = finalPay * cfg.maxDeductionRatio; - if (cfg.minPaymentAmount > 0) { - const allowed = finalPay - cfg.minPaymentAmount; - if (allowed <= 0) { - usePointsNumber.value = 0; - carts.orderCostSummary.pointUsed = 0; - carts.orderCostSummary.pointDeductionAmount = 0; - return; - } - maxByRatio = Math.min(maxByRatio, allowed); + // 对于单笔抵扣:若订单实付低于配置的最小门槛,则不可使用(作为启用条件) + if (cfg.minPaymentAmount > 0 && finalPay < cfg.minPaymentAmount) { + usePointsNumber.value = 0; + carts.orderCostSummary.pointUsed = 0; + carts.orderCostSummary.pointDeductionAmount = 0; + return; } const maxAllowedMoney = new BigNumber(maxByRatio).decimalPlaces(2, BigNumber.ROUND_DOWN).toNumber(); + console.debug("pointsToMoney debug:", { finalPay, cfg, pts, money, maxByRatio, maxAllowedMoney }); if (money > maxAllowedMoney) { // 调整积分到允许的最大金额对应的积分 const allowedPts = Math.floor(maxAllowedMoney * cfg.equivalentPoints); @@ -735,7 +771,12 @@ async function payOrder(payType, isScan, guazhangren) { } carts.clear(); } catch (error) { - console.log(error); + console.log('payOrder===', error); + // 启动状态查询 + if (error.code == 211) { + showCheckPayStauts.value = true + autoCheckOrder() + } clearTimeout(payTimer); loading.close(); } @@ -746,6 +787,102 @@ async function payOrder(payType, isScan, guazhangren) { } } +function clearAutoCheckOrder() { + clearInterval(timer.value) + timer.value = null +} + +// 关闭查询 +function closeScanCode() { + showCheckPayStauts.value = false; + reset() +} + +// 重新扫码 +function resetScanCode() { + reset() + showCheckPayStauts.value = false; + clearInterval(timer.value) + timer.value = null + + clearInterval(closeStateTimer.value) + closeStateTimer.value = null + + setTimeout(() => { + refScanPay.value.open(returnPayParams(), "scanCode") + }, 500) +} + +const closeState = ref(false) +const closeStateTime = ref(5); +const closeStateTimer = ref(null) + +function closeStateTimerFuc() { + closeStateTimer.value = setInterval(() => { + closeStateTime.value-- + if (closeStateTime.value <= 0) { + clearInterval(closeStateTimer.value) + closeStateTimer.value = null + closeState.value = true + } + }, 1000) +} + +// 自动查询订单状态 +const timer = ref(null) +function autoCheckOrder() { + closeStateTimerFuc() + timer.value = setInterval(() => { + // 开始锁单 + // goodsStore.isOrderLock({ + // table_code: table_code.value + // }, 'pay_lock') + checkPayStauts(false) + }, 2000) +} + +function reset() { + checkPayStautsLoading.value = true; + closeState.value = false + closeStateTime.value = 5 +} + +// 查询订单支付状态 +const showCheckPayStauts = ref(false) +const checkPayStautsLoading = ref(true) +async function checkPayStauts(tips = true) { + try { + // 扫码下单 + const res = await payApi.queryOrderStatus({ orderId: props.orderInfo.id }); + if (res == "done") { + // 支付成功,解锁订单 + // await goodsStore.isOrderLock({ + // table_code: table_code.value + // }, 'pay_unlock') + + // userPayWait.value = false + checkPayStautsLoading.value = false; + // scanCode.value = ""; + showCheckPayStauts.value = false; + clearAutoCheckOrder() + paysuccess(); + return; + } + if (res == "unpaid") { + if (tips) { + ElMessage.warning("用户支付中..."); + } + return; + } else { + clearAutoCheckOrder() + ElMessage.warning(res.msg || ''); + return; + } + } catch (error) { + console.log(error); + } +} + function paysuccess() { clearTimeout(payTimer); ElMessage.success("支付成功"); @@ -806,6 +943,10 @@ watch( } ); +onUnmounted(() => { + clearAutoCheckOrder() +}) + onMounted(() => { carts.payParamsInit(); getPaytype(); @@ -858,9 +999,13 @@ defineExpose({ .order-info { font-size: 14px; - .title {} + .title { + display: inline-block; + } - .value {} + .value { + display: inline-block; + } .price { color: #fa5555; @@ -879,4 +1024,30 @@ defineExpose({ color: #666; padding: 8px 10px 8px 20px; } + +.pay_status_content { + flex: 1; + padding: 0 var(--el-font-size-base); + height: 400px; + padding-bottom: 100px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + + .loading { + width: 200px; + height: 200px; + --el-loading-spinner-size: 100px; + + :deep(.el-loading-text) { + font-size: 20px; + } + } + + .btn { + width: 200px; + padding-top: var(--el-font-size-base); + } +} \ No newline at end of file diff --git a/src/views/tool/Instead/components/scan-pay.vue b/src/views/tool/Instead/components/scan-pay.vue index 47f59c1..3ec29b9 100644 --- a/src/views/tool/Instead/components/scan-pay.vue +++ b/src/views/tool/Instead/components/scan-pay.vue @@ -2,12 +2,8 @@
- + {{ item.text }}
@@ -21,13 +17,8 @@ - +
取消 @@ -46,7 +37,9 @@
{{ form.money }}元
- + + + 等待用户支付
@@ -55,7 +48,8 @@
- - -