| <?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.matrix.system.shopXcx.dao.ShopDeliveryInfoDao"> | 
|     <!-- 定义ShopDeliveryInfo 的复杂关联map --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopDeliveryInfo" id="ShopDeliveryInfoMap"> | 
|         <id property="id" column="id" /> | 
|         <result property="createBy" column="create_by" /> | 
|         <result property="createTime" column="create_time" /> | 
|         <result property="updateBy" column="update_by" /> | 
|         <result property="updateTime" column="update_time" /> | 
|             <result property="waybillNo" column="waybill_no" /> | 
|             <result property="deliveryWay" column="delivery_way" /> | 
|             <result property="receiveAddress" column="receive_address" /> | 
|             <result property="logisticsCompany" column="logistics_company" /> | 
|             <result property="orderId" column="order_id" /> | 
|             <result property="userId" column="user_id" /> | 
|             <result property="orderNo" column="order_no" /> | 
|             <result property="remarks" column="remarks" /> | 
|             <result property="logisticsCompanyCode" column="logistics_company_code" /> | 
|             <result property="logisticsStatus" column="logistics_status" /> | 
|             <result property="deliveryTime" column="delivery_time" /> | 
|             <result property="pickUpStatus" column="pick_up_status"/> | 
|     </resultMap> | 
|   | 
|   | 
|     <!-- 定义ShopDeliveryInfo 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopDeliveryInfo" id="ShopDeliveryInfoSimpleMap"> | 
|         <id property="id" column="id" /> | 
|         <result property="createBy" column="create_by" /> | 
|         <result property="createTime" column="create_time" /> | 
|         <result property="updateBy" column="update_by" /> | 
|         <result property="updateTime" column="update_time" /> | 
|             <result property="waybillNo" column="waybill_no" /> | 
|             <result property="deliveryWay" column="delivery_way" /> | 
|             <result property="receiveAddress" column="receive_address" /> | 
|             <result property="logisticsCompany" column="logistics_company" /> | 
|             <result property="orderId" column="order_id" /> | 
|             <result property="userId" column="user_id" /> | 
|             <result property="orderNo" column="order_no" /> | 
|             <result property="remarks" column="remarks" /> | 
|             <result property="logisticsCompanyCode" column="logistics_company_code" /> | 
|             <result property="logisticsStatus" column="logistics_status" /> | 
|             <result property="deliveryTime" column="delivery_time" /> | 
|             <result property="pickUpStatus" column="pick_up_status"/> | 
|     </resultMap> | 
|   | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         create_by, | 
|         create_time, | 
|         update_by, | 
|         update_time, | 
|             id, | 
|             waybill_no, | 
|             delivery_way, | 
|             receive_address, | 
|             logistics_company, | 
|             order_id, | 
|             user_id, | 
|             order_no, | 
|             remarks, | 
|             logistics_company_code, | 
|             logistics_status, | 
|             delivery_time, | 
|             pick_up_status, | 
|             receive_id, | 
|             shop_id | 
|     </sql> | 
|   | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.createBy}, | 
|         now(), | 
|         #{item.updateBy}, | 
|         now(), | 
|             #{item.id}, | 
|             #{item.waybillNo}, | 
|             #{item.deliveryWay}, | 
|             #{item.receiveAddress}, | 
|             #{item.logisticsCompany}, | 
|             #{item.orderId}, | 
|             #{item.userId}, | 
|             #{item.orderNo}, | 
|             #{item.remarks}, | 
|             #{item.logisticsCompanyCode}, | 
|             #{item.logisticsStatus}, | 
|             #{item.deliveryTime}, | 
|             #{item.pickUpStatus}, | 
|             #{item.receiveId}, | 
|             #{item.shopId} | 
|     </sql> | 
|   | 
|     <!-- where sql --> | 
|     <sql id="where_sql"> | 
|   | 
|          <if test="record!=null"> | 
|             <if test="(record.id!=null and record.id!='') or  (record.id!='' and record.id==0)  "> | 
|                 and id  = #{record.id} | 
|             </if> | 
|             <if test="(record.waybillNo!=null and record.waybillNo!='') or  (record.waybillNo!='' and record.waybillNo==0)  "> | 
|                 and waybill_no like concat('%',#{record.waybillNo},'%') | 
|   | 
|             </if> | 
|             <if test="(record.deliveryWay!=null and record.deliveryWay!='') or  (record.deliveryWay!='' and record.deliveryWay==0)  "> | 
|                 and delivery_way  = #{record.deliveryWay} | 
|             </if> | 
|             <if test="(record.receiveAddress!=null and record.receiveAddress!='') or  (record.receiveAddress!='' and record.receiveAddress==0)  "> | 
|                 and receive_address  = #{record.receiveAddress} | 
|             </if> | 
|             <if test="(record.logisticsCompany!=null and record.logisticsCompany!='') or  (record.logisticsCompany!='' and record.logisticsCompany==0)  "> | 
|                 and logistics_company  = #{record.logisticsCompany} | 
|             </if> | 
|             <if test="(record.orderId!=null and record.orderId!='') or  (record.orderId!='' and record.orderId==0)  "> | 
|                 and order_id  = #{record.orderId} | 
|             </if> | 
|             <if test="(record.userId!=null and record.userId!='') or  (record.userId!='' and record.userId==0)  "> | 
|                 and user_id  = #{record.userId} | 
|             </if> | 
|             <if test="(record.orderNo!=null and record.orderNo!='') or  (record.orderNo!='' and record.orderNo==0)  "> | 
|                 and order_no  like concat('%',#{record.orderNo},'%') | 
|             </if> | 
|             <if test="(record.remarks!=null and record.remarks!='') or  (record.remarks!='' and record.remarks==0)  "> | 
|                 and remarks  = #{record.remarks} | 
|             </if> | 
|             <if test="(record.logisticsCompanyCode!=null and record.logisticsCompanyCode!='') or  (record.logisticsCompanyCode!='' and record.logisticsCompanyCode==0)  "> | 
|                 and logistics_company_code  = #{record.logisticsCompanyCode} | 
|             </if> | 
|             <if test="(record.logisticsStatus!=null and record.logisticsStatus!='') or  (record.logisticsStatus!='' and record.logisticsStatus==0)  "> | 
|                 and logistics_status  = #{record.logisticsStatus} | 
|             </if> | 
|             <if test="(record.startTime!=null and record.startTime!='') or  (record.startTime!='' and record.startTime==0)  "> | 
|                 and date_format(delivery_time,'%Y-%m-%d') >= #{record.startTime} | 
|             </if> | 
|              <if test="(record.endTime!=null and record.endTime!='') or  (record.endTime!='' and record.endTime==0)  "> | 
|                  and date_format(delivery_time,'%Y-%m-%d') <= #{record.endTime} | 
|              </if> | 
|              <if test="(record.deliveryTime!=null and record.deliveryTime!='') or  (record.deliveryTime!='' and record.deliveryTime==0)  "> | 
|                  and delivery_time  = #{record.deliveryTime} | 
|              </if> | 
|              <if test="(record.pickUpStatus!=null and record.pickUpStatus!='') or  (record.pickUpStatus!='' and record.pickUpStatus==0)  "> | 
|                  and pick_up_status  = #{record.pickUpStatus} | 
|              </if> | 
|              <if test="(record.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  "> | 
|                  and shop_id  = #{record.shopId} | 
|              </if> | 
|              <if test="(record.companyId!=null and record.companyId!='') or  (record.companyId!='' and record.companyId==0)  "> | 
|                  and company_id  = #{record.companyId} | 
|              </if> | 
|         </if> | 
|   | 
|     </sql> | 
|   | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopDeliveryInfo" | 
|         useGeneratedKeys="true" keyProperty="item.id"> | 
|         INSERT INTO shop_delivery_info ( | 
|              <include refid="columns"></include> | 
|         ) | 
|     VALUES ( | 
|          <include refid="propertys"></include> | 
|     ) | 
|     </insert> | 
|   | 
|   | 
|   | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO shop_delivery_info ( | 
|         <include refid="columns"></include> | 
|         ) | 
|     VALUES | 
|     <foreach collection="list" item="item" index="index" separator=",">( | 
|         <include refid="propertys"></include> | 
|     )</foreach> | 
|     </insert> | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     <!--  根据Map更新 部分更新   --> | 
|     <update id="updateByMap" parameterType="java.util.HashMap" > | 
|         UPDATE shop_delivery_info | 
|         <set> | 
|             <if test="_parameter.containsKey('waybillNo')"> | 
|                     waybill_no = #{waybillNo}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('deliveryWay')"> | 
|                     delivery_way = #{deliveryWay}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('receiveAddress')"> | 
|                     receive_address = #{receiveAddress}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('logisticsCompany')"> | 
|                     logistics_company = #{logisticsCompany}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('orderId')"> | 
|                     order_id = #{orderId}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('userId')"> | 
|                     user_id = #{userId}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('orderNo')"> | 
|                     order_no = #{orderNo}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('remarks')"> | 
|                     remarks = #{remarks}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('logisticsCompanyCode')"> | 
|                     logistics_company_code = #{logisticsCompanyCode}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('logisticsStatus')"> | 
|                     logistics_status = #{logisticsStatus}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('deliveryTime')"> | 
|                 delivery_time = #{deliveryTime}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('pickUpStatus')"> | 
|                 pick_up_status = #{pickUpStatus}, | 
|             </if> | 
|         </set> | 
|         WHERE id=#{id} | 
|     </update> | 
|   | 
|   | 
|     <!--  根据对象更新 部分更新   --> | 
|     <update id="updateByModel" parameterType="Integer"> | 
|         UPDATE shop_delivery_info | 
|         <set> | 
|             <if test="record.waybillNo != null and record.waybillNo != '' "> | 
|                 waybill_no  = #{record.waybillNo}, | 
|             </if> | 
|             <if test="record.deliveryWay != null and record.deliveryWay != '' "> | 
|                 delivery_way  = #{record.deliveryWay}, | 
|             </if> | 
|             <if test="record.receiveAddress != null and record.receiveAddress != '' "> | 
|                 receive_address  = #{record.receiveAddress}, | 
|             </if> | 
|             <if test="record.logisticsCompany != null and record.logisticsCompany != '' "> | 
|                 logistics_company  = #{record.logisticsCompany}, | 
|             </if> | 
|             <if test="record.orderId != null "> | 
|                 order_id  = #{record.orderId}, | 
|             </if> | 
|             <if test="record.receiveId != null "> | 
|                 receive_id  = #{record.receiveId}, | 
|             </if> | 
|             <if test="record.userId != null and record.userId != '' "> | 
|                 user_id  = #{record.userId}, | 
|             </if> | 
|             <if test="record.orderNo != null and record.orderNo != '' "> | 
|                 order_no  = #{record.orderNo}, | 
|             </if> | 
|             <if test="record.remarks != null and record.remarks != '' "> | 
|                 remarks  = #{record.remarks}, | 
|             </if> | 
|             <if test="record.logisticsCompanyCode != null and record.logisticsCompanyCode != '' "> | 
|                 logistics_company_code  = #{record.logisticsCompanyCode}, | 
|             </if> | 
|             <if test="record.logisticsStatus != null "> | 
|                 logistics_status  = #{record.logisticsStatus}, | 
|             </if> | 
|             <if test="record.deliveryTime != null "> | 
|                 delivery_time  = #{record.deliveryTime}, | 
|             </if> | 
|             <if test="record.pickUpStatus != null "> | 
|                 pick_up_status  = #{record.pickUpStatus}, | 
|             </if> | 
|             <if test="record.shopId != null "> | 
|                 shop_id  = #{record.shopId}, | 
|             </if> | 
|             <if test="record.companyId != null "> | 
|                 company_id  = #{record.companyId}, | 
|             </if> | 
|         </set> | 
|         WHERE id=#{record.id} | 
|     </update> | 
|   | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from shop_delivery_info where  id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|   | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" parameterType="Integer"> | 
|         DELETE FROM shop_delivery_info | 
|         where  id=#{id}  | 
|     </delete> | 
|   | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopDeliveryInfo"> | 
|         DELETE FROM shop_delivery_info | 
|         <where> | 
|         <include refid="where_sql" ></include> | 
|         </where> | 
|     </delete> | 
|   | 
|   | 
|   | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="ShopDeliveryInfoMap"> | 
|         select | 
|         <include refid="columns" ></include> | 
|         from shop_delivery_info | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 查询总条数 --> | 
|     <select id="selectTotalRecord" parameterType="long"   resultType="java.lang.Integer"> | 
|     select count(*) | 
|     from shop_delivery_info | 
|         <where> | 
|            <include refid="where_sql"></include> | 
|         </where> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="ShopDeliveryInfoMap"> | 
|         select | 
|         <include refid="columns" ></include> | 
|         from shop_delivery_info | 
|         where  id=#{id} | 
|     </select> | 
|   | 
|     <!-- 查询发货后15天待收货的数据--> | 
|     <select id="selectAutomaticReceive" resultMap="ShopDeliveryInfoMap"> | 
|         select | 
|             i.id, | 
|             i.waybill_no, | 
|             i.delivery_way, | 
|             i.receive_address, | 
|             i.logistics_company, | 
|             i.order_id, | 
|             i.user_id, | 
|             i.order_no, | 
|             i.remarks, | 
|             i.logistics_company_code, | 
|             i.logistics_status, | 
|             i.delivery_time, | 
|             i.pick_up_status | 
|         from shop_delivery_info i | 
|         LEFT JOIN shop_order o on i.order_id = o.id | 
|         WHERE DATE_ADD(i.delivery_time,INTERVAL 15 DAY) < now() | 
|         and o.del_flag = 2 | 
|         and o.order_status = 3 | 
|     </select> | 
|   | 
|     <!-- 根据订单id查询--> | 
|     <select id="selectByOrderId" resultMap="ShopDeliveryInfoMap"> | 
|         select | 
|         <include refid="columns" ></include> | 
|         from shop_delivery_info | 
|         where  order_id=#{orderId} | 
|     </select> | 
|   | 
|     <!-- 根据订单id查询最新物流信息--> | 
|     <select id="selectDescribeByOrderId" resultType ="java.lang.String"> | 
|         SELECT | 
|           b.`describe` | 
|         FROM | 
|           shop_delivery_info a | 
|         LEFT JOIN | 
|           shop_logistics_info b ON a.id = b.deliery_id | 
|         where  order_id=#{orderId} | 
|           ORDER BY | 
|           b.logistics_time DESC | 
|           LIMIT 1 | 
|     </select> | 
|   | 
|   | 
|     <!-- 根据id 锁表查询--> | 
|     <select id="selectForUpdate" resultMap="ShopDeliveryInfoMap"> | 
|         select | 
|         <include refid="columns" ></include> | 
|         from shop_delivery_info | 
|         where  id=#{id} | 
|         for update | 
|     </select> | 
|   | 
|   | 
|   | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="ShopDeliveryInfoMap"> | 
|         select | 
|         <include refid="columns" ></include> | 
|         from shop_delivery_info | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|     </select> | 
|   | 
| </mapper> |