You've already forked FrameTour-BE
价格查询,待处理订单内容
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.ycwl.basic.pricing.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ycwl.basic.pricing.entity.PriceBundleConfig;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一口价配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface PriceBundleConfigMapper extends BaseMapper<PriceBundleConfig> {
|
||||
|
||||
/**
|
||||
* 查询启用的一口价配置
|
||||
*/
|
||||
@Select("SELECT * FROM price_bundle_config WHERE is_active = 1")
|
||||
List<PriceBundleConfig> selectActiveBundles();
|
||||
|
||||
/**
|
||||
* 根据ID查询启用的配置
|
||||
*/
|
||||
@Select("SELECT * FROM price_bundle_config WHERE id = #{id} AND is_active = 1")
|
||||
PriceBundleConfig selectActiveBundleById(Long id);
|
||||
|
||||
/**
|
||||
* 插入一口价配置
|
||||
*/
|
||||
@Insert("INSERT INTO price_bundle_config (bundle_name, bundle_price, included_products, excluded_products, " +
|
||||
"description, is_active, created_time, updated_time) VALUES " +
|
||||
"(#{bundleName}, #{bundlePrice}, #{includedProducts}, #{excludedProducts}, " +
|
||||
"#{description}, #{isActive}, NOW(), NOW())")
|
||||
int insertBundleConfig(PriceBundleConfig config);
|
||||
|
||||
/**
|
||||
* 更新一口价配置
|
||||
*/
|
||||
@Update("UPDATE price_bundle_config SET bundle_name = #{bundleName}, bundle_price = #{bundlePrice}, " +
|
||||
"included_products = #{includedProducts}, excluded_products = #{excludedProducts}, " +
|
||||
"description = #{description}, is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||
int updateBundleConfig(PriceBundleConfig config);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ycwl.basic.pricing.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ycwl.basic.pricing.entity.PriceCouponClaimRecord;
|
||||
import com.ycwl.basic.pricing.enums.CouponStatus;
|
||||
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 PriceCouponClaimRecordMapper extends BaseMapper<PriceCouponClaimRecord> {
|
||||
|
||||
/**
|
||||
* 查询用户可用的优惠券记录
|
||||
*/
|
||||
@Select("SELECT r.*, c.coupon_name, c.coupon_type, c.discount_value, c.min_amount, " +
|
||||
"c.max_discount, c.applicable_products, c.valid_from, c.valid_until " +
|
||||
"FROM price_coupon_claim_record r " +
|
||||
"JOIN price_coupon_config c ON r.coupon_id = c.id " +
|
||||
"WHERE r.user_id = #{userId} AND r.status = 'CLAIMED' " +
|
||||
"AND c.is_active = 1 AND c.valid_from <= NOW() AND c.valid_until > NOW()")
|
||||
List<PriceCouponClaimRecord> selectUserAvailableCoupons(Long userId);
|
||||
|
||||
/**
|
||||
* 查询用户特定优惠券记录
|
||||
*/
|
||||
@Select("SELECT * FROM price_coupon_claim_record " +
|
||||
"WHERE user_id = #{userId} AND coupon_id = #{couponId} AND status = 'CLAIMED'")
|
||||
PriceCouponClaimRecord selectUserCouponRecord(@Param("userId") Long userId,
|
||||
@Param("couponId") Long couponId);
|
||||
|
||||
/**
|
||||
* 更新优惠券使用状态
|
||||
*/
|
||||
@Update("UPDATE price_coupon_claim_record SET status = #{status}, " +
|
||||
"use_time = #{useTime}, order_id = #{orderId}, updated_time = NOW() " +
|
||||
"WHERE id = #{id}")
|
||||
int updateCouponStatus(@Param("id") Long id,
|
||||
@Param("status") CouponStatus status,
|
||||
@Param("useTime") java.time.LocalDateTime useTime,
|
||||
@Param("orderId") String orderId);
|
||||
|
||||
/**
|
||||
* 插入优惠券领用记录
|
||||
*/
|
||||
@Insert("INSERT INTO price_coupon_claim_record (coupon_id, user_id, claim_time, status, created_time, updated_time) " +
|
||||
"VALUES (#{couponId}, #{userId}, NOW(), #{status}, NOW(), NOW())")
|
||||
int insertClaimRecord(PriceCouponClaimRecord record);
|
||||
|
||||
/**
|
||||
* 更新优惠券记录
|
||||
*/
|
||||
@Update("UPDATE price_coupon_claim_record SET status = #{status}, use_time = #{useTime}, " +
|
||||
"order_id = #{orderId}, updated_time = NOW() WHERE id = #{id}")
|
||||
int updateClaimRecord(PriceCouponClaimRecord record);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.ycwl.basic.pricing.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ycwl.basic.pricing.entity.PriceProductConfig;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品价格配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface PriceProductConfigMapper extends BaseMapper<PriceProductConfig> {
|
||||
|
||||
/**
|
||||
* 查询启用的商品配置
|
||||
*/
|
||||
@Select("SELECT * FROM price_product_config WHERE is_active = 1")
|
||||
List<PriceProductConfig> selectActiveConfigs();
|
||||
|
||||
/**
|
||||
* 根据商品类型查询配置
|
||||
*/
|
||||
@Select("SELECT * FROM price_product_config WHERE product_type = #{productType} AND is_active = 1")
|
||||
List<PriceProductConfig> selectByProductType(String productType);
|
||||
|
||||
/**
|
||||
* 根据商品类型和商品ID查询配置
|
||||
*/
|
||||
@Select("SELECT * FROM price_product_config WHERE product_type = #{productType} AND product_id = #{productId} AND is_active = 1")
|
||||
PriceProductConfig selectByProductTypeAndId(String productType, String productId);
|
||||
|
||||
/**
|
||||
* 插入商品价格配置
|
||||
*/
|
||||
@Insert("INSERT INTO price_product_config (product_type, product_id, product_name, base_price, original_price, unit, is_active, created_time, updated_time) " +
|
||||
"VALUES (#{productType}, #{productId}, #{productName}, #{basePrice}, #{originalPrice}, #{unit}, #{isActive}, NOW(), NOW())")
|
||||
int insertProductConfig(PriceProductConfig config);
|
||||
|
||||
/**
|
||||
* 更新商品价格配置
|
||||
*/
|
||||
@Update("UPDATE price_product_config SET product_id = #{productId}, product_name = #{productName}, base_price = #{basePrice}, " +
|
||||
"original_price = #{originalPrice}, unit = #{unit}, is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||
int updateProductConfig(PriceProductConfig config);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.ycwl.basic.pricing.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ycwl.basic.pricing.entity.PriceTierConfig;
|
||||
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 PriceTierConfigMapper extends BaseMapper<PriceTierConfig> {
|
||||
|
||||
/**
|
||||
* 根据商品类型、商品ID和数量查询匹配的阶梯价格
|
||||
*/
|
||||
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
||||
"AND product_id = #{productId} " +
|
||||
"AND (product_sub_type = #{productSubType} OR product_sub_type IS NULL) " +
|
||||
"AND #{quantity} >= min_quantity AND #{quantity} <= max_quantity " +
|
||||
"AND is_active = 1 ORDER BY sort_order ASC LIMIT 1")
|
||||
PriceTierConfig selectByProductTypeAndQuantity(@Param("productType") String productType,
|
||||
@Param("productId") String productId,
|
||||
@Param("productSubType") String productSubType,
|
||||
@Param("quantity") Integer quantity);
|
||||
|
||||
/**
|
||||
* 根据商品类型查询所有阶梯配置
|
||||
*/
|
||||
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
||||
"AND is_active = 1 ORDER BY sort_order ASC")
|
||||
List<PriceTierConfig> selectByProductType(String productType);
|
||||
|
||||
/**
|
||||
* 根据商品类型和商品ID查询所有阶梯配置
|
||||
*/
|
||||
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
||||
"AND product_id = #{productId} AND is_active = 1 ORDER BY sort_order ASC")
|
||||
List<PriceTierConfig> selectByProductTypeAndId(@Param("productType") String productType,
|
||||
@Param("productId") String productId);
|
||||
|
||||
/**
|
||||
* 根据商品类型和子类型查询阶梯配置
|
||||
*/
|
||||
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
||||
"AND product_sub_type = #{productSubType} AND is_active = 1 ORDER BY sort_order ASC")
|
||||
List<PriceTierConfig> selectByProductTypeAndSubType(@Param("productType") String productType,
|
||||
@Param("productSubType") String productSubType);
|
||||
|
||||
/**
|
||||
* 插入阶梯定价配置
|
||||
*/
|
||||
@Insert("INSERT INTO price_tier_config (product_type, product_id, product_sub_type, min_quantity, max_quantity, price, " +
|
||||
"original_price, unit, sort_order, is_active, created_time, updated_time) VALUES " +
|
||||
"(#{productType}, #{productId}, #{productSubType}, #{minQuantity}, #{maxQuantity}, #{price}, " +
|
||||
"#{originalPrice}, #{unit}, #{sortOrder}, #{isActive}, NOW(), NOW())")
|
||||
int insertTierConfig(PriceTierConfig config);
|
||||
|
||||
/**
|
||||
* 更新阶梯定价配置
|
||||
*/
|
||||
@Update("UPDATE price_tier_config SET product_id = #{productId}, product_sub_type = #{productSubType}, min_quantity = #{minQuantity}, " +
|
||||
"max_quantity = #{maxQuantity}, price = #{price}, original_price = #{originalPrice}, unit = #{unit}, sort_order = #{sortOrder}, " +
|
||||
"is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||
int updateTierConfig(PriceTierConfig config);
|
||||
}
|
||||
Reference in New Issue
Block a user