add point redemption
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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.GaoPointRedemptionMapper">
|
||||
<select id="selectByStoreIdAndRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedemption">
|
||||
SELECT * FROM `gao_point_redemption`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectByStoreIdAndId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedemption">
|
||||
SELECT * FROM `gao_point_redemption`
|
||||
WHERE `store_id` = #{storeId} AND `id` = #{id} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedemption">
|
||||
SELECT * FROM `gao_point_redemption`
|
||||
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="customerId != null and customerId != ''">AND `r`.`customer_id` = #{customerId}</if>
|
||||
<if test="redeemSkuId != null and redeemSkuId != ''">AND `r`.`redeem_sku_id_snapshot` = #{redeemSkuId}</if>
|
||||
<if test="skuIdSnapshot != null and skuIdSnapshot != ''">AND `r`.`sku_id_snapshot` = #{skuIdSnapshot}</if>
|
||||
<if test="status != null">AND `r`.`status` = #{status}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">
|
||||
AND (`r`.`product_name_snapshot` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `r`.`sku_code_snapshot` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `r`.`sku_name_snapshot` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `c`.`code` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `c`.`name` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `c`.`telephone` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `c`.`name_pinyin_full` LIKE CONCAT(#{keyword}, '%')
|
||||
OR `c`.`name_pinyin_initial` LIKE CONCAT(#{keyword}, '%')
|
||||
OR `c`.`name_pinyin_mixed` LIKE CONCAT(#{keyword}, '%'))
|
||||
</if>
|
||||
<if test="beginAt != null">AND `r`.`redeemed_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND `r`.`redeemed_at` <= #{endAt}</if>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM `gao_point_redemption` `r`
|
||||
LEFT JOIN `gao_customer` `c` ON `c`.`id` = `r`.`customer_id`
|
||||
WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedemption">
|
||||
SELECT `r`.*
|
||||
FROM `gao_point_redemption` `r`
|
||||
LEFT JOIN `gao_customer` `c` ON `c`.`id` = `r`.`customer_id`
|
||||
WHERE <include refid="queryWhere"/>
|
||||
ORDER BY `r`.`redeemed_at` DESC, `r`.`created_at` DESC, `r`.`id` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<select id="sumValidQuantity" resultType="java.math.BigDecimal">
|
||||
SELECT COALESCE(SUM(`quantity` - `returned_quantity`), 0)
|
||||
FROM `gao_point_redemption`
|
||||
WHERE `store_id` = #{storeId}
|
||||
AND `customer_id` = #{customerId}
|
||||
AND `sku_id_snapshot` = #{skuId}
|
||||
AND `status` IN ('COMPLETED', 'PARTIALLY_RETURNED')
|
||||
AND `deleted_at` IS NULL
|
||||
<if test="beginAt != null">AND `redeemed_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND `redeemed_at` <= #{endAt}</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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.GaoPointRedemptionReturnMapper">
|
||||
<select id="selectByRedemptionId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedemptionReturn">
|
||||
SELECT * FROM `gao_point_redemption_return`
|
||||
WHERE `redemption_id` = #{redemptionId} AND `deleted_at` IS NULL
|
||||
ORDER BY `returned_at`, `created_at`, `id`
|
||||
</select>
|
||||
<select id="selectByRedemptionIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedemptionReturn">
|
||||
SELECT * FROM `gao_point_redemption_return`
|
||||
WHERE `redemption_id` IN
|
||||
<foreach collection="redemptionIdList" item="redemptionId" separator="," open="(" close=")">
|
||||
#{redemptionId}
|
||||
</foreach>
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `redemption_id`, `returned_at`, `created_at`, `id`
|
||||
</select>
|
||||
<select id="selectByRedemptionIdAndRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedemptionReturn">
|
||||
SELECT * FROM `gao_point_redemption_return`
|
||||
WHERE `redemption_id` = #{redemptionId} AND `request_no` = #{requestNo} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRedemptionReturn">
|
||||
SELECT * FROM `gao_point_redemption_return`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
FOR UPDATE
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user