package com.fzm.mall.server.front.order.mapper;

import com.fzm.mall.server.front.order.model.DeliveryRefund;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.mall.server.front.order.model.vo.ExpressVo;
import com.fzm.mall.server.front.order.model.vo.ReturnGoodsDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 提货退货单表 Mapper 接口
 * </p>
 *
 * @author fzm
 * @since 2021-04-26
 */
public interface DeliveryRefundMapper extends BaseMapper<DeliveryRefund> {
    @Select("select * from distribution_express where exp_name like #{searchKey}")
    List<ExpressVo> getExpress(@Param("searchKey") String searchKey);

    @Select("select a.*,b.number as number,b.sku_id as skuId from order_delivery_refund a left join order_delivery b on a.order_delivery_id = b.order_delivery_id where a.order_delivery_id = #{orderDeliveryId}")
    ReturnGoodsDetail getDetail(@Param("orderDeliveryId") String orderDeliveryId);

    @Update("update order_delivery_refund set state = 7 where order_delivery_id = #{orderDeliveryId} and state = 1")
    void revokeReturn(String orderDeliveryId);
}
