select
            a.*,
            b.id item_id,
            b.order_id,
            b.goods_id,
            b.sku_id,
            b.goods_name,
            b.style_name,
            b.sku_name,
            b.sku_image,
            b.cnt,
            b.price,
            b.amount
        from mall_order_info a
        inner join mall_order_item b on a.id=b.order_id
        
            a.del_flag=2
            
                and a.status in (5,6)
             
            
                and a.status = #{record.status}
             
            
                and a.status = 7
             
            
                and a.member_id=#{record.memberId}
             
            
                and a.order_type=#{record.orderType}
             
            
                and a.delivery_type=#{record.deliveryType}
             
            
                and a.take_unique_code=#{record.takeUniqueCode}
             
         
        order by a.created_time desc
     
    
        select
            a.*,
            b.goods_name from mall_order_info a
                          inner join mall_order_item b on a.id=b.order_id where a.member_id=#{memberId} and a.id=#{id}
     
    
        select a.*,
               b.name memberName,
               b.bind_phone memberBindPhone,
               b.phone memberPhone
        from mall_order_info a
        left join mall_member b on a.member_id = b.id
        
            
                
                    and a.pay_result = #{record.payResult}
                 
                
                    and a.order_type = #{record.orderType}
                 
                
                    and a.status = #{record.status}
                 
                
                    and a.delivery_type = #{record.deliveryType}
                 
                
                    and a.is_home = #{record.isHome}
                 
                
                    and a.order_no like CONCAT('%', CONCAT(#{record.orderNo}, '%'))
                 
                
                    and b.name like CONCAT('%', CONCAT(#{record.name}, '%'))
                 
                
                    and a.take_unique_code = #{record.uniqueCode}
                 
                
                    and a.order_time >= #{record.startTime}
                 
                
                    and a.order_time <= #{record.endTime}
                 
             
         
        GROUP BY a.id  order by a.created_time desc
     
    
        select * from mall_order_info where id = #{id}
     
    
        
             
     
    
        select
               a.*
        from mall_order_info a
        inner join mall_order_item b on a.id=b.order_id
        
            a.del_flag=2
            
                and a.member_id=#{record.memberId}
             
            
                and a.status = 4
             
            
                and a.status = #{record.status}
             
            
                and a.status = 7 or b.state in (2,3)
             
            
                and (b.goods_name like CONCAT('%', CONCAT(#{record.query}, '%')) or b.style_name like CONCAT('%', CONCAT(#{record.query}, '%')) or b.sku_name like CONCAT('%', CONCAT(#{record.query}, '%')))
             
            
                and a.order_type=#{record.orderType}
             
         
        order by a.created_time desc
     
    
        select
            a.*,
            b.id item_id,
            b.order_id,
            b.goods_id,
            b.sku_id,
            b.goods_name,
            b.style_name,
            b.sku_name,
            b.sku_image,
            b.state,
            b.cnt,
            b.price,
            b.amount,
            b.is_normal
        from mall_order_info a
             inner join mall_order_item b on a.id=b.order_id
        where a.id=#{id}
     
    
        select
            a.status,
            count(1) cnt
        from mall_order_info a
        where a.del_flag=2 and a.member_id=#{memberId}
        group by a.status
     
    
        select a.*,b.area addressArea,b.address addressInfo from mall_order_info a
        left join mall_address_info b on a.address_id = b.id
        where a.id = #{id}
     
    
        select * from mall_order_item where order_id = #{id}
     
    
        select * from mall_order_info where status=#{status}
     
    
        select * from mall_order_info where status=#{status} and now() > date_add(order_time,interval 1440 minute)
     
    
        select IFNULL(count(1), 0) from mall_order_info a
          inner join mall_member b on a.member_id=b.ID
        
            a.status in (2,3,4)
            
                and b.referrer_id=#{inviteId}
             
            
                and find_in_set(#{inviteId}, b.referrer_ids)
             
         
     
    
        select count(1) from (
        select a.invite_id, count(1)
        from mall_member a
           inner join mall_order_info b on a.ID=b.member_id
        where a.referrer_id=#{inviteId} and b.status in (2,3,4)
        group by a.invite_id
         ) a
     
    
        select IFNULL(sum(IFNULL(amount,0)),0) from mall_order_info
        where member_id=#{memberId} and status in (2, 3, 4) and order_type=1
     
    
        select IFNULL(sum(IFNULL(amount,0)),0) from mall_order_info
        where status = 4
        
            and member_id=#{memberId}
         
        
            and date_format(a.receiving_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')
         
     
    
        select IFNULL(sum(IFNULL(b.amount,0) - IFNULL(b.cost_price*b.cnt, 0)),0)
        from mall_order_info a
        inner join mall_order_item b on a.id=b.order_id
        where a.order_type=1
        
            and a.status in (2, 3, 4) and b.is_normal = 2 and b.has_settle=1
         
        
            and a.status=4 and b.is_normal = 1 and b.has_settle=1
         
        
            and member_id=#{memberId}
         
        
            and date_format(a.pay_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')
         
        
            and date_format(a.pay_time, '%Y-%m') = date_format(#{date}, '%Y-%m')
         
        
            and date_format(a.pay_time, '%Y') = date_format(#{date}, '%Y')
         
     
    
        select * from mall_order_info where order_no=#{orderNo}
     
    
        update mall_order_info
        set status=4,
            receiving_time=#{updateTime}
        where status=3 and date_format(pay_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')
     
    
        select * from mall_order_info a
        inner join mall_order_item b on a.id=b.order_id and b.is_normal=1
        where date_format(pay_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')
     
    
        select IFNULL(sum(IFNULL(amount,0)),0) from mall_order_info
        where pay_method = #{payMethod} and status = #{statue}
     
    
        update mall_order_info
        set status = #{orderState},
            delivery_state = #{deliveryState}
        where id = #{orderId}
     
    
        select
            status,
            count(1) cnt
        from mall_order_info
        where del_flag = 2 and take_unique_code = #{uniqueCode}
        group by status
     
    
        select * from mall_order_info where status=#{status}
         and date_format(pay_time, '%Y-%m-%d') = date_format(#{paytime}, '%Y-%m-%d')
     
    
         
    
        select
        a.*
        from mall_order_info a
        
            a.del_flag=2
            
                and a.member_id=#{record.memberId}
             
            
                and a.status = 4
             
            
                and a.status = #{record.status}
             
            
                and a.status = 7 or b.state in (2,3)
             
            
                and a.order_type=#{record.orderType}
             
         
        order by a.created_time desc
     
    
        select * from mall_order_info where id = #{orderId} and take_unique_code = #{takeUniqueCode}
     
    
        select
        a.*,
        b.goods_name,
        b.sku_name,
        b.cnt,
        b.price,
        b.amount
        from mall_order_info a
        inner join mall_order_item b on a.id=b.order_id
        where a.del_flag=2 and  a.id = #{orderId}
        order by a.created_time desc
     
    
    select
        goods_name goodsName,
        SUM(cnt) goodsCnt
    from mall_order_item
    
    1=1
        
            and order_id in
                
                    #{id}
                 
         
     
        GROUP BY goods_id
        ORDER BY goods_id desc