Commit 18bf36d7 authored by Qingyu Deng's avatar Qingyu Deng

feat: add refund function

parent 0738ebd6
......@@ -113,15 +113,16 @@ exports.orderItemList = async ctx => {
// 订单退款列表
exports.orderRefund = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/order_refundt`;
const url = `${GROUPMEAL_URI}/order/background/order_refund`;
const opts = {
url,
method: "GET"
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
// 订单驳回
exports.orderRefundReject = async ctx => {
const url = `${GROUPMEAL_URI}/order/background/order_refund_reject`;
......
......@@ -78,6 +78,6 @@ router.get(`${API_VERSION}/order/background/order_export`, groupmeal.orderExport
router.get(`${API_VERSION}/order/background/print`, groupmeal.orderPrint);
router.get(`${API_VERSION}/order/background/order_item_list`, groupmeal.orderItemList);
router.get(`${API_VERSION}/order/background/order_refund_reject`, groupmeal.orderRefundReject);
router.get(`${API_VERSION}/order/background/order_refundt`, groupmeal.orderRefund);
router.post(`${API_VERSION}/order/background/order_refund`, groupmeal.orderRefund);
module.exports = router;
......@@ -243,19 +243,24 @@
v-model="item.refundableQuantity"
@change="handleChange"
:min="1"
:max="10"
:max="item.goods_num"
label="描述文字"
></el-input-number>
</el-row>
<el-row>
退款金额(可退金额{{ item.refundAmount }}元):
<el-input v-model="item.ipt" style="width: 150px"></el-input>
<el-input
v-model="item.amountToRefund"
style="width: 150px"
></el-input>
</el-row>
</div>
<template #footer>
<span class="dialog-footer refundBtnGroup">
<el-button @click="refundShow = false">取 消</el-button>
<el-button type="primary" @click="refundConfirm">退款</el-button>
<el-button type="primary" @click="handleConfirmRefund"
>退款</el-button
>
</span>
</template>
</el-dialog>
......@@ -274,7 +279,7 @@ import {
orderPrint,
orderItemList,
orderRefundReject,
orderRefund,
refundOrder,
} from "@/service/Groupmeal/groupmeal";
import page from "../../components/Pagination.vue";
......@@ -366,7 +371,7 @@ export default {
payment: "", // 实付
refundableQuantity: "",
refundAmount: "",
ipt: "",
amountToRefund: "",
},
],
};
......@@ -528,15 +533,37 @@ export default {
this.refundGoods = res.result;
},
// 退款确认
async refundConfirm() {
const params = {
order_id: "",
refund_list: "",
order_item_id: "",
refund_num: "",
refund_amount: "",
async handleConfirmRefund() {
const isCheckAllSelected = () => this.refundGoods.refundedGoodsSel;
const getAllItems = () => this.refundGoods;
const getSelectedItems = () => {
const isSelected = ({ refundedGoodsSel }) => refundedGoodsSel;
return this.refundGoods.filter(isSelected);
};
const convertToNumber = (str) => {
return !Number.isNaN(parseFloat(str)) ? parseFloat(str) : 0;
};
const processRefundItem = (item) => {
return {
order_item_id: item.order_item_id,
refund_num: item.refundableQuantity || 0,
refund_amount: convertToNumber(item.amountToRefund),
};
const res = await orderRefund(params);
};
const orderId = this.refundGoods[0].order_id;
let itemsToRefund = null;
if (isCheckAllSelected()) {
itemsToRefund = getAllItems();
} else {
itemsToRefund = getSelectedItems();
}
itemsToRefund = itemsToRefund.map(processRefundItem);
const res = await refundOrder(orderId, itemsToRefund);
console.log(res);
},
},
......@@ -548,5 +575,4 @@ export default {
};
</script>
<style lang="less" src="./index.less" scope>
</style>
\ No newline at end of file
<style lang="less" src="./index.less" scope></style>
import axios from "@/utils/request";
// 获取主页配送员列表
export async function getList (params) {
const res = await axios.post("/api/v1/order/deliverer/list_day_deliverer_conf",{params});
export async function getList(params) {
const res = await axios.post(
"/api/v1/order/deliverer/list_day_deliverer_conf",
{ params }
);
return res;
}
}
// 获取分配配送员列表
export async function getDelivererList (params) {
const res = await axios.post("/api/v1/order/deliverer/list_day_deliverer",params);
export async function getDelivererList(params) {
const res = await axios.post(
"/api/v1/order/deliverer/list_day_deliverer",
params
);
return res;
}
}
// 添加配送员
export async function getAddDeliverer (params) {
const res = await axios.post("/api/v1/order/deliverer/add_deliverer",params);
export async function getAddDeliverer(params) {
const res = await axios.post("/api/v1/order/deliverer/add_deliverer", params);
return res;
}
// 分配配送员
export async function getSaveDeliverer (params) {
const res = await axios.post("/api/v1/order/deliverer/save_day_deliverer",params);
export async function getSaveDeliverer(params) {
const res = await axios.post(
"/api/v1/order/deliverer/save_day_deliverer",
params
);
return res;
}
// 获取订单列表
export async function getOrderList (params) {
const res = await axios.get("/api/v1/order/background/order_list",{
export async function getOrderList(params) {
const res = await axios.get("/api/v1/order/background/order_list", {
params
});
return res;
}
// 获取活动名称
export async function getMarketingList () {
export async function getMarketingList() {
const res = await axios.get("/api/v1/order/background/marketing_list");
return res;
}
// 获取商品名称
export async function getGoodsList(params) {
const res = await axios.get("/api/v1/order/background/goods_list",{
const res = await axios.get("/api/v1/order/background/goods_list", {
params
});
return res;
......@@ -51,7 +60,7 @@ export async function getSubShopList() {
// 导出订单
export async function orderExport(params) {
const res = await axios.get("/api/v1/order/background/order_export",{
const res = await axios.get("/api/v1/order/background/order_export", {
params
});
return res;
......@@ -59,7 +68,7 @@ export async function orderExport(params) {
// 打印订单
export async function orderPrint(params) {
const res = await axios.get("/api/v1/order/background/print",{
const res = await axios.get("/api/v1/order/background/print", {
params
});
return res;
......@@ -67,23 +76,28 @@ export async function orderPrint(params) {
// 订单退款列表
export async function orderItemList(params) {
const res = await axios.get("/api/v1/order/background/order_item_list",{
const res = await axios.get("/api/v1/order/background/order_item_list", {
params
});
return res;
}
// 订单退款
export async function orderRefund(params) {
const res = await axios.get("/api/v1/order/background/order_refund",{
params
export async function refundOrder(orderId, itemsToRefund) {
// const params = {
// order_id: orderId,
// refund_list: itemsToRefund
// };
const res = await axios.post("/api/v1/order/background/order_refund", {
order_id: orderId,
refund_list: itemsToRefund
});
return res;
}
// 订单驳回
export async function orderRefundReject(params) {
const res = await axios.get("/api/v1/order/background/order_refund_reject",{
const res = await axios.get("/api/v1/order/background/order_refund_reject", {
params
});
return res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment