sadjv3_java/src/main/resources/mapper/bl/massage/MassagePackageDetailDao.xml

186 lines
6.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.sqx.modules.bl.massage.dao.MassagePackageDetailDao">
<select id="findPage" resultType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
select
a.id,
a.main_id,
a.massage_type_id,
a.package_price,
a.service_count,
a.interval_days,
b.massage_img,
b.title,
b.old_price,
b.price,
b.duration,
b.status,
b.classify_id as type
from bl_massage_package_detail a inner join massage_type b on a.massage_type_id = b.massage_type_id
where a.main_id = #{params.mainId}
order by a.id desc
</select>
<update id="updatePrice" parameterType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
update bl_massage_package_detail set package_price=#{packagePrice} where id=#{id}
</update>
<update id="updateCount" parameterType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
update bl_massage_package_detail set service_count=#{serviceCount} where id=#{id}
</update>
<update id="updateIntervalDays" parameterType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
update bl_massage_package_detail set interval_days=#{intervalDays} where id=#{id}
</update>
<update id="updateStatus" parameterType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
update massage_type set status=#{status} where massage_type_id=#{massageTypeId}
</update>
<insert id="addMassage" useGeneratedKeys="true" keyProperty="massageTypeId" parameterType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
insert into massage_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != massageImg and '' != massageImg">
massage_img,
</if>
<if test="null != title and '' != title">
title,
</if>
<if test="null != content and '' != content">
content,
</if>
<if test="null != oldPrice">
old_price,
</if>
<if test="null != price">
price,
</if>
<if test="null != duration ">
duration,
</if>
<if test="null != sales">
sales,
</if>
<if test="null != isSex">
is_sex,
</if>
<if test="null != status and '' != status">
status,
</if>
<if test="null != createTime and '' != createTime">
create_time,
</if>
<if test="null != city and '' != city">
city,
</if>
<if test="null != contentImg and '' != contentImg">
content_img,
</if>
<if test="null != labels and '' != labels">
labels,
</if>
<if test="null != type">
classify_id,
</if>
<if test="null != applyPeople and '' != applyPeople">
apply_people,
</if>
<if test="null != jianjie and '' != jianjie">
jianjie,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != massageImg and '' != massageImg">
#{massageImg},
</if>
<if test="null != title and '' != title">
#{title},
</if>
<if test="null != content and '' != content">
#{content},
</if>
<if test="null != oldPrice">
#{oldPrice},
</if>
<if test="null != price">
#{price},
</if>
<if test="null != duration ">
#{duration},
</if>
<if test="null != sales">
#{sales},
</if>
<if test="null != isSex">
#{isSex},
</if>
<if test="null != status and '' != status">
#{status},
</if>
<if test="null != createTime and '' != createTime">
#{createTime},
</if>
<if test="null != city and '' != city">
#{city},
</if>
<if test="null != contentImg and '' != contentImg">
#{contentImg},
</if>
<if test="null != labels and '' != labels">
#{labels},
</if>
<if test="null != type ">
#{type},
</if>
<if test="null != applyPeople and '' != applyPeople">
#{applyPeople},
</if>
<if test="null != jianjie and '' != jianjie">
#{jianjie},
</if>
</trim>
</insert>
<insert id="addDetail" parameterType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
insert into bl_massage_package_detail(main_id,massage_type_id,package_price,service_count,interval_days)
values (#{mainId},#{massageTypeId},#{packagePrice},#{serviceCount},#{intervalDays})
</insert>
<select id="findMassagePage" resultType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
select
massage_type_id,
massage_img,
title,
old_price,
price,
duration,
status,
classify_id as type
from massage_type
where 1=1
<if test="params.type!=null and params.type!=''">
and classify_id=#{params.type}
</if>
<if test="params.title!=null and params.title!=''">
and title like concat('%',#{params.title},'%')
</if>
order by classify_id asc,massage_type_id
</select>
<delete id="delete" parameterType="com.sqx.modules.bl.massage.entity.MassagePackageDetail">
delete from bl_massage_package_detail where id=#{id}
</delete>
<select id="findPackagePrice" resultType="com.sqx.modules.bl.massage.entity.MassagePackage">
select
a.main_id as id,
ifnull(sum(package_price*service_count),0) as price
from bl_massage_package_detail a inner join massage_type b on a.massage_type_id = b.massage_type_id
where a.main_id = #{mainId}
and b.status = 1
group by a.main_id
</select>
</mapper>