| <?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.ShopOrderDao"> | 
|     <!-- 定义ShopOrder 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopOrder" id="ShopOrderMap"> | 
|         <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="orderNo" column="order_no" /> | 
|             <result property="orderMoney" column="order_money" /> | 
|             <result property="commodityPrice" column="commodity_price" /> | 
|             <result property="userId" column="user_id" /> | 
|             <result property="orderTime" column="order_time" /> | 
|             <result property="payStatus" column="pay_status" /> | 
|             <result property="discountExplain" column="discount_explain" /> | 
|             <result property="discountAmount" column="discount_amount" /> | 
|             <result property="orderStatus" column="order_status" /> | 
|             <result property="refundCharge" column="refund_charge" /> | 
|             <result property="userName" column="user_name" /> | 
|             <result property="userTel" column="user_tel" /> | 
|             <result property="remarks" column="remarks" /> | 
|             <result property="shippingMethod" column="shipping_method"/> | 
|             <result property="storeId" column="store_id" /> | 
|             <result property="purchaseQuantity" column="purchase_quantity" /> | 
|             <result property="delFlag" column="del_flag" /> | 
|             <result property="wxOrderNo" column="wx_order_no" /> | 
|             <result property="payResult" column="pay_result" /> | 
|             <result property="postage" column="postage" /> | 
|             <result property="storeName" column="shop_name" /> | 
|             <result property="orderType" column="order_type" /> | 
|             <result property="applyStatus" column="apply_status" /> | 
|             <result property="scorePay" column="score_pay" /> | 
|             <result property="payMethod" column="pay_method" /> | 
|             <result property="companyId" column="company_id" /> | 
|             <!--返回详情列表--> | 
|             <collection property="details" column="{orderId=id}" | 
|                         select="com.matrix.system.shopXcx.dao.ShopOrderDetailsDao.selectByOrderId"/> | 
|     </resultMap> | 
|   | 
|   | 
|     <!-- 定义ShopOrder 的复杂map --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopOrder" id="ShopOrderComplexMap"> | 
|         <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="payMethod" column="pay_method" /> | 
|             <result property="orderNo" column="order_no" /> | 
|             <result property="orderMoney" column="order_money" /> | 
|             <result property="commodityPrice" column="commodity_price" /> | 
|             <result property="userId" column="user_id" /> | 
|             <result property="orderTime" column="order_time" /> | 
|             <result property="payStatus" column="pay_status" /> | 
|             <result property="discountExplain" column="discount_explain" /> | 
|             <result property="discountAmount" column="discount_amount" /> | 
|             <result property="orderStatus" column="order_status" /> | 
|             <result property="refundCharge" column="refund_charge" /> | 
|             <result property="userName" column="user_name" /> | 
|             <result property="userTel" column="user_tel" /> | 
|             <result property="remarks" column="remarks" /> | 
|             <result property="shippingMethod" column="shipping_method"/> | 
|             <result property="storeId" column="store_id" /> | 
|             <result property="purchaseQuantity" column="purchase_quantity" /> | 
|             <result property="delFlag" column="del_flag" /> | 
|             <result property="wxOrderNo" column="wx_order_no" /> | 
|             <result property="payResult" column="pay_result" /> | 
|             <result property="postage" column="postage" /> | 
|             <result property="orderType" column="order_type" /> | 
|             <result property="storeName" column="shop_name" /> | 
|         <result property="scorePay" column="score_pay" /> | 
|             <result property="companyId" column="company_id" /> | 
|         <result property="activityType" column="activity_type" /> | 
|         <!--支付时间--> | 
|         <association property="paymentTime" column="{orderId=id}" | 
|                      select="selectPaymentTimeByOrderId"/> | 
|         <!--开票数量--> | 
|         <association property="invoiceCount" column="{orderId=id}" | 
|                      select="selectInvoiceCountByOrderId"/> | 
|         <!--发货信息--> | 
|         <association property="deliveryInfo" column="{orderId=id}" | 
|                      select="com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao.selectByOrderId"/> | 
|   | 
|         <!--返回详情列表--> | 
|         <collection property="details" column="{orderId=id}" | 
|                     select="com.matrix.system.shopXcx.dao.ShopOrderDetailsDao.selectByOrderId"/> | 
|     </resultMap> | 
|   | 
|     <!--根据订单ID查询开发票数量--> | 
|     <select id="selectInvoiceCountByOrderId" resultType="java.lang.Integer"> | 
|         select count(*) | 
|         from shop_invoice | 
|         where order_id = #{orderId} | 
|     </select> | 
|   | 
|     <!--根据订单ID查询支付时间--> | 
|     <select id="selectPaymentTimeByOrderId" resultType="java.util.Date"> | 
|         select create_time | 
|         from shop_pay_log | 
|         where pay_type = 1 and pay_status = 2 | 
|         and join_id = #{orderId} | 
|     </select> | 
|   | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         create_by, | 
|         create_time, | 
|         update_by, | 
|         update_time, | 
|             id, | 
|             order_no, | 
|             order_money, | 
|             commodity_price, | 
|             user_id, | 
|             order_time, | 
|             pay_status, | 
|             discount_explain, | 
|             discount_amount, | 
|             order_status, | 
|             refund_charge, | 
|             user_name, | 
|             user_tel, | 
|             remarks, | 
|             shipping_method, | 
|             store_id, | 
|             purchase_quantity, | 
|             del_flag, | 
|             wx_order_no, | 
|             pay_result, | 
|             postage, | 
|             order_type, | 
|             activity_type, | 
| score_pay, | 
|   | 
|         pay_method, | 
|             company_id | 
|     </sql> | 
|      | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.createBy}, | 
|         now(), | 
|         #{item.updateBy}, | 
|         now(), | 
|             #{item.id}, | 
|             #{item.orderNo}, | 
|             #{item.orderMoney}, | 
|             #{item.commodityPrice}, | 
|             #{item.userId}, | 
|             now(), | 
|             #{item.payStatus}, | 
|             #{item.discountExplain}, | 
|             #{item.discountAmount}, | 
|             #{item.orderStatus}, | 
|             #{item.refundCharge}, | 
|             #{item.userName}, | 
|             #{item.userTel}, | 
|             #{item.remarks}, | 
|             #{item.shippingMethod}, | 
|             #{item.storeId}, | 
|             #{item.purchaseQuantity}, | 
|             #{item.delFlag}, | 
|             #{item.wxOrderNo}, | 
|             #{item.payResult}, | 
|             #{item.postage}, | 
|             #{item.orderType}, | 
|             #{item.activityType}, | 
|             #{item.scorePay}, | 
|             #{item.payMethod}, | 
|             #{item.companyId} | 
|     </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.orderNo!=null and record.orderNo!='') or  (record.orderNo!='' and record.orderNo==0)  "> | 
|                 and order_no like concat('%', #{record.orderNo}, '%') | 
|             </if> | 
|             <if test="(record.orderMoney!=null and record.orderMoney!='') or  (record.orderMoney!='' and record.orderMoney==0)  "> | 
|                 and order_money  = #{record.orderMoney}  | 
|             </if> | 
|              <if test="(record.commodityPrice!=null and record.commodityPrice!='') or  (record.commodityPrice!='' and record.commodityPrice==0)  "> | 
|                  and commodity_price  = #{record.commodityPrice} | 
|              </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.orderTime!=null and record.orderTime!='') or  (record.orderTime!='' and record.orderTime==0)  "> | 
|                 and order_time  = #{record.orderTime}  | 
|             </if> | 
|             <if test="(record.payStatus!=null and record.payStatus!='') or  (record.payStatus!='' and record.payStatus==0)  "> | 
|                 and pay_status  = #{record.payStatus}  | 
|             </if> | 
|             <if test="(record.discountExplain!=null and record.discountExplain!='') or  (record.discountExplain!='' and record.discountExplain==0)  "> | 
|                 and discount_explain  = #{record.discountExplain}  | 
|             </if> | 
|             <if test="(record.discountAmount!=null and record.discountAmount!='') or  (record.discountAmount!='' and record.discountAmount==0)  "> | 
|                 and discount_amount  = #{record.discountAmount}  | 
|             </if> | 
|             <if test="(record.orderStatus!=null and record.orderStatus!='') or  (record.orderStatus!='' and record.orderStatus==0)  "> | 
|                 and order_status  = #{record.orderStatus}  | 
|             </if> | 
|             <if test="(record.refundCharge!=null and record.refundCharge!='') or  (record.refundCharge!='' and record.refundCharge==0)  "> | 
|                 and refund_charge  = #{record.refundCharge}  | 
|             </if> | 
|             <if test="(record.userName!=null and record.userName!='') or  (record.userName!='' and record.userName==0)  "> | 
|                 and user_name  like concat('%', #{record.userName}, '%') | 
|             </if> | 
|             <if test="(record.userTel!=null and record.userTel!='') or  (record.userTel!='' and record.userTel==0)  "> | 
|                 and user_tel  like concat('%', #{record.userTel}, '%') | 
|             </if> | 
|             <if test="(record.remarks!=null and record.remarks!='') or  (record.remarks!='' and record.remarks==0)  "> | 
|                 and remarks  = #{record.remarks}  | 
|             </if> | 
|             <if test="(record.shippingMethod!=null and record.shippingMethod!='') or  (record.shippingMethod!='' and record.shippingMethod==0)  "> | 
|                  and shipping_method  = #{record.shippingMethod} | 
|             </if> | 
|             <if test="(record.storeId!=null and record.storeId!='') or  (record.storeId!='' and record.storeId==0)  "> | 
|                 and store_id  = #{record.storeId}  | 
|             </if> | 
|             <if test="(record.purchaseQuantity!=null and record.purchaseQuantity!='') or  (record.purchaseQuantity!='' and record.purchaseQuantity==0)  "> | 
|                 and purchase_quantity  = #{record.purchaseQuantity}  | 
|             </if> | 
|             <if test="(record.delFlag!=null and record.delFlag!='') or  (record.delFlag!='' and record.delFlag==0)  "> | 
|                 and del_flag  = #{record.delFlag}  | 
|             </if> | 
|             <if test="(record.wxOrderNo!=null and record.wxOrderNo!='') or  (record.wxOrderNo!='' and record.wxOrderNo==0)  "> | 
|                 and wx_order_no  = #{record.wxOrderNo}  | 
|             </if> | 
|             <if test="(record.payResult!=null and record.payResult!='') or  (record.payResult!='' and record.payResult==0)  "> | 
|                 and pay_result  = #{record.payResult}  | 
|             </if> | 
|              <if test="(record.postage!=null and record.postage!='') or  (record.postage!='' and record.postage==0)  "> | 
|                  and postage  = #{record.postage} | 
|              </if> | 
|              <if test="(record.orderType!=null and record.orderType!='') or  (record.orderType!='' and record.orderType==0)  "> | 
|                  and order_type  = #{record.orderType} | 
|              </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.ShopOrder" | 
|         useGeneratedKeys="true" keyProperty="item.id"> | 
|         INSERT INTO shop_order ( | 
|              <include refid="columns"></include> | 
|         ) | 
|     VALUES ( | 
|          <include refid="propertys"></include> | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO shop_order ( | 
|         <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_order | 
|         <set> | 
|             <if test="_parameter.containsKey('orderNo')"> | 
|                     order_no = #{orderNo}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('orderMoney')"> | 
|                     order_money = #{orderMoney}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('commodityPrice')"> | 
|                     commodity_price = #{commodityPrice}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('userId')"> | 
|                     user_id = #{userId}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('orderTime')"> | 
|                     order_time = #{orderTime}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('payStatus')"> | 
|                     pay_status = #{payStatus}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('discountExplain')"> | 
|                     discount_explain = #{discountExplain}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('discountAmount')"> | 
|                     discount_amount = #{discountAmount}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('orderStatus')"> | 
|                     order_status = #{orderStatus}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('refundCharge')"> | 
|                     refund_charge = #{refundCharge}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('userName')"> | 
|                     user_name = #{userName}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('userTel')"> | 
|                     user_tel = #{userTel}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('remarks')"> | 
|                     remarks = #{remarks}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('shippingMethod')"> | 
|                 shipping_method = #{shippingMethod}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('storeId')"> | 
|                     store_id = #{storeId}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('purchaseQuantity')"> | 
|                     purchase_quantity = #{purchaseQuantity}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('delFlag')"> | 
|                     del_flag = #{delFlag}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('wxOrderNo')"> | 
|                     wx_order_no = #{wxOrderNo}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('payResult')"> | 
|                     pay_result = #{payResult}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('postage')"> | 
|                 postage = #{postage}, | 
|                 </if> | 
|             <if test="true"> | 
|                 update_time  = now(), | 
|             </if> | 
|             <if test="_parameter.containsKey('orderType')"> | 
|                 order_type  = #{orderType}, | 
|             </if> | 
|             <if test="_parameter.containsKey('scorePay')"> | 
|                 score_pay  = #{scorePay}, | 
|             </if> | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update>  | 
|      | 
|      | 
|     <!--  根据对象更新 部分更新   --> | 
|     <update id="updateByModel" parameterType="Integer"> | 
|         UPDATE shop_order | 
|         <set> | 
|             <if test="record.orderNo != null and record.orderNo != '' "> | 
|                 order_no  = #{record.orderNo}, | 
|             </if> | 
|             <if test="record.orderMoney != null "> | 
|                 order_money  = #{record.orderMoney},  | 
|             </if> | 
|             <if test="record.commodityPrice != null "> | 
|                 commodity_price  = #{record.commodityPrice}, | 
|             </if> | 
|             <if test="record.userId != null and record.userId != '' "> | 
|                 user_id  = #{record.userId},  | 
|             </if> | 
|             <if test="record.orderTime != null "> | 
|                 order_time  = #{record.orderTime},  | 
|             </if> | 
|             <if test="record.payStatus != null "> | 
|                 pay_status  = #{record.payStatus},  | 
|             </if> | 
|             <if test="record.discountExplain != null and record.discountExplain != '' "> | 
|                 discount_explain  = #{record.discountExplain},  | 
|             </if> | 
|             <if test="record.discountAmount != null "> | 
|                 discount_amount  = #{record.discountAmount},  | 
|             </if> | 
|             <if test="record.orderStatus != null "> | 
|                 order_status  = #{record.orderStatus},  | 
|             </if> | 
|             <if test="record.refundCharge != null "> | 
|                 refund_charge  = #{record.refundCharge},  | 
|             </if> | 
|             <if test="record.userName != null and record.userName != '' "> | 
|                 user_name  = #{record.userName},  | 
|             </if> | 
|             <if test="record.userTel != null and record.userTel != '' "> | 
|                 user_tel  = #{record.userTel},  | 
|             </if> | 
|             <if test="record.remarks != null and record.remarks != '' "> | 
|                 remarks  = #{record.remarks},  | 
|             </if> | 
|             <if test="record.shippingMethod != null "> | 
|                 shipping_method  = #{record.shippingMethod}, | 
|             </if> | 
|             <if test="record.storeId != null "> | 
|                 store_id  = #{record.storeId},  | 
|             </if> | 
|             <if test="record.purchaseQuantity != null "> | 
|                 purchase_quantity  = #{record.purchaseQuantity},  | 
|             </if> | 
|             <if test="record.delFlag != null "> | 
|                 del_flag  = #{record.delFlag},  | 
|             </if> | 
|             <if test="record.wxOrderNo != null and record.wxOrderNo != '' "> | 
|                 wx_order_no  = #{record.wxOrderNo},  | 
|             </if> | 
|             <if test="record.payResult != null and record.payResult != '' "> | 
|                 pay_result  = #{record.payResult},  | 
|             </if> | 
|             <if test="record.postage != null and record.postage != '' "> | 
|                 postage  = #{record.postage}, | 
|             </if> | 
|             <if test="record.scorePay != null and record.scorePay != '' "> | 
|                 score_pay  = #{record.scorePay}, | 
|             </if> | 
|             <if test="true"> | 
|                 update_time  = now(), | 
|             </if> | 
|   | 
|             <if test="(record.orderType!=null and record.orderType!='') or  (record.orderType!='' and record.orderType==0)  "> | 
|                 order_type  =#{record.orderType}, | 
|             </if> | 
|   | 
|         </set> | 
|         WHERE id=#{record.id}  | 
|     </update> | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from shop_order 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_order | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopOrder"> | 
|         DELETE FROM shop_order | 
|         <where> | 
|         <include refid="where_sql" ></include> | 
|         </where> | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="ShopOrderMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_order | 
|         <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_order | 
|         <where> | 
|            <include refid="where_sql"></include> | 
|         </where> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="ShopOrderMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_order | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据id 锁表查询--> | 
|     <select id="selectForUpdate" resultMap="ShopOrderMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_order | 
|         where  id=#{id}  | 
|         for update | 
|     </select>     | 
|      | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="ShopOrderMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_order | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|     </select> | 
|   | 
|     <!--根据状态查询订单列表--> | 
|     <select id="selectMyOrderByStatus" resultMap="ShopOrderComplexMap"> | 
|         select o.*, | 
|         s.shop_short_name as shop_name | 
|         from shop_order o | 
|         left JOIN sys_shop_info s on o.store_id = s.ID | 
|         where user_id = #{userId} | 
|         and del_flag = 2 | 
|         <if test="params.orderStatus != 0"> | 
|             and order_status = #{params.orderStatus} | 
|         </if> | 
|         order by ${params.sort} ${params.order} | 
|         limit #{params.offset}, #{params.limit} | 
|     </select> | 
|   | 
|     <!--根据ID状态查询订单信息--> | 
|     <select id="selectOrderInfoById" resultMap="ShopOrderComplexMap"> | 
|         select o.*, | 
|         s.shop_name | 
|         from shop_order o | 
|         LEFT JOIN sys_shop_info s on o.store_id = s.ID | 
|         where user_id = #{userId} | 
|         and o.id = #{id} | 
|         and del_flag = 2 | 
|     </select> | 
|   | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPageByQuery" resultMap="ShopOrderComplexMap"> | 
|         select | 
|         o.*, | 
|         s.shop_name | 
|         from shop_order o | 
|         INNER JOIN sys_shop_info s on o.store_id = s.ID | 
|         where del_flag = 2 and o.company_id  = #{record.companyId} | 
|         <if test="record != null"> | 
|             <if test="(record.userTel!=null and record.userTel!='')"> | 
|                 and  o.user_tel like concat('%', #{record.userTel}, '%') | 
|             </if> | 
|             <if test="(record.userName!=null and record.userName!='')"> | 
|                 and o.user_name like concat('%', #{record.userName}, '%') | 
|             </if> | 
|             <if test="(record.orderNo!=null and record.orderNo!='')"> | 
|                 and  o.order_no like concat('%', #{record.orderNo}, '%') | 
|             </if> | 
|             <if test="(record.orderBeginTime!=null and record.orderBeginTime!='')"> | 
|                 and date_format(order_time, '%Y-%m-%d') >= #{record.orderBeginTime} | 
|             </if> | 
|             <if test="(record.orderEndTime!=null and record.orderEndTime!='')"> | 
|                 and  #{record.orderEndTime} >= date_format(o.order_time, '%Y-%m-%d') | 
|             </if> | 
|             <if test="(record.orderStatus!=null and record.orderStatus!='')"> | 
|                 and  o.order_status = #{record.orderStatus} | 
|             </if> | 
|             <if test="(record.storeName!=null and record.storeName!='')"> | 
|                 and s.shop_name like concat('%', #{record.storeName}, '%') | 
|             </if> | 
|             <if test="(record.shopId!=null and record.shopId!='')"> | 
|                 and o.store_id=#{record.shopId} | 
|             </if> | 
|   | 
|   | 
|         </if> | 
|         <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> | 
|   | 
|     <!-- 导出Excel --> | 
|     <select id="selectInPageByQueryOfExcel" resultMap="ShopOrderComplexMap"> | 
|         select | 
|         o.create_by, | 
|         o.create_time, | 
|         o.update_by, | 
|         o.update_time, | 
|         o.id, | 
|         o.order_no, | 
|         o.order_money, | 
|         o.commodity_price, | 
|         o.user_id, | 
|         o.order_time, | 
|         o.pay_status, | 
|         o.discount_explain, | 
|         o.discount_amount, | 
|         o.order_status, | 
|         o.refund_charge, | 
|         o.user_name, | 
|         o.user_tel, | 
|         o.remarks, | 
|         o.shipping_method, | 
|         o.store_id, | 
|         o.purchase_quantity, | 
|         o.del_flag, | 
|         o.wx_order_no, | 
|         o.pay_result, | 
|         o.postage, | 
|                o.pay_method, | 
|         s.shop_name, | 
|         o.order_type | 
|         from shop_order o | 
|         LEFT JOIN sys_shop_info s on o.store_id = s.ID | 
|         where del_flag = 2 and o.company_id  = #{record.companyId} | 
|   | 
|         <if test="record != null"> | 
|             <if test="(record.userTel!=null and record.userTel!='')"> | 
|                 and  o.user_tel like concat('%', #{record.userTel}, '%') | 
|             </if> | 
|             <if test="(record.userName!=null and record.userName!='')"> | 
|                 and o.user_name like concat('%', #{record.userName}, '%') | 
|             </if> | 
|             <if test="(record.orderNo!=null and record.orderNo!='')"> | 
|                 and  o.order_no like concat('%', #{record.orderNo}, '%') | 
|             </if> | 
|             <if test="(record.orderBeginTime!=null and record.orderBeginTime!='')"> | 
|                 and date_format(o.order_time, '%Y-%m-%d') >= #{record.orderBeginTime} | 
|             </if> | 
|             <if test="(record.orderEndTime!=null and record.orderEndTime!='')"> | 
|                 and  #{record.orderEndTime} >= date_format(o.order_time, '%Y-%m-%d') | 
|             </if> | 
|             <if test="(record.orderStatus!=null and record.orderStatus!='')"> | 
|                 and  o.order_status = #{record.orderStatus} | 
|             </if> | 
|             <if test="(record.storeName!=null and record.storeName!='')"> | 
|                 and s.shop_name like concat('%', #{record.storeName}, '%') | 
|             </if> | 
|         </if> | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 查询总条数 --> | 
|     <select id="selectTotalRecordByQuery" resultType="java.lang.Integer"> | 
|         select count(*) | 
|         from shop_order o | 
|         INNER JOIN sys_shop_info s on o.store_id = s.ID | 
|         where del_flag = 2 and o.company_id  = #{record.companyId} | 
|         <if test="record != null"> | 
|             <if test="(record.userTel!=null and record.userTel!='')"> | 
|                 and  o.user_tel like concat('%', #{record.userTel}, '%') | 
|             </if> | 
|             <if test="(record.userName!=null and record.userName!='')"> | 
|                 and o.user_name like concat('%', #{record.userName}, '%') | 
|             </if> | 
|             <if test="(record.orderNo!=null and record.orderNo!='')"> | 
|                 and  o.order_no like concat('%', #{record.orderNo}, '%') | 
|             </if> | 
|             <if test="(record.orderBeginTime!=null and record.orderBeginTime!='')"> | 
|                 and date_format(o.order_time, '%Y-%m-%d') >= #{record.orderBeginTime} | 
|             </if> | 
|             <if test="(record.orderEndTime!=null and record.orderEndTime!='')"> | 
|                 and  #{record.orderEndTime} >= date_format(o.order_time, '%Y-%m-%d') | 
|             </if> | 
|             <if test="(record.orderStatus!=null and record.orderStatus!='')"> | 
|                 and  o.order_status = #{record.orderStatus} | 
|             </if> | 
|             <if test="(record.storeName!=null and record.storeName!='')"> | 
|                 and s.shop_name like concat('%', #{record.storeName}, '%') | 
|             </if> | 
|             <if test="(record.shopId!=null and record.shopId!='')"> | 
|                 and o.store_id=#{record.shopId} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!--根据订单ID查询订单信息--> | 
|     <select id="selectMyOrderById" resultMap="ShopOrderComplexMap"> | 
|         select | 
|         <include refid="columns" ></include> | 
|         from shop_order | 
|         where id = #{orderId} | 
|     </select> | 
|   | 
|     <select id="selectOrdersByIds" resultMap="ShopOrderMap"> | 
|         select * from shop_order a | 
|         inner join sys_shop_info b on a.store_id=b.id | 
|         where a.store_id=#{shopId} | 
|         and a.id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|                  separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </select> | 
|   | 
|     <update id="updateOrderApplyStatus"> | 
|         <foreach collection="list" index="index" item="item" separator=";"> | 
|             update shop_order set apply_status=#{item.applyStatus} | 
|             where id=#{item.id} | 
|         </foreach> | 
|     </update> | 
|   | 
|     <select id="selectShopOrderByApplyId" resultMap="ShopOrderMap"> | 
|         select a.* from shop_order a | 
|         inner join wx_apply_order_relate b on find_in_set(',' + a.id, b.order_ids) | 
|         where b.apply_id=#{applyId} | 
|     </select> | 
|   | 
|     <select id="selectShopOrderInPageByApplyId" resultMap="ShopOrderMap"> | 
|         select a.* from shop_order a | 
|         inner join wx_apply_order_relate b on find_in_set(',' + a.id, b.order_ids) | 
|         where b.apply_id=#{applyId} | 
|         <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="selectShopOrderTotalByApplyId" resultType="java.lang.Integer"> | 
|         select count(1) from shop_order a | 
|         inner join wx_apply_order_relate b on find_in_set(',' + a.id, b.order_ids) | 
|         where b.apply_id=#{applyId} | 
|     </select> | 
|   | 
|     <select id="selectOrderStatusCount"  resultType="java.util.HashMap"  > | 
|         select  count(order_status) as count , order_status as orderStatus | 
|         from shop_order | 
|         where user_id=#{userId} | 
|         group by order_status | 
|     </select> | 
|   | 
|     <select id="selectShopOrderByOrderNo"  resultType="com.matrix.system.shopXcx.bean.ShopOrder"  > | 
|         select | 
|         a.* | 
|         from shop_order a | 
|         where a.order_no=#{orderNo} | 
|     </select> | 
|   | 
|     <update id="batchUpdateOrderStatus"> | 
|         <foreach collection="list" index="index" item="item" separator=";"> | 
|             update shop_order set order_status=#{item.orderStatus} | 
|             where id=#{item.id} | 
|         </foreach> | 
|     </update> | 
| </mapper> |