| <?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.xzx.gc.system.mapper.OrderMapper">  | 
|     <select id="findStatusNumByPartnerId" resultType="int">  | 
|         SELECT count(*) from xzx_order_info a  | 
|         inner join xzx_user_other_info b on a.receiver=b.user_id  | 
|         WHERE a.order_status in  | 
|         <foreach collection="status" index="index" item="id" open="(" separator="," close=")">  | 
|             #{id}  | 
|         </foreach>  | 
|         and b.partner_id=#{partnerId}  | 
|     </select>  | 
|   | 
|     <select id="queryOrderByCityId"   resultType="com.xzx.gc.model.admin.OrderModel">  | 
|         SELECT  | 
|         a.*  | 
|         FROM  | 
|         xzx_order_info a  | 
|         where a.order_status in ('4','7') and a.order_type in('1','2')  | 
|         <if test="townIds!= null and townIds.size() != 0">  | 
|             and a.town_id in  | 
|             <foreach collection="townIds" index="index" item="id" open="(" separator="," close=")">  | 
|                 #{id}  | 
|             </foreach>  | 
|         </if>  | 
|   | 
|     </select>  | 
|   | 
|     <select id="queryOrderByTownIdApiList" resultType="com.xzx.gc.model.admin.OrderModel">  | 
|         SELECT a.order_id as orderId,a.create_time as createTime,a.reserve_time as reserveTime,a.order_type as  | 
|         orderType,  | 
|         a.rela_phone as relaPhone,m.receive_time as receiveTime,  | 
|         m.complete_time as completeTime,  | 
|         m.cancel_reason_name as cancelReasonName,  | 
|         a.order_status as orderStatus,  | 
|         IFNULL(d.nick_name,c.nick_name) as nickName,  | 
|         c.name as name,d.mobile_phone as mobilePhone,a.rela_name as relaName,  | 
|         m.orderMoney as orderMoney,m.orderWeight AS orderWeight,  | 
|         m.order_fast_flag as orderFastFlag,  | 
|         m.mark_code as markCode,  | 
|         IFNULL(m.mark_read,0) as markRead,  | 
|         d.partner_id as partnerId,  | 
|         IFNULL(c.del_flag,0) as delFlag  | 
|         FROM xzx_order_info a  | 
|         LEFT JOIN ( select SUM(f.money) as orderMoney,SUM(f.weight) AS orderWeight,b.order_id,  | 
|         b.complete_time,b.cancel_reason_name,b.receive_time,b.order_fast_flag,b.mark_code,b.mark_read  | 
|         from  | 
|         xzx_order_detail_info b  | 
|         LEFT JOIN xzx_order_item_info f ON f.order_id = b.order_id  | 
|         where 1=1 group by b.order_id  | 
|         )m ON m.order_id=a.order_id  | 
|         LEFT JOIN xzx_user_info d ON a.create_user_id = d.user_id  | 
|         LEFT JOIN xzx_user_other_info c ON a.receiver = c.user_id  | 
|         WHERE 1=1  | 
|   | 
|         <if test="orderStatus != null and orderStatus != ''">  | 
|             AND a.order_status=#{orderStatus}  | 
|         </if>  | 
|   | 
|         <if test="startTime != null and startTime != ''">  | 
|             AND a.create_time BETWEEN #{startTime} AND #{endTime}  | 
|         </if>  | 
|   | 
|         <if test="orderType != null and orderType != ''">  | 
|             AND a.order_type = #{orderType}  | 
|         </if>  | 
|   | 
|         <if test="name != null and name != ''">  | 
|             AND c.name like concat('%',#{name} ,'%')  | 
|         </if>  | 
|   | 
|         <if test="mobilePhone != null and mobilePhone != ''">  | 
|             AND (d.mobile_phone like concat('%',#{mobilePhone} ,'%') or d.nick_name = #{nickName} or a.rela_phone like concat('%',#{mobilePhone} ,'%'))  | 
|         </if>  | 
|   | 
|         <if test="orderId != null and orderId != ''">  | 
|             AND a.order_id like concat('%',#{orderId},'%')  | 
|         </if>  | 
|   | 
|         <if test="createType != null and createType != ''">  | 
|             AND a.create_type = #{createType}  | 
|         </if>  | 
|   | 
|         <if test="townIds != null and townIds.size()>0">  | 
|             AND a.town_id in  | 
|             <foreach collection="townIds" index="index" item="id" separator="," open="(" close=")">  | 
|                 #{id}  | 
|             </foreach>  | 
|         </if>  | 
|         GROUP BY a.order_id  | 
|         order by a.create_time desc  | 
|     </select>  | 
|   | 
|     <select id="queryOrderApiList" resultType="com.xzx.gc.model.admin.OrderModel">  | 
|         SELECT a.order_id as orderId,a.create_time as createTime,a.reserve_time as reserveTime,a.order_type as  | 
|         orderType,a.rela_phone as relaPhone,b.receive_time as receiveTime,b.complete_time as  | 
|         completeTime,b.cancel_reason_name as cancelReasonName,  | 
|         a.order_status as orderStatus,IFNULL(d.nick_name,c.nick_name) as nickName,c.name as name,d.mobile_phone as  | 
|         mobilePhone,a.rela_name as relaName,SUM(f.money) as orderMoney,SUM(f.weight) AS orderWeight,IFNULL(b.mark_read,0) as markRead,  | 
|         b.order_fast_flag as orderFastFlag,b.mark_code as markCode,d.partner_id as partnerId,IFNULL(c.del_flag,0) as delFlag  | 
|         FROM xzx_order_info a  | 
|         LEFT JOIN xzx_order_detail_info b ON a.order_id = b.order_id  | 
|         LEFT JOIN xzx_user_info d ON a.create_user_id = d.user_id  | 
|         LEFT JOIN xzx_user_other_info c ON a.receiver = c.user_id  | 
|         LEFT JOIN xzx_order_item_info f ON a.order_id = f.order_id  | 
|         LEFT JOIN xzx_user_address_info k ON b.address_id=k.address_id  | 
|         WHERE 1 = 1  | 
|         <if test="orderStatus != null and orderStatus != ''">  | 
|             AND a.order_status=#{orderStatus}  | 
|         </if>  | 
|   | 
|         <if test="startTime != null and startTime != ''">  | 
|             AND a.create_time BETWEEN #{startTime} AND #{endTime}  | 
|         </if>  | 
|   | 
|         <if test="orderType != null and orderType != ''">  | 
|             AND a.order_type = #{orderType}  | 
|         </if>  | 
|   | 
|         <if test="name != null and name != ''">  | 
|             AND c.name like concat('%',#{name} ,'%')  | 
|         </if>  | 
|   | 
|         <if test="mobilePhone != null and mobilePhone != ''">  | 
|             AND (d.mobile_phone like concat('%',#{mobilePhone} ,'%') or d.nick_name = #{nickName} or a.rela_phone like concat('%',#{mobilePhone} ,'%'))  | 
|         </if>  | 
|   | 
|         <if test="orderId != null and orderId != ''">  | 
|             AND a.order_id like concat('%',#{orderId} ,'%')  | 
|         </if>  | 
|   | 
|         <if test="createType != null and createType != ''">  | 
|             AND a.create_type = #{createType}  | 
|         </if>  | 
|   | 
|         <if test=" partnerIds != null and partnerIds.size() != 0">  | 
|             AND c.partner_id in  | 
|             <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">  | 
|                 #{id}  | 
|             </foreach>  | 
|         </if>  | 
|         <if test="townIds != null">  | 
|             AND k.township_id in  | 
|             <foreach collection="townIds" index="index" item="tid" separator="," open="(" close=")">  | 
|                 #{tid}  | 
|             </foreach>  | 
|         </if>  | 
|         GROUP BY a.order_id  | 
|         order by a.create_time desc  | 
|     </select>  | 
|   | 
|     <select id="getSysStorageTypeName" resultType="java.util.Map">  | 
|         SELECT sum(c.weight) AS weight, sum(c.money ) as money, d.title FROM xzx_order_info a  | 
|         LEFT JOIN xzx_order_detail_info b ON a.order_id=b.order_id  | 
|         LEFT JOIN xzx_order_item_info c ON c.order_id=a.order_id  | 
|         LEFT JOIN xzx_sys_environmental_info d ON c.item_type = d.item_type  | 
|         WHERE a.order_status=5 and b.complete_time is not null  | 
|         and a.order_id in  | 
|         <foreach collection="orderIds" index="index" item="id" open="(" separator="," close=")">  | 
|             #{id}  | 
|         </foreach>  | 
|         <if test="startTime != null and startTime != ''">  | 
|             AND b.complete_time <![CDATA[>= ]]>#{startTime}  | 
|         </if>  | 
|         <if test="endTime != null and endTime != ''">  | 
|             AND b.complete_time<![CDATA[<= ]]>#{endTime}  | 
|         </if>  | 
|         <if test="typeName != null and endTime != ''">  | 
|             AND d.title like concat("%",#{typeName},"%")  | 
|         </if>  | 
|         group by d.title  | 
|     </select>  | 
|   | 
|     <select id="findPartnerId" resultType="com.xzx.gc.entity.OrderInfo">  | 
|         SELECT  | 
|             a.order_id "orderId",  | 
|             a.create_time "createTime",  | 
|             b.partner_id "partnerId",  | 
|             c.money  | 
|         FROM  | 
|             xzx_order_info a  | 
|             LEFT JOIN xzx_order_detail_info c on a.order_id=c.order_id  | 
|             LEFT JOIN xzx_partner_fence b ON a.town_id = b.fence_id  | 
|     </select>  | 
|   | 
|     <select id="findPartnerIdByTime" resultType="com.xzx.gc.entity.OrderInfo">  | 
|         SELECT  | 
|             a.order_id "orderId",  | 
|             a.create_time "createTime",  | 
|             b.partner_id "partnerId",  | 
|             c.money  | 
|         FROM  | 
|             xzx_order_info a  | 
|             LEFT JOIN xzx_order_detail_info c on a.order_id=c.order_id  | 
|             LEFT JOIN xzx_partner_fence b ON a.town_id = b.fence_id  | 
|                                              AND b.del_flag = 0  | 
|         where  | 
|             DATE_FORMAT(a.create_time,'%Y-%m-%d')=date_sub(CURRENT_DATE(), interval 1 day)  | 
|     </select>  | 
|   | 
|   | 
| </mapper> |