|
@@ -46,52 +46,77 @@
|
46
|
46
|
t.hotel_name,
|
47
|
47
|
IFNULL( s.share_num, 0 ) AS share_num,
|
48
|
48
|
IFNULL( s.customer_num, 0 ) AS customer_num,
|
49
|
|
- IFNULL( s.visit_num, 0 ) AS visit_num,
|
50
|
|
- SUM( IF ( m.track_id IS NULL, 0, 1 ) ) AS recommend_num,
|
|
49
|
+ IFNULL( m.visit_num, 0 ) AS visit_num,
|
|
50
|
+ IFNULL( n.recommend_num, 0 ) AS recommend_num,
|
51
|
51
|
SUM( IFNULL( l.amount, 0 ) ) AS commission_charge
|
52
|
52
|
FROM
|
53
|
53
|
ta_hotel t
|
54
|
|
- LEFT JOIN (
|
55
|
|
- SELECT
|
56
|
|
- a.hotel_id,
|
57
|
|
- COUNT( DISTINCT a.room_order_id ) AS share_num,
|
58
|
|
- COUNT( DISTINCT b.customer_phone ) AS customer_num,
|
59
|
|
- SUM( IF ( c.track_id IS NULL, 0, 1 ) ) AS visit_num
|
60
|
|
- FROM
|
61
|
|
- ta_room_order a
|
62
|
|
- INNER JOIN ta_room_order_person b ON b.room_order_id = a.room_order_id
|
63
|
|
- LEFT JOIN tr_person_page c ON c.page = '/pages/index/index'
|
64
|
|
- AND c.params LIKE CONCAT( '%', 'roomOrderId=', a.room_order_id, '%' )
|
65
|
|
- WHERE
|
66
|
|
- 1 = 1
|
67
|
|
- <if test="startDate != null">
|
68
|
|
- AND a.create_date >= #{startDate}
|
69
|
|
- AND c.create_date >= #{startDate}
|
70
|
|
- </if>
|
71
|
|
- <if test="endDate != null">
|
72
|
|
- AND a.create_date <= #{endDate}
|
73
|
|
- AND c.create_date <= #{endDate}
|
74
|
|
- </if>
|
75
|
|
- GROUP BY
|
76
|
|
- a.hotel_id
|
|
54
|
+ LEFT JOIN (
|
|
55
|
+ SELECT
|
|
56
|
+ a.hotel_id,
|
|
57
|
+ COUNT( DISTINCT a.room_order_id ) AS share_num,
|
|
58
|
+ COUNT( DISTINCT b.customer_phone ) AS customer_num
|
|
59
|
+ FROM
|
|
60
|
+ ta_room_order a
|
|
61
|
+ INNER JOIN ta_room_order_person b ON b.room_order_id = a.room_order_id
|
|
62
|
+ WHERE 1 = 1
|
|
63
|
+ <if test="startDate != null and startDate != ''">
|
|
64
|
+ AND DATE_FORMAT( a.create_date, '%Y-%m-%d' ) >= #{startDate}
|
|
65
|
+ </if>
|
|
66
|
+ <if test="endDate != null and endDate != ''">
|
|
67
|
+ AND DATE_FORMAT( a.create_date, '%Y-%m-%d' ) <= #{endDate}
|
|
68
|
+ </if>
|
|
69
|
+ GROUP BY
|
|
70
|
+ a.hotel_id
|
77
|
71
|
) s ON s.hotel_id = t.hotel_id
|
78
|
|
- LEFT JOIN tr_person_click m ON m.event_type = 'hotel_recommend_package'
|
79
|
|
- AND m.event_params LIKE CONCAT( '%', 'hotelId=', t.hotel_id, '%' )
|
80
|
|
- LEFT JOIN ta_hotel_account_log l ON l.hotel_id = t.hotel_id
|
81
|
|
- AND l.amount_type = 'commission'
|
|
72
|
+ LEFT JOIN (
|
|
73
|
+ SELECT
|
|
74
|
+ a.statis_param AS hotel_param,
|
|
75
|
+ COUNT( 1 ) AS visit_num
|
|
76
|
+ FROM
|
|
77
|
+ ts_page_event_daily a
|
|
78
|
+ WHERE
|
|
79
|
+ a.page_name = 'hotel_guide'
|
|
80
|
+ <if test="startDate != null and startDate != ''">
|
|
81
|
+ AND a.statis_date >= #{startDate}
|
|
82
|
+ </if>
|
|
83
|
+ <if test="endDate != null and endDate != ''">
|
|
84
|
+ AND a.statis_date <= #{endDate}
|
|
85
|
+ </if>
|
|
86
|
+ GROUP BY
|
|
87
|
+ a.statis_param
|
|
88
|
+ ) m ON m.hotel_param = CONCAT( 'hotel_id=', t.hotel_id )
|
|
89
|
+ LEFT JOIN (
|
|
90
|
+ SELECT
|
|
91
|
+ SUBSTRING_INDEX( a.statis_param, <![CDATA['&']]>, 2 ) AS hotel_param,
|
|
92
|
+ COUNT( 1 ) AS recommend_num
|
|
93
|
+ FROM
|
|
94
|
+ ts_page_event_daily a
|
|
95
|
+ WHERE
|
|
96
|
+ a.page_name = 'hotel_recommend'
|
|
97
|
+ <if test="startDate != null and startDate != ''">
|
|
98
|
+ AND a.statis_date >= #{startDate}
|
|
99
|
+ </if>
|
|
100
|
+ <if test="endDate != null and endDate != ''">
|
|
101
|
+ AND a.statis_date <= #{endDate}
|
|
102
|
+ </if>
|
|
103
|
+ GROUP BY
|
|
104
|
+ SUBSTRING_INDEX( a.statis_param, <![CDATA['&']]>, 2 )
|
|
105
|
+ ) n ON n.hotel_param = CONCAT( 'hotelId=', t.hotel_id )
|
|
106
|
+ LEFT JOIN ta_hotel_account_log l ON l.hotel_id = t.hotel_id
|
|
107
|
+ AND l.amount_type = 'commission'
|
82
|
108
|
WHERE
|
83
|
109
|
t.`status` > - 1
|
84
|
110
|
<if test="hotelName != null and hotelName != ''">
|
85
|
111
|
AND t.hotel_name LIKE CONCAT( '%', #{hotelName}, '%' )
|
86
|
112
|
</if>
|
87
|
113
|
<if test="startDate != null">
|
88
|
|
- AND m.create_date >= #{startDate}
|
89
|
|
- AND l.create_date >= #{startDate}
|
|
114
|
+ AND DATE_FORMAT( l.create_date, '%Y-%m-%d' ) >= #{startDate}
|
90
|
115
|
</if>
|
91
|
116
|
<if test="endDate != null">
|
92
|
|
- AND m.create_date <= #{endDate}
|
93
|
|
- AND l.create_date <= #{endDate}
|
|
117
|
+ AND DATE_FORMAT( l.create_date, '%Y-%m-%d' ) <= #{endDate}
|
94
|
118
|
</if>
|
|
119
|
+
|
95
|
120
|
GROUP BY
|
96
|
121
|
t.hotel_id
|
97
|
122
|
ORDER BY
|