227 lines
8.9 KiB
Java
227 lines
8.9 KiB
Java
package com.ruoyi.jysystem.controller;
|
|
|
|
import java.util.List;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
import com.ruoyi.jysystem.domain.JySysOrder;
|
|
import com.ruoyi.jysystem.dto.OrderAdminRejectDTO;
|
|
import com.ruoyi.jysystem.dto.OrderAssignDTO;
|
|
import com.ruoyi.jysystem.dto.OrderCloseDTO;
|
|
import com.ruoyi.jysystem.dto.OrderStatusChangeDTO;
|
|
import com.ruoyi.jysystem.service.IJySysOrderService;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.utils.file.FileUtils;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
/**
|
|
* 订单Controller
|
|
*
|
|
* @author ruoyi
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/jysystem/order")
|
|
public class JySysOrderController extends BaseController
|
|
{
|
|
@Autowired
|
|
private IJySysOrderService jySysOrderService;
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:list')")
|
|
@GetMapping("/list")
|
|
public TableDataInfo list(JySysOrder jySysOrder)
|
|
{
|
|
startPage();
|
|
List<JySysOrder> list = jySysOrderService.selectJySysOrderList(jySysOrder);
|
|
return getDataTable(list);
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:export')")
|
|
@Log(title = "订单", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
public void export(HttpServletResponse response, JySysOrder jySysOrder)
|
|
{
|
|
List<JySysOrder> list = jySysOrderService.selectJySysOrderList(jySysOrder);
|
|
ExcelUtil<JySysOrder> util = new ExcelUtil<JySysOrder>(JySysOrder.class);
|
|
util.exportExcel(response, list, "订单数据");
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:export')")
|
|
@Log(title = "订单批量导出Excel", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export/batch/{ids}")
|
|
public void exportBatch(@PathVariable Long[] ids, HttpServletResponse response)
|
|
{
|
|
List<JySysOrder> list = jySysOrderService.selectJySysOrderByIds(ids);
|
|
ExcelUtil<JySysOrder> util = new ExcelUtil<JySysOrder>(JySysOrder.class);
|
|
util.exportExcel(response, list, "订单数据");
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:export')")
|
|
@Log(title = "订单批量导出PDF", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/exportPdf/batch/{ids}")
|
|
public void exportPdfBatch(@PathVariable Long[] ids, HttpServletResponse response) throws java.io.IOException
|
|
{
|
|
byte[] data = jySysOrderService.exportOrderPdfBatch(ids);
|
|
response.setContentType("application/pdf");
|
|
FileUtils.setAttachmentResponseHeader(response, "orders-" + System.currentTimeMillis() + ".pdf");
|
|
response.getOutputStream().write(data);
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:query')")
|
|
@GetMapping("/logistics/{id}")
|
|
public AjaxResult logistics(@PathVariable("id") Long id)
|
|
{
|
|
return success(jySysOrderService.selectOrderLogistics(id));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:query')")
|
|
@GetMapping(value = "/{id}")
|
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
{
|
|
return success(jySysOrderService.selectJySysOrderById(id));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:add')")
|
|
@Log(title = "订单", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
public AjaxResult add(@RequestBody JySysOrder jySysOrder)
|
|
{
|
|
jySysOrder.setCreateBy(getUsername());
|
|
return toAjax(jySysOrderService.insertJySysOrder(jySysOrder));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@Log(title = "订单", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
public AjaxResult edit(@RequestBody JySysOrder jySysOrder)
|
|
{
|
|
jySysOrder.setUpdateBy(getUsername());
|
|
return toAjax(jySysOrderService.updateJySysOrder(jySysOrder));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@GetMapping("/assign/preview")
|
|
public AjaxResult previewAssign(Long orderId, Long lensFactoryTenantId)
|
|
{
|
|
return success(jySysOrderService.previewAssignPrice(orderId, lensFactoryTenantId));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@Log(title = "订单分配", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/assign")
|
|
public AjaxResult assign(@RequestBody OrderAssignDTO assignDTO)
|
|
{
|
|
if (assignDTO == null || assignDTO.getOrderId() == null)
|
|
{
|
|
return error("订单ID不能为空");
|
|
}
|
|
return toAjax(jySysOrderService.assignOrder(assignDTO.getOrderId(), assignDTO.getLensFactoryTenantId(), getUsername()));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@Log(title = "订单驳回", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/reject")
|
|
public AjaxResult reject(@RequestBody OrderAdminRejectDTO rejectDTO)
|
|
{
|
|
if (rejectDTO == null || rejectDTO.getOrderId() == null)
|
|
{
|
|
return error("订单ID不能为空");
|
|
}
|
|
if (rejectDTO.getReason() == null || rejectDTO.getReason().trim().isEmpty())
|
|
{
|
|
return error("驳回原因不能为空");
|
|
}
|
|
return toAjax(jySysOrderService.adminRejectOrder(
|
|
rejectDTO.getOrderId(), rejectDTO.getReason().trim(), getUsername()));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@Log(title = "订单关闭", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/close")
|
|
public AjaxResult close(@RequestBody OrderCloseDTO closeDTO)
|
|
{
|
|
if (closeDTO == null || closeDTO.getOrderId() == null)
|
|
{
|
|
return error("订单ID不能为空");
|
|
}
|
|
return toAjax(jySysOrderService.adminCloseOrder(closeDTO.getOrderId(), getUsername()));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@Log(title = "订单完成", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/complete")
|
|
public AjaxResult complete(@RequestBody OrderCloseDTO completeDTO)
|
|
{
|
|
if (completeDTO == null || completeDTO.getOrderId() == null)
|
|
{
|
|
return error("订单ID不能为空");
|
|
}
|
|
return toAjax(jySysOrderService.adminCompleteOrder(completeDTO.getOrderId(), getUsername()));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@Log(title = "同意换货申请", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/exchangeAgree")
|
|
public AjaxResult exchangeAgree(@RequestBody OrderCloseDTO agreeDTO)
|
|
{
|
|
if (agreeDTO == null || agreeDTO.getOrderId() == null)
|
|
{
|
|
return error("订单ID不能为空");
|
|
}
|
|
return toAjax(jySysOrderService.adminAgreeExchangeOrder(agreeDTO.getOrderId(), getUsername()));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@Log(title = "拒绝换货申请", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/exchangeReject")
|
|
public AjaxResult exchangeReject(@RequestBody OrderAdminRejectDTO rejectDTO)
|
|
{
|
|
if (rejectDTO == null || rejectDTO.getOrderId() == null)
|
|
{
|
|
return error("订单ID不能为空");
|
|
}
|
|
if (rejectDTO.getReason() == null || rejectDTO.getReason().trim().isEmpty())
|
|
{
|
|
return error("拒绝换货申请原因不能为空");
|
|
}
|
|
return toAjax(jySysOrderService.adminRejectExchangeOrder(
|
|
rejectDTO.getOrderId(), rejectDTO.getReason().trim(), getUsername()));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:edit')")
|
|
@Log(title = "订单状态变更", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/changeStatus")
|
|
public AjaxResult changeStatus(@RequestBody OrderStatusChangeDTO statusChangeDTO)
|
|
{
|
|
if (statusChangeDTO == null || statusChangeDTO.getOrderId() == null)
|
|
{
|
|
return error("订单ID不能为空");
|
|
}
|
|
if (statusChangeDTO.getOrderStatus() == null || statusChangeDTO.getOrderStatus().isEmpty())
|
|
{
|
|
return error("订单状态不能为空");
|
|
}
|
|
return toAjax(jySysOrderService.changeOrderStatus(
|
|
statusChangeDTO.getOrderId(), statusChangeDTO.getOrderStatus(), getUsername()));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('jysystem:order:remove')")
|
|
@Log(title = "订单", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{ids}")
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
{
|
|
return toAjax(jySysOrderService.deleteJySysOrderByIds(ids));
|
|
}
|
|
}
|