<?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.ruoyi.order.mapper.goods.GoodsMapper">
|
|
<resultMap type="Goods" id="GoodsResult">
|
<result property="goodsId" column="goods_id" />
|
<result property="delFlag" column="del_flag" />
|
<result property="goodsStatus" column="goods_status" />
|
<result property="goodsType" column="goods_type" />
|
<result property="createTime" column="create_time" />
|
<result property="createUserId" column="create_user_id" />
|
<result property="updateTime" column="update_time" />
|
<result property="updateUserId" column="update_user_id" />
|
<result property="goodsClassId" column="goods_class_id" />
|
<result property="goodsName" column="goods_name" />
|
<result property="cycleNumFlag" column="cycle_num_flag" />
|
<result property="serviceNum" column="service_num" />
|
<result property="goodsIntroduction" column="goods_introduction" />
|
<result property="salesPrice" column="sales_price" />
|
<result property="mininumPrice" column="mininum_price" />
|
<result property="subscriptionFlag" column="subscription_flag" />
|
<result property="subscription" column="subscription" />
|
<result property="goodsDetail" column="goods_detail" />
|
<result property="recommendFlag" column="recommend_flag" />
|
<result property="goodsNurses" column="goods_nurses" />
|
<result property="goodsTags" column="goods_tags" />
|
</resultMap>
|
|
<sql id="selectGoodsVo">
|
select goods_id, del_flag, goods_status, goods_type, create_time, create_user_id, update_time, update_user_id, goods_class_id, goods_name, cycle_num_flag, service_num, goods_introduction, sales_price, mininum_price, subscription_flag, subscription, goods_detail, recommend_flag, goods_nurses, goods_tags from t_goods
|
</sql>
|
|
<select id="selectGoodsList" parameterType="Goods" resultMap="GoodsResult">
|
<include refid="selectGoodsVo"/>
|
<where>
|
<if test="goodsStatus != null "> and goods_status = #{goodsStatus}</if>
|
<if test="goodsType != null "> and goods_type = #{goodsType}</if>
|
<if test="createUserId != null "> and create_user_id = #{createUserId}</if>
|
<if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
|
<if test="goodsClassId != null "> and goods_class_id = #{goodsClassId}</if>
|
<if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
|
<if test="cycleNumFlag != null "> and cycle_num_flag = #{cycleNumFlag}</if>
|
<if test="serviceNum != null "> and service_num = #{serviceNum}</if>
|
<if test="goodsIntroduction != null and goodsIntroduction != ''"> and goods_introduction = #{goodsIntroduction}</if>
|
<if test="salesPrice != null "> and sales_price = #{salesPrice}</if>
|
<if test="mininumPrice != null "> and mininum_price = #{mininumPrice}</if>
|
<if test="subscriptionFlag != null "> and subscription_flag = #{subscriptionFlag}</if>
|
<if test="subscription != null "> and subscription = #{subscription}</if>
|
<if test="goodsDetail != null and goodsDetail != ''"> and goods_detail = #{goodsDetail}</if>
|
<if test="recommendFlag != null "> and recommend_flag = #{recommendFlag}</if>
|
<if test="goodsNurses != null and goodsNurses != ''"> and goods_nurses = #{goodsNurses}</if>
|
<if test="goodsTags != null and goodsTags != ''"> and goods_tags = #{goodsTags}</if>
|
</where>
|
</select>
|
|
<select id="selectGoodsByGoodsId" parameterType="String" resultMap="GoodsResult">
|
<include refid="selectGoodsVo"/>
|
where goods_id = #{goodsId}
|
</select>
|
|
<insert id="insertGoods" parameterType="Goods">
|
insert into t_goods
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="goodsId != null">goods_id,</if>
|
<if test="delFlag != null">del_flag,</if>
|
<if test="goodsStatus != null">goods_status,</if>
|
<if test="goodsType != null">goods_type,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="createUserId != null">create_user_id,</if>
|
<if test="updateTime != null">update_time,</if>
|
<if test="updateUserId != null">update_user_id,</if>
|
<if test="goodsClassId != null">goods_class_id,</if>
|
<if test="goodsName != null">goods_name,</if>
|
<if test="cycleNumFlag != null">cycle_num_flag,</if>
|
<if test="serviceNum != null">service_num,</if>
|
<if test="goodsIntroduction != null">goods_introduction,</if>
|
<if test="salesPrice != null">sales_price,</if>
|
<if test="mininumPrice != null">mininum_price,</if>
|
<if test="subscriptionFlag != null">subscription_flag,</if>
|
<if test="subscription != null">subscription,</if>
|
<if test="goodsDetail != null">goods_detail,</if>
|
<if test="recommendFlag != null">recommend_flag,</if>
|
<if test="goodsNurses != null">goods_nurses,</if>
|
<if test="goodsTags != null">goods_tags,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="goodsId != null">#{goodsId},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
<if test="goodsStatus != null">#{goodsStatus},</if>
|
<if test="goodsType != null">#{goodsType},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="createUserId != null">#{createUserId},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateUserId != null">#{updateUserId},</if>
|
<if test="goodsClassId != null">#{goodsClassId},</if>
|
<if test="goodsName != null">#{goodsName},</if>
|
<if test="cycleNumFlag != null">#{cycleNumFlag},</if>
|
<if test="serviceNum != null">#{serviceNum},</if>
|
<if test="goodsIntroduction != null">#{goodsIntroduction},</if>
|
<if test="salesPrice != null">#{salesPrice},</if>
|
<if test="mininumPrice != null">#{mininumPrice},</if>
|
<if test="subscriptionFlag != null">#{subscriptionFlag},</if>
|
<if test="subscription != null">#{subscription},</if>
|
<if test="goodsDetail != null">#{goodsDetail},</if>
|
<if test="recommendFlag != null">#{recommendFlag},</if>
|
<if test="goodsNurses != null">#{goodsNurses},</if>
|
<if test="goodsTags != null">#{goodsTags},</if>
|
</trim>
|
</insert>
|
|
<update id="updateGoods" parameterType="Goods">
|
update t_goods
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
<if test="goodsStatus != null">goods_status = #{goodsStatus},</if>
|
<if test="goodsType != null">goods_type = #{goodsType},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createUserId != null">create_user_id = #{createUserId},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateUserId != null">update_user_id = #{updateUserId},</if>
|
<if test="goodsClassId != null">goods_class_id = #{goodsClassId},</if>
|
<if test="goodsName != null">goods_name = #{goodsName},</if>
|
<if test="cycleNumFlag != null">cycle_num_flag = #{cycleNumFlag},</if>
|
<if test="serviceNum != null">service_num = #{serviceNum},</if>
|
<if test="goodsIntroduction != null">goods_introduction = #{goodsIntroduction},</if>
|
<if test="salesPrice != null">sales_price = #{salesPrice},</if>
|
<if test="mininumPrice != null">mininum_price = #{mininumPrice},</if>
|
<if test="subscriptionFlag != null">subscription_flag = #{subscriptionFlag},</if>
|
<if test="subscription != null">subscription = #{subscription},</if>
|
<if test="goodsDetail != null">goods_detail = #{goodsDetail},</if>
|
<if test="recommendFlag != null">recommend_flag = #{recommendFlag},</if>
|
<if test="goodsNurses != null">goods_nurses = #{goodsNurses},</if>
|
<if test="goodsTags != null">goods_tags = #{goodsTags},</if>
|
</trim>
|
where goods_id = #{goodsId}
|
</update>
|
|
<delete id="deleteGoodsByGoodsId" parameterType="String">
|
delete from t_goods where goods_id = #{goodsId}
|
</delete>
|
|
<delete id="deleteGoodsByGoodsIds" parameterType="String">
|
delete from t_goods where goods_id in
|
<foreach item="goodsId" collection="array" open="(" separator="," close=")">
|
#{goodsId}
|
</foreach>
|
</delete>
|
|
<!--分页获取推荐商品-->
|
<select id="pageRecommendGoods" resultType="com.ruoyi.order.domain.vo.AppSimpleGoodsVo">
|
SELECT
|
tg.goods_id goodsId,
|
tg.goods_name goodsName,
|
tg.goods_introduction goodsIntroduction,
|
tg.goods_type goodsType,
|
CASE tg.goods_type
|
WHEN 1 THEN "周期"
|
WHEN 2 THEN "服务"
|
WHEN 3 THEN "体验"
|
WHEN 4 THEN "单品"
|
END goodsTag,
|
IFNULL(tsg.sales_price,tg.sales_price) salesPrice,
|
tgf.file_url goodsPicture,
|
tg.goods_nurses goodsNurses
|
FROM t_goods tg
|
LEFT JOIN t_goods_file tgf ON tg.goods_id = tgf.goods_id AND tgf.del_flag = 0 AND tgf.file_type = 1
|
LEFT JOIN t_shop_goods tsg ON tg.goods_id = tsg.goods_id AND tsg.shop_id = #{shopId}
|
WHERE tg.del_flag = 0 AND tg.goods_status = 1 AND tg.recommend_flag = 1
|
ORDER BY tg.create_time DESC
|
</select>
|
|
<!--分页获取商城商品列表-->
|
<select id="pageShopGoods" resultType="com.ruoyi.order.domain.vo.AppSimpleGoodsVo">
|
SELECT
|
tg.goods_id goodsId,
|
tg.goods_name goodsName,
|
tg.goods_introduction goodsIntroduction,
|
tg.goods_type goodsType,
|
CASE tg.goods_type
|
WHEN 1 THEN "周期"
|
WHEN 2 THEN "服务"
|
WHEN 3 THEN "体验"
|
WHEN 4 THEN "单品"
|
END goodsTag,
|
IFNULL(tsg.sales_price,tg.sales_price) salesPrice,
|
tgf.file_url goodsPicture,
|
tg.goods_nurses goodsNurses
|
FROM t_goods tg
|
INNER JOIN t_goods_total tgt ON tg.goods_id = tgt.goods_id
|
LEFT JOIN t_goods_file tgf ON tg.goods_id = tgf.goods_id AND tgf.del_flag = 0 AND tgf.file_type = 1
|
LEFT JOIN t_shop_goods tsg ON tg.goods_id = tsg.goods_id AND tsg.shop_id = #{param.shopId}
|
WHERE tg.del_flag = 0 AND tg.goods_status = 1
|
<if test="param.goodsType!=null and param.goodsType != ''">
|
AND tg.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.goodsClassId!=null and param.goodsClassId != ''">
|
AND tg.goods_class_id = #{param.goodsClassId}
|
</if>
|
<if test="param.keyword!=null and param.keyword != ''">
|
AND tg.goods_name LIKE CONCAT('%',#{param.keyword},'%')
|
</if>
|
ORDER BY
|
<if test="param.sort != null and param.sort != ''">
|
<choose>
|
<when test="param.sort==1">
|
salesPrice DESC,tg.create_time DESC
|
</when>
|
<when test="param.sort==2">
|
salesPrice ASC,tg.create_time DESC
|
</when>
|
<when test="param.sort==3">
|
tgt.buy_num_count ASC,tg.create_time DESC
|
</when>
|
<when test="param.sort==4">
|
tgt.buy_num_count DESC,tg.create_time DESC
|
</when>
|
<when test="param.sort==5">
|
tg.create_time DESC
|
</when>
|
<otherwise>
|
tg.create_time DESC
|
</otherwise>
|
</choose>
|
</if>
|
</select>
|
|
<!--分页获取搜索商品列表-->
|
<select id="pageSearchGoods" resultType="com.ruoyi.order.domain.vo.AppSimpleGoodsVo">
|
SELECT
|
tg.goods_id goodsId,
|
tg.goods_name goodsName,
|
tg.goods_introduction goodsIntroduction,
|
tg.goods_type goodsType,
|
CASE tg.goods_type
|
WHEN 1 THEN "周期"
|
WHEN 2 THEN "服务"
|
WHEN 3 THEN "体验"
|
WHEN 4 THEN "单品"
|
END goodsTag,
|
IFNULL(tsg.sales_price,tg.sales_price) salesPrice,
|
tgf.file_url goodsPicture,
|
tg.goods_tags goodsNurses
|
FROM t_goods tg
|
LEFT JOIN t_goods_file tgf ON tg.goods_id = tgf.goods_id AND tgf.del_flag = 0 AND tgf.file_type = 1
|
LEFT JOIN t_shop_goods tsg ON tg.goods_id = tsg.goods_id AND tsg.shop_id = #{param.shopId}
|
WHERE tg.del_flag = 0 AND tg.goods_status = 1
|
<if test="param.keyword!=null and param.keyword != ''">
|
AND tg.goods_name LIKE CONCAT('%',#{param.keyword},'%')
|
</if>
|
ORDER BY tg.create_time DESC
|
</select>
|
|
<!--分页获取搜索活动商品列表-->
|
<select id="pageSearchActivityGoods" resultType="com.ruoyi.order.domain.vo.AppSimpleActivityGoodsVo">
|
SELECT
|
tg.goods_id goodsId,
|
tg.goods_name goodsName,
|
tg.goods_introduction goodsIntroduction,
|
tg.goods_type goodsType,
|
CASE tg.goods_type
|
WHEN 1 THEN "周期"
|
WHEN 2 THEN "服务"
|
WHEN 3 THEN "体验"
|
WHEN 4 THEN "单品"
|
END goodsTag,
|
GREATEST(tg.sales_price,IFNULL(tsg.sales_price,'0.00')) salesPrice,
|
tag.activity_price activityPrice,
|
tgf.file_url goodsPicture,
|
tg.goods_tags goodsNurses,
|
tag.activity_number activityNumber,
|
tag.sales_number salesNumber
|
FROM t_goods tg
|
INNER JOIN t_activity_goods tag ON tg.goods_id = tag.goods_id
|
LEFT JOIN t_goods_file tgf ON tg.goods_id = tgf.goods_id AND tgf.del_flag = 0 AND tgf.file_type = 1
|
LEFT JOIN t_shop_goods tsg ON tg.goods_id = tsg.goods_id AND tsg.shop_id = #{param.shopId}
|
WHERE tg.del_flag = 0 AND tg.goods_status = 1
|
<if test="param.keyword!=null and param.keyword != ''">
|
AND tg.goods_name LIKE CONCAT('%',#{param.keyword},'%')
|
</if>
|
ORDER BY tg.create_time DESC
|
</select>
|
|
<select id="pageMerShopGoods" resultType="com.ruoyi.order.domain.vo.MerGoodsPageVo">
|
SELECT
|
tg.goods_id goodsId,
|
tg.goods_name goodsName,
|
tg.goods_introduction goodsIntroduction,
|
tg.goods_type goodsType,
|
CASE tg.goods_type
|
WHEN 1 THEN "周期"
|
WHEN 2 THEN "服务"
|
WHEN 3 THEN "体验"
|
WHEN 4 THEN "单品"
|
END goodsTag,
|
IFNULL(tsg.sales_price,tg.sales_price) salesPrice,
|
tg.sales_price suggestSalesPrice,
|
tgf.file_url goodsPicture,
|
tg.goods_nurses goodsNurses,
|
tg.cycle_num_flag cycleNumFlag,
|
tg.service_num defaultServiceNum,
|
IFNULL(tsg.service_num,tg.service_num) serviceNum
|
FROM t_goods tg
|
LEFT JOIN t_goods_file tgf ON tg.goods_id = tgf.goods_id AND tgf.del_flag = 0 AND tgf.file_type = 1
|
LEFT JOIN t_shop_goods tsg ON tg.goods_id = tsg.goods_id AND tsg.shop_id = #{param.shopId}
|
WHERE tg.del_flag = 0 AND tg.goods_status = 1
|
<if test="param.goodsType != null">
|
AND tg.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.goodsName != null and param.goodsName != ''">
|
AND tg.goods_name LIKE CONCAT('%',#{param.goodsName},'%')
|
</if>
|
ORDER BY tg.create_time DESC
|
</select>
|
</mapper>
|