diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php index 9885e0ae..b4f74709 100644 --- a/api/controllers/plan/Order.php +++ b/api/controllers/plan/Order.php @@ -221,13 +221,13 @@ class Order extends CI_Controller{ /** * Notes:向飞书发送小狸播报 - * https://liche-api-dev.xiaoyu.com/plan/order/send_aggs_biz_ding_piao_rpt?sd=1 + * https://liche-api-dev.xiaoyu.com/plan/order/send_aggs_biz_ding_piao_rpt?sd=1&debug=1 * https://api.liche.cn/plan/order/send_aggs_biz_ding_piao_rpt */ public function send_aggs_biz_ding_piao_rpt(){ $params = $this->input->get(); $hour = date('H.i'); - $test = false; + $test = $params['debug'] ? true : false; if ( !($hour >= 23.00 && $hour <= 23.10 || $params['sd'])) { return false; } diff --git a/common/libraries/receiver/Orders_v2_entity.php b/common/libraries/receiver/Orders_v2_entity.php index 4156dfe8..4dd70d64 100644 --- a/common/libraries/receiver/Orders_v2_entity.php +++ b/common/libraries/receiver/Orders_v2_entity.php @@ -907,7 +907,7 @@ class Orders_v2_entity{ } $sql = " SELECT b.city_id as biz_type, - if(b.type in (2, 3), b.type, o.biz_id) as biz_id, + case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end as biz_id, o.brand_id, if(ab.`name` is null, '-', ab.`name`) as brand_name, o.s_id, if(s.`name` is null, '-', s.`name`) as series_name, count(if(o.order_time >= '$today_start' AND o.order_time < '$today_end', o.id, null)) as doc_ding_today, count(o.id) as doc_ding @@ -919,8 +919,8 @@ class Orders_v2_entity{ WHERE o.`status` >= 0 AND o.order_time >= '$total_start' AND o.order_time < '$total_end' AND b.type in (1, 2, 3) - group by b.city_id, if(b.type in (2, 3), b.type, o.biz_id), o.brand_id, ab.`name`, o.s_id, s.`name` - order by b.city_id, FIELD(b.type,1,2,3), if(b.type in (2, 3), b.type, o.biz_id), o.brand_id, o.s_id + group by b.city_id, case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end, o.brand_id, ab.`name`, o.s_id, s.`name` + order by b.city_id, FIELD(b.type,1,2,3), case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end, o.brand_id, o.s_id "; return $this->ci->db->query($sql)->result_array(); } @@ -983,7 +983,7 @@ class Orders_v2_entity{ } $sql = " SELECT b.city_id as biz_type, - if(b.type in (2, 3), b.type, o.biz_id) as biz_id, + case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end as biz_id, o.brand_id, ab.`name` as brand_name, o.s_id, s.`name` as series_name, count(if(o.bill_time >= '$today_start' AND o.bill_time < '$today_end', o.id, null)) as doc_piao_today, count(o.id) as doc_piao @@ -998,8 +998,8 @@ class Orders_v2_entity{ AND o.brand_id > 0 AND o.`status` <> 2 AND b.type in (1, 2, 3) - group by b.city_id, if(b.type in (2, 3), b.type, o.biz_id), o.brand_id, ab.`name`, o.s_id, s.`name` - order by b.city_id, FIELD(b.type,1,2,3), if(b.type in (2, 3), b.type, o.biz_id), o.brand_id, o.s_id + group by b.city_id, case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end, o.brand_id, ab.`name`, o.s_id, s.`name` + order by b.city_id, FIELD(b.type,1,2,3), case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end, o.brand_id, o.s_id "; return $this->ci->db->query($sql)->result_array(); } @@ -1155,8 +1155,8 @@ class Orders_v2_entity{ ( SELECT b.city_id as biz_type, c.`name` as city_name, - if(b.type in (2, 3), b.type, o.biz_id) as biz_id, - case when b.type=2 then '合伙店' when b.type=3 then '渠道店' else b.biz_name end as biz_name, + case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end as biz_id, + case when b.type=2 then '合伙店' when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then '东风店渠道'when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then '哪吒店渠道' when b.type=3 then '渠道店' else b.biz_name end as biz_name, count(if(o.order_time >= '$today_start' AND o.order_time < '$today_end', o.id, null)) as doc_ding_today, count(o.id) as doc_ding, null as doc_piao_today, null as doc_piao FROM lc_receiver_orders_v2 o @@ -1165,12 +1165,12 @@ class Orders_v2_entity{ WHERE o.`status` >= 0 AND o.order_time >= '$total_start' AND o.order_time < '$total_end' AND b.type in (1, 2, 3) - group by b.city_id, c.`name`, if(b.type in (2, 3), b.type, o.biz_id), case when b.type=2 then '合伙店' when b.type=3 then '渠道店' else b.biz_name end + group by b.city_id, c.`name`, case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end, case when b.type=2 then '合伙店' when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then '东风店渠道'when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then '哪吒店渠道' when b.type=3 then '渠道店' else b.biz_name end union all SELECT b.city_id as biz_type, c.`name` as city_name, - if(b.type in (2, 3), b.type, o.biz_id) as biz_id, - case when b.type=2 then '合伙店' when b.type=3 then '渠道店' else b.biz_name end as biz_name, + case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end as biz_id, + case when b.type=2 then '合伙店' when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then '东风店渠道'when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then '哪吒店渠道' when b.type=3 then '渠道店' else b.biz_name end as biz_name, null as doc_ding_today, null as doc_ding, count(if(o.bill_time >= '$today_start' AND o.bill_time < '$today_end', o.id, null)) as doc_piao_today, count(o.id) as doc_piao @@ -1183,7 +1183,7 @@ class Orders_v2_entity{ AND o.brand_id > 0 AND o.`status` <> 2 AND b.type in (1, 2, 3) - group by b.city_id, c.`name`, if(b.type in (2, 3), b.type, o.biz_id), case when b.type=2 then '合伙店' when b.type=3 then '渠道店' else b.biz_name end + group by b.city_id, c.`name`, case when b.type = 2 then b.type when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then b.type when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then 4 when b.type = 3 then b.type else o.biz_id end, case when b.type=2 then '合伙店' when b.type = 3 and b.city_id = 350200 and b.id in (73,78,110,171) then '东风店渠道'when b.type = 3 and b.city_id = 350200 and b.id not in (73,78,110,171) then '哪吒店渠道' when b.type=3 then '渠道店' else b.biz_name end ) u group by biz_type, city_name, biz_id, biz_name order by biz_type, biz_id desc