修改订单支付优惠券积分

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 { 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'

View File

@@ -2,8 +2,7 @@
<view class="page-gray u-font-28">
<view class="search bg-fff u-flex u-col-center ">
<view class="u-flex-1">
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索" @confirm="search"
@clear="search"
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索" @confirm="search" @clear="search"
v-model="query.name">
</uni-search-bar>
</view>
@@ -25,7 +24,10 @@
<image v-if="item.headImg" :src="item.headImg" class="img" mode=""></image>
</view>
<view class="u-m-l-32">
<view>{{item.nickName}}</view>
<view class="u-flex">
<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">
<text class="color-999" v-if="!item.isVip">非会员</text>
<text class="color-main" v-else>会员</text>
@@ -48,7 +50,7 @@
<my-pagination :page="query.page" :totalElements="query.totalElements" :size="query.size"
@change="pageChange"></my-pagination>
</view>
</template>
<template v-if="hasAjax&&list.length<=0">
<my-img-empty tips="未找到相关用户"></my-img-empty>
@@ -107,16 +109,16 @@
isVip: 1
})
const list = reactive([])
let hasAjax=ref(false)
let hasAjax = ref(false)
async function getUser() {
const {
content,
totalElements
} = await Api.queryAllShopUser(query)
hasAjax.value=true
list.length=content.length
hasAjax.value = true
list.length = content.length
for (let i in content) {
list[i]={
list[i] = {
...content[i],
checked: false
}
@@ -126,7 +128,7 @@
}
function pageChange(e) {
query.page=e
query.page = e
getUser()
}

View File

@@ -53,7 +53,7 @@
</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 "
v-if="discount.price&&discount.currentPrice!=order.amount">
<view>服务员改价</view>
@@ -62,7 +62,7 @@
</view>
</view>
<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 class=" u-flex u-col-center">
<text style="color: rgb(255, 95, 46);">-{{to2(accountPoints.price)}}</text>
@@ -169,7 +169,7 @@
</view>
<view class="bg-fff card bottom border-r-12 u-p-32">
<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">
<template v-if="order.status=='unpaid'">
<up-loading-icon size="14" text="等待支付"></up-loading-icon>
@@ -245,9 +245,12 @@
price:0
})
async function calcUsablePoints(){
if(!order.memberId){
return
}
const res=await Api.$calcUsablePoints({
memberId:order.memberId,
orderAmount:order.amount
orderAmount:pointCanDicountPrice.value
})
accountPoints.calcRes=res
accountPoints.num=res.maxUsablePoints
@@ -424,16 +427,7 @@
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) {
console.log(form);
Object.assign(discount, form)
@@ -486,7 +480,15 @@
payType,
vipUserId: order.memberId,
discount: 1,
code: ''
code: '',
pointsNum:accountPoints.sel?accountPoints.num:0,
userCouponInfos:pays.quan.map(v=>{
return {
userCouponId:v.id,
num:v.num
}
})
})
paySuccess()
}
@@ -553,11 +555,33 @@
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(()=>{
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) => {
console.log(opt);
option = opt
@@ -566,8 +590,9 @@
pays.payTypes.list = payTypeList
init()
})
onBeforeUnmount(() => {
console.log('onBeforeUnmount');
clear()
})
</script>

View File

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

View File

@@ -10,7 +10,7 @@ export function returnProductCouponPrice(coup, goodsArr, vipUser) {
}
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
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=[]) {
// if(!coup.use){
// return false
// }
if(!coup.use){
return false
}
const findGoods=goodsArr.filter(v=>v.productId==coup.proId)
if(!findGoods.length){
return false
@@ -49,8 +49,7 @@ export function returnProductCoupon(coup, goodsArr, vipUser) {
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
const discountAmount=(price*coup.num).toFixed(2)
console.log(discountAmount);
// const canUse=!coup.use?false:(discountAmount>0)
const canUse=discountAmount>0
const canUse=!coup.use?false:(discountAmount>0)
return { ...coup, discountAmount: discountAmount,use:canUse}
}