|  | @@ -0,0 +1,187 @@
 | 
	
		
			
				|  |  | +<?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.SellOrderDao">
 | 
	
		
			
				|  |  | +    <resultMap id="SellOrder" type="com.ym.mec.biz.dal.entity.SellOrder">
 | 
	
		
			
				|  |  | +        <!--@mbg.generated-->
 | 
	
		
			
				|  |  | +        <!--@Table sell_order-->
 | 
	
		
			
				|  |  | +        <id column="id_" property="id"/>
 | 
	
		
			
				|  |  | +        <result column="organ_id_" property="organId"/>
 | 
	
		
			
				|  |  | +        <result column="school_id_" property="schoolId"/>
 | 
	
		
			
				|  |  | +        <result column="school_name_" property="schoolName"/>
 | 
	
		
			
				|  |  | +        <result column="trans_no_" property="transNo"/>
 | 
	
		
			
				|  |  | +        <result column="order_no_" property="orderNo"/>
 | 
	
		
			
				|  |  | +        <result column="order_id_" property="orderId"/>
 | 
	
		
			
				|  |  | +        <result column="expect_amount_" property="expectAmount"/>
 | 
	
		
			
				|  |  | +        <result column="actual_amount_" property="actualAmount"/>
 | 
	
		
			
				|  |  | +        <result column="balance_amount_" property="balanceAmount"/>
 | 
	
		
			
				|  |  | +        <result column="type_" property="type"/>
 | 
	
		
			
				|  |  | +        <result column="goods_id_" property="goodsId"/>
 | 
	
		
			
				|  |  | +        <result column="goods_name_" property="goodsName"/>
 | 
	
		
			
				|  |  | +        <result column="sell_cost_" property="sellCost"/>
 | 
	
		
			
				|  |  | +        <result column="sell_cost2_" property="sellCost2"/>
 | 
	
		
			
				|  |  | +        <result column="num_" property="num"/>
 | 
	
		
			
				|  |  | +        <result column="user_id_" property="userId"/>
 | 
	
		
			
				|  |  | +        <result column="user_name_" property="userName"/>
 | 
	
		
			
				|  |  | +        <result column="phone_" property="phone"/>
 | 
	
		
			
				|  |  | +        <result column="organ_name_" property="organName"/>
 | 
	
		
			
				|  |  | +        <result column="user_id_" property="userId"/>
 | 
	
		
			
				|  |  | +        <result column="payment_channel_" property="paymentChannel"/>
 | 
	
		
			
				|  |  | +        <result column="mer_no_" property="merNo"/>
 | 
	
		
			
				|  |  | +        <result column="sell_time_" property="sellTime"/>
 | 
	
		
			
				|  |  | +        <result column="create_ime_" property="createIme"/>
 | 
	
		
			
				|  |  | +        <result column="update_time_" property="updateTime"/>
 | 
	
		
			
				|  |  | +    </resultMap>
 | 
	
		
			
				|  |  | +    <sql id="Base_Column_List">
 | 
	
		
			
				|  |  | +        <!--@mbg.generated-->
 | 
	
		
			
				|  |  | +        id_, organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
 | 
	
		
			
				|  |  | +        balance_amount_, sell_cost_, sell_cost2_, type_, goods_id_,goods_name_, num_, user_id_, payment_channel_,
 | 
	
		
			
				|  |  | +        mer_no_, sell_time_, create_ime_, update_time_
 | 
	
		
			
				|  |  | +    </sql>
 | 
	
		
			
				|  |  | +    <select id="get" parameterType="java.lang.Integer" resultMap="SellOrder">
 | 
	
		
			
				|  |  | +        <!--@mbg.generated-->
 | 
	
		
			
				|  |  | +        select
 | 
	
		
			
				|  |  | +        <include refid="Base_Column_List"/>
 | 
	
		
			
				|  |  | +        from sell_order
 | 
	
		
			
				|  |  | +        where id_ = #{id}
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +    <delete id="delete" parameterType="java.lang.Integer">
 | 
	
		
			
				|  |  | +        <!--@mbg.generated-->
 | 
	
		
			
				|  |  | +        delete from sell_order
 | 
	
		
			
				|  |  | +        where id_ = #{id}
 | 
	
		
			
				|  |  | +    </delete>
 | 
	
		
			
				|  |  | +    <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SellOrder"
 | 
	
		
			
				|  |  | +            useGeneratedKeys="true">
 | 
	
		
			
				|  |  | +        <!--@mbg.generated-->
 | 
	
		
			
				|  |  | +        insert into sell_order (organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
 | 
	
		
			
				|  |  | +        balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
 | 
	
		
			
				|  |  | +        mer_no_, sell_time_, create_ime_, update_time_)
 | 
	
		
			
				|  |  | +        values (#{organId}, #{schoolId}, #{transNo}, #{orderNo},#{orderId}, #{expectAmount}, #{actualAmount},
 | 
	
		
			
				|  |  | +        #{balanceAmount}, #{type}, #{goodsId}, #{goodsName}, #{sellCost}, #{sellCost2}, #{num}, #{userId},
 | 
	
		
			
				|  |  | +        #{paymentChannel},
 | 
	
		
			
				|  |  | +        #{merNo}, #{sellTime}, #{createIme}, #{updateTime})
 | 
	
		
			
				|  |  | +    </insert>
 | 
	
		
			
				|  |  | +    <update id="update" parameterType="com.ym.mec.biz.dal.entity.SellOrder">
 | 
	
		
			
				|  |  | +        <!--@mbg.generated-->
 | 
	
		
			
				|  |  | +        update sell_order
 | 
	
		
			
				|  |  | +        <set>
 | 
	
		
			
				|  |  | +            <if test="organId != null">
 | 
	
		
			
				|  |  | +                organ_id_ = #{organId},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="schoolId != null">
 | 
	
		
			
				|  |  | +                school_id_ = #{schoolId},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="transNo != null">
 | 
	
		
			
				|  |  | +                trans_no_ = #{transNo},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="orderId != null">
 | 
	
		
			
				|  |  | +                order_id_ = #{orderId},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="orderNo != null">
 | 
	
		
			
				|  |  | +                order_no_ = #{orderNo},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="expectAmount != null">
 | 
	
		
			
				|  |  | +                expect_amount_ = #{expectAmount},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="actualAmount != null">
 | 
	
		
			
				|  |  | +                actual_amount_ = #{actualAmount},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="balanceAmount != null">
 | 
	
		
			
				|  |  | +                balance_amount_ = #{balanceAmount},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="type != null">
 | 
	
		
			
				|  |  | +                type_ = #{type},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="goodsId != null">
 | 
	
		
			
				|  |  | +                goods_id_ = #{goodsId},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="goodsName != null">
 | 
	
		
			
				|  |  | +                goods_name_ = #{goodsName},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="sellCost != null">
 | 
	
		
			
				|  |  | +                sell_cost_ = #{sellCost},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="sellCost2 != null">
 | 
	
		
			
				|  |  | +                sell_cost2_ = #{sellCost2},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="num != null">
 | 
	
		
			
				|  |  | +                num_ = #{num},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="userId != null">
 | 
	
		
			
				|  |  | +                user_id_ = #{userId},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="paymentChannel != null">
 | 
	
		
			
				|  |  | +                payment_channel_ = #{paymentChannel},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="merNo != null">
 | 
	
		
			
				|  |  | +                mer_no_ = #{merNo},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="sellTime != null">
 | 
	
		
			
				|  |  | +                sell_time_ = #{sellTime},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="createIme != null">
 | 
	
		
			
				|  |  | +                create_ime_ = #{createIme},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="updateTime != null">
 | 
	
		
			
				|  |  | +                update_time_ = #{updateTime},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +        </set>
 | 
	
		
			
				|  |  | +        where id_ = #{id}
 | 
	
		
			
				|  |  | +    </update>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
 | 
	
		
			
				|  |  | +        insert into sell_order (organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
 | 
	
		
			
				|  |  | +        balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
 | 
	
		
			
				|  |  | +        mer_no_, sell_time_, create_ime_, update_time_)
 | 
	
		
			
				|  |  | +        VALUE
 | 
	
		
			
				|  |  | +        <foreach collection="sellOrders" separator="," item="sellOrder">
 | 
	
		
			
				|  |  | +            (#{sellOrder.organId},#{sellOrder.schoolId},#{sellOrder.transNo},#{sellOrder.orderId},#{sellOrder.orderNo},
 | 
	
		
			
				|  |  | +            #{sellOrder.expectAmount},#{sellOrder.actualAmount},#{sellOrder.balanceAmount},#{sellOrder.type},#{sellOrder.goodsId},
 | 
	
		
			
				|  |  | +            #{sellOrder.goodsName},#{sellOrder.sellCost},#{sellOrder.sellCost2},#{sellOrder.num},#{sellOrder.userId},
 | 
	
		
			
				|  |  | +            #{sellOrder.paymentChannel},#{sellOrder.merNo},#{sellOrder.sellTime},#{sellOrder.createIme},#{sellOrder.updateTime})
 | 
	
		
			
				|  |  | +        </foreach>
 | 
	
		
			
				|  |  | +    </insert>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <!-- 分页查询 -->
 | 
	
		
			
				|  |  | +    <select id="queryPage" resultMap="SellOrder" parameterType="map">
 | 
	
		
			
				|  |  | +        SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_,s.name_ school_name_ FROM sell_order so
 | 
	
		
			
				|  |  | +        LEFT JOIN sys_user su ON so.user_id_ = su.id_
 | 
	
		
			
				|  |  | +        LEFT JOIN organization o ON o.id_ = so.organ_id_
 | 
	
		
			
				|  |  | +        LEFT JOIN school s ON s.id_= so.school_id_
 | 
	
		
			
				|  |  | +        <include refid="queryPageSql"/>
 | 
	
		
			
				|  |  | +        ORDER BY so.sell_time_ DESC
 | 
	
		
			
				|  |  | +        <include refid="global.limit"/>
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <!-- 查询当前表的总记录数 -->
 | 
	
		
			
				|  |  | +    <select id="queryCount" resultType="int">
 | 
	
		
			
				|  |  | +        SELECT COUNT(*) FROM sell_order so
 | 
	
		
			
				|  |  | +        <include refid="queryPageSql"/>
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <sql id="queryPageSql">
 | 
	
		
			
				|  |  | +        <where>
 | 
	
		
			
				|  |  | +            <if test="search != null and search != ''">
 | 
	
		
			
				|  |  | +                AND (so.order_no_ = #{search} OR so.trans_no_ = #{search})
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="organIdList != null and organIdList != ''">
 | 
	
		
			
				|  |  | +                AND FIND_IN_SET(so.organ_id_,#{organIdList})
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="goodsName != null and goodsName != ''">
 | 
	
		
			
				|  |  | +                AND so.goods_name_ = #{goodsName}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="schoolId != null">
 | 
	
		
			
				|  |  | +                AND so.school_id_ = #{schoolId}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="type != null">
 | 
	
		
			
				|  |  | +                AND so.type_ = #{type}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="startTime != null">
 | 
	
		
			
				|  |  | +                AND so.sell_time_ >= #{startTime}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="endTime != null">
 | 
	
		
			
				|  |  | +                AND so.sell_time_ <= #{endTime}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +        </where>
 | 
	
		
			
				|  |  | +    </sql>
 | 
	
		
			
				|  |  | +</mapper>
 |