package com.ruoyi.inspect.controller;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.common.core.domain.Result;
|
import com.ruoyi.inspect.dto.SampleOrderDto;
|
import com.ruoyi.inspect.pojo.InsOrder;
|
import com.ruoyi.inspect.service.InsOrderRatesService;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.Operation;
|
import org.springframework.web.bind.annotation.*;
|
|
import jakarta.annotation.Resource;
|
import java.math.BigDecimal;
|
|
|
/**
|
* 订单费用表
|
*
|
* @author zhuo
|
* @since 2025-02-28
|
*/
|
@Tag(name = "订单费用信息")
|
@RestController
|
@RequestMapping("/insOrderRates")
|
public class InsOrderRatesController {
|
|
@Resource
|
private InsOrderRatesService insOrderRatesService;
|
|
|
/**
|
* 查询订单列表
|
* @param page
|
* @param sampleOrderDto
|
* @return
|
*/
|
@Operation(summary = "查询订单列表")
|
@GetMapping("/selectRatesPage")
|
public Result selectInsOrderRates(Page page, SampleOrderDto sampleOrderDto,
|
String startMonth, String endMonth) {
|
return Result.success(insOrderRatesService.selectInsOrderRates(page, sampleOrderDto, startMonth, endMonth));
|
}
|
|
|
/**
|
* 更新费用优惠与备注
|
* @param insOrder
|
* @return
|
*/
|
@Operation(summary = "更新费用优惠与备注")
|
@PostMapping("/updateFee")
|
public Result<?> updateFee(@RequestBody InsOrder insOrder) {
|
if (insOrder.getId() == null) {
|
return Result.fail("订单id不能为空");
|
}
|
Integer isDiscount = insOrder.getIsDiscount();
|
if (isDiscount == null || (isDiscount != 0 && isDiscount != 1)) {
|
return Result.fail("是否优惠参数不正确");
|
}
|
BigDecimal discountAmount = insOrder.getDiscountAmount();
|
if (isDiscount == 1) {
|
if (discountAmount == null) {
|
return Result.fail("有优惠时请填写优惠后金额");
|
}
|
if (discountAmount.compareTo(BigDecimal.ZERO) < 0) {
|
return Result.fail("优惠后金额不能小于0");
|
}
|
} else {
|
discountAmount = null;
|
}
|
String feeRemark = insOrder.getFeeRemark();
|
if (feeRemark != null && feeRemark.length() > 500) {
|
return Result.fail("备注不能超过500字");
|
}
|
boolean success = insOrderRatesService.updateOrderFee(insOrder.getId(), isDiscount, discountAmount, feeRemark);
|
return success ? Result.success() : Result.fail("保存失败,订单不存在");
|
}
|
|
|
/**
|
* 查询订单列表
|
* @param insOrderId
|
* @return
|
*/
|
@Operation(summary = "查询订单费用详情")
|
@GetMapping("/selectRatesDetail")
|
public Result selectRatesDetail(Page page, Integer insOrderId) {
|
return Result.success(insOrderRatesService.selectTemplateRatesDetail(page, insOrderId));
|
}
|
|
}
|