123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- <?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.ym.mec.biz.dal.dao.GoodsDao">
- <resultMap type="com.ym.mec.biz.dal.entity.Goods" id="Goods">
- <result column="id_" property="id"/>
- <result column="goods_category_id_" property="goodsCategoryId"/>
- <result column="goods_category_name_" property="goodsCategoryName"/>
- <result column="sn_" property="sn"/>
- <result column="name_" property="name"/>
- <result column="brand_" property="brand"/>
- <result column="specification_" property="specification"/>
- <result column="image_" property="image"/>
- <result column="stock_count_" property="stockCount"/>
- <result column="tax_stock_count_" property="taxStockCount"/>
- <result column="sell_count_" property="sellCount"/>
- <result column="market_price_" property="marketPrice"/>
- <result column="discount_price_" property="discountPrice"/>
- <result column="group_purchase_price_" property="groupPurchasePrice"/>
- <result column="agree_cost_price_" property="agreeCostPrice"/>
- <result column="brief_" property="brief"/>
- <result column="desc_" property="desc"/>
- <result column="is_new_" property="isNew" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="is_top_" property="isTop" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="memo_" property="memo"/>
- <result column="publish_time_" property="publishTime"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
- <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="supply_channel_" property="supplyChannel" />
- <result column="stock_type_" property="stockType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="stock_warning_" property="stockWarning" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="student_show_organ_id_" property="studentShowOrganId"/>
- <result column="student_show_organ_name_" property="studentShowOrganName"/>
- <result column="education_show_organ_id_" property="educationShowOrganId"/>
- <result column="education_show_organ_name_" property="educationShowOrganName"/>
- <result column="replacement_show_organ_id_" property="replacementShowOrganId"/>
- <result column="replacement_show_organ_name_" property="replacementShowOrganName"/>
- <result column="course_fee_show_organ_id_" property="courseFeeShowOrganId"/>
- <result column="course_fee_show_organ_name_" property="courseFeeShowOrganName"/>
- <result column="member_fee_show_organ_id_" property="memberFeeShowOrganId"/>
- <result column="member_fee_show_organ_name_" property="memberFeeShowOrganName"/>
- </resultMap>
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="Goods" useCache="false" flushCache="true">
- SELECT * FROM goods g
- WHERE g.id_ = #{id}
- </select>
- <select id="lock" resultMap="Goods" useCache="false" flushCache="true">
- SELECT * FROM goods WHERE id_ = #{goodsId} LOCK IN SHARE MODE
- </select>
- <!-- 全查询 -->
- <select id="findAll" resultMap="Goods">
- SELECT * FROM goods ORDER BY id_
- </select>
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Goods" useGeneratedKeys="true" keyColumn="id"
- keyProperty="id">
- INSERT INTO goods
- (goods_category_id_,sn_,name_,brand_,specification_,image_,stock_count_,tax_stock_count_,sell_count_,market_price_,
- discount_price_,group_purchase_price_,brief_,desc_,is_new_,is_top_,status_,memo_,publish_time_,
- complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_,stock_warning_,stock_type_
- ,student_show_organ_id_,education_show_organ_id_,replacement_show_organ_id_,course_fee_show_organ_id_,member_fee_show_organ_id_)
- VALUES(#{goodsCategoryId},#{sn},#{name},#{brand},#{specification},#{image},#{stockCount},#{taxStockCount},#{sellCount},#{marketPrice},
- #{discountPrice},#{groupPurchasePrice},#{brief},#{desc},
- #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{memo},#{publishTime},#{complementGoodsIdList},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{agreeCostPrice},
- #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{studentShowOrganId},#{educationShowOrganId},#{replacementShowOrganId},#{courseFeeShowOrganId},#{memberFeeShowOrganId})
- </insert>
- <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO goods
- (goods_category_id_,name_,brand_,specification_,image_,market_price_,
- discount_price_,group_purchase_price_,brief_,desc_,update_time_,create_time_,type_,agree_cost_price_,sn_,
- stock_count_,tax_stock_count_,stock_warning_,stock_type_
- ,student_show_organ_id_,education_show_organ_id_,replacement_show_organ_id_,course_fee_show_organ_id_,member_fee_show_organ_id_)
- VALUES
- <foreach collection="list" separator="," item="goods">
- (#{goods.goodsCategoryId},#{goods.name},#{goods.brand},#{goods.specification},#{goods.image},#{goods.marketPrice},
- #{goods.discountPrice},#{goods.groupPurchasePrice},#{goods.brief},#{goods.desc},now(),now(),
- #{goods.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.agreeCostPrice},#{goods.sn},
- #{goods.stockCount},#{goods.taxStockCount},
- #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{goods.studentShowOrganId},#{goods.educationShowOrganId},#{goods.replacementShowOrganId},#{goods.courseFeeShowOrganId},#{goods.memberFeeShowOrganId}
- )
- </foreach>
- </insert>
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.Goods">
- UPDATE goods
- <set>
- <if test="studentShowOrganId != null">
- student_show_organ_id_ = #{studentShowOrganId},
- </if>
- <if test="educationShowOrganId != null">
- education_show_organ_id_ = #{educationShowOrganId},
- </if>
- <if test="replacementShowOrganId != null">
- replacement_show_organ_id_ = #{replacementShowOrganId},
- </if>
- <if test="courseFeeShowOrganId != null">
- course_fee_show_organ_id_ = #{courseFeeShowOrganId},
- </if>
- <if test="memberFeeShowOrganId != null">
- member_fee_show_organ_id_ = #{memberFeeShowOrganId},
- </if>
- <if test="agreeCostPrice != null">
- agree_cost_price_ = #{agreeCostPrice},
- </if>
- <if test="specification != null">
- specification_ = #{specification},
- </if>
- <if test="status != null">
- status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="isTop != null">
- is_top_ = #{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="type != null">
- type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="sn != null">
- sn_ = #{sn},
- </if>
- <if test="marketPrice != null">
- market_price_ = #{marketPrice},
- </if>
- <if test="memo != null">
- memo_ = #{memo},
- </if>
- <if test="isNew != null">
- is_new_ = #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="groupPurchasePrice != null">
- group_purchase_price_ = #{groupPurchasePrice},
- </if>
- <if test="name != null">
- name_ = #{name},
- </if>
- <if test="stockCount != null">
- stock_count_ = #{stockCount},
- </if>
- <if test="goodsCategoryId != null">
- goods_category_id_ = #{goodsCategoryId},
- </if>
- <if test="brand != null">
- brand_ = #{brand},
- </if>
- <if test="brief != null">
- brief_ = #{brief},
- </if>
- <if test="discountPrice != null">
- discount_price_ = #{discountPrice},
- </if>
- <if test="sellCount != null">
- sell_count_ = #{sellCount},
- </if>
- <if test="image != null">
- image_ = #{image},
- </if>
- <if test="desc != null">
- desc_ = #{desc},
- </if>
- <if test="publishTime != null">
- publish_time_ = #{publishTime},
- </if>
- <if test="complementGoodsIdList != null">
- complement_goods_id_list_ = #{complementGoodsIdList},
- </if>
- <if test="taxStockCount != null">
- tax_stock_count_ = #{taxStockCount},
- </if>
- <if test="stockWarning != null">
- stock_warning_ = #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="stockType != null">
- stock_type_ = #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- update_time_ = NOW()
- </set>
- WHERE id_ = #{id}
- </update>
- <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.Goods">
- <foreach collection="goodsList" item="goods" separator=";">
- UPDATE goods
- <set>
- <if test="goods.studentShowOrganId != null">
- student_show_organ_id_ = #{goods.studentShowOrganId},
- </if>
- <if test="goods.educationShowOrganId != null">
- education_show_organ_id_ = #{goods.educationShowOrganId},
- </if>
- <if test="goods.replacementShowOrganId != null">
- replacement_show_organ_id_ = #{goods.replacementShowOrganId},
- </if>
- <if test="goods.courseFeeShowOrganId != null">
- course_fee_show_organ_id_ = #{goods.courseFeeShowOrganId},
- </if>
- <if test="goods.memberFeeShowOrganId != null">
- member_fee_show_organ_id_ = #{goods.memberFeeShowOrganId},
- </if>
- <if test="goods.agreeCostPrice != null">
- agree_cost_price_ = #{goods.agreeCostPrice},
- </if>
- <if test="goods.specification != null">
- specification_ = #{goods.specification},
- </if>
- <if test="goods.status != null">
- status_ = #{goods.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="goods.isTop != null">
- is_top_ = #{goods.isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="goods.type != null">
- type_ = #{goods.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="goods.sn != null">
- sn_ = #{goods.sn},
- </if>
- <if test="goods.marketPrice != null">
- market_price_ = #{goods.marketPrice},
- </if>
- <if test="goods.memo != null">
- memo_ = #{goods.memo},
- </if>
- <if test="goods.isNew != null">
- is_new_ = #{goods.isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="goods.groupPurchasePrice != null">
- group_purchase_price_ = #{goods.groupPurchasePrice},
- </if>
- <if test="goods.name != null">
- name_ = #{goods.name},
- </if>
- <if test="goods.stockCount != null">
- stock_count_ = #{goods.stockCount},
- </if>
- <if test="goods.goodsCategoryId != null">
- goods_category_id_ = #{goods.goodsCategoryId},
- </if>
- <if test="goods.brand != null">
- brand_ = #{goods.brand},
- </if>
- <if test="goods.brief != null">
- brief_ = #{goods.brief},
- </if>
- <if test="goods.discountPrice != null">
- discount_price_ = #{goods.discountPrice},
- </if>
- <if test="goods.sellCount != null">
- sell_count_ = #{goods.sellCount},
- </if>
- <if test="goods.image != null">
- image_ = #{goods.image},
- </if>
- <if test="goods.desc != null">
- desc_ = #{goods.desc},
- </if>
- <if test="goods.publishTime != null">
- publish_time_ = #{goods.publishTime},
- </if>
- <if test="goods.complementGoodsIdList != null">
- complement_goods_id_list_ = #{goods.complementGoodsIdList},
- </if>
- <if test="goods.taxStockCount != null">
- tax_stock_count_ = #{goods.taxStockCount},
- </if>
- <if test="goods.stockWarning != null">
- stock_warning_ = #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="goods.stockType != null">
- stock_type_ = #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- update_time_ = NOW()
- </set>
- WHERE id_ = #{goods.id}
- </foreach>
- </update>
- <!-- 根据主键删除一条记录 -->
- <delete id="delete">
- DELETE FROM goods WHERE id_ = #{id}
- </delete>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="Goods" parameterType="map">
- SELECT g.*,gc.name_ goods_category_name_ FROM goods g
- LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_
- <include refid="queryGoodsPageSql"/>
- GROUP BY g.id_
- ORDER BY g.id_ DESC
- <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM goods g
- <include refid="queryGoodsPageSql"/>
- </select>
- <sql id="queryGoodsPageSql">
- <where>
- <if test="goodsCategoryId != null">
- AND g.goods_category_id_ = #{goodsCategoryId}
- </if>
- <if test="type != null">
- AND g.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="isNew != null">
- AND g.is_new_ = #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="isTop != null">
- AND g.is_top_ = #{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="status != null">
- AND g.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="groupGoods!=null and groupGoods==0">
- AND g.complement_goods_id_list_ IS NULL
- </if>
- <if test="groupGoods!=null and groupGoods==1">
- AND g.complement_goods_id_list_ IS NOT NULL
- </if>
- <if test="studentShowOrganId != null and studentShowOrganId!=''">
- AND INTE_ARRAY(#{studentShowOrganId},g.student_show_organ_id_)
- </if>
- <if test="educationShowOrganId != null and educationShowOrganId!=''">
- AND INTE_ARRAY(#{educationShowOrganId},g.education_show_organ_id_)
- </if>
- <if test="courseFeeShowOrganId != null and courseFeeShowOrganId!=''">
- AND INTE_ARRAY(#{courseFeeShowOrganId},g.course_fee_show_organ_id_)
- </if>
- <if test="memberFeeShowOrganId!=null and memberFeeShowOrganId!=''">
- AND INTE_ARRAY(#{memberFeeShowOrganId},g.member_fee_show_organ_id_)
- </if>
- <if test="replacementShowOrganId!=null and replacementShowOrganId!=''">
- AND INTE_ARRAY(#{replacementShowOrganId},g.replacement_show_organ_id_)
- </if>
- <if test="noOrganSearch == null">
- <if test="organId != null and organId != ''">
- AND INTE_ARRAY (#{organId},CONCAT_WS(",",replacement_show_organ_id_,member_fee_show_organ_id_,
- course_fee_show_organ_id_,education_show_organ_id_,student_show_organ_id_))
- </if>
- </if>
- <if test="search!=null and search!=''">
- AND (g.sn_=#{search} OR g.id_=#{search} OR g.name_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- </where>
- </sql>
- <select id="findGoodsBySubId" resultMap="Goods">
- SELECT g.* FROM subject_goods_mapper sgm
- LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
- <include refid="queryOrganIdSql"/>
- </select>
- <sql id="queryOrganIdSql">
- <where>
- AND g.status_ != 0
- <if test="goodsQuery.subjectId != null">
- AND sgm.subject_id_ = #{goodsQuery.subjectId}
- </if>
- <if test="goodsQuery.type != null and goodsQuery.type != ''">
- AND g.type_ = #{goodsQuery.type}
- </if>
- <if test="goodsQuery.studentShowOrganId != null">
- AND FIND_IN_SET(#{goodsQuery.studentShowOrganId},g.student_show_organ_id_)
- </if>
- <if test="goodsQuery.educationShowOrganId != null">
- AND FIND_IN_SET(#{goodsQuery.educationShowOrganId},g.education_show_organ_id_)
- </if>
- <if test="goodsQuery.courseFeeShowOrganId != null">
- AND FIND_IN_SET(#{goodsQuery.courseFeeShowOrganId},g.course_fee_show_organ_id_)
- </if>
- <if test="goodsQuery.memberFeeShowOrganId!=null">
- AND FIND_IN_SET(#{goodsQuery.memberFeeShowOrganId},g.member_fee_show_organ_id_)
- </if>
- <if test="goodsQuery.replacementShowOrganId!=null">
- AND FIND_IN_SET(#{goodsQuery.replacementShowOrganId},g.replacement_show_organ_id_)
- </if>
- <if test="goodsQuery.organId != null">
- AND FIND_IN_SET (#{goodsQuery.organId},CONCAT_WS(",",replacement_show_organ_id_,member_fee_show_organ_id_,
- course_fee_show_organ_id_,education_show_organ_id_,student_show_organ_id_))
- </if>
- </where>
- </sql>
- <!-- 根据 -->
- <select id="findGoodsNumByCategoryId" resultType="int">
- SELECT COUNT(*) FROM goods WHERE goods_category_id_ = #{goodsCategoryId}
- </select>
- <select id="findGoodsByIds" resultMap="Goods">
- SELECT * FROM goods WHERE FIND_IN_SET(id_,#{ids})
- </select>
- <select id="findTypeGoods" resultMap="Goods">
- SELECT * FROM goods WHERE type_ = #{type} AND status_ != 0
- </select>
- <select id="getGoodies" resultMap="Goods">
- SELECT * FROM goods WHERE id_ IN
- <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
- #{goodsId}
- </foreach>
- </select>
- <select id="lockGoods" resultMap="Goods" useCache="false" flushCache="true">
- SELECT * FROM goods WHERE id_ IN
- <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
- #{goodsId}
- </foreach>
- FOR UPDATE
- </select>
- <select id="findBySn" resultMap="Goods">
- SELECT * FROM goods WHERE sn_ = #{sn}
- </select>
- <select id="lockBySn" resultMap="Goods">
- SELECT * FROM goods WHERE sn_ = #{sn} FOR UPDATE
- </select>
- <select id="findBySns" resultMap="Goods">
- SELECT * FROM goods WHERE sn_ IN
- <foreach collection="sns" item="sn" separator="," open="(" close=")">
- #{sn}
- </foreach>
- </select>
- <select id="getInnerRepertoryWarnName" resultType="java.lang.String">
- SELECT GROUP_CONCAT( DISTINCT name_) FROM goods WHERE stock_count_ <= #{innerRepertoryWarnNum} AND stock_warning_ = 1 AND complement_goods_id_list_ IS NULL
- </select>
- <select id="getOuterRepertoryWarnName" resultType="java.lang.String">
- SELECT GROUP_CONCAT( DISTINCT name_) FROM goods WHERE tax_stock_count_ <= #{outerRepertoryWarnNum} AND stock_warning_ = 1 AND complement_goods_id_list_ IS NULL
- </select>
- <select id="getWithComplementGoodsAndStatus" resultMap="Goods">
- SELECT * FROM goods WHERE status_ = #{status} AND FIND_IN_SET(#{goodsId}, complement_goods_id_list_)
- </select>
- <resultMap id="GoodsSellDtoMap" type="com.ym.mec.biz.dal.dto.GoodsSellDto">
- <result property="goodsId" column="id_"/>
- <result property="image" column="image_"/>
- <result property="goodsName" column="name_"/>
- <result property="goodsType" column="type_"/>
- <result property="goodsPrice" column="discount_price_"/>
- <result property="totalGoodsPrice" column="discount_price_"/>
- </resultMap>
- <select id="queryGoodsSellDtos" resultMap="GoodsSellDtoMap">
- SELECT id_,image_,name_,type_,discount_price_ FROM goods WHERE FIND_IN_SET(id_,#{goodsId})
- </select>
- <resultMap id="MusicGroupGoods" type="com.ym.mec.biz.dal.dto.MusicGroupGoodsAndDiscountDto" extends="Goods"/>
- <select id="getMusicGroupGoodsAndDiscount" resultMap="MusicGroupGoods">
- SELECT g.* FROM subject_goods_mapper sgm
- LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
- WHERE sgm.subject_id_ = #{subjectId} AND g.status_ != 0
- <if test="organId != null">
- <if test="courseViewType != null">
- <if test="courseViewType == 1">
- AND FIND_IN_SET(#{organId},g.member_fee_show_organ_id_)
- </if>
- <if test="courseViewType == 0">
- AND FIND_IN_SET(#{organId},g.course_fee_show_organ_id_)
- </if>
- </if>
- </if>
- <if test="type!=null">
- AND g.type_ = #{type}
- </if>
- </select>
- <select id="findByIdAndStatus" resultType="java.lang.Boolean">
- SELECT COUNT(0) FROM goods WHERE status_ = #{status} AND id_ = #{goodsId}
- </select>
- <select id="getGoodsInfo" resultMap="Goods">
- SELECT g.*,gc.name_ goods_category_name_ FROM goods g
- LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
- WHERE g.id_=#{id}
- </select>
- <select id="getGoodiesAndCate" resultMap="Goods">
- SELECT g.*,gc.name_ goods_category_name_ FROM goods g
- LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
- WHERE g.id_ IN
- <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
- #{goodsId}
- </foreach>
- </select>
- <!-- 根据子商品获取所有包含的子商品的父商品(全部状态)-->
- <select id="getGoodsByBaseGoodsId" resultMap="Goods">
- SELECT * FROM goods WHERE FIND_IN_SET(#{goodsId}, complement_goods_id_list_)
- </select>
- <!-- 根据分部获取乐器置换的商品-->
- <select id="getReplacementGoodsPage" resultMap="com.ym.mec.biz.dal.dao.ReplacementInstrumentDao.ReplacementInstrument">
- SELECT g.id_,g.brand_,g.specification_,g.brief_ param_,g.market_price_,g.discount_price_,g.group_purchase_price_ sale_price_,
- (g.discount_price_-g.group_purchase_price_) depreciation_price_
- FROM subject_goods_mapper sgm
- LEFT JOIN goods_category gc ON gc.id_=sgm.goods_category_id_
- LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
- <include refid="replacementQuerySql"/>
- <include refid="global.limit"/>
- </select>
- <select id="getReplacementInstrumentCount" resultType="int">
- SELECT COUNT(*)
- FROM subject_goods_mapper sgm
- LEFT JOIN goods_category gc ON gc.id_=sgm.goods_category_id_
- LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
- <include refid="replacementQuerySql"/>
- <include refid="global.limit"/>
- </select>
- <sql id="replacementQuerySql">
- <where>
- g.status_ != 0
- AND g.type_ = 'INSTRUMENT'
- AND gc.del_flag_ = 0
- <if test="organId != null">
- AND FIND_IN_SET(#{organId},g.replacement_show_organ_id_)
- </if>
- <if test="subjectId != null">
- AND sgm.subject_id_ = #{subjectId}
- </if>
- <if test="brand != null and brand!=''">
- AND g.brand_ = #{brand}
- </if>
- <if test="specification != null and specification!=''">
- AND g.specification_ = #{specification}
- </if>
- </where>
- </sql>
- </mapper>
|