CouponRulerApi.java
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.diligrp.etrade.coupon.api;
import com.diligrp.etrade.core.domain.Message;
import com.diligrp.etrade.coupon.domain.CouponForOrderDto;
import com.diligrp.etrade.coupon.model.CouponRulerResponseDo;
import com.diligrp.etrade.coupon.service.CouponRulerService;
import com.diligrp.etrade.coupon.util.TUtils;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author jy
* @Date 2023/9/11 10:22
* @Version 1.0
*/
@RestController
@RequestMapping("/api/coupon/ruler")
public class CouponRulerApi {
Logger log = LoggerFactory.getLogger(CouponRulerApi.class);
@Resource
private CouponRulerService couponRulerService;
/**
* 下单验证优惠劵并计算出最优优惠劵及优惠金额和应付金额
* @param couponForOrderDto
* @return
*/
@PostMapping("/validate")
public Message<CouponRulerResponseDo> validate(@RequestBody CouponForOrderDto couponForOrderDto){
log.info("下单验证优惠劵并计算出最优优惠劵及优惠金额和应付金额入参,{}",couponForOrderDto);
TUtils.isTure(ObjectUtils.isEmpty(couponForOrderDto.getCustomerId())).throwMessage("客户信息不能为空");
TUtils.isTure(ObjectUtils.isEmpty(couponForOrderDto.getMarketId())).throwMessage("市场信息不能为空");
TUtils.isTure(ObjectUtils.isEmpty(couponForOrderDto.getAmount())).throwMessage("订单金额不能为空");
CouponRulerResponseDo couponRulerResponseDo = couponRulerService.validate(couponForOrderDto);
return Message.success(couponRulerResponseDo);
}
}