价格查询,待处理订单内容

This commit is contained in:
2025-08-14 10:48:59 +08:00
parent 41269572c7
commit 9c932b6ba8
41 changed files with 2371 additions and 1 deletions

View File

@@ -0,0 +1,62 @@
package com.ycwl.basic.pricing.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ycwl.basic.pricing.entity.PriceCouponConfig;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
/**
* 优惠券配置Mapper
*/
@Mapper
public interface PriceCouponConfigMapper extends BaseMapper<PriceCouponConfig> {
/**
* 查询有效的优惠券配置
*/
@Select("SELECT * FROM price_coupon_config WHERE is_active = 1 " +
"AND valid_from <= NOW() AND valid_until > NOW() " +
"AND used_quantity < total_quantity")
List<PriceCouponConfig> selectValidCoupons();
/**
* 根据ID查询优惠券(包括使用数量检查)
*/
@Select("SELECT * FROM price_coupon_config WHERE id = #{couponId} " +
"AND is_active = 1 AND valid_from <= NOW() AND valid_until > NOW() " +
"AND used_quantity < total_quantity")
PriceCouponConfig selectValidCouponById(Long couponId);
/**
* 增加优惠券使用数量
*/
@Update("UPDATE price_coupon_config SET used_quantity = used_quantity + 1, " +
"updated_time = NOW() WHERE id = #{couponId} AND used_quantity < total_quantity")
int incrementUsedQuantity(Long couponId);
/**
* 插入优惠券配置
*/
@Insert("INSERT INTO price_coupon_config (coupon_name, coupon_type, discount_value, min_amount, " +
"max_discount, applicable_products, total_quantity, used_quantity, valid_from, valid_until, " +
"is_active, created_time, updated_time) VALUES " +
"(#{couponName}, #{couponType}, #{discountValue}, #{minAmount}, #{maxDiscount}, " +
"#{applicableProducts}, #{totalQuantity}, #{usedQuantity}, #{validFrom}, #{validUntil}, " +
"#{isActive}, NOW(), NOW())")
int insertCoupon(PriceCouponConfig coupon);
/**
* 更新优惠券配置
*/
@Update("UPDATE price_coupon_config SET coupon_name = #{couponName}, coupon_type = #{couponType}, " +
"discount_value = #{discountValue}, min_amount = #{minAmount}, max_discount = #{maxDiscount}, " +
"applicable_products = #{applicableProducts}, total_quantity = #{totalQuantity}, " +
"valid_from = #{validFrom}, valid_until = #{validUntil}, is_active = #{isActive}, " +
"updated_time = NOW() WHERE id = #{id}")
int updateCoupon(PriceCouponConfig coupon);
}