493 lines
18 KiB
XML
493 lines
18 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.zhwl.eatery.mapper.ZdyEateryProductMapper">
|
|
|
|
<resultMap type="ZdyEateryProductVo" id="ZdyEateryProductResult">
|
|
<result property="id" column="id"/>
|
|
<result property="name" column="name"/>
|
|
<result property="type" column="type"/>
|
|
<result property="img" column="img"/>
|
|
<result property="salePrise" column="sale_prise"/>
|
|
<result property="code" column="code"/>
|
|
<result property="manufactureDate" column="manufacture_date"/>
|
|
<result property="sort" column="sort"/>
|
|
<result property="status" column="status"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="merchantId" column="merchant_id"/>
|
|
<result property="submitTime" column="submit_time"/>
|
|
<result property="auditStatus" column="audit_status"/>
|
|
<result property="auditTime" column="audit_time"/>
|
|
<result property="rejectReason" column="reject_reason"/>
|
|
<result property="flag" column="flag"/>
|
|
<result property="shopName" column="shop_name"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="ZdyEateryProductZdyEateryProductSpecsResult" type="ZdyEateryProduct"
|
|
extends="ZdyEateryProductResult">
|
|
<collection property="zdyEateryProductSpecsList" notNullColumn="sub_id"
|
|
javaType="java.util.List" resultMap="ZdyEateryProductSpecsResult"/>
|
|
</resultMap>
|
|
|
|
<resultMap type="ZdyEateryProductSpecs" id="ZdyEateryProductSpecsResult">
|
|
<result property="id" column="sub_id"/>
|
|
<result property="productId" column="sub_product_id"/>
|
|
<result property="name" column="sub_name"/>
|
|
<result property="price" column="sub_price"/>
|
|
<result property="createBy" column="sub_create_by"/>
|
|
<result property="createTime" column="sub_create_time"/>
|
|
<result property="updateBy" column="sub_update_by"/>
|
|
<result property="updateTime" column="sub_update_time"/>
|
|
<result property="remark" column="sub_remark"/>
|
|
<result property="merchantId" column="sub_merchant_id"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectZdyEateryProductVo">
|
|
select ep.id,
|
|
ep.name,
|
|
ep.type,
|
|
ep.img,
|
|
ep.sale_prise,
|
|
ep.code,
|
|
ep.sort,
|
|
ep.status,
|
|
ep.manufacture_date,
|
|
ep.create_by,
|
|
ep.create_time,
|
|
ep.update_by,
|
|
ep.update_time,
|
|
ep.remark,
|
|
ep.merchant_id,
|
|
ep.submit_time,
|
|
ep.audit_status,
|
|
ep.audit_time,
|
|
ep.reject_reason,
|
|
ep.flag,
|
|
ep.sort
|
|
from zdy_eatery_product ep
|
|
left join sys_dept d on ep.merchant_id = d.dept_id
|
|
</sql>
|
|
|
|
<select id="selectZdyEateryProductList" parameterType="ZdyEateryProduct" resultMap="ZdyEateryProductResult">
|
|
select ep.id, ep.name, ep.type, ep.img, ep.sale_prise, ep.code, ep.sort, ep.status, ep.manufacture_date,
|
|
ep.create_by, ep.create_time, ep.update_by, ep.update_time, ep.remark, ep.merchant_id,
|
|
ep.submit_time,
|
|
ep.audit_status,
|
|
ep.audit_time,
|
|
ep.reject_reason,
|
|
ep.flag,
|
|
ep.sort,
|
|
sbi.name shop_name
|
|
from zdy_eatery_product ep
|
|
left join sys_dept d on ep.merchant_id = d.dept_id
|
|
left join zdy_store_base_info sbi on sbi.dept_id=d.dept_id
|
|
<where>
|
|
and ep.delete_flag = 0
|
|
<if test="name != null and name != ''">
|
|
and ep.name like concat('%', #{name}, '%')
|
|
</if>
|
|
<if test="type != null and type != ''">
|
|
and ep.type = #{type}
|
|
</if>
|
|
<if test="img != null and img != ''">
|
|
and ep.img = #{img}
|
|
</if>
|
|
<if test="code != null and code != ''">
|
|
and ep.code = #{code}
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
and FIND_IN_SET(ep.status, #{status}) > 0
|
|
</if>
|
|
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
|
|
and ep.manufacture_date between #{params.beginTime} and #{params.endTime}
|
|
</if>
|
|
<if test="params.beginManufactureDate != null and params.beginManufactureDate != '' and params.endManufactureDate != null and params.endManufactureDate != ''">
|
|
and ep.manufacture_date between #{params.beginManufactureDate} and #{params.endManufactureDate}
|
|
</if>
|
|
<if test="merchantId != null ">
|
|
and ep.merchant_id = #{merchantId}
|
|
</if>
|
|
<if test="params.submitBeginTime != null and params.submitBeginTime != ''"><!-- 开始时间检索 -->
|
|
AND date_format(ep.submit_time,'%y%m%d') >= date_format(#{params.submitBeginTime},'%y%m%d')
|
|
</if>
|
|
<if test="params.submitEndTime != null and params.submitEndTime != ''"><!-- 结束时间检索 -->
|
|
AND date_format(ep.submit_time,'%y%m%d') <= date_format(#{params.submitEndTime},'%y%m%d')
|
|
</if>
|
|
<if test="auditStatus != null ">
|
|
and ep.audit_status = #{auditStatus}
|
|
</if>
|
|
${params.dataScope}
|
|
</where>
|
|
order by ep.sort
|
|
</select>
|
|
|
|
<select id="selectZdyEateryProductById" parameterType="Long"
|
|
resultMap="ZdyEateryProductZdyEateryProductSpecsResult">
|
|
select a.id,
|
|
a.name,
|
|
a.type,
|
|
a.img,
|
|
a.sale_prise,
|
|
a.code,
|
|
a.manufacture_date,
|
|
a.status,
|
|
a.create_by,
|
|
a.create_time,
|
|
a.update_by,
|
|
a.update_time,
|
|
a.remark,
|
|
a.merchant_id,
|
|
b.id as
|
|
sub_id,
|
|
b.product_id as
|
|
sub_product_id,
|
|
b.name as
|
|
sub_name,
|
|
b.price as
|
|
sub_price,
|
|
b.create_by as
|
|
sub_create_by,
|
|
b.create_time as
|
|
sub_create_time,
|
|
b.update_by as
|
|
sub_update_by,
|
|
b.update_time as
|
|
sub_update_time,
|
|
b.remark as
|
|
sub_remark,
|
|
b.merchant_id as
|
|
sub_merchant_id,
|
|
a.sort,
|
|
a.submit_time,
|
|
a.audit_status,
|
|
a.audit_time,
|
|
a.reject_reason,
|
|
a.flag
|
|
from zdy_eatery_product a
|
|
left join zdy_eatery_product_specs b on b.product_id = a.id
|
|
where a.id = #{id}
|
|
</select>
|
|
<select id="selectZdyEateryProductByName" resultType="com.zhwl.eatery.domain.ZdyEateryProduct">
|
|
select id, name, type, img, sale_prise, code, manufacture_date, sort, create_by, create_time, update_by,
|
|
update_time, remark, merchant_id, delete_flag
|
|
from zdy_eatery_product a
|
|
where delete_flag = 0 and a.name = #{name}
|
|
<if test="merchantId != null">
|
|
and merchant_id = #{merchantId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectZdyEateryProductListWithoutLogin" parameterType="ZdyEateryProduct"
|
|
resultMap="ZdyEateryProductResult">
|
|
<include refid="selectZdyEateryProductVo"/>
|
|
left join zdy_store_base_info sbi on d.dept_id = sbi.dept_id
|
|
<where>
|
|
and ep.delete_flag = 0
|
|
and sbi.register_audit_status = 'APPROVED'
|
|
and sbi.grounding_status = 'up'
|
|
|
|
<if test="name != null and name != ''">
|
|
and ep.name like concat('%', #{name}, '%')
|
|
</if>
|
|
<if test="type != null and type != ''">
|
|
and ep.type = #{type}
|
|
</if>
|
|
<if test="img != null and img != ''">
|
|
and ep.img = #{img}
|
|
</if>
|
|
<if test="code != null and code != ''">
|
|
and ep.code = #{code}
|
|
</if>
|
|
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
|
|
and ep.manufacture_date between #{params.beginTime} and #{params.endTime}
|
|
</if>
|
|
<if test="params.beginManufactureDate != null and params.beginManufactureDate != '' and params.endManufactureDate != null and params.endManufactureDate != ''">
|
|
and ep.manufacture_date between #{params.beginManufactureDate} and #{params.endManufactureDate}
|
|
</if>
|
|
<if test="merchantId != null ">
|
|
and ep.merchant_id = #{merchantId}
|
|
</if>
|
|
<if test="auditStatus != null ">
|
|
and ep.audit_status = #{auditStatus}
|
|
</if>
|
|
<if test="status != null and status!=''">
|
|
and ep.status = #{status}
|
|
</if>
|
|
</where>
|
|
order by sort
|
|
</select>
|
|
<select id="selectZdyEateryProductListByTypeId" resultMap="ZdyEateryProductResult">
|
|
<include refid="selectZdyEateryProductVo"/>
|
|
left join zdy_store_base_info sbi on d.dept_id = sbi.dept_id
|
|
<where>
|
|
and ep.delete_flag = 0
|
|
|
|
and ep.status = 'up'
|
|
and ep.audit_status = 2
|
|
|
|
and sbi.register_audit_status = 'APPROVED'
|
|
and sbi.grounding_status = 'up'
|
|
<if test="productSet != null and productSet != ''">
|
|
AND ep.id in
|
|
<foreach collection="productSet " item="item" open=" (" close=")"
|
|
separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="typeId != null and typeId != ''">
|
|
and ep.type = #{typeId}
|
|
</if>
|
|
</where>
|
|
order by ep.sort
|
|
</select>
|
|
|
|
|
|
<insert id="insertZdyEateryProduct" parameterType="ZdyEateryProduct" useGeneratedKeys="true"
|
|
keyProperty="id">
|
|
insert into zdy_eatery_product
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="name != null">name,
|
|
</if>
|
|
<if test="type != null">type,
|
|
</if>
|
|
<if test="img != null">img,
|
|
</if>
|
|
<if test="salePrise != null">sale_prise,
|
|
</if>
|
|
<if test="code != null">code,
|
|
</if>
|
|
<if test="manufactureDate != null">manufacture_date,
|
|
</if>
|
|
<if test="createBy != null">create_by,
|
|
</if>
|
|
<if test="createTime != null">create_time,
|
|
</if>
|
|
<if test="updateBy != null">update_by,
|
|
</if>
|
|
<if test="updateTime != null">update_time,
|
|
</if>
|
|
<if test="remark != null">remark,
|
|
</if>
|
|
<if test="merchantId != null">merchant_id,
|
|
</if>
|
|
<if test="sort != null">sort,
|
|
</if>
|
|
<if test="submitTime != null">submit_time,
|
|
</if>
|
|
<if test="auditStatus != null">audit_status,
|
|
</if>
|
|
<if test="auditTime != null">audit_time,
|
|
</if>
|
|
<if test="rejectReason != null and rejectReason !='' ">reject_reason,
|
|
</if>
|
|
<if test="flag != null ">flag,
|
|
</if>
|
|
<if test="status != null ">status,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="name != null">#{name},
|
|
</if>
|
|
<if test="type != null">#{type},
|
|
</if>
|
|
<if test="img != null">#{img},
|
|
</if>
|
|
<if test="salePrise != null">#{salePrise},
|
|
</if>
|
|
<if test="code != null">#{code},
|
|
</if>
|
|
<if test="manufactureDate != null">#{manufactureDate},
|
|
</if>
|
|
<if test="createBy != null">#{createBy},
|
|
</if>
|
|
<if test="createTime != null">#{createTime},
|
|
</if>
|
|
<if test="updateBy != null">#{updateBy},
|
|
</if>
|
|
<if test="updateTime != null">#{updateTime},
|
|
</if>
|
|
<if test="remark != null">#{remark},
|
|
</if>
|
|
<if test="merchantId != null">#{merchantId},
|
|
</if>
|
|
<if test="sort != null">#{sort},
|
|
</if>
|
|
<if test="submitTime != null">#{submitTime},
|
|
</if>
|
|
<if test="auditStatus != null">#{auditStatus},
|
|
</if>
|
|
<if test="auditTime != null">#{auditTime},
|
|
</if>
|
|
<if test="rejectReason != null and rejectReason !='' ">#{rejectReason},
|
|
</if>
|
|
<if test="flag != null ">#{flag},
|
|
</if>
|
|
<if test="status != null ">#{status},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateZdyEateryProduct" parameterType="ZdyEateryProduct">
|
|
update zdy_eatery_product
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="name != null">name =
|
|
#{name},
|
|
</if>
|
|
<if test="type != null">type =
|
|
#{type},
|
|
</if>
|
|
<if test="img != null">img =
|
|
#{img},
|
|
</if>
|
|
<if test="salePrise != null">sale_prise =
|
|
#{salePrise},
|
|
</if>
|
|
<if test="manufactureDate != null">manufacture_date =
|
|
#{manufactureDate},
|
|
</if>
|
|
<if test="createBy != null">create_by =
|
|
#{createBy},
|
|
</if>
|
|
<if test="createTime != null">create_time =
|
|
#{createTime},
|
|
</if>
|
|
<if test="updateBy != null">update_by =
|
|
#{updateBy},
|
|
</if>
|
|
<if test="updateTime != null">update_time =
|
|
#{updateTime},
|
|
</if>
|
|
<if test="remark != null">remark =
|
|
#{remark},
|
|
</if>
|
|
<if test="sort != null">sort =
|
|
#{sort},
|
|
</if>
|
|
<if test="submitTime != null">submit_time=
|
|
#{submitTime},
|
|
</if>
|
|
<if test="auditStatus != null">audit_status=
|
|
#{auditStatus},
|
|
</if>
|
|
<if test="auditTime != null">audit_time=
|
|
#{auditTime},
|
|
</if>
|
|
<if test="rejectReason != null and rejectReason !='' ">reject_reason=
|
|
#{rejectReason},
|
|
</if>
|
|
<if test="flag != null ">flag = #{flag},
|
|
</if>
|
|
</trim>
|
|
where id = #{id}
|
|
<if test="merchantId != null">
|
|
and merchant_id = #{merchantId}
|
|
</if>
|
|
</update>
|
|
<update id="offAll" parameterType="java.lang.Long">
|
|
UPDATE `zdy_eatery_product`
|
|
SET `status` = 'down'
|
|
where merchant_id = #{merchantId}
|
|
</update>
|
|
<update id="on">
|
|
UPDATE `zdy_eatery_product` SET `status` = #{status}
|
|
where id = #{id}
|
|
<if test="merchantId != null">
|
|
and merchant_id = #{merchantId}
|
|
</if>
|
|
</update>
|
|
<update id="offByIds">
|
|
UPDATE `zdy_eatery_product` SET `status` = 'down' where id in
|
|
<foreach item="productId" collection="ids" open="(" separator="," close=")">
|
|
#{productId}
|
|
</foreach>
|
|
<if test="merchantId != null">
|
|
and merchant_id = #{merchantId}
|
|
</if>
|
|
</update>
|
|
|
|
<delete id="deleteZdyEateryProductById" parameterType="Long">
|
|
update zdy_eatery_product SET `delete_flag` = '1' where id = #{id}
|
|
<if test="merchantId != null">
|
|
and merchant_id = #{merchantId}
|
|
</if>
|
|
</delete>
|
|
|
|
<delete id="deleteZdyEateryProductByIds" parameterType="String">
|
|
delete from zdy_eatery_product where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<delete id="deleteZdyEateryProductSpecsByProductIds" parameterType="String">
|
|
delete from zdy_eatery_product_specs where product_id in
|
|
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
|
#{productId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<delete id="deleteZdyEateryProductSpecsByProductId" parameterType="Long">
|
|
delete
|
|
from zdy_eatery_product_specs
|
|
where product_id = #{productId}
|
|
</delete>
|
|
|
|
<insert id="batchZdyEateryProductSpecs">
|
|
insert into zdy_eatery_product_specs
|
|
( id , product_id , name , price , create_by , create_time , update_by , update_time , remark , merchant_id)
|
|
values
|
|
<foreach item="item" index="index" collection="list" separator=",">
|
|
( #{item.id
|
|
}, #{item.productId
|
|
}, #{item.name
|
|
}, #{item.price
|
|
}, #{item.createBy
|
|
}, #{item.createTime
|
|
}, #{item.updateBy
|
|
}, #{item.updateTime
|
|
}, #{item.remark
|
|
}, #{item.merchantId
|
|
})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="selectZdyEateryProductListByDeptIdAndProductType"
|
|
resultMap="ZdyEateryProductResult">
|
|
select *
|
|
from zdy_eatery_product
|
|
<where>
|
|
delete_flag = 0
|
|
<if test="deptId!=null">
|
|
and merchant_id = #{deptId}
|
|
</if>
|
|
<if test="types != null and types.size() > 0">
|
|
and type in
|
|
<foreach collection="types" item="type" separator="," open="(" close=")">
|
|
#{type}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<delete id="deleteByDeptIds" parameterType="long">
|
|
update zdy_eatery_product SET `delete_flag` = 1 where merchant_id in
|
|
<foreach item="deptId" collection="deptIds" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteSpecsByDeptIds" parameterType="long">
|
|
delete zdy_eatery_product where merchant_id in
|
|
<foreach item="deptId" collection="deptIds" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
</mapper>
|