123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?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.ydd.module.mapper.ProfitsBillOrderMapper">
- <select id="selectSyncOrderShopId" resultType="java.lang.Long">
- SELECT
- o.shop_id
- FROM
- lb_waimai_order wo
- JOIN lb_order o ON wo.id = o.waimai_order_id
- WHERE
- wo.deleted = 0
- AND o.deleted = 0
- AND o.create_time >= #{startDate}
- AND #{endDate} >= o.create_time
- GROUP BY o.shop_id
- </select>
- <select id="selectListByShopId" resultType="com.ydd.module.dto.BillOrderDto">
- SELECT
- o.order_sn,
- o.shop_id,
- o.delivery_status,
- wo.status,
- wo.order_type
- FROM
- lb_waimai_order wo
- JOIN lb_order o ON wo.id = o.waimai_order_id
- WHERE
- wo.deleted = 0
- AND o.deleted = 0
- AND o.create_time >= #{startDate}
- AND #{endDate} >= o.create_time
- <if test="shopId != null">
- AND o.shop_id= #{shopId}
- </if>
- </select>
- <select id="selectBillOrderByShopId" resultType="com.ydd.module.dto.BillOrderDto">
- SELECT
- wor.shop_id,
- wo.status,
- wo.order_type
- FROM
- lb_waimai_order wo
- RIGHT JOIN lb_waimai_order_record wor ON wo.id = wor.waimai_order_id
- WHERE
- wo.deleted = 0
- AND wor.deleted = 0
- AND wor.create_time >= #{startDate}
- AND #{endDate} >= wor.create_time
- AND wor.shop_id= #{shopId}
- </select>
- <select id="selectBillOrderPage" resultType="com.ydd.module.dto.BillOrderDto">
- SELECT
- b.*
- FROM (
- SELECT
- a.*,
- round( ( a.order_bill_num / a.order_sync_num ), 4 ) * 100 AS orderBillRate,
- round( ( a.order_complete_num / a.order_sync_num ), 4 ) * 100 AS orderCompleteRate
- FROM (
- SELECT
- agent_id,
- merchant_id,
- shop_id,
- SUM(order_sync_num) AS order_sync_num,
- SUM(order_bill_num) AS order_bill_num,
- SUM(order_complete_num) AS order_complete_num
- FROM lb_profits_billOrder
- WHERE 1 = 1
- <if test="params.createStartTime != null and params.createStartTime != ''">
- AND create_time >= #{params.createStartTime}
- </if>
- <if test="params.createEndTime != null and params.createEndTime != ''">
- AND #{params.createEndTime} >= create_time
- </if>
- <if test="params.merchantIds != null and params.merchantIds.size > 0">
- AND
- merchant_id in
- <foreach collection="params.merchantIds" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="params.shopIds != null and params.shopIds.size > 0">
- AND
- shop_id in
- <foreach collection="params.shopIds" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="params.waimaiOrderType != null and params.waimaiOrderType != 4">
- AND order_type = #{params.waimaiOrderType}
- </if>
- GROUP BY
- shop_id
- ) a
- WHERE 1= 1
- <if test="params.startOrderSyncNum != null">
- AND a.order_sync_num >= #{params.startOrderSyncNum}
- </if>
- <if test="params.endOrderSyncNum != null">
- AND #{params.endOrderSyncNum} >= a.order_sync_num
- </if>
- <if test="params.startOrderCompleteRate != null">
- having round( ( a.order_complete_num / a.order_sync_num ), 4 ) * 100 >= #{params.startOrderCompleteRate}
- <if test="params.endOrderCompleteRate != null">
- AND #{params.endOrderCompleteRate} >= round( ( a.order_complete_num / a.order_sync_num ), 4 ) * 100
- </if>
- </if>
- ) b
- </select>
- </mapper>
|