package com.fs.course.mapper;

import java.util.List;
import com.fs.course.domain.FsUserVipOrder;
import com.fs.course.param.FsUserVipOrderParam;
import com.fs.course.vo.FsUserVipOrderListPVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 购买会员订单Mapper接口
 *
 * @author fs
 * @date 2024-06-27
 */
public interface FsUserVipOrderMapper
{
    /**
     * 查询购买会员订单
     *
     * @param orderId 购买会员订单主键
     * @return 购买会员订单
     */
    public FsUserVipOrder selectFsUserVipOrderByOrderId(Long orderId);

    /**
     * 查询购买会员订单列表
     *
     * @param fsUserVipOrder 购买会员订单
     * @return 购买会员订单集合
     */
    public List<FsUserVipOrder> selectFsUserVipOrderList(FsUserVipOrder fsUserVipOrder);

    /**
     * 新增购买会员订单
     *
     * @param fsUserVipOrder 购买会员订单
     * @return 结果
     */
    public int insertFsUserVipOrder(FsUserVipOrder fsUserVipOrder);

    /**
     * 修改购买会员订单
     *
     * @param fsUserVipOrder 购买会员订单
     * @return 结果
     */
    public int updateFsUserVipOrder(FsUserVipOrder fsUserVipOrder);

    /**
     * 删除购买会员订单
     *
     * @param orderId 购买会员订单主键
     * @return 结果
     */
    public int deleteFsUserVipOrderByOrderId(Long orderId);

    /**
     * 批量删除购买会员订单
     *
     * @param orderIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsUserVipOrderByOrderIds(Long[] orderIds);

    @Select("select * from fs_user_vip_order where order_code = #{orderCode}")
    FsUserVipOrder selectFsUserVipOrderByOrderCode(String orderCode);

    @Select({"<script> " +
            "select o.*,u.phone,p.package_name from fs_user_vip_order o " +
            " left join fs_user_vip_package p on p.package_id = o.package_id " +
            " left join fs_user u on u.user_id  = o.user_id " +
            " where 1=1 " +
            "<if test = ' maps.packageId!=null  '> " +
            "and o.package_id = #{maps.packageId} " +
            "</if>" +
            "<if test = ' maps.userId!=null  '> " +
            "and o.user_id = #{maps.userId} " +
            "</if>" +
            "<if test = ' maps.phone!=null  '> " +
            "and u.phone = #{maps.phone} " +
            "</if>" +
            "<if test = ' maps.status!=null  '> " +
            "and o.status = #{maps.status} " +
            "</if>" +
            "<if test = ' maps.payType!=null  '> " +
            "and o.pay_type = #{maps.payType} " +
            "</if>" +
            " order by o.order_id desc  "+
            "</script>"})
    List<FsUserVipOrderListPVO> selectFsUserVipOrderListPVO(@Param("maps") FsUserVipOrderParam param);
}
