修改订单支付优惠券积分

This commit is contained in:
2024-11-11 16:09:09 +08:00
parent 2691cf9b53
commit 7d39bc2bee
5 changed files with 126 additions and 80 deletions

View File

@@ -17,13 +17,13 @@ import infoBox from "@/commons/utils/infoBox.js"
import go from '@/commons/utils/go.js'; import go from '@/commons/utils/go.js';
import { reject } from 'lodash'; 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://pre-cashieradmin.sxczgkj.cn'
//正式 //正式
let baseUrl = 'https://cashieradmin.sxczgkj.cn' // let baseUrl = 'https://cashieradmin.sxczgkj.cn'
// 王伟本地测 // 王伟本地测
// let baseUrl = '/ww' // let baseUrl = '/ww'

View File

@@ -2,8 +2,7 @@
<view class="page-gray u-font-28"> <view class="page-gray u-font-28">
<view class="search bg-fff u-flex u-col-center "> <view class="search bg-fff u-flex u-col-center ">
<view class="u-flex-1"> <view class="u-flex-1">
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索" @confirm="search" <uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索" @confirm="search" @clear="search"
@clear="search"
v-model="query.name"> v-model="query.name">
</uni-search-bar> </uni-search-bar>
</view> </view>
@@ -25,7 +24,10 @@
<image v-if="item.headImg" :src="item.headImg" class="img" mode=""></image> <image v-if="item.headImg" :src="item.headImg" class="img" mode=""></image>
</view> </view>
<view class="u-m-l-32"> <view class="u-m-l-32">
<view class="u-flex">
<view>{{item.nickName}}</view> <view>{{item.nickName}}</view>
</view>
<view class="u-m-t-12 ">手机号:{{item.telephone}}</view>
<view class=" u-font-24 u-m-t-12 u-flex"> <view class=" u-font-24 u-m-t-12 u-flex">
<text class="color-999" v-if="!item.isVip">非会员</text> <text class="color-999" v-if="!item.isVip">非会员</text>
<text class="color-main" v-else>会员</text> <text class="color-main" v-else>会员</text>
@@ -107,16 +109,16 @@
isVip: 1 isVip: 1
}) })
const list = reactive([]) const list = reactive([])
let hasAjax=ref(false) let hasAjax = ref(false)
async function getUser() { async function getUser() {
const { const {
content, content,
totalElements totalElements
} = await Api.queryAllShopUser(query) } = await Api.queryAllShopUser(query)
hasAjax.value=true hasAjax.value = true
list.length=content.length list.length = content.length
for (let i in content) { for (let i in content) {
list[i]={ list[i] = {
...content[i], ...content[i],
checked: false checked: false
} }
@@ -126,7 +128,7 @@
} }
function pageChange(e) { function pageChange(e) {
query.page=e query.page = e
getUser() getUser()
} }

View File

@@ -53,7 +53,7 @@
</view> </view>
<view class="border-bottom u-p-b-30"> <view class="border-bottom u-p-b-30" v-if="payPrice!=order.amount">
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 " <view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
v-if="discount.price&&discount.currentPrice!=order.amount"> v-if="discount.price&&discount.currentPrice!=order.amount">
<view>服务员改价</view> <view>服务员改价</view>
@@ -62,7 +62,7 @@
</view> </view>
</view> </view>
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 " <view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
v-if="accountPoints.price"> v-if="accountPoints.price&&accountPoints.sel">
<view>积分抵扣</view> <view>积分抵扣</view>
<view class=" u-flex u-col-center"> <view class=" u-flex u-col-center">
<text style="color: rgb(255, 95, 46);">-{{to2(accountPoints.price)}}</text> <text style="color: rgb(255, 95, 46);">-{{to2(accountPoints.price)}}</text>
@@ -169,7 +169,7 @@
</view> </view>
<view class="bg-fff card bottom border-r-12 u-p-32"> <view class="bg-fff card bottom border-r-12 u-p-32">
<view class="font-bold u-font-32 u-text-center"> <view class="font-bold u-font-32 u-text-center">
{{discount.currentPrice?discount.currentPrice: order.amount}}</view> {{payPrice}}</view>
<view class="u-flex u-row-center u-m-t-24"> <view class="u-flex u-row-center u-m-t-24">
<template v-if="order.status=='unpaid'"> <template v-if="order.status=='unpaid'">
<up-loading-icon size="14" text="等待支付"></up-loading-icon> <up-loading-icon size="14" text="等待支付"></up-loading-icon>
@@ -245,9 +245,12 @@
price:0 price:0
}) })
async function calcUsablePoints(){ async function calcUsablePoints(){
if(!order.memberId){
return
}
const res=await Api.$calcUsablePoints({ const res=await Api.$calcUsablePoints({
memberId:order.memberId, memberId:order.memberId,
orderAmount:order.amount orderAmount:pointCanDicountPrice.value
}) })
accountPoints.calcRes=res accountPoints.calcRes=res
accountPoints.num=res.maxUsablePoints accountPoints.num=res.maxUsablePoints
@@ -424,16 +427,7 @@
const discount = reactive({ const discount = reactive({
}) })
const coupAllPrice=computed(()=>{
return pays.quan.reduce((prve,cur)=>{
return prve+cur.discountAmount*1
},0)
})
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)
})
function editDiscountConfirm(form) { function editDiscountConfirm(form) {
console.log(form); console.log(form);
Object.assign(discount, form) Object.assign(discount, form)
@@ -486,7 +480,15 @@
payType, payType,
vipUserId: order.memberId, vipUserId: order.memberId,
discount: 1, discount: 1,
code: '' code: '',
pointsNum:accountPoints.sel?accountPoints.num:0,
userCouponInfos:pays.quan.map(v=>{
return {
userCouponId:v.id,
num:v.num
}
})
}) })
paySuccess() paySuccess()
} }
@@ -553,11 +555,33 @@
function getPayUrl() { function getPayUrl() {
orderApi.$getOrderPayUrl({ orderApi.$getOrderPayUrl({
orderId: order.id, orderId: order.id,
payAmount: discount.currentPrice ? discount.currentPrice : order.amount payAmount: payPrice.value
}).then(res => { }).then(res => {
payCodeUrl.value = res payCodeUrl.value = res
}) })
} }
const coupAllPrice=computed(()=>{
return pays.quan.reduce((prve,cur)=>{
return prve+cur.discountAmount*1
},0)
})
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)
})
watch(()=>payPrice.value,()=>{
getPayUrl()
})
const pointCanDicountPrice=computed(()=>{
const discountPrice=discount.currentPrice?discount.currentPrice:order.amount
const calcPrice=discountPrice-coupAllPrice.value
return (calcPrice<=0?0:calcPrice).toFixed(2)
})
watch(()=>pointCanDicountPrice.value,(newval)=>{
calcUsablePoints()
})
onLoad(async (opt) => { onLoad(async (opt) => {
console.log(opt); console.log(opt);
option = opt option = opt
@@ -568,6 +592,7 @@
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
console.log('onBeforeUnmount');
clear() clear()
}) })
</script> </script>

