diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderMasterController.java b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderMasterController.java index 572c258a..ce7eec31 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderMasterController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderMasterController.java @@ -52,6 +52,7 @@ import com.ghy.worker.service.IWorkerCertificationService; import com.ghy.worker.service.WorkerService; import com.huifu.adapay.core.exception.BaseAdaPayException; import org.apache.commons.collections.CollectionUtils; +import org.apache.ibatis.annotations.Param; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -865,6 +866,32 @@ public class OrderMasterController extends BaseController { return AjaxResult.success(); } + /* + * 主单退单 + * */ + @PostMapping("/console/cancel") + @ResponseBody + public AjaxResult consoleCancel(Long id) { + if(id == null){ + return AjaxResult.error("订单编码id不能为空!"); + } + // 判断该主单状态 + OrderMaster orderMaster = orderMasterService.selectById(id); + if(!orderMaster.getOrderStatus().equals(OrderStatus.PLAIN.code()) && !orderMaster.getOrderStatus().equals(OrderStatus.RECEIVE.code())){ + return AjaxResult.error("该订单处于无法退单状态!"); + } + // 含有子单 + List orderDetails = orderDetailService.selectByOrderMasterId(id); + if(CollectionUtils.isNotEmpty(orderDetails)){ + return AjaxResult.error("该订单已经派发过子单,无法退单状态!"); + } + // 清空id + orderMasterService.removeWorker(orderMaster.getId()); + // 更新状态待接单 + orderMasterService.updateStatus(orderMaster.getId(), OrderStatus.RECEIVE.code()); + return AjaxResult.success(); + } + /** * 师傅审核取消主订单申请 * diff --git a/ghy-admin/src/main/resources/templates/order/orderManager.html b/ghy-admin/src/main/resources/templates/order/orderManager.html index bbc68b12..6523e806 100644 --- a/ghy-admin/src/main/resources/templates/order/orderManager.html +++ b/ghy-admin/src/main/resources/templates/order/orderManager.html @@ -654,7 +654,7 @@ formatter: function (value, row, index) { if(value){ return '' + value.name + value.phone + '
' - + '接单时间:' + row.revTime + ''; + + '接单时间:' + row.createTime + ''; } } }, @@ -664,7 +664,10 @@ formatter: function (value, row, index) { var actions = []; actions.push('查看 '); - actions.push('商家退单 '); + if(row.orderStatus == 0 || row.orderStatus == 1){ + actions.push('主单退单 '); + actions.push('商家退单 '); + } if (row.workerId != null) { actions.push('指派 '); } else { @@ -739,9 +742,26 @@ $.operate.post(url, data); }); } + // function orderMasterReject(id) { + // $.modal.confirm("确定要退单吗?", function() { + // const url = "master/reject"; + // const data = { "id": id }; + // $.operate.post(url, data); + // }); + // } + + // 商家退单 + function orderMasterCancel(id){ + $.modal.confirm("确定要取消订单吗?", function() { + const url = "cancel"; + const data = { "orderMasterId": id }; + $.operate.post(url, data); + }); + } + function orderMasterReject(id) { $.modal.confirm("确定要退单吗?", function() { - const url = "master/reject"; + const url = "console/cancel"; const data = { "id": id }; $.operate.post(url, data); }); diff --git a/ghy-admin/src/main/resources/templates/order/pc-master.html b/ghy-admin/src/main/resources/templates/order/pc-master.html index 6f952acc..ba7ef249 100644 --- a/ghy-admin/src/main/resources/templates/order/pc-master.html +++ b/ghy-admin/src/main/resources/templates/order/pc-master.html @@ -439,8 +439,10 @@ field: 'worker', title: '接单信息', formatter: function (value, row, index) { - - + if(value){ + return '' + value.name + value.phone + '
' + + '接单时间:' + row.createTime + ''; + } } }, { @@ -449,7 +451,9 @@ formatter: function (value, row, index) { var actions = []; actions.push('查看 '); - actions.push('商家退单 '); + if(row.orderStatus == 0 || row.orderStatus == 1){ + actions.push('商家退单 '); + } if (row.payStatus == 0) { actions.push('付款 '); } @@ -534,9 +538,19 @@ $.operate.post(url, data); }); } + + // 商家退单 + function orderMasterCancel(id){ + $.modal.confirm("确定要取消订单吗?", function() { + const url = "cancel"; + const data = { "orderMasterId": id }; + $.operate.post(url, data); + }); + } + function orderMasterReject(id) { $.modal.confirm("确定要退单吗?", function() { - const url = "master/reject"; + const url = "console/cancel"; const data = { "id": id }; $.operate.post(url, data); });