load->model('receiver/order/receiver_orders_model'); $this->load->model('receiver/order/receiver_orders_v2_model'); $this->load->model('receiver/order/receiver_order_status_model'); $this->load->model('app/liche/app_liche_orders_model'); } public function index(){ $size = $this->input->get('size'); !$size && $size = 5; $t1 = 'lc_receiver_orders'; $t2 = 'lc_receiver_orders_v2'; $fields = "$t1.*"; $where = [ "$t1.status>=" => 0, "$t2.id is null" => null ]; $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){ echo "执行old_id:{$val['id']}
"; if($val['status']==7){ $status = 2; }elseif($val['status']==6){ $status = 1; }else{ $status = 0; } $money_json = json_decode($val['money_json'],true); !$money_json['price_book'] && $money_json['price_book'] = $val['deposit']; $data = [ 'id' => $val['id'], 'sid' => $val['sid'], 'clue_id' => $val['clue_id'], 'customer_id' => $val['rid'], 'name' => $val['name'], 'mobile' => $val['mobile'], 'main_type' => $val['main_type'], 'payway' => $val['payway'], 'finance_id' => $val['finance_id'], 'srv_ids' => $val['srv_ids'], 'fines' => $val['fine_ids'], 'brand_id' => $val['brand_id'], 's_id' => $val['s_id'], 'v_id' => $val['v_id'], 'cor_id' => $val['cor_id'], 'incor_id' => $val['incor_id'], 'item_id' => $val['item_id'], 'biz_id' => $val['biz_id'], 'sale_id' => $val['admin_id'], 'info_json' => $val['info_json'], 'car_json' => $val['car_json'], 'money_json' => $val['money_json'], 'jsondata' => $val['jsondata'], 'delry_time' => $val['delry_time'], 'order_time' => $val['order_time'], 'bill_time' => $val['bill_time'], 'c_time' => $val['c_time'], 'u_time' => $val['u_time'], 'status' => $status ]; $res = $this->receiver_orders_v2_model->add($data); if($res){ echo "执行成功:{$val['id']}
"; }else{ echo "执行失败:{$val['id']}
"; } } $where = [ "$t1.status>=" => 0, "$t2.id is null" => null ]; $this->db->from("$t1"); $this->db->join("$t2", "$t2.id=$t1.id",'left'); $this->db->select($fields); $this->db->where($where); $res = $this->db->count_all_results(); echo "剩余:{$res}
"; } } public function up_pay_status(){ $page = $this->input->get('page'); $size = $this->input->get('size'); !$page && $page = 1; !$size && $size = 20; $where = [ 'id>=' => 10000, 'status>=' => 0 ]; $rows = $this->receiver_orders_v2_model->select($where,'id asc',$page,$size); if($rows){ foreach($rows as $key => $val){ $if_pay = $this->app_liche_orders_model->count(['o_id'=>$val['id'],'status'=>1]); $s_row = $this->receiver_order_status_model->count(['o_id'=>$val['id'],'pid_status'=>0,'status'=>1]); if($if_pay && !$s_row){ $data = [ 'o_id' => $val['id'], 'pid_status' => 0, 'status' => 1, 'c_time' => time() ]; $res = $this->receiver_order_status_model->add($data); echo "update o_id:{$val['id']}
"; }else{ echo "undo o_id:{$val['id']}
"; } } }else{ echo 'finish'; } } //更新旧订单数据状态 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"; } } }