package com.jeequan.jeepay.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeequan.jeepay.db.entity.RouteManage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2024-04-19
 */
public interface RouteManageMapper extends BaseMapper<RouteManage> {

    /**
     * 分页查询
     * @param page
     * @param entity
     * @return
     */
    IPage<RouteManage> pageList(@Param("page") Page<RouteManage> page, @Param("entity") RouteManage entity,@Param("date") Date[] dateRange);

    /**
     * 根据路由id和状态查询
     * @param routeId
     * @param state
     * @return
     */
    List<RouteManage> listByRouteId(@Param("routeId") String routeId, @Param("state") byte state);

    /**
     * 更新成功数据
     * @param amount
     * @param storeId
     */
    @Update("UPDATE t_route_manage set succ_num  = succ_num + 1,succ_amount = succ_amount + #{amount} where  store_id = #{storeId}")
    void updateSuccData(@Param("amount") Long amount, @Param("storeId") String storeId);

    /**
     * 更新总数
     * @param amount
     * @param storeId
     */
    @Update("UPDATE t_route_manage set total_num  = total_num + 1,total_amount = total_amount + #{amount} where  store_id = #{storeId}")
    void updateTotalData(@Param("amount") Long amount, @Param("storeId") String storeId);
}
