<?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.panzhihua.service_community.dao.ComBatteryCommodityMapper">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComBatteryCommodity" id="ComBatteryCommodityMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="code" column="code" jdbcType="VARCHAR"/>
|
<result property="price" column="price" jdbcType="VARCHAR"/>
|
<result property="storeId" column="store_id" jdbcType="INTEGER"/>
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
<result property="classId" column="class_id" jdbcType="INTEGER"/>
|
<result property="introduce" column="introduce" jdbcType="VARCHAR"/>
|
<result property="postage" column="postage" jdbcType="VARCHAR"/>
|
<result property="images" column="images" jdbcType="VARCHAR"/>
|
<result property="detail" column="detail" jdbcType="VARCHAR"/>
|
<result property="isDel" column="is_del" jdbcType="INTEGER"/>
|
<result property="createAt" column="create_at" jdbcType="TIMESTAMP"/>
|
<result property="createBy" column="create_by" jdbcType="INTEGER"/>
|
<result property="updateAt" column="update_at" jdbcType="TIMESTAMP"/>
|
<result property="updateBy" column="update_by" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!--查询单个-->
|
<select id="queryById" resultType="com.panzhihua.common.model.vos.common.ComBatteryCommodityVo">
|
SELECT
|
cbc.id,
|
cbc.`name`,
|
cbc.`code`,
|
cbc.price,
|
cbc.store_id,
|
cbc.`status`,
|
cbc.class_id,
|
cbc.introduce,
|
cbc.postage,
|
cbc.images,
|
cbc.detail,
|
cbc.is_del,
|
cbc.create_at,
|
cbc.create_by,
|
cbc.update_at,
|
cbc.update_by,
|
cbs.`name` as storeName,
|
cbsc.`name` as className,
|
(select count(id) from com_battery_commodity_order where commodity_id = cbc.id and `status` in (2,3,4)
|
AND create_at BETWEEN DATE_ADD( curdate(), INTERVAL - DAY ( curdate())+ 1 DAY ) AND now()) as monthSale
|
FROM
|
com_battery_commodity as cbc
|
left join com_battery_store as cbs on cbs.id = cbc.store_id
|
left join com_battery_store_class as cbsc on cbsc.id = cbc.class_id
|
where cbc.id = #{id}
|
</select>
|
|
<!--查询指定行数据-->
|
<select id="queryAllByLimit" resultType="com.panzhihua.common.model.vos.common.ComBatteryCommodityVo">
|
SELECT
|
cbc.id,
|
cbc.`name`,
|
cbc.`code`,
|
cbc.price,
|
cbc.store_id,
|
cbc.`status`,
|
cbc.class_id,
|
cbc.introduce,
|
cbc.postage,
|
cbc.images,
|
cbc.detail,
|
cbc.is_del,
|
cbc.create_at,
|
cbc.create_by,
|
cbc.update_at,
|
cbc.update_by,
|
cbs.`name` as storeName,
|
cbsc.`name` as className,
|
(select count(id) from com_battery_commodity_order where commodity_id = cbc.id and `status` in (2,3,4)) as monthSale
|
FROM
|
com_battery_commodity as cbc
|
left join com_battery_store as cbs on cbs.id = cbc.store_id
|
left join com_battery_store_class as cbsc on cbsc.id = cbc.class_id
|
<where>
|
and cbc.is_del = 2
|
<if test="dto.id != null">
|
and cbc.id = #{dto.id}
|
</if>
|
<if test="dto.name != null and dto.name != ''">
|
and cbc.name = #{dto.name}
|
</if>
|
<if test="dto.code != null and dto.code != ''">
|
and cbc.code = #{dto.code}
|
</if>
|
<if test="dto.storeId != null">
|
and cbc.store_id = #{dto.storeId}
|
</if>
|
<if test="dto.status != null">
|
and cbc.status = #{dto.status}
|
</if>
|
<if test="dto.classId != null">
|
and cbc.class_id = #{dto.classId}
|
</if>
|
<if test="dto.keyWord != null and dto.keyWord != ''">
|
and (cbc.`name` like concat('%',#{dto.keyWord},'%') or cbc.`code` like concat('%',#{dto.keyWord},'%'))
|
</if>
|
</where>
|
order by cbc.create_at desc
|
</select>
|
|
<!--查询所有数据-->
|
<select id="queryAllByList" resultType="com.panzhihua.common.model.vos.common.ComBatteryCommodityVo">
|
SELECT
|
cbc.id,
|
cbc.`name`,
|
cbc.`code`,
|
cbc.price,
|
cbc.store_id,
|
cbc.`status`,
|
cbc.class_id,
|
cbc.introduce,
|
cbc.postage,
|
cbc.images,
|
cbc.detail,
|
cbc.is_del,
|
cbc.create_at,
|
cbc.create_by,
|
cbc.update_at,
|
cbc.update_by,
|
cbs.`name` as storeName,
|
cbsc.`name` as className,
|
(select count(id) from com_battery_commodity_order where commodity_id = cbc.id and `status` in (2,3,4)) as monthSale
|
FROM
|
com_battery_commodity as cbc
|
left join com_battery_store as cbs on cbs.id = cbc.store_id
|
left join com_battery_store_class as cbsc on cbsc.id = cbc.class_id
|
<where>
|
and cbc.is_del = 2
|
<if test="dto.id != null">
|
and cbc.id = #{dto.id}
|
</if>
|
<if test="dto.name != null and dto.name != ''">
|
and cbc.name = #{dto.name}
|
</if>
|
<if test="dto.code != null and dto.code != ''">
|
and cbc.code = #{dto.code}
|
</if>
|
<if test="dto.storeId != null">
|
and cbc.store_id = #{dto.storeId}
|
</if>
|
<if test="dto.status != null">
|
and cbc.status = #{dto.status}
|
</if>
|
<if test="dto.classId != null">
|
and cbc.class_id = #{dto.classId}
|
</if>
|
<if test="dto.keyWord != null and dto.keyWord != ''">
|
and (cbc.`name` like concat('%',#{dto.keyWord},'%') or cbc.`code` like concat('%',#{dto.keyWord},'%'))
|
</if>
|
</where>
|
order by cbc.create_at desc
|
</select>
|
|
<select id="queryByAppletsPage" resultType="com.panzhihua.common.model.vos.common.ComBatteryCommodityVo">
|
SELECT
|
cbc.id,
|
cbc.`name`,
|
cbc.`code`,
|
cbc.price,
|
cbc.store_id,
|
cbc.`status`,
|
cbc.class_id,
|
cbc.introduce,
|
cbc.postage,
|
cbc.images,
|
cbc.detail,
|
cbc.is_del,
|
cbc.create_at,
|
cbc.create_by,
|
cbc.update_at,
|
cbc.update_by,
|
cbs.`name` as storeName,
|
cbsc.`name` as className,
|
(select count(id) from com_battery_commodity_order where commodity_id = cbc.id and `status` in (2,3,4)) as monthSale
|
FROM
|
com_battery_commodity as cbc
|
left join com_battery_store as cbs on cbs.id = cbc.store_id
|
left join com_battery_store_class as cbsc on cbsc.id = cbc.class_id
|
<where>
|
and cbc.is_del = 2 and status = 1
|
<if test="dto.id != null">
|
and cbc.id = #{dto.id}
|
</if>
|
<if test="dto.name != null and dto.name != ''">
|
and cbc.name like concat('%',#{dto.keyWord},'%')
|
</if>
|
<if test="dto.storeId != null">
|
and cbc.store_id = #{dto.storeId}
|
</if>
|
<if test="dto.classId != null">
|
and cbc.class_id = #{dto.classId}
|
</if>
|
</where>
|
order by cbc.create_at desc
|
</select>
|
|
<select id="queryAllByClassIdList" resultType="com.panzhihua.common.model.vos.common.ComBatteryCommodityVo">
|
SELECT
|
cbc.id,
|
cbc.`name`,
|
cbc.`code`,
|
cbc.price,
|
cbc.store_id,
|
cbc.`status`,
|
cbc.class_id,
|
cbc.introduce,
|
cbc.postage,
|
cbc.images,
|
cbc.detail,
|
cbc.is_del,
|
cbc.create_at,
|
cbc.create_by,
|
cbc.update_at,
|
cbc.update_by,
|
cbs.`name` as storeName,
|
cbsc.`name` as className,
|
(select count(id) from com_battery_commodity_order where commodity_id = cbc.id and `status` in (2,3,4)) as monthSale
|
FROM
|
com_battery_commodity as cbc
|
left join com_battery_store as cbs on cbs.id = cbc.store_id
|
left join com_battery_store_class as cbsc on cbsc.id = cbc.class_id
|
where cbc.class_id = #{classId} and cbc.is_del = 2 and cbc.status = 1
|
order by cbc.create_at desc
|
</select>
|
</mapper>
|