package org.ta.pddserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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 org.ta.pddserver.entity.LogOrderEntity;
import org.ta.pddserver.model.api.response.LogOrderListResponse;

import java.util.List;

@Mapper
public interface LogOrderMapper extends BaseMapper<LogOrderEntity> {
    @Update("UPDATE `log_order` SET `packageQuantity` = ${packageQuantity} WHERE `logisticsOrderCode` = #{logisticsOrderCode};")
    Boolean savePackageQuantity(@Param("logisticsOrderCode") String logisticsOrderCode, @Param("packageQuantity") long packageQuantity);

    @Select("SELECT * FROM `log_order` WHERE `logisticsOrderCode` = #{logisticsOrderCode};")
    LogOrderEntity selectByOrderCode(String logisticsOrderCode);

    @Update("UPDATE `log_order` SET `status` = #{status} WHERE `uid` = #{uid};")
    int updateOrderStatusById(int status, String uid);

    @Select("SELECT `uid`, `updated`, `logisticsOrderCode`, `bizType`, `buyerCode`, `consoType`, `dereRecogCode`, `packageQuantity`, `tags` FROM `log_order` WHERE  `logisticsOrderCode` = #{logisticsOrderCode}")
    List<LogOrderListResponse> getListByRequest(@Param("logisticsOrderCode") String logisticsOrderCode);
}
