<?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.matrix.system.hive.dao.SysGoodsDao">
|
|
<resultMap type="SysGoods" id="SysGoodsMap">
|
<id property="id" column="ID"/>
|
|
<!-- 外键id冲突时使用goodsId做映射 -->
|
<result property="id" column="goodsId"/>
|
|
<result property="goodsNo" column="GOODS_NO"/>
|
<result property="name" column="NAME"/>
|
<result property="unit" column="UNIT"/>
|
<result property="deleted" column="DELETED"/>
|
<result property="goodsAttr" column="GOODS_ATTR"/>
|
<result property="goodsSortId" column="GOODS_SORT_ID"/>
|
<result property="supplierId" column="SUPPLIER_ID"/>
|
<result property="measure" column="MEASURE"/>
|
<result property="alarmNum" column="alarm_num"/>
|
<result property="volume" column="volume"/>
|
<result property="price" column="price"/>
|
<result property="wholesale" column="wholesale"/>
|
<result property="shopId" column="shop_id"/>
|
<result property="companyId" column="company_id"/>
|
|
|
<!-- 扩展属性 -->
|
<result property="goodsSortName" column="GOODS_SORT_NAME"/>
|
|
</resultMap>
|
<!-- 不包含sku的map -->
|
<resultMap type="SysGoods" id="SysGoodsNoSkuMap">
|
<id property="id" column="ID"/>
|
<result property="goodsNo" column="GOODS_NO"/>
|
<result property="name" column="NAME"/>
|
<result property="unit" column="UNIT"/>
|
<result property="deleted" column="DELETED"/>
|
<result property="goodsAttr" column="GOODS_ATTR"/>
|
<result property="goodsSortId" column="GOODS_SORT_ID"/>
|
<result property="supplierId" column="SUPPLIER_ID"/>
|
<result property="measure" column="MEASURE"/>
|
|
<result property="alarmNum" column="alarm_num"/>
|
<result property="volume" column="volume"/>
|
<result property="price" column="price"/>
|
<result property="wholesale" column="wholesale"/>
|
<result property="shopId" column="shop_id"/>
|
<result property="companyId" column="company_id"/>
|
|
|
<!-- 扩展属性 -->
|
<result property="goodsSortName" column="GOODS_SORT_NAME"/>
|
</resultMap>
|
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="SysGoods"
|
useGeneratedKeys="true" keyProperty="id">
|
INSERT INTO sys_goods (
|
ID,
|
GOODS_NO,
|
NAME,
|
UNIT,
|
DELETED,
|
GOODS_ATTR,
|
GOODS_SORT_ID,
|
SUPPLIER_ID,
|
MEASURE,
|
alarm_num,
|
volume,
|
price,
|
wholesale,
|
shop_id,
|
company_id
|
)
|
VALUES (
|
#{id},
|
#{goodsNo},
|
#{name},
|
#{unit},
|
#{deleted},
|
#{goodsAttr},
|
#{goodsSortId},
|
#{supplierId},
|
#{measure},
|
#{alarmNum},
|
#{volume},
|
#{price},
|
#{wholesale},
|
#{shopId},
|
#{companyId}
|
)
|
</insert>
|
|
|
<!-- 根据id更新 部分更新 -->
|
<update id="update">
|
UPDATE sys_goods
|
<set>
|
<if test="measure != null and measure !='' ">
|
MEASURE = #{measure},
|
</if>
|
<if test="goodsNo != null and goodsNo !='' ">
|
GOODS_NO = #{goodsNo},
|
</if>
|
<if test="name != null and name !='' ">
|
NAME = #{name},
|
</if>
|
<if test="unit != null and unit !='' ">
|
UNIT = #{unit},
|
</if>
|
|
<if test="deleted != null and deleted !='' ">
|
DELETED = #{deleted},
|
</if>
|
<if test="goodsAttr != null and goodsAttr !='' ">
|
GOODS_ATTR = #{goodsAttr},
|
</if>
|
<if test="goodsSortId != null and goodsSortId !='' ">
|
GOODS_SORT_ID = #{goodsSortId},
|
</if>
|
|
<if test="supplierId != null and supplierId !='' ">
|
SUPPLIER_ID = #{supplierId},
|
</if>
|
|
|
<if test="alarmNum != null and alarmNum !='' ">
|
alarm_num = #{alarmNum},
|
</if>
|
<if test="volume != null and volume !='' ">
|
volume = #{volume},
|
</if>
|
<if test="price != null and price !='' ">
|
price = #{price},
|
</if>
|
<if test="wholesale != null and wholesale !='' ">
|
wholesale = #{wholesale},
|
</if>
|
<if test="companyId != null and companyId !='' ">
|
company_id = #{companyId},
|
</if>
|
<if test="shopId != null and shopId !='' ">
|
shop_id = #{shopId},
|
</if>
|
|
</set>
|
WHERE ID=#{id}
|
</update>
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
|
update
|
sys_goods
|
set
|
DELETED = 'Y',
|
GOODS_NO=concat(GOODS_NO,'[失效]')
|
where
|
ID in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除-->
|
<delete id="deleteById">
|
update
|
sys_goods
|
set
|
DELETED = 'Y',
|
GOODS_NO=concat(GOODS_NO,'[失效]')
|
where ID=#{id}
|
</delete>
|
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="SysGoodsMap">
|
select
|
ID,
|
GOODS_NO,
|
NAME,
|
UNIT,
|
DELETED,
|
GOODS_ATTR,
|
GOODS_SORT_ID,<!-- 商品分类id -->
|
SUPPLIER_ID,
|
(select TYPE_NAME from sys_goods_type t where t.id=GOODS_SORT_ID) GOODS_SORT_NAME,<!-- 商品分类名称 -->
|
|
MEASURE,
|
alarm_num,
|
volume,
|
price,
|
wholesale,
|
shop_id,
|
company_id
|
from sys_goods
|
where
|
1=1
|
and
|
DELETED = 'N'
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and ID = #{record.id}
|
</if>
|
<if test="record.goodsNo != null and record.goodsNo !='' ">
|
and GOODS_NO like CONCAT('%',#{record.goodsNo},'%')
|
</if>
|
<if test="record.name != null and record.name !='' ">
|
and NAME like CONCAT('%',#{record.name},'%')
|
</if>
|
<if test="record.goodsAttr != null and record.goodsAttr !='' ">
|
and GOODS_ATTR like concat('%',#{record.goodsAttr},'%')
|
</if>
|
<if test="record.goodsSortId != null and record.goodsSortId !='' ">
|
and GOODS_SORT_ID = #{record.goodsSortId}
|
</if>
|
<if test="record.supplierId != null and record.supplierId !='' ">
|
and SUPPLIER_ID = #{record.supplierId}
|
</if>
|
<if test="record.shopId != null and record.shopId !='' ">
|
and shop_id = #{record.shopId}
|
</if>
|
<if test="record.companyId != null and record.companyId !='' ">
|
and company_id = #{record.companyId}
|
</if>
|
</if>
|
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 查询总条数 -->
|
<select id="selectTotalRecord" resultType="java.lang.Integer">
|
select count(*)
|
from sys_goods
|
where
|
1=1
|
and
|
DELETED = 'N'
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and ID = #{record.id}
|
</if>
|
<if test="record.goodsNo != null and record.goodsNo !='' ">
|
and GOODS_NO like CONCAT('%',#{record.goodsNo},'%')
|
</if>
|
<if test="record.name != null and record.name !='' ">
|
and NAME like CONCAT('%',#{record.name},'%')
|
</if>
|
<if test="record.goodsAttr != null and record.goodsAttr !='' ">
|
and GOODS_ATTR like concat('%',#{record.goodsAttr},'%')
|
<!-- and #{record.goodsAttr} like concat('%',GOODS_ATTR,'%') -->
|
</if>
|
<if test="record.goodsSortId != null and record.goodsSortId !='' ">
|
and GOODS_SORT_ID = #{record.goodsSortId}
|
</if>
|
<if test="record.supplierId != null and record.supplierId !='' ">
|
and SUPPLIER_ID = #{record.supplierId}
|
</if>
|
<if test="record.shopId != null and record.shopId !='' ">
|
and shop_id = #{record.shopId}
|
</if>
|
<if test="record.companyId != null and record.companyId !='' ">
|
and company_id = #{record.companyId}
|
</if>
|
</if>
|
</select>
|
|
<!-- 根据id查询-->
|
<select id="selectById" resultMap="SysGoodsMap">
|
select
|
ID,
|
GOODS_NO,
|
NAME,
|
UNIT,
|
DELETED,
|
GOODS_ATTR,
|
SUPPLIER_ID,
|
MEASURE,
|
GOODS_SORT_ID,<!-- 商品分类id -->
|
(select TYPE_NAME from sys_goods_type t where t.id=GOODS_SORT_ID) GOODS_SORT_NAME,<!-- 商品分类名称 -->
|
alarm_num,
|
volume,
|
price,
|
wholesale,
|
shop_id,
|
company_id
|
from sys_goods
|
where
|
id=#{id}
|
and
|
deleted='N'
|
</select>
|
|
|
<!-- 根据对象查询-->
|
<select id="selectByModel" resultMap="SysGoodsMap">
|
select
|
ID,
|
GOODS_NO,
|
NAME,
|
UNIT,
|
DELETED,
|
GOODS_ATTR,
|
SUPPLIER_ID,
|
MEASURE,
|
GOODS_SORT_ID,<!-- 商品分类id -->
|
(select TYPE_NAME from sys_goods_type t where t.id=GOODS_SORT_ID) GOODS_SORT_NAME,<!-- 商品分类名称 -->
|
alarm_num,
|
volume,
|
price,
|
wholesale,
|
shop_id,
|
company_id
|
from sys_goods
|
where
|
1=1
|
and
|
deleted = 'N'
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and ID = #{record.id}
|
</if>
|
<if test="record.goodsNo != null and record.goodsNo !='' ">
|
and GOODS_NO like CONCAT('%',#{record.goodsNo},'%')
|
</if>
|
<if test="record.name != null and record.name !='' ">
|
and NAME like CONCAT('%',#{record.name},'%')
|
</if>
|
<if test="record.goodsAttr != null and record.goodsAttr !='' ">
|
and GOODS_ATTR = #{record.goodsAttr}
|
</if>
|
<if test="record.goodsSortId != null and record.goodsSortId !='' ">
|
and GOODS_SORT_ID = #{record.goodsSortId}
|
</if>
|
<if test="record.supplierId != null and record.supplierId !='' ">
|
and SUPPLIER_ID = #{record.supplierId}
|
</if>
|
<if test="record.shopId != null and record.shopId !='' ">
|
and shop_id = #{record.shopId}
|
</if>
|
<if test="record.companyId != null and record.companyId !='' ">
|
and company_id = #{record.companyId}
|
</if>
|
</if>
|
</select>
|
|
<!-- 统计本产品中的sku是否被项目所绑定 -->
|
<select id="getbindProjCount" parameterType="java.lang.Long" resultType="java.lang.Integer">
|
select
|
count(1)
|
from
|
sys_proj_goods a
|
where
|
a.SKU_ID =#{id}
|
</select>
|
|
|
<select id="getbindTaocanCount" parameterType="java.lang.Long" resultType="java.lang.Integer">
|
select
|
count(1)
|
from
|
shopping_goods_assemble a
|
where
|
a.assemble_sku_id =#{id}
|
</select>
|
|
|
<!-- 查询所有的编号,供用户查看-->
|
<select id="selectAllNo" resultMap="SysGoodsNoSkuMap">
|
select
|
ID,
|
GOODS_NO
|
from sys_goods
|
</select>
|
</mapper>
|