jsk 消费报表
This commit is contained in:
		
							parent
							
								
									27b5367b09
								
							
						
					
					
						commit
						88c58af55d
					
				| 
						 | 
				
			
			@ -860,48 +860,32 @@
 | 
			
		|||
        ap.area_name AS work_area_name,
 | 
			
		||||
        a.mch_sn
 | 
			
		||||
        FROM (
 | 
			
		||||
        SELECT a.flow_id AS order_id, a.cust_id, a.flow_amount AS payable_amount,
 | 
			
		||||
        a.flow_real_amount AS real_amount, a.pay_time,
 | 
			
		||||
        CASE
 | 
			
		||||
        WHEN bd.canteen_id IS NOT NULL THEN bd.canteen_id
 | 
			
		||||
        WHEN roi.canteen_id IS NOT NULL THEN roi.canteen_id
 | 
			
		||||
        ELSE a.canteen_id END AS canteen_id,
 | 
			
		||||
        CONCAT(a.cust_id,a.ord_time) AS id,
 | 
			
		||||
        a.mch_sn AS mch_sn
 | 
			
		||||
        FROM report_account_flow a
 | 
			
		||||
        select a.flow_id as order_id, a.cust_id,a.flow_amount as  payable_amount,a.flow_real_amount as real_amount,a.pay_time,
 | 
			
		||||
        case when bd.area_id is not null then bd.area_id when ac.area_id is not null then ac.area_id
 | 
			
		||||
        when cdp.dining_place_id is not null then cdp.dining_place_id
 | 
			
		||||
        else a.canteen_id end as area_id,CONCAT(a.cust_id,a.ord_time) as id
 | 
			
		||||
        ,case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id
 | 
			
		||||
        else a.canteen_id end as canteen_id
 | 
			
		||||
        ,a.mch_sn as mch_sn
 | 
			
		||||
        from (select * from report_account_flow a where a.pay_time >= #{vo.startTime} AND a.flow_type IN ( 110, 120,130 )
 | 
			
		||||
        AND a.pay_time <= #{vo.endTime} ) a
 | 
			
		||||
        LEFT JOIN device_info di ON a.mch_sn = di.device_sn
 | 
			
		||||
        LEFT JOIN device_bind bd ON di.device_id = bd.device_id
 | 
			
		||||
        LEFT JOIN report_order_info roi
 | 
			
		||||
        ON CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time)
 | 
			
		||||
        WHERE a.pay_time >= #{vo.startTime}
 | 
			
		||||
        AND a.flow_type IN (110, 120, 130)
 | 
			
		||||
        AND a.pay_time <= #{vo.endTime}
 | 
			
		||||
        AND (a.remark NOT LIKE '%支付' OR a.remark IS NULL)
 | 
			
		||||
 | 
			
		||||
        UNION ALL
 | 
			
		||||
 | 
			
		||||
        SELECT a.flow_id AS order_id, a.cust_id, a.flow_amount AS payable_amount,
 | 
			
		||||
        a.flow_real_amount AS real_amount, a.pay_time, bd.canteen_id,
 | 
			
		||||
        CONCAT(a.cust_id,a.ord_time) AS id,
 | 
			
		||||
        a.mch_sn AS mch_sn
 | 
			
		||||
        FROM report_account_flow a
 | 
			
		||||
        LEFT JOIN device_info di ON a.mch_sn = di.device_sn
 | 
			
		||||
        LEFT JOIN device_bind bd ON di.device_id = bd.device_id
 | 
			
		||||
        WHERE a.pay_time >= #{vo.startTime}
 | 
			
		||||
        AND a.flow_type IN (110, 120, 130)
 | 
			
		||||
        AND a.pay_time <= #{vo.endTime}
 | 
			
		||||
        AND a.remark LIKE '%支付'
 | 
			
		||||
        LEFT JOIN (select * from report_order_info a where a.pay_time >= #{vo.startTime}
 | 
			
		||||
        AND a.pay_time <= #{vo.endTime} ) roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time)
 | 
			
		||||
        LEFT JOIN alloc_canteen ac ON ac.canteen_id = roi.canteen_id
 | 
			
		||||
        left join cust_dining_place cdp on a.cust_id=cdp.cust_id and cdp.type = 'area'
 | 
			
		||||
        ) a
 | 
			
		||||
        LEFT JOIN alloc_canteen ac ON ac.canteen_id = a.canteen_id
 | 
			
		||||
        LEFT JOIN cust_info ci ON ci.cust_id = a.cust_id
 | 
			
		||||
        LEFT JOIN cust_org co ON co.org_id = ci.org_id
 | 
			
		||||
        JOIN cust_dining_place p ON p.cust_id = ci.cust_id AND p.type = 'area'
 | 
			
		||||
        LEFT JOIN alloc_area ar ON ar.area_id = ac.area_id
 | 
			
		||||
        LEFT JOIN alloc_area ar ON ar.area_id = a.area_id
 | 
			
		||||
        LEFT JOIN alloc_area ap ON ap.area_id = p.dining_place_id
 | 
			
		||||
        WHERE ac.area_id != p.dining_place_id
 | 
			
		||||
        WHERE ar.area_id != p.dining_place_id
 | 
			
		||||
        <!-- 判断消费地 -->
 | 
			
		||||
        <if test="vo.selectedOrg != null and vo.selectedOrg.length > 0">
 | 
			
		||||
            AND ac.area_id IN
 | 
			
		||||
            AND ar.area_id IN
 | 
			
		||||
            <foreach collection="vo.selectedOrg" item="id" open="(" separator="," close=")">
 | 
			
		||||
                #{id}
 | 
			
		||||
            </foreach>
 | 
			
		||||
| 
						 | 
				
			
			@ -929,34 +913,29 @@
 | 
			
		|||
        p.dining_place_id
 | 
			
		||||
        FROM (
 | 
			
		||||
        select a.flow_id as order_id, a.cust_id,a.flow_amount as  payable_amount,a.flow_real_amount as real_amount,a.pay_time,
 | 
			
		||||
        case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id
 | 
			
		||||
        else a.canteen_id end as canteen_id,CONCAT(a.cust_id,a.ord_time) as id
 | 
			
		||||
        case when bd.area_id is not null then bd.area_id when ac.area_id is not null then ac.area_id
 | 
			
		||||
        when cdp.dining_place_id is not null then cdp.dining_place_id
 | 
			
		||||
        else a.canteen_id end as area_id,CONCAT(a.cust_id,a.ord_time) as id
 | 
			
		||||
        ,case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id
 | 
			
		||||
        else a.canteen_id end as canteen_id
 | 
			
		||||
        ,a.mch_sn as mch_sn
 | 
			
		||||
        from report_account_flow a
 | 
			
		||||
        from (select * from report_account_flow a where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 )
 | 
			
		||||
        AND a.pay_time <= #{endTime} ) a
 | 
			
		||||
        LEFT JOIN device_info di ON a.mch_sn = di.device_sn
 | 
			
		||||
        LEFT JOIN device_bind bd ON di.device_id = bd.device_id
 | 
			
		||||
        LEFT JOIN report_order_info roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time)
 | 
			
		||||
        where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 )
 | 
			
		||||
        AND a.pay_time <= #{endTime} and (a.remark not like '%支付' or a.remark is null)
 | 
			
		||||
 | 
			
		||||
        UNION ALL
 | 
			
		||||
 | 
			
		||||
        select a.flow_id as order_id, a.cust_id,a.flow_amount as  payable_amount,a.flow_real_amount as real_amount,a.pay_time,bd.canteen_id
 | 
			
		||||
        ,CONCAT(a.cust_id,a.ord_time) as id
 | 
			
		||||
        ,a.mch_sn as mch_sn
 | 
			
		||||
        from report_account_flow a
 | 
			
		||||
        LEFT JOIN device_info di ON a.mch_sn = di.device_sn
 | 
			
		||||
        LEFT JOIN device_bind bd ON di.device_id = bd.device_id
 | 
			
		||||
        where a.pay_time >= #{startTime} 	AND a.flow_type IN ( 110, 120,130 )
 | 
			
		||||
        AND a.pay_time <= #{endTime} and a.remark like '%支付'
 | 
			
		||||
        LEFT JOIN (select * from report_order_info a where a.pay_time >= #{startTime}
 | 
			
		||||
        AND a.pay_time <= #{endTime} ) roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time)
 | 
			
		||||
        LEFT JOIN alloc_canteen ac ON ac.canteen_id = roi.canteen_id
 | 
			
		||||
        left join cust_dining_place cdp on a.cust_id=cdp.cust_id and cdp.type = 'area'
 | 
			
		||||
        ) a
 | 
			
		||||
        LEFT JOIN alloc_canteen ac ON ac.canteen_id = a.canteen_id
 | 
			
		||||
        JOIN cust_info ci ON ci.cust_id = a.cust_id
 | 
			
		||||
        LEFT JOIN alloc_area ar ON ar.area_id = a.area_id
 | 
			
		||||
        JOIN cust_dining_place p ON p.cust_id = ci.cust_id AND p.type = 'area'
 | 
			
		||||
        WHERE ac.area_id != p.dining_place_id
 | 
			
		||||
        WHERE ar.area_id != p.dining_place_id
 | 
			
		||||
        <!-- 判断消费地 -->
 | 
			
		||||
        <if test="selectedOrg != null and selectedOrg.length  > 0">
 | 
			
		||||
            AND ac.area_id IN
 | 
			
		||||
            AND ar.area_id IN
 | 
			
		||||
            <foreach collection="selectedOrg" item="id" open="(" separator="," close=")">
 | 
			
		||||
                #{id}
 | 
			
		||||
            </foreach>
 | 
			
		||||
