oil-station/gasStation-uni/pagesRefuel/orderDetail/index.vue

1041 lines
34 KiB
Vue
Raw Normal View History

2023-12-01 15:47:01 +08:00
<template>
<!-- 订单详情页 -->
<view class="content">
<view class="container">
<view class="my-header">
<view class="my-icons" @click="goBack"> <uni-icons type="left" size="16"></uni-icons> </view>
<view class="my-text">支付订单</view>
<view class="my-icons"></view>
</view>
<!-- 顶部区域 -->
<view style="background-color: white;width: 94%;margin: 15px auto;">
2023-12-01 16:40:20 +08:00
<view style="font-weight: bold;height: 40px;line-height: 40px;margin-left: 10px;margin-top: 20px;">订单详情
</view>
2023-12-01 15:47:01 +08:00
<view class="desc">
<view>油站名称</view>
<view>{{store.name}}{{store.description ? "("+store.description+")" : ""}}</view>
</view>
<view class="desc">
<view>油号油枪</view>
<view>{{oilName}}/{{oilOrder.oilGunNum}}</view>
</view>
<view class="desc">
<view>加油金额</view>
<view>{{oilOrder.orderAmount}}</view>
</view>
<view class="desc">
<view>加油数量</view>
<view>{{oilOrder.oilNum}}</view>
</view>
<view class="desc">
<view>油品单价</view>
<view>{{oilPrice}}/</view>
</view>
<view class="desc">
<view>加油员工</view>
<view>{{staff.realName}}</view>
</view>
</view>
2023-12-01 16:40:20 +08:00
2023-12-01 15:47:01 +08:00
<view style="background-color: white;width: 94%;margin: 15px auto;">
<view class="desc">
2023-12-04 16:35:09 +08:00
<view style="display: flex;">
储值卡
2023-12-08 15:48:54 +08:00
<span style="display: flex;">(余额{{user.cardBalance}})</span>
2023-12-04 16:35:09 +08:00
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">-{{balanceRedece}}</span>
<u-checkbox-group>
2023-12-07 18:28:31 +08:00
<u-checkbox v-model="balance" @change="changeBalance"></u-checkbox>
2023-12-04 16:35:09 +08:00
</u-checkbox-group>
</view>
2023-12-01 15:47:01 +08:00
</view>
2023-12-04 16:35:09 +08:00
2023-12-08 15:48:54 +08:00
<view class="desc" v-if="refuelMoney.length > 0">
2023-12-01 15:47:01 +08:00
<view style="display: flex;">
2023-12-04 16:35:09 +08:00
<u-collapse>
<u-collapse-item title="囤油卡" :open="true">
<view v-for="(item,index) in refuelMoney" :key="index">
{{item.type}}{{item.oilType}}:{{item.refuelMoney}}L
</view>
</u-collapse-item>
</u-collapse>
<!-- 囤油卡
2023-12-01 16:40:20 +08:00
<span style="color: red;display: flex;">(余额0.00)<u-icon name="question-circle"
2023-12-04 16:35:09 +08:00
color="red"></u-icon></span> -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">- {{oilCardRedece}}L</span>
<u-checkbox-group>
2023-12-07 18:28:31 +08:00
<u-checkbox v-model="oilCard" @change="changeOilCard"></u-checkbox>
2023-12-04 16:35:09 +08:00
</u-checkbox-group>
</view>
</view>
2023-12-07 18:28:31 +08:00
<view class="desc" v-if="gradeDiscount.length>0">
2023-12-04 16:35:09 +08:00
<view style="display: flex;">
<u-collapse>
<u-collapse-item title="会员等级优惠" :open="true">
<view v-for="(item,index) in gradeDiscount" :key="index">
<span v-if="item.type=='满减优惠'">
{{item.type}}:{{item.full}}{{item.reduce}}
</span>
<span v-else>
{{item.type}}:{{item.full}}每升<br/>优惠{{item.liters}}
</span>
</view>
</u-collapse-item>
</u-collapse>
<!-- 会员等级优惠gradeDiscount -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">-{{gradeRedece}}</span>
<u-checkbox-group>
2023-12-07 18:28:31 +08:00
<u-checkbox v-model="grade" @change="changeGrade"></u-checkbox>
2023-12-04 16:35:09 +08:00
</u-checkbox-group>
</view>
</view>
2023-12-06 18:36:10 +08:00
<view v-if="exclusion == 0">
2023-12-07 18:28:31 +08:00
<view class="desc" v-if="fullRedece >= couponRedece && fullReduceDiscount.length > 0">
2023-12-06 18:36:10 +08:00
<view style="display: flex;">
<u-collapse>
<u-collapse-item title="满减优惠" :open="true">
<view v-for="(item,index) in fullReduceDiscount" :key="index">
<span v-if="item.discount!=0">
{{item.type}}:{{ item.full }}{{ item.discount }}
</span>
<span v-else>{{ item.full }}{{ item.reduce }}</span>
</view>
</u-collapse-item>
</u-collapse>
<!-- 满减优惠fullReduceDiscount -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">-{{fullRedece}}</span>
<u-checkbox-group>
2023-12-07 18:28:31 +08:00
<u-checkbox v-model="full" @change="changeFull"></u-checkbox>
2023-12-06 18:36:10 +08:00
</u-checkbox-group>
</view>
2023-12-04 16:35:09 +08:00
</view>
2023-12-06 18:36:10 +08:00
2023-12-07 18:28:31 +08:00
<view class="desc" v-else-if="fullRedece < couponRedece && couponDiscount > 0">
2023-12-06 18:36:10 +08:00
<view style="display: flex;">
<u-collapse>
<u-collapse-item title="优惠券" :open="true">
<view v-for="(item,index) in couponDiscount" :key="index">
{{ item.full }}{{ item.reduce }}
</view>
</u-collapse-item>
</u-collapse>
<!-- 优惠券 couponDiscount -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">-{{couponRedece}}</span>
<u-checkbox-group>
2023-12-07 18:28:31 +08:00
<u-checkbox v-model="coupon" @change="changeCoupon"></u-checkbox>
2023-12-06 18:36:10 +08:00
</u-checkbox-group>
</view>
2023-12-04 16:35:09 +08:00
</view>
</view>
2023-12-06 18:36:10 +08:00
<view v-else>
2023-12-07 18:28:31 +08:00
<view class="desc" v-if="fullRedece >= 0 && fullReduceDiscount.length>0">
2023-12-06 18:36:10 +08:00
<view style="display: flex;">
<u-collapse>
<u-collapse-item title="满减优惠" :open="true">
<view v-for="(item,index) in fullReduceDiscount" :key="index">
<span v-if="item.discount!=0">
{{item.type}}:{{ item.full }}{{ item.discount }}
</span>
<span v-else>{{ item.full }}{{ item.reduce }}</span>
</view>
</u-collapse-item>
</u-collapse>
<!-- 满减优惠fullReduceDiscount -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">-{{fullRedece}}</span>
<u-checkbox-group>
2023-12-07 18:28:31 +08:00
<u-checkbox v-model="full" @change="changeFull"></u-checkbox>
2023-12-06 18:36:10 +08:00
</u-checkbox-group>
</view>
2023-12-04 16:35:09 +08:00
</view>
2023-12-06 18:36:10 +08:00
2023-12-07 18:28:31 +08:00
<view class="desc" v-if="couponRedece >= 0 && couponDiscount.length>0">
2023-12-06 18:36:10 +08:00
<view style="display: flex;">
<u-collapse>
<u-collapse-item title="优惠券" :open="true">
<view v-for="(item,index) in couponDiscount" :key="index">
{{ item.full }}{{ item.reduce }}
</view>
</u-collapse-item>
</u-collapse>
<!-- 优惠券 couponDiscount -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">-{{couponRedece}}</span>
<u-checkbox-group>
2023-12-07 18:28:31 +08:00
<u-checkbox v-model="coupon" @change="changeCoupon"></u-checkbox>
2023-12-06 18:36:10 +08:00
</u-checkbox-group>
</view>
2023-12-01 15:47:01 +08:00
</view>
</view>
2023-12-06 18:36:10 +08:00
2023-12-08 15:48:54 +08:00
<view style="margin: 10px 20px 0;color: red;font-size: 12px;">囤油卡不参与任何优惠活动</view>
2023-12-01 15:47:01 +08:00
</view>
2023-12-01 16:40:20 +08:00
2023-12-01 15:47:01 +08:00
<view style="background-color: white;width: 94%;margin: 15px auto;">
2023-12-01 16:40:20 +08:00
<view style="font-weight: bold;height: 40px;line-height: 40px;margin-left: 10px;margin-top: 20px;">支付方式
</view>
2023-12-18 18:44:02 +08:00
<!-- <view class="desc">
2023-12-01 15:47:01 +08:00
<view>微信支付</view>
<u-radio-group v-model="value">
<u-radio name="wx"></u-radio>
</u-radio-group>
2023-12-18 18:44:02 +08:00
</view> -->
<view class="scc">
<image src="@/static/imgs/wechat.png" class="imgIcon"></image>
<span style="width: 70%;margin-top: 5px;">微信支付</span>
<radio value="r1" checked="true" />
2023-12-01 15:47:01 +08:00
</view>
</view>
<!-- 支付信息 -->
<view class="bar">
<view style="margin-left: 20px;">
<view>
2023-12-04 16:35:09 +08:00
<span style="font-size: 22px;font-weight: bold;">{{payAmount}}</span>
2023-12-01 15:47:01 +08:00
</view>
<view style="color: red;font-size: 12px;">应付金额</view>
</view>
2023-12-06 18:36:10 +08:00
<view @click="payment"
2023-12-01 16:40:20 +08:00
style="margin-right: 20px;width: 30%;border-radius:30px;background-color: #1879ff;height: 40px;line-height: 40px;text-align: center;color: white">
2023-12-01 15:47:01 +08:00
确认支付
</view>
</view>
</view>
</view>
</template>
<script>
import request from '../../utils/request'
export default {
data() {
return {
2023-12-07 18:28:31 +08:00
gradeDis:"",
2023-12-01 15:47:01 +08:00
title: '',
2023-12-08 15:48:54 +08:00
value: true,
2023-12-01 16:40:20 +08:00
orderNo: "",
2023-12-01 15:47:01 +08:00
// 油品订单信息
2023-12-01 16:40:20 +08:00
oilOrder: {},
2023-12-01 15:47:01 +08:00
// 员工列表信息
staff: {},
// 店铺信息
2023-12-01 16:40:20 +08:00
store: {},
oilPrice: 0,
2023-12-01 15:47:01 +08:00
// 油品名称
2023-12-01 16:40:20 +08:00
oilName: "",
2023-12-04 16:35:09 +08:00
// 油品类型
oilType:"",
// 用户信息
user:{
cardBalance:0,
},
2023-12-07 18:28:31 +08:00
balance:true,
2023-12-04 16:35:09 +08:00
grade:false,
oilCard:false,
coupon:false,
2023-12-07 18:28:31 +08:00
full:false,
2023-12-04 16:35:09 +08:00
// 会员等级信息
userGrade:{},
balanceRedece:0,
oilCardRedece:0,
gradeRedece:0,
fullRedece:0,
couponRedece:0,
hoardAmount:0,
// 囤油卡信息
refuelMoney:[],
// 会员等级优惠信息
gradeDiscount:[],
// 优惠券优惠信息
couponDiscount:[],
// 满减优惠信息
fullReduceDiscount:[],
payAmount:0,
// 查询优惠活动信息所需参数
preferentialData:{
userId:"",
storeId:"",
gradeId:"",
oilName:"",
oilPrice:"",
oilLiters:"",
},
// 互斥限制 -1没有限制 0满减互斥 1储值卡互斥
exclusion:-1,
// 是否为满减互斥
isUseFull:false,
// 是否为储值卡互斥
isUseBalance:false,
// 是否使用囤油卡
isOilStorageCard:false,
2023-12-07 18:28:31 +08:00
// 是否使用会员等级优惠
isUseGrade:false,
2023-12-01 15:47:01 +08:00
}
},
onLoad(e) {
2023-12-19 18:03:05 +08:00
this.orderNo = e.orderNo
// this.orderNo = "2345202312191043054f3328"
2023-12-01 15:47:01 +08:00
},
onShow() {
this.getOilOrder();
},
components: {
},
methods: {
2023-12-07 18:28:31 +08:00
changeBalance(val){
if(val){
this.balanceRedece = 0
this.isUseBalance = false;
2023-12-08 15:48:54 +08:00
// this.balance = true
2023-12-07 18:28:31 +08:00
}else{
2023-12-08 15:48:54 +08:00
// this.balance = false
2023-12-07 18:28:31 +08:00
this.isUseBalance = true;
2023-12-08 15:48:54 +08:00
this.isOilStorageCard = false;
this.oilCardRedece = 0;
2023-12-07 18:28:31 +08:00
}
this.isExclusion()
console.log(111,val,this.balance)
},
changeOilCard(val){
if(val == false){
this.oilCardRedece = 0
this.oilCard = true
2023-12-08 15:48:54 +08:00
this.isOilStorageCard = false
this.balance = true
2023-12-07 18:28:31 +08:00
}else{
this.oilCardRedece = this.oilOrder.oilNum
this.oilCard = false
2023-12-08 15:48:54 +08:00
this.isOilStorageCard = true
this.isUseBalance = false;
this.balance = false
2023-12-07 18:28:31 +08:00
}
this.isExclusion()
console.log(1,val,this.grade,this.oilOrder.oilNum)
},
changeGrade(val){
if(val == false){
this.gradeRedece = 0
this.grade = true
}else{
this.gradeRedece = 0
this.gradeDiscount.forEach(item => {
this.gradeRedece += +item.reduce
})
this.grade = false
}
this.isExclusion()
console.log(222,this.gradeDiscount,this.grade)
},
changeFull(val){
if(val == false){
this.fullRedece = 0
this.full = true
}else{
this.fullRedece = 0
this.fullReduceDiscount.forEach(item => {
this.fullRedece += +item.reduce
})
this.full = false
}
this.isExclusion()
console.log(333,val,this.full)
},
changeCoupon(val){
if(val == false){
this.couponRedece = 0
this.coupon = true
}else{
this.couponRedece = 0
this.couponDiscount.forEach(item => {
this.couponRedece += +item.reduce
})
this.coupon = false
}
this.isExclusion()
console.log(444,val,this.coupon)
},
closeDropdown() {
this.$refs.uDropdown.close();
},
2023-12-06 18:36:10 +08:00
// 支付接口
payment(){
2023-12-08 15:48:54 +08:00
let refuel = this.refuelMoney
refuel.refuelMoney = this.refuelMoney.refuelMoney - this.oilCardRedece
2023-12-06 18:36:10 +08:00
let map = {
2023-12-08 15:48:54 +08:00
orderNo : this.orderNo,
payAmount : this.payAmount,
// payAmount : "0.01",
discountAmount : this.fullRedece+this.gradeRedece+this.couponRedece,
oilCardAmount : JSON.stringify(refuel),
oilCardLiters : this.oilCardRedece,
2023-12-06 18:36:10 +08:00
balanceAmount : this.balanceRedece,
2023-12-08 15:48:54 +08:00
isOilStorageCard : this.isOilStorageCard,
tankId : uni.getStorageSync("tankId"),
// tankId : 6,
2023-12-06 18:36:10 +08:00
};
let _this = this;
2023-12-05 17:18:27 +08:00
request({
2023-12-06 18:36:10 +08:00
url: "business/oilOrder/appletPay",
2023-12-05 17:18:27 +08:00
method: 'post',
2023-12-06 18:36:10 +08:00
data: map,
2023-12-05 17:18:27 +08:00
}).then(res => {
console.log(res)
})
},
2023-12-04 16:35:09 +08:00
// 囤油卡变化后总金额的变化
changeRefuelMoney(){
let _this = this;
_this.consumeRefuelMoney = 0;
_this.oilActualPay = 0;
_this.hoardAmount = 0;
let conRefMon = 0;
let hoardAmount = 0;
if (_this.refuelMoney!=null){
_this.refuelMoney.forEach(item => {
if (item.oilType == _this.oilName){
_this.isOilStorageCard = true
if ((item.refuelMoney-_this.oilOrder.oilNum)>=0){
conRefMon = _this.oilOrder.oilNum
}else {
conRefMon = item.refuelMoney
// 扣除升数后需要消费的金额
2023-12-08 15:48:54 +08:00
hoardAmount = _this.oilOrder.orderAmount - +(item.refuelMoney * _this.oilPrice).toFixed(2)
2023-12-04 16:35:09 +08:00
}
}
})
}
_this.oilCardRedece += +conRefMon
if (_this.oilCardRedece!=0){
_this.isOilStorageCard = true;
_this.balanceRedece = 0;
}
_this.hoardAmount += +hoardAmount
_this.isExclusion();
},
// 使用囤油卡 囤油卡不参与任何优惠
countOilCard(){
if (this.hoardAmount!=0){
if (this.user.cardBalance!=0 && this.user.cardBalance >= (this.oilOrder.orderAmount - this.hoardAmount)) {
this.payAmount = 0
this.balanceRedece = this.hoardAmount
}else{
this.payAmount = (this.oilOrder.orderAmount - this.hoardAmount - this.user.cardBalance).toFixed(2)
}
}else{
2023-12-08 15:48:54 +08:00
this.payAmount = 0
this.balanceRedece = 0
2023-12-04 16:35:09 +08:00
}
console.log("oil",this.hoardAmount,this.payAmount)
},
// 使用优惠券不使用满减
countAmountFull(){
if (this.user.cardBalance >= (this.oilOrder.orderAmount-this.gradeRedece - this.couponRedece)) {
this.payAmount = 0
this.balanceRedece = (this.oilOrder.orderAmount-this.gradeRedece - this.couponRedece).toFixed(2)
}else{
this.balanceRedece = this.user.cardBalance
this.payAmount = (this.oilOrder.orderAmount - this.gradeRedece - this.couponRedece - this.user.cardBalance).toFixed(2)
}
console.log("coup",this.payAmount)
},
// 使用优惠券和满减不使用储值卡
countAmountUnBalance(){
if (this.fullRedece >= this.couponRedece && this.exclusion == 0) {
this.payAmount = (this.oilOrder.orderAmount - this.gradeRedece - this.fullRedece).toFixed(2)
}else if (this.fullRedece < this.couponRedece && this.exclusion == 0) {
this.payAmount = (this.oilOrder.orderAmount - this.gradeRedece - this.couponRedece).toFixed(2)
}else{
this.payAmount = (this.oilOrder.orderAmount - this.gradeRedece - this.couponRedece - this.fullRedece).toFixed(2)
}
this.balanceRedece = 0
console.log("full",this.payAmount,this.exclusion)
},
// 使用储值卡不使用优惠券 || 使用满减不使用优惠券
countAmountBalance(){
if (this.user.cardBalance >= (this.oilOrder.orderAmount-this.gradeRedece - this.fullRedece)) {
this.payAmount = 0
this.balanceRedece = (this.oilOrder.orderAmount-this.gradeRedece - this.fullRedece).toFixed(2)
}else{
this.balanceRedece = this.user.cardBalance
this.payAmount = (this.oilOrder.orderAmount-this.gradeRedece - this.fullRedece - this.user.cardBalance).toFixed(2)
}
2023-12-07 18:28:31 +08:00
console.log("balance",this.gradeRedece,this.payAmount)
2023-12-04 16:35:09 +08:00
},
// 判断互斥限制
isExclusion(){
if (this.exclusion == 1){
// 不使用满减
if (this.isUseBalance){
this.countAmountFull()
return;
}
// 储值卡互斥
if (this.isUseBalance){
this.countAmountUnBalance()
return;
}else {
this.countAmountBalance()
return;
}
}else if (this.exclusion == 0){
// 满减互斥
// 不使用储值卡
if (this.isUseBalance){
this.countAmountUnBalance()
return;
}
if (this.isUseFull){
this.countAmountFull()
return;
}else {
this.countAmountBalance()
return;
}
}else {
2023-12-18 18:44:02 +08:00
// 使用囤油卡
if (this.isOilStorageCard){
this.fullRedece = 0;
this.gradeRedece = 0;
this.couponRedece = 0;
this.countOilCard();
return;
}
2023-12-04 16:35:09 +08:00
// 无互斥
// 不使用储值卡
if (this.isUseBalance){
this.countAmountUnBalance()
return;
}
// 不使用满减
if (this.isUseBalance){
this.countAmountFull()
return;
}
this.countAmountBalance();
}
},
// 调用优惠券接口
getCoupon(){
let _this = this;
_this.couponDiscount =[];
request({
url: "business/marketingActivity/activeExchange/selectCardFavorableList",
method: 'get',
params: _this.preferentialData,
}).then(response => {
2023-12-07 18:28:31 +08:00
console.log(response)
2023-12-04 16:35:09 +08:00
_this.couponRedece = 0;
if (response.data.length>0){
response.data.forEach(item => {
_this.useCouponIds = item.id
let discount = {type:item.type,discountType:item.discountType,name:item.name,oilName:_this.oilOrder.oils,full:0,reduce:0,discount:0}
discount.full = item.satisfiedAmount
if (item.type==0){
// 油品券
if (item.discountType==0){
// 满减券
discount.reduce = item.discountAmount
}else {
// 折扣券
discount.discount = item.specialDiscount
discount.reduce = item.discountOffset
}
}else if (item.type==1){
// 商品券
if (item.discountType==0){
// 满减券
discount.reduce = item.discountAmount
}else {
// 折扣券
discount.discount = item.specialDiscount
discount.reduce = item.discountOffset
}
}else {
// 通用券
if (item.discountType==0){
// 满减券
discount.reduce = item.discountAmount
}else {
// 折扣券
discount.discount = item.specialDiscount
discount.reduce = item.discountOffset
}
}
if (discount.reduce!=0){
if (_this.couponDiscount.length!=0){
_this.couponDiscount.forEach(item2 => {
if (item2.oilName!=discount.oilName) {
_this.couponDiscount.push(discount)
_this.couponRedece = discount.reduce
}
if (item2.name!=discount.name && item2.oilName==discount.oilName) {
_this.couponDiscount.push(discount)
_this.couponRedece = discount.reduce
}
})
}else {
_this.couponDiscount.push(discount)
_this.couponRedece = discount.reduce
}
}
if (item.exclusiveFunction == 0){
// 满减互斥
_this.fullRedece = 0
_this.isUseFull = true;
}else {
// 储值卡付款互斥
_this.couponRedece = 0;
_this.isUseBalance = true;
}
_this.exclusion = item.exclusiveFunction
})
}
_this.isExclusion();
})
},
// 获取优惠活动信息
preferential(){
let _this = this;
let fullReduction = 0;
_this.fullReduction = 0;
request({
url: "business/marketingActivity/activeExchange/selectConsumptionList",
method: 'get',
params: _this.preferentialData,
}).then( response => {
if (response.data.length>0){
_this.fullReduceDiscount = []
response.data.forEach(item => {
if (item.participationCondition==1){
_this.exclusion = 0
}
let discount = {type:item.name,full:0,reduce:0,discount:0,exclusion:item.participationCondition}
let activeList = item.activeDiscountChildList;
2023-12-07 18:28:31 +08:00
if (activeList.length>0){
for (let i = 1;i<=activeList.length;i++){
if (activeList.length>0){
if (activeList[0].discount != null){
// 折扣营销
if (_this.oilOrder.orderAmount>=activeList[0].amount){
discount.full = activeList[0].amount;
discount.discount = activeList[0].discount;
discount.reduce = _this.oilOrder.orderAmount - (_this.oilOrder.orderAmount * (activeList[0].discount / 10)).toFixed(2)
fullReduction = _this.oilOrder.orderAmount - (_this.oilOrder.orderAmount * (activeList[0].discount / 10)).toFixed(2);
}
}else {
// 满减
if (_this.oilOrder.orderAmount>=activeList[0].amount){
discount.full = activeList[0].amount;
discount.reduce = activeList[0].deductionAmount;
fullReduction = activeList[0].deductionAmount;
}
}
2023-12-04 16:35:09 +08:00
}
}
}
if (activeList.length==0){
fullReduction = 0
}
if (discount.reduce!=0){
_this.fullReduceDiscount.push(discount)
}
_this.fullRedece += +fullReduction
})
}
if (_this.isUseFull){
_this.fullReduction = 0
}
})
},
// 根据等级id获取会员等级信息
getGrade(id){
let _this = this;
request({
url: "business/userManager/userGrade/isUse/" + id,
method: 'get',
}).then((response) => {
let gasolineDiscount = 0;
let dieselDiscount = 0;
let naturalGasDiscount = 0;
_this.gradeDiscount = [];
_this.userGrade = response.data
if (response.data != null) {
let discount = {type: "", full: 0, reduce: 0, liters: 0}
if (response.data.preferential == '自定义优惠' && response.data.status == 'qy') {
if (_this.oilType == "汽油") {
let gasolineRule = JSON.parse(response.data.gasolineRule);
if (response.data.gasolineDiscount == "满减优惠") {
let oilDiscount = 0;
discount.type = "满减优惠"
for (let i = 1; i <= gasolineRule.length; i++) {
// 将满减条件加入等级优惠列表
if (gasolineRule.length > 1) {
if (_this.oilOrder.orderAmount >= gasolineRule[gasolineRule.length - 1].gasolineRule1) {
discount.full = gasolineRule[gasolineRule.length - 1].gasolineRule1
oilDiscount = gasolineRule[gasolineRule.length - 1].gasolineRule2
discount.reduce = gasolineRule[gasolineRule.length - 1].gasolineRule2
break;
}
if (_this.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1 && _this.oilOrder.orderAmount < gasolineRule[i].gasolineRule1) {
discount.full = gasolineRule[i - 1].gasolineRule1
oilDiscount = gasolineRule[i - 1].gasolineRule2
discount.reduce = gasolineRule[i - 1].gasolineRule2
}
} else {
if (_this.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1) {
discount.full = gasolineRule[i - 1].gasolineRule1
oilDiscount = gasolineRule[i - 1].gasolineRule2
discount.reduce = gasolineRule[i - 1].gasolineRule2
}
}
}
if (discount.reduce != 0) {
_this.gradeDiscount.push(discount)
}
gasolineDiscount += +oilDiscount
} else if (response.data.gasolineDiscount == "每升优惠") {
discount.type = "每升优惠"
let oilDiscount = 0;
for (let i = 1; i <= gasolineRule.length; i++) {
// 将满减条件加入等级优惠列表
if (gasolineRule.length > 1) {
if (_this.oilOrder.orderAmount >= gasolineRule[gasolineRule.length - 1].gasolineRule1) {
discount.full = gasolineRule[gasolineRule.length - 1].gasolineRule1
oilDiscount = (_this.oilOrder.oilNum * gasolineRule[gasolineRule.length - 1].gasolineRule3).toFixed(2);
discount.reduce = (_this.oilOrder.oilNum * gasolineRule[gasolineRule.length - 1].gasolineRule3).toFixed(2);
discount.liters = gasolineRule[i - 1].gasolineRule3
break;
}
if (_this.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1 && _this.oilOrder.orderAmount < gasolineRule[i].gasolineRule1) {
discount.full = gasolineRule[i - 1].gasolineRule1
oilDiscount = (_this.oilOrder.oilNum * gasolineRule[i - 1].gasolineRule3).toFixed(2)
discount.reduce = (_this.oilOrder.oilNum * gasolineRule[i - 1].gasolineRule3).toFixed(2)
discount.liters = gasolineRule[i - 1].gasolineRule3
}
} else {
if (_this.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1) {
discount.full = gasolineRule[i - 1].gasolineRule1
oilDiscount = (_this.oilOrder.oilNum * gasolineRule[i - 1].gasolineRule3).toFixed(2)
discount.reduce = (_this.oilOrder.oilNum * gasolineRule[i - 1].gasolineRule3).toFixed(2)
discount.liters = gasolineRule[i - 1].gasolineRule3
}
}
}
if (discount.reduce != 0) {
_this.gradeDiscount.push(discount)
}
gasolineDiscount += +oilDiscount
} else {
gasolineDiscount = 0;
}
}
if (_this.oilType == "柴油") {
let dieselRule = JSON.parse(response.data.dieselRule);
if (response.data.dieselDiscount == "满减优惠") {
let oilDiscount = 0;
discount.type = "满减优惠"
for (let i = 1; i <= dieselRule.length; i++) {
// 将满减条件加入等级优惠列表
if (dieselRule.length > 1) {
if (_this.oilOrder.orderAmount >= dieselRule[dieselRule.length - 1].dieselRule1) {
discount.full = dieselRule[dieselRule.length - 1].dieselRule1
oilDiscount = dieselRule[dieselRule.length - 1].dieselRule2
discount.reduce = dieselRule[dieselRule.length - 1].dieselRule2
break;
}
if (_this.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && _this.oilOrder.orderAmount < dieselRule[i].dieselRule1) {
discount.full = dieselRule[i - 1].dieselRule1
oilDiscount = dieselRule[i - 1].dieselRule2
discount.reduce = dieselRule[i - 1].dieselRule2
}
} else {
discount.full = dieselRule[i - 1].dieselRule1
if (_this.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1) {
oilDiscount = dieselRule[i - 1].dieselRule2
discount.reduce = dieselRule[i - 1].dieselRule2
}
}
}
if (discount.reduce != 0) {
_this.gradeDiscount.push(discount)
}
dieselDiscount += +oilDiscount
} else if (response.data.dieselDiscount == "每升优惠") {
let oilDiscount = 0;
for (let i = 1; i <= dieselRule.length; i++) {
discount.type = "每升优惠"
// 将满减条件加入等级优惠列表
if (dieselRule.length > 1) {
if (_this.oilOrder.orderAmount >= dieselRule[dieselRule.length - 1].dieselRule1) {
discount.full = dieselRule[dieselRule.length - 1].dieselRule1
oilDiscount = (_this.oilOrder.oilNum * dieselRule[dieselRule.length - 1].dieselRule3).toFixed(2);
discount.reduce = (_this.oilOrder.oilNum * dieselRule[dieselRule.length - 1].dieselRule3).toFixed(2);
discount.liters = dieselRule[dieselRule.length - 1].dieselRule3
break;
}
if (_this.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && _this.oilOrder.orderAmount < dieselRule[i].dieselRule1) {
discount.full = dieselRule[i - 1].dieselRule1
oilDiscount = (_this.oilOrder.oilNum * dieselRule[i - 1].dieselRule3).toFixed(2)
discount.reduce = (_this.oilOrder.oilNum * dieselRule[i - 1].dieselRule3).toFixed(2)
discount.liters = dieselRule[i - 1].dieselRule3
}
} else {
discount.full = dieselRule[i - 1].dieselRule1
if (_this.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1) {
oilDiscount = (_this.oilOrder.oilNum * dieselRule[i - 1].dieselRule3).toFixed(2)
discount.reduce = (_this.oilOrder.oilNum * dieselRule[i - 1].dieselRule3).toFixed(2)
discount.liters = dieselRule[i - 1].dieselRule3
}
}
}
if (discount.reduce != 0) {
_this.gradeDiscount.push(discount)
}
dieselDiscount += +oilDiscount
} else {
dieselDiscount = 0;
}
}
if(_this.oilType == "天然气") {
let naturalGasRule = JSON.parse(response.data.naturalGasRule);
if (response.data.naturalGasDiscount == "满减优惠") {
let oilDiscount = 0;
discount.type = "满减优惠"
for (let i = 1; i <= naturalGasRule.length; i++) {
// 将满减条件加入等级优惠列表
if (naturalGasRule.length > 1) {
if (_this.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length - 1].naturalGasRule1) {
discount.full = naturalGasRule[naturalGasRule.length - 1].naturalGasRule1
oilDiscount = naturalGasRule[naturalGasRule.length - 1].naturalGasRule2;
discount.reduce = naturalGasRule[naturalGasRule.length - 1].naturalGasRule2
break;
}
if (_this.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1 && _this.oilOrder.orderAmount < naturalGasRule[i].naturalGasRule1) {
discount.full = naturalGasRule[i - 1].naturalGasRule1
oilDiscount = naturalGasRule[i - 1].naturalGasRule2
discount.reduce = naturalGasRule[i - 1].naturalGasRule2
}
} else {
if (_this.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1) {
discount.full = naturalGasRule[i - 1].naturalGasRule1
oilDiscount = naturalGasRule[i - 1].naturalGasRule2
discount.reduce = naturalGasRule[i - 1].naturalGasRule2
}
}
}
if (discount.reduce != 0) {
_this.gradeDiscount.push(discount)
}
naturalGasDiscount += +oilDiscount
} else if (response.data.naturalGasDiscount == "每单位优惠") {
let oilDiscount = 0;
discount.type = "每单位优惠"
for (let i = 1; i <= naturalGasRule.length; i++) {
// 将满减条件加入等级优惠列表
if (naturalGasRule.length > 1) {
if (_this.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length - 1].naturalGasRule1) {
discount.full = naturalGasRule[naturalGasRule.length - 1].naturalGasRule1
oilDiscount = (_this.oilOrder.oilNum * naturalGasRule[gasolineRule.length - 1].naturalGasRule3).toFixed(2)
discount.reduce = (_this.oilOrder.oilNum * naturalGasRule[gasolineRule.length - 1].naturalGasRule3).toFixed(2)
discount.liters = naturalGasRule[naturalGasRule.length - 1].naturalGasRule3
break;
}
if (_this.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1 && _this.oilOrder.orderAmount < naturalGasRule[i].naturalGasRule1) {
discount.full = naturalGasRule[i - 1].naturalGasRule1
oilDiscount = (_this.oilOrder.oilNum * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
discount.reduce = (_this.oilOrder.oilNum * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
discount.liters = naturalGasRule[i - 1].naturalGasRule3
}
} else {
if (_this.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1) {
discount.full = naturalGasRule[i - 1].naturalGasRule1
oilDiscount = (_this.oilOrder.oilNum * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
discount.reduce = (_this.oilOrder.oilNum * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
discount.liters = naturalGasRule[i - 1].naturalGasRule3
}
}
}
if (discount.reduce != 0) {
_this.gradeDiscount.push(discount)
}
naturalGasDiscount += +oilDiscount
} else {
naturalGasDiscount = 0;
}
}
}
_this.gradeRedece = gasolineDiscount + dieselDiscount + naturalGasDiscount
}
2023-12-07 18:28:31 +08:00
this.balance = true
2023-12-04 16:35:09 +08:00
})
},
// 根据用户id查询用户信息
getUser(id){
let _this = this;
request({
url: "business/userManager/user/" + id,
method: 'get',
}).then((res) => {
_this.user = res.data;
2023-12-06 18:36:10 +08:00
if (res.data.refuelMoney!=null && res.data.refuelMoney!=""){
_this.refuelMoney = JSON.parse(res.data.refuelMoney)
}
2023-12-04 16:35:09 +08:00
_this.changeRefuelMoney()
_this.preferentialData.oilPrice = _this.oilPrice
_this.preferentialData.gradeId = res.data.gradeId
_this.preferential()
_this.getCoupon()
2023-12-07 18:28:31 +08:00
_this.getGrade(res.data.gradeId)
2023-12-04 16:35:09 +08:00
})
},
2023-12-01 15:47:01 +08:00
// 获取油品订单
2023-12-01 16:40:20 +08:00
getOilOrder() {
2023-12-01 15:47:01 +08:00
let _this = this;
request({
url: "business/oilOrder/orderNo",
method: 'post',
2023-12-01 16:40:20 +08:00
data: {
orderNo: _this.orderNo
},
}).then((res) => {
2023-12-01 15:47:01 +08:00
_this.oilOrder = res.data
_this.getStaffList(res.data.staffId)
_this.getStore(res.data.storeId)
_this.getOilNumber(res.data.storeId)
2023-12-04 16:35:09 +08:00
_this.getUser(res.data.userId)
_this.preferentialData.storeId = res.data.storeId
_this.preferentialData.userId = res.data.userId
_this.preferentialData.oilName = res.data.oils
_this.preferentialData.oilLiters = res.data.oilNum
2023-12-01 15:47:01 +08:00
})
},
// 获取门店信息
2023-12-01 16:40:20 +08:00
getStore(id) {
2023-12-01 15:47:01 +08:00
let _this = this;
request({
url: "business/storeInformation/store/queryStoreById",
method: 'post',
2023-12-01 16:40:20 +08:00
data: {
"storeId": id
},
}).then((res) => {
2023-12-01 15:47:01 +08:00
_this.store = res.data;
})
},
// 根据员工id获取员工信息
2023-12-01 16:40:20 +08:00
getStaffList(staffId) {
2023-12-01 15:47:01 +08:00
let _this = this;
request({
url: "business/member/staff/" + staffId,
method: 'get',
2023-12-01 16:40:20 +08:00
}).then((res) => {
2023-12-01 15:47:01 +08:00
_this.staff = res.data
})
},
// 获取当前店铺油号信息
2023-12-01 16:40:20 +08:00
getOilNumber(storeId) {
2023-12-01 15:47:01 +08:00
let _this = this;
request({
url: "business/petrolStationManagement/oilNumber/getOilNumberName/" + storeId,
method: 'get',
2023-12-01 16:40:20 +08:00
}).then((res) => {
2023-12-01 15:47:01 +08:00
res.data.forEach(item => {
2023-12-01 16:40:20 +08:00
if (item.oilName == _this.oilOrder.oils) {
2023-12-01 15:47:01 +08:00
_this.oilPrice = item.gbPrice;
_this.oilName = item.oilNames;
2023-12-04 16:35:09 +08:00
_this.oilType = item.oilType;
2023-12-01 15:47:01 +08:00
}
})
})
},
goBack() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
2023-12-18 18:44:02 +08:00
.scc{
display: flex;
justify-content: space-around;
margin-top: 10px;
height: 40px;
font-size: 18px;
line-height: 40px;
}
.imgIcon{
width: 30px;
height: 30px;
border-radius: 50%;
margin-top: 10px;
}
2023-12-01 16:40:20 +08:00
.desc {
2023-12-01 15:47:01 +08:00
height: 35px;
line-height: 35px;
margin-left: 20px;
margin-right: 20px;
display: flex;
justify-content: space-between;
font-size: 15px;
color: rgba(0, 0, 0, 0.65);
}
2023-12-01 16:40:20 +08:00
2023-12-01 15:47:01 +08:00
.bar {
width: 100%;
height: 70px;
background-color: white;
position: fixed;
bottom: 0px;
display: flex;
align-items: center;
justify-content: space-between;
}
2023-12-01 16:40:20 +08:00
2023-12-01 15:47:01 +08:00
.content {
background: #f4f5f6;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
</style>