Files
TimiServerAPI/src/main/resources/mapper/timi-server/gao/GaoPointRedeemSkuMapper.xml
T
2026-09-15 01:25:32 +08:00

63 lines
2.6 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoPointRedeemSkuMapper">
<select id="selectByStoreIdAndId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedeemSku">
SELECT * FROM `gao_point_redeem_sku`
WHERE `store_id` = #{storeId} AND `id` = #{id} AND `deleted_at` IS NULL
LIMIT 1
</select>
<select id="selectByStoreSkuUnit" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedeemSku">
SELECT * FROM `gao_point_redeem_sku`
WHERE `store_id` = #{storeId} AND `sku_id` = #{skuId} AND `sku_unit_id` = #{skuUnitId}
AND `deleted_at` IS NULL
LIMIT 1
</select>
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedeemSku">
SELECT * FROM `gao_point_redeem_sku`
WHERE `id` = #{id} AND `deleted_at` IS NULL
LIMIT 1
FOR UPDATE
</select>
<sql id="queryWhere">
`r`.`deleted_at` IS NULL
<if test="storeId != null and storeId != ''">AND `r`.`store_id` = #{storeId}</if>
<if test="skuId != null and skuId != ''">AND `r`.`sku_id` = #{skuId}</if>
<if test="status != null">AND `r`.`status` = #{status}</if>
<if test="keyword != null and keyword.trim() != ''">
AND (`p`.`name` LIKE CONCAT('%', #{keyword}, '%') OR `p`.`code` LIKE CONCAT('%', #{keyword}, '%')
OR `k`.`name` LIKE CONCAT('%', #{keyword}, '%') OR `k`.`code` LIKE CONCAT('%', #{keyword}, '%'))
</if>
</sql>
<select id="countByQuery" resultType="long">
SELECT COUNT(1)
FROM `gao_point_redeem_sku` `r`
INNER JOIN `gao_product_sku` `k` ON `k`.`id` = `r`.`sku_id`
INNER JOIN `gao_product` `p` ON `p`.`id` = `k`.`product_id`
WHERE <include refid="queryWhere"/>
</select>
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedeemSku">
SELECT `r`.*
FROM `gao_point_redeem_sku` `r`
INNER JOIN `gao_product_sku` `k` ON `k`.`id` = `r`.`sku_id`
INNER JOIN `gao_product` `p` ON `p`.`id` = `k`.`product_id`
WHERE <include refid="queryWhere"/>
ORDER BY `r`.`created_at` DESC, `r`.`id` DESC
LIMIT #{offset}, #{limit}
</select>
<update id="updateConfig">
UPDATE `gao_point_redeem_sku`
SET `sku_id` = #{skuId},
`sku_unit_id` = #{skuUnitId},
`status` = #{status},
`default_point_cost` = #{defaultPointCost},
`begin_at` = #{beginAt},
`end_at` = #{endAt},
`max_total_quantity` = #{maxTotalQuantity},
`max_daily_quantity` = #{maxDailyQuantity},
`max_monthly_quantity` = #{maxMonthlyQuantity},
`remark` = #{remark},
`updated_at` = #{updatedAt}
WHERE `id` = #{id} AND `deleted_at` IS NULL
</update>
</mapper>