<?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.shopXcx.dao.ShopProductDao">
|
|
|
|
|
<!-- 定义ShopProduct 的复杂关联map -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopProduct" id="ShopProductMap">
|
<id property="id" column="id"/>
|
<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="categoryId" column="category_id"/>
|
<result property="title" column="title"/>
|
<result property="briefIntroduction" column="brief_introduction"/>
|
<result property="carriage" column="carriage"/>
|
<result property="imgPc" column="img_pc"/>
|
<result property="imgMobile" column="img_mobile"/>
|
<result property="brand" column="brand"/>
|
<result property="price" column="price"/>
|
<result property="pcDetails" column="pc_details"/>
|
<result property="mobileDetails" column="mobile_details"/>
|
<result property="buyLimit" column="buy_limit"/>
|
<result property="limitCycle" column="limit_cycle"/>
|
<result property="isCanComment" column="is_can_comment"/>
|
<result property="mnemonicCode" column="mnemonic_code"/>
|
<result property="status" column="status"/>
|
<result property="dsVolume" column="ds_volume"/>
|
<result property="rsVolume" column="rs_volume"/>
|
<result property="delFlag" column="del_flag"/>
|
<result property="attrValues" column="attrs_values"/>
|
<result property="isService" column="is_service"/>
|
<result property="isSpecialPrice" column="is_special_price"/>
|
<result property="markedPrice" column="marked_price"/>
|
<result property="atrid" column="atrid"/>
|
<result property="shopIds" column="shop_ids"/>
|
<result property="stockNum" column="stockNum"></result>
|
<result property="couponId" column="couponId"></result>
|
<result property="serviceTime" column="service_time"></result>
|
<result property="companyId" column="company_id"/>
|
<association property="shopCoupon" select="com.matrix.system.shopXcx.dao.ShopCouponDao.selectById"
|
column="{id=couponId}"></association>
|
</resultMap>
|
|
|
<!-- 定义ShopProduct 的简单map ,本map不添加其他的关联属性 -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopProduct" id="ShopProductSimpleMap">
|
<id property="id" column="id"/>
|
<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="categoryId" column="category_id"/>
|
<result property="title" column="title"/>
|
<result property="briefIntroduction" column="brief_introduction"/>
|
<result property="carriage" column="carriage"/>
|
<result property="imgPc" column="img_pc"/>
|
<result property="imgMobile" column="img_mobile"/>
|
<result property="brand" column="brand"/>
|
<result property="price" column="price"/>
|
<result property="pcDetails" column="pc_details"/>
|
<result property="mobileDetails" column="mobile_details"/>
|
<result property="buyLimit" column="buy_limit"/>
|
<result property="limitCycle" column="limit_cycle"/>
|
<result property="isCanComment" column="is_can_comment"/>
|
<result property="mnemonicCode" column="mnemonic_code"/>
|
<result property="status" column="status"/>
|
<result property="dsVolume" column="ds_volume"/>
|
<result property="rsVolume" column="rs_volume"/>
|
<result property="delFlag" column="del_flag"/>
|
<result property="attrValues" column="attrs_values"/>
|
<result property="isService" column="is_service"/>
|
<result property="isSpecialPrice" column="is_special_price"/>
|
<result property="markedPrice" column="marked_price"/>
|
<result property="stockNum" column="stockNum"></result>
|
<result property="couponId" column="couponId"></result>
|
<result property="serviceTime" column="service_time"></result>
|
<result property="companyId" column="company_id"/>
|
</resultMap>
|
|
<sql id="columns">
|
create_by,
|
create_time,
|
update_by,
|
update_time,
|
id,
|
category_id,
|
title,
|
brief_introduction,
|
carriage,
|
img_pc,
|
img_mobile,
|
brand,
|
price,
|
pc_details,
|
mobile_details,
|
buy_limit,
|
limit_cycle,
|
is_can_comment,
|
mnemonic_code,
|
status,
|
ds_volume,
|
rs_volume,
|
del_flag,
|
attrs_values,
|
is_special_price,
|
marked_price,
|
couponId,
|
is_service,
|
service_time,
|
shop_ids,
|
company_id
|
</sql>
|
|
<!-- 属性sql -->
|
<sql id="propertys">
|
#{item.createBy},
|
now(),
|
#{item.updateBy},
|
now(),
|
#{item.id},
|
#{item.categoryId},
|
#{item.title},
|
#{item.briefIntroduction},
|
#{item.carriage},
|
#{item.imgPc},
|
#{item.imgMobile},
|
#{item.brand},
|
#{item.price},
|
#{item.pcDetails},
|
#{item.mobileDetails},
|
#{item.buyLimit},
|
#{item.limitCycle},
|
#{item.isCanComment},
|
#{item.mnemonicCode},
|
#{item.status},
|
#{item.dsVolume},
|
#{item.rsVolume},
|
#{item.delFlag},
|
#{item.attrValues},
|
#{item.isSpecialPrice},
|
#{item.markedPrice},
|
#{item.couponId},
|
#{item.isService},
|
#{item.serviceTime},
|
#{item.shopIds},
|
#{item.companyId}
|
</sql>
|
<!-- where sql -->
|
<sql id="where_sql">
|
|
<if test="record!=null">
|
<if test="(record.id!=null and record.id!='') or (record.id!='' and record.id==0) ">
|
and id = #{record.id}
|
</if>
|
<if test="(record.categoryId!=null and record.categoryId!='') or (record.categoryId!='' and record.categoryId==0) ">
|
and category_id = #{record.categoryId}
|
</if>
|
<if test='record.title!=null and record.title!="" and record.title != ","'>
|
and (a.title like concat('%',#{record.title},'%') or a.mnemonic_code like
|
concat('%',#{record.title},'%'))
|
</if>
|
<if test='record.title == ","'>
|
and a.title = #{record.title}
|
</if>
|
<if test="(record.briefIntroduction!=null and record.briefIntroduction!='') or (record.briefIntroduction!='' and record.briefIntroduction==0) ">
|
and brief_introduction = #{record.briefIntroduction}
|
</if>
|
<if test="(record.carriage!=null and record.carriage!='') or (record.carriage!='' and record.carriage==0) ">
|
and carriage = #{record.carriage}
|
</if>
|
<if test="(record.imgPc!=null and record.imgPc!='') or (record.imgPc!='' and record.imgPc==0) ">
|
and img_pc = #{record.imgPc}
|
</if>
|
<if test="(record.imgMobile!=null and record.imgMobile!='') or (record.imgMobile!='' and record.imgMobile==0) ">
|
and img_mobile = #{record.imgMobile}
|
</if>
|
<if test="(record.brand!=null and record.brand!='') or (record.brand!='' and record.brand==0) ">
|
and brand like concat('%',#{record.brand},'%')
|
</if>
|
<if test="(record.price!=null and record.price!='') or (record.price!='' and record.price==0) ">
|
and price = #{record.price}
|
</if>
|
<if test="(record.pcDetails!=null and record.pcDetails!='') or (record.pcDetails!='' and record.pcDetails==0) ">
|
and pc_details = #{record.pcDetails}
|
</if>
|
<if test="(record.mobileDetails!=null and record.mobileDetails!='') or (record.mobileDetails!='' and record.mobileDetails==0) ">
|
and mobile_details = #{record.mobileDetails}
|
</if>
|
<if test="(record.buyLimit!=null and record.buyLimit!='') or (record.buyLimit!='' and record.buyLimit==0) ">
|
and buy_limit = #{record.buyLimit}
|
</if>
|
<if test="(record.limitCycle!=null and record.limitCycle!='') or (record.limitCycle!='' and record.limitCycle==0) ">
|
and limit_cycle = #{record.limitCycle}
|
</if>
|
<if test="(record.isCanComment!=null and record.isCanComment!='') or (record.isCanComment!='' and record.isCanComment==0) ">
|
and is_can_comment = #{record.isCanComment}
|
</if>
|
<if test="(record.mnemonicCode!=null and record.mnemonicCode!='') or (record.mnemonicCode!='' and record.mnemonicCode==0) ">
|
and mnemonic_code = #{record.mnemonicCode}
|
</if>
|
<if test="(record.status!=null and record.status!='') or (record.status!='' and record.status==0) ">
|
and status = #{record.status}
|
</if>
|
<if test="(record.dsVolume!=null and record.dsVolume!='') or (record.dsVolume!='' and record.dsVolume==0) ">
|
and ds_volume = #{record.dsVolume}
|
</if>
|
<if test="(record.rsVolume!=null and record.rsVolume!='') or (record.rsVolume!='' and record.rsVolume==0) ">
|
and rs_volume = #{record.rsVolume}
|
</if>
|
<if test="(record.delFlag!=null and record.delFlag!='') or (record.delFlag!='' and record.delFlag==0) ">
|
and del_flag = #{record.delFlag}
|
</if>
|
<if test="(record.attrs!=null and record.attrs!='') or (record.attrs!='' and record.attrs==0) ">
|
and b.attr_full_path like concat('%/',#{record.attrs},'/%')
|
</if>
|
<if test="(record.markedPrice!=null and record.markedPrice!='') or (record.markedPrice!='' and record.markedPrice==0) ">
|
and marked_price = #{record.markedPrice}
|
</if>
|
<if test="(record.isService!=null and record.isService!='') or (record.isService!='' and record.isService==0) ">
|
and is_service = #{record.isService}
|
</if>
|
<if test="(record.isSpecialPrice!=null and record.isSpecialPrice!='') or (record.isSpecialPrice!='' and record.isSpecialPrice==0) ">
|
and is_special_price = #{record.isSpecialPrice}
|
</if>
|
<if test="(record.serviceTime!=null and record.serviceTime!='') or (record.serviceTime!='' and record.serviceTime==0) ">
|
and service_time = #{record.serviceTime}
|
</if>
|
<if test="(record.shopIds!=null and record.shopIds!='') or (record.shopIds!='' and record.shopIds==0) ">
|
and shop_ids = #{record.shopIds}
|
</if>
|
<if test="record.companyId != null and record.companyId !='' ">
|
and a.company_id = #{record.companyId}
|
</if>
|
|
|
</if>
|
|
</sql>
|
|
|
<sql id="where_model_sql">
|
|
<if test="record!=null">
|
<if test="(record.categoryId!=null and record.categoryId!='') or (record.categoryId!='' and record.categoryId==0) ">
|
and a.category_id = #{record.categoryId}
|
</if>
|
<if test="(record.briefIntroduction!=null and record.briefIntroduction!='') or (record.briefIntroduction!='' and record.briefIntroduction==0) ">
|
and a.brief_introduction = #{record.briefIntroduction}
|
</if>
|
<if test="(record.carriage!=null and record.carriage!='') or (record.carriage!='' and record.carriage==0) ">
|
and a.carriage = #{record.carriage}
|
</if>
|
<if test="(record.brand!=null and record.brand!='') or (record.brand!='' and record.brand==0) ">
|
and a.brand = #{record.brand}
|
</if>
|
<if test="record.companyId != null and record.companyId !='' ">
|
and a.company_id = #{record.companyId}
|
</if>
|
|
|
<if test="(record.buyLimit!=null and record.buyLimit!='') or (record.buyLimit!='' and record.buyLimit==0) ">
|
and a.buy_limit = #{record.buyLimit}
|
</if>
|
<if test="(record.limitCycle!=null and record.limitCycle!='') or (record.limitCycle!='' and record.limitCycle==0) ">
|
and a.limit_cycle = #{record.limitCycle}
|
</if>
|
<if test="(record.isCanComment!=null and record.isCanComment!='') or (record.isCanComment!='' and record.isCanComment==0) ">
|
and a.is_can_comment = #{record.isCanComment}
|
</if>
|
<if test="(record.status!=null and record.status!='') or (record.status!='' and record.status==0) ">
|
and a.status = #{record.status}
|
</if>
|
<if test="(record.dsVolume!=null and record.dsVolume!='') or (record.dsVolume!='' and record.dsVolume==0) ">
|
and a.ds_volume = #{record.dsVolume}
|
</if>
|
<if test="(record.rsVolume!=null and record.rsVolume!='') or (record.rsVolume!='' and record.rsVolume==0) ">
|
and a.rs_volume = #{record.rsVolume}
|
</if>
|
|
<if test="(record.startPrice!=null and record.startPrice!='') or (record.startPrice!='' and record.startPrice==0) ">
|
and a.price >= #{record.startPrice}
|
</if>
|
<if test="(record.endPrice!=null and record.endPrice!='') or (record.endPrice!='' and record.endPrice==0) ">
|
and a.price <= #{record.endPrice}
|
</if>
|
<if test="(record.delFlag!=null and record.delFlag!='') or (record.delFlag!='' and record.delFlag==0) ">
|
and a.del_flag = #{record.delFlag}
|
</if>
|
<if test="record.title!=null and record.title!=''">
|
and (a.title like concat('%',#{record.title},'%') or a.mnemonic_code like
|
concat('%',#{record.title},'%'))
|
</if>
|
<if test="(record.isService!=null and record.isService!='') or (record.isService!='' and record.isService==0) ">
|
and a.is_service = #{record.isService}
|
</if>
|
<if test='record.title == ","'>
|
and a.title = #{record.title}
|
</if>
|
<if test="(record.isSpecialPrice!=null and record.isSpecialPrice!='') or (record.isSpecialPrice!='' and record.isSpecialPrice==0) ">
|
and a.is_special_price = #{record.isSpecialPrice}
|
</if>
|
<if test="(record.serviceTime!=null and record.serviceTime!='') or (record.serviceTime!='' and record.serviceTime==0) ">
|
and a.service_time = #{record.serviceTime}
|
</if>
|
<if test="(record.attrs!=null and record.attrs!='') or (record.attrs!='' and record.attrs==0) ">
|
|
and b.attr_full_path like concat('%/',#{record.attrs},'/%')
|
</if>
|
|
</if>
|
|
</sql>
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopProduct"
|
useGeneratedKeys="true" keyProperty="item.id">
|
INSERT INTO shop_product (
|
<include refid="columns"></include>
|
)
|
VALUES (
|
<include refid="propertys"></include>
|
)
|
</insert>
|
|
|
<!-- 批量插入 -->
|
<insert id="batchInsert" parameterType="java.util.List">
|
INSERT INTO shop_product (
|
<include refid="columns"></include>
|
)
|
VALUES
|
<foreach collection="list" item="item" index="index" separator=",">(
|
<include refid="propertys"></include>
|
)
|
</foreach>
|
</insert>
|
|
|
<!-- 根据Map更新 部分更新 -->
|
<update id="updateByMap" parameterType="java.util.HashMap">
|
UPDATE shop_product
|
<set>
|
<if test="_parameter.containsKey('categoryId')">
|
category_id = #{categoryId},
|
</if>
|
<if test="_parameter.containsKey('title')">
|
title = #{title},
|
</if>
|
<if test="_parameter.containsKey('briefIntroduction')">
|
brief_introduction = #{briefIntroduction},
|
</if>
|
<if test="_parameter.containsKey('carriage')">
|
carriage = #{carriage},
|
</if>
|
<if test="_parameter.containsKey('imgPc')">
|
img_pc = #{imgPc},
|
</if>
|
<if test="_parameter.containsKey('imgMobile')">
|
img_mobile = #{imgMobile},
|
</if>
|
<if test="_parameter.containsKey('brand')">
|
brand = #{brand},
|
</if>
|
<if test="_parameter.containsKey('price')">
|
price = #{price},
|
</if>
|
<if test="_parameter.containsKey('pcDetails')">
|
pc_details = #{pcDetails},
|
</if>
|
<if test="_parameter.containsKey('mobileDetails')">
|
mobile_details = #{mobileDetails},
|
</if>
|
<if test="_parameter.containsKey('buyLimit')">
|
buy_limit = #{buyLimit},
|
</if>
|
<if test="_parameter.containsKey('limitCycle')">
|
limit_cycle = #{limitCycle},
|
</if>
|
<if test="_parameter.containsKey('isCanComment')">
|
is_can_comment = #{isCanComment},
|
</if>
|
<if test="_parameter.containsKey('mnemonicCode')">
|
mnemonic_code = #{mnemonicCode},
|
</if>
|
<if test="_parameter.containsKey('status')">
|
status = #{status},
|
</if>
|
<if test="_parameter.containsKey('dsVolume')">
|
ds_volume = #{dsVolume},
|
</if>
|
<if test="_parameter.containsKey('rsVolume')">
|
rs_volume = #{rsVolume},
|
</if>
|
<if test="_parameter.containsKey('delFlag')">
|
del_flag = #{delFlag},
|
</if>
|
<if test="_parameter.containsKey('isService')">
|
is_service = #{isService},
|
</if>
|
<if test="_parameter.containsKey('isSpecialPrice')">
|
is_special_price = #{isSpecialPrice},
|
</if>
|
<if test="_parameter.containsKey('markedPrice')">
|
marked_price = #{markedPrice},
|
</if>
|
<if test="_parameter.containsKey('couponId')">
|
couponId = #{couponId},
|
</if>
|
<if test="_parameter.containsKey('serviceTime')">
|
service_time = #{serviceTime},
|
</if>
|
|
<if test="_parameter.containsKey('companyId')">
|
company_id = #{companyId},
|
</if>
|
|
</set>
|
WHERE id=#{id}
|
</update>
|
|
|
<!-- 根据对象更新 部分更新 -->
|
<update id="updateByModel" parameterType="Integer">
|
UPDATE shop_product
|
<set>
|
<if test="(record.categoryId!=null and record.categoryId!='') or (record.categoryId!='' and record.categoryId==0) ">
|
category_id = #{record.categoryId},
|
</if>
|
<if test="(record.title!=null and record.title!='') or (record.title!='' and record.title==0) ">
|
title = #{record.title},
|
</if>
|
<if test="(record.briefIntroduction!=null and record.briefIntroduction!='') or (record.briefIntroduction!='' and record.briefIntroduction==0) ">
|
brief_introduction = #{record.briefIntroduction},
|
</if>
|
<if test="(record.carriage!=null and record.carriage!='') or (record.carriage!='' and record.carriage==0) ">
|
carriage = #{record.carriage},
|
</if>
|
<if test="(record.serviceTime!=null and record.serviceTime!='') or (record.serviceTime!='' and record.serviceTime==0) ">
|
service_time = #{record.serviceTime},
|
</if>
|
<if test="(record.imgPc!=null and record.imgPc!='') or (record.imgPc!='' and record.imgPc==0) ">
|
img_pc = #{record.imgPc},
|
</if>
|
<if test="(record.imgMobile!=null and record.imgMobile!='') or (record.imgMobile!='' and record.imgMobile==0) ">
|
img_mobile = #{record.imgMobile},
|
</if>
|
<if test="(record.brand!=null and record.brand!='') or (record.brand!='' and record.brand==0) ">
|
brand = #{record.brand},
|
</if>
|
<if test="(record.price!=null and record.price!='') or (record.price!='' and record.price==0) ">
|
price = #{record.price},
|
</if>
|
<if test="(record.pcDetails!=null and record.pcDetails!='') or (record.pcDetails!='' and record.pcDetails==0) ">
|
pc_details = #{record.pcDetails},
|
</if>
|
<if test="(record.mobileDetails!=null and record.mobileDetails!='') or (record.mobileDetails!='' and record.mobileDetails==0) ">
|
mobile_details = #{record.mobileDetails},
|
</if>
|
|
buy_limit = #{record.buyLimit},
|
|
|
limit_cycle = #{record.limitCycle},
|
|
<if test="(record.isCanComment!=null and record.isCanComment!='') or (record.isCanComment!='' and record.isCanComment==0) ">
|
is_can_comment = #{record.isCanComment},
|
</if>
|
mnemonic_code = #{record.mnemonicCode},
|
<if test="(record.status!=null and record.status!='') or (record.status!='' and record.status==0) ">
|
status = #{record.status},
|
</if>
|
<if test="(record.dsVolume!=null and record.dsVolume!='') or (record.dsVolume!='' and record.dsVolume==0) ">
|
ds_volume = #{record.dsVolume},
|
</if>
|
<if test="(record.rsVolume!=null and record.rsVolume!='') or (record.rsVolume!='' and record.rsVolume==0) ">
|
rs_volume = #{record.rsVolume},
|
</if>
|
<if test="(record.delFlag!=null and record.delFlag!='') or (record.delFlag!='' and record.delFlag==0) ">
|
del_flag = #{record.delFlag},
|
</if>
|
<if test="(record.attrValues!=null and record.attrValues!='') or (record.attrValues!='' and record.attrValues==0) ">
|
attrs_values = #{record.attrValues},
|
</if>
|
marked_price = #{record.markedPrice},
|
<if test="(record.isService!=null and record.isService!='') or (record.isService!='' and record.isService==0) ">
|
is_service = #{record.isService},
|
</if>
|
<if test="(record.isSpecialPrice!=null and record.isSpecialPrice!='') or (record.isSpecialPrice!='' and record.isSpecialPrice==0) ">
|
is_special_price = #{record.isSpecialPrice},
|
</if>
|
<if test="(record.couponId!=null and record.couponId!='') or (record.couponId!='' and record.couponId==0) ">
|
couponId = #{record.couponId},
|
</if>
|
<if test="(record.shopIds!=null and record.shopIds!='') or (record.shopIds!='' and record.shopIds==0) ">
|
shop_ids = #{record.shopIds},
|
</if>
|
|
|
</set>
|
WHERE id=#{record.id}
|
</update>
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from shop_product where id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!--根据id批量修改-->
|
<update id="updateByIds" parameterType="java.util.List">
|
|
update shop_product
|
<set>
|
<if test="record.delFlag != null ">
|
del_flag= #{record.delFlag},
|
</if>
|
<if test="record.status != null ">
|
status = #{record.status},
|
</if>
|
</set>
|
where id in
|
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
</update>
|
|
<!-- 根据id删除-->
|
<update id="deleteById" parameterType="Integer">
|
update shop_product
|
<set>
|
del_flag=1
|
</set>
|
where id = #{id}
|
</update>
|
|
<!-- 删除产品中的优惠券标签 -->
|
<update id="removeProductCouponLable">
|
update shop_product set couponId =NULL where couponId=#{couponId};
|
</update>
|
|
<!-- 根据对象删除-->
|
<delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopProduct">
|
DELETE FROM shop_product
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</delete>
|
|
|
<!-- 分页查询 -->
|
<select id="selectProductByAttrid" resultMap="ShopProductMap">
|
select a.create_by,
|
a.create_time,
|
a.update_by,
|
a.update_time,
|
a.id,
|
a.company_id,
|
a.category_id,
|
a.title,
|
a.brief_introduction,
|
a.carriage,
|
a.img_pc,
|
a.img_mobile,
|
a.brand,
|
a.price,
|
a.pc_details,
|
a.mobile_details,
|
a.buy_limit,
|
a.limit_cycle,
|
a.is_can_comment,
|
a.service_time,
|
a.mnemonic_code,
|
a.status,
|
a.ds_volume,
|
a.rs_volume,
|
a.del_flag,
|
a.attrs_values,
|
a.is_service,
|
a.is_special_price,
|
a.marked_price,
|
b.attr_full_path,
|
a.couponId,
|
(SELECT ROUND(SUM(ss.stock),2) from shop_sku ss where ss.p_id = a.id) as stockNum,
|
GROUP_CONCAT(DISTINCT(s.atrid) order by a.id SEPARATOR ',') atrid
|
from shop_product a left join shop_product_attr_ref b on a.id = b.p_id
|
left join shop_sku s on a.id = s.p_id
|
where b.attr_full_path like concat('%/',#{attrId},'/%') and a.shop_ids=#{shopId}
|
GROUP BY a.id
|
|
</select>
|
|
<select id="selectProductByIds" resultMap="ShopProductMap" parameterType="java.lang.String">
|
select a.create_by,
|
a.create_time,
|
a.update_by,
|
a.update_time,
|
a.id,
|
a.category_id,
|
a.title,
|
a.brief_introduction,
|
a.carriage,
|
a.img_pc,
|
a.company_id,
|
a.img_mobile,
|
a.brand,
|
a.price,
|
a.pc_details,
|
a.mobile_details,
|
a.buy_limit,
|
a.limit_cycle,
|
a.is_can_comment,
|
a.mnemonic_code,
|
a.status,
|
a.ds_volume,
|
a.rs_volume,
|
a.del_flag,
|
a.attrs_values,
|
a.is_service,
|
a.is_special_price,
|
a.marked_price,
|
a.service_time,
|
a.couponId,
|
(SELECT ROUND(SUM(ss.stock),2) from shop_sku ss where ss.p_id = a.id) as stockNum
|
from shop_product a
|
where a.id in (${productIds}) and shop_ids=#{shopId}
|
</select>
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="ShopProductMap">
|
select a.create_by,
|
a.create_time,
|
a.update_by,
|
a.update_time,
|
a.id,
|
a.category_id,
|
a.title,
|
a.brief_introduction,
|
a.carriage,
|
a.img_pc,
|
a.img_mobile,
|
a.brand,
|
a.price,
|
a.pc_details,
|
a.company_id,
|
a.mobile_details,
|
a.buy_limit,
|
a.limit_cycle,
|
a.is_can_comment,
|
a.mnemonic_code,
|
a.status,
|
a.ds_volume,
|
a.rs_volume,
|
a.del_flag,
|
a.attrs_values,
|
a.is_service,
|
a.is_special_price,
|
a.marked_price,
|
b.attr_full_path,
|
a.couponId,
|
a.service_time,
|
(SELECT ROUND(SUM(ss.stock),2) from shop_sku ss where ss.p_id = a.id) as stockNum,
|
GROUP_CONCAT(DISTINCT(s.atrid) order by a.id SEPARATOR ',') atrid
|
from shop_product a left join shop_product_attr_ref b on a.id = b.p_id
|
left join shop_sku s on a.id = s.p_id
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
GROUP BY a.id
|
<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="selectByModel" resultMap="ShopProductMap">
|
select
|
<include refid="columns"></include>
|
from shop_product a
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</select>
|
|
<!--根据对象查询-->
|
<select id="selectByModelWx" resultMap="ShopProductMap">
|
select a.create_by,
|
a.create_time,
|
a.update_by,
|
a.update_time,
|
a.id,
|
a.company_id,
|
a.category_id,
|
a.title,
|
a.brief_introduction,
|
a.carriage,
|
a.img_pc,
|
a.img_mobile,
|
a.brand,
|
a.price,
|
a.pc_details,
|
a.mobile_details,
|
a.buy_limit,
|
a.limit_cycle,
|
a.is_can_comment,
|
a.mnemonic_code,
|
a.status,
|
a.ds_volume,
|
a.rs_volume,
|
a.del_flag,
|
a.attrs_values,
|
a.is_service,
|
a.is_special_price,
|
a.marked_price,
|
b.attr_full_path,
|
a.service_time,
|
a.couponId,
|
(SELECT ROUND(SUM(s.stock),2) from shop_sku s where s.p_id = a.id) as stockNum,
|
(SELECT COUNT(p.com_id) from shop_product_comment p where p.product_id=a.id and p.del_flag=2 and p.com_audit_status=1 and p.com_score=5) as comment
|
from shop_product a
|
left join shop_product_attr_ref b on a.id = b.p_id
|
left join shop_product_attribute c on a.category_id = c.attr_id
|
|
<where>
|
<if test="record.companyId != null and record.companyId !='' ">
|
and a.company_id = #{record.companyId}
|
</if>
|
<if test="(record.categoryId!=null and record.categoryId!='') or (record.categoryId!='' and record.categoryId==0) ">
|
and (a.category_id = #{record.categoryId} or c.parent_id= #{record.categoryId})
|
</if>
|
<if test="(record.brand!=null and record.brand!='') or (record.brand!='' and record.brand==0) ">
|
and a.brand = #{record.brand}
|
</if>
|
<if test="(record.isService!=null and record.isService!='') or (record.isService!='' and record.isService==0) ">
|
and a.is_service = #{record.isService}
|
</if>
|
<if test="(record.status!=null and record.status!='') or (record.status!='' and record.status==0) ">
|
and a.status = #{record.status}
|
</if>
|
<if test="(record.startPrice!=null and record.startPrice!='') or (record.startPrice!='' and record.startPrice==0) ">
|
and a.price >= #{record.startPrice}
|
</if>
|
<if test="(record.endPrice!=null and record.endPrice!='') or (record.endPrice!='' and record.endPrice==0) ">
|
and a.price <= #{record.endPrice}
|
</if>
|
<if test="(record.delFlag!=null and record.delFlag!='') or (record.delFlag!='' and record.delFlag==0) ">
|
and a.del_flag = #{record.delFlag}
|
</if>
|
<if test="record.title!=null and record.title!=''">
|
and (a.title like concat('%',#{record.title},'%') or a.mnemonic_code like
|
concat('%',#{record.title},'%'))
|
</if>
|
<if test="(record.attrs!=null and record.attrs!='') or (record.attrs!='' and record.attrs==0) ">
|
and b.attr_full_path like concat('%/',#{record.attrs},'/%')
|
</if>
|
<if test="(record.shopIds!=null and record.shopIds!='') or (record.shopIds!='' and record.shopIds==0) ">
|
and find_in_set(#{record.shopIds}, a.shop_ids)
|
</if>
|
</where>
|
GROUP BY a.id
|
<if test="record.queryType != null and record.queryType == 1">
|
order by comment desc, a.ds_volume desc
|
</if>
|
<if test="record.queryType != null and record.queryType == 2">
|
order by a.ds_volume desc
|
</if>
|
<if test="record.queryType != null and record.queryType == 3">
|
order by a.price ${record.sortType}
|
</if>
|
<if test="record.offset >=0 and record.limit >0">
|
limit
|
#{record.offset},#{record.limit}
|
</if>
|
</select>
|
|
<!-- 查询总条数 -->
|
<select id="selectTotalRecord" parameterType="long" resultType="java.lang.Integer">
|
select count(DISTINCT a.id)
|
from shop_product a LEFT JOIN shop_product_attr_ref b
|
ON a.id = b.p_id
|
left join shop_sku s on a.id = s.p_id
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</select>
|
|
<!-- 根据id查询-->
|
<select id="selectById" resultMap="ShopProductMap">
|
select
|
id,
|
category_id,
|
title,
|
brief_introduction,
|
carriage,
|
img_pc,
|
img_mobile,
|
brand,
|
price,
|
pc_details,
|
mobile_details,
|
buy_limit,
|
limit_cycle,
|
is_can_comment,
|
mnemonic_code,
|
status,
|
ds_volume,
|
rs_volume,
|
company_id,
|
del_flag,
|
a.service_time,
|
attrs_values,
|
is_service,
|
is_special_price,
|
marked_price,
|
couponId,
|
(SELECT SUM(s.stock) from shop_sku s where s.p_id = a.id) as stockNum,
|
(SELECT ROUND(SUM(s.stock),2) from shop_sku s where s.p_id = a.id) as stockNum,
|
shop_ids
|
from shop_product a
|
where id=#{id}
|
</select>
|
|
<!-- 根据id查询-->
|
<select id="selectByIds" resultMap="ShopProductMap">
|
select
|
<include refid="columns"></include>
|
from shop_product
|
where id in
|
<foreach collection="ids" item="item" separator="," open="(" close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="selectProductNameByIds" resultType="java.lang.String">
|
select
|
title
|
from shop_product
|
where id in
|
<foreach collection="ids" item="item" separator="," open="(" close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
|
<!-- 根据id 锁表查询-->
|
<select id="selectForUpdate" resultMap="ShopProductMap">
|
select
|
<include refid="columns"></include>
|
from shop_product
|
where id=#{id}
|
for update
|
</select>
|
|
<select id="selectBrands" resultType="java.lang.String">
|
select distinct brand from shop_product
|
<where>
|
<if test="record!=null">
|
<if test="(record.categoryId!=null and record.categoryId!='') or (record.categoryId!='' and record.categoryId==0) ">
|
and category_id = #{record.categoryId}
|
</if>
|
<if test="(record.title!=null and record.title!='') or (record.title!='' and record.title==0) ">
|
and title like concat('%',#{record.title},'%')
|
</if>
|
<if test="(record.delFlag!=null and record.delFlag!='') or (record.delFlag!='' and record.delFlag==0) ">
|
and del_flag = #{record.delFlag}
|
</if>
|
<if test="(record.status!=null and record.status!='') or (record.status!='' and record.status==0) ">
|
and status = #{record.status}
|
</if>
|
</if>
|
</where>
|
</select>
|
</mapper>
|