<?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="DTPMapper">
<!--处方登记 -->
    <select id="RecipeRegisterList" parameterType="pd" resultType="pd">
        select id, orderId, saleOrderNumber, genericName, productName, specification, quantity, manufacturer, mdmCode,
        posMemberName, posMemberPhone, prescriptionType, orderTime, prescriptionNumber, hospital, department,
        doctor, patientName, patientPhone, storeName, registrar, completionTime,lastUpdated, deliveryMethod, paymentCode,
        paymentMethod, status ,create_time as createTime  from s_dtp_cfdj_prescription
        <where>
            <if test="id != null">AND id = #{id}</if>
            <if test="orderId != null and orderId!=''">AND orderId = #{orderId}</if>
            <if test="saleOrderNumber != null and saleOrderNumber!=''">AND saleOrderNumber = #{saleOrderNumber}</if>
            <if test="genericName != null and genericName!=''">AND genericName = #{genericName}</if>
            <if test="productName != null and productName!=''">AND productName = #{productName}</if>
            <if test="specification != null and specification!=''">AND specification = #{specification}</if>
            <if test="quantity != null and quantity!=''">AND quantity = #{quantity}</if>
            <if test="manufacturer != null and manufacturer!=''">AND manufacturer = #{manufacturer}</if>
            <if test="mdmCode != null and mdmCode!=''">AND mdmCode = #{mdmCode}</if>
            <if test="posMemberName != null and posMemberName!=''">AND posMemberName = #{posMemberName}</if>
            <if test="posMemberPhone != null and posMemberPhone!=''">AND posMemberPhone = #{posMemberPhone}</if>
            <if test="prescriptionType != null and prescriptionType!=''">AND prescriptionType=#{prescriptionType}</if>
            <if test="beginTime != null and beginTime!='' and endTime != null and endTime!=''">
                and orderTime between #{beginTime} and #{endTime}
            </if>
            <if test="prescriptionNumber != null and prescriptionNumber!=''">AND prescriptionNumber = #{prescriptionNumber}</if>
            <if test="hospital != null and hospital!=''">AND hospital = #{hospital}</if>
            <if test="department != null and department!=''">AND department = #{department}</if>
            <if test="doctor != null and doctor!=''">AND doctor = #{doctor}</if>
            <if test="query != null and query != ''">
                AND (patientName LIKE CONCAT('%', #{query}, '%')
                OR patientPhone = #{query})
            </if>
            <if test="storeName != null and storeName!=''">AND storeName = #{storeName}</if>
            <if test="registrar != null and registrar!=''">AND registrar = #{registrar}</if>
            <if test="completionTime != null and completionTime!=''">AND completionTime = #{completionTime}</if>
            <if test="deliveryMethod != null and deliveryMethod!=''">AND deliveryMethod=#{deliveryMethod}</if>
            <if test="paymentCode != null and paymentCode!=''">AND paymentCode = #{paymentCode}</if>
            <if test="paymentMethod != null and paymentMethod!=''">AND paymentMethod = #{paymentMethod}</if>
            <if test="status != null  and status!=''">AND status = #{status}</if>
            <if test="createTime != null and createTime!=''">AND create_time = #{createTime}</if>
            and del_flag = '0'
        </where>
        order by create_time desc
    </select>

    <insert id="insertRecipe" parameterType="pd">
        insert into s_dtp_cfdj_prescription
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="orderId != null and orderId!=''">orderId,</if>
            <if test="saleOrderNumber != null and saleOrderNumber!=''">saleOrderNumber,</if>
            <if test="genericName != null and genericName!=''">genericName,</if>
            <if test="productName != null and productName!=''">productName,</if>
            <if test="specification != null and specification!=''">specification,</if>
            <if test="quantity != null and quantity!=''">quantity,</if>
            <if test="manufacturer != null and manufacturer!=''">manufacturer,</if>
            <if test="mdmCode != null and mdmCode!=''">mdmCode,</if>
            <if test="posMemberName != null and posMemberName!=''">posMemberName,</if>
            <if test="posMemberPhone != null and posMemberPhone!=''">posMemberPhone,</if>
            <if test="prescriptionType != null and prescriptionType!=''">prescriptionType,</if>
            <if test="orderTime != null and orderTime!=''">orderTime,</if>
            <if test="prescriptionNumber != null and prescriptionNumber!=''">prescriptionNumber,</if>
            <if test="hospital != null and hospital!=''">hospital,</if>
            <if test="department != null and department!=''">department,</if>
            <if test="doctor != null and doctor!=''">doctor,</if>
            <if test="patientName != null and patientName!=''">patientName,</if>
            <if test="patientPhone != null and patientPhone!=''">patientPhone,</if>
            <if test="storeName != null and storeName!=''">storeName,</if>
            <if test="registrar != null and registrar!=''">registrar,</if>
            <if test="completionTime != null and completionTime!=''">completionTime,</if>
            <if test="deliveryMethod != null and deliveryMethod!=''">deliveryMethod,</if>
            <if test="paymentCode != null and paymentCode!=''">paymentCode,</if>
            <if test="paymentMethod != null and paymentMethod!=''">paymentMethod,</if>
            <if test="status != null and status!=''">status},</if>
            <if test="lastUpdated != null and lastUpdated!=''">lastUpdated,</if>
            <if test="createTime != null and createTime!=''">create_time,</if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="orderId != null and orderId!=''">#{orderId},</if>
            <if test="saleOrderNumber != null and saleOrderNumber!=''">#{saleOrderNumber},</if>
            <if test="genericName != null and genericName!=''">#{genericName},</if>
            <if test="productName != null and productName!=''">#{productName},</if>
            <if test="specification != null and specification!=''">#{specification},</if>
            <if test="quantity != null and quantity!=''">#{quantity},</if>
            <if test="manufacturer != null and manufacturer!=''">#{manufacturer},</if>
            <if test="mdmCode != null and mdmCode!=''">#{mdmCode},</if>
            <if test="posMemberName != null and posMemberName!=''">#{posMemberName},</if>
            <if test="posMemberPhone != null and posMemberPhone!=''">#{posMemberPhone},</if>
            <if test="prescriptionType != null and prescriptionType!=''">#{prescriptionType},</if>
            <if test="orderTime != null and orderTime!=''">#{orderTime},</if>
            <if test="prescriptionNumber != null and prescriptionNumber!=''">#{prescriptionNumber},</if>
            <if test="hospital != null and hospital!=''">#{hospital},</if>
            <if test="department != null and department!=''">#{department},</if>
            <if test="doctor != null and doctor!=''">#{doctor},</if>
            <if test="patientName != null and patientName!=''">#{patientName},</if>
            <if test="patientPhone != null and patientPhone!=''">#{patientPhone},</if>
            <if test="storeName != null and storeName!=''">#{storeName},</if>
            <if test="registrar != null and registrar!=''">#{registrar},</if>
            <if test="completionTime != null and completionTime!=''">#{completionTime},</if>
            <if test="deliveryMethod != null and deliveryMethod!=''">#{deliveryMethod},</if>
            <if test="paymentCode != null and paymentCode!=''">#{paymentCode},</if>
            <if test="paymentMethod != null and paymentMethod!=''">#{paymentMethod},</if>
            <if test="status != null and status!=''">#{status},</if>
            <if test="lastUpdated != null and lastUpdated!=''">#{lastUpdated},</if>
            <if test="createTime != null and createTime!=''">#{createTime},</if>
        </trim>
    </insert>

    <delete id="deleteRecipe" parameterType="pd">
        <if test="ids != null and ids!=''">
            delete from s_dtp_cfdj_prescription
            where id in (${ids})
        </if>

    </delete>

    <update id="updateRecipe" parameterType="pd">
        update s_dtp_cfdj_prescription
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
            <if test="orderId != null and orderId!=''">orderId=#{orderId},</if>
            <if test="saleOrderNumber != null and saleOrderNumber!=''">saleOrderNumber=#{saleOrderNumber},</if>
            <if test="genericName != null and genericName!=''">genericName=#{genericName},</if>
            <if test="productName != null and productName!=''">productName=#{productName},</if>
            <if test="specification != null">specification=#{specification},</if>
            <if test="quantity != null">quantity=#{quantity},</if>
            <if test="manufacturer != null">manufacturer=#{manufacturer},</if>
            <if test="mdmCode != null">mdmCode=#{mdmCode},</if>
            <if test="posMemberName != null and posMemberName!=''">posMemberName=#{posMemberName},</if>
            <if test="posMemberPhone != null and posMemberPhone!=''">posMemberPhone=#{posMemberPhone},</if>
            <if test="prescriptionType != null and prescriptionType!=''">prescriptionType=#{prescriptionType},</if>
            <if test="orderTime != null">orderTime=#{orderTime},</if>
            <if test="prescriptionNumber != null and prescriptionNumber!=''">prescriptionNumber=#{prescriptionNumber},</if>
            <if test="hospital != null">hospital=#{hospital},</if>
            <if test="department != null">department=#{department},</if>
            <if test="doctor != null">doctor=#{doctor},</if>
            <if test="patientName != null and patientName!=''">patientName=#{patientName},</if>
            <if test="patientPhone != null and patientPhone!=''">patientPhone=#{patientPhone},</if>
            <if test="storeName != null">storeName=#{storeName},</if>
            <if test="registrar != null">registrar=#{registrar},</if>
            <if test="completionTime != null and completionTime!=''">completionTime=#{completionTime},</if>
            <if test="deliveryMethod != null and deliveryMethod!=''">deliveryMethod=#{deliveryMethod},</if>
            <if test="paymentCode != null and paymentCode!=''">paymentCode=#{paymentCode},</if>
            <if test="paymentMethod != null and paymentMethod!=''">paymentMethod=#{paymentMethod},</if>
            <if test="status != null and status!=''">status=#{status},</if>
            <if test="lastUpdated != null and lastUpdated!=''">lastUpdated=#{lastUpdated},</if>
            <if test="createTime != null and createTime!=''">create_time=#{createTime},</if>
        </trim>
        where id=#{id}
    </update>
    <select id="checkPatientNameAndPhoneUnique" parameterType="pd" resultType="pd">
        select patientName, patientPhone from s_dtp_cfdj_prescription where patientName=#{patientName} and patientPhone=#{patientPhone} and del_flag = '0' limit 1
    </select>
    <select id="selectOne" parameterType="pd" resultType="pd">
        select id, orderId, saleOrderNumber, genericName, productName, specification, quantity, manufacturer, mdmCode,
        posMemberName, posMemberPhone, prescriptionType, orderTime, prescriptionNumber, hospital, department,
        doctor, patientName, patientPhone, storeName, registrar, completionTime, lastUpdated,deliveryMethod, paymentCode,
        paymentMethod, status ,create_time as createTime  from s_dtp_cfdj_prescription where id=#{id}
    </select>


    <!--冷链配送管理 -->
    <select id="DistributionOrderList" parameterType="pd" resultType="pd">
        select id, orderNumber, chainName, storeName, deliveryStatus, coldChainType,orderSource,recipientName,
               recipientPhone,recipientAddress,departureTemperature,arrivalTemperature,signaturePhoto,isOnlineSignature,
               deliveryBoxNumber,icePackNumber,deliveryPerson, expectedDeliveryTime, actualDeliveryTime, creationTime, updatedTime,
               createdBy, createdDate
        from s_dtp_llps_distribution_order
        <where>
            <if test="id != null">AND id = #{id}</if>
            <if test="orderNumber != null and orderNumber!=''">AND orderNumber = #{orderNumber}</if>
            <if test="chainName != null and chainName!=''">AND chainName = #{chainName}</if>
            <if test="storeName != null and storeName!=''">AND storeName = #{storeName}</if>
            <if test="deliveryStatus != null and deliveryStatus!=''">AND deliveryStatus = #{deliveryStatus}</if>
            <if test="recipientName != null and recipientName!=''">AND recipientName = #{recipientName}</if>
            <if test="recipientPhone != null and recipientPhone!=''">AND recipientPhone = #{recipientPhone}</if>
            <if test="recipientAddress != null and recipientAddress!=''">AND recipientAddress = #{recipientAddress}</if>
            <if test="deliveryPerson != null and deliveryPerson!=''">AND deliveryPerson = #{deliveryPerson}</if>
            <if test="expectedDeliveryTime != null and expectedDeliveryTime!=''">AND expectedDeliveryTime = #{expectedDeliveryTime}</if>
            <if test="actualDeliveryTimeStart != null and actualDeliveryTimeStart!='' and actualDeliveryTimeEnd != null and actualDeliveryTimeEnd!=''">
                and actualDeliveryTime between #{actualDeliveryTimeStart} and #{actualDeliveryTimeEnd}
            </if>
            <if test="creationTimeStart != null and creationTimeStart!='' and  creationTimeEnd != null and creationTimeEnd!=''">
                and creationTime between #{creationTimeStart} and #{creationTimeEnd}
            </if>
            <if test="updatedTime != null and updatedTime!=''">AND updatedTime = #{updatedTime}</if>
            <if test="createdBy != null and createdBy!=''">AND createdBy = #{createdBy}</if>
            <if test="createdDate != null and createdDate!=''">AND createdDate = #{createdDate}</if>
            <if test="query != null and query!=''">
                AND recipientName LIKE CONCAT('%', #{query}, '%') or recipientPhone = #{query}
            </if>
             and del_flag= '0'
        </where>
        order by create_time desc
    </select>

    <insert id="insertDistributionOrder" parameterType="pd">
        insert into s_dtp_llps_distribution_order
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="orderNumber != null and orderNumber!=''">orderNumber,</if>
            <if test="chainName != null and chainName!=''">chainName,</if>
            <if test="storeName != null and storeName!=''">storeName,</if>
            <if test="deliveryStatus != null and deliveryStatus!=''">deliveryStatus,</if>
            <if test="recipientName != null and recipientName!=''">recipientName,</if>
            <if test="recipientPhone != null and recipientPhone!=''">recipientPhone,</if>
            <if test="recipientAddress != null and recipientAddress!=''">recipientAddress,</if>
            <if test="deliveryPerson != null and deliveryPerson!=''">deliveryPerson,</if>
            <if test="expectedDeliveryTime != null and expectedDeliveryTime!=''">expectedDeliveryTime,</if>
            <if test="actualDeliveryTime != null and actualDeliveryTime!=''">actualDeliveryTime,</if>
            <if test="createdBy != null and createdBy!=''">createdBy,</if>
            <if test="createdDate != null and createdDate!=''">createdDate,</if>
            <if test="creationTime != null and creationTime!=''">creationTime,</if>
            <if test="updatedTime != null and updatedTime!=''">updatedTime,</if>
            <if test="createTime != null and createTime!=''">create_time,</if>
            <if test="coldChainType != null and coldChainType != ''">coldChainType ,</if>
            <if test="orderSource != null and orderSource != ''">orderSource,</if>
            <if test="departureTemperature != null">departureTemperature,</if>
            <if test="arrivalTemperature != null">arrivalTemperature,</if>
            <if test="signaturePhoto != null and signaturePhoto != ''">signaturePhoto,</if>
            <if test="isOnlineSignature != null">isOnlineSignature ,</if>
            <if test="deliveryBoxNumber != null and deliveryBoxNumber != ''">deliveryBoxNumber ,</if>
            <if test="icePackNumber != null and icePackNumber != ''">icePackNumber,</if>
            <if test="paymentSequence != null">paymentSequence,</if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="orderNumber != null and orderNumber!=''">#{orderNumber},</if>
            <if test="chainName != null and chainName!=''">#{chainName},</if>
            <if test="storeName != null and storeName!=''">#{storeName},</if>
            <if test="deliveryStatus != null and deliveryStatus!=''">#{deliveryStatus},</if>
            <if test="recipientName != null and recipientName!=''">#{recipientName},</if>
            <if test="recipientPhone != null and recipientPhone!=''">#{recipientPhone},</if>
            <if test="recipientAddress != null and recipientAddress!=''">#{recipientAddress},</if>
            <if test="deliveryPerson != null and deliveryPerson!=''">#{deliveryPerson},</if>
            <if test="expectedDeliveryTime != null and expectedDeliveryTime!=''">#{expectedDeliveryTime},</if>
            <if test="actualDeliveryTime != null and actualDeliveryTime!=''">#{actualDeliveryTime},</if>
            <if test="createdBy != null and createdBy!=''">#{createdBy},</if>
            <if test="createdDate != null and createdDate!=''">#{createdDate},</if>
            <if test="creationTime != null and creationTime!=''">#{creationTime},</if>
            <if test="updatedTime != null and updatedTime!=''">#{updatedTime},</if>
            <if test="createTime != null and createTime!=''">#{createTime},</if>
            <if test="coldChainType != null and coldChainType != ''">#{coldChainType} ,</if>
            <if test="orderSource != null and orderSource != ''">#{orderSource},</if>
            <if test="departureTemperature != null">#{departureTemperature},</if>
            <if test="arrivalTemperature != null">#{arrivalTemperature},</if>
            <if test="signaturePhoto != null and signaturePhoto != ''">#{signaturePhoto},</if>
            <if test="isOnlineSignature != null">#{isOnlineSignature} ,</if>
            <if test="deliveryBoxNumber != null and deliveryBoxNumber != ''">#{deliveryBoxNumber} ,</if>
            <if test="icePackNumber != null and icePackNumber != ''">#{icePackNumber},</if>
            <if test="paymentSequence != null">#{paymentSequence},</if>
        </trim>
    </insert>

    <update id="updateDistributionOrder" parameterType="pd">
        update s_dtp_llps_distribution_order
        <set>
            <if test="orderNumber != null and orderNumber != ''">orderNumber = #{orderNumber},</if>
            <if test="chainName != null and chainName != ''">chainName = #{chainName},</if>
            <if test="storeName != null and storeName != ''">storeName = #{storeName},</if>
            <if test="deliveryStatus != null">deliveryStatus = #{deliveryStatus},</if>
            <if test="recipientName != null and recipientName != ''">recipientName = #{recipientName},</if>
            <if test="recipientPhone != null and recipientPhone != ''">recipientPhone = #{recipientPhone},</if>
            <if test="recipientAddress != null and recipientAddress != ''">recipientAddress = #{recipientAddress},</if>
            <if test="deliveryPerson != null and deliveryPerson != ''">deliveryPerson = #{deliveryPerson},</if>
            <if test="expectedDeliveryTime != null">expectedDeliveryTime = #{expectedDeliveryTime},</if>
            <if test="actualDeliveryTime != null">actualDeliveryTime = #{actualDeliveryTime},</if>
            <if test="createdBy != null and createdBy != ''">createdBy = #{createdBy},</if>
            <if test="createdDate != null">createdDate = #{createdDate},</if>
            <if test="creationTime != null">creationTime = #{creationTime},</if>
            <if test="updatedTime != null">updatedTime = #{updatedTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="coldChainType != null and coldChainType != ''">coldChainType = #{coldChainType},</if>
            <if test="orderSource != null and orderSource != ''">orderSource = #{orderSource},</if>
            <if test="departureTemperature != null">departureTemperature = #{departureTemperature},</if>
            <if test="arrivalTemperature != null">arrivalTemperature = #{arrivalTemperature},</if>
            <if test="signaturePhoto != null and signaturePhoto != ''">signaturePhoto = #{signaturePhoto},</if>
            <if test="isOnlineSignature != null">isOnlineSignature = #{isOnlineSignature},</if>
            <if test="deliveryBoxNumber != null and deliveryBoxNumber != ''">deliveryBoxNumber = #{deliveryBoxNumber},</if>
            <if test="icePackNumber != null and icePackNumber != ''">icePackNumber = #{icePackNumber},</if>
            <if test="paymentSequence != null">paymentSequence = #{paymentSequence},</if>
        </set>
        where id = #{id}
    </update>



    <update id="softDeleteColdOrder" parameterType="pd">
            update s_dtp_llps_distribution_order
            set del_flag = 1
            where  where
            <if test="ids != null and ids!=''">
                id in(${ids})
            </if>
    </update>
<!--配送单据打印模块-->
    <select id="listPrintEntity" parameterType="pd" resultType="com.bzd.common.core.domain.entity.DtpDeliveryPrint">
        select id,
        businessId,
        orderId,
        storeId,
        status,
        deliverer,
        deliveryTime,
        printRequestTime,
        createdBy,
        orderData,
        del_flag as delFlag,
        gmtCreate,
        updateBy updatedTime,
        create_time as createTime
        from s_dtp_llps_distribution_print
        <where>
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="businessId != null and businessId != ''">and businessId = #{businessId}</if>
            <if test="orderId != null and orderId != ''">and orderId = #{orderId}</if>
            <if test="storeId != null and storeId != ''">and storeId = #{storeId}</if>
            <if test="status != null  and status != ''">and status = #{status}</if>
            <if test="deliverer != null and deliverer != ''">and deliverer = #{deliverer}</if>
            <if test="deliveryTimeStart != null and deliveryTimeStart!='' and deliveryTimeEnd != null and deliveryTimeEnd!=''">
                and deliveryTime between #{deliveryTimeStart} and #{deliveryTimeEnd}
            </if>
            <if test="printRequestTimeStart != null and printRequestTimeStart!='' and  printRequestTimeEnd != null and printRequestTimeEnd!=''">
                and printRequestTime between #{printRequestTimeStart} and #{printRequestTimeEnd}
            </if>
            <if test="createdBy != null and createdBy != ''">and createdBy = #{createdBy}</if>
            <if test="createBy != null and createBy != ''">and createBy = #{createBy}</if>
            <if test="updateBy != null and updateBy != ''">and updateBy = #{updateBy}</if>
            and del_flag = '0'
        </where>
        order by create_time desc
    </select>
    <select id="listPrintPd" parameterType="pd" resultType="pd">
        select id,
        businessId,
        orderId,
        storeId,
        status,
        deliverer,
        deliveryTime,
        printRequestTime,
        createdBy,
        orderData,
        del_flag as delFlag,
        gmtCreate,
        updateBy updatedTime,
        create_time as createTime
        from s_dtp_llps_distribution_print
        <where>
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="businessId != null and businessId != ''">and businessId = #{businessId}</if>
            <if test="orderId != null and orderId != ''">and orderId = #{orderId}</if>
            <if test="storeId != null and storeId != ''">and storeId = #{storeId}</if>
            <if test="status != null  and status != ''">and status = #{status}</if>
            <if test="deliverer != null and deliverer != ''">and deliverer = #{deliverer}</if>
            <if test="deliveryTimeStart != null and deliveryTimeStart!='' and deliveryTimeEnd != null and deliveryTimeEnd!=''">
                and deliveryTime between #{deliveryTimeStart} and #{deliveryTimeEnd}
            </if>
            <if test="printRequestTimeStart != null and printRequestTimeStart!='' and  printRequestTimeEnd != null and printRequestTimeEnd!=''">
                and printRequestTime between #{printRequestTimeStart} and #{printRequestTimeEnd}
            </if>
            <if test="createdBy != null and createdBy != ''">and createdBy = #{createdBy}</if>
            <if test="createBy != null and createBy != ''">and createBy = #{createBy}</if>
            <if test="updateBy != null and updateBy != ''">and updateBy = #{updateBy}</if>
            and del_flag = '0'
        </where>
        order by create_time desc
    </select>

    <insert id="savePrint" parameterType="pd">
        insert into s_dtp_llps_distribution_print
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="createdBy != null and createdBy != ''">createdBy,</if>
            <if test="createTime != null and createTime != ''">create_time,</if>
            <if test="businessId != null and businessId != ''">businessId,</if>
            <if test="deliveryTime != null and deliveryTime != ''">deliveryTime,</if>
            <if test="printRequestTime != null and printRequestTime != ''">printRequestTime,</if>
            <if test="deliverer != null and deliverer != ''">deliverer,</if>
            <if test="createBy != null and createBy != ''">createBy,</if>
            <if test="extend != null and extend != ''">extend,</if>
            <if test="gmtCreate != null and gmtCreate != ''">gmtCreate,</if>
            <if test="gmtUpdate != null and gmtUpdate != ''">gmtUpdate,</if>
            <if test="orderId != null and orderId != ''">orderId,</if>
            <if test="orderData != null and orderData != ''">orderData,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="storeId != null and storeId != ''">storeId,</if>
            <if test="updateBy != null and updateBy != ''">updateBy,</if>
            <if test="version != null and version != ''">version,</if>
        </trim>
        <trim prefix="VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="createdBy != null and createdBy != ''">#{createdBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="businessId != null">#{businessId},</if>
            <if test="deliveryTime != null">#{deliveryTime},</if>
            <if test="printRequestTime != null">#{printRequestTime},</if>
            <if test="deliverer != null and deliverer != ''">#{deliverer},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="extend != null">#{extend},</if>
            <if test="gmtCreate != null">#{gmtCreate},</if>
            <if test="gmtUpdate != null">#{gmtUpdate},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="orderData != null">#{orderData},</if>
            <if test="status != null">#{status},</if>
            <if test="storeId != null">#{storeId},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="version != null">#{version},</if>
        </trim>
    </insert>

    <update id="editPrint" parameterType="pd">
        update s_dtp_llps_distribution_print
        <set>
            <if test="createdBy != null and createdBy != ''">createdBy = #{createdBy},</if>
            <if test="createTime != null  and createTime != ''">create_time = #{createTime},</if>
            <if test="businessId != null  and businessId != ''">businessId = #{businessId},</if>
            <if test="deliveryTime != null  and deliveryTime != ''">deliveryTime = #{deliveryTime},</if>
            <if test="printRequestTime != null  and printRequestTime != ''">printRequestTime = #{printRequestTime},</if>
            <if test="deliverer != null and deliverer != ''">deliverer = #{deliverer},</if>
            <if test="createBy != null and createBy != ''">createBy = #{createBy},</if>
            <if test="extend != null  and extend != ''">extend = #{extend},</if>
            <if test="gmtCreate != null  and gmtCreate != ''">gmtCreate = #{gmtCreate},</if>
            <if test="gmtUpdate != null  and gmtUpdate != ''">gmtUpdate = #{gmtUpdate},</if>
            <if test="orderId != null  and orderId != ''">orderId = #{orderId},</if>
            <if test="orderData != null  and orderData != ''">orderData = #{orderData},</if>
            <if test="status != null  and status != ''">status = #{status},</if>
            <if test="storeId != null  and storeId != ''">storeId = #{storeId},</if>
            <if test="updateBy != null and updateBy != ''">updateBy = #{updateBy},</if>
            <if test="version != null  and version != ''">version = #{version},</if>
        </set>
        where id = #{id}
    </update>

    <!--配送单据打印模块 软删除-->
    <update id="DelPrint" parameterType="pd">
            update s_dtp_llps_distribution_print
            set del_flag = 1
            where
            <if test="ids != null and ids!=''">
                id in(${ids})
            </if>
    </update>

    <!--配置信息查询模块-->
    <select id="StoreProductList" parameterType="pd" resultType="pd">
        select
        id,
        createdBy,
        createdDate,
        storeId,
        storeCode,
        storeName,
        mdmCode,
        genericName,
        productName,
        manufacturer,
        specification,
        isPrescriptionItem,
        isFlipItem,
        isFollowUpItem,
        isMandatoryRegistration,
        isColdChainItem,
        create_time as createTime,
        updatedAt
        from s_dtp_pzxx_store_product_list
        <where>
            <if test="id != null">AND id = #{id}</if>
            <if test="createdBy != null and createdBy != ''">AND createdBy = #{createdBy}</if>
            <if test="createdDate != null and createdDate != ''">AND createdDate = #{createdDate}</if>
            <if test="storeId != null">AND storeId = #{storeId}</if>
            <if test="storeCode != null and storeCode != ''">AND storeCode = #{storeCode}</if>
            <if test="storeName != null and storeName != ''">AND storeName = #{storeName}</if>
            <if test="mdmCode != null and mdmCode != ''">AND mdmCode = #{mdmCode}</if>
            <if test="genericName != null and genericName != ''">AND genericName = #{genericName}</if>
            <if test="productName != null and productName != ''">AND productName = #{productName}</if>
            <if test="manufacturer != null and manufacturer != ''">AND manufacturer = #{manufacturer}</if>
            <if test="specification != null and specification != ''">AND specification = #{specification}</if>
            <if test="isPrescriptionItem != null">AND isPrescriptionItem = #{isPrescriptionItem}</if>
            <if test="isFlipItem != null">AND isFlipItem = #{isFlipItem}</if>
            <if test="isFollowUpItem != null">AND isFollowUpItem = #{isFollowUpItem}</if>
            <if test="isMandatoryRegistration != null">AND isMandatoryRegistration = #{isMandatoryRegistration}</if>
            <if test="isColdChainItem != null">AND isColdChainItem = #{isColdChainItem}</if>
            <if test="create_time_start != null and create_time_start != '' and create_time_end != null and create_time_end != ''">
                AND create_time BETWEEN #{create_time_start} AND #{create_time_end}
            </if>
            <if test="updatedAt_start != null and updatedAt_start != '' and updatedAt_end != null and updatedAt_end != ''">
                AND updatedAt BETWEEN #{updatedAt_start} AND #{updatedAt_end}
            </if>
            <if test="query != null and query != ''">
                AND (genericName LIKE CONCAT('%', #{query}, '%') OR productName LIKE CONCAT('%', #{query}, '%'))
            </if>
            AND del_flag = '0'
        </where>
        order by create_time desc
    </select>
    <select id="HospitalList" parameterType="pd" resultType="pd">
        select
        id,
        createdBy,
        standardName,
        address,
        phone,
        create_time as createTime,
        updated_time as updatedTime
        from s_dtp_pzxx_hospital_list
        <where>
            <if test="id != null and id != ''">AND id = #{id}</if>
            <if test="createdBy != null and createdBy != ''">AND createdBy = #{createdBy}</if>
            <if test="standardName != null and standardName != ''">AND standardName  LIKE CONCAT('%', #{standardName}, '%')) </if>
            <if test="address != null and address != ''">AND address = #{address}</if>
            <if test="phone != null and phone != ''">AND phone = #{phone}</if>
            <if test="create_time_start != null and create_time_start != '' and create_time_end != null and create_time_end != ''">
                AND create_time BETWEEN #{create_time_start} AND #{create_time_end}
            </if>
            <if test="updated_time_start != null and updated_time_start != '' and updated_time_end != null and updated_time_end != ''">
                AND updated_time BETWEEN #{updated_time_start} AND #{updated_time_end}
            </if>
            <if test="query != null and query != ''">
                AND (standardName LIKE CONCAT('%', #{query}, '%') OR address LIKE CONCAT('%', #{query}, '%'))
            </if>
            AND del_flag = '0'
        </where>
        order by create_time desc
    </select>

</mapper>
