This commit is contained in:
YeMingfei666 2024-11-11 14:04:28 +08:00
commit 22ae339e30
12 changed files with 1207 additions and 182 deletions

View File

@ -471,4 +471,50 @@ export function $activateByOrderId(data) {
...data
}
});
}
//会员积分列表
export function $returnMemberPointsList(data) {
return request({
url: '/api/points/member-points/page',
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}
// 会员积分账户信息
export function $returnMemberPoints(memberId) {
return request({
url: '/api/points/member-points/'+memberId,
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}
//002-获取订单可用积分及抵扣金额(支付页面使用)
export function $calcUsablePoints(data) {
return request({
url: '/api/points/member-points/calc-usable-points',
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}
// 003-根据积分计算可抵扣金额
export function $calcDeDuctionPoints(data) {
return request({
url: '/api/points/member-points/calc-deduction-amount',
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}

View File

@ -364,4 +364,21 @@ text {
.filter-gray {
filter: grayscale(1);
}
.youhui-tips.el-tooltip__popper {
background: #fff;
min-width: 150px;
border-radius: 4px;
border: 1px solid #ebeef5 !important;
padding: 12px;
color: #606266;
line-height: 1.4;
text-align: justify;
font-size: 14px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
word-break: break-all;
}
.youhui-tips.el-tooltip__popper[x-placement^="top"] .popper__arrow:after,
.youhui-tips.el-tooltip__popper[x-placement^="top"] .popper__arrow {
border-top-color: #fff;
}

View File

@ -30,5 +30,9 @@ export const $status= {
cleaning: {
label: "待清台",
type: "#FAAD14",
},
unbind:{
label: "未绑定",
type: "rgb(221,221,221)",
}
}

View File

@ -207,21 +207,24 @@ export default {
filters: {
orderTypeFilter(t) {
if (t) {
return t && orderEnum.orderType.find(item => item.key == t).label;
const item= orderEnum.orderType.find(item => item.key == t);
return t && item?item.label:'';
} else {
return t;
}
},
sendTypeFilter(t) {
if (t) {
return orderEnum.sendType.find(item => item.key == t).label;
const item= orderEnum.sendType.find(item => item.key == t);
return item?item.label:'';
} else {
return t;
}
},
statusFilter(t) {
if (t) {
return t && orderEnum.status.find(item => item.key == t).label;
const item= orderEnum.status.find(item => item.key == t);
return t && item?item.label:'';
} else {
return t;
}

View File

@ -30,9 +30,7 @@
</div>
<div class="" v-if="placeNum == 0">
<div class="note" v-if="item.note">
备注:{{ item.note || "" }}
</div>
<div class="note" v-if="item.note">备注:{{ item.note || "" }}</div>
<div class="note flex" v-else>
<span>备注:</span>
<span class="el-icon-edit u-font-12" @click="editNote"></span>
@ -69,15 +67,22 @@
</div>
<div class="color-333 total-price">
<div v-if="item.isGift === 'true' || item.status == 'return'">0</div>
<div
:class="{
'free-price': item.isGift === 'true' || item.status == 'return',
}"
>
<span v-if="isSeatFee"> {{ item.totalAmount }}</span>
<span v-else> {{ (item.salePrice*item.number+(item.packAmount||0)).toFixed(2) }}</span>
</div>
<template v-if="item.isGift === 'true' || item.status == 'return'">
<div>0</div>
<div class="free-price">
<span v-if="isSeatFee"> {{ item.totalAmount }}</span>
<span v-else> {{ isShowVipPrice ? vipAllPrice : allPrice }}</span>
</div>
</template>
<template v-else>
<div v-if="isSeatFee">{{ item.totalAmount }}</div>
<div v-else>
<div v-if="isShowVipPrice&&vipAllPrice!=allPrice">{{ vipAllPrice }}</div>
<div :class="{ 'free-price': isShowVipPrice&&vipAllPrice!=allPrice }">
<span> {{ allPrice }}</span>
</div>
</div>
</template>
</div>
</div>
</div>
@ -86,6 +91,10 @@
<script>
export default {
props: {
isShowVipPrice: {
type: Boolean,
default: false,
},
//
isSeatFee: {
type: Boolean,
@ -133,6 +142,23 @@ export default {
};
},
computed: {
vipAllPrice() {
const item = this.item;
const price =
this.isShowVipPrice &&
item.memberPrice != null &&
item.memberPrice != undefined
? (item.memberPrice<=0?item.salePrice:item.memberPrice)
: item.salePrice;
return (price * item.number + (item.packAmount || 0)).toFixed(2);
},
allPrice() {
const item = this.item;
const price = item.salePrice;
return (price * item.number + (item.packAmount || 0)).toFixed(2);
},
isActive() {
const isSel =
this.selIndex === this.index && this.placeNum === this.selPlaceNum;

View File

@ -1,5 +1,5 @@
<template>
<el-dialog title="选择用户" width="850px" :visible.sync="show">
<el-dialog title="选择用户" width="850px" :visible.sync="show" top="20px">
<div class="app-container">
<div class="head-container">
<el-form :model="query" inline>
@ -73,7 +73,7 @@
</template>
</el-table-column>
<el-table-column label="余额" prop="amount"></el-table-column>
<el-table-column label="积分" prop="totalScore"></el-table-column>
<el-table-column label="积分" prop="accountPoints"></el-table-column>
<el-table-column label="操作" width="90" fixed="right">
<template v-slot="scope">
@ -99,6 +99,7 @@
<script>
import { queryAllShopUser, queryAllShopInfo } from "@/api/shop";
import { $returnMemberPointsList } from "@/api/table";
import dayjs from "dayjs";
let cacheData = {};
export default {
@ -107,6 +108,7 @@ export default {
show: false,
query: {
name: "",
isVip:1
},
shopInfo: {
balanceTotal: 0,
@ -202,7 +204,6 @@ export default {
this.tableData.page = e - 1;
this.getTableData();
},
//
async getTableData() {
this.tableData.loading = true;
try {

View File

@ -154,7 +154,7 @@ export default {
}
if (curretnMoney > money) {
this.$message.error("实收金额不能大于总金额");
this.form.curretnMoney = form.money;
this.form.curretnMoney = this.form.money;
}
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount =toFixedNoRounding( ((this.form.curretnMoney / money) * 100).toFixed(3) );
@ -173,7 +173,7 @@ export default {
},
open(data) {
console.log(data);
this.form.money = data.amount;
this.form.money = data.amount*1;
this.form.discount = data.discount?toFixedNoRounding(data.discount.toFixed(3)):100;
this.show = true;
this.init();

View File

@ -0,0 +1,450 @@
<template>
<el-dialog
width="700px"
:title="title"
:visible.sync="show"
top="20px"
@close="reset"
>
<div class="u-p-15">
<div class="">
<el-tabs v-model="activeName" @tab-click="tabClick">
<el-tab-pane label="优惠券(单选)" name="youhui">
<el-table
ref="table"
empty-text="无可用优惠券"
:data="quans.fullReductionCoupon"
@cell-click="fullReductionCouponClick"
>
<el-table-column
type="index"
label=""
v-if="quans.fullReductionCoupon.length > 0"
>
<template v-slot="scope">
<el-checkbox
@change="fullReductionCouponClick(scope.row)"
:value="scope.row.id == fullReductionCouponSel.id"
></el-checkbox>
</template>
</el-table-column>
<el-table-column type="index" label="#"> </el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope">
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
</template>
</el-table-column>
<el-table-column prop="discountAmount" label="抵扣">
<template v-slot="scope">
<span class="color-red">
{{ scope.row.discountAmount }}
</span>
</template>
</el-table-column>
<el-table-column prop="discountAmount" label="限制" width="120">
<template v-slot="scope">
<div class="u-flex">
<span>支付满</span>
<span class="color-red no-wrap">
{{ scope.row.fullAmount }}
</span>
<span>元可用</span>
</div>
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="商品券(多选)" name="goods">
<el-table
ref="table1"
@cell-click="productCouponClick"
empty-text="无可用商品券"
:data="quans.productCoupon"
tooltip-effect="dark"
style="width: 100%"
@selection-change="productCouponChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column type="index" width="50" label="#">
</el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="商品信息" width="120">
<template v-slot="scope">
<div class="u-flex">
<div class="u-flex">
<el-image
:src="scope.row.productCover"
fit="cover"
style="width: 40px; height: 40px"
:preview-src-list="[scope.row.productCover]"
></el-image>
</div>
<div class="u-p-l-10">
<div class="">{{ scope.row.productName }}</div>
<div class="">x{{ scope.row.num || "" }}</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column prop="discountAmount" label="抵扣">
<template v-slot="scope">
<span class="color-red">
{{ scope.row.discountAmount }}
</span>
</template>
</el-table-column>
<el-table-column label="券类型">
<template v-slot="scope">
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
<div v-if="quansSelArr.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div>
<el-table empty-text="未选择优惠券" :data="quansSelArr">
<el-table-column type="index" width="50" label="#">
</el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope">
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
</template>
</el-table-column>
<el-table-column label="商品信息">
<template v-slot="scope">
<div class="u-flex" v-if="scope.row.type == 2">
<el-image
:src="scope.row.productCover"
style="width: 40px; height: 40px"
:preview-src-list="[scope.row.productCover]"
></el-image>
<div class="u-m-l-10">{{ scope.row.productName }}</div>
</div>
</template>
</el-table-column>
<el-table-column prop="discountAmount" label="抵扣">
<template v-slot="scope">
<span class="color-red">
{{ scope.row.discountAmount }}
</span>
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
<el-table-column prop="useRestrictions" label="">
<template v-slot="scope">
<el-button type="danger" size="mini" @click="delQuan(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<div class="u-flex u-m-t-20">
<span class="">抵扣</span>
<span class="color-red font-bold">{{ AllCouponPrice }}</span>
</div>
</div>
<div class="u-flex u-row-center u-m-t-50">
<el-button size="medium" @click="close">取消</el-button>
<el-button size="medium" type="primary" @click="confirm"
>确定</el-button
>
</div>
</div>
</div>
</el-dialog>
</template>
<script>
import { $activateByOrderId } from "@/api/table";
import {
returnProductCouponAllPrice,
returnProductCouponPrice,
returnFullReductionCouponAllPrice,
} from "../util";
let $originFullReductionCoupon = [];
export default {
props: {
title: {
type: String,
default: "选择优惠券",
},
goodsArr: {
type: Array,
default: [],
},
vipUser: {
type: Object,
default: () => {
return {
isVip: false,
};
},
},
orderPrice: {
type: Number,
default: 0,
},
},
data() {
return {
propSelCoup: [],
fullReductionCouponSel: {
id: "",
},
quansSelArr: [],
quans: {
fullReductionCoupon: [],
productCoupon: [],
},
currentRow: null,
multipleSelection: null,
fullReductionCouponSelId: "",
activeName: "youhui",
form: {},
show: false,
isSetProductCoup: false,
};
},
watch: {
activeName(newval) {
if (newval == "youhui") {
this.filterFullReductionCoupon();
}
},
},
computed: {
goodsDiscount() {
const coupArr = this.quansSelArr.filter((v) => v.type == 2);
return returnProductCouponAllPrice(coupArr, this.goodsArr, this.vipUser);
},
fullReductionCouponDiscount() {
const coupArr = this.quansSelArr.filter((v) => v.type == 1);
return returnFullReductionCouponAllPrice(coupArr);
},
AllCouponPrice() {
return (
this.goodsDiscount * 1 +
this.fullReductionCouponDiscount * 1
).toFixed(2);
},
},
methods: {
delQuan(row) {
if (row.type == 2) {
const index = this.quansSelArr.findIndex((item) => item.id == row.id);
this.quansSelArr.splice(index, 1);
this.$refs.table1.toggleRowSelection(row, false);
} else {
this.fullReductionCouponSel = { id: "" };
this.quansSelArr.splice(0, 1);
}
if (index != -1) {
const row = this.quansSelArr.find;
}
},
reset() {
this.quansSelArr = [];
this.fullReductionCouponSel = { id: "" };
this.$refs.table1.clearSelection();
},
filterFullReductionCoupon() {
this.quans.fullReductionCoupon = $originFullReductionCoupon.filter(
(v) => this.orderPrice - this.goodsDiscount >= v.fullAmount
);
},
productCouponChange(val) {
if (this.isSetProductCoup) {
return;
}
const firstCoup = this.quansSelArr[0];
const firstIsDikouQuan = firstCoup ? firstCoup.type == 1 : false;
if (firstCoup && firstIsDikouQuan) {
if (
this.orderPrice -
this.fullReductionCouponDiscount -
returnProductCouponAllPrice(val, this.goodsArr, this.vipUser) <
firstCoup.fullAmount
) {
this.$confirm(
"所选优惠券不满足最低抵扣" + firstCoup.fullAmount + "元要求",
"提示",
{
distinguishCancelAndClose: true,
confirmButtonText: "放弃选择商品券",
cancelButtonText: "删除优惠券",
type: "warning",
}
)
.then(() => {
val.map((v) => {
this.$refs.table1.toggleRowSelection(v);
});
})
.catch((action) => {
if (action == "cancel") {
this.quansSelArr.splice(0, 1);
this.fullReductionCouponSel = { id: "" };
this.quansSelArr = [...val];
}
if (action == "close") {
val.map((v) => {
this.$refs.table1.toggleRowSelection(v);
});
}
});
} else {
this.quansSelArr.splice(
val.length <= 0 ? 1 : val.length,
this.quansSelArr.length
);
for (let i in val) {
this.$set(this.quansSelArr, i * 1 + 1, { ...val[i] });
}
}
} else {
this.quansSelArr = [...val];
}
},
fullReductionCouponClick(row) {
if (row.id == this.fullReductionCouponSel.id) {
this.fullReductionCouponSel = { id: "" };
this.quansSelArr.splice(0, 1);
return;
}
const dikouQuan = this.quansSelArr[0];
this.fullReductionCouponSel = row;
if (dikouQuan && dikouQuan.type == 1) {
this.$set(this.quansSelArr, 0, row);
} else {
this.quansSelArr.unshift(row);
}
if(!this.fullReductionCouponSel.id){
return
}
if (
this.orderPrice -
this.fullReductionCouponDiscount -
this.goodsDiscount <
this.fullReductionCouponSel.fullAmount
) {
this.fullReductionCouponSel = { id: "" };
this.quansSelArr.splice(0, 1);
this.$confirm(
"所选优惠券不满足最低抵扣" +
this.fullReductionCouponSel.fullAmount +
"元要求",
"提示",
{
distinguishCancelAndClose: true,
confirmButtonText: "确定",
type: "warning",
}
).then(() => {});
}
},
productCouponClick(row) {
this.$refs.table1.toggleRowSelection(row);
},
handleCurrentChange(val) {
this.currentRow = val;
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
tabClick() {},
init() {},
changeKey(key, val) {
this[key] = val;
},
confirm() {
this.$emit("confirm", [...this.quansSelArr]);
this.close();
},
setSelectCoupon() {
const dikouQuan = this.propSelCoup.find((v) => v.type == 1);
this.fullReductionCouponSel = dikouQuan ? dikouQuan : { id: "" };
const productCouArr = this.propSelCoup.filter((v) => v.type == 2);
this.quans.productCoupon.map((v) => {
for (let i in productCouArr) {
this.isSetProductCoup = true;
if (v.id == productCouArr[i].id) {
this.$refs.table1.toggleRowSelection(v, true);
}
}
});
this.isSetProductCoup = false;
},
async open(data, propSelCoup) {
this.propSelCoup = [...propSelCoup] || [];
console.log(data);
if (data.memberId) {
let quansRes = await $activateByOrderId({
orderId: data.id,
memberId: data.memberId,
});
quansRes.fullReductionCoupon = quansRes.fullReductionCoupon.filter(
(v) => this.orderPrice >= v.fullAmount
);
$originFullReductionCoupon = quansRes.fullReductionCoupon;
this.quans.productCoupon = quansRes.productCoupon
.map((v) => {
return {
...v,
discountAmount: returnProductCouponPrice(
v,
this.goodsArr,
this.vipUser
),
};
})
.filter((v) => v.discountAmount > 0);
// this.quans = quans;
this.filterFullReductionCoupon();
this.quansSelArr = this.propSelCoup;
this.$nextTick(() => {
this.setSelectCoupon();
});
}
this.show = true;
this.init();
},
close() {
this.show = false;
},
},
mounted() {
this.number = `${this.value}`;
},
};
</script>
<style lang="scss" scoped>
.codeImg {
width: 160px;
border: 1px solid rgb(220, 223, 230);
height: 160px;
}
::v-deep .el-input .el-input__inner::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
::v-deep .el-input .el-input__inner::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
</style>

View File

@ -113,6 +113,7 @@ export default {
},
open(item) {
this.goods = item?item:this.goods;
console.log(item)
this.show = true;
if (item != "-999") {
this.number = 1;

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,18 @@
//计算打包费
import {isTui} from '../../order_manage/order_goods_util.js'
//计算打包费
export function returnPackFee(arr, isOld = true) {
if (isOld) {
return arr.reduce((a, b) => {
const bTotal = b.info
.filter((v) => v.isGift !== "true" && v.status !== "return")
.reduce((prve, cur) => {
return prve + (cur.packFee || cur.packAmount||0);
return prve + (cur.packFee || cur.packAmount || 0);
}, 0);
return a + bTotal;
}, 0);
} else {
return arr.filter(v => v.status !== 'return' && v.isGift !== 'true').reduce((a, b) => {
return a + (b.packFee || b.packAmount||0);
return a + (b.packFee || b.packAmount || 0);
}, 0);
}
@ -90,28 +91,108 @@ export function returnGiftArr(arr) {
return result
}
export function formatOrderGoodsList(arr){
export function formatOrderGoodsList(arr) {
const goodsMap = {}
for (let i in arr) {
const goods = arr[i]
if (goods.productName != '客座费') {
if (goodsMap.hasOwnProperty(goods.placeNum)) {
goodsMap[goods.placeNum||1].push(goods)
goodsMap[goods.placeNum || 1].push(goods)
} else {
goodsMap[goods.placeNum||1] = [goods]
goodsMap[goods.placeNum || 1] = [goods]
}
}
}
return Object.entries(goodsMap).map(([key, value]) => ({
info: value,
placeNum: key||1
placeNum: key || 1
}))
}
export function returnIsSeatFee(item){
if(!item){
export function returnIsSeatFee(item) {
if (!item) {
return false
}
return item.productId=="-999"
return item.productId == "-999"?true:false;
}
/**
* 计算购物车会员优惠价格
*/
export function returnVipDiscountPrice() {
}
//计算商品券优惠价格
export function returnProductCouponPrice(coup, goodsArr, vipUser) {
const item = goodsArr.find(v => v.productId == coup.proId);
if(!item){
return 0
}
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
return price
}
//返回新的商品列表,过滤掉退菜的,退单的商品
export function returnNewGoodsList(arr) {
let goodsMap={}
return arr.filter(v => !isTui(v))
}
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
export function returnProductCoupon(coup, goodsArr, vipUser) {
const newGoodsArr = returnNewGoodsList(goodsArr)
const item = newGoodsArr.find(v => v.productId == coup.proId);
if(!item){
return {...coup, discountAmount: 0,use:false}
}
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
const canUse=!v.use?false:(discountAmount>0)
return { ...coup, discountAmount: price,use:canUse}
}
/**
* 根据购物车商品计算商品券抵扣价格以及是否满足可用需求
* 1.商品券对应商品数量大于购物车对应商品数量不可用
* 2.未在购物车找到相关商品不可用
* @param {*} coupArr
* @param {*} goodsArr
* @param {*} vipUser
* @returns
*/
export function returnProductAllCoup(coupArr, goodsArr, vipUser){
return coupArr.map((v) => {
return returnProductCoupon(v, goodsArr, vipUser)
})
}
//计算商品券总优惠价格
export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
if(coupArr.length == 0){
return 0;
}
return coupArr.reduce((a, b) => {
const price = returnProductCouponPrice(b, goodsArr, vipUser)
return a + price;
}, 0).toFixed(2);
}
//计算满减券总优惠价格
export function returnFullReductionCouponAllPrice(coupArr) {
if(coupArr.length == 0){
return 0;
}
return coupArr.filter(v => v.type == 1).reduce((a, b) => {
const price = b.discountAmount
return a + price;
}, 0).toFixed(2);
}
//计算优惠券总价格
export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
const poductAllprice=returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
const pointAllPrice=returnFullReductionCouponAllPrice(coupArr)
return (poductAllprice*1+pointAllPrice*1).toFixed(2);
}