| <?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="cc.mrbird.febs.mall.mapper.MallAchieveRecordMapper"> | 
|   | 
|     <select id="selectAchieveTotal" resultType="java.math.BigDecimal"> | 
|         select IFNULL(sum(IFNULL(amount,0)),0) from mall_achieve_record | 
|         where 1=1 | 
|         <if test='type == "D"'> | 
|             and date_format(achieve_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d'); | 
|         </if> | 
|         <if test='type == "M"'> | 
|             and date_format(achieve_time, '%Y-%m') = date_format(#{date}, '%Y-%m'); | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="selectSumAchieveByMemberIds" resultType="java.math.BigDecimal"> | 
|         select IFNULL(sum(IFNULL(amount,0)),0) | 
|         from mall_achieve_record | 
|         where  member_id IN | 
|         <foreach collection = "list" item = "item"  separator=","  open = "(" close = ")" > | 
|             #{item} | 
|         </foreach > | 
|         and date_format(achieve_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d'); | 
|     </select> | 
|   | 
|     <select id="selectListByDate" resultType="cc.mrbird.febs.mall.entity.MallAchieveRecord"> | 
|         select * from mall_achieve_record | 
|         where date_format(achieve_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d'); | 
|     </select> | 
|   | 
|     <select id="selectSumAchieveByMemberId" resultType="java.math.BigDecimal"> | 
|         select IFNULL(sum(IFNULL(amount,0)),0) | 
|         from mall_achieve_record | 
|         where  member_id = #{memberId}; | 
|     </select> | 
|   | 
| </mapper> |