add-plan-up_ins_img
This commit is contained in:
+358
-290
@@ -20,329 +20,397 @@ class Order extends CI_Controller{
|
||||
}
|
||||
|
||||
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']}<br>";
|
||||
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']}<br>";
|
||||
}else{
|
||||
echo "执行失败:{$val['id']}<br>";
|
||||
}
|
||||
}
|
||||
|
||||
$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}<br>";
|
||||
}
|
||||
// $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']}<br>";
|
||||
// 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']}<br>";
|
||||
// }else{
|
||||
// echo "执行失败:{$val['id']}<br>";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// $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}<br>";
|
||||
// }
|
||||
}
|
||||
|
||||
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']}<br>";
|
||||
}else{
|
||||
echo "undo o_id:{$val['id']}<br>";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo 'finish';
|
||||
}
|
||||
// $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']}<br>";
|
||||
// }else{
|
||||
// echo "undo o_id:{$val['id']}<br>";
|
||||
// }
|
||||
// }
|
||||
// }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";
|
||||
}
|
||||
// $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(){
|
||||
$size = $this->input->get('size');
|
||||
!$size && $size = 20;
|
||||
|
||||
$t1 = 'lc_receiver_order_status';
|
||||
$t2 = 'lc_receiver_orders_v2';
|
||||
|
||||
$fields = "$t2.*";
|
||||
$where = [
|
||||
"$t1.pid_status" => 0,
|
||||
"$t1.status" => 1,
|
||||
"$t2.id>=" => 10000,
|
||||
"$t2.order_time" => '0000-00-00 00:00:00',
|
||||
];
|
||||
|
||||
$this->db->from("$t1");
|
||||
$this->db->join("$t2", "$t2.id=$t1.o_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){
|
||||
$where = [
|
||||
'o_id'=>$val['id'],
|
||||
'status'=>1,
|
||||
"pay_time <>" => '0000-00-00 00:00:00',
|
||||
];
|
||||
$pay_row = $this->app_liche_orders_model->select($where,'pay_time asc',1,1);
|
||||
if($pay_row){
|
||||
$order_time = $pay_row[0]['pay_time'];
|
||||
$res = $this->receiver_orders_v2_model->update(['order_time'=>$order_time],['id'=>$val['id']]);
|
||||
echo "订单id:{$val['id']},更新{$res}<br>";
|
||||
}else{
|
||||
echo "订单id:{$val['id']},未找到支付订单<br>";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo "no data";
|
||||
}
|
||||
// $size = $this->input->get('size');
|
||||
// !$size && $size = 20;
|
||||
//
|
||||
// $t1 = 'lc_receiver_order_status';
|
||||
// $t2 = 'lc_receiver_orders_v2';
|
||||
//
|
||||
// $fields = "$t2.*";
|
||||
// $where = [
|
||||
// "$t1.pid_status" => 0,
|
||||
// "$t1.status" => 1,
|
||||
// "$t2.id>=" => 10000,
|
||||
// "$t2.order_time" => '0000-00-00 00:00:00',
|
||||
// ];
|
||||
//
|
||||
// $this->db->from("$t1");
|
||||
// $this->db->join("$t2", "$t2.id=$t1.o_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){
|
||||
// $where = [
|
||||
// 'o_id'=>$val['id'],
|
||||
// 'status'=>1,
|
||||
// "pay_time <>" => '0000-00-00 00:00:00',
|
||||
// ];
|
||||
// $pay_row = $this->app_liche_orders_model->select($where,'pay_time asc',1,1);
|
||||
// if($pay_row){
|
||||
// $order_time = $pay_row[0]['pay_time'];
|
||||
// $res = $this->receiver_orders_v2_model->update(['order_time'=>$order_time],['id'=>$val['id']]);
|
||||
// echo "订单id:{$val['id']},更新{$res}<br>";
|
||||
// }else{
|
||||
// echo "订单id:{$val['id']},未找到支付订单<br>";
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// echo "no data";
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
//过期未支付订单
|
||||
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
|
||||
public function car_img(){
|
||||
$oid = $this->input->get('oid');
|
||||
$page = $this->input->get('page');
|
||||
$size = $this->input->get('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
$where = [
|
||||
"ins_img <> ''" => null,
|
||||
"o_id>=" => 1000,
|
||||
];
|
||||
$oid && $where['o_id'] = $oid;
|
||||
$rows = $this->receiver_order_datas_model->select($where,'id asc',$page,$size);
|
||||
if($rows){
|
||||
foreach ($rows as $item) {
|
||||
$res = $this->order_datas_entity->orc_ins_img($item['o_id']);
|
||||
echo "{$item['o_id']}执行结果:{$res}";
|
||||
}
|
||||
}else{
|
||||
echo "no data";
|
||||
}
|
||||
// $oid = $this->input->get('oid');
|
||||
// $page = $this->input->get('page');
|
||||
// $size = $this->input->get('size');
|
||||
// !$page && $page = 1;
|
||||
// !$size && $size = 10;
|
||||
// $where = [
|
||||
// "ins_img <> ''" => null,
|
||||
// "o_id>=" => 1000,
|
||||
// ];
|
||||
// $oid && $where['o_id'] = $oid;
|
||||
// $rows = $this->receiver_order_datas_model->select($where,'id asc',$page,$size);
|
||||
// if($rows){
|
||||
// foreach ($rows as $item) {
|
||||
// $res = $this->order_datas_entity->orc_ins_img($item['o_id']);
|
||||
// echo "{$item['o_id']}执行结果:{$res}";
|
||||
// }
|
||||
// }else{
|
||||
// echo "no data";
|
||||
// }
|
||||
}
|
||||
//车型车牌号码
|
||||
public function up_num(){
|
||||
$oid = $this->input->get('oid');
|
||||
// $oid = $this->input->get('oid');
|
||||
// $page = $this->input->get('page');
|
||||
// $size = $this->input->get('size');
|
||||
// !$page && $page = 1;
|
||||
// !$size && $size = 10;
|
||||
// $where = [
|
||||
// "car_img <> ''" => null,
|
||||
// "o_id>=" => 1000,
|
||||
// ];
|
||||
// $oid && $where['o_id'] = $oid;
|
||||
// $rows = $this->receiver_order_datas_model->select($where,'id asc',$page,$size);
|
||||
// if($rows){
|
||||
// foreach ($rows as $item) {
|
||||
// $res = $this->order_datas_entity->up_car_num($item['o_id']);
|
||||
// echo "{$item['o_id']}执行结果:{$res}";
|
||||
// }
|
||||
// }else{
|
||||
// echo "no data";
|
||||
// }
|
||||
}
|
||||
//更新交付截止时间
|
||||
public function up_otime(){
|
||||
// $this->load->model('auto/auto_business_model');
|
||||
// $page = $this->input->get('page');
|
||||
// $size = $this->input->get('size');
|
||||
// !$page && $page = 1;
|
||||
// !$size && $size = 20;
|
||||
//
|
||||
// $where = [
|
||||
// 'id>=' => 10000,
|
||||
// ];
|
||||
// $rows = $this->receiver_orders_v2_model->select($where,'id asc',$page,$size);
|
||||
// if($rows){
|
||||
// foreach($rows as $key => $val){
|
||||
// $car_json = json_decode($val['car_json'],true);
|
||||
// $info_json = json_decode($val['info_json'],true);
|
||||
// $business_id = $info_json['business_id'];
|
||||
// $over_time = '0000-00-00 00:00:00';
|
||||
// if($business_id){
|
||||
// $business_row = $this->auto_business_model->get(['id'=>$business_id]);
|
||||
//
|
||||
// if($business_row['delivery_day']){
|
||||
// $contract = $this->receiver_order_contracts_model->get(['o_id' => $val['id'],'type in (0,1)' => null]);
|
||||
// $s_time = $contract ? $contract['c_time'] : $val['c_time'];
|
||||
// $over_time = date('Y-m-d H:i:s',$s_time+$business_row['delivery_day']*24*60*60); //交付截止时间
|
||||
// }
|
||||
//
|
||||
// $car_json['delivery_day'] = $business_row['delivery_day'];
|
||||
// }
|
||||
// $update = [
|
||||
// 'car_json' => json_encode($car_json,JSON_UNESCAPED_UNICODE)
|
||||
// ];
|
||||
// $over_time && $update['over_time'] = $over_time;
|
||||
// if($val['main_type']==1){
|
||||
// $update['owner_name'] = $info_json['c_company'];
|
||||
// }
|
||||
// if($update){
|
||||
// $this->receiver_orders_v2_model->update($update,['id'=>$val['id']]);
|
||||
// echo "update id:".$val['id']."<br>";
|
||||
// }else{
|
||||
// echo "not update id:".$val['id']."<br>";
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// echo 'finish';
|
||||
// }
|
||||
}
|
||||
|
||||
//更新保险图片
|
||||
public function up_ins_img(){
|
||||
$redis = load_cache('redis');
|
||||
$this->load->library('qiniuorc');
|
||||
$page = $this->input->get('page');
|
||||
$size = $this->input->get('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
$c_key = "TEMP_ORDER_INSIMG_LAST_ID";
|
||||
$where = [
|
||||
"car_img <> ''" => null,
|
||||
"ins_img <> ''" => null,
|
||||
"insurance_img" => null,
|
||||
"business_img" => null,
|
||||
"o_id>=" => 1000,
|
||||
];
|
||||
$oid && $where['o_id'] = $oid;
|
||||
$rows = $this->receiver_order_datas_model->select($where,'id asc',$page,$size);
|
||||
if($rows){
|
||||
foreach ($rows as $item) {
|
||||
$res = $this->order_datas_entity->up_car_num($item['o_id']);
|
||||
echo "{$item['o_id']}执行结果:{$res}";
|
||||
}
|
||||
}else{
|
||||
echo "no data";
|
||||
$last_id = $redis->get($c_key);
|
||||
if($this->input->get('last_id')){
|
||||
echo $last_id;exit;
|
||||
}
|
||||
}
|
||||
//更新交付截止时间
|
||||
public function up_otime(){
|
||||
$this->load->model('auto/auto_business_model');
|
||||
$page = $this->input->get('page');
|
||||
$size = $this->input->get('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 20;
|
||||
|
||||
$where = [
|
||||
'id>=' => 10000,
|
||||
];
|
||||
$rows = $this->receiver_orders_v2_model->select($where,'id asc',$page,$size);
|
||||
if($rows){
|
||||
foreach($rows as $key => $val){
|
||||
$car_json = json_decode($val['car_json'],true);
|
||||
$info_json = json_decode($val['info_json'],true);
|
||||
$business_id = $info_json['business_id'];
|
||||
$over_time = '0000-00-00 00:00:00';
|
||||
if($business_id){
|
||||
$business_row = $this->auto_business_model->get(['id'=>$business_id]);
|
||||
|
||||
if($business_row['delivery_day']){
|
||||
$contract = $this->receiver_order_contracts_model->get(['o_id' => $val['id'],'type in (0,1)' => null]);
|
||||
$s_time = $contract ? $contract['c_time'] : $val['c_time'];
|
||||
$over_time = date('Y-m-d H:i:s',$s_time+$business_row['delivery_day']*24*60*60); //交付截止时间
|
||||
if($last_id){
|
||||
$where['id<'] = $last_id;
|
||||
}
|
||||
$count = $this->receiver_order_datas_model->count($where);
|
||||
$rows = $this->receiver_order_datas_model->select($where,'id desc',$page,$size,'id,o_id,ins_img,insurance_img,business_img,jsondata');
|
||||
if(!$rows){
|
||||
echo "finish";
|
||||
}
|
||||
foreach ($rows as $key => $val) {
|
||||
$ins_img = json_decode($val['ins_img'],true);
|
||||
$jsondata = json_decode($val['jsondata'],true);
|
||||
$ins_info = $jsondata['ins_info'] ? $jsondata['ins_info'] : [];
|
||||
$update = $business_img = $insurance_img = [];
|
||||
if(is_array($ins_info)){
|
||||
$new_ins_img = [];
|
||||
foreach ($ins_img as $k => $v) {
|
||||
$img_url = build_qiniu_image_url($v);
|
||||
$ins_key = md5($img_url);
|
||||
$o_ins_info = $ins_info[$ins_key]['data'];
|
||||
if(count($o_ins_info['投保险种'])>3 && !$business_img){ //商业险
|
||||
$business_img['img'] = $v;
|
||||
$business_img['date'] = $o_ins_info['投保确认时间'];
|
||||
$business_img['price'] = floatval($o_ins_info['合计保费']);
|
||||
$business_img['product'] = $o_ins_info['保险公司'];
|
||||
$update['business_img'] = json_encode($business_img,JSON_UNESCAPED_UNICODE);
|
||||
}elseif(count($o_ins_info['投保险种'])==3 && !$insurance_img){ //强制险
|
||||
$insurance_img['img'] = $v;
|
||||
$insurance_img['date'] = $o_ins_info['投保确认时间'];
|
||||
$insurance_img['price'] = floatval($o_ins_info['合计保费']);
|
||||
$insurance_img['product'] = $o_ins_info['保险公司'];
|
||||
$update['insurance_img'] = json_encode($insurance_img,JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$new_ins_img[] = $v;
|
||||
}
|
||||
|
||||
$car_json['delivery_day'] = $business_row['delivery_day'];
|
||||
}
|
||||
$update = [
|
||||
'car_json' => json_encode($car_json,JSON_UNESCAPED_UNICODE)
|
||||
];
|
||||
$over_time && $update['over_time'] = $over_time;
|
||||
if($val['main_type']==1){
|
||||
$update['owner_name'] = $info_json['c_company'];
|
||||
}
|
||||
if($update){
|
||||
$this->receiver_orders_v2_model->update($update,['id'=>$val['id']]);
|
||||
echo "update id:".$val['id']."<br>";
|
||||
}else{
|
||||
echo "not update id:".$val['id']."<br>";
|
||||
}
|
||||
$update['ins_img'] = json_encode($new_ins_img,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}else{
|
||||
echo 'finish';
|
||||
if($business_img && $insurance_img){
|
||||
$this->receiver_order_datas_model->update($update,['id'=>$val['id']]);
|
||||
}
|
||||
$last_id = $val['id'];
|
||||
$update_str = json_encode($update,JSON_UNESCAPED_UNICODE);
|
||||
echo "自增id:{$last_id},订单id:{$val['o_id']},更新数据:{$update_str}<br>";
|
||||
}
|
||||
$redis->save($c_key,$last_id,24*60*60);
|
||||
$left = $count-$size;
|
||||
echo "剩余:{$left}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user