| 1234567891011121314151617181920212223242526 | package conm.zhentao.service.impl;import conm.zhentao.service.CouponService;import org.springframework.stereotype.Service;import java.math.BigDecimal;@Servicepublic class CouponServiceImpl implements CouponService {    @Override    public BigDecimal calculateDiscount(Long couponId, BigDecimal totalAmount) {        // 这里实现优惠券折扣计算逻辑        // 示例:假设优惠券是满100减10        if (totalAmount.compareTo(new BigDecimal("100")) >= 0) {            return new BigDecimal("10");        }        return BigDecimal.ZERO;    }    @Override    public void useCoupon(Long couponId, Long userId) {        // 这里实现优惠券使用逻辑        // 示例:更新优惠券状态为已使用        // couponMapper.updateStatus(couponId, userId, 1);    }} 
 |