123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?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.caimei.modules.product.dao.CmProductCombinationDao">
- <sql id="cmProductCombinationColumns">
- a.id AS "id",
- a.name AS "name",
- a.addTime AS "addTime",
- a.updateTime AS "updateTime",
- a.delFlag AS "delFlag"
- </sql>
- <sql id="cmProductCombinationJoins">
- </sql>
- <select id="get" resultType="CmProductCombination">
- SELECT
- <include refid="cmProductCombinationColumns"/>
- FROM cm_product_combination a
- <include refid="cmProductCombinationJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="findList" resultType="CmProductCombination">
- SELECT
- <include refid="cmProductCombinationColumns"/>
- FROM cm_product_combination a
- <include refid="cmProductCombinationJoins"/>
- <where>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </if>
- and a.delFlag = 0
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.addTime desc
- </otherwise>
- </choose>
- </select>
- <select id="findCombinationProductList" resultType="com.caimei.modules.product.entity.Product">
- SELECT a.*,s.name as "shopName"
- FROM product a
- left join shop s on a.shopId = s.shopID
- where
- combinationID = #{id}
- and a.productCategory = 1
- group by a.productID
- ORDER BY combinationSort!= 0 desc,combinationSort asc
- </select>
- <select id="findProductCombinationList" resultType="com.caimei.modules.product.entity.CmProductCombination">
- select * From cm_product_combination where delFlag = 0
- </select>
- <select id="findAllList" resultType="CmProductCombination">
- SELECT
- <include refid="cmProductCombinationColumns"/>
- FROM cm_product_combination a
- <include refid="cmProductCombinationJoins"/>
- <where>
- a.delFlag = 0
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.addTime desc
- </otherwise>
- </choose>
- </select>
- <insert id="insert" parameterType="CmProductCombination" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_product_combination(
- name,
- addTime,
- updateTime,
- delFlag
- ) VALUES (
- #{name},
- #{addTime},
- #{updateTime},
- #{delFlag}
- )
- </insert>
- <update id="update">
- UPDATE cm_product_combination SET
- name = #{name},
- addTime = #{addTime},
- updateTime = #{updateTime},
- delFlag = #{delFlag}
- WHERE id = #{id}
- </update>
- <update id="saveSort">
- UPDATE product SET combinationSort = #{sort} WHERE productID = #{id}
- </update>
- <update id="untieProduct">
- UPDATE product SET combinationID = NULL,combinationSort = NULL where combinationID = #{combinationId};
- </update>
- <update id="addProductCombination">
- UPDATE product SET combinationID = #{id},combinationSort = 0 where productID in
- <foreach collection="productIds" item="item" index="index" open="(" separator="," close=")">
- #{item}
- </foreach>
- </update>
- <!--获取商品列表,排除已经绑定组合的商品-->
- <select id="findProductList" resultType="com.caimei.modules.product.entity.Product">
- SELECT a.*,s.name as "shopName"
- FROM product a
- left join cm_organize_product_info copi on copi.productId = a.productID
- left join shop s on a.shopId = s.shopID
- <where>
- copi.validFlag in (2,3,9)
- <if test="productID !=null and productID !=''">
- AND a.productID=#{productID}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE
- <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
- </if>
- and a.combinationID is null
- and a.productCategory = 1
- </where>
- group by a.productID
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.productID desc
- </otherwise>
- </choose>
- </select>
- <update id="untieProductByProductId">
- UPDATE product SET combinationID = NULL,combinationSort = NULL where productID = #{productId};
- </update>
- <delete id="delete">
- DELETE FROM cm_product_combination
- WHERE id = #{id}
- </delete>
- </mapper>
|