View File

@@ -45,9 +45,8 @@
<template v-if="myQuan.types.sel==1"> <template v-if="myQuan.types.sel==1">
<view class="" @click="changeProductCoupon(item)" v-for="(item,index) in myQuan.res.productCoupon" <view class="" @click="changeProductCoupon(item)" v-for="(item,index) in myQuan.res.productCoupon"
:class="{filtergray:!item.use}" :key="index" :class="{filtergray:!item.use}" :key="index">
> <view class="quan goods u-row-between u-flex u-col-center u-m-b-32 border-r-10 u-relative">
<view class="quan goods u-row-between u-flex u-col-center u-m-b-32 border-r-10 u-relative" >
<view class="no-use" v-if="!item.use"> <view class="no-use" v-if="!item.use">
<image class="img" src="/pagesOrder/static/image/no-use.svg" mode=""></image> <image class="img" src="/pagesOrder/static/image/no-use.svg" mode=""></image>
</view> </view>
@@ -90,14 +89,22 @@
</view> </view>
<view :style="{height:safebottomHeight+'px'}"></view> <view :style="{height:safebottomHeight+'px'}"></view>
<view class="fixed-b u-flex gap-20 bottom safe-bottom border-top"> <view class="fixed-b bottom safe-bottom border-top">
<view class="u-m-b-32">
<text>抵扣金额</text>
<text class="color-red"></text>
<text class="color-red">{{discountAmount}}</text>
</view>
<view class="u-flex gap-20">
<up-button shape="circle" plain @click="back"> <up-button shape="circle" plain @click="back">
<view class="font-bold">取消</view> <view class="font-bold">取消</view>
</up-button> </up-button>
<up-button shape="circle" type="primary" @click="toEmitChooseQuan()"> <up-button shape="circle" type="primary" @click="toEmitChooseQuan()">
<view class="font-bold" >确定</view> <view class="font-bold">确定</view>
</up-button> </up-button>
</view> </view>
</view>
</view> </view>
</template> </template>
@@ -125,14 +132,20 @@
import { import {
queryAllShopUser queryAllShopUser
} from '@/http/yskApi/shop-user.js' } from '@/http/yskApi/shop-user.js'
import {returnNewGoodsList,returnCoupCanUse,returnProductCoupon} from '../quan_util.js' import {
function back(){ returnNewGoodsList,
returnCoupCanUse,
returnCouponAllPrice,
returnProductCoupon
} from '../quan_util.js'
function back() {
uni.navigateBack() uni.navigateBack()
} }
let order=ref({ let order = ref({
}) })
let canDikouGoodsArr=[] let canDikouGoodsArr = []
const myQuan = reactive({ const myQuan = reactive({
fullReductionCouponSel: { fullReductionCouponSel: {
id: '' id: ''
@@ -151,15 +164,15 @@
}) })
function changeProductCoupon(item) { function changeProductCoupon(item) {
if(!item.use){ if (!item.use) {
return return
} }
item.checked = !item.checked item.checked = !item.checked
const CheckedArr=myQuan.res.productCoupon.filter(v=>v.checked) const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked)
const noCheckedArr=myQuan.res.productCoupon.filter(v=>!v.checked) const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
noCheckedArr.map(v=>{ noCheckedArr.map(v => {
console.log(returnCoupCanUse(canDikouGoodsArr,v,CheckedArr)); console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
v.use=returnCoupCanUse(canDikouGoodsArr,v,CheckedArr) v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
}) })
} }
@@ -174,13 +187,13 @@
function toUse(item) { function toUse(item) {
} }
let user=reactive({ let user = reactive({
isVip:false isVip: false
}) })
async function getQuan() { async function getQuan() {
order.value=await orderApi.tbOrderInfoDetail(option.orderId) order.value = await orderApi.tbOrderInfoDetail(option.orderId)
if(order.value.memberId){ if (order.value.memberId) {
const userRes= await queryAllShopUser({ const userRes = await queryAllShopUser({
id: order.value.memberId id: order.value.memberId
}) })
if (userRes.content[0]) { if (userRes.content[0]) {
@@ -190,10 +203,10 @@
console.log(order.value); console.log(order.value);
const res = await $activateByOrderId(option) const res = await $activateByOrderId(option)
canDikouGoodsArr=returnNewGoodsList(order.value.detailList||[]) canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => !v.use) res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => !v.use)
res.productCoupon = res.productCoupon.map(v => { res.productCoupon = res.productCoupon.map(v => {
const calcCoup=returnProductCoupon(v,canDikouGoodsArr,user.value) const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value)
return { return {
...calcCoup, ...calcCoup,
checked: false checked: false
@@ -204,32 +217,36 @@
} }
const option = reactive({ const option = reactive({
orderId: '', orderId: '',
memberId: '', memberId: ''
payPrice:''
}) })
function toEmitChooseQuan(item){ function toEmitChooseQuan(item) {
let arr=[] let arr = []
if(item){ if (item) {
arr=[item] arr = [item]
}else{ } else {
if(myQuan.fullReductionCouponSel.id){ if (myQuan.fullReductionCouponSel.id) {
arr.push(myQuan.fullReductionCouponSel) arr.push(myQuan.fullReductionCouponSel)
} }
const goodsQuan=myQuan.res.productCoupon.filter(v=>v.checked) const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
arr.push(...goodsQuan) arr.push(...goodsQuan)
} }
uni.$emit('choose-quan',arr) uni.$emit('choose-quan', arr)
back() back()
} }
const discountAmount = computed(() => {
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
let coupArr = [...fullReductionCoupon, ...goodsQuan]
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
})
onLoad((opt) => { onLoad((opt) => {
Object.assign(option, opt) Object.assign(option, opt)
getQuan() getQuan()
}) })
let safebottomHeight = ref(0) let safebottomHeight = ref(0)
onReady(() => { onReady(() => {
getSafeBottomHeight('bottom',0).then(height => { getSafeBottomHeight('bottom', 0).then(height => {
safebottomHeight.value = height safebottomHeight.value = height
}) })
}) })
@@ -238,7 +255,8 @@
<style lang="scss" scoped> <style lang="scss" scoped>
// $quan-color:rgb(233, 77, 60); // $quan-color:rgb(233, 77, 60);
$quan-color: #318AFE; $quan-color: #318AFE;
.no-use{
.no-use {
position: absolute; position: absolute;
left: 0; left: 0;
right: 0; right: 0;
@@ -247,12 +265,14 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.img{
.img {
width: 200rpx; width: 200rpx;
height: 200rpx; height: 200rpx;
z-index: 10; z-index: 10;
} }
} }
.fixed-b { .fixed-b {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
@@ -357,7 +377,7 @@
.hui { .hui {
// background-color: $quan-color; // background-color: $quan-color;
background-image: linear-gradient(to right bottom,rgb(254,103,4),rgb(241,50,42)); background-image: linear-gradient(to right bottom, rgb(254, 103, 4), rgb(241, 50, 42));
padding: 4rpx 10rpx; padding: 4rpx 10rpx;
border-radius: 10rpx; border-radius: 10rpx;
font-size: 24rpx; font-size: 24rpx;

View File

@@ -10,7 +10,7 @@ export function returnProductCouponPrice(coup, goodsArr, vipUser) {
} }
const memberPrice = item.memberPrice ? item.memberPrice : item.price; const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0; const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
return price return price*coup.num
} }
//返回新的商品列表,过滤掉退菜的,退单的商品 //返回新的商品列表,过滤掉退菜的,退单的商品
@@ -20,9 +20,9 @@ export function returnNewGoodsList(arr) {
} }
//根据当前购物车商品以及数量,已选券对应商品数量,判断该券是否可用 //根据当前购物车商品以及数量,已选券对应商品数量,判断该券是否可用
export function returnCoupCanUse(goodsArr=[],coup,selCoupArr=[]) { export function returnCoupCanUse(goodsArr=[],coup,selCoupArr=[]) {
// if(!coup.use){ if(!coup.use){
// return false return false
// } }
const findGoods=goodsArr.filter(v=>v.productId==coup.proId) const findGoods=goodsArr.filter(v=>v.productId==coup.proId)
if(!findGoods.length){ if(!findGoods.length){
return false return false
@@ -49,8 +49,7 @@ export function returnProductCoupon(coup, goodsArr, vipUser) {
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0; const price = item ? (vipUser.isVip ? 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) const canUse=!coup.use?false:(discountAmount>0)
const canUse=discountAmount>0
return { ...coup, discountAmount: discountAmount,use:canUse} return { ...coup, discountAmount: discountAmount,use:canUse}
} }