From 08f600cf84d036d5de6b80c5c33bbc81fbfb0fc1 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Sat, 26 Mar 2022 00:46:43 +0800 Subject: [PATCH] edit-admin-robot --- admin/controllers/receiver/orderv2/Orders.php | 7 +- api/controllers/plan/Xzcall.php | 12 +++- common/libraries/Qyrobot.php | 65 ++++++++++++++----- 3 files changed, 64 insertions(+), 20 deletions(-) diff --git a/admin/controllers/receiver/orderv2/Orders.php b/admin/controllers/receiver/orderv2/Orders.php index 861beb98..ce1c4957 100644 --- a/admin/controllers/receiver/orderv2/Orders.php +++ b/admin/controllers/receiver/orderv2/Orders.php @@ -694,7 +694,12 @@ class Orders extends HD_Controller $descrip && $data['descrip'] = $descrip; $this->app_liche_orders_model->add($data); if($this->app_liche_orders_model->count(['status'=>1,'o_id'=>$row['id']])==1 && $money>=100){ //企业微信推送 - $this->qyrobot->deposit_notify_v2($row['id']); + if(date('Y-m-d',strtotime($pay_time))==date('Y-m-d')){ //当天 + $this->qyrobot->deposit_notify_v2($row['id']); + }else{ + $this->qyrobot->deposit_notify_v2($row['id'],1,$data['pay_time']); + } + } $where = [ 'status'=>1, diff --git a/api/controllers/plan/Xzcall.php b/api/controllers/plan/Xzcall.php index 314b47ff..5edb5fd4 100644 --- a/api/controllers/plan/Xzcall.php +++ b/api/controllers/plan/Xzcall.php @@ -170,11 +170,21 @@ class Xzcall extends HD_Controller { $o_id = $this->input->get('id'); $test = $this->input->get('test'); + $type = $this->input->get('type'); + $pay_time = $this->input->get('pay_time'); if ($o_id) { $params = []; $test && $params['test'] = 1; $this->load->library('qyrobot',$params); - $robot_res = $this->qyrobot->deposit_notify_v2($o_id); + if($type){ + if(!$pay_time){ + die('pay_time:不能为空'); + } + + $robot_res = $this->qyrobot->deposit_notify_v2($o_id,1,$pay_time); + }else{ + $robot_res = $this->qyrobot->deposit_notify_v2($o_id); + } var_dump($robot_res); } } diff --git a/common/libraries/Qyrobot.php b/common/libraries/Qyrobot.php index 68341427..b256f69f 100644 --- a/common/libraries/Qyrobot.php +++ b/common/libraries/Qyrobot.php @@ -112,9 +112,11 @@ class Qyrobot{ /** * 新订单支付后推送消息 * @param $oid + * @param int $type type=0 当天 type=1 补报 + * @param string $date 日期type=1必填 * @return mixed */ - public function deposit_notify_v2($oid){ + public function deposit_notify_v2($oid, $type=0, $date=''){ $this->ci->load->model('receiver/order/receiver_orders_v2_model'); $this->ci->load->model("biz/biz_model"); $this->ci->load->model('area_model'); @@ -167,15 +169,27 @@ class Qyrobot{ $car_info = "{$brand_row['name']} {$series_row['name']} {$v_name} {$cor_name}"; $min_price = 100; - $today_s_time = date('Y-m-d 00:00:00'); - $sql = "select count(*) as total from (select min(pay_time) as pay_time,min(pay_price) as pay_price from lc_app_liche_orders - where o_id>=10000 and status=1 and pid!=0 and pay_time!='0000-00-00 00:00:00' group by o_id order by o_id desc)a - where pay_price>{$min_price} and pay_time>='{$today_s_time}'"; + if($type){ + if(!$date){ + return false; + } + $today_s_time = date('Y-m-d 00:00:00',strtotime($date)); + $today_e_time = date('Y-m-d 23:59:59',strtotime($date)); + $month_s_time = date('Y-m-01 00:00:00',strtotime($date)); + $month_e_time = date('Y-m-t 23:59:59',strtotime($date)); + }else{ + $today_s_time = date('Y-m-d 00:00:00'); + $today_e_time = date('Y-m-d H:i:s'); + $month_s_time = date('Y-m-01 00:00:00'); + $month_e_time = date('Y-m-t H:i:s'); + } + $sql = "select count(*) as total from (select min(pay_time) as pay_time from lc_app_liche_orders + where o_id>=10000 and status=1 and pid!=0 and pay_price>0 and pay_time!='0000-00-00 00:00:00' and pay_price>{$min_price} group by o_id order by o_id desc)a + where pay_time>='{$today_s_time}' and pay_time<='{$today_e_time}'"; $today_query = $this->ci->db->query($sql)->row_array(); - $month_s_time = date('Y-m-01 00:00:00'); - $sql = "select count(*) as total from (select min(pay_time) as pay_time,min(pay_price) as pay_price from lc_app_liche_orders - where o_id>=10000 and status=1 and pid!=0 and pay_time!='0000-00-00 00:00:00' group by o_id order by o_id desc)a - where pay_price>{$min_price} and pay_time>='{$month_s_time}'"; + $sql = "select count(*) as total from (select min(pay_time) as pay_time from lc_app_liche_orders + where o_id>=10000 and status=1 and pid!=0 and pay_price>0 and pay_time!='0000-00-00 00:00:00' and pay_price>{$min_price} group by o_id order by o_id desc)a + where pay_time>='{$month_s_time}' and pay_time<='{$month_e_time}'"; $month_query = $this->ci->db->query($sql)->row_array(); $today_count = $today_query['total']; $month_count = $month_query['total']; @@ -187,15 +201,17 @@ class Qyrobot{ 'pay_price>=' => 100, 'o_id<' => 10000, ]; - $where["pay_time>="] = date('Y-m-d 00:00:00'); + $where["pay_time>="] = $today_s_time; + $where["pay_time<="] = $today_e_time; $old_today_count = $this->ci->app_liche_orders_model->count($where);//今日成交订单数 - $where['pay_time>='] = date('Y-m-01 00:00:00'); + $where["pay_time>="] = $month_s_time; + $where["pay_time<="] = $month_e_time; $old_month_count = $this->ci->app_liche_orders_model->count($where);//本月成交订单数 //意向金等于定金的支付订单 - $sql = "select count(*) as total from lc_app_liche_orders as a left join lc_receiver_orders as b on a.o_id=b.id where a.total_price=b.deposit and a.type=4 and a.status=1 and a.pay_price>=50 and a.pay_time>='".date('Y-m-d 00:00:00')."'"; + $sql = "select count(*) as total from lc_app_liche_orders as a left join lc_receiver_orders as b on a.o_id=b.id where a.total_price=b.deposit and a.type=4 and a.status=1 and a.pay_price>=50 and a.pay_time>='{$today_s_time}' and a.pay_time<='{$today_e_time}'"; $old_today_query = $this->ci->db->query($sql)->row_array(); - $sql = "select count(*) as total from lc_app_liche_orders as a left join lc_receiver_orders as b on a.o_id=b.id where a.total_price=b.deposit and a.type=4 and a.status=1 and a.pay_price>=50 and a.pay_time>='".date('Y-m-01 00:00:00')."'"; + $sql = "select count(*) as total from lc_app_liche_orders as a left join lc_receiver_orders as b on a.o_id=b.id where a.total_price=b.deposit and a.type=4 and a.status=1 and a.pay_price>=50 and a.pay_time>='{$month_s_time}' and a.pay_time<='{$month_e_time}'"; $old_month_query = $this->ci->db->query($sql)->row_array(); $old_today_query['total'] && $old_today_count += $old_today_query['total']; $old_month_query['total'] && $old_month_count += $old_month_query['total']; @@ -206,14 +222,27 @@ class Qyrobot{ $url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key='.$this->key; $this->ci->load->library('mycurl'); - $data = [ - 'msgtype' => 'markdown', - 'markdown' => [ - 'content' => "🎉🎉🎉 **喜讯** 🎉🎉🎉 \n + if(!$type){ + $content = "🎉🎉🎉 **喜讯** 🎉🎉🎉 \n 恭喜 {$biz_info} 成交 {$car_info} 一台。\n >本日累计成交: {$today_count} 单 >本月累计成交: {$month_count} 单\n - ### 狸车加油,冲冲冲!💪🏻💪🏻💪🏻" + ### 狸车加油,冲冲冲!💪🏻💪🏻💪🏻"; + }else{ + $day = date('d日',strtotime($date)); + $m_day = date('m月d日',strtotime($date)); + $month = date('m',strtotime($date)); + $month_show = $month==date('m') ? '本月' : $month.'月'; + $content = "🎉🎉🎉 **喜讯-补报** 🎉🎉🎉 \n + 恭喜 {$biz_info} {$day}成交 {$car_info} 一台。\n + >{$m_day}累计成交: {$today_count} 单 + >{$month_show}累计成交: {$month_count} 单\n + ### 狸车加油,冲冲冲!💪🏻💪🏻💪🏻"; + } + $data = [ + 'msgtype' => 'markdown', + 'markdown' => [ + 'content' => $content ] ]; $res = $this->ci->mycurl->httpPost($url,$data,'is_json');