diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php index 8adc586b..4d19854c 100644 --- a/api/controllers/plan/Order.php +++ b/api/controllers/plan/Order.php @@ -141,36 +141,36 @@ class Order extends CI_Controller{ //更新旧订单数据状态 public function up_old_status(){ -// $size = $this->input->get('size'); -// !$size && $size = 20; -// -// $t1 = 'lc_receiver_orders_v2'; -// $t2 = 'lc_receiver_orders'; -// -// $fields = "$t1.*"; -// $where = [ -// "$t1.id<" => 10000, -// "$t1.status" => 0, -// "$t2.status" => 6 -// ]; -// -// $this->db->from("$t1"); -// $this->db->join("$t2", "$t2.id=$t1.id",'left'); -// -// $this->db->select($fields); -// $this->db->where($where); -// $this->db->order_by("$t1.id asc"); -// $this->db->limit($size); -// $rows = $this->db->get()->result_array(); -// if($rows){ -// foreach($rows as $key=>$val){ -// $res = $this->receiver_orders_v2_model->update(['status'=>1],['id'=>$val['id']]); -// $str = "更新订单状态:{$val['id']}"; -// debug_log($str,$this->log_file,$this->log_dir); -// } -// }else{ -// echo "no data"; -// } + $size = $this->input->get('size'); + !$size && $size = 20; + + $t1 = 'lc_receiver_orders_v2'; + $t2 = 'lc_receiver_orders'; + + $fields = "$t1.*"; + $where = [ + "$t1.id<" => 10000, + "$t1.status" => 0, + "$t2.status" => 6 + ]; + + $this->db->from("$t1"); + $this->db->join("$t2", "$t2.id=$t1.id",'left'); + + $this->db->select($fields); + $this->db->where($where); + $this->db->order_by("$t1.id asc"); + $this->db->limit($size); + $rows = $this->db->get()->result_array(); + if($rows){ + foreach($rows as $key=>$val){ + $res = $this->receiver_orders_v2_model->update(['status'=>1],['id'=>$val['id']]); + $str = "更新订单状态:{$val['id']}"; + debug_log($str,$this->log_file,$this->log_dir); + } + }else{ + echo "no data"; + } } public function up_order_time(){ @@ -220,38 +220,38 @@ class Order extends CI_Controller{ //过期未支付订单 public function out_time(){ -// if(time()<=strtotime('2022-04-20 00:00:00')){ //2022-4-20后开始执行 -// exit; -// } -// $s_time = date('Y-m-d 00:00:00',strtotime("-1 day"));//昨天开始时间 -// $e_time = date('Y-m-d 23:59:59',strtotime("-1 day"));//昨天结束时间 -// -// $last_id_key = "out_time_receiver_order_id"; -// $redis = &load_cache(); -// $last_id = $redis->get($last_id_key); -// -// $where = [ -// 'c_time<=' => strtotime($e_time), -// 'c_time>=' => strtotime($s_time), -// 'status' => 0 -// ]; -// -// $last_id && $where['id>'] = $last_id; -// $rows = $this->receiver_orders_v2_model->select($where,'id asc',1,30); -// if($rows){ -// foreach($rows as $key=>$val){ -// $if_pay = $this->app_liche_orders_model->count(['o_id'=>$val['id'],'status'=>1]); -// if(!$if_pay){ //不存在已支付订单 -// $this->receiver_orders_v2_model->update(['status'=>-1],['id'=>$val['id']]); -// $this->app_liche_orders_model->update(['status'=>-1],['o_id'=>$val['id']]); -// debug_log("订单过期:".$val['id'],$this->log_file,$this->log_dir); -// } -// $do_last_id = $val['id']; -// } -// $redis->save($last_id_key,$do_last_id,2*24*60*60); -// }else{ -// debug_log("订单过期执行完毕",$this->log_file,$this->log_dir); -// } + if(time()<=strtotime('2022-04-20 00:00:00')){ //2022-4-20后开始执行 + exit; + } + $s_time = date('Y-m-d 00:00:00',strtotime("-1 day"));//昨天开始时间 + $e_time = date('Y-m-d 23:59:59',strtotime("-1 day"));//昨天结束时间 + + $last_id_key = "out_time_receiver_order_id"; + $redis = &load_cache(); + $last_id = $redis->get($last_id_key); + + $where = [ + 'c_time<=' => strtotime($e_time), + 'c_time>=' => strtotime($s_time), + 'status' => 0 + ]; + + $last_id && $where['id>'] = $last_id; + $rows = $this->receiver_orders_v2_model->select($where,'id asc',1,30); + if($rows){ + foreach($rows as $key=>$val){ + $if_pay = $this->app_liche_orders_model->count(['o_id'=>$val['id'],'status'=>1]); + if(!$if_pay){ //不存在已支付订单 + $this->receiver_orders_v2_model->update(['status'=>-1],['id'=>$val['id']]); + $this->app_liche_orders_model->update(['status'=>-1],['o_id'=>$val['id']]); + debug_log("订单过期:".$val['id'],$this->log_file,$this->log_dir); + } + $do_last_id = $val['id']; + } + $redis->save($last_id_key,$do_last_id,2*24*60*60); + }else{ + debug_log("订单过期执行完毕",$this->log_file,$this->log_dir); + } } //更新bd