对接新版结算
This commit is contained in:
@@ -8,7 +8,7 @@ ENV = development
|
|||||||
# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
||||||
|
|
||||||
# 本地ws
|
# 本地ws
|
||||||
VITE_API_WSS = 'ws://192.168.1.31:2348'
|
VITE_API_WSS = 'ws://192.168.1.42:2348'
|
||||||
|
|
||||||
# 正式 php
|
# 正式 php
|
||||||
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||||
@@ -20,7 +20,7 @@ VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
|||||||
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||||
|
|
||||||
# 本地调试连接
|
# 本地调试连接
|
||||||
VITE_API_URL = 'http://192.168.1.31/'
|
VITE_API_URL = 'http://192.168.1.42/'
|
||||||
|
|
||||||
# 线上测试
|
# 线上测试
|
||||||
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
ENV = test
|
ENV = test
|
||||||
|
|
||||||
# 测试ws
|
# 测试ws
|
||||||
# VITE_API_WSS = 'ws://192.168.1.31:2348'
|
VITE_API_WSS = 'ws://192.168.1.42:2348'
|
||||||
|
|
||||||
# 测试ws
|
# 测试ws
|
||||||
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
||||||
|
|
||||||
# 正式ws
|
# 正式ws
|
||||||
VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
||||||
|
|
||||||
# 正式 php
|
# 正式 php
|
||||||
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||||
@@ -23,7 +23,7 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
|||||||
# VITE_API_URL = 'https://fv901fw8033.vicp.fun/'
|
# VITE_API_URL = 'https://fv901fw8033.vicp.fun/'
|
||||||
|
|
||||||
# 正式Java
|
# 正式Java
|
||||||
VITE_API_URL = 'https://cashier.sxczgkj.com/'
|
# VITE_API_URL = 'https://cashier.sxczgkj.com/'
|
||||||
|
|
||||||
# 本地调试连接
|
# 本地调试连接
|
||||||
# VITE_API_URL = 'http://192.168.1.31/'
|
VITE_API_URL = 'http://192.168.1.42/'
|
||||||
File diff suppressed because it is too large
Load Diff
7977
package-lock.json
generated
Normal file
7977
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -8,11 +8,13 @@
|
|||||||
"build": "node ./addVersion.js && vite build && electron-builder",
|
"build": "node ./addVersion.js && vite build && electron-builder",
|
||||||
"build:test": "vite build --mode test && electron-builder",
|
"build:test": "vite build --mode test && electron-builder",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"build:win": "node ./addVersion.js && vite build && electron-builder --w"
|
"build:win": "node ./addVersion.js && vite build && electron-builder --w",
|
||||||
|
"postinstall": "electron-builder install-app-deps"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
|
"bignumber.js": "^9.3.1",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"electron-pos-printer": "^1.3.6",
|
"electron-pos-printer": "^1.3.6",
|
||||||
"electron-pos-printer-vue": "^1.0.9",
|
"electron-pos-printer-vue": "^1.0.9",
|
||||||
@@ -23,16 +25,16 @@
|
|||||||
"pinia-plugin-persistedstate": "^3.2.1",
|
"pinia-plugin-persistedstate": "^3.2.1",
|
||||||
"qrcode": "^1.5.3",
|
"qrcode": "^1.5.3",
|
||||||
"reconnecting-websocket": "^4.4.0",
|
"reconnecting-websocket": "^4.4.0",
|
||||||
"serialport": "^12.0.0",
|
|
||||||
"speak-tts": "^2.0.8",
|
"speak-tts": "^2.0.8",
|
||||||
"swiper": "^11.1.1",
|
"swiper": "^11.1.1",
|
||||||
"uuid": "^10.0.0",
|
"uuid": "^10.0.0",
|
||||||
"vue": "^3.3.8",
|
"vue": "^3.3.8",
|
||||||
"vue-router": "^4.2.5"
|
"vue-router": "^4.2.5",
|
||||||
|
"ysk-utils": "^1.0.41"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.5.0",
|
"@vitejs/plugin-vue": "^4.5.0",
|
||||||
"electron": "^28.2.3",
|
"electron": "^28.3.3",
|
||||||
"electron-builder": "^24.13.3",
|
"electron-builder": "^24.13.3",
|
||||||
"electron-rebuild": "^3.2.9",
|
"electron-rebuild": "^3.2.9",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ export function printerAdd(data, method = "post") {
|
|||||||
export function findCoupon(params) {
|
export function findCoupon(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/account/admin/coupon/findCoupon",
|
url: "/market/admin/coupon/findCoupon",
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/api/market.js
Normal file
14
src/api/market.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import request from "@/utils/request.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 智慧充值 配置信息获取
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function shopRecharge(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/market/admin/shopRecharge",
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -33,6 +33,21 @@
|
|||||||
<span class="title">{{ item.payName }}</span>
|
<span class="title">{{ item.payName }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="quick_charge">
|
||||||
|
<div class="item" :class="{active:chargeActive == index }" v-for="(item,index) in chargeList" :key="item.id" @click="changeCharge(index,item)">
|
||||||
|
<div class="row">
|
||||||
|
<span class="icon">¥</span>
|
||||||
|
<span class="num">{{ item.amount }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<span class="t1">赠¥{{ item.rewardAmount }}</span>
|
||||||
|
<span class="t1">送{{ item.rewardPoints }}积分</span>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<span class="t2">送{{item.couponCount}}张券</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="input_wrap">
|
<div class="input_wrap">
|
||||||
<div class="input" style="flex: 1">储值:¥{{ money }}</div>
|
<div class="input" style="flex: 1">储值:¥{{ money }}</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,13 +75,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<scanModal ref="scanModalRef" fast :amount="money" :money="money" :selecttype="props.type"
|
<scanModal ref="scanModalRef" fast :amount="money" :money="money" :selecttype="props.type"
|
||||||
:orderId="props.userInfo.id" @success="scanCodeSuccess" />
|
:orderId="props.userInfo.id" :chargeId="chargeId" @success="scanCodeSuccess" />
|
||||||
<takeFoodCode ref="takeFoodCodeRef" title="支付密码" :type="2" input-type="password" placeholder="请输入支付密码"
|
<takeFoodCode ref="takeFoodCodeRef" title="支付密码" :type="2" input-type="password" placeholder="请输入支付密码"
|
||||||
@success="passwordSuccess" />
|
@success="passwordSuccess" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
|
import { shopRecharge } from '@/api/market.js'
|
||||||
import { getPayType } from '@/api/account.js'
|
import { getPayType } from '@/api/account.js'
|
||||||
import { cashPayVip } from "@/api/order.js";
|
import { cashPayVip } from "@/api/order.js";
|
||||||
import { clearNoNum } from "@/utils";
|
import { clearNoNum } from "@/utils";
|
||||||
@@ -134,7 +150,8 @@ async function passwordSuccess(e = '') {
|
|||||||
// pwd: e ? md5(e) : '',
|
// pwd: e ? md5(e) : '',
|
||||||
pwd: e,
|
pwd: e,
|
||||||
orderId: '',
|
orderId: '',
|
||||||
allPack: ''
|
allPack: '',
|
||||||
|
rechargeDetailId: chargeId.value
|
||||||
});
|
});
|
||||||
payLoading.value = false;
|
payLoading.value = false;
|
||||||
ElMessage.success("充值成功");
|
ElMessage.success("充值成功");
|
||||||
@@ -196,12 +213,16 @@ async function confirmOrder() {
|
|||||||
// 输入
|
// 输入
|
||||||
function amountInput(num) {
|
function amountInput(num) {
|
||||||
money.value = clearNoNum({ value: (money.value += num) });
|
money.value = clearNoNum({ value: (money.value += num) });
|
||||||
|
chargeActive.value = null
|
||||||
|
chargeId.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
function delHandle() {
|
function delHandle() {
|
||||||
if (!money.value) return;
|
if (!money.value) return;
|
||||||
money.value = money.value.substring(0, money.value.length - 1);
|
chargeActive.value = null
|
||||||
|
chargeId.value = ''
|
||||||
|
money.value = money.value.substring(0, money.value.length - 1);
|
||||||
if (!money.value) {
|
if (!money.value) {
|
||||||
money.value = "0";
|
money.value = "0";
|
||||||
}
|
}
|
||||||
@@ -225,15 +246,49 @@ async function queryPayTypeAjax() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化
|
||||||
function reset() {
|
function reset() {
|
||||||
money.value = 0;
|
money.value = 0;
|
||||||
payActive.value = 0;
|
payActive.value = 0;
|
||||||
|
chargeActive.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取智慧充值的配置信息
|
||||||
|
const chargeActive = ref(null);
|
||||||
|
const chargeList = ref([])
|
||||||
|
const chargeId = ref('')
|
||||||
|
|
||||||
|
function changeCharge(index,item) {
|
||||||
|
chargeActive.value = index
|
||||||
|
chargeId.value = item.id
|
||||||
|
money.value = ''
|
||||||
|
money.value = clearNoNum({ value: (money.value += item.amount) })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function shopRechargeAjax() {
|
||||||
|
try {
|
||||||
|
const res = await shopRecharge()
|
||||||
|
res.rechargeDetailList.map((item) => {
|
||||||
|
item.couponCount = 0
|
||||||
|
item.couponInfoList.map(val => {
|
||||||
|
item.couponCount += val.num;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
chargeList.value = res.rechargeDetailList
|
||||||
|
|
||||||
|
console.log(chargeList.value)
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
defineExpose({ reset });
|
defineExpose({ reset });
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
queryPayTypeAjax();
|
queryPayTypeAjax();
|
||||||
|
shopRechargeAjax()
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -300,7 +355,7 @@ onMounted(() => {
|
|||||||
gap: var(--el-font-size-base);
|
gap: var(--el-font-size-base);
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
height: 130px;
|
height: 80px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -330,9 +385,56 @@ onMounted(() => {
|
|||||||
width: $size;
|
width: $size;
|
||||||
height: $size;
|
height: $size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.title {
|
.quick_charge {
|
||||||
padding-top: 10px;
|
width: 100%;
|
||||||
|
height: 100px;
|
||||||
|
overflow-x: auto;
|
||||||
|
margin-top: var(--el-font-size-base);
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
$activeColor: #FF6300;
|
||||||
|
display: flex;
|
||||||
|
gap: 2px;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: var(--el-font-size-base);
|
||||||
|
margin-right: var(--el-font-size-base);
|
||||||
|
border: 2px solid #F5F5F5;
|
||||||
|
&.active {
|
||||||
|
border-color: $activeColor;
|
||||||
|
.row {
|
||||||
|
.icon {
|
||||||
|
color: $activeColor;
|
||||||
|
}
|
||||||
|
.num {
|
||||||
|
color: $activeColor;
|
||||||
|
}
|
||||||
|
.t1 {
|
||||||
|
color: $activeColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
.icon {
|
||||||
|
font-size: 12px;
|
||||||
|
position: relative;
|
||||||
|
top: 3px;
|
||||||
|
}
|
||||||
|
.num {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.t2 {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,7 +447,7 @@ onMounted(() => {
|
|||||||
.input {
|
.input {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 60px;
|
height: 50px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
border: 1px solid var(--primary-color);
|
border: 1px solid var(--primary-color);
|
||||||
font-size: calc(var(--el-font-size-base) + 6px);
|
font-size: calc(var(--el-font-size-base) + 6px);
|
||||||
@@ -363,7 +465,7 @@ onMounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
.left {
|
.left {
|
||||||
--item-height: calc((100vh - 440px) / 4);
|
--item-height: calc((100vh - 440px) / 5);
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
|
|||||||
@@ -1,58 +1,100 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="showDialog" title="选择优惠券" top="12vh" width="80%" @closed="resetHandle">
|
<el-dialog v-model="showDialog" title="选择优惠券" top="12vh" width="80%" @closed="resetHandle">
|
||||||
<el-radio-group v-model="query.type" @change="typeChange">
|
<el-radio-group v-model="querForm.statusActiveIndex" @change="typeChange">
|
||||||
<el-radio-button label="优惠券" :value="1"></el-radio-button>
|
<el-radio-button :label="`商品兑换券(${goodsCoupon.length})`" :value="0"></el-radio-button>
|
||||||
<el-radio-button label="商品券" :value="2"></el-radio-button>
|
<el-radio-button :label="`折扣优惠券(${discountCoupon.length})`" :value="1"></el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
<div class="table">
|
<div style="height: 50vh;overflow-y: auto;">
|
||||||
<el-table ref="tableRef1" :data="tableData.list" border stripe v-loading="tableData.loading"
|
<div class="table" v-if="querForm.statusActiveIndex == 0">
|
||||||
v-show="query.type == 1" height="300px">
|
<div class="title">可用优惠券</div>
|
||||||
<el-table-column label="名称" prop="name"></el-table-column>
|
<el-table ref="tableRef1" :data="list.canUseCoupons" border stripe v-loading="tableData.loading"
|
||||||
<el-table-column label="抵扣" prop="discountAmount"></el-table-column>
|
row-key="id">
|
||||||
<el-table-column label="限制" prop="fullAmount">
|
<el-table-column label="名称" prop="name"></el-table-column>
|
||||||
<template v-slot="scope">
|
<el-table-column label="抵扣" prop="discountAmount"></el-table-column>
|
||||||
满{{ scope.row.fullAmount }}减{{ scope.row.discountAmount }}
|
<el-table-column label="限制" prop="fullAmount">
|
||||||
</template>
|
<template v-slot="scope">
|
||||||
</el-table-column>
|
满{{ scope.row.fullAmount }}减{{ scope.row.discountAmount }}
|
||||||
<el-table-column label="描述" prop="useRestrictions">
|
</template>
|
||||||
<template v-slot="scope">
|
</el-table-column>
|
||||||
<div v-html="scope.row.useRestrictions"></div>
|
<el-table-column label="描述" prop="useRestrictions">
|
||||||
</template>
|
<template v-slot="scope">
|
||||||
</el-table-column>
|
<div v-html="scope.row.useRestrictions"></div>
|
||||||
<el-table-column label="操作" align="center">
|
</template>
|
||||||
<template v-slot="scope">
|
</el-table-column>
|
||||||
<el-button type="primary" @click="selectCoupon(scope.row)">选择</el-button>
|
<el-table-column label="选择" width="100" align="center">
|
||||||
</template>
|
<template #default="scope">
|
||||||
</el-table-column>
|
<el-checkbox v-model="scope.row.selected" :true-value="1" :false-value="0"
|
||||||
</el-table>
|
:disabled="scope.row.disabled" @change="selectCoupon($event, scope.row)"></el-checkbox>
|
||||||
<el-table ref="tableRef2" :data="tableData.list" border stripe row-key="id" v-loading="tableData.loading"
|
</template>
|
||||||
v-show="query.type == 2" height="300px">
|
</el-table-column>
|
||||||
<el-table-column type="selection" width="55"></el-table-column>
|
</el-table>
|
||||||
<el-table-column label="名称" prop="name"></el-table-column>
|
<div class="title">不可用优惠券</div>
|
||||||
<el-table-column label="商品信息">
|
<el-table ref="tableRef2" :data="list.noCanUseCoupons" border v-loading="tableData.loading">
|
||||||
<template v-slot="scope">
|
<el-table-column label="名称" prop="name"></el-table-column>
|
||||||
{{ scope.row.productName }} ¥{{ scope.row.lowPrice }}
|
<el-table-column label="不可用原因">
|
||||||
</template>
|
<template v-slot="scope">
|
||||||
</el-table-column>
|
{{ scope.row.canuseResult.reason }}
|
||||||
<el-table-column label="描述" prop="useRestrictions">
|
</template>
|
||||||
<template v-slot="scope">
|
</el-table-column>
|
||||||
<div v-html="scope.row.useRestrictions"></div>
|
<el-table-column label="描述" prop="useRestrictions">
|
||||||
</template>
|
<template v-slot="scope">
|
||||||
</el-table-column>
|
<div v-html="scope.row.useRestrictions"></div>
|
||||||
</el-table>
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
<div class="table" v-if="querForm.statusActiveIndex == 1">
|
||||||
|
<div class="title">可用优惠券</div>
|
||||||
|
<el-table ref="tableRef1" :data="list.canUseDiscountCoupon" border stripe v-loading="tableData.loading">
|
||||||
|
<el-table-column label="名称" prop="name"></el-table-column>
|
||||||
|
<el-table-column label="抵扣" prop="discountAmount"></el-table-column>
|
||||||
|
<el-table-column label="限制" prop="fullAmount">
|
||||||
|
<template v-slot="scope">
|
||||||
|
满{{ scope.row.fullAmount }}减{{ scope.row.discountAmount }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="描述" prop="useRestrictions">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div v-html="scope.row.useRestrictions"></div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="选择" width="100" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-checkbox v-model="scope.row.selected" :true-value="1" :false-value="0"
|
||||||
|
:disabled="scope.row.disabled" @change="selectCoupon($event, scope.row)"></el-checkbox>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="title">不可用优惠券</div>
|
||||||
|
<el-table ref="tableRef2" :data="list.noUseDiscountCoupon" border v-loading="tableData.loading">
|
||||||
|
<el-table-column label="名称" prop="name"></el-table-column>
|
||||||
|
<el-table-column label="不可用原因">
|
||||||
|
<template v-slot="scope">
|
||||||
|
{{ scope.row.canuseResult.reason }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="描述" prop="useRestrictions">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div v-html="scope.row.useRestrictions"></div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dialog_footer" v-if="query.type == 2">
|
<div class="dialog_footer">
|
||||||
<el-button @click="showDialog = false">取消</el-button>
|
<el-button @click="showDialog = false">取消</el-button>
|
||||||
<el-button type="primary" @click="selectCoupon()">确认</el-button>
|
<el-button type="primary" @click="selectCouponConfirm">确认</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
import { useGoods } from '@/store/goods.js'
|
import { useGoods } from '@/store/goods.js'
|
||||||
import { findCoupon } from '@/api/account.js'
|
import { findCoupon } from '@/api/account.js'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
import * as UTILS from '@/utils/coupon-utils.js';
|
||||||
|
import { useUser } from "@/store/user.js";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
orderList: {
|
orderList: {
|
||||||
@@ -63,6 +105,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
const emits = defineEmits(['success'])
|
const emits = defineEmits(['success'])
|
||||||
|
|
||||||
|
const store = useUser()
|
||||||
const goodsStore = useGoods()
|
const goodsStore = useGoods()
|
||||||
const tableRef1 = ref(null)
|
const tableRef1 = ref(null)
|
||||||
const tableRef2 = ref(null)
|
const tableRef2 = ref(null)
|
||||||
@@ -85,11 +128,15 @@ function resetHandle() {
|
|||||||
|
|
||||||
function typeChange() {
|
function typeChange() {
|
||||||
tableData.loading = false
|
tableData.loading = false
|
||||||
tableData.list = []
|
// tableData.list = []
|
||||||
|
list.canUseCoupons = []
|
||||||
|
list.noCanUseCoupons = []
|
||||||
|
list.canUseDiscountCoupon = []
|
||||||
|
list.noUseDiscountCoupon = []
|
||||||
findCouponAjax()
|
findCouponAjax()
|
||||||
if (query.type == 2) {
|
// if (query.type == 2) {
|
||||||
tableRef2.value.clearSelection()
|
// tableRef2.value.clearSelection()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
function groupByPropertyAndCount(arr, property) {
|
function groupByPropertyAndCount(arr, property) {
|
||||||
@@ -117,92 +164,320 @@ function groupByPropertyAndCount(arr, property) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 选择优惠券
|
// 选择优惠券
|
||||||
function selectCoupon(row) {
|
const goodsCoupon = ref([]) // 商品券
|
||||||
if (query.value.type == 1) {
|
const discountCoupon = ref([]) // 其他优惠券
|
||||||
emits('success', { type: query.value.type, couponList: [{ ...row }] })
|
function selectCoupon($event, e) {
|
||||||
} else {
|
console.log($event);
|
||||||
|
console.log(e);
|
||||||
let goods = [
|
if (querForm.value.statusActiveIndex == 0) {
|
||||||
...goodsStore.cartList,
|
goodsCoupon.value = []
|
||||||
...goodsStore.orderList.map(item => item.goods).flat()
|
if ($event) {
|
||||||
]
|
goodsCoupon.value.push(e)
|
||||||
|
list.canUseCoupons.map(item => {
|
||||||
let arr = tableRef2.value.getSelectionRows()
|
if (item.id != e.id) {
|
||||||
|
item.disabled = true
|
||||||
|
|
||||||
if (!arr.length) {
|
|
||||||
ElMessage.error('请选择优惠券')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let obj = groupByPropertyAndCount(arr, 'proId')
|
|
||||||
let goodsObj = groupByPropertyAndCount(goods, 'product_id')
|
|
||||||
|
|
||||||
console.log(obj);
|
|
||||||
console.log(goodsObj);
|
|
||||||
|
|
||||||
for (let val of goodsObj) {
|
|
||||||
for (let item of obj) {
|
|
||||||
if (val.value == item.value) {
|
|
||||||
if (item.count > val.count) {
|
|
||||||
ElMessage.error('超出订单数量,请重新选择')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
list.canUseCoupons.map(item => {
|
||||||
|
if (item.id != e.id) {
|
||||||
|
item.disabled = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
discountCoupon.value = []
|
||||||
|
if ($event) {
|
||||||
|
discountCoupon.value.push(e)
|
||||||
|
list.canUseDiscountCoupon.map(item => {
|
||||||
|
if (item.id != e.id) {
|
||||||
|
item.disabled = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
list.canUseDiscountCoupon.map(item => {
|
||||||
|
if (item.id != e.id) {
|
||||||
|
item.disabled = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSelCoupon();
|
||||||
|
|
||||||
|
|
||||||
|
// if (query.value.type == 1) {
|
||||||
|
// emits('success', { type: query.value.type, couponList: [{ ...row }] })
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
// let goods = [
|
||||||
|
// ...goodsStore.cartList,
|
||||||
|
// ...goodsStore.orderList.map(item => item.goods).flat()
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// let arr = tableRef2.value.getSelectionRows()
|
||||||
|
|
||||||
|
|
||||||
|
// if (!arr.length) {
|
||||||
|
// ElMessage.error('请选择优惠券')
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// let obj = groupByPropertyAndCount(arr, 'proId')
|
||||||
|
// let goodsObj = groupByPropertyAndCount(goods, 'product_id')
|
||||||
|
|
||||||
|
// console.log(obj);
|
||||||
|
// console.log(goodsObj);
|
||||||
|
|
||||||
|
// for (let val of goodsObj) {
|
||||||
|
// for (let item of obj) {
|
||||||
|
// if (val.value == item.value) {
|
||||||
|
// if (item.count > val.count) {
|
||||||
|
// ElMessage.error('超出订单数量,请重新选择')
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// emits('success', { type: query.value.type, couponList: arr })
|
||||||
|
// }
|
||||||
|
// showDialog.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSelCoupon() {
|
||||||
|
const newval = [...goodsCoupon.value, ...discountCoupon.value];
|
||||||
|
|
||||||
|
const user = goodsStore.vipUserInfo;
|
||||||
|
let shopInfo = store.shopInfo;
|
||||||
|
if (!shopInfo.isMemberPrice) {
|
||||||
|
shopInfo = {};
|
||||||
|
}
|
||||||
|
const canDikouGoodsArr = UTILS.returnCanDikouGoods(goodsStore.cartInfo.allGoods, [], user);
|
||||||
|
|
||||||
|
if (newval.length >= 2) {
|
||||||
|
let goodsCoupon = newval.filter((v) => v.type == 2);
|
||||||
|
let otherCoupon = newval.filter((v) => v.type != 2);
|
||||||
|
goodsCoupon = goodsCoupon.map((v) => {
|
||||||
|
const discount = UTILS.returnCouponDiscount(
|
||||||
|
canDikouGoodsArr,
|
||||||
|
v,
|
||||||
|
user,
|
||||||
|
goodsStore.cartInfo.costSummary.goodsRealAmount,
|
||||||
|
[],
|
||||||
|
shopInfo
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
discount,
|
||||||
|
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
otherCoupon = otherCoupon.map((v) => {
|
||||||
|
const discount = UTILS.returnCouponDiscount(
|
||||||
|
canDikouGoodsArr,
|
||||||
|
v,
|
||||||
|
user,
|
||||||
|
goodsStore.cartInfo.costSummary.goodsRealAmount,
|
||||||
|
goodsCoupon,
|
||||||
|
shopInfo
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
discount,
|
||||||
|
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('otherCoupon[0]===', otherCoupon[0]);
|
||||||
|
console.log('goodsCoupon[0]===', goodsCoupon[0]);
|
||||||
|
|
||||||
|
discountCoupon.value = [otherCoupon[0]];
|
||||||
|
goodsCoupon.value = [goodsCoupon[0]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认选择优惠券,然后关闭弹窗
|
||||||
|
function selectCouponConfirm() {
|
||||||
|
showDialog.value = false
|
||||||
|
const data = [...goodsCoupon.value, ...discountCoupon.value]
|
||||||
|
emits('success', data)
|
||||||
|
goodsCoupon.value = []
|
||||||
|
discountCoupon.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
const querForm = ref({
|
||||||
|
searchValue: '',
|
||||||
|
shopId: '',
|
||||||
|
shopName: '',
|
||||||
|
statusActiveIndex: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
const list = reactive({
|
||||||
|
page: 1,
|
||||||
|
size: 10,
|
||||||
|
status: 'nomore',
|
||||||
|
data: [],
|
||||||
|
noCanUseCoupons: [],
|
||||||
|
canUseCoupons: [],
|
||||||
|
noUseDiscountCoupon: [],
|
||||||
|
canUseDiscountCoupon: []
|
||||||
|
});
|
||||||
|
|
||||||
|
const couponSel = ref({
|
||||||
|
id: ''
|
||||||
|
});
|
||||||
|
const goodsCouponSel = ref({
|
||||||
|
id: ''
|
||||||
|
});
|
||||||
|
const quansSelArr = computed(() => {
|
||||||
|
return [couponSel.value, goodsCouponSel.value].filter((v) => v.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 格式化优惠券
|
||||||
|
function formatCoupon() {
|
||||||
|
let canUseGoodsCoupon = [];
|
||||||
|
let canUseDiscountCoupon = [];
|
||||||
|
|
||||||
|
let noUseGoodsCoupon = [];
|
||||||
|
let noUseDiscountCoupon = [];
|
||||||
|
const user = goodsStore.vipUserInfo;
|
||||||
|
let shopInfo = store.shopInfo;
|
||||||
|
if (!shopInfo.isMemberPrice) {
|
||||||
|
shopInfo = {};
|
||||||
|
}
|
||||||
|
const goodsOrderPrice = goodsStore.cartInfo.costSummary.goodsRealAmount;
|
||||||
|
|
||||||
|
console.log('goodsOrderPrice==========', goodsOrderPrice);
|
||||||
|
|
||||||
|
|
||||||
|
const canDikouGoodsArr = UTILS.returnCanDikouGoods(goodsStore.cartInfo.allGoods, [], user);
|
||||||
|
for (let i = 0; i < couponList.value.length; i++) {
|
||||||
|
const coupon = couponList.value[i];
|
||||||
|
const canuseResult = UTILS.returnCouponCanUse({
|
||||||
|
canDikouGoodsArr,
|
||||||
|
coupon,
|
||||||
|
goodsOrderPrice,
|
||||||
|
user,
|
||||||
|
selCoupon: quansSelArr.value,
|
||||||
|
shopInfo
|
||||||
|
});
|
||||||
|
const { canUse, reason } = canuseResult;
|
||||||
|
if (coupon.type == 2) {
|
||||||
|
if (canUse || goodsCouponSel.value.id == coupon.id) {
|
||||||
|
canUseGoodsCoupon.push(coupon);
|
||||||
|
} else {
|
||||||
|
noUseGoodsCoupon.push({
|
||||||
|
...coupon,
|
||||||
|
canuseResult
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (canUse || couponSel.value.id == coupon.id) {
|
||||||
|
canUseDiscountCoupon.push(coupon);
|
||||||
|
} else {
|
||||||
|
noUseDiscountCoupon.push({
|
||||||
|
...coupon,
|
||||||
|
canuseResult
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emits('success', { type: query.value.type, couponList: arr })
|
|
||||||
}
|
}
|
||||||
showDialog.value = false
|
//商品券
|
||||||
|
canUseGoodsCoupon = canUseGoodsCoupon.map((v) => {
|
||||||
|
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
discount,
|
||||||
|
discountAmount: discount ? discount.discountPrice : v.discountAmount
|
||||||
|
};
|
||||||
|
});
|
||||||
|
//非商品券
|
||||||
|
canUseDiscountCoupon = canUseDiscountCoupon.map((v) => {
|
||||||
|
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
discount,
|
||||||
|
discountAmount: discount ? discount.discountPrice : v.discountAmount
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (querForm.value.statusActiveIndex == 0) {
|
||||||
|
list.noCanUseCoupons = noUseGoodsCoupon;
|
||||||
|
|
||||||
|
canUseGoodsCoupon.map(item => {
|
||||||
|
item.selected = false
|
||||||
|
item.disabled = false
|
||||||
|
})
|
||||||
|
|
||||||
|
list.canUseCoupons = canUseGoodsCoupon;
|
||||||
|
} else {
|
||||||
|
list.noUseDiscountCoupon = noUseDiscountCoupon;
|
||||||
|
|
||||||
|
canUseDiscountCoupon.map(item => {
|
||||||
|
item.selected = false
|
||||||
|
item.disabled = false
|
||||||
|
})
|
||||||
|
|
||||||
|
list.canUseDiscountCoupon = canUseDiscountCoupon;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('canUseGoodsCoupon', canUseGoodsCoupon);
|
||||||
|
console.log('noUseGoodsCoupon', noUseGoodsCoupon);
|
||||||
|
console.log('canUseDiscountCoupon', canUseDiscountCoupon);
|
||||||
|
console.log('noUseDiscountCoupon', noUseDiscountCoupon);
|
||||||
|
|
||||||
|
console.log('list===', list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户可用的优惠券
|
// 获取用户可用的优惠券
|
||||||
|
const couponList = ref([])
|
||||||
async function findCouponAjax() {
|
async function findCouponAjax() {
|
||||||
try {
|
try {
|
||||||
tableData.loading = true
|
tableData.loading = true
|
||||||
const res = await findCoupon({
|
const res = await findCoupon({
|
||||||
shopUserId: query.value.userId,
|
shopUserId: query.value.userId
|
||||||
type: query.value.type
|
|
||||||
})
|
})
|
||||||
|
couponList.value = res
|
||||||
|
formatCoupon()
|
||||||
|
// if (query.value.type == 1) {
|
||||||
|
// tableData.list = res
|
||||||
|
// } else {
|
||||||
|
// let arr = []
|
||||||
|
// let ids = props.orderList.map(item => item.product_id)
|
||||||
|
// res && res.map((item, index) => {
|
||||||
|
|
||||||
if (query.value.type == 1) {
|
// let found = ids.find(val => val == item.proId)
|
||||||
tableData.list = res
|
// let result = found !== undefined
|
||||||
} else {
|
|
||||||
let arr = []
|
|
||||||
let ids = props.orderList.map(item => item.product_id)
|
|
||||||
res && res.map((item, index) => {
|
|
||||||
|
|
||||||
let found = ids.find(val => val == item.proId)
|
// if (result) {
|
||||||
let result = found !== undefined
|
// let pro = props.orderList.find(val => val.product_id == item.proId)
|
||||||
|
|
||||||
if (result) {
|
// console.log('pro===', pro);
|
||||||
let pro = props.orderList.find(val => val.product_id == item.proId)
|
|
||||||
|
|
||||||
console.log('pro===', pro);
|
// let discount = pro.lowPrice
|
||||||
|
|
||||||
let discount = pro.lowPrice
|
// if (goodsStore.showVipPrice) {
|
||||||
|
// discount = pro.memberPrice
|
||||||
|
// }
|
||||||
|
|
||||||
if (goodsStore.showVipPrice) {
|
// if (+pro.discount_sale_amount) {
|
||||||
discount = pro.memberPrice
|
// discount = pro.discount_sale_amount
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (+pro.discount_sale_amount) {
|
// arr.push({
|
||||||
discount = pro.discount_sale_amount
|
// ...item,
|
||||||
}
|
// productName: pro.productName,
|
||||||
|
// lowPrice: pro.lowPrice,
|
||||||
|
// discount: discount
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// tableData.list = arr
|
||||||
|
|
||||||
arr.push({
|
// console.log('tableData.list===', tableData.list);
|
||||||
...item,
|
// }
|
||||||
productName: pro.productName,
|
|
||||||
lowPrice: pro.lowPrice,
|
|
||||||
discount: discount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
tableData.list = arr
|
|
||||||
|
|
||||||
console.log('tableData.list===', tableData.list);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
@@ -222,13 +497,15 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.table {
|
|
||||||
padding-top: var(--el-font-size-base);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog_footer {
|
.dialog_footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
padding-top: var(--el-font-size-base);
|
padding-top: var(--el-font-size-base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
padding: 20px 0 10px 0;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -4,21 +4,24 @@
|
|||||||
<div class="left">
|
<div class="left">
|
||||||
<div class="t1">
|
<div class="t1">
|
||||||
<span class="title">应收:¥</span>
|
<span class="title">应收:¥</span>
|
||||||
<span class="num">{{ money }}</span>
|
<span class="num">{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount || 0) }}</span>
|
||||||
<div class="clear" v-if="money != props.amount" @click="emit('reset')">
|
<!-- <div class="clear" v-if="money != props.amount" @click="emit('reset')">
|
||||||
<span style="margin-left: 10px;">清除优惠</span>
|
<span style="margin-left: 10px;">清除优惠</span>
|
||||||
<el-icon style="margin-left: 6px">
|
<el-icon style="margin-left: 6px">
|
||||||
<CircleClose />
|
<CircleClose />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="t2">
|
<div class="t2">
|
||||||
<span>原价:¥{{ originOrderAmount }}</span>
|
<span>原价:¥{{ goodsStore.cartInfo.costSummary.goodsOriginalAmount }}</span>
|
||||||
<span>餐位费:¥{{ formatDecimal(+goodsStore.tableInfo.tableFee || 0) }}</span>
|
<span>餐位费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount.seatFee || 0)
|
||||||
<span>打包费:¥{{ formatDecimal(+goodsStore.cartInfo.packFee || 0) }}</span>
|
}}</span>
|
||||||
<span>优惠:¥{{ formatDecimal(props.amount - money) }}</span>
|
<span>打包费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount.packFee || 0)
|
||||||
<span v-if="discountRateVlaue">
|
}}</span>
|
||||||
<span>折扣:{{ discountRateVlaue }}折</span>
|
<span>优惠:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount -
|
||||||
|
goodsStore.cartInfo.costSummary.finalPayAmount) }}</span>
|
||||||
|
<span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
|
||||||
|
<span>折扣:{{ goodsStore.cartInfo.costSummary.goodsDiscountAmount }}</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -44,7 +47,8 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="input_wrap">
|
<div class="input_wrap">
|
||||||
<div class="input" style="flex: 1">付款:¥{{ money }}</div>
|
<div class="input" style="flex: 1">付款:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount
|
||||||
|
|| 0) }}</div>
|
||||||
<el-button type="primary" style="width: 120px;border-radius: 6px; height: 60px;"
|
<el-button type="primary" style="width: 120px;border-radius: 6px; height: 60px;"
|
||||||
@click="showCouponHandle">添加优惠</el-button>
|
@click="showCouponHandle">添加优惠</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -119,8 +123,8 @@
|
|||||||
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
|
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
|
||||||
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog v-model="showCoupon" :title="`添加优惠(¥${originOrderAmount})`" @open="couponDialogOpen"
|
<el-dialog v-model="showCoupon" :title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount)})`"
|
||||||
@closed="resetCouponFormHandle" top="5vh" width="80%">
|
@open="couponDialogOpen" @closed="resetCouponFormHandle" top="5vh" width="80%">
|
||||||
<div class="coupom_dialog">
|
<div class="coupom_dialog">
|
||||||
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
||||||
<el-form-item label="选择会员">
|
<el-form-item label="选择会员">
|
||||||
@@ -146,8 +150,7 @@
|
|||||||
<el-button type="primary"
|
<el-button type="primary"
|
||||||
:disabled="!couponFormUser.id && (!couponResList1.length && !couponResList2.length)"
|
:disabled="!couponFormUser.id && (!couponResList1.length && !couponResList2.length)"
|
||||||
@click="showCounponModalHandle">选择优惠券</el-button>
|
@click="showCounponModalHandle">选择优惠券</el-button>
|
||||||
<div>
|
<div style="padding-top: 20px;">
|
||||||
<div class="title">优惠券</div>
|
|
||||||
<el-table :data="couponResList1" border stripe>
|
<el-table :data="couponResList1" border stripe>
|
||||||
<el-table-column label="名称" prop="name"></el-table-column>
|
<el-table-column label="名称" prop="name"></el-table-column>
|
||||||
<el-table-column label="抵扣" prop="discountAmount"></el-table-column>
|
<el-table-column label="抵扣" prop="discountAmount"></el-table-column>
|
||||||
@@ -161,14 +164,14 @@
|
|||||||
<div v-html="scope.row.useRestrictions"></div>
|
<div v-html="scope.row.useRestrictions"></div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<!-- <el-table-column label="操作" width="110" align="center">
|
<el-table-column label="操作" width="110" align="center">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button type="danger" @click="delCoupon(scope.$index, 1)">删除</el-button>
|
<el-button type="danger" @click="delCoupon(scope.$index, 1)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column> -->
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<!-- <div>
|
||||||
<div class="title">商品券</div>
|
<div class="title">商品券</div>
|
||||||
<el-table :data="couponResList2" border stripe>
|
<el-table :data="couponResList2" border stripe>
|
||||||
<el-table-column label="名称" prop="name"></el-table-column>
|
<el-table-column label="名称" prop="name"></el-table-column>
|
||||||
@@ -187,19 +190,19 @@
|
|||||||
<div v-html="scope.row.useRestrictions"></div>
|
<div v-html="scope.row.useRestrictions"></div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<!-- <el-table-column label="操作" width="110" align="center">
|
<el-table-column label="操作" width="110" align="center">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button type="danger" @click="delCoupon(scope.$index, 2)">删除</el-button>
|
<el-button type="danger" @click="delCoupon(scope.$index, 2)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column> -->
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="积分抵扣">
|
<el-form-item label="积分抵扣">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<el-input v-model="couponForm.pointsNum"
|
<el-input v-model="couponForm.pointsNum"
|
||||||
:disabled="!couponFormUser.id || !pointOptions.usable || couponForm.amount < pointOptions.minPaymentAmount"
|
:disabled="!couponFormUser.id || !pointOptions.usable || goodsStore.cartInfo.costSummary.finalPayAmount < pointOptions.minPaymentAmount"
|
||||||
:placeholder="pointOptions.usable ? '请输入需要抵扣的积分' : pointOptions.unusableReason"
|
:placeholder="pointOptions.usable ? '请输入需要抵扣的积分' : pointOptions.unusableReason"
|
||||||
v-loading="pointOptions.loading" @input="pointInput">
|
v-loading="pointOptions.loading" @input="pointInput">
|
||||||
<template #prepend>现有积分:{{ couponFormUser.accountPoints || 0 }}</template>
|
<template #prepend>现有积分:{{ couponFormUser.accountPoints || 0 }}</template>
|
||||||
@@ -208,7 +211,8 @@
|
|||||||
<el-button type="danger" @click="clearPoint">清除</el-button>
|
<el-button type="danger" @click="clearPoint">清除</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="point_tips err"
|
<div class="point_tips err"
|
||||||
v-if="couponFormUser.id && couponForm.amount < pointOptions.minPaymentAmount">注意:订单金额不足¥{{
|
v-if="couponFormUser.id && goodsStore.cartInfo.costSummary.finalPayAmount < pointOptions.minPaymentAmount">
|
||||||
|
注意:订单金额不足¥{{
|
||||||
formatDecimal(+pointOptions.minPaymentAmount) }},无法使用积分抵扣
|
formatDecimal(+pointOptions.minPaymentAmount) }},无法使用积分抵扣
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -217,10 +221,11 @@
|
|||||||
<div class="dialog_footer">
|
<div class="dialog_footer">
|
||||||
<div class="result">
|
<div class="result">
|
||||||
优惠完:
|
优惠完:
|
||||||
<span class="i">¥</span> <span class="n">{{ formatDecimal(+couponForm.amount) }}</span>
|
<span class="i">¥</span> <span class="n">{{
|
||||||
|
formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn">
|
<div class="btn">
|
||||||
<el-button @click="showCoupon = false">取消</el-button>
|
<el-button @click="cancelAllDiscount">取消</el-button>
|
||||||
<el-button type="primary" @click="discountConfirm">确定</el-button>
|
<el-button type="primary" @click="discountConfirm">确定</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -279,9 +284,9 @@ const props = defineProps({
|
|||||||
const discountAmount = ref(null)
|
const discountAmount = ref(null)
|
||||||
|
|
||||||
watch(props, () => {
|
watch(props, () => {
|
||||||
money.value = formatDecimal(props.amount)
|
money.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount)
|
||||||
originOrderAmount.value = formatDecimal(props.amount - (goodsStore.tableInfo.tableFee || 0) -
|
// originOrderAmount.value = formatDecimal(props.amount - (goodsStore.tableInfo.tableFee || 0) -
|
||||||
(goodsStore.cartInfo.packFee || 0))
|
// (goodsStore.cartInfo.packFee || 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
const originOrderAmount = ref(0)
|
const originOrderAmount = ref(0)
|
||||||
@@ -397,11 +402,16 @@ async function vipPayAjax(row) {
|
|||||||
// 切换支付类型
|
// 切换支付类型
|
||||||
async function payTypeChange(index, item) {
|
async function payTypeChange(index, item) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
console.log(item);
|
||||||
|
|
||||||
// await staffPermission('yun_xu_shou_kuan')
|
// await staffPermission('yun_xu_shou_kuan')
|
||||||
// if (item.disabled) return
|
// if (item.disabled) return
|
||||||
payActive.value = index;
|
payActive.value = index;
|
||||||
payType.value = item.payType;
|
payType.value = item.payType;
|
||||||
|
|
||||||
|
upadatePayData()
|
||||||
|
|
||||||
if (item.payType == "scanCode") {
|
if (item.payType == "scanCode") {
|
||||||
scanModalRef.value.show();
|
scanModalRef.value.show();
|
||||||
}
|
}
|
||||||
@@ -424,6 +434,28 @@ async function payTypeChange(index, item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新支付参数
|
||||||
|
function upadatePayData() {
|
||||||
|
payData.value.checkOrderPay = {
|
||||||
|
orderId: goodsStore.orderListInfo.id,
|
||||||
|
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价
|
||||||
|
allPack: goodsStore.allSelected, // 是否整单打包
|
||||||
|
userId: goodsStore.vipUserInfo.userId || '',
|
||||||
|
seatNum: goodsStore.tableInfo.num, // 用餐人数
|
||||||
|
originAmount: formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||||
|
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
|
||||||
|
discountAmount: discountRateNumber.value, // 手动优惠金额
|
||||||
|
productCouponDiscountAmount: goodsStore.cartInfo.costSummary.productCouponDeduction, //商品优惠券抵扣金额
|
||||||
|
otherCouponDiscountAmount: goodsStore.cartInfo.costSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
||||||
|
couponList: couponResList1.value.map(item => item.id), // 用户使用的卡券
|
||||||
|
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount, // 订单金额
|
||||||
|
roundAmount: goodsStore.cartInfo.costSummary.goodsDiscountAmount, // 抹零金额 减免多少钱
|
||||||
|
pointsDiscountAmount: goodsStore.cartInfo.costSummary.pointDeductionAmount, // 积分抵扣金额(tb_points_basic_setting表)
|
||||||
|
pointsNum: goodsStore.cartInfo.costSummary.pointUsed, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||||
|
isPrint: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 结算支付
|
// 结算支付
|
||||||
async function confirmOrder() {
|
async function confirmOrder() {
|
||||||
try {
|
try {
|
||||||
@@ -433,6 +465,11 @@ async function confirmOrder() {
|
|||||||
})
|
})
|
||||||
if (payLoading.value) return
|
if (payLoading.value) return
|
||||||
// await staffPermission("yun_xu_shou_kuan");
|
// await staffPermission("yun_xu_shou_kuan");
|
||||||
|
|
||||||
|
upadatePayData()
|
||||||
|
|
||||||
|
|
||||||
|
payType.value = payList.value[payActive.value].payType
|
||||||
if (payList.value[payActive.value].payType == "arrears") {
|
if (payList.value[payActive.value].payType == "arrears") {
|
||||||
showBuyerHandle();
|
showBuyerHandle();
|
||||||
return
|
return
|
||||||
@@ -533,7 +570,7 @@ async function queryPayTypeAjax() {
|
|||||||
const res = await getPayType();
|
const res = await getPayType();
|
||||||
|
|
||||||
res.map((item) => {
|
res.map((item) => {
|
||||||
if (props.amount <= 0 && item.payType == "scanCode") {
|
if (goodsStore.cartInfo.costSummary.finalPayAmount <= 0 && item.payType == "scanCode") {
|
||||||
item.disabled = true;
|
item.disabled = true;
|
||||||
} else {
|
} else {
|
||||||
item.disabled = false;
|
item.disabled = false;
|
||||||
@@ -569,6 +606,7 @@ const pointOptions = ref({
|
|||||||
usable: true,
|
usable: true,
|
||||||
unusableReason: '',
|
unusableReason: '',
|
||||||
amount: 0,
|
amount: 0,
|
||||||
|
equivalentPoints: '',
|
||||||
loading: false
|
loading: false
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -589,12 +627,23 @@ const resetCouponForm = ref('')
|
|||||||
function clearCouponUser() {
|
function clearCouponUser() {
|
||||||
couponFormUser.value = ''
|
couponFormUser.value = ''
|
||||||
couponFormUserList.value = []
|
couponFormUserList.value = []
|
||||||
|
|
||||||
|
goodsStore.showVipPrice = 0
|
||||||
|
goodsStore.vipUserInfo = ''
|
||||||
|
|
||||||
|
couponForm.value.pointsNum = ''
|
||||||
|
couponForm.value.discountRatio = ''
|
||||||
|
discountRateNumber.value = 0
|
||||||
|
|
||||||
|
updateCartCalc()
|
||||||
|
|
||||||
resetCouponFormHandle()
|
resetCouponFormHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 折扣格式化
|
// 折扣格式化
|
||||||
|
const discountRateNumber = ref(0)
|
||||||
const discountInput = _.debounce(function (e) {
|
const discountInput = _.debounce(function (e) {
|
||||||
couponForm.value.amount = couponForm.value.originAmount
|
// couponForm.value.amount = couponForm.value.originAmount
|
||||||
couponForm.value.discountRatio = inputFilterFloat(e)
|
couponForm.value.discountRatio = inputFilterFloat(e)
|
||||||
if (couponForm.value.discountRatio > 9.9) {
|
if (couponForm.value.discountRatio > 9.9) {
|
||||||
couponForm.value.discountRatio = 9.9
|
couponForm.value.discountRatio = 9.9
|
||||||
@@ -604,18 +653,43 @@ const discountInput = _.debounce(function (e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (couponForm.value.discountRatio) {
|
if (couponForm.value.discountRatio) {
|
||||||
couponForm.value.amount = formatDecimal(couponForm.value.amount * (couponForm.value.discountRatio / couponFormDiscountRate.value))
|
discountRateNumber.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount - goodsStore.cartInfo.costSummary.finalPayAmount * (couponForm.value.discountRatio / couponFormDiscountRate.value))
|
||||||
} else {
|
} else {
|
||||||
couponForm.value.amount = formatDecimal(+couponForm.value.originAmount)
|
discountRateNumber.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount - goodsStore.cartInfo.costSummary.finalPayAmount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将优惠券/积分所有设置初始化
|
|
||||||
couponResList1.value = []
|
updateCartCalc()
|
||||||
couponResList2.value = []
|
// // 将优惠券/积分所有设置初始化
|
||||||
|
// couponResList1.value = []
|
||||||
|
// couponResList2.value = []
|
||||||
|
|
||||||
|
// couponForm.value.pointsNum = ''
|
||||||
|
// pointOptions.value.amount = 0
|
||||||
|
}, 500)
|
||||||
|
|
||||||
|
// 取消所有优惠
|
||||||
|
function cancelAllDiscount() {
|
||||||
|
showCoupon.value = false
|
||||||
|
|
||||||
couponForm.value.pointsNum = ''
|
couponForm.value.pointsNum = ''
|
||||||
pointOptions.value.amount = 0
|
couponResList1.value = []
|
||||||
}, 500)
|
couponForm.value.discountRatio = ''
|
||||||
|
discountRateNumber.value = ''
|
||||||
|
|
||||||
|
updateCartCalc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同意更新商品计算
|
||||||
|
function updateCartCalc() {
|
||||||
|
goodsStore.calcCartInfo({
|
||||||
|
pointsPerYuan: pointOptions.value.equivalentPoints,
|
||||||
|
maxDeductionAmount: pointOptions.value.max,
|
||||||
|
userPoints: couponForm.value.pointsNum,
|
||||||
|
backendCoupons: couponResList1.value,
|
||||||
|
fixedAmount: discountRateNumber.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 清除积分
|
// 清除积分
|
||||||
function clearPoint() {
|
function clearPoint() {
|
||||||
@@ -624,6 +698,8 @@ function clearPoint() {
|
|||||||
couponForm.value.amount = +couponForm.value.amount + +pointOptions.value.amount
|
couponForm.value.amount = +couponForm.value.amount + +pointOptions.value.amount
|
||||||
pointOptions.value.amount = 0
|
pointOptions.value.amount = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCartCalc()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 积分输入格式化
|
// 积分输入格式化
|
||||||
@@ -655,6 +731,8 @@ const pointInput = _.debounce(function (e) {
|
|||||||
pointOptions.value.loading = true
|
pointOptions.value.loading = true
|
||||||
calcPointMoney()
|
calcPointMoney()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCartCalc()
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
|
|
||||||
@@ -662,12 +740,14 @@ const pointInput = _.debounce(function (e) {
|
|||||||
const calcPointMoney = async () => {
|
const calcPointMoney = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await calcDeductionAmount({
|
const res = await calcDeductionAmount({
|
||||||
shopUserId: couponFormUser.value.id,
|
shopUserId: goodsStore.vipUserInfo.id,
|
||||||
orderAmount: couponForm.value.amount,
|
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount,
|
||||||
points: couponForm.value.pointsNum
|
points: couponForm.value.pointsNum
|
||||||
})
|
})
|
||||||
pointOptions.value.amount = formatDecimal(+res)
|
pointOptions.value.amount = formatDecimal(+res)
|
||||||
couponForm.value.amount = couponForm.value.amount - res
|
couponForm.value.amount = couponForm.value.amount - res
|
||||||
|
|
||||||
|
updateCartCalc()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
@@ -706,6 +786,7 @@ function couponDialogOpen() {
|
|||||||
// 关闭后初始化dialog
|
// 关闭后初始化dialog
|
||||||
function resetCouponFormHandle() {
|
function resetCouponFormHandle() {
|
||||||
couponForm.value = { ...resetCouponForm.value }
|
couponForm.value = { ...resetCouponForm.value }
|
||||||
|
cancelAllDiscount()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择会员完成后
|
// 选择会员完成后
|
||||||
@@ -721,10 +802,10 @@ async function selectUserHandle(row) {
|
|||||||
|
|
||||||
goodsStore.calcCartInfo()
|
goodsStore.calcCartInfo()
|
||||||
|
|
||||||
emit('reset')
|
// emit('reset')
|
||||||
|
|
||||||
couponForm.value.discountRatio = ''
|
// couponForm.value.discountRatio = ''
|
||||||
discountInput('')
|
// discountInput('')
|
||||||
|
|
||||||
if (showCoupon.value) {
|
if (showCoupon.value) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -766,8 +847,8 @@ function resetCoupon() {
|
|||||||
async function pointOptionsAjax() {
|
async function pointOptionsAjax() {
|
||||||
try {
|
try {
|
||||||
const res = await calcUsablePoints({
|
const res = await calcUsablePoints({
|
||||||
shopUserId: couponFormUser.value.id,
|
shopUserId: goodsStore.vipUserInfo.id,
|
||||||
orderAmount: couponForm.value.amount
|
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount
|
||||||
})
|
})
|
||||||
|
|
||||||
pointOptions.value.min = res.minDeductionPoints // 最少使用积分
|
pointOptions.value.min = res.minDeductionPoints // 最少使用积分
|
||||||
@@ -775,6 +856,7 @@ async function pointOptionsAjax() {
|
|||||||
pointOptions.value.usable = res.usable // 是否可用
|
pointOptions.value.usable = res.usable // 是否可用
|
||||||
pointOptions.value.unusableReason = res.unusableReason // 不可用的原因
|
pointOptions.value.unusableReason = res.unusableReason // 不可用的原因
|
||||||
pointOptions.value.minPaymentAmount = res.minPaymentAmount // 最少使用的金额
|
pointOptions.value.minPaymentAmount = res.minPaymentAmount // 最少使用的金额
|
||||||
|
pointOptions.value.equivalentPoints = res.equivalentPoints
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
@@ -794,51 +876,52 @@ function showCounponModalHandle() {
|
|||||||
const couponResList2Amount = ref(0)
|
const couponResList2Amount = ref(0)
|
||||||
// 选择完优惠券的回调事件
|
// 选择完优惠券的回调事件
|
||||||
function CouponModalSuccess(res) {
|
function CouponModalSuccess(res) {
|
||||||
console.log(res);
|
couponResList1.value = res
|
||||||
couponResType.value = res.type
|
updateCartCalc()
|
||||||
clearPoint()
|
// couponResType.value = res.type
|
||||||
|
// clearPoint()
|
||||||
|
|
||||||
if (res.type == 2) {
|
// if (res.type == 2) {
|
||||||
couponResList2Amount.value = 0
|
// couponResList2Amount.value = 0
|
||||||
couponResList1.value = []
|
// couponResList1.value = []
|
||||||
couponForm.value.fullCouponDiscountAmount = 0
|
// couponForm.value.fullCouponDiscountAmount = 0
|
||||||
couponResList2.value = res.couponList
|
// couponResList2.value = res.couponList
|
||||||
|
|
||||||
// 商品券
|
// // 商品券
|
||||||
const discountOrders = applyCoupons([...props.orderList], couponResList2.value)
|
// const discountOrders = applyCoupons([...props.orderList], couponResList2.value)
|
||||||
|
|
||||||
// 计算所有的优惠金额
|
// // 计算所有的优惠金额
|
||||||
discountOrders.forEach(item => {
|
// discountOrders.forEach(item => {
|
||||||
if (item.isCoupon) {
|
// if (item.isCoupon) {
|
||||||
if (item.discount) {
|
// if (item.discount) {
|
||||||
couponResList2Amount.value += item.discount
|
// couponResList2Amount.value += item.discount
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
|
|
||||||
couponForm.value.productCouponDiscountAmount = couponResList2Amount.value
|
// couponForm.value.productCouponDiscountAmount = couponResList2Amount.value
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (res.type == 1) {
|
// if (res.type == 1) {
|
||||||
if (couponForm.value.amount < res.couponList[0].fullAmount) {
|
// if (couponForm.value.amount < res.couponList[0].fullAmount) {
|
||||||
ElMessage.error(`订单金额不足¥${formatDecimal(res.couponList[0].fullAmount, 2, true)},无法使用优惠券`)
|
// ElMessage.error(`订单金额不足¥${formatDecimal(res.couponList[0].fullAmount, 2, true)},无法使用优惠券`)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
couponResList1.value = res.couponList
|
// couponResList1.value = res.couponList
|
||||||
couponForm.value.fullCouponDiscountAmount = res.couponList[0].discountAmount
|
// couponForm.value.fullCouponDiscountAmount = res.couponList[0].discountAmount
|
||||||
}
|
// }
|
||||||
|
|
||||||
let rate = 1
|
// let rate = 1
|
||||||
if (couponForm.value.discountRatio) {
|
// if (couponForm.value.discountRatio) {
|
||||||
rate = couponForm.value.discountRatio / couponFormDiscountRate.value
|
// rate = couponForm.value.discountRatio / couponFormDiscountRate.value
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 满减券,切勿使用discount计算
|
// // 满减券,切勿使用discount计算
|
||||||
couponForm.value.amount = formatDecimal((originOrderAmount.value * rate) - (couponResList1.value.length ? couponResList1.value[0].discountAmount : 0) - couponResList2Amount.value)
|
// couponForm.value.amount = formatDecimal((originOrderAmount.value * rate) - (couponResList1.value.length ? couponResList1.value[0].discountAmount : 0) - couponResList2Amount.value)
|
||||||
|
|
||||||
if (couponForm.value.amount < 0) {
|
// if (couponForm.value.amount < 0) {
|
||||||
couponForm.value.amount = 0
|
// couponForm.value.amount = 0
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 多个优惠券抵扣多个商品,优先已价格最低的抵扣
|
// 多个优惠券抵扣多个商品,优先已价格最低的抵扣
|
||||||
@@ -877,6 +960,9 @@ function delCoupon(index, t) {
|
|||||||
couponForm.value.amount = +couponForm.value.amount + +price
|
couponForm.value.amount = +couponForm.value.amount + +price
|
||||||
couponResList2.value.splice(index, 1)
|
couponResList2.value.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCartCalc()
|
||||||
|
|
||||||
console.log(couponForm.value.amount);
|
console.log(couponForm.value.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -942,29 +1028,29 @@ async function payCardInit() {
|
|||||||
discountAmount.value = null
|
discountAmount.value = null
|
||||||
roundAmount.value = 0
|
roundAmount.value = 0
|
||||||
discountRateVlaue.value = 0
|
discountRateVlaue.value = 0
|
||||||
money.value = `${formatDecimal(props.amount)}`;
|
money.value = `${formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount)}`;
|
||||||
originOrderAmount.value = formatDecimal(props.amount - (goodsStore.tableInfo.tableFee || 0) -
|
originOrderAmount.value = formatDecimal(props.amount - (goodsStore.tableInfo.tableFee || 0) -
|
||||||
(goodsStore.cartInfo.packFee || 0))
|
(goodsStore.cartInfo.packFee || 0))
|
||||||
payData.value = {
|
payData.value = {
|
||||||
shopId: store.shopInfo.id,
|
shopId: store.shopInfo.id,
|
||||||
buyerRemark: "", // 订单备注
|
buyerRemark: "", // 订单备注
|
||||||
checkOrderPay: {
|
checkOrderPay: {
|
||||||
orderId: goodsStore.orderListInfo.id,
|
// orderId: goodsStore.orderListInfo.id,
|
||||||
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价
|
// vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价
|
||||||
allPack: goodsStore.allSelected, // 是否整单打包
|
// allPack: goodsStore.allSelected, // 是否整单打包
|
||||||
userId: goodsStore.vipUserInfo.userId || '',
|
// userId: goodsStore.vipUserInfo.userId || '',
|
||||||
seatNum: goodsStore.tableInfo.num, // 用餐人数
|
// seatNum: goodsStore.tableInfo.num, // 用餐人数
|
||||||
originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
// originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||||
discountRatio: '', // 折扣比例(计算时 向上取整保留 两位小数)
|
// discountRatio: '', // 折扣比例(计算时 向上取整保留 两位小数)
|
||||||
discountAmount: 0, // 手动优惠金额
|
// discountAmount: 0, // 手动优惠金额
|
||||||
productCouponDiscountAmount: 0, // 商品优惠券抵扣金额
|
// productCouponDiscountAmount: 0, // 商品优惠券抵扣金额
|
||||||
fullCouponDiscountAmount: 0, // 满减优惠券抵扣金额
|
// fullCouponDiscountAmount: 0, // 满减优惠券抵扣金额
|
||||||
couponList: [], // 用户使用的卡券
|
// couponList: [], // 用户使用的卡券
|
||||||
orderAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单金额
|
// orderAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单金额
|
||||||
roundAmount: 0, // 抹零金额 减免多少钱
|
// roundAmount: 0, // 抹零金额 减免多少钱
|
||||||
pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
|
// pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
|
||||||
pointsNum: 0, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
// pointsNum: 0, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||||
isPrint: 1
|
// isPrint: 1
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="right" v-if="!userPayWait">
|
<div class="right" v-if="!userPayWait">
|
||||||
<div class="amount">
|
<div class="amount">
|
||||||
<span class="t">扫码支付</span>
|
<span class="t">扫码支付</span>
|
||||||
<span class="n">{{ props.money }}</span>
|
<span class="n">{{ goodsStore.cartInfo.costSummary.finalPayAmount }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<el-input ref="inputRef" v-model="scanCode" :maxlength="18"
|
<el-input ref="inputRef" v-model="scanCode" :maxlength="18"
|
||||||
@@ -100,6 +100,10 @@ const props = defineProps({
|
|||||||
payData: {
|
payData: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: {}
|
default: {}
|
||||||
|
},
|
||||||
|
chargeId: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: "",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -122,6 +126,11 @@ async function submitHandleAjax() {
|
|||||||
if (!scanCode.value || scanCode.value.length > 18) return;
|
if (!scanCode.value || scanCode.value.length > 18) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
|
console.log('props.selecttype===', props.selecttype);
|
||||||
|
console.log('props.payType===', props.payType);
|
||||||
|
|
||||||
|
// return;
|
||||||
|
|
||||||
// 判断订单是否锁定
|
// 判断订单是否锁定
|
||||||
await goodsStore.isOrderLock({
|
await goodsStore.isOrderLock({
|
||||||
table_code: goodsStore.orderListInfo.tableCode
|
table_code: goodsStore.orderListInfo.tableCode
|
||||||
@@ -147,7 +156,8 @@ async function submitHandleAjax() {
|
|||||||
shopId: store.shopInfo.id,
|
shopId: store.shopInfo.id,
|
||||||
shopUserId: props.orderId,
|
shopUserId: props.orderId,
|
||||||
amount: props.amount,
|
amount: props.amount,
|
||||||
authCode: scanCode.value
|
authCode: scanCode.value,
|
||||||
|
rechargeDetailId: props.chargeId,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// 快捷收银
|
// 快捷收银
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _, { reject } from "lodash";
|
import _ from "lodash";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
|
import { ref, computed } from "vue";
|
||||||
import { productPage, categoryList } from "@/api/product_new.js";
|
import { productPage, categoryList } from "@/api/product_new.js";
|
||||||
import { historyOrder, cancelOrder, rmPlaceOrder } from "@/api/order.js";
|
import { historyOrder, cancelOrder, rmPlaceOrder } from "@/api/order.js";
|
||||||
import { useUser } from "@/store/user.js";
|
import { useUser } from "@/store/user.js";
|
||||||
@@ -10,6 +11,8 @@ import { formatDecimal } from "@/utils/index.js";
|
|||||||
import { shopUserDetail } from "@/api/account.js";
|
import { shopUserDetail } from "@/api/account.js";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
|
||||||
|
import yskUtils from "ysk-utils";
|
||||||
|
|
||||||
// 商品store + 购物车store
|
// 商品store + 购物车store
|
||||||
export const useGoods = defineStore("goods", {
|
export const useGoods = defineStore("goods", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -31,15 +34,17 @@ export const useGoods = defineStore("goods", {
|
|||||||
cartActiveIndex: 0, // 购物车激活索引,
|
cartActiveIndex: 0, // 购物车激活索引,
|
||||||
isCartInit: false,
|
isCartInit: false,
|
||||||
cartList: [], // 购物车列表
|
cartList: [], // 购物车列表
|
||||||
cartInfo: {
|
// cartInfo: {
|
||||||
total: 0,
|
// total: 0,
|
||||||
totalAmount: 0,
|
// totalAmount: 0,
|
||||||
gifNumber: 0,
|
// gifNumber: 0,
|
||||||
gifNumberAmount: 0,
|
// gifNumberAmount: 0,
|
||||||
saleNumber: 0,
|
// saleNumber: 0,
|
||||||
saleNumberAmount: 0,
|
// saleNumberAmount: 0,
|
||||||
tableFee: 0,
|
// tableFee: 0,
|
||||||
}, // 购物车信息,
|
// },
|
||||||
|
// 购物车信息,
|
||||||
|
cartInfo: '',
|
||||||
goodsName: "", // 商品名称,
|
goodsName: "", // 商品名称,
|
||||||
categoryIndex: useStorage.get("categoryIndex") || 0, // 商品分类索引,
|
categoryIndex: useStorage.get("categoryIndex") || 0, // 商品分类索引,
|
||||||
categoryList: [], // 商品分类列表
|
categoryList: [], // 商品分类列表
|
||||||
@@ -247,7 +252,7 @@ export const useGoods = defineStore("goods", {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.orderList = arr;
|
this.orderList = arr;
|
||||||
console.log("this.orderList===2222", this.orderList);
|
// console.log("this.orderList===2222", this.orderList);
|
||||||
} else {
|
} else {
|
||||||
this.orderList = [];
|
this.orderList = [];
|
||||||
this.orderListInfo = "";
|
this.orderListInfo = "";
|
||||||
@@ -298,7 +303,7 @@ export const useGoods = defineStore("goods", {
|
|||||||
|
|
||||||
this.updateGoodsNumber();
|
this.updateGoodsNumber();
|
||||||
},
|
},
|
||||||
filterCategoryGoods(id) {},
|
filterCategoryGoods(id) { },
|
||||||
// 根据商品名字模糊查询商品列表
|
// 根据商品名字模糊查询商品列表
|
||||||
filterNameGoods(name) {
|
filterNameGoods(name) {
|
||||||
this.goodsList = _.chunk(
|
this.goodsList = _.chunk(
|
||||||
@@ -428,7 +433,7 @@ export const useGoods = defineStore("goods", {
|
|||||||
// await this.historyOrderAjax(this.tableInfo.tableCode);
|
// await this.historyOrderAjax(this.tableInfo.tableCode);
|
||||||
// }
|
// }
|
||||||
this.calcCartInfo();
|
this.calcCartInfo();
|
||||||
console.log("getCartList.cartList===", this.cartList);
|
// console.log("getCartList.cartList===", this.cartList);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("getCartList===", error);
|
console.log("getCartList===", error);
|
||||||
}
|
}
|
||||||
@@ -461,7 +466,7 @@ export const useGoods = defineStore("goods", {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("updateGoodsNumber===", this.goodsList);
|
// console.log("updateGoodsNumber===", this.goodsList);
|
||||||
},
|
},
|
||||||
// 添加商品到购物车
|
// 添加商品到购物车
|
||||||
addCart(params) {
|
addCart(params) {
|
||||||
@@ -540,14 +545,19 @@ export const useGoods = defineStore("goods", {
|
|||||||
},
|
},
|
||||||
// 补全商品信息
|
// 补全商品信息
|
||||||
completeGoodsInfo(item) {
|
completeGoodsInfo(item) {
|
||||||
|
console.log('补全商品信息===', item);
|
||||||
if (item.is_temporary) {
|
if (item.is_temporary) {
|
||||||
|
item.salePrice = item.discount_sale_amount
|
||||||
return item;
|
return item;
|
||||||
} else {
|
} else {
|
||||||
let flag = false;
|
let flag = false;
|
||||||
this.originGoodsList.map((val) => {
|
this.originGoodsList.map((val) => {
|
||||||
if (val.id == item.product_id) {
|
if (val.id == item.product_id) {
|
||||||
flag = true;
|
flag = true;
|
||||||
let sku = val.skuList.find((sku) => sku.id == item.sku_id);
|
let sku = val.skuList.find((sku) => sku.id == item.sku_id || sku.id == item.skuId);
|
||||||
|
|
||||||
|
console.log('sku===', sku);
|
||||||
|
|
||||||
|
|
||||||
let group_text = "";
|
let group_text = "";
|
||||||
if (val.type == "package" && item.pro_group_info) {
|
if (val.type == "package" && item.pro_group_info) {
|
||||||
@@ -560,6 +570,9 @@ export const useGoods = defineStore("goods", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
item.lowPrice = sku.salePrice;
|
item.lowPrice = sku.salePrice;
|
||||||
|
item.number = +item.number
|
||||||
|
item.num = +item.number
|
||||||
|
item.salePrice = sku.salePrice;
|
||||||
item.memberPrice = sku.memberPrice;
|
item.memberPrice = sku.memberPrice;
|
||||||
item.product_name = val.name;
|
item.product_name = val.name;
|
||||||
item.sku_name = sku && sku.specInfo;
|
item.sku_name = sku && sku.specInfo;
|
||||||
@@ -585,6 +598,8 @@ export const useGoods = defineStore("goods", {
|
|||||||
},
|
},
|
||||||
// 补全订单列表商品信息
|
// 补全订单列表商品信息
|
||||||
comleteOrderInfo(item) {
|
comleteOrderInfo(item) {
|
||||||
|
console.log('补全订单列表商品信息');
|
||||||
|
|
||||||
this.originGoodsList.map((val) => {
|
this.originGoodsList.map((val) => {
|
||||||
if (val.id == item.productId) {
|
if (val.id == item.productId) {
|
||||||
let sku = val.skuList.find((sku) => sku.id == item.skuId);
|
let sku = val.skuList.find((sku) => sku.id == item.skuId);
|
||||||
@@ -598,7 +613,6 @@ export const useGoods = defineStore("goods", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
item.product_id = item.productId;
|
item.product_id = item.productId;
|
||||||
item.lowPrice = item.price;
|
|
||||||
item.sku_name = sku && sku.specInfo;
|
item.sku_name = sku && sku.specInfo;
|
||||||
item.group_type = val.groupType;
|
item.group_type = val.groupType;
|
||||||
item.goods_type = val.type;
|
item.goods_type = val.type;
|
||||||
@@ -607,10 +621,15 @@ export const useGoods = defineStore("goods", {
|
|||||||
item.group_text = group_text;
|
item.group_text = group_text;
|
||||||
item.packFee = item.packAmount;
|
item.packFee = item.packAmount;
|
||||||
item.unitName = val.unitName;
|
item.unitName = val.unitName;
|
||||||
|
item.lowPrice = sku.salePrice;
|
||||||
|
item.salePrice = sku.salePrice;
|
||||||
}
|
}
|
||||||
item.pack_number = item.packNumber;
|
item.pack_number = item.packNumber;
|
||||||
item.product_name = item.productName;
|
item.product_name = item.productName;
|
||||||
item.number = item.num;
|
item.number = item.num;
|
||||||
|
item.is_temporary = item.isTemporary;
|
||||||
|
item.discount_sale_amount = item.discountSaleAmount
|
||||||
|
item.is_gift = item.isGift
|
||||||
});
|
});
|
||||||
return item;
|
return item;
|
||||||
},
|
},
|
||||||
@@ -685,147 +704,276 @@ export const useGoods = defineStore("goods", {
|
|||||||
this.calcCartInfo();
|
this.calcCartInfo();
|
||||||
},
|
},
|
||||||
// 计算购物车信息
|
// 计算购物车信息
|
||||||
calcCartInfo() {
|
// calcCartInfo() {
|
||||||
this.updateGoodsNumber();
|
// console.log("yskUtils===", yskUtils);
|
||||||
|
|
||||||
|
// this.updateGoodsNumber();
|
||||||
|
// const store = useUser();
|
||||||
|
|
||||||
|
// let total = 0; // 总数量
|
||||||
|
// let totalAmount = 0; // 总金额
|
||||||
|
// let gifNumber = 0; // 赠送总数量
|
||||||
|
// let gifNumberAmount = 0; // 赠送总金额
|
||||||
|
// let saleNumber = 0; // 打折总数量
|
||||||
|
// let saleNumberAmount = 0; // 打折总金额
|
||||||
|
// let packFee = 0; // 打包费
|
||||||
|
// let packFeeNumber = 0; // 打包数量
|
||||||
|
// let tableFee = 0; // 客座费
|
||||||
|
|
||||||
|
// let arr = [
|
||||||
|
// ...this.cartList,
|
||||||
|
// ...this.orderList
|
||||||
|
// .map((item) => item.goods)
|
||||||
|
// .flat()
|
||||||
|
// .map((item) => {
|
||||||
|
// item.discount_sale_amount = item.discountSaleAmount;
|
||||||
|
// item.discount_sale_note = item.discountSaleNote;
|
||||||
|
// item.is_print = item.isPrint;
|
||||||
|
// item.is_gift = item.isGift;
|
||||||
|
// item.is_temporary = item.isTemporary;
|
||||||
|
// return item;
|
||||||
|
// }),
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// console.log("arr===11111", arr);
|
||||||
|
|
||||||
|
// arr.map((val, index) => {
|
||||||
|
// let lowPrice = 0;
|
||||||
|
// let number = val.number - (val.returnNum || 0);
|
||||||
|
|
||||||
|
// if (this.vipUserInfo.id && store.shopInfo.isMemberPrice) {
|
||||||
|
// if (!+val.memberPrice) {
|
||||||
|
// lowPrice = val.lowPrice;
|
||||||
|
// } else {
|
||||||
|
// lowPrice = +val.memberPrice;
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// lowPrice = val.lowPrice;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// total += number;
|
||||||
|
|
||||||
|
// if (+val.pack_number && !val.is_temporary) {
|
||||||
|
// packFeeNumber += +val.pack_number;
|
||||||
|
// if (+val.pack_number > number) {
|
||||||
|
// packFee += number * +val.packFee;
|
||||||
|
// } else {
|
||||||
|
// packFee += +val.pack_number * +val.packFee;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (val.is_temporary) {
|
||||||
|
// if (val.is_gift) {
|
||||||
|
// gifNumber += +number;
|
||||||
|
// gifNumberAmount += +number * +val.discount_sale_amount;
|
||||||
|
// } else {
|
||||||
|
// // 临时菜使用discount_sale_amount计算价格
|
||||||
|
// totalAmount += number * val.discount_sale_amount;
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if (val.is_gift) {
|
||||||
|
// // 赠送
|
||||||
|
// if (+val.discount_sale_amount) {
|
||||||
|
// // 且有折扣
|
||||||
|
// gifNumber += +number;
|
||||||
|
// gifNumberAmount += +number * val.discount_sale_amount;
|
||||||
|
|
||||||
|
// saleNumber += +number;
|
||||||
|
// saleNumberAmount +=
|
||||||
|
// number * (lowPrice - val.discount_sale_amount);
|
||||||
|
// } else {
|
||||||
|
// gifNumber += +number;
|
||||||
|
// gifNumberAmount += +number * +lowPrice;
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if (+val.discount_sale_amount) {
|
||||||
|
// // 代表打过折
|
||||||
|
// saleNumber += +number;
|
||||||
|
// saleNumberAmount +=
|
||||||
|
// number * (lowPrice - val.discount_sale_amount);
|
||||||
|
|
||||||
|
// // 使用正常价减去折扣价格计算
|
||||||
|
// totalAmount += number * val.discount_sale_amount;
|
||||||
|
// } else {
|
||||||
|
// // 使用正常价格计算
|
||||||
|
// totalAmount += number * lowPrice;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// this.cartInfo.gifNumber = +gifNumber;
|
||||||
|
// this.cartInfo.gifNumberAmount = gifNumberAmount;
|
||||||
|
|
||||||
|
// this.cartInfo.saleNumber = saleNumber;
|
||||||
|
// this.cartInfo.saleNumberAmount = saleNumberAmount;
|
||||||
|
|
||||||
|
// this.cartInfo.packFee = packFee;
|
||||||
|
// this.cartInfo.packFeeNumber = packFeeNumber;
|
||||||
|
|
||||||
|
// this.cartInfo.total = total;
|
||||||
|
|
||||||
|
// if (this.tableInfo.name && !store.shopInfo.isTableFee) {
|
||||||
|
// tableFee = this.tableInfo.num * store.shopInfo.tableFee;
|
||||||
|
// this.tableInfo.tableFee = tableFee;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// console.log("this.tableInfo.tableFee===", tableFee);
|
||||||
|
|
||||||
|
// this.cartInfo.totalAmount = totalAmount + packFee + tableFee;
|
||||||
|
|
||||||
|
// console.log("this.cartInfo===", this.cartInfo);
|
||||||
|
|
||||||
|
// const discountInfo = [];
|
||||||
|
|
||||||
|
// if (this.cartInfo.gifNumberAmount) {
|
||||||
|
// discountInfo.push(
|
||||||
|
// `赠送:${formatDecimal(this.cartInfo.gifNumberAmount, 2, true)}元`
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// if (this.cartInfo.saleNumberAmount) {
|
||||||
|
// discountInfo.push(
|
||||||
|
// `改价优惠:${formatDecimal(
|
||||||
|
// this.cartInfo.saleNumberAmount,
|
||||||
|
// 2,
|
||||||
|
// true
|
||||||
|
// )}元`
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// if (this.cartInfo.packFee) {
|
||||||
|
// discountInfo.push(
|
||||||
|
// `打包费:${formatDecimal(this.cartInfo.packFee, 2, true)}元`
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// this.cartInfo.discountInfo = discountInfo.join(",");
|
||||||
|
// },
|
||||||
|
// 计算购物车信息
|
||||||
|
calcCartInfo(opts = {}) {
|
||||||
|
const defaultOptions = {
|
||||||
|
pointsPerYuan: 0, // 积分换算规律
|
||||||
|
maxDeductionAmount: 0, // 最大抵扣
|
||||||
|
userPoints: 0, // 使用积分数量
|
||||||
|
newUserDiscount: 0, // 新客立减
|
||||||
|
fixedAmount: 0, // 商家减免
|
||||||
|
backendCoupons: [], // 已选择的优惠券
|
||||||
|
};
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
...defaultOptions,
|
||||||
|
...opts
|
||||||
|
}
|
||||||
|
|
||||||
const store = useUser();
|
const store = useUser();
|
||||||
|
|
||||||
let total = 0; // 总数量
|
const { OrderPriceCalculator } = yskUtils;
|
||||||
let totalAmount = 0; // 总金额
|
|
||||||
let gifNumber = 0; // 赠送总数量
|
|
||||||
let gifNumberAmount = 0; // 赠送总金额
|
|
||||||
let saleNumber = 0; // 打折总数量
|
|
||||||
let saleNumberAmount = 0; // 打折总金额
|
|
||||||
let packFee = 0; // 打包费
|
|
||||||
let packFeeNumber = 0; // 打包数量
|
|
||||||
let tableFee = 0; // 客座费
|
|
||||||
|
|
||||||
let arr = [
|
const shopInfo = ref(store.shopInfo) || {
|
||||||
...this.cartList,
|
isMemberPrice: 0,
|
||||||
...this.orderList
|
isTableFee: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const consumeDiscount = ref({});
|
||||||
|
|
||||||
|
//商品数据Map
|
||||||
|
const goodsMap = this.originGoodsList
|
||||||
|
|
||||||
|
var getAllGoodsList = () => {
|
||||||
|
console.log('this.cartList===', this.cartList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const currentGoods = (this.cartList).map(item => {
|
||||||
|
return {
|
||||||
|
...this.completeGoodsInfo(item),
|
||||||
|
discountSaleAmount: item.discount_sale_amount
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('currentGoods===', currentGoods);
|
||||||
|
|
||||||
|
const giftGoods = [].map(this.completeGoodsInfo);
|
||||||
|
// 扁平化历史订单商品
|
||||||
|
const oldOrderGoods = this.orderList
|
||||||
.map((item) => item.goods)
|
.map((item) => item.goods)
|
||||||
.flat()
|
.flat()
|
||||||
.map((item) => {
|
.map(this.comleteOrderInfo);
|
||||||
item.discount_sale_amount = item.discountSaleAmount;
|
return [...currentGoods, ...giftGoods, ...oldOrderGoods];
|
||||||
item.discount_sale_note = item.discountSaleNote;
|
}
|
||||||
item.is_print = item.isPrint;
|
|
||||||
item.is_gift = item.isGift;
|
|
||||||
item.is_temporary = item.isTemporary;
|
|
||||||
return item;
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
console.log("arr===11111", arr);
|
// 合并所有商品列表
|
||||||
|
const allGoods = ref(getAllGoodsList() || [])
|
||||||
|
|
||||||
arr.map((val, index) => {
|
// 就餐类型 'dine-in' | 'take-out'
|
||||||
let lowPrice = 0;
|
let dinnerType = ref(this.allSelected ? "take-out" : "dine-in");
|
||||||
let number = val.number - (val.returnNum || 0);
|
|
||||||
|
|
||||||
if (this.vipUserInfo.id && store.shopInfo.isMemberPrice) {
|
// 餐位费
|
||||||
if (!+val.memberPrice) {
|
const seatFeeConfig = ref({
|
||||||
lowPrice = val.lowPrice;
|
pricePerPerson: store.shopInfo.tableFee || 0,
|
||||||
} else {
|
personCount: this.tableInfo.num,
|
||||||
lowPrice = +val.memberPrice;
|
isEnabled: !store.shopInfo.isTableFee,
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lowPrice = val.lowPrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
total += number;
|
|
||||||
|
|
||||||
if (+val.pack_number && !val.is_temporary) {
|
|
||||||
packFeeNumber += +val.pack_number;
|
|
||||||
if (+val.pack_number > number) {
|
|
||||||
packFee += number * +val.packFee;
|
|
||||||
} else {
|
|
||||||
packFee += +val.pack_number * +val.packFee;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (val.is_temporary) {
|
|
||||||
if (val.is_gift) {
|
|
||||||
gifNumber += +number;
|
|
||||||
gifNumberAmount += +number * +val.discount_sale_amount;
|
|
||||||
} else {
|
|
||||||
// 临时菜使用discount_sale_amount计算价格
|
|
||||||
totalAmount += number * val.discount_sale_amount;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (val.is_gift) {
|
|
||||||
// 赠送
|
|
||||||
if (+val.discount_sale_amount) {
|
|
||||||
// 且有折扣
|
|
||||||
gifNumber += +number;
|
|
||||||
gifNumberAmount += +number * val.discount_sale_amount;
|
|
||||||
|
|
||||||
saleNumber += +number;
|
|
||||||
saleNumberAmount +=
|
|
||||||
number * (lowPrice - val.discount_sale_amount);
|
|
||||||
} else {
|
|
||||||
gifNumber += +number;
|
|
||||||
gifNumberAmount += +number * +lowPrice;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (+val.discount_sale_amount) {
|
|
||||||
// 代表打过折
|
|
||||||
saleNumber += +number;
|
|
||||||
saleNumberAmount +=
|
|
||||||
number * (lowPrice - val.discount_sale_amount);
|
|
||||||
|
|
||||||
// 使用正常价减去折扣价格计算
|
|
||||||
totalAmount += number * val.discount_sale_amount;
|
|
||||||
} else {
|
|
||||||
// 使用正常价格计算
|
|
||||||
totalAmount += number * lowPrice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.cartInfo.gifNumber = +gifNumber;
|
//积分规则
|
||||||
this.cartInfo.gifNumberAmount = gifNumberAmount;
|
const pointDeductionRule = ref({
|
||||||
|
pointsPerYuan: options.pointsPerYuan,
|
||||||
|
maxDeductionAmount: options.maxDeductionAmount,
|
||||||
|
});
|
||||||
|
|
||||||
this.cartInfo.saleNumber = saleNumber;
|
const userPoints = ref(options.userPoints);
|
||||||
this.cartInfo.saleNumberAmount = saleNumberAmount;
|
|
||||||
|
|
||||||
this.cartInfo.packFee = packFee;
|
// 初始配置:默认无减免(固定金额 0 元)
|
||||||
this.cartInfo.packFeeNumber = packFeeNumber;
|
const merchantReductionConfig = ref({
|
||||||
|
type: "fixed_amount",
|
||||||
|
fixedAmount: options.fixedAmount,
|
||||||
|
});
|
||||||
|
|
||||||
this.cartInfo.total = total;
|
//新客立减
|
||||||
|
const newUserDiscount = ref(options.newUserDiscount);
|
||||||
|
// 订单额外配置
|
||||||
|
const orderExtraConfig = computed(() => ({
|
||||||
|
// 引用扩展后的商家减免配置
|
||||||
|
merchantReduction: merchantReductionConfig.value,
|
||||||
|
additionalFee: 0,
|
||||||
|
pointDeductionRule: pointDeductionRule.value,
|
||||||
|
seatFeeConfig: seatFeeConfig.value,
|
||||||
|
currentStoreId: "",
|
||||||
|
userPoints: userPoints.value,
|
||||||
|
isMember: this.showVipPrice,
|
||||||
|
memberDiscountRate: 1,
|
||||||
|
newUserDiscount: newUserDiscount.value,
|
||||||
|
}));
|
||||||
|
|
||||||
if (this.tableInfo.name && !store.shopInfo.isTableFee) {
|
// 营销活动列表
|
||||||
tableFee = this.tableInfo.num * store.shopInfo.tableFee;
|
const activityList = [];
|
||||||
this.tableInfo.tableFee = tableFee;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("this.tableInfo.tableFee===", tableFee);
|
// 优惠券列表
|
||||||
|
const backendCoupons = ref(options.backendCoupons);
|
||||||
|
|
||||||
this.cartInfo.totalAmount = totalAmount + packFee + tableFee;
|
// 商品加入购物车顺序
|
||||||
|
const cartOrder = ref({});
|
||||||
|
|
||||||
console.log("this.cartInfo===", this.cartInfo);
|
// 订单费用汇总
|
||||||
|
|
||||||
const discountInfo = [];
|
console.log('allGoods===', allGoods);
|
||||||
|
|
||||||
if (this.cartInfo.gifNumberAmount) {
|
|
||||||
discountInfo.push(
|
|
||||||
`赠送:${formatDecimal(this.cartInfo.gifNumberAmount, 2, true)}元`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (this.cartInfo.saleNumberAmount) {
|
|
||||||
discountInfo.push(
|
|
||||||
`改价优惠:${formatDecimal(
|
|
||||||
this.cartInfo.saleNumberAmount,
|
|
||||||
2,
|
|
||||||
true
|
|
||||||
)}元`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (this.cartInfo.packFee) {
|
|
||||||
discountInfo.push(
|
|
||||||
`打包费:${formatDecimal(this.cartInfo.packFee, 2, true)}元`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.cartInfo.discountInfo = discountInfo.join(",");
|
const orderCostSummary = {
|
||||||
|
allGoods: allGoods.value,
|
||||||
|
costSummary: OrderPriceCalculator.calculateOrderCostSummary(
|
||||||
|
allGoods.value,
|
||||||
|
dinnerType.value,
|
||||||
|
backendCoupons.value,
|
||||||
|
activityList.value,
|
||||||
|
orderExtraConfig.value,
|
||||||
|
cartOrder.value,
|
||||||
|
new Date()
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("orderCostSummary===", orderCostSummary);
|
||||||
|
this.cartInfo = orderCostSummary
|
||||||
|
return orderCostSummary;
|
||||||
},
|
},
|
||||||
// 购物车操作
|
// 购物车操作
|
||||||
operateCart(data, operate_type = "add") {
|
operateCart(data, operate_type = "add") {
|
||||||
@@ -874,3 +1022,12 @@ export const useGoods = defineStore("goods", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// // 在store外部或初始化时订阅
|
||||||
|
// const goodsStore = useGoods()
|
||||||
|
// goodsStore.$subscribe((mutation, state) => {
|
||||||
|
// // mutation包含变化的信息
|
||||||
|
// console.log(`状态变化:`, mutation, state)
|
||||||
|
// // 可以根据变化执行逻辑
|
||||||
|
// })
|
||||||
520
src/utils/coupon-utils.js
Normal file
520
src/utils/coupon-utils.js
Normal file
@@ -0,0 +1,520 @@
|
|||||||
|
import {
|
||||||
|
BigNumber
|
||||||
|
} from "bignumber.js";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回商品单价
|
||||||
|
* @param goods 商品
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param {Object} shopInfo
|
||||||
|
*/
|
||||||
|
export function returnGoodsPrice(goods, user, shopInfo) {
|
||||||
|
if (!goods) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if (goods.discount_sale_amount * 1 > 0) {
|
||||||
|
return goods.discount_sale_amount;
|
||||||
|
}
|
||||||
|
if (shopInfo && !shopInfo.isMemberPrice) {
|
||||||
|
return goods.salePrice;
|
||||||
|
}
|
||||||
|
if (user.isVip && goods.memberPrice * 1 <= goods.salePrice * 1 && goods.memberPrice * 1 > 0) {
|
||||||
|
return goods.memberPrice;
|
||||||
|
}
|
||||||
|
return goods.salePrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回商品分组
|
||||||
|
* @param arr 商品列表
|
||||||
|
*/
|
||||||
|
export function returnGoodsGroupMap(arr) {
|
||||||
|
let map = {};
|
||||||
|
arr.forEach((v) => {
|
||||||
|
const key = v.productId + "_" + v.skuId;
|
||||||
|
if (!map[key]) {
|
||||||
|
map[key] = [];
|
||||||
|
}
|
||||||
|
map[key].push(v);
|
||||||
|
});
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券类型:1-满减券,2-商品兑换券,3-折扣券,4-第二件半价券,5-消费送券,6-买一送一券,7-固定价格券,8-免配送费券
|
||||||
|
* @param coupon
|
||||||
|
*/
|
||||||
|
export function returnCoupType(coupon) {
|
||||||
|
const couponTypes = {
|
||||||
|
1: "满减券",
|
||||||
|
2: "商品券",
|
||||||
|
3: "折扣券",
|
||||||
|
4: "第二件半价券",
|
||||||
|
5: "消费送券",
|
||||||
|
6: "买一送一券",
|
||||||
|
7: "固定价格券",
|
||||||
|
8: "免配送费券",
|
||||||
|
};
|
||||||
|
return couponTypes[coupon.type] || "未知类型";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回商品券抵扣后的商品列表
|
||||||
|
* @param canDikouGoodsArr 可抵扣商品列表
|
||||||
|
* @param selCoupon 已选择的优惠券列表
|
||||||
|
* @param user 用户信息
|
||||||
|
*/
|
||||||
|
export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
|
||||||
|
const types = [2, 4, 6];
|
||||||
|
// 收集已抵扣商品并关联对应的优惠券类型
|
||||||
|
const goodsCouponGoods = selCoupon
|
||||||
|
.filter((v) => types.includes(v.type))
|
||||||
|
.reduce((prev, cur) => {
|
||||||
|
// 给每个抵扣商品添加所属优惠券类型
|
||||||
|
const goodsWithType = cur.discount.hasDiscountGoodsArr.map(goods => ({
|
||||||
|
...goods,
|
||||||
|
couponType: cur.type // 记录该商品是被哪种类型的优惠券抵扣的
|
||||||
|
}));
|
||||||
|
prev.push(...goodsWithType);
|
||||||
|
return prev;
|
||||||
|
}, []);
|
||||||
|
const arr = _.cloneDeep(canDikouGoodsArr)
|
||||||
|
.map((v) => {
|
||||||
|
const findCart = goodsCouponGoods.find((carts) => carts.id == v.id);
|
||||||
|
if (findCart) {
|
||||||
|
// 根据优惠券类型判断扣减数量
|
||||||
|
if ([4, 6].includes(findCart.couponType)) {
|
||||||
|
// 类型4(第二件半价)或6(买一送一),数量减2
|
||||||
|
v.num -= 2;
|
||||||
|
} else {
|
||||||
|
// 其他类型(如类型2商品券),按原逻辑扣减对应数量
|
||||||
|
v.num -= findCart.num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
})
|
||||||
|
.filter((v) => v.num > 0); // 过滤掉数量<=0的商品
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断优惠券是否可使用,并返回不可用原因
|
||||||
|
*
|
||||||
|
* @param {Object} args - 函数参数集合
|
||||||
|
* @param {Array} args.canDikouGoodsArr - 可参与抵扣的商品列表
|
||||||
|
* @param {Object} args.coupon - 优惠券信息对象
|
||||||
|
* @param {boolean} args.coupon.use - 优惠券是否启用
|
||||||
|
* @param {Array} args.coupon.useFoods - 优惠券适用的商品ID列表
|
||||||
|
* @param {number} args.coupon.fullAmount - 优惠券使用门槛金额
|
||||||
|
* @param {number} args.coupon.type - 优惠券类型
|
||||||
|
* @param {number} args.goodsOrderPrice - 订单中所有商品的总金额
|
||||||
|
* @param {Object} args.user - 用户信息对象
|
||||||
|
* @param {Object} args.selCoupon - 已经选择的优惠券信息对象
|
||||||
|
* @param {Object} args.shopInfo
|
||||||
|
* @returns {Object} - { canUse: boolean, reason: string } 可用状态及不可用原因
|
||||||
|
*/
|
||||||
|
export function returnCouponCanUse(args) {
|
||||||
|
let {
|
||||||
|
canDikouGoodsArr,
|
||||||
|
coupon,
|
||||||
|
goodsOrderPrice,
|
||||||
|
user,
|
||||||
|
selCoupon,
|
||||||
|
shopInfo
|
||||||
|
} = args;
|
||||||
|
// 优惠券未启用
|
||||||
|
if (!coupon.use) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason:coupon.noUseRestrictions|| "不在可用时间段内"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算门槛金额
|
||||||
|
let fullAmount = goodsOrderPrice;
|
||||||
|
canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user, shopInfo);
|
||||||
|
//优惠券指定门槛商品列表
|
||||||
|
let canCalcGoodsArr = [...canDikouGoodsArr]
|
||||||
|
//部分商品参与门槛计算
|
||||||
|
if (coupon.thresholdFoods.length) {
|
||||||
|
canCalcGoodsArr = canDikouGoodsArr.filter((v) => {
|
||||||
|
return coupon.thresholdFoods.find((food) => food.id == v.productId);
|
||||||
|
});
|
||||||
|
fullAmount = canCalcGoodsArr.reduce((pre, cur) => {
|
||||||
|
return pre + returnGoodsPrice(cur, user, shopInfo) * cur.num;
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 是否全部商品可用
|
||||||
|
const isDikouAll = coupon.useFoods.length === 0;
|
||||||
|
// 订单可用商品列表
|
||||||
|
let canUseGoodsArr = [];
|
||||||
|
if (!isDikouAll) {
|
||||||
|
canUseGoodsArr = canDikouGoodsArr.filter((v) => {
|
||||||
|
return coupon.useFoods.find((food) => food.id == v.productId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (user.isVip && !coupon.vipPriceShare) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "非会员可用"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (selCoupon.length > 0 && !selCoupon[0].otherCouponShare) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "当前选中的券不可与其他券同享"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (selCoupon.length > 0 && !coupon.otherCouponShare) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "当前选中的券不可与其他券同享"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// 满减券和折扣券计算门槛金额是否满足
|
||||||
|
if ([1, 3].includes(coupon.type)) {
|
||||||
|
if (canCalcGoodsArr.length <= 0) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "没有可参与计算门槛的商品"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// 不满足门槛金额
|
||||||
|
if (fullAmount < coupon.fullAmount) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
|
||||||
|
if ([2, 4, 5].includes(coupon.type)) {
|
||||||
|
// 没有符合条件的商品
|
||||||
|
if (isDikouAll && canDikouGoodsArr.length === 0) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "没有符合条件的商品"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!isDikouAll && canUseGoodsArr.length === 0) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "没有符合条件的商品"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//商品兑换券是否达到门槛金额
|
||||||
|
if (coupon.type == 2 && goodsOrderPrice < coupon.fullAmount) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 买一送一券特殊验证
|
||||||
|
if (coupon.type === 6) {
|
||||||
|
let canUse = false;
|
||||||
|
if (isDikouAll) {
|
||||||
|
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
|
||||||
|
} else if (canCalcGoodsArr.length > 0) {
|
||||||
|
canUse = canCalcGoodsArr.some((v) => v.num >= 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!canUse) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "需要购买至少2件相同的商品才能使用"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第二件半价券特殊验证
|
||||||
|
if (coupon.type === 4) {
|
||||||
|
let canUse = false;
|
||||||
|
if (isDikouAll) {
|
||||||
|
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
|
||||||
|
} else if (canCalcGoodsArr.length > 0) {
|
||||||
|
canUse = canCalcGoodsArr.some((v) => v.num >= 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!canUse) {
|
||||||
|
return {
|
||||||
|
canUse: false,
|
||||||
|
reason: "需要购买至少2件相同的商品才能使用"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 所有条件都满足
|
||||||
|
return {
|
||||||
|
canUse: true,
|
||||||
|
reason: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算抵扣商品金额
|
||||||
|
* @param discountGoodsArr 可抵扣商品列表
|
||||||
|
* @param discountNum 抵扣数量
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param {Object} shopInfo 店铺信息
|
||||||
|
*/
|
||||||
|
export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user, shopInfo) {
|
||||||
|
let hasCountNum = 0;
|
||||||
|
let discountPrice = 0;
|
||||||
|
let hasDiscountGoodsArr = [];
|
||||||
|
for (let i = 0; i < discountGoodsArr.length; i++) {
|
||||||
|
if (hasCountNum >= discountNum) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const goods = discountGoodsArr[i];
|
||||||
|
const shengyuNum = discountNum - hasCountNum;
|
||||||
|
const num = Math.min(goods.num, shengyuNum);
|
||||||
|
discountPrice += returnGoodsPrice(goods, user, shopInfo) * num;
|
||||||
|
hasCountNum += num;
|
||||||
|
hasDiscountGoodsArr.push({
|
||||||
|
...goods,
|
||||||
|
num
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
discountPrice,
|
||||||
|
hasDiscountGoodsArr
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算优惠券抵扣金额
|
||||||
|
* @param arr 可抵扣商品列表
|
||||||
|
* @param coupon 优惠券
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param goodsOrderPrice 商品订单金额
|
||||||
|
* @param selCoupon 已选择的优惠券列表
|
||||||
|
* @param shopInfo 店铺信息
|
||||||
|
*/
|
||||||
|
export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon, shopInfo) {
|
||||||
|
const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user);
|
||||||
|
if (coupon.type == 2) {
|
||||||
|
return returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
||||||
|
}
|
||||||
|
if (coupon.type == 6) {
|
||||||
|
const result = returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
if (coupon.type == 4) {
|
||||||
|
return returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
||||||
|
}
|
||||||
|
if (coupon.type == 3) {
|
||||||
|
return returnCouponZhekouDiscount(canDikouGoodsArr, coupon, user, goodsOrderPrice, selCoupon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 折扣券抵扣金额
|
||||||
|
* @param canDikouGoodsArr 可抵扣商品列表
|
||||||
|
* @param coupon 优惠券
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param goodsOrderPrice 商品订单金额
|
||||||
|
* @param selCoupon 已选择的优惠券列表
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function returnCouponZhekouDiscount(
|
||||||
|
canDikouGoodsArr,
|
||||||
|
coupon,
|
||||||
|
user,
|
||||||
|
goodsOrderPrice,
|
||||||
|
selCoupon
|
||||||
|
) {
|
||||||
|
const {
|
||||||
|
discountRate,
|
||||||
|
maxDiscountAmount
|
||||||
|
} = coupon;
|
||||||
|
|
||||||
|
// 计算商品优惠券折扣总和,使用BigNumber避免精度问题
|
||||||
|
const goodsCouponDiscount = selCoupon
|
||||||
|
.filter((v) => v.type == 2)
|
||||||
|
.reduce((prve, cur) => {
|
||||||
|
return new BigNumber(prve).plus(new BigNumber(cur.discount.discountPrice));
|
||||||
|
}, new BigNumber(0));
|
||||||
|
|
||||||
|
// 将商品订单价格转换为BigNumber并减去优惠券折扣
|
||||||
|
const adjustedGoodsOrderPrice = new BigNumber(goodsOrderPrice).minus(goodsCouponDiscount);
|
||||||
|
console.log('adjustedGoodsOrderPrice', adjustedGoodsOrderPrice.toNumber());
|
||||||
|
|
||||||
|
// 计算优惠比例:(100 - 折扣率) / 100
|
||||||
|
const discountAmountRatio = new BigNumber(100).minus(discountRate).dividedBy(100);
|
||||||
|
|
||||||
|
// 计算折扣金额:调整后的商品订单金额 × 优惠比例
|
||||||
|
let discountPrice = adjustedGoodsOrderPrice.times(discountAmountRatio)
|
||||||
|
.decimalPlaces(2, BigNumber.ROUND_FLOOR)
|
||||||
|
.toNumber();
|
||||||
|
|
||||||
|
// 应用最大折扣金额限制
|
||||||
|
if (maxDiscountAmount !== 0) {
|
||||||
|
discountPrice = discountPrice >= maxDiscountAmount ? maxDiscountAmount : discountPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
discountPrice, // 折扣抵扣金额(即优惠的金额)
|
||||||
|
hasDiscountGoodsArr: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品券抵扣金额
|
||||||
|
* @param canDikouGoodsArr 可抵扣商品列表
|
||||||
|
* @param coupon 优惠券
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param shopInfo 店铺信息
|
||||||
|
*/
|
||||||
|
export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
|
||||||
|
const {
|
||||||
|
useFoods,
|
||||||
|
discountNum,
|
||||||
|
useRule
|
||||||
|
} = coupon;
|
||||||
|
//抵扣商品数组
|
||||||
|
let discountGoodsArr = [];
|
||||||
|
//抵扣全部商品
|
||||||
|
if (useFoods.length === 0) {
|
||||||
|
if (useRule == "price_asc") {
|
||||||
|
discountGoodsArr = canDikouGoodsArr
|
||||||
|
.slice(canDikouGoodsArr.length - discountNum, canDikouGoodsArr.length)
|
||||||
|
.reverse();
|
||||||
|
} else {
|
||||||
|
discountGoodsArr = canDikouGoodsArr.slice(0, discountNum);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//抵扣选中商品
|
||||||
|
const discountSelGoodsArr = canDikouGoodsArr.filter((v) =>
|
||||||
|
useFoods.find((food) => food.id == v.productId)
|
||||||
|
);
|
||||||
|
if (useRule == "price_asc") {
|
||||||
|
discountGoodsArr = discountSelGoodsArr
|
||||||
|
.slice(discountSelGoodsArr.length - discountNum, discountSelGoodsArr.length)
|
||||||
|
.reverse();
|
||||||
|
} else {
|
||||||
|
discountGoodsArr = discountSelGoodsArr.slice(0, discountNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const result = calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user, shopInfo);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回买一送一券抵扣详情
|
||||||
|
/**
|
||||||
|
* @param canDikouGoodsArr 可抵扣商品列表
|
||||||
|
* @param coupon 优惠券
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param shopInfo 店铺信息
|
||||||
|
*/
|
||||||
|
function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
|
||||||
|
const {
|
||||||
|
useFoods,
|
||||||
|
useRule
|
||||||
|
} = coupon;
|
||||||
|
//抵扣商品
|
||||||
|
let discountGoods = undefined;
|
||||||
|
//符合买一送一条件的商品
|
||||||
|
const canUseGoods = canDikouGoodsArr.filter((v) => v.num >= 2);
|
||||||
|
//抵扣全部商品
|
||||||
|
if (useFoods.length === 0) {
|
||||||
|
if (useRule == "price_asc") {
|
||||||
|
discountGoods = canUseGoods[canUseGoods.length - 1]
|
||||||
|
} else {
|
||||||
|
discountGoods = canUseGoods[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//符合抵扣条件的商品
|
||||||
|
const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId));
|
||||||
|
if (useRule == "price_asc") {
|
||||||
|
discountGoods = canUseGoods1[canUseGoods1.length - 1]
|
||||||
|
} else {
|
||||||
|
discountGoods = canUseGoods1[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let discountPrice = 0;
|
||||||
|
let hasDiscountGoodsArr = []
|
||||||
|
console.log('returnCouponBuyOneGiveOneDiscount:discountGoods',discountGoods);
|
||||||
|
if (discountGoods) {
|
||||||
|
discountPrice = returnGoodsPrice(discountGoods, user, shopInfo);
|
||||||
|
hasDiscountGoodsArr = [discountGoods];
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
discountPrice:discountPrice<=0?0:discountPrice,
|
||||||
|
hasDiscountGoodsArr
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回第二件半价券抵扣详情
|
||||||
|
* @param canDikouGoodsArr 可抵扣商品列表
|
||||||
|
* @param coupon 优惠券
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param shopInfo 店铺信息
|
||||||
|
*/
|
||||||
|
function returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
|
||||||
|
const {
|
||||||
|
useFoods,
|
||||||
|
useRule
|
||||||
|
} = coupon;
|
||||||
|
//抵扣商品
|
||||||
|
let discountGoods = undefined;
|
||||||
|
//符合条件的商品
|
||||||
|
const canUseGoods = canDikouGoodsArr.filter((v) => v.num >= 2);
|
||||||
|
//抵扣全部商品
|
||||||
|
if (useFoods.length === 0) {
|
||||||
|
if (useRule == "price_asc") {
|
||||||
|
discountGoods = canUseGoods[canUseGoods.length - 1]
|
||||||
|
} else {
|
||||||
|
discountGoods = canUseGoods[0]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//符合抵扣条件的商品
|
||||||
|
const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId));
|
||||||
|
if (useRule == "price_asc") {
|
||||||
|
discountGoods = canUseGoods1[canUseGoods1.length - 1]
|
||||||
|
} else {
|
||||||
|
discountGoods = canUseGoods1[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let discountPrice = 0;
|
||||||
|
let hasDiscountGoodsArr = []
|
||||||
|
if (discountGoods) {
|
||||||
|
discountPrice = returnGoodsPrice(discountGoods, user, shopInfo);
|
||||||
|
hasDiscountGoodsArr = [discountGoods];
|
||||||
|
}
|
||||||
|
//返回半价价格
|
||||||
|
return {
|
||||||
|
discountPrice: discountPrice <= 0 ? 0 : new BigNumber(discountPrice).dividedBy(2).toNumber(),
|
||||||
|
hasDiscountGoodsArr,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回可以抵扣优惠券的商品列表,过滤掉赠品、临时商品,价格从高到低排序
|
||||||
|
* @param arr 商品列表
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param shopInfo 店铺信息
|
||||||
|
*/
|
||||||
|
export function returnCanDikouGoods(arr, user, shopInfo) {
|
||||||
|
const result = arr
|
||||||
|
.filter((v) => {
|
||||||
|
return v.is_temporary != 1 && v.is_gift != 1;
|
||||||
|
})
|
||||||
|
.filter((v) => {
|
||||||
|
return v.num > 0;
|
||||||
|
})
|
||||||
|
.sort((a, b) => {
|
||||||
|
return returnGoodsPrice(b, user, shopInfo) - returnGoodsPrice(a, user, shopInfo);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -134,7 +134,6 @@ import { onMounted, reactive, ref } from "vue";
|
|||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { useUser } from "@/store/user.js";
|
import { useUser } from "@/store/user.js";
|
||||||
import { Loading } from "element-plus/es/components/loading/src/service";
|
|
||||||
import { usePrint } from "@/store/print.js";
|
import { usePrint } from "@/store/print.js";
|
||||||
import { printerAdd, printerDetail } from "@/api/account.js";
|
import { printerAdd, printerDetail } from "@/api/account.js";
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ import { useRouter, useRoute } from "vue-router";
|
|||||||
import { ElMessage, dayjs } from "element-plus";
|
import { ElMessage, dayjs } from "element-plus";
|
||||||
import { printerAdd, printerDetail } from "@/api/account.js";
|
import { printerAdd, printerDetail } from "@/api/account.js";
|
||||||
import { useUser } from "@/store/user.js";
|
import { useUser } from "@/store/user.js";
|
||||||
import { Loading } from "element-plus/es/components/loading/src/service";
|
|
||||||
import classify from "@/components/classify/index.vue";
|
import classify from "@/components/classify/index.vue";
|
||||||
import QRCode from 'qrcode'
|
import QRCode from 'qrcode'
|
||||||
import { usePrint } from "@/store/print.js";
|
import { usePrint } from "@/store/print.js";
|
||||||
|
|||||||
@@ -378,6 +378,7 @@ function giftPackHandle(key) {
|
|||||||
goodsStore.cartList[goodsStore.cartActiveIndex][key] = 0
|
goodsStore.cartList[goodsStore.cartActiveIndex][key] = 0
|
||||||
}
|
}
|
||||||
goodsStore.operateCart({ ...goodsStore.cartList[goodsStore.cartActiveIndex] }, 'edit')
|
goodsStore.operateCart({ ...goodsStore.cartList[goodsStore.cartActiveIndex] }, 'edit')
|
||||||
|
goodsStore.calcCartInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -540,6 +541,8 @@ function discountFormSubmit() {
|
|||||||
goodsStore.cartList[goodsStore.cartActiveIndex].discount_sale_amount = discountForm.value.discount_sale_amount
|
goodsStore.cartList[goodsStore.cartActiveIndex].discount_sale_amount = discountForm.value.discount_sale_amount
|
||||||
goodsStore.cartList[goodsStore.cartActiveIndex].discount_sale_note = discountForm.value.note
|
goodsStore.cartList[goodsStore.cartActiveIndex].discount_sale_note = discountForm.value.note
|
||||||
showDiscountModal.value = false
|
showDiscountModal.value = false
|
||||||
|
|
||||||
|
goodsStore.calcCartInfo()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="drawer_wrap">
|
<div class="drawer_wrap">
|
||||||
<div class="cart_list">
|
<div class="cart_list">
|
||||||
<div class="nav_wrap card">
|
<div class="nav_wrap card">
|
||||||
<div class="return" @click="dialogVisible = false">
|
<div class="return" @click="returnHandle">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
<ArrowLeftBold />
|
<ArrowLeftBold />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -12,12 +12,20 @@
|
|||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="master_id">
|
<div class="master_id">
|
||||||
<span>{{ goodsStore.orderListInfo.tableCode || store.shopInfo.shopName }}</span>
|
<span>{{ goodsStore.orderListInfo.tableCode || store.shopInfo.shopName }}</span>
|
||||||
<span class="member_info" v-if="goodsStore.vipUserInfo.id">
|
<div class="member_info" v-if="goodsStore.vipUserInfo.id">
|
||||||
会员:{{ formatPhoneNumber(goodsStore.vipUserInfo.phone) }}
|
<span>用户昵称:{{ formatPhoneNumber(goodsStore.vipUserInfo.phone) }}</span>
|
||||||
</span>
|
<span class="vip">白银会员</span>
|
||||||
|
</div>
|
||||||
|
<div class="member_info s" v-if="goodsStore.vipUserInfo.id">当前积分:
|
||||||
|
{{ goodsStore.vipUserInfo.accountPoints }}
|
||||||
|
</div>
|
||||||
|
<div class="member_info s between" v-if="goodsStore.vipUserInfo.id">
|
||||||
|
<span>当前余额:{{ goodsStore.vipUserInfo.amount }}</span>
|
||||||
|
<el-button size="small" @click="userChangeRef.show()">去充值</el-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btm">
|
<div class="btm">
|
||||||
<span class="p">服务员:{{ store.userInfo.name || "暂无" }}</span>
|
<span class="p">服务员:{{ store.userInfo.name || store.shopInfo.shopName }}</span>
|
||||||
<span class="t">{{ dayjs().format("M月D日 HH:mm") }}</span>
|
<span class="t">{{ dayjs().format("M月D日 HH:mm") }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -75,6 +83,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-dialog> -->
|
</el-dialog> -->
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
<user-charge ref="userChangeRef" :userInfo="goodsStore.vipUserInfo" @pay-success="chargeSuccess" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -84,7 +93,7 @@ import { useUser } from "@/store/user.js";
|
|||||||
import payCard from "@/components/payCard/payCard.vue";
|
import payCard from "@/components/payCard/payCard.vue";
|
||||||
import SettleItem from './settleItem.vue'
|
import SettleItem from './settleItem.vue'
|
||||||
import { print } from "@/api/pay";
|
import { print } from "@/api/pay";
|
||||||
import { shopStaffInfo } from '@/api/account.js'
|
import { shopStaffInfo, shopUserDetail } from '@/api/account.js'
|
||||||
import { dayjs, ElMessage } from "element-plus";
|
import { dayjs, ElMessage } from "element-plus";
|
||||||
import { formatPhoneNumber, getOrderByIdAjax, commOrderPrintData } from '@/utils/index.js'
|
import { formatPhoneNumber, getOrderByIdAjax, commOrderPrintData } from '@/utils/index.js'
|
||||||
import useStorage from '@/utils/useStorage.js'
|
import useStorage from '@/utils/useStorage.js'
|
||||||
@@ -93,8 +102,12 @@ import { usePrint } from '@/store/print.js'
|
|||||||
import { useGoods } from '@/store/goods.js'
|
import { useGoods } from '@/store/goods.js'
|
||||||
import { useSocket } from '@/store/socket.js'
|
import { useSocket } from '@/store/socket.js'
|
||||||
import { orderPrint } from '@/api/order.js'
|
import { orderPrint } from '@/api/order.js'
|
||||||
|
import { } from '@/utils/coupon-utils.js'
|
||||||
|
|
||||||
import { staffPermission } from '@/api/user.js'
|
import { staffPermission } from '@/api/user.js'
|
||||||
|
import UserCharge from "@/views/member/components/userCharge.vue";
|
||||||
|
|
||||||
|
const userChangeRef = ref(null);
|
||||||
|
|
||||||
const goodsStore = useGoods()
|
const goodsStore = useGoods()
|
||||||
|
|
||||||
@@ -253,6 +266,34 @@ function show(t) {
|
|||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
payCardRef.value.payCardInit()
|
payCardRef.value.payCardInit()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log('vipUserInfo===', goodsStore.vipUserInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 会员充值成功
|
||||||
|
async function chargeSuccess() {
|
||||||
|
try {
|
||||||
|
const res = await shopUserDetail({
|
||||||
|
id: goodsStore.vipUserInfo.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(res)
|
||||||
|
goodsStore.vipUserInfo = res
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不支付返回清楚所有优惠
|
||||||
|
function returnHandle() {
|
||||||
|
dialogVisible.value = false
|
||||||
|
goodsStore.calcCartInfo({
|
||||||
|
pointsPerYuan: '',
|
||||||
|
maxDeductionAmount: '',
|
||||||
|
userPoints: '',
|
||||||
|
backendCoupons: [],
|
||||||
|
fixedAmount: ''
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
@@ -312,7 +353,7 @@ defineExpose({
|
|||||||
$padding: 10px;
|
$padding: 10px;
|
||||||
|
|
||||||
.master_id {
|
.master_id {
|
||||||
height: 77px;
|
height: 127px;
|
||||||
font-size: calc(var(--el-font-size-base) + 10px);
|
font-size: calc(var(--el-font-size-base) + 10px);
|
||||||
border-bottom: 1px solid #ececec;
|
border-bottom: 1px solid #ececec;
|
||||||
padding: $padding 0;
|
padding: $padding 0;
|
||||||
@@ -321,8 +362,28 @@ defineExpose({
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
.member_info {
|
.member_info {
|
||||||
color: #999;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
&.s {
|
||||||
|
color: #999;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.between {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vip {
|
||||||
|
background-color: #F8F8F8;
|
||||||
|
border-radius: 6px;
|
||||||
|
color: #333;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +406,7 @@ defineExpose({
|
|||||||
|
|
||||||
.list_wrap {
|
.list_wrap {
|
||||||
padding: 0 var(--el-font-size-base);
|
padding: 0 var(--el-font-size-base);
|
||||||
height: calc(100vh - 222px);
|
height: calc(100vh - 270px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,8 +130,8 @@
|
|||||||
<div class="left" v-else></div>
|
<div class="left" v-else></div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
共<el-text>
|
共<el-text>
|
||||||
{{ formatDecimal(goodsStore.cartInfo.total || 0, 2, true) }}件
|
{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsTotal || 0, 2, true) }}件
|
||||||
</el-text>,¥{{ formatDecimal(goodsStore.cartInfo.totalAmount || 0) }}
|
</el-text>,¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount || 0) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="num_wrap_btm">
|
<div class="num_wrap_btm">
|
||||||
@@ -856,6 +856,7 @@ function clearVipUserHandle() {
|
|||||||
|
|
||||||
.t {
|
.t {
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import fastPayCard from "@/components/fastPayCard.vue";
|
|||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
userInfo: {
|
userInfo: {
|
||||||
type: Object,
|
type: [Object,String],
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user