<?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.ShoppingGoodsAssembleDao">
|
|
<resultMap type="ShoppingGoodsAssemble" id="ShoppingGoodsAssembleMap">
|
<id property="id" column="id"/>
|
<result property="shoppingGoodsId" column="shopping_goods_id"/>
|
<result property="assembleSkuId" column="assemble_sku_id"/>
|
<result property="assembleProjId" column="assemble_proj_id"/>
|
<result property="price" column="price"/>
|
<result property="total" column="total"/>
|
<result property="status" column="status"/>
|
<result property="deductionNum" column="deductionNum"/>
|
<result property="assembleGoodId" column="assembleGoodId"/>
|
|
|
<association property="shoppingGoods" resultMap="com.matrix.system.hive.dao.ShoppingGoodsDao.ShoppingGoodsSimpleMap" />
|
|
|
|
|
</resultMap>
|
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="ShoppingGoodsAssemble"
|
useGeneratedKeys="true" keyProperty="id">
|
INSERT INTO
|
shopping_goods_assemble (
|
id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
price,
|
status,
|
deductionNum,
|
assembleGoodId
|
)
|
VALUES (
|
#{id},
|
#{shoppingGoodsId},
|
#{assembleSkuId},
|
#{assembleProjId},
|
#{total},
|
#{price},
|
#{status},
|
#{deductionNum},
|
#{assembleGoodId}
|
)
|
</insert>
|
|
<!-- 批量插入 -->
|
<insert id="batchInsert" parameterType="java.util.List">
|
INSERT INTO shopping_goods_assemble (
|
id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
price,
|
status,
|
deductionNum,
|
assembleGoodId
|
)
|
VALUES
|
<foreach collection="list" item="item" index="index"
|
separator=",">(
|
#{item.id},
|
#{item.shoppingGoodsId},
|
#{item.assembleSkuId},
|
#{item.assembleProjId},
|
#{item.total},
|
#{item.price},
|
#{item.status},
|
#{item.deductionNum},
|
#{item.assembleGoodId}
|
)
|
</foreach>
|
</insert>
|
|
|
<!-- 根据id更新 部分更新 -->
|
<update id="update">
|
UPDATE shopping_goods_assemble
|
<set>
|
<if test="shoppingGoodsId != null and shoppingGoodsId !='' ">
|
shopping_goods_id = #{shoppingGoodsId},
|
</if>
|
<if test="assembleSkuId != null and assembleSkuId !='' ">
|
assemble_sku_id = #{assembleSkuId},
|
</if>
|
<if test="assembleProjId != null and assembleProjId !='' ">
|
assemble_proj_id = #{assembleProjId},
|
</if>
|
<if test="total != null and total !='' ">
|
total = #{total},
|
</if>
|
<if test="price != null and price !='' ">
|
price = #{price},
|
</if>
|
<if test="status != null and status !='' ">
|
status = #{status},
|
</if>
|
<if test="deductionNum != null and deductionNum !='' ">
|
deductionNum = #{deductionNum},
|
</if>
|
<if test="assembleGoodId != null and assembleGoodId !='' ">
|
assembleGoodId = #{assembleGoodId},
|
</if>
|
</set>
|
WHERE id=#{id}
|
</update>
|
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from shopping_goods_assemble where id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除 -->
|
<delete id="deleteById">
|
DELETE FROM
|
shopping_goods_assemble
|
where id=#{id}
|
</delete>
|
|
|
<delete id="deleteByGoodsId">
|
DELETE FROM
|
shopping_goods_assemble
|
where shopping_goods_id=#{shoppingGoodsId}
|
</delete>
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="ShoppingGoodsAssembleMap">
|
select
|
sga.id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
sga.price,
|
status,
|
deductionNum,
|
assembleGoodId
|
from shopping_goods_assemble sga
|
LEFT JOIN sys_goods s ON sga.assemble_sku_id =s.id
|
where 1=1
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and id =#{record.id}
|
</if>
|
<if test="record.shoppingGoodsId != null and record.shoppingGoodsId !='' ">
|
and shopping_goods_id =#{record.shoppingGoodsId}
|
</if>
|
<if test="record.assembleSkuId != null and record.assembleSkuId !='' ">
|
and assemble_sku_id =#{record.assembleSkuId}
|
</if>
|
<if test="record.assembleProjId != null and record.assembleProjId !='' ">
|
and assemble_proj_id =#{record.assembleProjId}
|
</if>
|
<if test="record.total != null and record.total !='' ">
|
and total =#{record.total}
|
</if>
|
<if test="record.price != null and record.price !='' ">
|
and price =#{record.price}
|
</if>
|
<if test="record.status != null and record.status !='' ">
|
and status =#{record.status}
|
</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 shopping_goods_assemble
|
where 1=1
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and id =#{record.id}
|
</if>
|
<if test="record.shoppingGoodsId != null and record.shoppingGoodsId !='' ">
|
and shopping_goods_id =#{record.shoppingGoodsId}
|
</if>
|
<if test="record.assembleSkuId != null and record.assembleSkuId !='' ">
|
and assemble_sku_id =#{record.assembleSkuId}
|
</if>
|
<if test="record.assembleProjId != null and record.assembleProjId !='' ">
|
and assemble_proj_id =#{record.assembleProjId}
|
</if>
|
<if test="record.total != null and record.total !='' ">
|
and total =#{record.total}
|
</if>
|
<if test="record.price != null and record.price !='' ">
|
and price =#{record.price}
|
</if>
|
<if test="record.status != null and record.status !='' ">
|
and status =#{record.status}
|
</if>
|
</if>
|
</select>
|
|
<!-- 根据id查询 -->
|
<select id="selectById" resultMap="ShoppingGoodsAssembleMap">
|
select
|
id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
price,
|
status,
|
deductionNum,
|
assembleGoodId
|
from shopping_goods_assemble
|
where id=#{id}
|
</select>
|
|
|
<select id="selectForShoppingCar" resultMap="ShoppingGoodsAssembleMap">
|
select
|
sga.id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
sga.price,
|
status,
|
deductionNum,
|
assembleGoodId
|
from shopping_goods_assemble sga
|
LEFT JOIN sys_goods s ON sga.assemble_sku_id
|
=s.id
|
LEFT JOIN shopping_goods sg ON sga.shopping_goods_id=sg.id
|
where
|
sga.id=#{id}
|
</select>
|
|
|
<!-- 根据对象查询 -->
|
<select id="selectByModel" resultMap="ShoppingGoodsAssembleMap">
|
select
|
id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
price,
|
status,
|
deductionNum,
|
assembleGoodId
|
from shopping_goods_assemble
|
where 1=1
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and id =#{record.id}
|
</if>
|
<if test="record.shoppingGoodsId != null and record.shoppingGoodsId !='' ">
|
and shopping_goods_id =#{record.shoppingGoodsId}
|
</if>
|
<if test="record.assembleSkuId != null and record.assembleSkuId !='' ">
|
and assemble_sku_id =#{record.assembleSkuId}
|
</if>
|
<if test="record.assembleProjId != null and record.assembleProjId !='' ">
|
and assemble_proj_id =#{record.assembleProjId}
|
</if>
|
<if test="record.total != null and record.total !='' ">
|
and total =#{record.total}
|
</if>
|
<if test="record.price != null and record.price !='' ">
|
and price =#{record.price}
|
</if>
|
<if test="record.status != null and record.status !='' ">
|
and status =#{record.status}
|
</if>
|
</if>
|
</select>
|
|
<select id="selectGoodsByShoppingGoodsIdAndType"
|
resultMap="ShoppingGoodsAssembleMap">
|
SELECT
|
a.id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
a.price,
|
STATUS,
|
deductionNum,
|
assembleGoodId,
|
g.*,
|
(select TYPE_NAME from sys_goods_type t where t.id=g.GOODS_SORT_ID) GOODS_SORT_NAME,
|
(select NAME from shopping_goods_category t where t.id = g.cate_id) as cate_name
|
FROM
|
shopping_goods_assemble a
|
LEFT JOIN shopping_goods g ON a.assembleGoodId = g.id
|
where
|
shopping_goods_id=#{goodsId}
|
<if test="goodsType!=null">
|
and g.good_type=#{goodsType}
|
</if>
|
|
</select>
|
|
|
<select id="selectGoodsByShoppingGoodsId"
|
resultMap="ShoppingGoodsAssembleMap">
|
SELECT
|
a.id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
a.price,
|
STATUS,
|
deductionNum,
|
assembleGoodId,
|
g.*,
|
(select TYPE_NAME from sys_goods_type t where t.id=g.GOODS_SORT_ID) GOODS_SORT_NAME,
|
(select NAME from shopping_goods_category t where t.id = g.cate_id) as cate_name
|
FROM
|
shopping_goods_assemble a
|
LEFT JOIN shopping_goods g ON a.assembleGoodId = g.id
|
where
|
shopping_goods_id=#{goodsId}
|
|
|
</select>
|
|
<select id="selectProjByShoppingGoodsId"
|
resultMap="ShoppingGoodsAssembleMap">
|
SELECT
|
a.id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
a.price,
|
STATUS,
|
deductionNum,
|
assembleGoodId
|
FROM
|
shopping_goods_assemble a
|
where
|
shopping_goods_id=#{goodsId}
|
and assemble_proj_id is not null
|
</select>
|
|
<select id="selectAssembleShoppingGoodsByShoppingGoodsId"
|
resultMap="ShoppingGoodsAssembleMap">
|
SELECT
|
a.id,
|
shopping_goods_id,
|
assemble_sku_id,
|
assemble_proj_id,
|
total,
|
a.price,
|
STATUS,
|
deductionNum,
|
assembleGoodId,
|
|
g.ID as sp_id,
|
g.name,
|
g.introduction,
|
g.staus,
|
g.seal_pice,
|
g.reference_pice,
|
g.seal_count,
|
g.is_assemble,
|
g.deleted,
|
g.cate_id,
|
g.jf_pice,
|
g.jf_number,
|
g.good_type,
|
g.sale_off_time,
|
g.is_present,
|
g.is_once,
|
g.sale_platform,
|
g.validity,
|
g.is_course,
|
g.car_max_sale_count,
|
g.car_is_all,
|
g.car_use_count,
|
(select NAME from shopping_goods_category t where t.id=cate_id) as cate_name,
|
g.is_vip_car,
|
g.vip_grad_id,
|
g.is_integral,
|
g.real_seal_count,
|
g.store,
|
g.commission_rate,
|
g.is_distribution,
|
g.frist_commission,
|
g.second_commission
|
FROM
|
shopping_goods_assemble a
|
LEFT JOIN shopping_goods g ON a.assembleGoodId = g.id
|
where
|
shopping_goods_id=#{goodsId}
|
and assembleGoodId is not null
|
</select>
|
|
|
|
|
|
<!-- 如果商品到了自动下架时间 则它绑定的商品全部下架,根据商品id修改它所绑定的商品 -->
|
<update id="updateByGoodsId">
|
UPDATE shopping_goods_assemble
|
<set>
|
<if test="status != null and status !='' ">
|
status = #{status}
|
</if>
|
</set>
|
WHERE shopping_goods_id = #{shoppingGoodsId}
|
</update>
|
|
|
</mapper>
|