package org.ta.pddserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.ta.pdd.entity.CollectOrderDetailEntity;
import org.ta.pddserver.model.api.response.CollectOrderDetailResponse;

import java.util.List;

@Mapper
public interface CollectOrderDetailMapper extends BaseMapper<CollectOrderDetailEntity> {

    @Select("SELECT `uid`, `orderCode`, `orderSn`, `logisticsOrderCode`, `itemId`, `itemName`, `categoryName`, `itemQuantity`, `weightTotal`, `actualAmount`, `productName`, `exportDecAmount` FROM `collect_order_detail` WHERE `orderCode` = #{orderCode} AND `itemQuantity` > 0; ")
    List<CollectOrderDetailResponse> getListByOrderCode(String orderCode);

    @Delete("DELETE FROM `collect_order_detail` WHERE `orderCode` = #{orderCode}")
    Integer deleteByOrderCode(@Param("orderCode") String orderCode);
}
