package com.xxfc.platform.activity.mapper;

import com.xxfc.platform.activity.dto.UserCouponDTO;
import com.xxfc.platform.activity.dto.UserCouponFindDTO;
import com.xxfc.platform.activity.entity.UserCoupon;
import com.xxfc.platform.activity.vo.UserCouponVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 我的优惠卷
 * 
 * @author libin
 * @email 18178966185@163.com
 * @date 2019-06-21 14:34:49
 */
public interface UserCouponMapper extends Mapper<UserCoupon> , InsertListMapper<UserCoupon> {

    //我的优惠卷
    public List<UserCouponVo> getUserCouponsByType(@Param("userId")Integer userId,@Param("type")int type,@Param("time")Long time,@Param("channel")Integer channel);

   //单个优惠卷
    public UserCouponVo getUserCoupon(@Param("tickerNo")String tickerNo);

    //已使用的优惠券数量数量加减
    @Update("update coupon set used_count=used_count+#{count} where `id`=#{id}")
    int upUsedCount(@Param("id")Integer id,@Param("count")Integer count);


    List<UserCouponDTO> findUserCoupons(UserCouponFindDTO userCouponFindDTO);

    int inserBatch(@Param("userCoupons") List<UserCoupon> userCoupons);

    void updateUserCouponStatusById(@Param("id") Integer id);
}