edit | blame | history | raw

queryLatAndLong

SELECT a.*,b.latitude,b.longitude,c.order_status FROM xzx_user_info a 
RIGHT JOIN xzx_user_address_info b ON a.user_id = b.user_id AND b.flag = 1 AND b.del_flag=0
LEFT JOIN xzx_order_info c ON c.create_user_id = b.user_id 
WHERE a.del_flag = 0 GROUP BY a.mobile_phone;

queryPromoterStatis

SELECT x.orderId, x.relaName,x.createTime,
x.nickName, x.orderWeightCount, x.orderMoneyCount from (
    SELECT b.order_id as orderId, b.rela_name as relaName,b.create_time as createTime,
    e.receiver_name as nickName, SUM(c.weight) as orderWeightCount, 
    SUM(c.money) as orderMoneyCount FROM xzx_order_info b 
        LEFT JOIN xzx_order_item_info c ON b.order_id=c.order_id 
            LEFT JOIN xzx_order_detail_info e ON e.order_id=b.order_id 
        WHERE b.order_type=1 AND order_status=5 
        @if(!isEmpty(startTime)){
            AND b.create_time BETWEEN #startTime# AND #endTime#
        @}
        AND create_user_id in (
            SELECT user_id FROM xzx_user_info a WHERE a.mobile_phone IN (
            SELECT mobile FROM xzx_user_target_info x
                    WHERE del_flag=0
                    @if(!isEmpty(userId)){
                        AND x.real_user_id=#userId#
                    @}
                 AND regster_type=3 
            )
        ) GROUP BY b.order_id ORDER BY b.create_user_id 
) x 
@if(!isEmpty(orderWeightCount)){
    where x.orderWeightCount >= #orderWeightCount#
@}
    limit #page#, #limit#

queryPromoterStatisCount

SELECT count(*) from (
    SELECT y.order_id from (
        SELECT b.order_id,SUM(c.weight) as orderWeightCount FROM xzx_order_info b 
        LEFT JOIN xzx_order_item_info c ON b.order_id=c.order_id 
        LEFT JOIN xzx_order_detail_info e ON e.order_id=b.order_id 
        WHERE b.order_type=1 AND order_status=5 
        @if(!isEmpty(startTime)){
            AND b.create_time BETWEEN #startTime# AND #endTime#
        @}
        AND create_user_id in (
            SELECT user_id FROM xzx_user_info a WHERE a.mobile_phone IN (
            SELECT mobile FROM xzx_user_target_info x
                    WHERE del_flag=0
                    @if(!isEmpty(userId)){
                        AND x.real_user_id=#userId#
                    @}
                 AND regster_type=3 
            )
        ) GROUP BY b.order_id ORDER BY b.create_user_id
    ) y 
    @if(!isEmpty(orderWeightCount)){
        where y.orderWeightCount >= #orderWeightCount#
    @}
) as x

queryQromoterOrder

SELECT x.orderId, x.relaName,x.createTime,
x.nickName, x.orderWeightCount, x.orderMoneyCount,x.completeTime from (
    SELECT b.order_id as orderId, b.rela_name as relaName,b.create_time as createTime,
    e.receiver_name as nickName, SUM(c.weight) as orderWeightCount, 
    SUM(c.money) as orderMoneyCount,e.complete_time as completeTime  FROM xzx_order_info b 
        LEFT JOIN xzx_order_item_info c ON b.order_id=c.order_id 
            LEFT JOIN xzx_order_detail_info e ON e.order_id=b.order_id 
        WHERE b.order_type=1 AND order_status in (4,5,7)
        @if(!isEmpty(startTime)){
            AND e.complete_time BETWEEN #startTime# AND #endTime#
        @}
        AND create_user_id in (
            SELECT user_id FROM xzx_user_info a WHERE a.mobile_phone IN (
            SELECT mobile FROM xzx_user_target_info x
                    WHERE del_flag=0
                    @if(!isEmpty(userId)){
                        AND x.real_user_id=#userId#
                    @}
                 AND regster_type=3 
            )
        ) GROUP BY b.order_id 
         @if(!isEmpty(sortType)){
             ORDER BY b.create_time asc limit #orderNumSort#
         @}
) x 
@if(!isEmpty(orderWeightCount)){
    where x.orderWeightCount >= #orderWeightCount#
@}
    @if(!isEmpty(sortType)){
       ORDER BY x.createTime desc limit 1
    @} 
    @if(isEmpty(sortType)){
       limit #page#, #limit#    
    @} 

queryQromoterOrderCount

SELECT count(*) from (
    SELECT y.order_id from (
        SELECT b.order_id,SUM(c.weight) as orderWeightCount FROM xzx_order_info b 
        LEFT JOIN xzx_order_item_info c ON b.order_id=c.order_id 
        LEFT JOIN xzx_order_detail_info e ON e.order_id=b.order_id 
        WHERE b.order_type=1 AND order_status in (4,5,7)
           @if(!isEmpty(startTime)){
               AND e.complete_time BETWEEN #startTime# AND #endTime#
           @}
        AND create_user_id in (
            SELECT user_id FROM xzx_user_info a WHERE a.mobile_phone IN (
            SELECT mobile FROM xzx_user_target_info x
                    WHERE del_flag=0
                    @if(!isEmpty(userId)){
                        AND x.real_user_id=#userId#
                    @}
                 AND regster_type=3 
            )
        ) GROUP BY b.order_id 
                   @if(!isEmpty(sortType)){
                         ORDER BY b.create_time asc limit #orderNumSort#
                   @}
    ) y 
    @if(!isEmpty(orderWeightCount)){
        where y.orderWeightCount >= #orderWeightCount#
    @}
) as x

queryQromoterOrderOne

SELECT x.orderId, x.relaName,x.createTime, x.nickName, x.orderWeightCount, x.orderMoneyCount,x.completeTime ,x.createUserId
from
      ( SELECT b.order_id as orderId, b.rela_name as relaName,b.create_time as createTime, e.receiver_name as nickName, SUM(c.weight) as orderWeightCount,
          SUM(c.money) as orderMoneyCount,e.complete_time as completeTime,b.create_user_id as createUserId 
         FROM xzx_order_info b 
       LEFT JOIN xzx_order_item_info c ON b.order_id=c.order_id 
       LEFT JOIN xzx_order_detail_info e ON e.order_id=b.order_id 
       WHERE b.order_type=1 AND b.order_status in (4,5,7)
         @if(!isEmpty(startTime)){
                       AND b.create_time >= #startTime# AND #endTime#
         @}
         @if(!isEmpty(endTime)){
                                    AND b.create_time<= #endTime#
                      @}
         AND b.create_user_id in ( SELECT user_id FROM xzx_user_info a 
                                 WHERE a.mobile_phone IN 
                                  ( SELECT mobile FROM xzx_user_target_info x 
                                    WHERE del_flag=0
                                    @if(!isEmpty(userId)){
                                        AND x.real_user_id=#userId#
                                    @}
                                    AND regster_type=3 ) ) 
       GROUP BY b.create_user_id,b.order_id
       ORDER BY b.create_time asc limit 0, 10000) x  
       @if(!isEmpty(orderWeightCount)){
           where x.orderWeightCount >= #orderWeightCount#
       @}
       ORDER BY x.createUserId,x.createTime asc