package com.bonus.canteen.core.menu.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.menu.entity.MenuDishesSaleRecord;
import com.bonus.canteen.core.menu.model.MenuStallSaleModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MenuDishesSaleRecordMapper extends BaseMapper<MenuDishesSaleRecord> {
   @Update({"update menu_dishes_sale_record set sale_num = sale_num + #{saleNum}, monthly_sales = monthly_sales + #{saleNum}, update_time = now() where dishes_id = #{dishesId} and stall_id = #{stallId}"})
   void updateSaleNum(@Param("dishesId") Long dishesId, @Param("stallId") Long stallId, @Param("saleNum") Integer saleNum);

   List<Long> selectTopDishesIdList(@Param("stallIdList") List<Long> stallIdList);

   @Select({"select dishes_id, evaluate_num, evaluate_level, good_probability from menu_dishes_sale_record ${ew.customSqlSegment}"})
   MenuDishesSaleRecord selectEvaluate(@Param("ew") Wrapper<MenuDishesSaleRecord> wrapper);

   List<MenuStallSaleModel> selectMonthSalesStall(@Param("stallIdList") List<Long> stallIdList);

//   List<DishesStallSaleModel> selectSalesAndGoodProbability(@Param("stallIdList") List<Long> stallIdList, @Param("dishesIds") List<Long> dishesIds);
}
