Merge branch 'test' of e.coding.net:g-cphe0354/yinshoukeguanliduan/management into gyq

This commit is contained in:
gyq 2024-11-22 09:34:22 +08:00
commit 796fc49fb1
12 changed files with 248 additions and 62 deletions

View File

@ -3,13 +3,13 @@ ENV = 'production'
# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇Nginx 配置 # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇Nginx 配置
# 接口地址,注意协议,如果你没有配置 ssl需要将 https 改为 http # 接口地址,注意协议,如果你没有配置 ssl需要将 https 改为 http
# 测试 # 测试
VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' # VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn'
# 生产 # 生产
# VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn' # VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn'
# 预发布接口 # 预发布接口
# VUE_APP_BASE_API = 'https://pre-cashieradmin.sxczgkj.cn' VUE_APP_BASE_API = 'https://pre-cashieradmin.sxczgkj.cn'
# VUE_APP_BASE_API = 'http://192.168.2.98:8000' # VUE_APP_BASE_API = 'http://192.168.2.98:8000'
# 如果接口是 http 形式, wss 需要改为 ws # 如果接口是 http 形式, wss 需要改为 ws

View File

@ -15,6 +15,17 @@ export function tbPrintMachine(data, method = "post") {
}); });
} }
// 开票
export function getbinding(data) {
return request({
url: "/api/tbShopInfo/binding",
method: "post",
data: {
shopId: localStorage.getItem("shopId"),
...data
}
});
}
/** /**
* 获取应用中心列表 * 获取应用中心列表
* @returns * @returns

View File

@ -313,6 +313,7 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: block; display: block;
object-fit: cover;
} }
.icon { .icon {
@ -376,6 +377,8 @@ export default {
.title { .title {
font-size: 12px; font-size: 12px;
line-height: 16px;
padding: 6px 0;
} }
.btm { .btm {

View File

@ -11,7 +11,7 @@
<el-radio label="vip">仅会员</el-radio> <el-radio label="vip">仅会员</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="费赠送积分" prop="consumeAmount"> <el-form-item label="费赠送积分" prop="consumeAmount">
<el-input v-model="form.consumeAmount" style="width: 250px;" <el-input v-model="form.consumeAmount" style="width: 250px;"
@input="inputFilterInt($event, 'consumeAmount')"> @input="inputFilterInt($event, 'consumeAmount')">
<template slot="prepend">每消费</template> <template slot="prepend">每消费</template>

View File

@ -2,6 +2,15 @@
<div class="app-container"> <div class="app-container">
<div class="title">应用中心</div> <div class="title">应用中心</div>
<div class="list"> <div class="list">
<div class="item" @click="upPop">
<img src="./kp.png" class="icon">
<div class="info">
<div class="name">开票</div>
<div class="intro">
</div>
</div>
</div>
<div class="item" v-for="item in list" :key="item.id" @click="to(item)"> <div class="item" v-for="item in list" :key="item.id" @click="to(item)">
<img :src="item.coverImg" class="icon"> <img :src="item.coverImg" class="icon">
<div class="info"> <div class="info">
@ -12,21 +21,67 @@
</div> </div>
</div> </div>
</div> </div>
<!-- 弹窗 -->
<el-dialog :title="title" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
<el-form :model="forms">
<el-form-item label="账号:" label-width="60px">
<el-input v-model="forms.account" :disabled="title != '绑定数点票账号'" autocomplete="off"></el-input>
</el-form-item>
<!-- <el-form-item label="密码/验证码" label-width="120px">
<el-input v-model="forms.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="开票项目:" label-width="120px">
<el-input v-model="forms.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="开票类型:" label-width="120px">
<el-input v-model="forms.name" autocomplete="off"></el-input>
</el-form-item> -->
<div style="text-align: right;" v-if="title == '绑定数点票账号'">联系区域经理开通</div>
<div style="text-align: center;" v-else @click="title = '绑定数点票账号'">更换绑定</div>
<!-- <el-form-item label="活动区域" label-width="120px">
<el-select v-model="form.region" placeholder="请选择活动区域">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item> -->
</el-form>
<span slot="footer" class="dialog-footer" v-if="title == '绑定数点票账号'">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="sumbitEvent"> </el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { appCenterGet } from "@/api/application"; import { appCenterGet, getbinding } from "@/api/application";
export default { export default {
data() { data() {
return { return {
list: [] list: [],
dialogVisible: false,
forms: {},
title: '绑定数点票账号',
} }
}, },
mounted() { mounted() {
this.appCenterGet() this.appCenterGet()
this.getbinding()
}, },
methods: { methods: {
upPop() {
this.dialogVisible = true
},
handleClose() {
},
sumbitEvent() {
if (this.forms.account) {
this.dialogVisible = false
this.getbinding(this.forms)
}
},
// //
to(item) { to(item) {
localStorage.setItem('applocation', JSON.stringify(item)) localStorage.setItem('applocation', JSON.stringify(item))
@ -42,7 +97,24 @@ export default {
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
},
//
async getbinding(d = "") {
try {
const res = await getbinding(d)
if (res) {
this.forms = res.store
this.title = '数电票账号已绑定'
} else {
this.title = '绑定数点票账号'
this.forms = {}
} }
} catch (error) {
console.log(error);
}
}
} }
} }
</script> </script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

View File

@ -173,7 +173,7 @@ export default {
async profilepicture(d) { async profilepicture(d) {
this.handleSpeak(d.callNum) this.handleSpeak('请'+d.callNum+'用餐')
let res = await callTablecall({ let res = await callTablecall({
shopId: localStorage.getItem('shopId'), shopId: localStorage.getItem('shopId'),
callQueueId: d.id callQueueId: d.id

View File

@ -3,7 +3,7 @@
<div class="u-p-15"> <div class="u-p-15">
<div class="u-m-t-20"> <div class="u-m-t-20">
<el-form label-width="90px" label-position="left"> <el-form label-width="90px" label-position="left">
<el-form-item label="应付金额"> <el-form-item label="总价">
<div class="color-red u-font-18 font-600">{{ form.money }}</div> <div class="color-red u-font-18 font-600">{{ form.money }}</div>
<!-- <el-input :value="form.money" disabled> </el-input> --> <!-- <el-input :value="form.money" disabled> </el-input> -->
</el-form-item> </el-form-item>

View File

@ -10,6 +10,7 @@
v-for="(item, index) in list" v-for="(item, index) in list"
:key="index" :key="index"
:type="sel === item.payType ? 'primary' : ''" :type="sel === item.payType ? 'primary' : ''"
:disabled="disabledPayType.includes(item.payType)"
> >
{{ item.payName }} {{ item.payName }}
</el-button> </el-button>
@ -30,6 +31,10 @@ export default {
type: [String, Number], type: [String, Number],
default: '', default: '',
}, },
disabledPayType:{
type:Array,
default:()=>[]
}
}, },
data() { data() {
return { return {
@ -38,6 +43,10 @@ export default {
}; };
}, },
watch: { watch: {
disabledPayType(){
const item = this.list.find(v=>!this.disabledPayType.includes(v.payType))
this.sel=item.payType
},
sel(newval) { sel(newval) {
console.log(newval); console.log(newval);
this.$emit("input", newval); this.$emit("input", newval);

View File

@ -16,11 +16,7 @@
:data="quans.fullReductionCoupon" :data="quans.fullReductionCoupon"
@cell-click="fullReductionCouponClick" @cell-click="fullReductionCouponClick"
> >
<el-table-column <el-table-column type="index" label="">
type="index"
label=""
v-if="quans.fullReductionCoupon.length > 0"
>
<template v-slot="scope"> <template v-slot="scope">
<el-checkbox <el-checkbox
@change="fullReductionCouponClick(scope.row)" @change="fullReductionCouponClick(scope.row)"
@ -65,10 +61,7 @@
:data="quans.productCoupon" :data="quans.productCoupon"
style="width: 100%" style="width: 100%"
> >
<el-table-column <el-table-column>
label=""
v-if="quans.fullReductionCoupon.length > 0"
>
<template v-slot="scope"> <template v-slot="scope">
<el-checkbox <el-checkbox
@change="productCouponClick(scope.row)" @change="productCouponClick(scope.row)"
@ -112,11 +105,11 @@
</el-table-column> </el-table-column>
<el-table-column prop="useRestrictions" label="描述"> <el-table-column prop="useRestrictions" label="描述">
</el-table-column> </el-table-column>
<el-table-column prop="useRestrictions" label="是否可用"> <!-- <el-table-column prop="useRestrictions" label="是否可用">
<template v-slot="scope"> <template v-slot="scope">
{{ scope.row.use ? "可以" : "不可用" }} {{ scope.row.use ? "可以" : "不可用" }}
</template> </template>
</el-table-column> </el-table-column> -->
</el-table> </el-table>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@ -232,7 +225,7 @@ export default {
isVip: false, isVip: false,
}; };
}, },
} },
}, },
data() { data() {
return { return {
@ -297,7 +290,7 @@ export default {
$goodsPayPriceMap[row.proId], $goodsPayPriceMap[row.proId],
index, index,
row.num row.num
); ).toFixed(2);
} else { } else {
return 0; return 0;
} }
@ -310,7 +303,8 @@ export default {
const index = this.quansSelArr.findIndex((item) => item.id == row.id); const index = this.quansSelArr.findIndex((item) => item.id == row.id);
if (row.type == 2 && index != -1) { if (row.type == 2 && index != -1) {
this.quansSelArr.splice(index, 1); this.quansSelArr.splice(index, 1);
this.quans.productCoupon[index].checked = false; const proIndex=this.quans.productCoupon.findIndex((v) => v.id == row.id);
this.quans.productCoupon[proIndex].checked = false;
} }
if (row.type == 1 && index != -1) { if (row.type == 1 && index != -1) {
this.fullReductionCouponSel = { id: "" }; this.fullReductionCouponSel = { id: "" };
@ -350,16 +344,44 @@ export default {
if (!item.use) { if (!item.use) {
return; return;
} }
const hasSelNum = this.quansSelArr
.filter((v) => v.type == 2 && v.proId == item.proId)
.reduce((a, b) => {
return a + b.num;
}, 0);
const maxSelNum = $goodsPayPriceMap[item.proId].length;
const coupMaxUseNum = Math.min(item.num, maxSelNum - hasSelNum);
const canUseNum = Math.min(maxSelNum, coupMaxUseNum);
if (this.fullReductionCouponSel.id && !item.checked) { if (this.fullReductionCouponSel.id && !item.checked) {
const goodsQuan = this.quans.productCoupon.filter((v) => v.checked); const goodsQuan = this.quans.productCoupon.filter((v) => v.checked);
const fullReductionCoupon = this.fullReductionCouponSel.id const fullReductionCoupon = this.fullReductionCouponSel.id
? [this.fullReductionCouponSel] ? [this.fullReductionCouponSel]
: []; : [];
let coupArr = [...goodsQuan, item];
let coupArr = [...goodsQuan, { ...item, num: canUseNum }];
const payPrice = const payPrice =
this.orderPrice - this.orderPrice -
returnCouponAllPrice(coupArr, canDikouGoodsArr, this.vipUser); returnCouponAllPrice(coupArr, canDikouGoodsArr, this.vipUser);
console.log(payPrice); console.log(payPrice);
if (payPrice <= 0) {
return this.$confirm(
"选择该商品券后支付金额将为0继续选择将取消选择的满减券",
"提示",
{
confirmButtonText: "继续选择",
cancelButtonText: "取消",
type: "warning",
}
)
.then(() => {
this.fullReductionCouponSel = {
id: "",
};
this.quansSelArr.splice(0, 1);
})
.catch(() => {});
}
if (this.fullReductionCouponSel.fullAmount > payPrice) { if (this.fullReductionCouponSel.fullAmount > payPrice) {
this.$confirm( this.$confirm(
"选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券", "选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券",
@ -379,13 +401,19 @@ export default {
} }
} }
item.checked = !item.checked; item.checked = !item.checked;
if (!item.checked) {
console.log(index);
const index = this.quansSelArr.findIndex((v) => v.id == item.id);
this.quansSelArr.splice(index, 1);
} else {
this.quansSelArr.push({ ...item, num: canUseNum });
}
const CheckedArr = this.quans.productCoupon.filter((v) => v.checked); const CheckedArr = this.quans.productCoupon.filter((v) => v.checked);
this.quansSelArr = [ if (CheckedArr.length <= 0) {
...(this.fullReductionCouponSel.id return this.quans.productCoupon.map((v) => {
? [this.fullReductionCouponSel] v.use = true;
: []), });
...CheckedArr, }
];
const noCheckedArr = this.quans.productCoupon.filter((v) => !v.checked); const noCheckedArr = this.quans.productCoupon.filter((v) => !v.checked);
noCheckedArr.map((v) => { noCheckedArr.map((v) => {
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr); v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr);
@ -405,7 +433,7 @@ export default {
}, },
confirm() { confirm() {
this.$emit("confirm", [...this.quansSelArr]); this.$emit("confirm", [...this.quansSelArr], $goodsPayPriceMap);
this.close(); this.close();
}, },
async open(data, propSelCoup) { async open(data, propSelCoup) {
@ -419,7 +447,7 @@ export default {
memberId: data.memberId, memberId: data.memberId,
}); });
quansRes.fullReductionCoupon = quansRes.fullReductionCoupon.filter( quansRes.fullReductionCoupon = quansRes.fullReductionCoupon.filter(
(v) => v.use && this.orderPrice * 1 >= v.fullAmount * 1 (v) =>this.orderPrice<=0?false:(v.use && this.orderPrice * 1 >= v.fullAmount * 1)
); );
const selFullReductionCoupon = this.quansSelArr.find( const selFullReductionCoupon = this.quansSelArr.find(
(v) => v.type == 1 (v) => v.type == 1
@ -442,6 +470,7 @@ export default {
checked: this.quansSelArr.find((selCoup) => selCoup.id == v.id) checked: this.quansSelArr.find((selCoup) => selCoup.id == v.id)
? true ? true
: false, : false,
use:this.orderPrice<=0?false:calcCoup.use
}; };
}) })
.filter((v) => v.use); .filter((v) => v.use);

View File

@ -964,7 +964,7 @@
</el-table-column> </el-table-column>
<el-table-column label="商品信息" width="120"> <el-table-column label="商品信息" width="120">
<template v-slot="scope"> <template v-slot="scope">
<div class="u-flex"> <div class="u-flex" v-if="scope.row.type == 2">
<div class="u-flex"> <div class="u-flex">
<el-image <el-image
:src="scope.row.productCover" :src="scope.row.productCover"
@ -982,9 +982,14 @@
</el-table-column> </el-table-column>
<el-table-column prop="discountAmount" label="抵扣"> <el-table-column prop="discountAmount" label="抵扣">
<template v-slot="scope"> <template v-slot="scope">
<span class="color-red"> <span class="color-red" v-if="scope.row.type == 1">
{{ scope.row.discountAmount }} {{ scope.row.discountAmount }}
</span> </span>
<span class="color-red" v-if="scope.row.type == 2">
{{
returnProDiscount(scope.row, scope.row.index)
}}
</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="useRestrictions" label=""> <el-table-column prop="useRestrictions" label="">
@ -1011,6 +1016,7 @@
ref="refPayType" ref="refPayType"
v-model="order.payType" v-model="order.payType"
@itemClick="payTypeItemClick" @itemClick="payTypeItemClick"
:disabledPayType="disabledPayType"
> >
</pay-type> </pay-type>
<div style="margin-top: 20px"> <div style="margin-top: 20px">
@ -1094,13 +1100,7 @@
</div> </div>
<div class="detail_form_item"> <div class="detail_form_item">
<div class="left">应付金额</div> <div class="left">应付金额</div>
<div class="right redfont"> <div class="right redfont">{{ yinFuJinE }}</div>
{{
currentPayMoney - points.toMoney <= 0
? 0
: (currentPayMoney - points.toMoney) | to2
}}
</div>
</div> </div>
<div class="line"></div> <div class="line"></div>
</div> </div>
@ -1481,6 +1481,9 @@ import {
returnVipDiscountPrice, returnVipDiscountPrice,
returnCouponAllPrice, returnCouponAllPrice,
} from "./util.js"; } from "./util.js";
import { returnProductCoupAllPrice } from "./quan_util.js";
//0n
let $goodsPayPriceMap = {};
import { $status } from "@/utils/table.js"; import { $status } from "@/utils/table.js";
let $originTableList = []; let $originTableList = [];
@ -1501,6 +1504,7 @@ export default {
}, },
data() { data() {
return { return {
disabledPayType: [],
// //
points: { points: {
res: { res: {
@ -1609,6 +1613,7 @@ export default {
total: 0, total: 0,
}, },
order: { order: {
status: "",
packFee: { packFee: {
totalNumber: 0, totalNumber: 0,
status: "", status: "",
@ -1715,7 +1720,7 @@ export default {
computed: { computed: {
isShowVipPrice() { isShowVipPrice() {
if (!this.shopInfo.isMemberPrice) { if (!this.shopInfo.isMemberPrice) {
return false return false;
} }
return this.vipUser.isVip ? true : false; return this.vipUser.isVip ? true : false;
}, },
@ -1752,11 +1757,12 @@ export default {
const amount = this.createOrder.data.amount || 0; const amount = this.createOrder.data.amount || 0;
const discount = this.createOrder.discount || 1; const discount = this.createOrder.discount || 1;
// const total=((amount - this.coupdiscount) * this.createOrder.discount - this.points.toMoney) // const total=((amount - this.coupdiscount) * this.createOrder.discount - this.points.toMoney)
const total = (amount - this.coupdiscount) * this.createOrder.discount; const total = (amount) * this.createOrder.discount - this.coupdiscount;
return total <= 0 ? 0 : total; return total <= 0 ? 0 : total;
}, },
yinFuJinE() { yinFuJinE() {
const total = this.currentPayMoney - (this.points.toMoney || 0); const total = this.currentPayMoney - (this.points.toMoney || 0);
console.log(total)
if (this.isCreateOrder) { if (this.isCreateOrder) {
return total.toFixed(2); return total.toFixed(2);
} else { } else {
@ -1971,6 +1977,13 @@ export default {
}, },
}, },
watch: { watch: {
yinFuJinE: function (newval) {
if (newval <= 0) {
this.disabledPayType = ["scanCode", "deposit"];
} else {
this.disabledPayType = [];
}
},
"goods.query.categoryId": function (newval) { "goods.query.categoryId": function (newval) {
this.goods.query.page = 1; this.goods.query.page = 1;
this.goods.list = []; this.goods.list = [];
@ -2038,8 +2051,8 @@ export default {
// this.masterId = masterId; // this.masterId = masterId;
console.log("this.createOrder.data"); console.log("this.createOrder.data");
console.log(this.createOrder.data); console.log(this.createOrder.data);
if(this.createOrder.data.memberId==val){ if (this.order.status == "finish") {
return return;
} }
$setUser({ $setUser({
tableId: this.table.tableId, tableId: this.table.tableId,
@ -2053,6 +2066,8 @@ export default {
this.getOrderData().then(() => { this.getOrderData().then(() => {
this.pointsValueChange(this.points.value); this.pointsValueChange(this.points.value);
}); });
} else {
this.getCart();
} }
}); });
}, },
@ -2171,6 +2186,21 @@ export default {
this.open(this.$route.query); this.open(this.$route.query);
}, },
methods: { methods: {
returnProDiscount(row) {
console.log(row);
//
const arr = this.quansSelArr.filter((v) => v.proId == row.proId);
const index = arr.findIndex((v) => v.id == row.id);
if (index != -1) {
return returnProductCoupAllPrice(
$goodsPayPriceMap[row.proId],
index,
row.num
).toFixed(2);
} else {
return 0;
}
},
lingshicaiShow() { lingshicaiShow() {
this.$refs.refPopAddCai.open(); this.$refs.refPopAddCai.open();
}, },
@ -2231,14 +2261,15 @@ export default {
{ {
id: this.createOrder.data.id, id: this.createOrder.data.id,
memberId: this.createOrder.data.memberId || this.vipUser.id, memberId: this.createOrder.data.memberId || this.vipUser.id,
orderPrice:(this.yinFuJinE*1+this.coupdiscount*1).toFixed(2) orderPrice: (this.yinFuJinE * 1 + this.coupdiscount * 1).toFixed(2),
}, },
[...this.quansSelArr] [...this.quansSelArr]
); );
}, },
quansConfirm(e) { quansConfirm(e, goodsPayPriceMap) {
console.log(e); console.log(e);
this.quansSelArr = [...e]; this.quansSelArr = [...e];
$goodsPayPriceMap = goodsPayPriceMap;
}, },
searchInput(e) { searchInput(e) {
console.log(e); console.log(e);
@ -2646,7 +2677,7 @@ export default {
if (!canDiscount) { if (!canDiscount) {
return; return;
} }
const amount = this.createOrder.data.amount - this.coupdiscount; const amount = this.createOrder.data.amount;
this.refToggle("refDiscount", true, { this.refToggle("refDiscount", true, {
amount, amount,
discount: this.createOrder.discount * 100, discount: this.createOrder.discount * 100,
@ -2834,6 +2865,7 @@ export default {
title: "支付成功", title: "支付成功",
type: "success", type: "success",
}); });
this.order.status = "finish";
this.close(); this.close();
// this.reset(); // this.reset();
}, },
@ -3065,11 +3097,14 @@ export default {
} }
if (key === "returnCart") { if (key === "returnCart") {
console.log(this.order); console.log(this.order);
let selGoods=undefined let selGoods = undefined;
if (this.order.selPlaceNum == -10) { if (this.order.selPlaceNum == -10) {
selGoods = {...this.order.seatFee,num:this.order.seatFee.number} selGoods = { ...this.order.seatFee, num: this.order.seatFee.number };
} else { } else {
selGoods = this.order.old.list[this.order.selPlaceNum-1].info[this.order.old.selIndex]; selGoods =
this.order.old.list[this.order.selPlaceNum - 1].info[
this.order.old.selIndex
];
} }
console.log(selGoods); console.log(selGoods);
this.refToggle("refReturnCart", true, selGoods); this.refToggle("refReturnCart", true, selGoods);
@ -3538,6 +3573,7 @@ export default {
}, },
reset() { reset() {
// this.goods.list = []; // this.goods.list = [];
this.order.status = "";
this.loading = false; this.loading = false;
this.table = ""; this.table = "";
this.order.list = []; this.order.list = [];
@ -3911,7 +3947,6 @@ export default {
this.$router.replace({ path: "/tool/table_list" }); this.$router.replace({ path: "/tool/table_list" });
} else { } else {
this.$router.replace({ path: "/tool/Instead/index" }); this.$router.replace({ path: "/tool/Instead/index" });
this.$router.go(0);
// this.reset(); // this.reset();
// this.$router.replace({ path: "/tool/Instead/index" }); // this.$router.replace({ path: "/tool/Instead/index" });
} }

View File

@ -2,7 +2,7 @@ export function isTui(item) {
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding' return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
} }
//是否使用会员价 //是否使用会员价
export function isUseMemberPrice(vipUser,goods){ export function isUseVipPrice(vipUser,goods){
return vipUser.id&&vipUser.isVip&&goods.isMember return vipUser.id&&vipUser.isVip&&goods.isMember
} }
@ -13,7 +13,7 @@ export function returnProductCouponPrice(coup, goodsArr, vipUser) {
return 0 return 0
} }
const memberPrice = item.memberPrice ? item.memberPrice : item.price; const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item ? (isUseMemberPrice(vipUser,item) ? memberPrice : item.price) : 0; const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
return price * coup.num return price * coup.num
} }
@ -40,7 +40,8 @@ export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
if (selCoupNumber >= findGoodsTotalNumber) { if (selCoupNumber >= findGoodsTotalNumber) {
return false return false
} }
return findGoodsTotalNumber < (coup.num + selCoupNumber) ? false : true console.log(selCoupNumber,findGoodsTotalNumber);
return findGoodsTotalNumber < selCoupNumber ? false : true
} }
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求) //查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) { export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
@ -54,12 +55,13 @@ export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
} }
} }
const memberPrice = item.memberPrice ? item.memberPrice : item.price; const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item ? (isUseMemberPrice(vipUser,item) ? memberPrice : item.price) : 0; const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
const discountAmount = (price * coup.num).toFixed(2) const discountAmount = (price * coup.num).toFixed(2)
console.log(discountAmount); console.log(discountAmount);
const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr)) // const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
// const canUse=discountAmount>0 // const canUse=discountAmount>0
const canUse=coup.use
return { return {
...coup, ...coup,
discountAmount: discountAmount, discountAmount: discountAmount,
@ -85,7 +87,7 @@ export function returnProductAllCoup(coupArr, goodsArr, vipUser) {
//返回商品实际支付价格 //返回商品实际支付价格
export function returnProductPayPrice(goods,vipUser){ export function returnProductPayPrice(goods,vipUser){
const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price; const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
const price = isUseMemberPrice(vipUser,goods) ? memberPrice : goods.price; const price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.price;
return price return price
} }
//返回商品券抵扣的商品价格 //返回商品券抵扣的商品价格
@ -100,6 +102,23 @@ export function returnProductCoupAllPrice(productPriceArr,startIndex,num){
return prve+curPrice return prve+curPrice
},0) },0)
} }
//返回商品券可抵扣的商品数量
export function returnProductCanUseNum(productPriceArr,startIndex,num){
console.log(productPriceArr);
console.log(num);
let n=0;
for(let i=0;i<num;i++){
if(productPriceArr[startIndex*1+i]){
n+=1
console.log(n);
}else{
break
}
}
return n
}
//返回同类商品券在同类商品价格数组里的开始位置 //返回同类商品券在同类商品价格数组里的开始位置
export function returnProCoupStartIndex(coupArr,index){ export function returnProCoupStartIndex(coupArr,index){
return coupArr.slice(0,index).reduce((prve,cur)=>{ return coupArr.slice(0,index).reduce((prve,cur)=>{
@ -166,7 +185,9 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
} }
const proCoupStartIndex=returnProCoupStartIndex(arr,i) const proCoupStartIndex=returnProCoupStartIndex(arr,i)
console.log(proCoupStartIndex); console.log(proCoupStartIndex);
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coup.num) const coupNum=Math.min(goodsPayPriceMap[coup.proId].length,coup.num)
console.log(coupNum);
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
} }
} }
@ -198,6 +219,12 @@ export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
return v return v
} }
const isfullAmount = payPrice >= v.fullAmount * 1 const isfullAmount = payPrice >= v.fullAmount * 1
if(payPrice<=0){
return {
...v,
use: false
}
}
return { return {
...v, ...v,
use: v.use && isfullAmount use: v.use && isfullAmount