|  |  |  | 
|---|
|  |  |  | <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" | 
|---|
|  |  |  | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </set> | 
|---|
|  |  |  | WHERE id=#{id} | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  | <update id="updateId"> | 
|---|
|  |  |  | update money_card_use set id=#{newId} where id=#{id} | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | select | 
|---|
|  |  |  | a.id, | 
|---|
|  |  |  | a.order_item_id, | 
|---|
|  |  |  | d.id AS orderId, | 
|---|
|  |  |  | a.use_total, | 
|---|
|  |  |  | a.last_count, | 
|---|
|  |  |  | a.real_money, | 
|---|
|  |  |  | 
|---|
|  |  |  | a.remark, | 
|---|
|  |  |  | a.card_name | 
|---|
|  |  |  | from money_card_use a | 
|---|
|  |  |  | where vip_id = #{record.vipId} | 
|---|
|  |  |  | 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} | 
|---|
|  |  |  | 
|---|
|  |  |  | select count(*) | 
|---|
|  |  |  | from money_card_use a | 
|---|
|  |  |  | left join shopping_goods b on a.goods_id=b.id | 
|---|
|  |  |  | where vip_id = #{record.vipId} | 
|---|
|  |  |  | 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} | 
|---|
|  |  |  | 
|---|
|  |  |  | group by b.id) t | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- 美度不显示赠送金额 IFNULL(sum(IFNULL(gift_money, 0)),0)+--> | 
|---|
|  |  |  | <select id="selectVipCardTotalMoney" resultType="java.lang.Double"> | 
|---|
|  |  |  | SELECT TRUNCATE( SUM(gift_money)+SUM(real_money) ,2 ) from money_card_use where vip_id=#{vipId}  and `status` ='有效' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SELECT  IFNULL(sum(IFNULL(real_money, 0)),0)  from money_card_use where vip_id=#{vipId}  and `status` ='有效' | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectHasValidMoneyCardUse" resultMap="MoneyCardUseSimpleMap"> | 
|---|
|  |  |  | select * from money_card_use | 
|---|
|  |  |  | <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='有效' | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  | </mapper> | 
|---|