| | |
| | | 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; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Operation(summary = "查询订单列表") |
| | | @GetMapping("/selectRatesPage") |
| | | public Result selectInsOrderRates(Page page, SampleOrderDto sampleOrderDto) { |
| | | return Result.success(insOrderRatesService.selectInsOrderRates(page, sampleOrderDto)); |
| | | public Result selectInsOrderRates(Page page, SampleOrderDto sampleOrderDto, |
| | | String startMonth, String endMonth) { |
| | | return Result.success(insOrderRatesService.selectInsOrderRates(page, sampleOrderDto, startMonth, endMonth)); |
| | | } |
| | | |
| | | |
| | | @Operation(summary = "汇总筛选条件下全部订单费用") |
| | | @GetMapping("/selectRatesSummary") |
| | | public Result selectRatesSummary(SampleOrderDto sampleOrderDto, String startMonth, String endMonth) { |
| | | return Result.success(insOrderRatesService.selectRatesSummary(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("保存失败,订单不存在"); |
| | | } |
| | | |
| | | |