diff --git a/commons/utils/goodsUtil.js b/commons/utils/goodsUtil.js
index b0e821d..9ff70de 100644
--- a/commons/utils/goodsUtil.js
+++ b/commons/utils/goodsUtil.js
@@ -2,7 +2,7 @@ export function canComputedPackFee(v) {
return v.pack && v.status != 'return' && v.status != 'refund' && v.status != 'refunding'
}
export function returnCanComputedGoodsArr(arr) {
- return arr.filter(v=>canComputedPackFee(v))
+ return arr.filter(v => canComputedPackFee(v))
}
export function returnPackFee(arr) {
return arr.reduce((prve, cur) => {
@@ -10,18 +10,28 @@ export function returnPackFee(arr) {
}, 0).toFixed(2)
}
-export function canTuicai(orderInfo,item){
- return orderInfo.status=='unpaid'&&orderInfo.useType!='dine-in-before'&& item.status!='return'
+export function canTuicai(orderInfo, item) {
+ if (orderInfo.status == 'unpaid' && orderInfo.isPostpaid !== null && orderInfo.isPostpaid == 0) {
+ return false
+ }
+ return orderInfo.status == 'unpaid' && orderInfo.useType != 'dine-in-before' && item.status != 'return'
}
-export function canTuiKuan(orderInfo,item){
- return orderInfo.status!='unpaid'&& item.status!='return'&&item.status!='refund'&&item.status!='refunding'
+export function canTuiKuan(orderInfo, item) {
+ return orderInfo.status == 'closed' && item.status != 'return' && item.status != 'refund' && item.status !=
+ 'refunding'
}
-export function isTui(item){
- return item.status=='return'||item.status=='refund'||item.status=='refunding'
+export function isTuiCai(item) {
+ return item.status == 'return'
}
-export function numSum(arr){
- const sum=arr.reduce((a,b)=>{
- return a+b*100
- },0)
- return (sum/100).toFixed(2)
+export function isTui(item) {
+ return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
+}
+export function isGift(item) {
+ return !isTui(item) && item.gift
+}
+export function numSum(arr) {
+ const sum = arr.reduce((a, b) => {
+ return a + b * 100
+ }, 0)
+ return (sum / 100).toFixed(2)
}
\ No newline at end of file
diff --git a/commons/utils/safe-bottom.js b/commons/utils/safe-bottom.js
index c8ed07d..9cfddc1 100644
--- a/commons/utils/safe-bottom.js
+++ b/commons/utils/safe-bottom.js
@@ -1,23 +1,32 @@
import {
getCurrentInstance,
} from 'vue';
-export function getElRect(elClass, dataVal) {
- const instance = getCurrentInstance();
- return new Promise((resolve, reject) => {
- const query = uni.createSelectorQuery().in(instance.proxy);
+export async function getElRect(elClass, instance,option) {
+ instance = instance ? instance : getCurrentInstance();
+ const query = uni.createSelectorQuery().in(instance.proxy);
+ try{
+ const res= await getEle(query,elClass,option)
+ return res
+ }catch(e){
+ console.log(e);
+ }
+}
+async function getEle(query,elClass,option){
+ return new Promise((resolve, reject)=>{
query.select('.' + elClass).fields({
- size: true
+ size: true,
+ ...option
}, res => {
// 如果节点尚未生成,res值为null,循环调用执行
if (!res) {
- setTimeout(() => {
- getElRect(elClass);
+ return setTimeout(() => {
+ getEle(query,elClass,option);
}, 10);
- return;
}
resolve(res);
}).exec();
})
+
}
export async function getSafeBottomHeight(className, height = 16) {
diff --git a/components/my-components/edit-discount.vue b/components/my-components/edit-discount.vue
index dfabe73..2e2c5ac 100644
--- a/components/my-components/edit-discount.vue
+++ b/components/my-components/edit-discount.vue
@@ -69,10 +69,14 @@
price: {
type: [Number,String],
default: 0
+ },
+ nowPrice:{
+ type: [Number,String],
+ default: 0
}
})
function currentPriceInput(newval){
- form.discount=(newval*100/form.price).toFixed()
+ form.discount=(newval*100/form.price)
}
function discountInput(newval){
form.currentPrice=(form.price*newval/100).toFixed(2)
@@ -126,8 +130,8 @@
function open() {
model.value.open()
form.price=props.price
- form.currentPrice=props.price
form.discount=props.discount
+ form.currentPrice=(props.discount*props.price/100).toFixed(2)
}
function close() {
diff --git a/components/my-components/my-date-pickerview.vue b/components/my-components/my-date-pickerview.vue
index 7507b74..0ea73ad 100644
--- a/components/my-components/my-date-pickerview.vue
+++ b/components/my-components/my-date-pickerview.vue
@@ -389,9 +389,10 @@
const year = years[arr[0]]
const month = arr[1] + 1
const day = arr[2] + 1
- const hour = ('0' + arr[3]).slice(-2)
- const min = ('0' + arr[4]).slice(-2)
- const sen = ('0' + arr[5]).slice(-2)
+ const hour = ('0' + (arr[3]||0)).slice(-2)
+ console.log(hour)
+ const min = ('0' + (arr[4]||0)).slice(-2)
+ const sen = ('0' + (arr[5]||0)).slice(-2)
if (isObj) {
return new Date(year, month, day, hour, min, sen)
}
@@ -400,6 +401,7 @@
function confirm(e) {
+ console.log(value.value);
const start = returnDateString(value.value)
console.log(start);
const end = returnDateString(value1.value)
@@ -487,7 +489,9 @@
const endTotal = returnDateString(e.detail.value, true).getTime()
value1.value = e.detail.value
nextTick(() => {
- value1.value = endTotal < startTotal ? value.value : e.detail.value
+ if (props.isArea) {
+ value1.value = endTotal < startTotal ? value.value : e.detail.value
+ }
debounce(changeDays(true, value1.value), 100)
})
}
@@ -521,7 +525,7 @@
}
function nullFunction() {
-
+
}
function pickend(e) {
diff --git a/http/yskApi/Instead.js b/http/yskApi/Instead.js
index 3221307..d964201 100644
--- a/http/yskApi/Instead.js
+++ b/http/yskApi/Instead.js
@@ -331,4 +331,62 @@ export function $returnOrder(data) {
...data
}
});
+}
+
+//获取订单可用优惠券
+export function $activateByOrderId(data) {
+ return request({
+ url: '/api/tbShopCoupon/activateByOrderId',
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
+}
+
+//会员积分列表
+export function $returnMemberPointsList(data) {
+ return request({
+ url: '/api/points/member-points/page',
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
+}
+
+// 会员积分账户信息
+export function $returnMemberPoints(memberId) {
+ return request({
+ url: '/api/points/member-points/'+memberId,
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
+}
+//002-获取订单可用积分及抵扣金额(支付页面使用)
+export function $calcUsablePoints(data) {
+ return request({
+ url: '/api/points/member-points/calc-usable-points',
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
+}
+// 003-根据积分计算可抵扣金额
+export function $calcDeDuctionPoints(data) {
+ return request({
+ url: '/api/points/member-points/calc-deduction-amount',
+ method: "get",
+ params:{
+ shopId: uni.getStorageSync("shopId"),
+ ...data
+ }
+ });
}
\ No newline at end of file
diff --git a/http/yskApi/http.js b/http/yskApi/http.js
index 67aef22..9f39d97 100644
--- a/http/yskApi/http.js
+++ b/http/yskApi/http.js
@@ -17,13 +17,13 @@ import infoBox from "@/commons/utils/infoBox.js"
import go from '@/commons/utils/go.js';
import { reject } from 'lodash';
// 测试服
-let baseUrl = 'https://admintestpapi.sxczgkj.cn'
+// let baseUrl = 'https://admintestpapi.sxczgkj.cn'
//预发布
// let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
//正式
-// let baseUrl = 'https://cashieradmin.sxczgkj.cn'
+let baseUrl = 'https://cashieradmin.sxczgkj.cn'
// 王伟本地测
// let baseUrl = '/ww'
diff --git a/pageBwc/index/index.vue b/pageBwc/index/index.vue
index c91d0e9..98d3c26 100644
--- a/pageBwc/index/index.vue
+++ b/pageBwc/index/index.vue
@@ -1,23 +1,23 @@
+ style="border-radius: 18px 18px 0 0;padding:32rpx 24rpx;border-bottom: 2rpx solid #E5E5E5;">
充值设置
- 用户消费结账时,成功充值成功
-
+ 用户消费结账时,成功充值
+
倍的金额本单即可享受免单
-
+
充值门槛
订单支付金额需满
-
+
元,才能使用
@@ -28,11 +28,11 @@
+ style="margin-top:24rpx; padding:32rpx 24rpx; border-radius: 0 0 18px 18px;">
充值说明
-
+
@@ -71,7 +71,7 @@
useTypeList: [],
childShopIdList: '',
});
-
+
const getlist = async () => {
let res = await get()
console.log(res)
@@ -83,9 +83,9 @@
title: '保存成功'
})
Object.assign(form, res)
- setTimeout(()=>{
+ setTimeout(() => {
uni.navigateBack()
- },1500)
+ }, 1500)
}
onShow(() => {
getlist()
@@ -113,21 +113,22 @@
}
.boxconstantbox_tow {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- flex-wrap: wrap;
- padding-bottom: 24rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 28rpx;
color: #333333;
- box-sizing: border-box;
-
+ // display: flex;
+ // justify-content: flex-start;
+ // align-items: center;
+ // flex-wrap: wrap;
+ // align-content: flex-start;
.text {
+ display:inline-flex;
+ text-align: center;
margin: 0 12rpx;
width: 118rpx;
height: 48rpx;
+ line-height: 48rpx;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #E5E5E5;
diff --git a/pageConsumables/components/my-date-pickerview.vue b/pageConsumables/components/my-date-pickerview.vue
index df67817..f634983 100644
--- a/pageConsumables/components/my-date-pickerview.vue
+++ b/pageConsumables/components/my-date-pickerview.vue
@@ -24,7 +24,7 @@
{{item}}日
-
+
至
{{item}}日
-
+
diff --git a/pageConsumables/editConsumables.vue b/pageConsumables/editConsumables.vue
index 759bda4..e548a7b 100644
--- a/pageConsumables/editConsumables.vue
+++ b/pageConsumables/editConsumables.vue
@@ -25,7 +25,7 @@
耗材价格
-
+
@@ -33,7 +33,7 @@
预警值
-
+
+
+
应付金额
@@ -117,6 +129,7 @@
list: [],
// 供应商渲染数组
status: [],
+ unitList:[],
form: {
shopId: uni.getStorageSync("shopId"),
type: "out",
@@ -135,6 +148,10 @@
})
onMounted(() => {
datas.item = JSON.parse(props.item)
+ datas.form = Object.assign(datas.form, datas.item)
+ // 单位列表
+ datas.unitList = [ datas.form.conUnit,datas.form.conUnitTwo]
+ datas.form.list.unit=datas.form.defaultUnit
})
onShow(() => {
getList()
@@ -165,7 +182,9 @@ onShow(() => {
nowStatusIndex.value = i.detail.value
showStatus.value = false
}
-
+ function changeNowStatusIndexs(i) {
+ datas.form.list.unit = datas.unitList[i.detail.value]
+ }
function sumbit() {
if (!datas.form.list.stockNumber) {
diff --git a/pageConsumables/time.png b/pageConsumables/time.png
new file mode 100644
index 0000000..0f07e71
Binary files /dev/null and b/pageConsumables/time.png differ
diff --git a/pageConsumables/viewrecords.vue b/pageConsumables/viewrecords.vue
index 1c52869..f8f0883 100644
--- a/pageConsumables/viewrecords.vue
+++ b/pageConsumables/viewrecords.vue
@@ -1,5 +1,5 @@
-
+
+
+
-
*单价
@@ -42,6 +33,18 @@
+
+
+ 单位
+
+
+
+ {{datas.form.list.unit}}
+
+
+
+
+
应付金额
@@ -71,14 +74,13 @@
供应商
- {{datas.status[nowStatusIndex]}}
+ {{datas.status[nowStatusIndex]}}
+
新增
-
@@ -120,6 +122,8 @@
list: [],
// 供应商渲染数组
status: [],
+ // 单位列表
+ unitList: [],
form: {
shopId: uni.getStorageSync("shopId"),
type: "in",
@@ -138,7 +142,10 @@
})
onMounted(() => {
datas.item = JSON.parse(props.item)
- datas.form = assign(datas.form, ...datas.item)
+ datas.form = Object.assign(datas.form, datas.item)
+ // 单位列表
+ datas.unitList = [ datas.form.conUnit,datas.form.conUnitTwo]
+ datas.form.list.unit=datas.form.defaultUnit
})
onShow(() => {
getList()
@@ -159,7 +166,6 @@
res.content.forEach(ele => {
datas.status.push(ele.purveyorName)
})
- console.log(datas.status, '调试121')
})
}
@@ -173,6 +179,10 @@
showStatus.value = false
}
+ function changeNowStatusIndexs(i) {
+ datas.form.list.unit = datas.unitList[i.detail.value]
+ }
+
function sumbit() {
if (!datas.form.list.stockNumber) {
refs.ctx.$refs.uToastRef.show({
diff --git a/pageCoupon/discountCoupons.vue b/pageCoupon/discountCoupons.vue
index a382ff5..f596c45 100644
--- a/pageCoupon/discountCoupons.vue
+++ b/pageCoupon/discountCoupons.vue
@@ -8,9 +8,9 @@
- 使用门槛
+ 使用门槛2
- 满元,减元
+ 满元,减元
@@ -35,13 +35,15 @@
有效期(天)
-
+
- 隔天生效
+ 隔天生效
+
+
- 隔天生效
+ 隔天生效
@@ -79,7 +81,7 @@
总发放数量
-
+
@@ -311,6 +313,7 @@
height: 150rpx;
width: 100%;
background-color: #fff;
+ z-index: 9;
>button {
width: 530rpx;
margin: 30rpx 0;
diff --git a/pageCoupon/editCertificate.vue b/pageCoupon/editCertificate.vue
index aa2048b..132cfb6 100644
--- a/pageCoupon/editCertificate.vue
+++ b/pageCoupon/editCertificate.vue
@@ -10,13 +10,13 @@
使用门槛
- 满元,可用
+ 满元,可用
总发放数量
-
+
diff --git a/pageCoupon/index.vue b/pageCoupon/index.vue
index 0a326e7..71d7501 100644
--- a/pageCoupon/index.vue
+++ b/pageCoupon/index.vue
@@ -36,10 +36,10 @@
满 {{ item.fullAmount }} 元减 {{ item.discountAmount }} 元
满 {{ item.fullAmount }} 元可用
-
+
有效期
领券后{{ item.validDays }}天过期
@@ -197,7 +197,7 @@
padding: 32rpx 28rpx;
background-color: #fff;
position: fixed;
- top: 79rpx;
+ top: 0rpx;
z-index: 999;
.tag-item {
display: inline-block;
@@ -253,7 +253,7 @@
/* height: 544rpx; */
margin: 32rpx auto 0;
margin-bottom: 32rpx;
- padding: 122rpx 28rpx 182rpx 28rpx;
+ padding: 70rpx 28rpx 182rpx 28rpx;
}
.couponContent {
/* background-color: #f9f9f9; */
diff --git a/pageLineUp/index.vue b/pageLineUp/index.vue
index f76e29e..d3d6788 100644
--- a/pageLineUp/index.vue
+++ b/pageLineUp/index.vue
@@ -265,22 +265,31 @@
}
.pageLineUpTop {
- .df;
- justify-content: space-around;
+ display: flex;
+ // justify-content: space-around;
+ flex-wrap: wrap;
margin: 36rpx 0;
+
>view {
width: 208rpx;
height: 136rpx;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #E5E5E5;
+ margin-top: 20rpx;
+ margin-left: 22rpx;
>view {
text-align: center;
}
}
+ // >view:last-child {
+ // margin-right: auto;
+ // margin-left: 22rpx;
+ // }
+
.active {
border: 2rpx solid #318AFE;
diff --git a/pageProduct/add-Product/add-Product - 副本.vue b/pageProduct/add-Product/add-Product - 副本.vue
index f9ec7b6..e08499a 100644
--- a/pageProduct/add-Product/add-Product - 副本.vue
+++ b/pageProduct/add-Product/add-Product - 副本.vue
@@ -1,189 +1,845 @@
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{category.list[FormData.category]||'分类'}}
-
-
-
-
-
-
-
-
-
- {{FormData.specificationsGroup||'添加规格组'}}
-
-
-
-
-
-
-
-
-
-
- {{salesMethod.list[FormData.salesMethod]||'售卖方式'}}
-
-
-
-
-
-
- 库存
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
- 打折设置
-
-
+
+
+
+
+ 注:第一张图为商品封面图,图片尺寸为750x750
-
-
-
-
+
+
-
-
-
- 不参与会员折扣
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
- 每日销量上限
-
+
-
-
-
-
- 每单限购
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 设为推荐
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 名称
+ 操作
+
+
+
+
+ {{item.name}}
+
+
+
+
+
+
+
+
+
+ 添加团购券分类
+
+
+
+
+
+
+
+
+
+
+
+
+ 选择规格
+ 编辑规格
+
+
+
+ {{FormData.specsInfoName}}
+ 请选择
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 套餐商品
+
+
+
+
+
+
+
+ 商品信息
+
+
+ 名称
+ 数量
+ 操作
+
+
+
+
+ {{product.name}}
+
+
+
+
+ x1
+
+
+
+
+
+
+
+
+ 添加商品
+
+
+
+
+
+
+
+
+
+
+ 删除分组
+
+
+
+
+
+
+ 添加分组
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 上架
+
+
+
+
+
+
+ 库存开关
+
+
+ 注:关闭则不计算出入库数据
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 设为推荐
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 删除该商品
+
-
-
-
+
+
+ 保存
+
+
+
-
- 删除该商品
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+ 确定
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pageProduct/add-Product/add-Product.vue b/pageProduct/add-Product/add-Product.vue
index e08499a..dad2fe6 100644
--- a/pageProduct/add-Product/add-Product.vue
+++ b/pageProduct/add-Product/add-Product.vue
@@ -846,7 +846,7 @@
},
{
minLength: 1,
- maxLength: 20,
+ maxLength: 40,
errorMessage: '商品名称长度在 {minLength} 到 {maxLength} 个字符',
}
]
@@ -1375,7 +1375,7 @@
for (let i of FormData.specificationsGroup.selectSpec) {
if (i.selectSpecResult.length) {
skuSnap.push({
- label: i.name,
+ name: i.name,
value: i.selectSpecResult.join(',')
})
}
diff --git a/pageProduct/index/components/edit-price.vue b/pageProduct/index/components/edit-price.vue
index 79f676a..f4c77eb 100644
--- a/pageProduct/index/components/edit-price.vue
+++ b/pageProduct/index/components/edit-price.vue
@@ -227,7 +227,9 @@
// }
onMounted(()=>{
+ // #ifndef H5
refForm.value.setRules(rules)
+ // #endif
})
diff --git a/pageProduct/index/components/edit-stock.vue b/pageProduct/index/components/edit-stock.vue
index 79a407b..cbd9303 100644
--- a/pageProduct/index/components/edit-stock.vue
+++ b/pageProduct/index/components/edit-stock.vue
@@ -256,7 +256,9 @@
// }
onMounted(()=>{
+ // #ifndef H5
refForm.value.setRules(rules)
+ // #endif
})
diff --git a/pageStaff/addstaff.vue b/pageStaff/addstaff.vue
index bde3596..e267ac1 100644
--- a/pageStaff/addstaff.vue
+++ b/pageStaff/addstaff.vue
@@ -89,10 +89,13 @@
+
+
\ No newline at end of file
diff --git a/pagesOrder/detail/components/list.vue b/pagesOrder/detail/components/list.vue
index fc3770b..1e18940 100644
--- a/pagesOrder/detail/components/list.vue
+++ b/pagesOrder/detail/components/list.vue
@@ -26,7 +26,9 @@
{{item.status=='refunding'?'退款中':'已退'}}
- {{item.name||item.productName}}
+
+ {{item.name||item.productName}}
@@ -35,11 +37,20 @@
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
+
+
+
+
+
+ 退款金额:
+ {{item.returnAmount}}
+
{{item.productSkuName||''}}
@@ -54,8 +65,29 @@
¥{{returnTotalMoney(item)}}
+
+ ¥0.00
+ ¥{{returnTotalMoney(item)}}
+
+
- ¥{{returnTotalMoney(item)}}
+
+ ¥{{returnCanTuiMoney(item)}}
+
+ ¥{{returnTotalMoney(item)}}
+
+
+ ¥{{returnTotalMoney(item)}}
+
+
X{{item.number||item.num}}
@@ -70,10 +102,10 @@
-
- 退款
-
+
+ {{item.userCouponId?'退券':'退款' }}
+
@@ -99,13 +131,22 @@
-
- 小计¥
- {{allPrice}}
+
+
+
+ 已优惠¥{{youhuiAllPrice}}
+
+
+
+
+ 小计¥
+ {{allPrice}}
+
+
-
+
退款金额
@@ -127,34 +168,241 @@
-
- 总计¥
-
- {{to2(allPrice*1+seatFeePrice*1+packFee*1) }}
-
+
+
+ 总计¥
+ {{orderInfo.amount }}
+
+
+
+
+ 总计¥
+ {{orderInfo.amount}}
+
+
+
+
+
重新打印
+
+
+ 优惠详情
+
+
+ 会员优惠
+
+ ¥
+ {{vipDiscountPrice}}
+
+
+
+ 打折
+
+ ¥
+ {{to2(discountAmount) }}
+
+
+
+ 满减券抵扣
+
+ ¥
+ {{to2(orderInfo.fullCouponDiscountAmount) }}
+
+
+
+ 商品券抵扣
+
+ ¥
+ {{productCouponDiscountAmount }}
+
+
+
+
+ 积分抵扣
+
+ ¥
+ {{to2(orderInfo.pointsDiscountAmount) }}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pagesOrder/pay-order/pay-order.vue b/pagesOrder/pay-order/pay-order.vue
index 50c53d9..3811782 100644
--- a/pagesOrder/pay-order/pay-order.vue
+++ b/pagesOrder/pay-order/pay-order.vue
@@ -1,43 +1,98 @@
-
- ¥
- {{discount.currentPrice?discount.currentPrice:order.amount}}
-
-
- ¥
- {{order.amount}}
-
-
- 修改
-
+
+
+ ¥
+
+ {{payPrice}}
+
+
+ ¥
+ {{originPrice}}
+
+
+ 修改
+
+
+
+
+ ¥
+ {{originPrice}}
+
+
+ 修改
+
+
+
-
-
- 优惠券
-
- 选择优惠券
-
-
+
+
+
+ 会员优惠
+
+ -¥{{vipDiscount}}
-
- 服务员改价
-
- -¥{{to2(order.amount- discount.currentPrice)}}
+
+
+
+ 优惠券
+
+ 选择优惠券
+
+
+
+
+
+
+
+
+ 减
+ {{item.name}}
+ x{{item.num}}
+
+
+
+ -¥{{item.discountAmount}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 服务员改价
+
+ -¥{{to2(discount.value)}}
+
+
+
+ 积分抵扣
+
+ -¥{{to2(accountPoints.price)}}
+
+
-
@@ -45,7 +100,8 @@
{{item.payName}}
-
+
会员:
{{user.telephone||user.nickName}}
@@ -54,14 +110,65 @@
余额:
¥{{user.amount||'0'}}
+
-
-
+
+
+
+
+
+
+
+
+ 积分抵扣
+
+ (
+ {{user.accountPoints||'0'}}
+ )
+
+
+
+
+
+
+ {{accountPoints.num}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ *
+ {{accountPoints.calcRes.unusableReason}}
+
+
+ *
+ 100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}}元,
+
+ 最大抵扣积分{{accountPoints.calcRes.maxUsablePoints}}
+
+ ,
+ 最小抵扣积分0
+
+
+
确认付款
@@ -81,7 +188,7 @@
- ¥{{discount.currentPrice?discount.currentPrice: order.amount}}
+ ¥{{payPrice}}
@@ -104,8 +211,17 @@
-
+
+
+
+
+
+
@@ -115,29 +231,181 @@
onMounted,
watch,
ref,
- onBeforeUnmount
+ onBeforeUnmount,
+ computed
} from 'vue';
import {
onLoad,
- onBackPress,onShow
+ onBackPress,
+ onShow
} from '@dcloudio/uni-app'
import go from '@/commons/utils/go.js'
import * as Api from '@/http/yskApi/Instead.js'
import {
queryAllShopUser
} from '@/http/yskApi/shop-user.js'
- import {hasPermission} from '@/commons/utils/hasPermission.js'
+ import {
+ hasPermission
+ } from '@/commons/utils/hasPermission.js'
import * as orderApi from '@/http/yskApi/order.js'
import infoBox from '@/commons/utils/infoBox.js'
import editDiscount from '@/components/my-components/edit-discount.vue'
- async function discountShow(){
- const bol=await hasPermission('yun_xu_da_zhe')
- if(bol){
- showModel('editMoney',true)
+ import editAccountPoints from './components/edit-accountPoints.vue'
+ import {
+ returnGoodsPayPriceMap,
+ returnProCoupStartIndex,
+ returnProductCoupAllPrice,
+ returnProductCanUseNum
+ } from '../quan_util.js'
+
+ const modal = reactive({
+ title: '提示',
+ cancelText: '取消',
+ confirmText: '确认',
+ content: '',
+ key: 'cash',
+ show: false,
+ data: ''
+ })
+
+ function confirmModelCancel() {
+ if (modal.key == 'fullCoupon') {
+ // 取消改价
+ discount.discount = 100
+ discount.value = 0
+ }
+ confirmModelClose()
+ }
+
+ function confirmModelClose() {
+ modal.show = false
+ modal.key = ''
+ modal.data = ''
+ }
+
+ function cashConfirmShow() {
+ modal.content = '是否确认已现金收款' + payPrice.value
+ modal.key = 'cash'
+ modal.show = true
+ }
+ async function confirmModelConfirm() {
+ if (modal.key == 'cash') {
+ await pay()
+ confirmModelCancel()
+ return
+ }
+ if (modal.key == 'fullCoupon') {
+ //删除满减券
+ const index = pays.quan.findIndex(v => v.type == 1)
+ pays.quan.splice(index, 1)
+ return
}
}
- let option = {isNowPay:false}
- let payFinish=ref(false)
+
+ //商品数量从0到n每一个对应的价格
+ let $goodsPayPriceMap = {}
+
+ const refPoints = ref(null)
+
+ function delQuan(i) {
+ pays.quan.splice(i, 1)
+ }
+
+ function refPointsOpen() {
+ if (!accountPoints.calcRes.usable && accountPoints.sel) {
+ return
+ }
+ refPoints.value.open()
+ }
+ const accountPoints = reactive({
+ sel: false,
+ num: 0,
+ calcRes: {
+ usable: false,
+ unusableReason: '',
+ minDeductionPoints: 0,
+ maxUsablePoints: 0
+ },
+ price: 0
+ })
+
+ function pointsConfirm(e) {
+ accountPoints.num = e
+ }
+ async function calcUsablePoints(orderAmount) {
+ if (!order.memberId) {
+ return
+ }
+ console.log(orderAmount);
+ const res = await Api.$calcUsablePoints({
+ memberId: order.memberId,
+ orderAmount: orderAmount ? orderAmount : payPrice.value
+ })
+ accountPoints.calcRes = res
+ accountPoints.num = res.maxUsablePoints
+ return res;
+ }
+ watch(() => accountPoints.sel, (newval) => {
+ if (newval) {
+ calcDeDuctionPoints()
+ }
+ })
+ async function calcDeDuctionPoints() {
+ if (accountPoints.num <= 0) {
+ accountPoints.price = 0
+ return ''
+ }
+ const res = await Api.$calcDeDuctionPoints({
+ memberId: order.memberId,
+ orderAmount: originPrice.value,
+ points: accountPoints.num
+ })
+ if (res) {
+ accountPoints.price = res
+ }
+ return res
+ }
+ watch(() => accountPoints.num, (newval) => {
+ if (!newval) {
+ accountPoints.price = 0
+ return
+ }
+ calcDeDuctionPoints()
+ })
+
+ function changeAccountPoints() {
+ if (!accountPoints.calcRes.usable) {
+ return
+ }
+ accountPoints.sel = !accountPoints.sel
+ if (!accountPoints.sel) {
+ accountPoints.num = 0
+ }
+ }
+
+ function toQuan() {
+ console.log(order);
+ if (!order.memberId) {
+ return infoBox.showToast('请先选择会员', 0.5).then(() => {
+ chooseUser()
+ })
+ }
+ go.to('PAGES_ORDER_QUAN', {
+ orderId: order.id,
+ memberId: order.memberId,
+ orderPrice: (payPrice.value * 1 + coupAllPrice.value * 1).toFixed(2)
+ })
+ }
+ async function discountShow() {
+ const bol = await hasPermission('yun_xu_da_zhe')
+ if (bol) {
+ showModel('editMoney', true)
+ }
+ }
+ let option = {
+ isNowPay: false
+ }
+ let payFinish = ref(false)
onBackPress(() => {
uni.$emit('orderDetail:update')
console.log('onBackPress');
@@ -148,7 +416,6 @@
// }
// return false
})
- let payStatus = ref(null) //loading success
let timer = null
@@ -165,7 +432,7 @@
if (!n) {
return ''
}
- return n.toFixed(2)
+ return Number(n).toFixed(2)
}
const pays = reactive({
list: ['扫码收款', '二维码收款'],
@@ -173,17 +440,19 @@
payTypes: {
list: [],
selIndex: 0
- }
+ },
+ quan: []
})
-
+
function chooseUser() {
go.to('PAGES_CHOOSE_USER')
}
//更新选择用户
- function setUser(par) {
+ function setUser(par) {
console.log(option);
const submitPar = {
tableId: order.tableId,
+ orderId: order.id,
masterId: order.masterId,
vipUserId: user.value.id ? user.value.id : '',
type: user.value.id ? 0 : 1 //0 设置 1 取消
@@ -191,21 +460,75 @@
Object.assign(submitPar, par)
return Api.$setUser(submitPar)
}
+
function watchChooseuser() {
uni.$off('choose-user')
uni.$on('choose-user', (data) => {
console.log(data);
- setUser({
- vipUserId: data.id ? data.id : '',
- type: data.id ? 0 : 1 //0 设置 1 取消
- }).then(res=>{
- user.value = data
- order.memberId=data.id
- })
+ pays.quan = []
+ setUser({
+ vipUserId: data.id ? data.id : '',
+ type: data.id ? 0 : 1 //0 设置 1 取消
+ }).then(res => {
+ user.value = data
+ order.memberId = data.id
+ init()
+ })
})
}
- onShow(()=>{
+
+ function setQuan(arr) {
+ console.log(arr);
+ discount.discount = 100
+ discount.value = 0
+ discount.currentPrice = order.amount
+ const manjianCoup = arr.filter(v => v.type == 1 && v.num >= 1)
+ let productCoup = arr.filter(v => v.type == 2)
+ console.log(productCoup);
+ //商品券分组
+ let coupMap = {}
+ for (let i in productCoup) {
+ const coup = productCoup[i]
+ if (coupMap.hasOwnProperty(coup.proId)) {
+ coupMap[coup.proId].push(coup)
+ } else {
+ coupMap[coup.proId] = [coup]
+ }
+ }
+ console.log(coupMap);
+ for (let key in coupMap) {
+ const arr = coupMap[key]
+ for (let i in arr) {
+ const coup = arr[i]
+ const proCoupStartIndex = returnProCoupStartIndex(arr, i)
+ console.log(proCoupStartIndex);
+ const coupUseNum = returnProductCanUseNum($goodsPayPriceMap[coup.proId], proCoupStartIndex,
+ coup.num)
+ const num = Math.min($goodsPayPriceMap[coup.proId].length, coupUseNum)
+ coup.num = num
+ console.log($goodsPayPriceMap[coup.proId]);
+ const findGoods = order.detailList.find(v => v.productId == coup.proId)
+ const isMember = findGoods.isMember
+ coup.discountAmount = returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],
+ proCoupStartIndex, num, isMember).toFixed(2)
+ }
+ }
+ productCoup = productCoup.filter(v => v.num >= 1)
+ console.log(productCoup);
+ pays.quan = [...manjianCoup, ...productCoup]
+ console.log(pays.quan);
+ }
+
+ function watchChooseQuan() {
+ uni.$off('choose-quan')
+ uni.$on('choose-quan', (arr) => {
+ setQuan(arr)
+ })
+ }
+
+ onShow(() => {
watchChooseuser()
+ watchChooseQuan()
})
watch(() => pays.selIndex, (newval) => {
@@ -239,31 +562,56 @@
//打折相关数据
const discount = reactive({
-
+ discount: 100,
+ currentPrice: 0,
+ value: 0
})
function editDiscountConfirm(form) {
console.log(form);
- Object.assign(discount, form)
+ accountPoints.sel = false
+ Object.assign(discount, {
+ ...form,
+ value: form.price - form.currentPrice
+ })
+ const fullCoupon = pays.quan.find(v => v.type == 1)
+ if (fullCoupon && form.currentPrice < fullCoupon.fullAmount) {
+ modal.content = '改价后价格不满足满减券最低满减需求' + fullCoupon.fullAmount + '元'
+ modal.key = 'fullCoupon'
+ modal.show = true
+ modal.cancelText = '取消改价'
+ modal.confirmText = '删除满减券'
+ }
getPayUrl()
}
+
async function getPayType() {
const payTypeList = await Api.$getPayType()
- pays.payTypes.list = payTypeList
+ pays.payTypes.list = payTypeList.map(v => {
+ return {
+ ...v,
+ disabled: false
+ }
+ })
}
function changePayType(i, item) {
+ if (item.disabled) {
+ return infoBox.showToast(item.payName + '不可用')
+ }
pays.payTypes.selIndex = i
- if (item.payType == 'vipPay' ) {
- chooseUser()
+ if (item.payType == 'vipPay' && !user.value.id) {
+ chooseUser()
}
}
+ let payStatus = '';
//支付成功回调
function paySuccess() {
infoBox.showToast('支付成功')
+ payStatus = 'success'
setTimeout(() => {
// uni.$emit('orderDetail:update')
- payFinish.value=true
+ payFinish.value = true
uni.$emit('get:table')
uni.$emit('update:orderDetail')
uni.navigateBack({
@@ -278,29 +626,55 @@
if (payType == 'scanCode' || payType == 'deposit') {
return saomaPay()
}
+ if (payType == 'cash' && payPrice.value * 1 > 0) {
+ return cashConfirmShow()
+ }
payOrder()
}
+ const tipsMap = {
+ paying: '支付中',
+ success: '已支付成功'
+ }
async function payOrder() {
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
if (payType == 'vipPay' && user.value.amount * 1 < order.amount * 1) {
- infoBox.showToast('余额不足')
- return
+ infoBox.showToast('余额不足')
+ return
}
+
+ if (payStatus) {
+ return infoBox.showToast(tipsMap[payStatus])
+ }
+ try {
+ pay()
+ } catch (e) {
+ //TODO handle the exception
+ payStatus = ''
+ }
+ }
+ async function pay(par) {
+ const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
+ payStatus = 'paying'
await Api.$payOrder({
tableId: order.tableId,
masterId: order.masterId,
orderId: order.id || order.orderId,
payType,
vipUserId: order.memberId,
- discount: 1,
- code: ''
+ discount: discount.discount / 100,
+ code: '',
+ pointsNum: accountPoints.sel ? accountPoints.num : 0,
+ userCouponInfos: pays.quan.map(v => {
+ return {
+ userCouponId: v.id,
+ num: v.num
+ }
+ }),
+ ...par
})
paySuccess()
}
- onMounted(() => {
- getPayType()
- })
const order = reactive({
amount: 0
})
@@ -314,14 +688,8 @@
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
- Api.$payOrder({
- "orderId": order.orderId, // 订单id
- "payType": item.payType, //
- "discount": order.discount,
- "code": res.result
- }).then(res => {
- console.log(res);
- paySuccess()
+ pay({
+ code: res.result
})
}
});
@@ -344,41 +712,140 @@
async function init() {
const orderRes = await orderApi.tbOrderInfoDetail(order.orderId)
Object.assign(order, orderRes)
+ $goodsPayPriceMap = returnGoodsPayPriceMap(order.detailList)
+ const hasSelQuan = orderRes.couponInfoList ? JSON.parse(orderRes.couponInfoList) : {
+ fullReductionCoupon: [],
+ productCoupon: []
+ };
+ const fullReductionCoupon = hasSelQuan.fullReductionCoupon.filter(v => v.type == 1)
+ const productCoupon = hasSelQuan.productCoupon.filter(v => v.type == 2)
+ setQuan([...fullReductionCoupon, ...productCoupon])
+
if (orderRes.memberId) {
+ calcUsablePoints()
+ if (orderRes.pointsNum) {
+ accountPoints.sel = true
+ }
queryAllShopUser({
id: orderRes.memberId
}).then(res => {
- if(res.content[0]){
- user.value =res.content[0]
+ if (res.content[0]) {
+ user.value = res.content[0]
}
})
}
- getPayUrl()
}
function getPayUrl() {
orderApi.$getOrderPayUrl({
orderId: order.id,
- payAmount: discount.currentPrice ? discount.currentPrice : order.amount
+ payAmount: payPrice.value
}).then(res => {
payCodeUrl.value = res
})
}
+ const coupAllPrice = computed(() => {
+ const n = pays.quan.reduce((prve, cur) => {
+ return prve + cur.discountAmount * 1
+ }, 0)
+ return n
+ })
+ const payPrice = computed(() => {
+ // const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
+ // const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
+ // return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
+ const total = (originPrice.value) - vipDiscount.value - productCouponDiscountAmount.value - discount
+ .value -
+ fullCouponDiscountAmount.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
+ return (total < 0 ? 0 : total).toFixed(2)
+ })
+ const vipDiscount = computed(() => {
+ if (!user.value.isVip) {
+ return 0
+ }
+ const goodsPrice = order.detailList.filter(v => v.gift != true && v.status !== "return" && (v.isMember &&
+ v.memberPrice) && (v.memberPrice != v.price)).reduce((
+ a,
+ b) => {
+ return a + (b.num * (b.price - b.memberPrice))
+ }, 0)
+ return goodsPrice.toFixed(2)
+ })
+ const originPrice = computed(() => {
+ const n = (order.amount || 0) * 1 + vipDiscount.value * 1 + (order.fullCouponDiscountAmount || 0) + (order
+ .productCouponDiscountAmount || 0) +
+ (order.pointsDiscountAmount || 0)
+
+ return n.toFixed(2)
+ })
+ const fullCouponDiscountAmount = computed(() => {
+ return pays.quan.filter(v => v.type == 1).reduce((prve, cur) => {
+ return prve + cur.discountAmount * 1
+ }, 0)
+ })
+ const productCouponDiscountAmount = computed(() => {
+ return pays.quan.filter(v => v.type == 2).reduce((prve, cur) => {
+ return prve + cur.discountAmount * 1
+ }, 0)
+ })
+ watch(() => payPrice.value, (newval) => {
+ getPayUrl()
+ if (newval <= 0) {
+ const arr = ['cash', 'vipPay']
+ pays.payTypes.list.map(v => {
+ if (arr.includes(v.payType)) {
+ v.disabled = false
+ } else {
+ v.disabled = true
+ }
+ })
+ const index = pays.payTypes.list.findIndex(v => !v.disabled)
+ pays.payTypes.selIndex = index
+ } else {
+ pays.payTypes.list.map(v => {
+ v.disabled = false
+ })
+ }
+ })
+ const pointCanDicountPrice = computed(() => {
+ const total = (order.amount || 0) - productCouponDiscountAmount.value - discount.value -
+ fullCouponDiscountAmount.value
+ return (total < 0 ? 0 : total).toFixed(2)
+ })
+ watch(() => pointCanDicountPrice.value, (newval) => {
+ calcUsablePoints()
+ })
+
onLoad(async (opt) => {
console.log(opt);
option = opt
Object.assign(order, opt)
- const payTypeList = await Api.$getPayType()
- pays.payTypes.list = payTypeList
+ getPayType()
init()
})
onBeforeUnmount(() => {
+ console.log('onBeforeUnmount');
clear()
})
\ No newline at end of file
diff --git a/pagesOrder/quan_util.js b/pagesOrder/quan_util.js
new file mode 100644
index 0000000..b11f492
--- /dev/null
+++ b/pagesOrder/quan_util.js
@@ -0,0 +1,250 @@
+export function isTui(item) {
+ return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
+}
+//是否使用会员价
+export function isUseVipPrice(vipUser,goods){
+ return vipUser.id&&vipUser.isVip&&goods.isMember
+}
+
+//计算商品券优惠价格
+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 ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
+ return price * coup.num
+
+}
+//返回新的商品列表,过滤掉退菜的,退单的商品
+export function returnNewGoodsList(arr) {
+ let goodsMap = {}
+ return arr.filter(v => !isTui(v))
+}
+//根据当前购物车商品以及数量,已选券对应商品数量,判断该商品券是否可用
+export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
+ // if(!coup.use){
+ // return false
+ // }
+ const findGoods = goodsArr.filter(v => v.productId == coup.proId)
+ if (!findGoods.length) {
+ return false
+ }
+ const findGoodsTotalNumber = findGoods.reduce((prve, cur) => {
+ return prve + cur.num * 1
+ }, 0)
+ const selCoupNumber = selCoupArr.filter(v => v.proId == coup.proId).reduce((prve, cur) => {
+ return prve + cur.num * 1
+ }, 0)
+ if (selCoupNumber >= findGoodsTotalNumber) {
+ return false
+ }
+ console.log(selCoupNumber,findGoodsTotalNumber);
+ return findGoodsTotalNumber < selCoupNumber ? false : true
+}
+//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
+export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
+ 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 ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
+ const discountAmount = (price * coup.num).toFixed(2)
+ console.log(discountAmount);
+
+ // const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
+ // const canUse=discountAmount>0
+ const canUse=coup.use
+ return {
+ ...coup,
+ discountAmount: discountAmount,
+ 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 returnProductPayPrice(goods,vipUser){
+ const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
+ const price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.price;
+ return price
+}
+//返回商品券抵扣的商品价格
+export function returnProductCoupAllPrice(productPriceArr,startIndex,num,isMember=true){
+ console.log(productPriceArr);
+ return productPriceArr.slice(startIndex,startIndex+num).reduce((prve,cur)=>{
+ let curPrice=0
+ if(typeof cur==='object'){
+ curPrice=isMember?cur.memberPrice*1:cur.price
+ }else{
+ curPrice=cur*1
+ }
+ return prve+curPrice
+ },0)
+}
+
+//返回商品券可抵扣的商品数量
+export function returnProductCanUseNum(productPriceArr,startIndex,num){
+ console.log(productPriceArr);
+ console.log(num);
+ let n=0;
+ for(let i=0;i{
+ return prve+cur.num*1
+ },0)
+}
+//返回商品数量从0到n每一个对应的价格对照表
+export function returnGoodsPayPriceMap(goodsArr){
+ return goodsArr.reduce((prve,cur)=>{
+ if(!prve.hasOwnProperty(cur.productId)){
+ prve[cur.productId]=[]
+ }
+ const arr=new Array(cur.num).fill(cur).map(v=>{
+ return {
+ memberPrice:v.memberPrice?v.memberPrice:v.price,
+ price:v.price
+ }
+ })
+ prve[cur.productId].push(...arr)
+ return prve
+ },{})
+}
+//计算商品券总优惠价格
+export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
+ if (coupArr.length == 0) {
+ return 0;
+ }
+ //商品分组
+ const goodsMap={}
+ //商品数量从0到n每一个对应的价格
+ const goodsPayPriceMap={}
+ //商品券分组
+ let coupMap={}
+ for(let i in coupArr){
+ const coup=coupArr[i]
+ if(coupMap.hasOwnProperty(coup.proId)){
+ coupMap[coup.proId].push(coup)
+ }else{
+ coupMap[coup.proId]=[coup]
+ }
+ }
+ let total=0
+ for(let key in coupMap){
+ const arr=coupMap[key]
+ for(let i in arr){
+ const coup=arr[i]
+ if(!goodsMap.hasOwnProperty(coup.proId)){
+ goodsMap[coup.proId]=goodsArr.filter(v=>v.productId==coup.proId).map(v=>{
+ return {
+ ...v,
+ payPrice:returnProductPayPrice(v,vipUser)
+ }
+ }).sort((a,b)=>{
+ const aPrice=a.payPrice
+ const bPrice=b.payPrice
+ return aPrice-bPrice
+ })
+ goodsPayPriceMap[coup.proId]=goodsMap[coup.proId].reduce((prve,cur)=>{
+ const arr=new Array(cur.num).fill(cur.payPrice)
+ console.log(arr);
+ prve.push(...arr)
+ return prve
+ },[])
+ }
+ const proCoupStartIndex=returnProCoupStartIndex(arr,i)
+ console.log(proCoupStartIndex);
+ const coupNum=Math.min(goodsPayPriceMap[coup.proId].length,coup.num)
+ console.log(coupNum);
+ total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
+ }
+ }
+
+ return total.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);
+}
+
+//返回当前满减券列表可用状态
+export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
+ return coupArr.map(v => {
+ if (v.id == selCoup.id) {
+ return v
+ }
+ const isfullAmount = payPrice >= v.fullAmount * 1
+ if(payPrice<=0){
+ return {
+ ...v,
+ use: false
+ }
+ }
+ return {
+ ...v,
+ use: v.use && isfullAmount
+ }
+ })
+}
+
+//根据商品数量还有商品券数量返回优惠券可以使用的数量数组
+export function returnCanUseNumProductCoup(coupArr,){
+ let productCoup = coupArr.filter(v => v.type == 2)
+ //商品券分组
+ let coupMap={}
+ for(let i in productCoup){
+ const coup=productCoup[i]
+ if(coupMap.hasOwnProperty(coup.proId)){
+ coupMap[coup.proId].push(coup)
+ }else{
+ coupMap[coup.proId]=[coup]
+ }
+ }
+ return arr
+}
\ No newline at end of file
diff --git a/pagesOrder/static/image/no-use.svg b/pagesOrder/static/image/no-use.svg
new file mode 100644
index 0000000..a5df700
--- /dev/null
+++ b/pagesOrder/static/image/no-use.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/pagesOrder/tuikuan/tuikuan.vue b/pagesOrder/tuikuan/tuikuan.vue
index 04df108..6e5084e 100644
--- a/pagesOrder/tuikuan/tuikuan.vue
+++ b/pagesOrder/tuikuan/tuikuan.vue
@@ -20,7 +20,7 @@
- ¥{{item.priceAmount}}
+ ¥{{item.priceAmount}}
x{{item.number}}
@@ -28,7 +28,7 @@
- ¥{{item.priceAmount}}
+ ¥{{item.priceAmount}}
{{item.number}}
@@ -39,21 +39,24 @@
-
- 支付金额
-
- {{to2(totalPrice)}}元
+
+
+ 支付金额
+
+ {{to2(totalPrice)}}元
+
-
-
- 退款金额
-
- {{to2(tuikuanPrice)}}元
+
+ 退款金额
+
+ {{to2(tuikuanPrice)}}元
+
-
+
+
退回优惠券
-
+
该订单未使用优惠券
@@ -143,7 +146,8 @@
})
const tuikuanPrice = computed(() => {
return orderDetail.goodsList.reduce((prve, cur) => {
- return prve + cur.number * cur.price
+ const n=(cur.number/cur.num*100) * cur.priceAmount
+ return prve + (n/100).toFixed(2)
}, 0)
})