goods-order-mapper.xml 1.86 KB
<?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">

<!-- 兑换记录 @author kongmingke -->
<mapper namespace="com.cjs.cms.dao.user.point.GoodsOrderDao">

	<sql id="goods_order_field">
	    goods_order.id, order_no, goods_order.user_id, goods_id, buy_amount, 
	    buy_money, buy_point, status, goods_order.remark, goods_order.create_at, goods_order.create_by
	</sql>
	
	<sql id="searchCondition">
		<if test="userId != null and userId != ''"> and user_id=#{userId} </if>
		<if test="otcCode != null and otcCode != ''"> and otc_code =#{otcCode} </if>
		<if test="otcName != null and otcName != ''"> and otc_name =#{otcName} </if>
		<if test="status != null and status != ''"> and status = #{status} </if>
		<if test="startDate != null and startDate != ''"> <![CDATA[ and goods_order.create_at >= #{startDate}]]> </if>
		<if test="endDate != null and endDate != ''"> <![CDATA[ and goods_order.create_at <= DATE_ADD(#{endDate}, INTERVAL 1 day)]]> </if>
	</sql>
	<select id="search" parameterType="map" resultType="GoodsOrderInfo">
		select <include refid="goods_order_field" />, otc_code, otc_name
		from goods_order, goods_config
		where goods_order.goods_id=goods_config.id
		<include refid="searchCondition" />
		order by id desc
		<include refid="common.pageLimit" />
	</select>
	<select id="searchTotal" parameterType="map" resultType="int">
		select count(*)
		from goods_order, goods_config
		where goods_order.goods_id=goods_config.id
		<include refid="searchCondition" />
	</select>
	
	<select id="searchSum" parameterType="map" resultType="map">
	   select IFNULL(sum(buy_amount),0) buyAmount,IFNULL(sum(buy_money),0) buyMoney,IFNULL(sum(buy_point),0) buyPoint
	   from goods_order, goods_config
	   where goods_order.goods_id=goods_config.id
	   <include refid="searchCondition" />
	</select>
</mapper>