package com.yunzhi.marketing.redpack.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunzhi.marketing.entity.TaCustomerFrom;
import com.yunzhi.marketing.excel.redPacket.RedPacketVisitRecordtExport;
import com.yunzhi.marketing.redpack.entity.TaRedPacket;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 红包助力活动  Mapper 接口
 * </p>
 *
 * @author fxf
 * @since 2020-06-03
 */
@Mapper
@Component
public interface TaRedPacketMapper extends BaseMapper<TaRedPacket> {

    /**
     * 初始化红包基础配置信息
     *
     * @param activityId
     * @return
     */
    Integer initRedPacket(@Param("activityId") String activityId,
                          @Param("name") String name,
                          @Param("qrCode") String qrCode,
                          @Param("startDate") LocalDateTime startDate,
                          @Param("endDate") LocalDateTime endDate,
                          @Param("templeActivityId") String templeActivityId,
                          @Param("buildingId") String buildingId,
                          @Param("orgId") Integer orgId);

    /**
     * 初始化红包助力配置信息
     *
     * @param activityId
     * @return
     */
    Integer initRedPacketHelp(@Param("activityId") String activityId,
                              @Param("templeActivityId") String templeActivityId);

    /**
     * 初始化红包客户端消息配置
     *
     * @param activityId
     * @return
     */
    Integer initRedPacketClient(@Param("activityId") String activityId,
                                @Param("activityName") String activityName,
                                @Param("miniAppName") String miniAppName,
                                @Param("templeActivityId") String templeActivityId);

    /**
     * 初始化红包金额配置
     *
     * @param activityId
     * @return
     */
    Integer initRedPacketMoney(@Param("activityId") String activityId,
                               @Param("templeActivityId") String templeActivityId);

    /**
     * 初始化红包图片信息
     *
     * @param activityId
     * @return
     */
    Integer initRedPacketImages(@Param("activityId") String activityId,
                                @Param("templeActivityId") String templeActivityId);

    /**
     * 查询客户访问记录
     *
     * @param page
     * @param startTime
     * @param endTime
     * @param drainageId
     * @param phone
     * @param sharePersonPhone
     * @param orgId
     * @return
     */
    IPage<TaCustomerFrom> listVisitRecordByCondition(IPage<TaCustomerFrom> page,
                                                     @Param("startTime") LocalDateTime startTime,
                                                     @Param("endTime") LocalDateTime endTime,
                                                     @Param("drainageId") String drainageId,
                                                     @Param("phone") String phone,
                                                     @Param("sharePersonPhone") String sharePersonPhone,
                                                     @Param("orgId") Integer orgId);


    /**
     * @param startTime
     * @param endTime
     * @param drainageId
     * @param phone
     * @param sharePersonPhone
     * @param orgId
     * @return
     */
    List<RedPacketVisitRecordtExport> exportVisitRecordByCondition(@Param("startTime") LocalDateTime startTime,
                                                                   @Param("endTime") LocalDateTime endTime,
                                                                   @Param("drainageId") String drainageId,
                                                                   @Param("phone") String phone,
                                                                   @Param("sharePersonPhone") String sharePersonPhone,
                                                                   @Param("orgId") Integer orgId);

}
