<?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="com.hzya.frame.plugin.lets.dao.impl.BusidataTocreturnsDetailDaoImpl">

    <resultMap id="get-BusidataTocreturnsDetailEntity-result" type="com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity" >
       <result property="baseUnitName" column="base_unit_name" jdbcType="VARCHAR"/>
           <result property="batchNo" column="batch_no" jdbcType="VARCHAR"/>
           <result property="brandName" column="brand_name" jdbcType="VARCHAR"/>
           <result property="brandNo" column="brand_no" jdbcType="VARCHAR"/>
           <result property="checkedCostPrice" column="checked_cost_price" jdbcType="VARCHAR"/>
           <result property="defect" column="defect" jdbcType="VARCHAR"/>
           <result property="expectNum" column="expect_num" jdbcType="VARCHAR"/>
           <result property="expireDate" column="expire_date" jdbcType="VARCHAR"/>
           <result property="goodsId" column="goods_id" jdbcType="VARCHAR"/>
           <result property="goodsName" column="goods_name" jdbcType="VARCHAR"/>
           <result property="goodsNo" column="goods_no" jdbcType="VARCHAR"/>
           <result property="goodsUnit" column="goods_unit" jdbcType="VARCHAR"/>
           <result property="logisticsId" column="logistics_id" jdbcType="VARCHAR"/>
           <result property="logisticsName" column="logistics_name" jdbcType="VARCHAR"/>
           <result property="logisticsNo" column="logistics_no" jdbcType="VARCHAR"/>
           <result property="num" column="num" jdbcType="VARCHAR"/>
           <result property="positionNo" column="position_no" jdbcType="VARCHAR"/>
           <result property="productionDate" column="production_date" jdbcType="VARCHAR"/>
           <result property="prop2" column="prop2" jdbcType="VARCHAR"/>
           <result property="recId" column="rec_id" jdbcType="VARCHAR"/>
           <result property="refundAmount" column="refund_amount" jdbcType="VARCHAR"/>
           <result property="refundDetailId" column="refund_detail_id" jdbcType="VARCHAR"/>
           <result property="refundNo" column="refund_no" jdbcType="VARCHAR"/>
           <result property="remark" column="remark" jdbcType="VARCHAR"/>
           <result property="rightNum" column="right_num" jdbcType="VARCHAR"/>
           <result property="specCode" column="spec_code" jdbcType="VARCHAR"/>
           <result property="specId" column="spec_id" jdbcType="VARCHAR"/>
           <result property="specName" column="spec_name" jdbcType="VARCHAR"/>
           <result property="specNo" column="spec_no" jdbcType="VARCHAR"/>
           <result property="srcOrderId" column="src_order_id" jdbcType="VARCHAR"/>
           <result property="stockinId" column="stockin_id" jdbcType="VARCHAR"/>
           <result property="stockinNum" column="stockin_num" jdbcType="VARCHAR"/>
           <result property="totalCost" column="total_cost" jdbcType="VARCHAR"/>
           <result property="warehouseId" column="warehouse_id" jdbcType="VARCHAR"/>
           <result property="id" column="id" jdbcType="INTEGER"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "BusidataTocreturnsDetailEntity_Base_Column_List">
        base_unit_name
       ,batch_no 
        ,brand_name 
        ,brand_no 
        ,checked_cost_price 
        ,defect 
        ,expect_num 
        ,expire_date 
        ,goods_id 
        ,goods_name 
        ,goods_no 
        ,goods_unit 
        ,logistics_id 
        ,logistics_name 
        ,logistics_no 
        ,num 
        ,position_no 
        ,production_date 
        ,prop2 
        ,rec_id 
        ,refund_amount 
        ,refund_detail_id 
        ,refund_no 
        ,remark 
        ,right_num 
        ,spec_code 
        ,spec_id 
        ,spec_name 
        ,spec_no 
        ,src_order_id 
        ,stockin_id 
        ,stockin_num 
        ,total_cost 
        ,warehouse_id 
        ,id 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-BusidataTocreturnsDetailEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity">
    select
    <include refid="BusidataTocreturnsDetailEntity_Base_Column_List" />
    from busidata_tocreturns_detail
    <trim prefix="where" prefixOverrides="and"> 
        <if test="baseUnitName != null and baseUnitName != ''"> and base_unit_name = #{baseUnitName} </if>
            <if test="batchNo != null and batchNo != ''"> and batch_no = #{batchNo} </if>
            <if test="brandName != null and brandName != ''"> and brand_name = #{brandName} </if>
            <if test="brandNo != null and brandNo != ''"> and brand_no = #{brandNo} </if>
            <if test="checkedCostPrice != null and checkedCostPrice != ''"> and checked_cost_price = #{checkedCostPrice} </if>
            <if test="defect != null and defect != ''"> and defect = #{defect} </if>
            <if test="expectNum != null and expectNum != ''"> and expect_num = #{expectNum} </if>
            <if test="expireDate != null and expireDate != ''"> and expire_date = #{expireDate} </if>
            <if test="goodsId != null and goodsId != ''"> and goods_id = #{goodsId} </if>
            <if test="goodsName != null and goodsName != ''"> and goods_name = #{goodsName} </if>
            <if test="goodsNo != null and goodsNo != ''"> and goods_no = #{goodsNo} </if>
            <if test="goodsUnit != null and goodsUnit != ''"> and goods_unit = #{goodsUnit} </if>
            <if test="logisticsId != null and logisticsId != ''"> and logistics_id = #{logisticsId} </if>
            <if test="logisticsName != null and logisticsName != ''"> and logistics_name = #{logisticsName} </if>
            <if test="logisticsNo != null and logisticsNo != ''"> and logistics_no = #{logisticsNo} </if>
            <if test="num != null and num != ''"> and num = #{num} </if>
            <if test="positionNo != null and positionNo != ''"> and position_no = #{positionNo} </if>
            <if test="productionDate != null and productionDate != ''"> and production_date = #{productionDate} </if>
            <if test="prop2 != null and prop2 != ''"> and prop2 = #{prop2} </if>
            <if test="recId != null and recId != ''"> and rec_id = #{recId} </if>
            <if test="refundAmount != null and refundAmount != ''"> and refund_amount = #{refundAmount} </if>
            <if test="refundDetailId != null and refundDetailId != ''"> and refund_detail_id = #{refundDetailId} </if>
            <if test="refundNo != null and refundNo != ''"> and refund_no = #{refundNo} </if>
            <if test="remark != null and remark != ''"> and remark = #{remark} </if>
            <if test="rightNum != null and rightNum != ''"> and right_num = #{rightNum} </if>
            <if test="specCode != null and specCode != ''"> and spec_code = #{specCode} </if>
            <if test="specId != null and specId != ''"> and spec_id = #{specId} </if>
            <if test="specName != null and specName != ''"> and spec_name = #{specName} </if>
            <if test="specNo != null and specNo != ''"> and spec_no = #{specNo} </if>
            <if test="srcOrderId != null and srcOrderId != ''"> and src_order_id = #{srcOrderId} </if>
            <if test="stockinId != null and stockinId != ''"> and stockin_id = #{stockinId} </if>
            <if test="stockinNum != null and stockinNum != ''"> and stockin_num = #{stockinNum} </if>
            <if test="totalCost != null and totalCost != ''"> and total_cost = #{totalCost} </if>
            <if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId} </if>
            <if test="id != null"> and id = #{id} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity">
        select  count(1)   from busidata_tocreturns_detail
    <trim prefix="where" prefixOverrides="and"> 
        <if test="baseUnitName != null and baseUnitName != ''"> and base_unit_name = #{baseUnitName} </if>
            <if test="batchNo != null and batchNo != ''"> and batch_no = #{batchNo} </if>
            <if test="brandName != null and brandName != ''"> and brand_name = #{brandName} </if>
            <if test="brandNo != null and brandNo != ''"> and brand_no = #{brandNo} </if>
            <if test="checkedCostPrice != null and checkedCostPrice != ''"> and checked_cost_price = #{checkedCostPrice} </if>
            <if test="defect != null and defect != ''"> and defect = #{defect} </if>
            <if test="expectNum != null and expectNum != ''"> and expect_num = #{expectNum} </if>
            <if test="expireDate != null and expireDate != ''"> and expire_date = #{expireDate} </if>
            <if test="goodsId != null and goodsId != ''"> and goods_id = #{goodsId} </if>
            <if test="goodsName != null and goodsName != ''"> and goods_name = #{goodsName} </if>
            <if test="goodsNo != null and goodsNo != ''"> and goods_no = #{goodsNo} </if>
            <if test="goodsUnit != null and goodsUnit != ''"> and goods_unit = #{goodsUnit} </if>
            <if test="logisticsId != null and logisticsId != ''"> and logistics_id = #{logisticsId} </if>
            <if test="logisticsName != null and logisticsName != ''"> and logistics_name = #{logisticsName} </if>
            <if test="logisticsNo != null and logisticsNo != ''"> and logistics_no = #{logisticsNo} </if>
            <if test="num != null and num != ''"> and num = #{num} </if>
            <if test="positionNo != null and positionNo != ''"> and position_no = #{positionNo} </if>
            <if test="productionDate != null and productionDate != ''"> and production_date = #{productionDate} </if>
            <if test="prop2 != null and prop2 != ''"> and prop2 = #{prop2} </if>
            <if test="recId != null and recId != ''"> and rec_id = #{recId} </if>
            <if test="refundAmount != null and refundAmount != ''"> and refund_amount = #{refundAmount} </if>
            <if test="refundDetailId != null and refundDetailId != ''"> and refund_detail_id = #{refundDetailId} </if>
            <if test="refundNo != null and refundNo != ''"> and refund_no = #{refundNo} </if>
            <if test="remark != null and remark != ''"> and remark = #{remark} </if>
            <if test="rightNum != null and rightNum != ''"> and right_num = #{rightNum} </if>
            <if test="specCode != null and specCode != ''"> and spec_code = #{specCode} </if>
            <if test="specId != null and specId != ''"> and spec_id = #{specId} </if>
            <if test="specName != null and specName != ''"> and spec_name = #{specName} </if>
            <if test="specNo != null and specNo != ''"> and spec_no = #{specNo} </if>
            <if test="srcOrderId != null and srcOrderId != ''"> and src_order_id = #{srcOrderId} </if>
            <if test="stockinId != null and stockinId != ''"> and stockin_id = #{stockinId} </if>
            <if test="stockinNum != null and stockinNum != ''"> and stockin_num = #{stockinNum} </if>
            <if test="totalCost != null and totalCost != ''"> and total_cost = #{totalCost} </if>
            <if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId} </if>
            <if test="id != null"> and id = #{id} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-BusidataTocreturnsDetailEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity">
    select
    <include refid="BusidataTocreturnsDetailEntity_Base_Column_List" />
    from busidata_tocreturns_detail
    <trim prefix="where" prefixOverrides="and"> 
        <if test="baseUnitName != null and baseUnitName != ''"> and base_unit_name like concat('%',#{baseUnitName},'%') </if>
            <if test="batchNo != null and batchNo != ''"> and batch_no like concat('%',#{batchNo},'%') </if>
            <if test="brandName != null and brandName != ''"> and brand_name like concat('%',#{brandName},'%') </if>
            <if test="brandNo != null and brandNo != ''"> and brand_no like concat('%',#{brandNo},'%') </if>
            <if test="checkedCostPrice != null and checkedCostPrice != ''"> and checked_cost_price like concat('%',#{checkedCostPrice},'%') </if>
            <if test="defect != null and defect != ''"> and defect like concat('%',#{defect},'%') </if>
            <if test="expectNum != null and expectNum != ''"> and expect_num like concat('%',#{expectNum},'%') </if>
            <if test="expireDate != null and expireDate != ''"> and expire_date like concat('%',#{expireDate},'%') </if>
            <if test="goodsId != null and goodsId != ''"> and goods_id like concat('%',#{goodsId},'%') </if>
            <if test="goodsName != null and goodsName != ''"> and goods_name like concat('%',#{goodsName},'%') </if>
            <if test="goodsNo != null and goodsNo != ''"> and goods_no like concat('%',#{goodsNo},'%') </if>
            <if test="goodsUnit != null and goodsUnit != ''"> and goods_unit like concat('%',#{goodsUnit},'%') </if>
            <if test="logisticsId != null and logisticsId != ''"> and logistics_id like concat('%',#{logisticsId},'%') </if>
            <if test="logisticsName != null and logisticsName != ''"> and logistics_name like concat('%',#{logisticsName},'%') </if>
            <if test="logisticsNo != null and logisticsNo != ''"> and logistics_no like concat('%',#{logisticsNo},'%') </if>
            <if test="num != null and num != ''"> and num like concat('%',#{num},'%') </if>
            <if test="positionNo != null and positionNo != ''"> and position_no like concat('%',#{positionNo},'%') </if>
            <if test="productionDate != null and productionDate != ''"> and production_date like concat('%',#{productionDate},'%') </if>
            <if test="prop2 != null and prop2 != ''"> and prop2 like concat('%',#{prop2},'%') </if>
            <if test="recId != null and recId != ''"> and rec_id like concat('%',#{recId},'%') </if>
            <if test="refundAmount != null and refundAmount != ''"> and refund_amount like concat('%',#{refundAmount},'%') </if>
            <if test="refundDetailId != null and refundDetailId != ''"> and refund_detail_id like concat('%',#{refundDetailId},'%') </if>
            <if test="refundNo != null and refundNo != ''"> and refund_no like concat('%',#{refundNo},'%') </if>
            <if test="remark != null and remark != ''"> and remark like concat('%',#{remark},'%') </if>
            <if test="rightNum != null and rightNum != ''"> and right_num like concat('%',#{rightNum},'%') </if>
            <if test="specCode != null and specCode != ''"> and spec_code like concat('%',#{specCode},'%') </if>
            <if test="specId != null and specId != ''"> and spec_id like concat('%',#{specId},'%') </if>
            <if test="specName != null and specName != ''"> and spec_name like concat('%',#{specName},'%') </if>
            <if test="specNo != null and specNo != ''"> and spec_no like concat('%',#{specNo},'%') </if>
            <if test="srcOrderId != null and srcOrderId != ''"> and src_order_id like concat('%',#{srcOrderId},'%') </if>
            <if test="stockinId != null and stockinId != ''"> and stockin_id like concat('%',#{stockinId},'%') </if>
            <if test="stockinNum != null and stockinNum != ''"> and stockin_num like concat('%',#{stockinNum},'%') </if>
            <if test="totalCost != null and totalCost != ''"> and total_cost like concat('%',#{totalCost},'%') </if>
            <if test="warehouseId != null and warehouseId != ''"> and warehouse_id like concat('%',#{warehouseId},'%') </if>
            <if test="id != null"> and id like concat('%',#{id},'%') </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="BusidataTocreturnsDetailentity_list_or" resultMap="get-BusidataTocreturnsDetailEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity">
    select
    <include refid="BusidataTocreturnsDetailEntity_Base_Column_List" />
    from busidata_tocreturns_detail
    <trim prefix="where" prefixOverrides="and"> 
         <if test="baseUnitName != null and baseUnitName != ''"> or base_unit_name = #{baseUnitName} </if>
             <if test="batchNo != null and batchNo != ''"> or batch_no = #{batchNo} </if>
             <if test="brandName != null and brandName != ''"> or brand_name = #{brandName} </if>
             <if test="brandNo != null and brandNo != ''"> or brand_no = #{brandNo} </if>
             <if test="checkedCostPrice != null and checkedCostPrice != ''"> or checked_cost_price = #{checkedCostPrice} </if>
             <if test="defect != null and defect != ''"> or defect = #{defect} </if>
             <if test="expectNum != null and expectNum != ''"> or expect_num = #{expectNum} </if>
             <if test="expireDate != null and expireDate != ''"> or expire_date = #{expireDate} </if>
             <if test="goodsId != null and goodsId != ''"> or goods_id = #{goodsId} </if>
             <if test="goodsName != null and goodsName != ''"> or goods_name = #{goodsName} </if>
             <if test="goodsNo != null and goodsNo != ''"> or goods_no = #{goodsNo} </if>
             <if test="goodsUnit != null and goodsUnit != ''"> or goods_unit = #{goodsUnit} </if>
             <if test="logisticsId != null and logisticsId != ''"> or logistics_id = #{logisticsId} </if>
             <if test="logisticsName != null and logisticsName != ''"> or logistics_name = #{logisticsName} </if>
             <if test="logisticsNo != null and logisticsNo != ''"> or logistics_no = #{logisticsNo} </if>
             <if test="num != null and num != ''"> or num = #{num} </if>
             <if test="positionNo != null and positionNo != ''"> or position_no = #{positionNo} </if>
             <if test="productionDate != null and productionDate != ''"> or production_date = #{productionDate} </if>
             <if test="prop2 != null and prop2 != ''"> or prop2 = #{prop2} </if>
             <if test="recId != null and recId != ''"> or rec_id = #{recId} </if>
             <if test="refundAmount != null and refundAmount != ''"> or refund_amount = #{refundAmount} </if>
             <if test="refundDetailId != null and refundDetailId != ''"> or refund_detail_id = #{refundDetailId} </if>
             <if test="refundNo != null and refundNo != ''"> or refund_no = #{refundNo} </if>
             <if test="remark != null and remark != ''"> or remark = #{remark} </if>
             <if test="rightNum != null and rightNum != ''"> or right_num = #{rightNum} </if>
             <if test="specCode != null and specCode != ''"> or spec_code = #{specCode} </if>
             <if test="specId != null and specId != ''"> or spec_id = #{specId} </if>
             <if test="specName != null and specName != ''"> or spec_name = #{specName} </if>
             <if test="specNo != null and specNo != ''"> or spec_no = #{specNo} </if>
             <if test="srcOrderId != null and srcOrderId != ''"> or src_order_id = #{srcOrderId} </if>
             <if test="stockinId != null and stockinId != ''"> or stockin_id = #{stockinId} </if>
             <if test="stockinNum != null and stockinNum != ''"> or stockin_num = #{stockinNum} </if>
             <if test="totalCost != null and totalCost != ''"> or total_cost = #{totalCost} </if>
             <if test="warehouseId != null and warehouseId != ''"> or warehouse_id = #{warehouseId} </if>
             <if test="id != null"> or id = #{id} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString()  "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity" keyProperty="id" useGeneratedKeys="true">
    insert into busidata_tocreturns_detail(
  <trim suffix="" suffixOverrides=",">
       <if test="baseUnitName != null and baseUnitName != ''"> base_unit_name , </if>
            <if test="batchNo != null and batchNo != ''"> batch_no , </if>
            <if test="brandName != null and brandName != ''"> brand_name , </if>
            <if test="brandNo != null and brandNo != ''"> brand_no , </if>
            <if test="checkedCostPrice != null and checkedCostPrice != ''"> checked_cost_price , </if>
            <if test="defect != null and defect != ''"> defect , </if>
            <if test="expectNum != null and expectNum != ''"> expect_num , </if>
            <if test="expireDate != null and expireDate != ''"> expire_date , </if>
            <if test="goodsId != null and goodsId != ''"> goods_id , </if>
            <if test="goodsName != null and goodsName != ''"> goods_name , </if>
            <if test="goodsNo != null and goodsNo != ''"> goods_no , </if>
            <if test="goodsUnit != null and goodsUnit != ''"> goods_unit , </if>
            <if test="logisticsId != null and logisticsId != ''"> logistics_id , </if>
            <if test="logisticsName != null and logisticsName != ''"> logistics_name , </if>
            <if test="logisticsNo != null and logisticsNo != ''"> logistics_no , </if>
            <if test="num != null and num != ''"> num , </if>
            <if test="positionNo != null and positionNo != ''"> position_no , </if>
            <if test="productionDate != null and productionDate != ''"> production_date , </if>
            <if test="prop2 != null and prop2 != ''"> prop2 , </if>
            <if test="recId != null and recId != ''"> rec_id , </if>
            <if test="refundAmount != null and refundAmount != ''"> refund_amount , </if>
            <if test="refundDetailId != null and refundDetailId != ''"> refund_detail_id , </if>
            <if test="refundNo != null and refundNo != ''"> refund_no , </if>
            <if test="remark != null and remark != ''"> remark , </if>
            <if test="rightNum != null and rightNum != ''"> right_num , </if>
            <if test="specCode != null and specCode != ''"> spec_code , </if>
            <if test="specId != null and specId != ''"> spec_id , </if>
            <if test="specName != null and specName != ''"> spec_name , </if>
            <if test="specNo != null and specNo != ''"> spec_no , </if>
            <if test="srcOrderId != null and srcOrderId != ''"> src_order_id , </if>
            <if test="stockinId != null and stockinId != ''"> stockin_id , </if>
            <if test="stockinNum != null and stockinNum != ''"> stockin_num , </if>
            <if test="totalCost != null and totalCost != ''"> total_cost , </if>
            <if test="warehouseId != null and warehouseId != ''"> warehouse_id , </if>
            <if test="id != null"> id , </if>
            <if test="sorts == null ">sorts,</if>
    <if test="sts == null ">sts,</if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="baseUnitName != null and baseUnitName != ''"> #{baseUnitName} ,</if>
            <if test="batchNo != null and batchNo != ''"> #{batchNo} ,</if>
            <if test="brandName != null and brandName != ''"> #{brandName} ,</if>
            <if test="brandNo != null and brandNo != ''"> #{brandNo} ,</if>
            <if test="checkedCostPrice != null and checkedCostPrice != ''"> #{checkedCostPrice} ,</if>
            <if test="defect != null and defect != ''"> #{defect} ,</if>
            <if test="expectNum != null and expectNum != ''"> #{expectNum} ,</if>
            <if test="expireDate != null and expireDate != ''"> #{expireDate} ,</if>
            <if test="goodsId != null and goodsId != ''"> #{goodsId} ,</if>
            <if test="goodsName != null and goodsName != ''"> #{goodsName} ,</if>
            <if test="goodsNo != null and goodsNo != ''"> #{goodsNo} ,</if>
            <if test="goodsUnit != null and goodsUnit != ''"> #{goodsUnit} ,</if>
            <if test="logisticsId != null and logisticsId != ''"> #{logisticsId} ,</if>
            <if test="logisticsName != null and logisticsName != ''"> #{logisticsName} ,</if>
            <if test="logisticsNo != null and logisticsNo != ''"> #{logisticsNo} ,</if>
            <if test="num != null and num != ''"> #{num} ,</if>
            <if test="positionNo != null and positionNo != ''"> #{positionNo} ,</if>
            <if test="productionDate != null and productionDate != ''"> #{productionDate} ,</if>
            <if test="prop2 != null and prop2 != ''"> #{prop2} ,</if>
            <if test="recId != null and recId != ''"> #{recId} ,</if>
            <if test="refundAmount != null and refundAmount != ''"> #{refundAmount} ,</if>
            <if test="refundDetailId != null and refundDetailId != ''"> #{refundDetailId} ,</if>
            <if test="refundNo != null and refundNo != ''"> #{refundNo} ,</if>
            <if test="remark != null and remark != ''"> #{remark} ,</if>
            <if test="rightNum != null and rightNum != ''"> #{rightNum} ,</if>
            <if test="specCode != null and specCode != ''"> #{specCode} ,</if>
            <if test="specId != null and specId != ''"> #{specId} ,</if>
            <if test="specName != null and specName != ''"> #{specName} ,</if>
            <if test="specNo != null and specNo != ''"> #{specNo} ,</if>
            <if test="srcOrderId != null and srcOrderId != ''"> #{srcOrderId} ,</if>
            <if test="stockinId != null and stockinId != ''"> #{stockinId} ,</if>
            <if test="stockinNum != null and stockinNum != ''"> #{stockinNum} ,</if>
            <if test="totalCost != null and totalCost != ''"> #{totalCost} ,</if>
            <if test="warehouseId != null and warehouseId != ''"> #{warehouseId} ,</if>
            <if test="id != null"> #{id} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from busidata_tocreturns_detail a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">
  insert IGNORE into busidata_tocreturns_detail(base_unit_name, batch_no, brand_name, brand_no, checked_cost_price, defect, expect_num, expire_date, goods_id, goods_name, goods_no, goods_unit, logistics_id, logistics_name, logistics_no, num, position_no, production_date, prop2, rec_id, refund_amount, refund_detail_id, refund_no, remark, right_num, spec_code, spec_id, spec_name, spec_no, src_order_id, stockin_id, stockin_num, total_cost, warehouse_id,price)
    values
    <foreach collection="list" item="entity" separator=",">
    (#{entity.baseUnitName},#{entity.batchNo},#{entity.brandName},#{entity.brandNo},#{entity.checkedCostPrice},#{entity.defect},#{entity.expectNum},#{entity.expireDate},#{entity.goodsId},#{entity.goodsName},#{entity.goodsNo},#{entity.goodsUnit},#{entity.logisticsId},#{entity.logisticsName},#{entity.logisticsNo},#{entity.num},#{entity.positionNo},#{entity.productionDate},#{entity.prop2},#{entity.recId},#{entity.refundAmount},#{entity.refundDetailId},#{entity.refundNo},#{entity.remark},#{entity.rightNum},#{entity.specCode},#{entity.specId},#{entity.specName},#{entity.specNo},#{entity.srcOrderId},#{entity.stockinId},#{entity.stockinNum},#{entity.totalCost},#{entity.warehouseId},#{entity.price})
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
    insert into busidata_tocreturns_detail(base_unit_name, batch_no, brand_name, brand_no, checked_cost_price, defect, expect_num, expire_date, goods_id, goods_name, goods_no, goods_unit, logistics_id, logistics_name, logistics_no, num, position_no, production_date, prop2, rec_id, refund_amount, refund_detail_id, refund_no, remark, right_num, spec_code, spec_id, spec_name, spec_no, src_order_id, stockin_id, stockin_num, total_cost, warehouse_id,price)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.baseUnitName},#{entity.batchNo},#{entity.brandName},#{entity.brandNo},#{entity.checkedCostPrice},#{entity.defect},#{entity.expectNum},#{entity.expireDate},#{entity.goodsId},#{entity.goodsName},#{entity.goodsNo},#{entity.goodsUnit},#{entity.logisticsId},#{entity.logisticsName},#{entity.logisticsNo},#{entity.num},#{entity.positionNo},#{entity.productionDate},#{entity.prop2},#{entity.recId},#{entity.refundAmount},#{entity.refundDetailId},#{entity.refundNo},#{entity.remark},#{entity.rightNum},#{entity.specCode},#{entity.specId},#{entity.specName},#{entity.specNo},#{entity.srcOrderId},#{entity.stockinId},#{entity.stockinNum},#{entity.totalCost},#{entity.warehouseId},#{entity.price})
    </foreach>
    on duplicate key update
    base_unit_name = values(base_unit_name),
    batch_no = values(batch_no),
    brand_name = values(brand_name),
    brand_no = values(brand_no),
    checked_cost_price = values(checked_cost_price),
    defect = values(defect),
    expect_num = values(expect_num),
    expire_date = values(expire_date),
    goods_id = values(goods_id),
    goods_name = values(goods_name),
    goods_no = values(goods_no),
    goods_unit = values(goods_unit),
    logistics_id = values(logistics_id),
    logistics_name = values(logistics_name),
    logistics_no = values(logistics_no),
    num = values(num),
    position_no = values(position_no),
    production_date = values(production_date),
    prop2 = values(prop2),
    rec_id = values(rec_id),
    refund_amount = values(refund_amount),
    refund_detail_id = values(refund_detail_id),
    refund_no = values(refund_no),
    remark = values(remark),
    right_num = values(right_num),
    spec_code = values(spec_code),
    spec_id = values(spec_id),
    spec_name = values(spec_name),
    spec_no = values(spec_no),
    src_order_id = values(src_order_id),
    stockin_id = values(stockin_id),
    stockin_num = values(stockin_num),
    total_cost = values(total_cost),
    warehouse_id = values(warehouse_id)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity" >
update busidata_tocreturns_detail  set
<trim suffix="" suffixOverrides=",">
  <if test="baseUnitName != null and baseUnitName != ''"> base_unit_name = #{baseUnitName},</if>
  <if test="batchNo != null and batchNo != ''"> batch_no = #{batchNo},</if>
  <if test="brandName != null and brandName != ''"> brand_name = #{brandName},</if>
  <if test="brandNo != null and brandNo != ''"> brand_no = #{brandNo},</if>
  <if test="checkedCostPrice != null and checkedCostPrice != ''"> checked_cost_price = #{checkedCostPrice},</if>
  <if test="defect != null and defect != ''"> defect = #{defect},</if>
  <if test="expectNum != null and expectNum != ''"> expect_num = #{expectNum},</if>
  <if test="expireDate != null and expireDate != ''"> expire_date = #{expireDate},</if>
  <if test="goodsId != null and goodsId != ''"> goods_id = #{goodsId},</if>
  <if test="goodsName != null and goodsName != ''"> goods_name = #{goodsName},</if>
  <if test="goodsNo != null and goodsNo != ''"> goods_no = #{goodsNo},</if>
  <if test="goodsUnit != null and goodsUnit != ''"> goods_unit = #{goodsUnit},</if>
  <if test="logisticsId != null and logisticsId != ''"> logistics_id = #{logisticsId},</if>
  <if test="logisticsName != null and logisticsName != ''"> logistics_name = #{logisticsName},</if>
  <if test="logisticsNo != null and logisticsNo != ''"> logistics_no = #{logisticsNo},</if>
  <if test="num != null and num != ''"> num = #{num},</if>
  <if test="positionNo != null and positionNo != ''"> position_no = #{positionNo},</if>
  <if test="productionDate != null and productionDate != ''"> production_date = #{productionDate},</if>
  <if test="prop2 != null and prop2 != ''"> prop2 = #{prop2},</if>
  <if test="recId != null and recId != ''"> rec_id = #{recId},</if>
  <if test="refundAmount != null and refundAmount != ''"> refund_amount = #{refundAmount},</if>
  <if test="refundDetailId != null and refundDetailId != ''"> refund_detail_id = #{refundDetailId},</if>
  <if test="refundNo != null and refundNo != ''"> refund_no = #{refundNo},</if>
  <if test="remark != null and remark != ''"> remark = #{remark},</if>
  <if test="rightNum != null and rightNum != ''"> right_num = #{rightNum},</if>
  <if test="specCode != null and specCode != ''"> spec_code = #{specCode},</if>
  <if test="specId != null and specId != ''"> spec_id = #{specId},</if>
  <if test="specName != null and specName != ''"> spec_name = #{specName},</if>
  <if test="specNo != null and specNo != ''"> spec_no = #{specNo},</if>
  <if test="srcOrderId != null and srcOrderId != ''"> src_order_id = #{srcOrderId},</if>
  <if test="stockinId != null and stockinId != ''"> stockin_id = #{stockinId},</if>
  <if test="stockinNum != null and stockinNum != ''"> stockin_num = #{stockinNum},</if>
  <if test="totalCost != null and totalCost != ''"> total_cost = #{totalCost},</if>
  <if test="warehouseId != null and warehouseId != ''"> warehouse_id = #{warehouseId},</if>
</trim>
where id = #{id}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity" >
update busidata_tocreturns_detail  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.BusidataTocreturnsDetailEntity" >
update busidata_tocreturns_detail  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="baseUnitName != null and baseUnitName != ''"> and base_unit_name = #{baseUnitName} </if>
            <if test="batchNo != null and batchNo != ''"> and batch_no = #{batchNo} </if>
            <if test="brandName != null and brandName != ''"> and brand_name = #{brandName} </if>
            <if test="brandNo != null and brandNo != ''"> and brand_no = #{brandNo} </if>
            <if test="checkedCostPrice != null and checkedCostPrice != ''"> and checked_cost_price = #{checkedCostPrice} </if>
            <if test="defect != null and defect != ''"> and defect = #{defect} </if>
            <if test="expectNum != null and expectNum != ''"> and expect_num = #{expectNum} </if>
            <if test="expireDate != null and expireDate != ''"> and expire_date = #{expireDate} </if>
            <if test="goodsId != null and goodsId != ''"> and goods_id = #{goodsId} </if>
            <if test="goodsName != null and goodsName != ''"> and goods_name = #{goodsName} </if>
            <if test="goodsNo != null and goodsNo != ''"> and goods_no = #{goodsNo} </if>
            <if test="goodsUnit != null and goodsUnit != ''"> and goods_unit = #{goodsUnit} </if>
            <if test="logisticsId != null and logisticsId != ''"> and logistics_id = #{logisticsId} </if>
            <if test="logisticsName != null and logisticsName != ''"> and logistics_name = #{logisticsName} </if>
            <if test="logisticsNo != null and logisticsNo != ''"> and logistics_no = #{logisticsNo} </if>
            <if test="num != null and num != ''"> and num = #{num} </if>
            <if test="positionNo != null and positionNo != ''"> and position_no = #{positionNo} </if>
            <if test="productionDate != null and productionDate != ''"> and production_date = #{productionDate} </if>
            <if test="prop2 != null and prop2 != ''"> and prop2 = #{prop2} </if>
            <if test="recId != null and recId != ''"> and rec_id = #{recId} </if>
            <if test="refundAmount != null and refundAmount != ''"> and refund_amount = #{refundAmount} </if>
            <if test="refundDetailId != null and refundDetailId != ''"> and refund_detail_id = #{refundDetailId} </if>
            <if test="refundNo != null and refundNo != ''"> and refund_no = #{refundNo} </if>
            <if test="remark != null and remark != ''"> and remark = #{remark} </if>
            <if test="rightNum != null and rightNum != ''"> and right_num = #{rightNum} </if>
            <if test="specCode != null and specCode != ''"> and spec_code = #{specCode} </if>
            <if test="specId != null and specId != ''"> and spec_id = #{specId} </if>
            <if test="specName != null and specName != ''"> and spec_name = #{specName} </if>
            <if test="specNo != null and specNo != ''"> and spec_no = #{specNo} </if>
            <if test="srcOrderId != null and srcOrderId != ''"> and src_order_id = #{srcOrderId} </if>
            <if test="stockinId != null and stockinId != ''"> and stockin_id = #{stockinId} </if>
            <if test="stockinNum != null and stockinNum != ''"> and stockin_num = #{stockinNum} </if>
            <if test="totalCost != null and totalCost != ''"> and total_cost = #{totalCost} </if>
            <if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId} </if>
            <if test="id != null"> and id = #{id} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from busidata_tocreturns_detail where id = #{id}
</delete>

</mapper>

