From 9fd9770b3cabe99d725586e2a3e56b6176b0a1f4 Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Tue, 19 Apr 2022 15:44:10 +0800 Subject: [PATCH] add-plan-out_time_order --- api/controllers/plan/Order.php | 36 +++++++++++++++++++++ api/controllers/plan/Plan.php | 1 + api/controllers/wxapp/licheb/CusorderV2.php | 9 +++--- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php index c505649f..d9f52f26 100644 --- a/api/controllers/plan/Order.php +++ b/api/controllers/plan/Order.php @@ -214,4 +214,40 @@ 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); + } + } } diff --git a/api/controllers/plan/Plan.php b/api/controllers/plan/Plan.php index 7e3d9d48..51be95f5 100644 --- a/api/controllers/plan/Plan.php +++ b/api/controllers/plan/Plan.php @@ -39,6 +39,7 @@ class Plan extends CI_Controller $plan[] = array('url' => base_url(array('plan', 'biz', 'settle')), 'interval' => 1); $plan[] = array('url' => base_url(array('plan', 'order', 'up_old_status')), 'interval' => 30); //更新旧订单状态 + $plan[] = array('url' => base_url(array('plan', 'order', 'order_time')), 'interval' => 10); //未支付订单过期 $this->plan = $plan; } diff --git a/api/controllers/wxapp/licheb/CusorderV2.php b/api/controllers/wxapp/licheb/CusorderV2.php index 743629dc..12b1ae85 100644 --- a/api/controllers/wxapp/licheb/CusorderV2.php +++ b/api/controllers/wxapp/licheb/CusorderV2.php @@ -78,7 +78,8 @@ class CusorderV2 extends Wxapp{ $c_credit = $this->input_param('credit'); $delry_time = $this->input_param('delry_time'); $finance_id = $this->input_param('finance_id'); - $inten_money = floatval($this->input_param('inten_money'));//意向金 + //$inten_money = floatval($this->input_param('inten_money'));//意向金 + $inten_money = 0; $disc_money = floatval($this->input_param('disc_money'));//优惠金额 $disc_fine_money = floatval($this->input_param('disc_fine_money'));//精品优惠金额 $if_fine = $this->input_param('if_fine'); @@ -114,9 +115,9 @@ class CusorderV2 extends Wxapp{ if($deposit<2000){ throw new Exception('定金不得少于2000', ERR_PARAMS_ERROR); } - if($inten_money > $deposit){ - throw new Exception('意向金不得高于定金', ERR_PARAMS_ERROR); - } + //if($inten_money >= $deposit){ + // throw new Exception('意向金不得高于定金', ERR_PARAMS_ERROR); + //} $biz = $this->biz_model->get(['id'=>$row['biz_id']],'city_id,type'); $car_row = $this->auto_cars_model->get(['brand_id'=>$series_row['brand_id'],'s_id'=>$series_row['id'],'v_id'=>$v_id],'',$biz['city_id']);