<?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="org.springblade.modules.guosen.goodsRecord.mapper.GoodsRecordMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="goodsRecordResultMap" type="org.springblade.modules.guosen.goodsRecord.entity.GoodsRecord">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="user_id" property="userId"/>
        <result column="present_id" property="presentId"/>
        <result column="user_goods_ids" property="userGoodsIds"/>
        <result column="goods_name" property="goodsName"/>
        <result column="goods_pic" property="goodsPic"/>
        <result column="count" property="count"/>
        <result column="goods_post_amount" property="goodsPostAmount"/>
        <result column="distribution_id" property="distributionId"/>
        <result column="distribution_status" property="distributionStatus"/>
        <result column="done_time" property="doneTime"/>
        <result column="address_id" property="addressId"/>
    </resultMap>

    <select id="selectGoodsRecordPage" resultType="org.springblade.modules.guosen.goodsRecord.vo.GoodsRecordVO">
        select a.*,b.nick_name,b.phone,b.avatar
        from cyzh_goods_record as a
        left join cyzh_login_user as b on a.user_id = b.id
        where a.is_deleted = 0
        <if test="goodsRecord != null and goodsRecord != ''">
            <if test="goodsRecord.nickName != null and goodsRecord.nickName != ''">
                and b.nick_name like concat('%',#{goodsRecord.nickName},'%')
            </if>
            <if test="goodsRecord.phone != null and goodsRecord.phone != ''">
                and b.phone like concat('%',#{goodsRecord.phone},'%')
            </if>
            <if test="goodsRecord.distributionStatus != null">
                and a.distribution_status = #{goodsRecord.distributionStatus}
            </if>
        </if>
    </select>

</mapper>
