<?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.matrix.system.hive.dao.MoneyCardUseDao"> 
 | 
    <!-- 定义MoneyCardUse 的复杂关联map --> 
 | 
    <resultMap type="MoneyCardUse" id="MoneyCardUseMap"> 
 | 
        <id property="id" column="id"/> 
 | 
        <result property="orderItemId" column="order_item_id"/> 
 | 
        <result property="useTotal" column="use_total"/> 
 | 
        <result property="lastCount" column="last_count"/> 
 | 
        <result property="realMoney" column="real_money"/> 
 | 
        <result property="giftMoney" column="gift_money"/> 
 | 
        <result property="status" column="status"/> 
 | 
        <result property="source" column="source"/> 
 | 
        <result property="failTime" column="fail_time"/> 
 | 
        <result property="goodsId" column="goods_id"/> 
 | 
        <result property="vipId" column="vip_id"/> 
 | 
        <result property="isOver" column="is_over"/> 
 | 
        <result property="isVipCar" column="is_vip_car"/> 
 | 
        <result property="remark" column="remark"/> 
 | 
        <result property="cardName" column="card_name"/> 
 | 
        <result property="orderId" column="orderId"/> 
 | 
  
 | 
        <!-- 对应会员信息 --> 
 | 
        <association property="vipInfo" javaType="SysVipInfo" 
 | 
                     column="{id=vip_id}" select="com.matrix.system.hive.dao.SysVipInfoDao.selectById"/> 
 | 
    </resultMap> 
 | 
  
 | 
  
 | 
    <!-- 定义MoneyCardUse 的简单map  ,本map不添加其他的关联属性 --> 
 | 
    <resultMap type="MoneyCardUse" id="MoneyCardUseSimpleMap"> 
 | 
        <id property="id" column="id"/> 
 | 
        <result property="orderItemId" column="order_item_id"/> 
 | 
        <result property="useTotal" column="use_total"/> 
 | 
        <result property="lastCount" column="last_count"/> 
 | 
        <result property="realMoney" column="real_money"/> 
 | 
        <result property="giftMoney" column="gift_money"/> 
 | 
        <result property="status" column="status"/> 
 | 
        <result property="source" column="source"/> 
 | 
        <result property="failTime" column="fail_time"/> 
 | 
        <result property="goodsId" column="goods_id"/> 
 | 
        <result property="vipId" column="vip_id"/> 
 | 
        <result property="isOver" column="is_over"/> 
 | 
        <result property="isVipCar" column="is_vip_car"/> 
 | 
        <result property="remark" column="remark"/> 
 | 
        <result property="cardName" column="card_name"/> 
 | 
    </resultMap> 
 | 
  
 | 
    <delete id="deleteByOrderItemId"> 
 | 
        delete from money_card_use where order_item_id=#{orderId} 
 | 
    </delete> 
 | 
  
 | 
    <!--  插入方法   --> 
 | 
    <insert id="insert" parameterType="MoneyCardUse" 
 | 
            useGeneratedKeys="true" keyProperty="id"> 
 | 
        INSERT INTO money_card_use ( 
 | 
            id, 
 | 
            order_item_id, 
 | 
            use_total, 
 | 
            last_count, 
 | 
            real_money, 
 | 
            gift_money, 
 | 
            status, 
 | 
            source, 
 | 
            fail_time, 
 | 
            goods_id, 
 | 
            vip_id, 
 | 
            is_vip_car, 
 | 
            is_over, 
 | 
            remark, 
 | 
            card_name 
 | 
        ) 
 | 
    VALUES ( 
 | 
            #{id}, 
 | 
            #{orderItemId}, 
 | 
            #{useTotal}, 
 | 
            #{lastCount}, 
 | 
            #{realMoney}, 
 | 
            #{giftMoney}, 
 | 
            #{status}, 
 | 
            #{source}, 
 | 
            #{failTime}, 
 | 
            #{goodsId}, 
 | 
            #{vipId}, 
 | 
            #{isVipCar}, 
 | 
            #{isOver}, 
 | 
            #{remark}, 
 | 
            #{cardName} 
 | 
    ) 
 | 
    </insert> 
 | 
  
 | 
  
 | 
    <!--  根据id更新 部分更新   --> 
 | 
    <update id="update"> 
 | 
        UPDATE money_card_use 
 | 
        <set> 
 | 
            <if test="orderItemId != null and orderItemId !='' "> 
 | 
                order_item_id = #{orderItemId}, 
 | 
            </if> 
 | 
            <if test="useTotal != null "> 
 | 
                use_total = #{useTotal}, 
 | 
            </if> 
 | 
            <if test="lastCount != null "> 
 | 
                last_count = #{lastCount}, 
 | 
            </if> 
 | 
  
 | 
            <if test="realMoney != null "> 
 | 
                real_money = #{realMoney}, 
 | 
            </if> 
 | 
            <if test="giftMoney != null "> 
 | 
                gift_money = #{giftMoney}, 
 | 
            </if> 
 | 
            <if test="status != null and status !='' "> 
 | 
                status = #{status}, 
 | 
            </if> 
 | 
            <if test="source != null and source !='' "> 
 | 
                source = #{source}, 
 | 
            </if> 
 | 
            <if test="failTime != null  "> 
 | 
                fail_time = #{failTime}, 
 | 
            </if> 
 | 
            <if test="goodsId != null and goodsId !='' "> 
 | 
                goods_id = #{goodsId}, 
 | 
            </if> 
 | 
            <if test="vipId != null and vipId !='' "> 
 | 
                vip_id = #{vipId}, 
 | 
            </if> 
 | 
            <if test="isOver != null and isOver !='' "> 
 | 
                is_over = #{isOver}, 
 | 
            </if> 
 | 
            <if test="isVipCar != null and isVipCar !='' "> 
 | 
                is_vip_car = #{isVipCar}, 
 | 
            </if> 
 | 
            <if test="remark != null and remark !='' "> 
 | 
                remark = #{remark}, 
 | 
            </if> 
 | 
            <if test="cardName != null and cardName !='' "> 
 | 
                card_name = #{cardName}, 
 | 
            </if> 
 | 
        </set> 
 | 
        WHERE id=#{id} 
 | 
    </update> 
 | 
    <update id="updateId"> 
 | 
        update money_card_use set id=#{newId} where id=#{id} 
 | 
    </update> 
 | 
  
 | 
  
 | 
    <!-- 批量删除 --> 
 | 
    <delete id="deleteByIds" parameterType="java.util.List"> 
 | 
        delete from money_card_use where id in 
 | 
        <foreach collection="list" index="index" item="item" open="(" 
 | 
                 separator="," close=")"> 
 | 
            #{item} 
 | 
        </foreach> 
 | 
    </delete> 
 | 
  
 | 
    <!-- 根据id删除--> 
 | 
    <delete id="deleteById"> 
 | 
        DELETE FROM money_card_use 
 | 
        where  id=#{id}  
 | 
    </delete> 
 | 
  
 | 
  
 | 
    <!-- 分页查询 --> 
 | 
    <select id="selectInPage" resultMap="MoneyCardUseMap"> 
 | 
        select 
 | 
        id, 
 | 
        order_item_id, 
 | 
        use_total, 
 | 
        last_count, 
 | 
        real_money, 
 | 
        gift_money, 
 | 
        status, 
 | 
        source, 
 | 
        fail_time, 
 | 
        goods_id, 
 | 
        vip_id, 
 | 
        is_over, 
 | 
        is_vip_car, 
 | 
        remark, 
 | 
        card_name 
 | 
        from money_card_use 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.id != null and record.id !='' "> 
 | 
                and id = #{record.id} 
 | 
            </if> 
 | 
            <if test="record.orderItemId != null and record.orderItemId !='' "> 
 | 
                and order_item_id = #{record.orderItemId} 
 | 
            </if> 
 | 
            <if test="record.useTotal != null and record.useTotal !='' "> 
 | 
                and use_total = #{record.useTotal} 
 | 
            </if> 
 | 
            <if test="record.lastCount != null and record.lastCount !='' "> 
 | 
                and last_count = #{record.lastCount} 
 | 
            </if> 
 | 
            <if test="record.realMoney != null and record.realMoney !='' "> 
 | 
                and real_money = #{record.realMoney} 
 | 
            </if> 
 | 
            <if test="record.giftMoney != null and record.giftMoney !='' "> 
 | 
                and gift_money = #{record.giftMoney} 
 | 
            </if> 
 | 
            <if test="record.status != null and record.status !='' "> 
 | 
                and status = #{record.status} 
 | 
            </if> 
 | 
            <if test="record.source != null and record.source !='' "> 
 | 
                and source = #{record.source} 
 | 
            </if> 
 | 
            <if test="record.failTime != null  "> 
 | 
                and fail_time = #{record.failTime} 
 | 
            </if> 
 | 
            <if test="record.goodsId != null and record.goodsId !='' "> 
 | 
                and goods_id = #{record.goodsId} 
 | 
            </if> 
 | 
            <if test="record.vipId != null and record.vipId !='' "> 
 | 
                and vip_id = #{record.vipId} 
 | 
            </if> 
 | 
            <if test="record.isOver != null and record.isOver !='' "> 
 | 
                and is_over = #{record.isOver} 
 | 
            </if> 
 | 
            <if test="record.isVipCar != null and record.isVipCar !='' "> 
 | 
                and is_vip_car = #{record.isVipCar} 
 | 
            </if> 
 | 
            <if test="record.remark != null and record.remark !='' "> 
 | 
                and remark = #{record.remark} 
 | 
            </if> 
 | 
            <if test="record.cardName != null and record.cardName !='' "> 
 | 
                and card_name = #{record.cardName} 
 | 
            </if> 
 | 
        </if> 
 | 
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> 
 | 
            <if test="pageVo.sort !=null  and pageVo.order !=null"> 
 | 
                order by 
 | 
                ${pageVo.sort} ${pageVo.order} 
 | 
            </if> 
 | 
            <if test="pageVo.offset >=0  and pageVo.limit >0"> 
 | 
                limit 
 | 
                #{pageVo.offset},#{pageVo.limit} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <!-- 查询总条数 --> 
 | 
    <select id="selectTotalRecord" resultType="java.lang.Integer"> 
 | 
        select count(*) 
 | 
        from money_card_use 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.id != null and record.id !='' "> 
 | 
                and id = #{record.id} 
 | 
            </if> 
 | 
            <if test="record.orderItemId != null and record.orderItemId !='' "> 
 | 
                and order_item_id = #{record.orderItemId} 
 | 
            </if> 
 | 
            <if test="record.useTotal != null and record.useTotal !='' "> 
 | 
                and use_total = #{record.useTotal} 
 | 
            </if> 
 | 
            <if test="record.lastCount != null and record.lastCount !='' "> 
 | 
                and last_count = #{record.lastCount} 
 | 
            </if> 
 | 
            <if test="record.realMoney != null and record.realMoney !='' "> 
 | 
                and real_money = #{record.realMoney} 
 | 
            </if> 
 | 
            <if test="record.giftMoney != null and record.giftMoney !='' "> 
 | 
                and gift_money = #{record.giftMoney} 
 | 
            </if> 
 | 
            <if test="record.status != null and record.status !='' "> 
 | 
                and status = #{record.status} 
 | 
            </if> 
 | 
            <if test="record.source != null and record.source !='' "> 
 | 
                and source = #{record.source} 
 | 
            </if> 
 | 
            <if test="record.failTime != null  "> 
 | 
                and fail_time = #{record.failTime} 
 | 
            </if> 
 | 
            <if test="record.goodsId != null and record.goodsId !='' "> 
 | 
                and goods_id = #{record.goodsId} 
 | 
            </if> 
 | 
            <if test="record.vipId != null and record.vipId !='' "> 
 | 
                and vip_id = #{record.vipId} 
 | 
            </if> 
 | 
            <if test="record.isOver != null and record.isOver !='' "> 
 | 
                and is_over = #{record.isOver} 
 | 
            </if> 
 | 
            <if test="record.isVipCar != null and record.isVipCar !='' "> 
 | 
                and is_vip_car = #{record.isVipCar} 
 | 
            </if> 
 | 
            <if test="record.remark != null and record.remark !='' "> 
 | 
                and remark = #{record.remark} 
 | 
            </if> 
 | 
            <if test="record.cardName != null and record.cardName !='' "> 
 | 
                and card_name = #{record.cardName} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <!-- 根据id查询--> 
 | 
    <select id="selectById" resultMap="MoneyCardUseMap"> 
 | 
        select * 
 | 
        from money_card_use 
 | 
        where  id=#{id}  
 | 
    </select> 
 | 
  
 | 
    <!--获取会员的会籍卡--> 
 | 
    <select id="selectVipCard" resultMap="MoneyCardUseMap"> 
 | 
        select * 
 | 
        from money_card_use 
 | 
        where  vip_id=#{vipId} and card_name='储值卡' 
 | 
    </select> 
 | 
  
 | 
    <!-- 根据对象查询--> 
 | 
    <select id="selectByModel" resultMap="MoneyCardUseMap"> 
 | 
        select * 
 | 
        from money_card_use 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.id != null and record.id !='' "> 
 | 
                and id = #{record.id} , 
 | 
            </if> 
 | 
            <if test="record.orderItemId != null and record.orderItemId !='' "> 
 | 
                and order_item_id = #{record.orderItemId} 
 | 
            </if> 
 | 
            <if test="record.useTotal != null and record.useTotal !='' "> 
 | 
                and use_total = #{record.useTotal} 
 | 
            </if> 
 | 
            <if test="record.lastCount != null and record.lastCount !='' "> 
 | 
                and last_count = #{record.lastCount} 
 | 
            </if> 
 | 
            <if test="record.realMoney != null and record.realMoney !='' "> 
 | 
                and real_money = #{record.realMoney} 
 | 
            </if> 
 | 
            <if test="record.giftMoney != null and record.giftMoney !='' "> 
 | 
                and gift_money = #{record.giftMoney} 
 | 
            </if> 
 | 
            <if test="record.status != null and record.status !='' "> 
 | 
                and status = #{record.status} 
 | 
            </if> 
 | 
            <if test="record.source != null and record.source !='' "> 
 | 
                and source = #{record.source} 
 | 
            </if> 
 | 
            <if test="record.failTime != null  "> 
 | 
                and fail_time = #{record.failTime} 
 | 
            </if> 
 | 
            <if test="record.goodsId != null and record.goodsId !='' "> 
 | 
                and goods_id = #{record.goodsId} 
 | 
            </if> 
 | 
            <if test="record.vipId != null and record.vipId !='' "> 
 | 
                and vip_id = #{record.vipId} 
 | 
            </if> 
 | 
            <if test="record.isOver != null and record.isOver !='' "> 
 | 
                and is_over = #{record.isOver} 
 | 
            </if> 
 | 
            <if test="record.isVipCar != null and record.isVipCar !='' "> 
 | 
                and is_vip_car = #{record.isVipCar} 
 | 
            </if> 
 | 
            <if test="record.remark != null and record.remark !='' "> 
 | 
                and remark = #{record.remark} 
 | 
            </if> 
 | 
            <if test="record.cardName != null and record.cardName !='' "> 
 | 
                and card_name = #{record.cardName} 
 | 
            </if> 
 | 
        </if> 
 | 
        order by is_over ,fail_time 
 | 
    </select> 
 | 
  
 | 
  
 | 
    <!-- 分页查询vip的充值卡 --> 
 | 
    <select id="selectVipCardUseInPage" resultMap="MoneyCardUseMap"> 
 | 
        select 
 | 
        a.id, 
 | 
        a.order_item_id, 
 | 
        d.id AS orderId, 
 | 
        a.use_total, 
 | 
        a.last_count, 
 | 
        a.real_money, 
 | 
        a.gift_money, 
 | 
        a.status, 
 | 
        a.source, 
 | 
        a.fail_time, 
 | 
        a.goods_id, 
 | 
        a.vip_id, 
 | 
        a.is_over, 
 | 
        a.is_vip_car, 
 | 
        a.remark, 
 | 
        a.card_name 
 | 
        from money_card_use a 
 | 
        left join shopping_goods b on a.goods_id=b.id 
 | 
        left join sys_order_item c on a.ORDER_ITEM_ID=c.id 
 | 
        left join sys_order d on c.ORDER_ID=d.id 
 | 
        where a.vip_id = #{record.vipId} 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.orderItemId != null and record.orderItemId !='' "> 
 | 
                and a.order_item_id = #{record.orderItemId} 
 | 
            </if> 
 | 
            <if test="record.status != null and record.status !='' "> 
 | 
                and a.status = #{record.status} 
 | 
            </if> 
 | 
            <if test="record.source != null and record.source !='' "> 
 | 
                and a.source = #{record.source} 
 | 
            </if> 
 | 
  
 | 
            <if test="record.isOver != null and record.isOver !='' "> 
 | 
                and a.is_over = #{record.isOver} 
 | 
            </if> 
 | 
            <if test="record.isVipCar != null and record.isVipCar !='' "> 
 | 
                and a.is_vip_car = #{record.isVipCar} 
 | 
            </if> 
 | 
  
 | 
            <if test="record.remark != null and record.remark !='' "> 
 | 
                and a.remark = #{record.remark} 
 | 
            </if> 
 | 
            <if test="record.cardName != null and record.cardName !='' "> 
 | 
                and card_name = #{record.cardName} 
 | 
            </if> 
 | 
        </if> 
 | 
        order by a.is_over ,a.fail_time 
 | 
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> 
 | 
            <if test="pageVo.offset >=0  and pageVo.limit >0"> 
 | 
                limit 
 | 
                #{pageVo.offset},#{pageVo.limit} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <!-- 查询总条数 --> 
 | 
    <select id="selectVipCardUseTotal" resultType="java.lang.Integer"> 
 | 
        select count(*) 
 | 
        from money_card_use a 
 | 
        left join shopping_goods b on a.goods_id=b.id 
 | 
        left join sys_order_item c on a.ORDER_ITEM_ID=c.id 
 | 
        left join sys_order d on c.ORDER_ID=d.id 
 | 
        where a.vip_id = #{record.vipId} 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.orderItemId != null and record.orderItemId !='' "> 
 | 
                and a.order_item_id = #{record.orderItemId} 
 | 
            </if> 
 | 
            <if test="record.status != null and record.status !='' "> 
 | 
                and a.status = #{record.status} 
 | 
            </if> 
 | 
            <if test="record.source != null and record.source !='' "> 
 | 
                and a.source = #{record.source} 
 | 
            </if> 
 | 
            <if test="record.isOver != null and record.isOver !='' "> 
 | 
                and a.is_over = #{record.isOver} 
 | 
            </if> 
 | 
            <if test="record.isVipCar != null and record.isVipCar !='' "> 
 | 
                and a.is_vip_car = #{record.isVipCar} 
 | 
            </if> 
 | 
            <if test="record.remark != null and record.remark !='' "> 
 | 
                and a.remark = #{record.remark} 
 | 
            </if> 
 | 
  
 | 
            <if test="record.cardName != null and record.cardName !='' "> 
 | 
                and card_name = #{record.cardName} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <!--查询vip的充值卡 --> 
 | 
    <select id="selectVipCardUse" resultMap="MoneyCardUseMap"> 
 | 
        select 
 | 
        a.id, 
 | 
        a.order_item_id, 
 | 
        a.use_total, 
 | 
        a.last_count, 
 | 
        a.real_money, 
 | 
        a.gift_money, 
 | 
        a.status, 
 | 
        a.source, 
 | 
        a.fail_time, 
 | 
        a.goods_id, 
 | 
        a.vip_id, 
 | 
        a.is_over, 
 | 
        a.is_vip_car, 
 | 
        a.remark, 
 | 
        a.card_name 
 | 
        from money_card_use a 
 | 
        left join shopping_goods b on a.goods_id=b.id 
 | 
        where vip_id = #{record.vipId} 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.orderItemId != null and record.orderItemId !='' "> 
 | 
                and a.order_item_id = #{record.orderItemId} 
 | 
            </if> 
 | 
            <if test="record.status != null and record.status !='' "> 
 | 
                and a.status = #{record.status} 
 | 
            </if> 
 | 
            <if test="record.source != null and record.source !='' "> 
 | 
                and a.source = #{record.source} 
 | 
            </if> 
 | 
  
 | 
            <if test="record.isOver != null and record.isOver !='' "> 
 | 
                and a.is_over = #{record.isOver} 
 | 
            </if> 
 | 
            <if test="record.isVipCar != null and record.isVipCar !='' "> 
 | 
                and a.is_vip_car = #{record.isVipCar} 
 | 
            </if> 
 | 
  
 | 
            <if test="record.remark != null and record.remark !='' "> 
 | 
                and a.remark = #{record.remark} 
 | 
            </if> 
 | 
            <if test="record.cardName != null and record.cardName !='' "> 
 | 
                and card_name = #{record.cardName} 
 | 
            </if> 
 | 
        </if> 
 | 
        order by a.is_over ,a.fail_time 
 | 
    </select> 
 | 
  
 | 
    <select id="selectItemDetail" resultType="java.util.HashMap" parameterType="java.util.HashMap"> 
 | 
        select c.VIP_NAME, 
 | 
        a.card_name, 
 | 
        a.real_money, 
 | 
        a.gift_money, 
 | 
        a.IS_OVER, 
 | 
        a.FAIL_TIME, 
 | 
        a.is_vip_car, 
 | 
        a.SOURCE, 
 | 
        e.ORDER_NO, 
 | 
        a.remark, 
 | 
        a.card_name 
 | 
        from money_card_use a 
 | 
        left join sys_vip_info c on c.ID = a.VIP_ID 
 | 
        left join sys_order_item d on d.id = a.ORDER_ITEM_ID 
 | 
        left join sys_order e on e.id = d.ORDER_ID 
 | 
        <where> 
 | 
            <if test="shopId != null and  shopId != ''"> 
 | 
                and c.shop_id =#{shopId} 
 | 
            </if> 
 | 
            <if test="vipQueryKey != null and vipQueryKey != ''  "> 
 | 
                and c.VIP_NAME like concat('%',#{vipQueryKey},'%') 
 | 
                or (c.VIP_NO like concat('%',#{vipQueryKey},'%') 
 | 
                or c.PHONE like concat('%',#{vipQueryKey},'%') 
 | 
                ) 
 | 
            </if> 
 | 
            <if test="goodsName != null and goodsName != ''  "> 
 | 
                b.name like concat('%',#{goodsName},'%') 
 | 
            </if> 
 | 
            <if test="cateId != null and cateId != ''  "> 
 | 
                b.cate_id=#{cateId} 
 | 
            </if> 
 | 
        </where> 
 | 
  
 | 
        <if test="sort !=null and sort!=''"> order by ${sort} ${order}</if> 
 | 
        <if test="(offset !=null and offset!='') or offset==0 "> 
 | 
            limit ${offset},${limit} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="selectItemDetailTotal" resultType="java.lang.Integer"> 
 | 
        select count(a.id) 
 | 
        from money_card_use a 
 | 
        left join shopping_goods b on a.goods_id = b.id 
 | 
        left join sys_vip_info c on c.ID = a.VIP_ID 
 | 
        left join sys_order_item d on d.id = a.ORDER_ITEM_ID 
 | 
        left join sys_order e on e.id = d.ORDER_ID 
 | 
        left join shopping_goods_category f on f.id = b.cate_id 
 | 
        <where> 
 | 
            <if test="shopId != null and  shopId != ''"> 
 | 
                and c.shop_id =#{shopId} 
 | 
            </if> 
 | 
            <if test="vipQueryKey != null and vipQueryKey != ''  "> 
 | 
                and e.VIP_NAME like concat('%',#{vipQueryKey},'%') 
 | 
                or (e.VIP_NO like concat('%',#{vipQueryKey},'%') 
 | 
                or e.PHONE like concat('%',#{vipQueryKey},'%') 
 | 
                ) 
 | 
            </if> 
 | 
            <if test="goodsName != null and goodsName != ''  "> 
 | 
                b.name like concat('%',#{goodsName},'%') 
 | 
            </if> 
 | 
            <if test="cateId != null and cateId != ''  "> 
 | 
                b.cate_id=#{cateId} 
 | 
            </if> 
 | 
        </where> 
 | 
    </select> 
 | 
  
 | 
    <select id="summaryItemDetail" resultType="java.util.HashMap" parameterType="java.util.HashMap"> 
 | 
        select 
 | 
        a.card_name, 
 | 
        b.id, 
 | 
        ROUND( SUM(a.real_money),2)as real_money, 
 | 
        ROUND(SUM(a.gift_money),2) as gift_money 
 | 
        from money_card_use a 
 | 
        left join shopping_goods b on a.goods_id = b.id 
 | 
        left join sys_vip_info c on c.ID = a.VIP_ID 
 | 
        <where> 
 | 
            <if test="shopId != null and  shopId != ''"> 
 | 
                and c.shop_id =#{shopId} 
 | 
            </if> 
 | 
            <if test="goodsName != null and goodsName != ''  "> 
 | 
                b.name like concat('%',#{goodsName},'%') 
 | 
            </if> 
 | 
            <if test="cateId != null and cateId != ''  "> 
 | 
                b.cate_id=#{cateId} 
 | 
            </if> 
 | 
        </where> 
 | 
        group by b.id 
 | 
  
 | 
        <if test="sort !=null and sort!=''"> order by ${sort} ${order}</if> 
 | 
        <if test="(offset !=null and offset!='') or offset==0 "> 
 | 
            limit ${offset},${limit} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="summaryItemDetailTotal" resultType="java.lang.Integer"> 
 | 
        select count(1) from ( 
 | 
        select count(1) 
 | 
        from money_card_use a 
 | 
        left join shopping_goods b on a.goods_id = b.id 
 | 
        left join sys_vip_info c on c.ID = a.VIP_ID 
 | 
        <where> 
 | 
            <if test="shopId != null and  shopId != ''"> 
 | 
                and c.shop_id =#{shopId} 
 | 
            </if> 
 | 
            <if test="goodsName != null and goodsName != ''  "> 
 | 
                b.name like concat('%',#{goodsName},'%') 
 | 
            </if> 
 | 
            <if test="cateId != null and cateId != ''  "> 
 | 
                b.cate_id=#{cateId} 
 | 
            </if> 
 | 
        </where> 
 | 
        group by b.id) t 
 | 
    </select> 
 | 
  
 | 
    <!-- 美度不显示赠送金额 IFNULL(sum(IFNULL(gift_money, 0)),0)+--> 
 | 
    <select id="selectVipCardTotalMoney" resultType="java.lang.Double"> 
 | 
  
 | 
            SELECT  IFNULL(sum(IFNULL(real_money, 0)),0)  from money_card_use where vip_id=#{vipId}  and `status` ='有效' 
 | 
    </select> 
 | 
  
 | 
  
 | 
    <update id="updateInvalidMoneyCardUse"> 
 | 
        update money_card_use set STATUS='无效' 
 | 
        where date_format(now(), '%Y-%m-%d') > date_format(FAIL_TIME, '%Y-%m-%d') and STATUS='有效' 
 | 
    </update> 
 | 
</mapper> 
 |