Commit cf6f59d8 authored by Junling Bu's avatar Junling Bu
Browse files

feat[litemall-admin, litemall-admin-api]: 支持订单删除。

parent 9f95aa0f
......@@ -214,6 +214,37 @@ public class AdminOrderService {
return ResponseUtil.ok();
}
/**
* 删除订单
* 1. 检测当前订单是否能够删除
* 2. 删除订单
*
* @param body 订单信息,{ orderId:xxx }
* @return 订单操作结果
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
public Object delete(String body) {
Integer orderId = JacksonUtil.parseInteger(body, "orderId");
LitemallOrder order = orderService.findById(orderId);
if (order == null) {
return ResponseUtil.badArgument();
}
// 如果订单不是关闭状态(已取消、系统取消、已退款、用户已确认、系统已确认),则不能删除
Short status = order.getOrderStatus();
if (!status.equals(OrderUtil.STATUS_CANCEL) && !status.equals(OrderUtil.STATUS_AUTO_CANCEL) &&
!status.equals(OrderUtil.STATUS_CONFIRM) &&!status.equals(OrderUtil.STATUS_AUTO_CONFIRM) &&
!status.equals(OrderUtil.STATUS_REFUND_CONFIRM)) {
return ResponseUtil.fail(ORDER_DELETE_FAILED, "订单不能删除");
}
// 删除订单
orderService.deleteById(orderId);
// 删除订单商品
orderGoodsService.deleteByOrderId(orderId);
logHelper.logOrderSucceed("删除", "订单编号 " + order.getOrderSn());
return ResponseUtil.ok();
}
/**
* 回复订单商品
......
......@@ -12,6 +12,7 @@ public class AdminResponseCode {
public static final Integer ORDER_CONFIRM_NOT_ALLOWED = 620;
public static final Integer ORDER_REFUND_FAILED = 621;
public static final Integer ORDER_REPLY_EXIST = 622;
public static final Integer ORDER_DELETE_FAILED = 623;
public static final Integer USER_INVALID_NAME = 630;
public static final Integer USER_INVALID_PASSWORD = 631;
public static final Integer USER_INVALID_MOBILE = 632;
......
......@@ -106,6 +106,19 @@ public class AdminOrderController {
}
/**
* 删除订单
*
* @param body 订单信息,{ orderId:xxx }
* @return 订单操作结果
*/
@RequiresPermissions("admin:order:delete")
@RequiresPermissionsDesc(menu = {"商场管理", "订单管理"}, button = "订单删除")
@PostMapping("/delete")
public Object delete(@RequestBody String body) {
return adminOrderService.delete(body);
}
/**
* 回复订单商品
*
......
......@@ -36,6 +36,14 @@ export function refundOrder(data) {
})
}
export function deleteOrder(data) {
return request({
url: '/order/delete',
method: 'post',
data
})
}
export function replyComment(data) {
return request({
url: '/order/reply',
......
......@@ -197,7 +197,7 @@ export const asyncRouterMap = [
component: () => import('@/views/mall/order'),
name: 'order',
meta: {
perms: ['GET /admin/order/list', 'GET /admin/order/detail', 'POST /admin/order/ordership', 'POST /admin/order/orderrefund', 'POST /admin/order/orderreply'],
perms: ['GET /admin/order/list', 'GET /admin/order/detail', 'POST /admin/order/ship', 'POST /admin/order/refund', 'POST /admin/order/delete', 'POST /admin/order/reply'],
title: '订单管理',
noCache: true
}
......
......@@ -36,9 +36,10 @@
<el-table-column align="center" label="物流渠道" prop="shipChannel" />
<el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width">
<el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button v-permission="['GET /admin/order/detail']" type="primary" size="mini" @click="handleDetail(scope.row)">详情</el-button>
<el-button v-permission="['POST /admin/order/delete']" type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
<el-button v-if="scope.row.orderStatus==201" v-permission="['POST /admin/order/ship']" type="primary" size="mini" @click="handleShip(scope.row)">发货</el-button>
<el-button v-if="scope.row.orderStatus==202||scope.row.orderStatus==204" v-permission="['POST /admin/order/refund']" type="primary" size="mini" @click="handleRefund(scope.row)">退款</el-button>
</template>
......@@ -152,7 +153,7 @@
</template>
<script>
import { detailOrder, listOrder, listChannel, refundOrder, shipOrder } from '@/api/order'
import { detailOrder, listOrder, listChannel, refundOrder, deleteOrder, shipOrder } from '@/api/order'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import checkPermission from '@/utils/permission' // 权限判断函数
......@@ -310,6 +311,20 @@ export default {
}
})
},
handleDelete(row) {
deleteOrder({ orderId: row.id }).then(response => {
this.$notify.success({
title: '成功',
message: '订单删除成功'
})
this.getList()
}).catch(response => {
this.$notify.error({
title: '失败',
message: response.data.errmsg
})
})
},
handleRefund(row) {
this.refundForm.orderId = row.id
this.refundForm.refundMoney = row.actualPrice
......
......@@ -53,4 +53,10 @@ public class LitemallOrderGoodsService {
example.or().andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return orderGoodsMapper.countByExample(example) != 0;
}
public void deleteByOrderId(Integer orderId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andDeletedEqualTo(false);
orderGoodsMapper.logicalDeleteByExample(example);
}
}
Supports Markdown
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