From eade31060adb34b67cf9926e50bdd1aa0b86fa37 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 7 Sep 2022 11:14:16 +0800 Subject: [PATCH] edit-api-mycar --- api/controllers/wxapp/liche/User.php | 77 ++++++++++++++++++---------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/api/controllers/wxapp/liche/User.php b/api/controllers/wxapp/liche/User.php index 2f3cd9fc..41ee8f89 100644 --- a/api/controllers/wxapp/liche/User.php +++ b/api/controllers/wxapp/liche/User.php @@ -386,8 +386,10 @@ class User extends Wxapp{ $count = $this->receiver_orders_v2_model->count($where); $lists = []; if($count){ + $this->load->library('receiver/orders_v2_entity'); $this->load->model("items/items_model"); $this->load->model('receiver/order/receiver_order_agents_model','agents_model'); + $this->load->model('receiver/order/receiver_order_datas_model'); $rows = $this->receiver_orders_v2_model->select($where,'id desc',$page,$size); //品牌车型 $brand_arr = array_unique(array_column($rows,'brand_id')); @@ -395,40 +397,60 @@ class User extends Wxapp{ //车系车型 $series_arr = array_unique(array_column($rows,'s_id')); $series = $this->auto_series_model->get_map_by_ids($series_arr,'id,name'); - foreach($rows as $key=>$val){ $item = $this->items_model->get(['id'=>$val['item_id']],'vin'); - $agent = $this->agents_model->get(['o_id'=>$val['id']]); $color = $this->auto_attr_model->get(['id'=>$val['cor_id']],'title,jsondata'); + $car_img = $ins_img = []; + $platenumber = $ins_company = $insure = ''; + if($val['id']>=Orders_v2_entity::V2_START_ID){ + $order_data = $this->receiver_order_datas_model->get(['o_id'=>$val['id']]); + $jsondata = json_decode($order_data['jsondata'],true); + $jsondata['car_info']['PlateNo'] && $platenumber = $jsondata['car_info']['PlateNo']; + if($order_data['car_img']){ + $car_img[] = build_qiniu_image_url($order_data['car_img']); + } + if($order_data['insurance_img'] || $order_data['business_img']){ + $insurance_img = json_decode($order_data['insurance_img'],true); + $business_img = json_decode($order_data['business_img'],true); + $insurance_img['img'] && $ins_img[] = build_qiniu_image_url($insurance_img['img']); + $ins_company = $business_img['product']; + if($business_img['img']){ + $business_url = build_qiniu_image_url($business_img['img']); + $ins_img[] = $business_url; + $business_info = $jsondata['ins_info'][md5($business_url)]; + $insure = $business_info['data']['投保日期'] ? $business_info['data']['投保日期'] : ''; + } + } + }else{ + $agent = $this->agents_model->get(['o_id'=>$val['id']]); + $agent['car_num'] && $platenumber = $agent['car_num']; + $insure = $agent['ins_time'] ? date('Y.m.d',strtotime($agent['ins_time'])):''; + $agent['car_img'] && $car_img[] = build_qiniu_image_url($agent['car_img']); + if($agent['ins_img']){ + $ins_imgs = json_decode($agent['ins_img']); + foreach($ins_imgs as $k =>$v){ + $ins_img[] = build_qiniu_image_url($v); + } + } + } + $other[] = [ + 'icon'=>'icon-hangshizheng', + 'title'=>'行驶证', + 'img'=> $car_img + ]; + $other[] = [ + 'icon'=>'icon-baodan', + 'title'=>'保单', + 'img'=> $ins_img + ]; + $color && $color['jsondata'] = json_decode($color['jsondata'],true); - $agent['ins_time'] = $agent['ins_time'] ? date('Y.m.d',strtotime($agent['ins_time'])):''; $brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : ''; $serie_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : ''; - $car_img = []; - if($agent['car_img']){ - $car_img[] = build_qiniu_image_url($agent['car_img']); - } - $ins_img = []; - if($agent['ins_img']){ - $ins_imgs = json_decode($agent['ins_img']); - foreach($ins_imgs as $key =>$val){ - $ins_img[] = build_qiniu_image_url($val); - } - } - $other[] = [ - 'icon'=>'icon-hangshizheng', - 'title'=>'行驶证', - 'img'=> $car_img - ]; - $other[] = [ - 'icon'=>'icon-baodan', - 'title'=>'保单', - 'img'=> $ins_img - ]; - $lists[] = [ + 'o_id' => $val['id'], 'title' => "{$brand_name}{$serie_name}", 'model' => [ 'title' => $color['title'], @@ -436,8 +458,9 @@ class User extends Wxapp{ 'color' => $color['jsondata']['code'] ], 'vincode' => "车架号 {$item['vin']}", - 'platenumber' => $agent['car_num'], - 'insure' => "{$agent['ins_time']}到期", + 'platenumber' => $platenumber, + 'ins_company' => $ins_company, + 'insure' => $insure, 'other' => $other ]; }