| 
						 | 
				
			
			@ -994,34 +973,29 @@
 | 
			
		|||
        a.mch_sn
 | 
			
		||||
        FROM (
 | 
			
		||||
        select a.flow_id as order_id, a.cust_id,a.flow_amount as  payable_amount,a.flow_real_amount as real_amount,a.pay_time,
 | 
			
		||||
        case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id
 | 
			
		||||
        else a.canteen_id end as canteen_id,CONCAT(a.cust_id,a.ord_time) as id
 | 
			
		||||
        case when bd.area_id is not null then bd.area_id when ac.area_id is not null then ac.area_id
 | 
			
		||||
        when cdp.dining_place_id is not null then cdp.dining_place_id
 | 
			
		||||
        else a.canteen_id end as area_id,CONCAT(a.cust_id,a.ord_time) as id
 | 
			
		||||
        ,case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id
 | 
			
		||||
        else a.canteen_id end as canteen_id
 | 
			
		||||
        ,a.mch_sn as mch_sn
 | 
			
		||||
        from report_account_flow a
 | 
			
		||||
        from (select * from report_account_flow a where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 )
 | 
			
		||||
        AND a.pay_time <= #{endTime} ) a
 | 
			
		||||
        LEFT JOIN device_info di ON a.mch_sn = di.device_sn
 | 
			
		||||
        LEFT JOIN device_bind bd ON di.device_id = bd.device_id
 | 
			
		||||
        LEFT JOIN report_order_info roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time)
 | 
			
		||||
        where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 )
 | 
			
		||||
        AND a.pay_time <= #{endTime} and (a.remark not like '%支付' or a.remark is null)
 | 
			
		||||
 | 
			
		||||
        UNION ALL
 | 
			
		||||
 | 
			
		||||
        select a.flow_id as order_id, a.cust_id,a.flow_amount as  payable_amount,a.flow_real_amount as real_amount,a.pay_time,bd.canteen_id
 | 
			
		||||
        ,CONCAT(a.cust_id,a.ord_time) as id
 | 
			
		||||
        ,a.mch_sn as mch_sn
 | 
			
		||||
        from report_account_flow a
 | 
			
		||||
        LEFT JOIN device_info di ON a.mch_sn = di.device_sn
 | 
			
		||||
        LEFT JOIN device_bind bd ON di.device_id = bd.device_id
 | 
			
		||||
        where a.pay_time >= #{startTime} 	AND a.flow_type IN ( 110, 120,130 )
 | 
			
		||||
        AND a.pay_time <= #{endTime} and a.remark like '%支付'
 | 
			
		||||
        LEFT JOIN (select * from report_order_info a where a.pay_time >= #{startTime}
 | 
			
		||||
        AND a.pay_time <= #{endTime} ) roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time)
 | 
			
		||||
        LEFT JOIN alloc_canteen ac ON ac.canteen_id = roi.canteen_id
 | 
			
		||||
        left join cust_dining_place cdp on a.cust_id=cdp.cust_id and cdp.type = 'area'
 | 
			
		||||
        ) a
 | 
			
		||||
        LEFT JOIN alloc_canteen ac ON ac.canteen_id = a.canteen_id
 | 
			
		||||
        LEFT JOIN cust_info ci ON ci.cust_id = a.cust_id
 | 
			
		||||
        LEFT JOIN alloc_area ar ON ar.area_id = a.area_id
 | 
			
		||||
        JOIN cust_dining_place p ON p.cust_id = ci.cust_id AND p.type = 'area'
 | 
			
		||||
        WHERE ac.area_id != p.dining_place_id
 | 
			
		||||
        WHERE ar.area_id != p.dining_place_id
 | 
			
		||||
        <!-- 判断消费地 -->
 | 
			
		||||
        <if test="selectedOrg != null and selectedOrg.length  > 0">
 | 
			
		||||
            AND ac.area_id IN
 | 
			
		||||
            AND ar.area_id IN
 | 
			
		||||
            <foreach collection="selectedOrg" item="id" open="(" separator="," close=")">
 | 
			
		||||
                #{id}
 | 
			
		||||
            </foreach>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,48 +34,32 @@
 | 
			
		|||
        ap.area_name AS work_area_name,
 | 
			
		||||
        a.mch_sn
 | 
			
		||||
        FROM (
 | 
			
		||||
        SELECT a.flow_id AS order_id, a.cust_id, a.flow_amount AS payable_amount,
 | 
			
		||||
        a.flow_real_amount AS real_amount, a.pay_time,
 | 
			
		||||
        CASE
 | 
			
		||||
        WHEN bd.canteen_id IS NOT NULL THEN bd.canteen_id
 | 
			
		||||
        WHEN roi.canteen_id IS NOT NULL THEN roi.canteen_id
 | 
			
		||||
        ELSE a.canteen_id END AS canteen_id,
 | 
			
		||||
        CONCAT(a.cust_id,a.ord_time) AS id,
 | 
			
		||||
        a.mch_sn AS mch_sn
 | 
			
		||||
        FROM report_account_flow a
 | 
			
		||||
        select a.flow_id as order_id, a.cust_id,a.flow_amount as  payable_amount,a.flow_real_amount as real_amount,a.pay_time,
 | 
			
		||||
        case when bd.area_id is not null then bd.area_id when ac.area_id is not null then ac.area_id
 | 
			
		||||
        when cdp.dining_place_id is not null then cdp.dining_place_id
 | 
			
		||||
        else a.canteen_id end as area_id,CONCAT(a.cust_id,a.ord_time) as id
 | 
			
		||||
        ,case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id
 | 
			
		||||
        else a.canteen_id end as canteen_id
 | 
			
		||||
        ,a.mch_sn as mch_sn
 | 
			
		||||
        from (select * from report_account_flow a where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 )
 | 
			
		||||
        AND a.pay_time <= #{endTime} ) a
 | 
			
		||||
        LEFT JOIN device_info di ON a.mch_sn = di.device_sn
 | 
			
		||||
        LEFT JOIN device_bind bd ON di.device_id = bd.device_id
 | 
			
		||||
        LEFT JOIN report_order_info roi
 | 
			
		||||
        ON CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time)
 | 
			
		||||
        WHERE a.pay_time >= #{startTime}
 | 
			
		||||
        AND a.flow_type IN (110, 120, 130)
 | 
			
		||||
        AND a.pay_time <= #{endTime}
 | 
			
		||||
        AND (a.remark NOT LIKE '%支付' OR a.remark IS NULL)
 | 
			
		||||
 | 
			
		||||
        UNION ALL
 | 
			
		||||
 | 
			
		||||
        SELECT a.flow_id AS order_id, a.cust_id, a.flow_amount AS payable_amount,
 | 
			
		||||
        a.flow_real_amount AS real_amount, a.pay_time, bd.canteen_id,
 | 
			
		||||
        CONCAT(a.cust_id,a.ord_time) AS id,
 | 
			
		||||
        a.mch_sn AS mch_sn
 | 
			
		||||
        FROM report_account_flow a
 | 
			
		||||
        LEFT JOIN device_info di ON a.mch_sn = di.device_sn
 | 
			
		||||
        LEFT JOIN device_bind bd ON di.device_id = bd.device_id
 | 
			
		||||
        WHERE a.pay_time >= #{startTime}
 | 
			
		||||
        AND a.flow_type IN (110, 120, 130)
 | 
			
		||||
        AND a.pay_time <= #{endTime}
 | 
			
		||||
        AND a.remark LIKE '%支付'
 | 
			
		||||
        LEFT JOIN (select * from report_order_info a where a.pay_time >= #{startTime}
 | 
			
		||||
        AND a.pay_time <= #{endTime} ) roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time)
 | 
			
		||||
        LEFT JOIN alloc_canteen ac ON ac.canteen_id = roi.canteen_id
 | 
			
		||||
        left join cust_dining_place cdp on a.cust_id=cdp.cust_id and cdp.type = 'area'
 | 
			
		||||
        ) a
 | 
			
		||||
        LEFT JOIN alloc_canteen ac ON ac.canteen_id = a.canteen_id
 | 
			
		||||
        LEFT JOIN cust_info ci ON ci.cust_id = a.cust_id
 | 
			
		||||
        LEFT JOIN cust_org co ON co.org_id = ci.org_id
 | 
			
		||||
        JOIN cust_dining_place p ON p.cust_id = ci.cust_id AND p.type = 'area'
 | 
			
		||||
        LEFT JOIN alloc_area ar ON ar.area_id = ac.area_id
 | 
			
		||||
        LEFT JOIN alloc_area ar ON ar.area_id = a.area_id
 | 
			
		||||
        LEFT JOIN alloc_area ap ON ap.area_id = p.dining_place_id
 | 
			
		||||
        WHERE ac.area_id != p.dining_place_id
 | 
			
		||||
        WHERE ar.area_id != p.dining_place_id
 | 
			
		||||
        <!-- 判断消费地 -->
 | 
			
		||||
        <if test="selectedOrg != null and selectedOrg.length > 0">
 | 
			
		||||
            AND ac.area_id IN
 | 
			
		||||
            AND ar.area_id IN
 | 
			
		||||
            <foreach collection="selectedOrg" item="id" open="(" separator="," close=")">
 | 
			
		||||
                #{id}
 | 
			
		||||
            </foreach>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue