<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="jnpf.personnels.mapper.FtbPersonnelsGoodsReceiveMapper">

    <select id="listPages" resultType="jnpf.model.personnels.vo.goods.FtbPersonnelsGoodsReceivePageVO">
        SELECT
            b.F_Id AS id,
            b.F_UserName AS userName,
            b.F_OrgName AS orgName,
            a.F_GoodsName AS goodsName,
            b.F_ReceiptTime AS receiptTime,
            b.F_Remark AS remark,
            b.F_OperatorName AS operatorName,
            b.F_QuantityUse AS quantityUse,
            b.F_ReturnStatus AS returnStatus,
            b.F_ReturnTime AS returnTime,
            a.F_NeedReturn AS needReturn,
            a.F_EnableMark AS isDeletedGoods
        FROM ftb_personnels_goods_receive b left JOIN ftb_personnels_goods a ON a.F_Id = b.F_GoodsId
        WHERE b.F_EnableMark = 0
        <if test="params.goodsName != null and params.goodsName != ''">
            AND (a.F_GoodsName LIKE CONCAT('%',#{params.goodsName},'%') or b.F_UserName LIKE CONCAT('%',#{params.goodsName},'%'))
        </if>
        <if test="params.returnStatus != null">
            AND b.F_ReturnStatus = #{params.returnStatus}
        </if>
        <if test="params.needReturn != null">
            AND a.F_NeedReturn = #{params.needReturn}
        </if>
        order by b.F_ReceiptTime desc,b.F_Id desc
    </select>
</mapper>