package org.jeecg.modules.system.app.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.jeecg.modules.app.dto.RefundsInfoDTO;
import org.jeecg.modules.system.app.entity.AppOrderProInfo;
import org.jeecg.modules.system.app.entity.AppOrderRefundsInfo;

@Mapper
public interface AppOrderRefundsInfoMapper extends BaseMapper<AppOrderRefundsInfo> {
    @Select("SELECT\n" +
            "\tori.id,\n" +
            "\to.amount as orderNum,\n" +
            "\to.price,\n" +
            "\tori.amount,\n" +
            "\topi.after_sale_status as refundStatus,\n" +
            "\tori.create_time,\n" +
            "\tori.accepted_time,\n" +
            "\tori.success_time\n" +
            "\t\n" +
            "FROM\n" +
            "\t`nm_order_refunds_info` ori\n" +
            "\tLEFT JOIN nm_order o ON o.id  = ori.order_id \n" +
            "\tLEFT JOIN nm_order_pro_info opi ON opi.id = ori.order_pro_info_id \n" +
            "WHERE \n" +
            "\tori.del_flag = 0 AND o.del_flag = 0 AND opi.del_flag = 0\n" +
            "\tAND ori.order_id = #{orderId} AND ori.order_pro_info_id = #{orderProInfoId}")
    RefundsInfoDTO getRefundsInfo(@Param("orderId") String orderId, @Param("orderProInfoId") String orderProInfoId);
}
