FlowOrderMapper.xml 11.9 KB
Newer Older
苗卫卫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
<?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.boco.nbd.wios.flow.mapper.def.FlowOrderMapper">

    <sql id="Base_Column_List">
        id
        ,process_ins_id,node_flag,
        oem_id,oem_name,oem_agent_id,
        oem_agent_name,oem_agent_code,oem_agent_info,
        oem_agent_contact_name,oem_agent_contact_phone,out_order_id,
        contract_id,supplier_contract_id,user_name,
        user_phone,user_sex,contact_name,
        contact_phone,region_id,city_name,
        city_id,region_name,region_level,
        province_name,province_id,area_name,
        area_id,country_name,country_id,
        warehouse_id,address,refuse_order_reason,
        is_pick_car,vehicle_model,vehicle_chassis_no,
        vehicle_vin,vehicle_parking_no,vehicle_parking_status,
        survey_before_sale_enable,manu_dispatch_enable,wallbox_model,
        pack_type,status,type,
        expand_status,expand_fail_reason,expand_fail_operate,
        expand_remark,survey_staff_id,survey_check_fail_num,
        survey_staff_phone,survey_staff_name,survey_finish_time,
        survey_reserve_time,survey_client_name,survey_client_phone,
        survey_cams_phone,survey_reserve_remark,install_supplier_id,
        install_supplier_name,install_staff_id,install_check_fail_num,
        install_staff_phone,install_staff_name,install_finish_time,
        install_reserve_time,install_client_name,install_client_phone,
        install_cams_phone,install_reserve_remark,survey_finish_fail_reason,
        survey_rectify_fail_reason,install_change_fail_reason,install_finish_fail_reason,
        install_rectify_fail_reason,close_order_reason,install_change_attachment_files,
        survey_reserve_fail_info,install_reserve_fail_info,files,
        description,score,visit_content,
        invoice_time,estate_type,has_independent_parking,
        install_position,property_agree,electric_expand,
        need_erect_pile,dispatch_time,survey_submit_examine_time,
        survey_approve_time,install_submit_examine_time,install_approve_time,
        return_visit_time,close_time,create_account,
        create_account_name,create_time,modify_account,
        modify_time,item_model,survey_wallbox_model,
        survey_pack_type,survey_item_model,install_wallbox_model,
        install_pack_type,install_item_model,address_lat,
        address_lng,survey_follow_time,install_follow_time,
        connect_person,connect_person_name,want_home_time,
        install_emergency_level,remark,is_connect,
        is_need_survey,shipno
    </sql>

    <select id="getOrderData" resultType="com.boco.nbd.wios.flow.entity.bo.OrderBO">
        select a.id,
        case a.expand_status
        when 1 then '通过'
        when 2 then '不通过'
        else '' end expand_status,
        b.name oem_name,
        b.code oem_code,
        c.name oem_agent_name,
        c.code oem_agent_code,
        c.organization_code oem_agent_code,
        d.name supplier_name,
        e.name survey_staff_name,
        e.phone survey_staff_phone,
        f.name install_staff_name,
        f.phone install_staff_phone,
        g.name region_name,
        h.secret_no virtual_user_phone,
        i.wallbox_no,
        i.real_cable_meter,
        i.predict_total_fee
        from t_order a
        left join t_oem b on a.oem_id = b.id
        left join t_oem c on a.oem_agent_id = c.id
        left join t_supplier d on a.install_supplier_id = d.id
        left join t_supplier_staff e on a.survey_staff_id = e.id
        left join t_supplier_staff f on a.install_staff_id = f.id
        left join t_region g on a.region_id = g.id
        left join t_secret_phone h on h.phone = a.user_phone and h.status = 1
        left join t_order_install i on i.order_id = a.id
        where 1=1
        <if test="ids !=null and ids.size>0">
            and a.id in
            <foreach item="id" collection="ids" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
    </select>

    <select id="getUserMoreInfo" resultType="com.ihidea.core.support.session.SessionInfo">
        select id userId,account loginname,name userName from
        wb_account
        where 1=1
        <if test="userIds !=null and userIds.size>0">
            and id in
            <foreach item="userId" collection="userIds" open="(" close=")" separator=",">
                #{userId}
            </foreach>
        </if>
    </select>


    <select id="getOrderByNodeFlagAndCreateTime" resultType="com.boco.nbd.wios.flow.entity.po.OrderPO">
        select
        <include refid="Base_Column_List"/>
        from t_order
        where type=1 and process_ins_id is not null
        <if test="nodeFlag != null and nodeFlag != ''">
            and node_flag &gt; #{nodeFlag}
        </if>
        <if test="createTime != null and createTime != ''">
            and date_format(create_time,'%Y-%m')=#{createTime}
        </if>
    </select>


    <select id="getSendMessageData" resultType="com.boco.nbd.wios.flow.entity.po.SendMessagePO">
        select node_flag,
               id,
               survey_client_phone user_phone,
               survey_staff_phone  staff_phone,
               survey_staff_name   staff_name,
               survey_reserve_time reserve_time
        from t_order
        where node_flag = 105
          and status!=64
        and survey_reserve_time <![CDATA[>=]]>#{startTime}
          and survey_reserve_time <![CDATA[<=]]>#{endTime}
        union all
        select node_flag,
               id,
               install_client_phone user_phone,
               install_staff_phone  staff_phone,
               install_staff_name   staff_name,
               install_reserve_time reserve_time
        from t_order
        where node_flag = 110
          and status!=64
        and install_reserve_time <![CDATA[>=]]>#{startTime}
          and install_reserve_time <![CDATA[<=]]>#{endTime}
    </select>


    <select id="getPmUser" resultType="com.boco.nbd.wios.flow.entity.po.PmUserPO">
        select a.account_id, a.region_id
        from t_cams_account a
                 inner join wb_account_role b on a.account_id = b.account_id
        where a.status = 1
          and b.role_id = 5
    </select>

    <select id="getUsableSupplier" resultType="com.boco.nbd.wios.flow.entity.po.UsableSupplierPO">
        select a.id supplier_id, a.name supplier_name, a.region_id, a.oem_code, a.pack_type, a.level, max_order_quantity
        from t_supplier a
                 inner join t_supplier_contract b on a.id = b.supplier_id and b.status = 2
        where a.status = 1
          and a.check_status = 1
    </select>

    <select id="getSupplierReceiveInfo" resultType="com.boco.nbd.wios.flow.entity.po.SupplierReceivePO">
        select install_supplier_id supplier_id, region_id, count(*) receive_num
        from t_order
        where 1=1
        <if test="supplierId != null">
            and install_supplier_id = #{supplierId}
        </if>
        <if test="regionId != null and regionId != ''">
            and region_id = #{regionId}
        </if>
    </select>

    <select id="selectOrderPO" resultType="com.boco.nbd.wios.flow.entity.po.OrderPO">
        select *
        from t_order a
        where 1 = 1
        <if test="outOrderId != null and outOrderId != ''">
            and a.out_order_id=#{outOrderId}
        </if>
        <if test="userName != null and userName != ''">
            and a.user_name=#{userName}
        </if>
        <if test="userPhone != null and userPhone != ''">
            and a.user_phone=#{userPhone}
        </if>
        <if test="oemAgentInfo != null and oemAgentInfo != ''">
            and a.oem_agent_info like concat(#{oemAgentInfo}, '%')
        </if>
        <if test="oemAgentName != null and oemAgentName != ''">
            and a.oem_agent_name like concat(#{oemAgentName}, '%')
        </if>
        <if test="id != null and id != ''">
            and a.id =#{id}
        </if>
        <if test="oemId != null">
            and a.oem_id =#{oemId}
        </if>
        <if test="status != null and status != ''">
            and a.status =#{status}
        </if>
        <if test="countryId != null and countryId != ''">
            a.country_id in (#{countryId})
        </if>
        <if test="areaId != null and areaId != ''">
            a.area_id in (#{areaId})
        </if>
        <if test="provinceId != null and provinceId != ''">
            a.province_id in (#{provinceId})
        </if>
        <if test="regionId != null and regionId != ''">
            a.region_id in (#{regionId})
        </if>
        <if test="cityId != null and cityId != ''">
            a.city_id in (#{cityId})
        </if>
        <if test="wallboxNo != null and wallboxNo != ''">
            and a.status =#{status}
        </if>
        <if test="supplierName != null and supplierName != ''">
            and a.install_supplier_name like concat(#{supplierName}, '%')
        </if>
        <if test="supplierId != null and supplierId != ''">
            and a.install_supplier_id in (#{supplierId})
        </if>
        <if test="type != null">
            and a.type in (#{type})
        </if>
        <if test="surveyFinishTimeStart != null">
            and a.survey_finish_time <![CDATA[<=]]>#{surveyFinishTimeStart}
        </if>
        <if test="surveyFinishTimeEnd != null">
            and a.survey_finish_time <![CDATA[<=]]>#{surveyFinishTimeEnd}
        </if>
        <if test="installFinishTimeStart != null">
            and a.install_finish_time <![CDATA[>=]]>#{installFinishTimeStart}
        </if>
        <if test="installFinishTimeEnd != null">
            and a.install_finish_time <![CDATA[<=]]>#{installFinishTimeEnd}
        </if>
        <if test="overtimeType != null">
            and a.overtime_type =#{overtimeType}
        </if>
        <if test="scoreGt != null">
            and a.client_rate <![CDATA[>=]]>#{scoreGt}
        </if>
        <if test="scoreLt != null">
            and a.client_rate <![CDATA[<=]]>#{scoreLt}
        </if>
        order by a.create_time desc
    </select>

    <select id="getVisitOrderScore" resultType="com.boco.nbd.wios.flow.entity.po.VisitOrderPO">
        select a.out_order_id,
        'cams APP' source,
        user_name,
        user_phone,
        a.score,
        a.know_after_sales_channel,
        a.install_length,
        c.score_data
        from t_order a
        left join (select b.order_id,
        group_concat(replace(b.code, 'customer_item', ''), ',', b.name, ',', b.score,',', b.description, ';') score_data
        from t_order_score b
        where b.status = 1
        group by b.order_id) c
        on a.id = c.order_id
        where 1=1
        <if test="status != null">
            and a.status = #{status}
        </if>
        <if test="id != null and id != ''">
            and a.id =#{id}
        </if>
        <if test="userName != null and userName != ''">
            and a.user_name=#{userName}
        </if>
        <if test="userPhone != null and userPhone != ''">
            and a.user_phone=#{userPhone}
        </if>
        <if test="oemName != null and oemName != ''">
            and a.oem_name like concat(#{oemName}, '%')
        </if>
        <if test="supplierName != null and supplierName != ''">
            and a.install_supplier_name like concat(#{supplierName}, '%')
        </if>
        <if test="surveyFinishStartTime != null and surveyFinishStartTime != ''">
            and a.survey_finish_time &gt;= #{surveyFinishStartTime}
        </if>
        <if test="surveyFinishEndTime != null and surveyFinishEndTime != ''">
            and a.survey_finish_time &lt;= #{surveyFinishEndTime}
        </if>
        <if test="installFinishStartTime != null and installFinishStartTime != ''">
            and a.install_finish_time &gt;= #{installFinishStartTime}
        </if>
        <if test="installFinishEndTime != null and installFinishEndTime != ''">
            and a.install_finish_time &lt;= #{installFinishEndTime}
        </if>
    </select>
</mapper>