【类 型】:fix

【主	题】:
【描	述】:退款功能
	[原因]:添加退款方法
	[过程]:向后端退款接口请求  规矩回调 订阅  更新订单状态
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
tk 2024-06-27 20:43:05 +08:00
parent 06439ccb1b
commit 6ec5717fa0
7 changed files with 116 additions and 77 deletions

View File

@ -8,16 +8,10 @@
export default { export default {
props: { props: {
startDate: { startDate: {
type: Number, type: Number
default () {
return Math.floor(new Date(new Date().setHours(0, 0, 0, 0)).getTime() / 1000)
}
}, },
endDate: { endDate: {
type: Number, type: Number
default () {
return Math.floor(new Date(new Date().setHours(23, 59, 59, 999)).getTime() / 1000)
}
} }
}, },
data () { data () {

View File

@ -51,7 +51,8 @@
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="操作" span="3"> <el-descriptions-item label="操作" span="3">
<el-button-group v-if="item.refund_status == '申请中'"> <el-button-group v-if="item.refund_status == '申请中'">
<el-button type="danger" icon="iconfont icon-zhengque"> <el-button type="danger" icon="iconfont icon-zhengque"
@click="refund(item.order_sn, item.shop_id, item.total_price, '已同意')">
<font class="m-l-5">同意退款</font> <font class="m-l-5">同意退款</font>
</el-button> </el-button>
<el-button @click="questAss(item.id, 'refund_status', '拒绝退')" type="warning" icon="iconfont icon-cuowu"> <el-button @click="questAss(item.id, 'refund_status', '拒绝退')" type="warning" icon="iconfont icon-cuowu">
@ -100,7 +101,7 @@
<script> <script>
import { parseTime } from '@/utils/index' import { parseTime } from '@/utils/index'
import { questAss } from '@/utils/api/table' import { questAss, refund } from '@/utils/api/table'
export default { export default {
data () { data () {
@ -115,6 +116,7 @@ export default {
}, },
methods: { methods: {
questAss, // questAss, //
refund, // 退
parseTime, // parseTime, //
/** /**
* @description: 通过蓝牙打印机并打印小票 * @description: 通过蓝牙打印机并打印小票

View File

@ -40,6 +40,7 @@ export default {
tempPath: tempPath, tempPath: tempPath,
apiPlanePath: '/mpApi/Plane/', apiPlanePath: '/mpApi/Plane/',
apiAdminPath: '/mpApi/Admin/', apiAdminPath: '/mpApi/Admin/',
apiPayPath: '/mpApi/Pay/',
apiLoginPath: '/mpApi/Login/', apiLoginPath: '/mpApi/Login/',
/** /**
* @description: mqtt服务器 * @description: mqtt服务器

View File

@ -13,6 +13,7 @@ const {
tempPath, tempPath,
apiPlanePath, apiPlanePath,
apiAdminPath, apiAdminPath,
apiPayPath,
apiLoginPath, apiLoginPath,
mqttHost, mqttHost,
mqttPort, mqttPort,
@ -33,6 +34,7 @@ const state = {
tempPath: tempPath, tempPath: tempPath,
apiPlanePath: apiPlanePath, apiPlanePath: apiPlanePath,
apiAdminPath: apiAdminPath, apiAdminPath: apiAdminPath,
apiPayPath: apiPayPath,
apiLoginPath: apiLoginPath, apiLoginPath: apiLoginPath,
mqttHost: mqttHost, mqttHost: mqttHost,
mqttPort: mqttPort, mqttPort: mqttPort,

View File

@ -63,6 +63,9 @@ function init (prefix) {
} else if (prefix === 'Admin') { } else if (prefix === 'Admin') {
axios.defaults.headers.common.Token = store.state.user.token axios.defaults.headers.common.Token = store.state.user.token
path = store.state.settings.apiAdminPath path = store.state.settings.apiAdminPath
} else if (prefix === 'Pay') {
axios.defaults.headers.common.Token = store.state.user.token
path = store.state.settings.apiPayPath
} else if (prefix === 'Login') { } else if (prefix === 'Login') {
axios.defaults.headers.common.Token = 'login' axios.defaults.headers.common.Token = 'login'
path = store.state.settings.apiLoginPath path = store.state.settings.apiLoginPath

View File

@ -39,3 +39,34 @@ export function questAss (id, state, val) {
} }
}) })
} }
/**
* @description: 退款函数
* @param {*} orderSn 订单号
* @param {*} shopId 商铺id
* @param {*} refundPrice 退款金额 单位元
* @param {*} refundType 退款类型
*/
export function refund (orderSn, shopId, refundPrice, refundType) {
// 构建请求参数
const params = new URLSearchParams()
params.append('order_sn', orderSn)
params.append('shop_id', shopId)
params.append('refund_price', refundPrice)
params.append('refund_type', refundType)
// 发送退款请求
api.post('refund', params, 'Pay')
.then(res => {
if (res.data.status === 1) {
Message.success('退款申请成功')
console.log('退款成功', res.data.msg)
} else {
Message.error('退款申请失败')
console.error('退款失败:', res.data.msg)
}
})
.catch(error => {
console.error('退款请求错误:', error)
})
}

View File

@ -6,7 +6,7 @@
<SelectionShopId class="w-100" v-model="shop_id" :allSel="true" /> <SelectionShopId class="w-100" v-model="shop_id" :allSel="true" />
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<DatePickerOrder class="w-100" /> <DatePickerOrder class="w-100" :startDate="startDate" :endDate="endDate" />
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<SearchOrder class="w-100" /> <SearchOrder class="w-100" />
@ -21,7 +21,7 @@
</el-col> </el-col>
</el-row> </el-row>
<!-- 订单列表 --> <!-- 订单列表 -->
<el-table class="m-t-20 w-100" ref="myTable" <!-- <el-table class="m-t-20 w-100" ref="myTable"
:data="orderListArr.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark"> :data="orderListArr.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark">
<el-table-column align="center" type="selection" width="40"> <el-table-column align="center" type="selection" width="40">
</el-table-column> </el-table-column>
@ -35,9 +35,9 @@
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.addtime | parseTime('{y}-{m}-{d} {h}:{i}') }} {{ scope.row.addtime | parseTime('{y}-{m}-{d} {h}:{i}') }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="controler" label="操作" width="380" min-width="380"> <el-table-column prop="controler" label="操作" width="380" min-width="380">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button-group> <el-button-group>
<el-button type="warning" icon="el-icon-edit">同意退款</el-button> <el-button type="warning" icon="el-icon-edit">同意退款</el-button>
<el-button type="danger" icon="el-icon-delete" @click="deleteAdmin([scope.row.id])">拒绝退款</el-button> <el-button type="danger" icon="el-icon-delete" @click="deleteAdmin([scope.row.id])">拒绝退款</el-button>
@ -45,12 +45,12 @@
@click="$router.replace(`/order/show/${scope.row.id}`)">查看</el-button> @click="$router.replace(`/order/show/${scope.row.id}`)">查看</el-button>
</el-button-group> </el-button-group>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table> -->
<!-- 分页 --> <!-- 分页 -->
<el-pagination class="m-t-20" layout="prev, pager, next" :current-page.sync="currentPage" :page-size="pageSize" <!-- <el-pagination class="m-t-20" layout="prev, pager, next" :current-page.sync="currentPage" :page-size="pageSize"
:total="orderListArr.length"> :total="orderListArr.length">
</el-pagination> </el-pagination> -->
</div> </div>
</template> </template>
@ -80,66 +80,72 @@ export default {
SearchOrder SearchOrder
}, },
computed: { computed: {
// startDate () {
orderList () { return Math.floor(new Date(new Date().setHours(0, 0, 0, 0)).getTime() / 1000)
return this.$store.state.orderList
}, },
// ( ) endDate () {
orderSerch () { return Math.floor(new Date(new Date().setHours(23, 59, 59, 999)).getTime() / 1000)
return this.$store.getters['app/getOrderSerch']
},
//
orderListArr () {
if (this.orderList.length > 0) {
let filteredList = this.orderList
// shop_id
if (this.shop_id !== '') {
filteredList = filteredList.filter(order => order.shop_id === this.shop_id)
}
//
if (this.orderSerch.start_time !== '' && this.orderSerch.end_time !== '') {
const startTime = parseInt(this.orderSerch.start_time)
const endTime = parseInt(this.orderSerch.end_time)
filteredList = filteredList.filter(order => {
const orderTime = parseInt(order.addtime)
return startTime < orderTime && orderTime < endTime
})
}
//
if (this.orderSerch.status.length > 0) {
filteredList = filteredList.filter(order => {
// this.status
return this.orderSerch.status.includes(order.status)
})
}
//
if (this.orderSerch.back.length > 0) {
filteredList = filteredList.filter(order => {
// this.status
return this.orderSerch.back.includes(order.back)
})
}
//
if (this.orderSerch.search[1] !== '') {
filteredList = filteredList.filter(order => {
if (this.orderSerch.search[0] === 'orderId') {
return order.order_sn.indexOf(this.orderSerch.search[1]) >= 0
} else if (this.orderSerch.search[0] === 'name') {
return order.receiver.indexOf(this.orderSerch.search[1]) >= 0
} else if (this.orderSerch.search[0] === 'tel') {
return order.tel.indexOf(this.orderSerch.search[1]) >= 0
} else if (this.orderSerch.search[0] === 'remark') {
return order.remark.indexOf(this.orderSerch.search[1]) >= 0
} else if (this.orderSerch.search[0] === 'desc') {
return order.describe.indexOf(this.orderSerch.search[1]) >= 0
}
})
}
return filteredList
} else {
return []
}
} }
//
// orderList () {
// return this.$store.state.orderList
// },
// // ( )
// orderSerch () {
// return this.$store.getters['app/getOrderSerch']
// },
// //
// orderListArr () {
// if (this.orderList.length > 0) {
// let filteredList = this.orderList
// // shop_id
// if (this.shop_id !== '') {
// filteredList = filteredList.filter(order => order.shop_id === this.shop_id)
// }
// //
// if (this.orderSerch.start_time !== '' && this.orderSerch.end_time !== '') {
// const startTime = parseInt(this.orderSerch.start_time)
// const endTime = parseInt(this.orderSerch.end_time)
// filteredList = filteredList.filter(order => {
// const orderTime = parseInt(order.addtime)
// return startTime < orderTime && orderTime < endTime
// })
// }
// //
// if (this.orderSerch.status.length > 0) {
// filteredList = filteredList.filter(order => {
// // this.status
// return this.orderSerch.status.includes(order.status)
// })
// }
// //
// if (this.orderSerch.back.length > 0) {
// filteredList = filteredList.filter(order => {
// // this.status
// return this.orderSerch.back.includes(order.back)
// })
// }
// //
// if (this.orderSerch.search[1] !== '') {
// filteredList = filteredList.filter(order => {
// if (this.orderSerch.search[0] === 'orderId') {
// return order.order_sn.indexOf(this.orderSerch.search[1]) >= 0
// } else if (this.orderSerch.search[0] === 'name') {
// return order.receiver.indexOf(this.orderSerch.search[1]) >= 0
// } else if (this.orderSerch.search[0] === 'tel') {
// return order.tel.indexOf(this.orderSerch.search[1]) >= 0
// } else if (this.orderSerch.search[0] === 'remark') {
// return order.remark.indexOf(this.orderSerch.search[1]) >= 0
// } else if (this.orderSerch.search[0] === 'desc') {
// return order.describe.indexOf(this.orderSerch.search[1]) >= 0
// }
// })
// }
// return filteredList
// } else {
// return []
// }
// }
}, },
methods: { methods: {
countSelIdArr countSelIdArr