客户查询详情页

dev
zhaocheng 5 years ago
parent 3366f57c9f
commit c522e4a0f9
  1. 112
      common/libs/MyLib.php
  2. 28
      frontend/controllers/CarController.php
  3. 64
      frontend/controllers/InsurerController.php
  4. 323
      frontend/views/insurer/info.php

@ -8,6 +8,8 @@
namespace common\libs;
use common\models\PriceT;
/**
* Description of MyLib
*
@ -279,4 +281,114 @@ class MyLib {
return $result;
}
/**
* 批量处理信息
* @param $type
* @param $data1
* @param null $data2
* @return array
*/
public static function GetInfosResponse($type, $data1, $data2 = null)
{
switch ($type){
case 'car': // $data1=>$car_info
$funcname = 'GetCarInfoResponse';break;
case 'order': // $data1=>$orders_info
$funcname = 'GetOrderInfoResponse';break;
case 'insurer_type': // $data1=>$insurer_types_info, $data2=>$order_id
$funcname = 'GetInsurerTypeInfoResponse';break;
case 'gift': // $data1=>$order_gifts_info
$funcname = 'GetGiftInfoResponse';break;
case 'history': // $data1=>$car_log_info
$funcname = 'GetCarLogResponse';break;
}
$infos = [];
foreach ($data1 as $item){
$infos[] = self::$funcname($item,$data2);
}
return $infos;
}
/**
* 处理车辆信息(将id字段转换为对应文本)
* @param $car_info @结果集
* @return array
*/
public static function GetCarInfoResponse($car_info)
{
$car_info_arr = $car_info->toArray();
$car_info_arr['brand_txt'] = $car_info->brand ? $car_info->brand->name : '';
$car_info_arr['car_type_txt'] = $car_info->carType ? $car_info->carType->name : '';
$car_info_arr['car_use_txt'] = $car_info->carUse ? $car_info->carUse->name : '';
$car_info_arr['car_use_txt'] = $car_info->carUse ? $car_info->carUse->name : '';
$car_info_arr['series_txt'] = $car_info->series ? $car_info->series->name : '';
$car_info_arr['displacement_txt'] = $car_info->displacement ? $car_info->displacement->name : '';
$car_info_arr['location_txt'] = $car_info->location == 3 ? '本区' : ($car_info->location == 6 ? '外区' : '未知');
return $car_info_arr;
}
/**
* 处理订单信息(将id字段转换为对应文本)
* @param $order_info @结果集
* @return array
*/
public static function GetOrderInfoResponse($order_info)
{
$order_info_arr = $order_info->toArray();
$order_info_arr['business_group_name'] = $order_info->businessGroup ? $order_info->businessGroup->name : '';
$order_info_arr['company_name'] = $order_info->company ? $order_info->company->name : '';
$order_info_arr['pay_type_txt'] = ($order_info->shoufei_id?MyLib::zhifufs($order_info->shoufei_id).'-':'').($order_info->payType?$order_info->payType->name:'');
$order_info_arr['payee_name'] = $order_info->payee_id?$order_info->payee->name:'';
$order_info_arr['payer_name'] = $order_info->payer? MyLib::payers($order_info->payer):'';
$order_info_arr['payment_name'] = $order_info->payment_id?$order_info->payment->name:'';
$order_info_arr['receiver_addr_txt'] = $order_info->receiver_province.
$order_info->receiver_city.
$order_info->receiver_county.
$order_info->receiver_address;
return $order_info_arr;
}
/**
* 处理险种信息
* @param $insurer_type_info
* @param $order_id
* @return array
*/
public static function GetInsurerTypeInfoResponse($insurer_type_info,$order_id)
{
$price_info = PriceT::find()
->where('order_id='.$order_id.' and type_id='.$insurer_type_info->id)
->one();
$insurer_type_info_arr = $insurer_type_info->toArray();
$insurer_type_info_arr['show_name'] = $insurer_type_info->name.'('.$insurer_type_info->code.')';
$insurer_type_info_arr['show_content'] = $price_info->val;
$insurer_type_info_arr['is_nopay_txt'] = $price_info->is_nopay==1?'是': '否';
return $insurer_type_info_arr;
}
/**
* 处理礼品信息
* @param $order_gift
* @return array
*/
public static function GetGiftInfoResponse($order_gift)
{
$gift_info = $order_gift->toArray();
$gift_info['gift_name'] = $order_gift->gift->name;
$gift_info['group_name'] = $order_gift->group->name;
return $gift_info;
}
/**
* 处理操作记录
* @param $log
* @return array
*/
public static function GetCarLogResponse($log)
{
$log_info = $log->toArray();
$log_info['op_time_txt'] = date('Y-m-d H:i:s',$log->op_time);
return $log_info;
}
}

@ -2694,6 +2694,34 @@ class CarController extends BaseController
$result['html'] = $html;
return $result;
}
public function actionAjaxHistoryIndexJson()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$car_id = $request->get('car_id');
$offset = $request->get('offset',0);
$limit = $request->get('limit', 10);
$result = array();
$result['success'] = false;
$result['msg'] = '读取失败';
$query = CarLogT::find()
->where(['car_id'=>$car_id,'type'=>1])
->andWhere('op_time>='.strtotime("-6 months"))
->orderBy('op_time DESC');
$total = $query->count();
$query = $query->offset($offset)->limit($limit);
$items = $query->all();
$result['success'] = true;
$result['msg'] = '读取成功';
$result['data'] = MyLib::GetInfosResponse('history',$items);
return $result;
}
public function actionAjaxHistoryIndexXubao()
{
Yii::$app->response->format = Response::FORMAT_JSON;

@ -181,77 +181,39 @@ class InsurerController extends BaseController
return $this->render('info');
}
public function actionInfJson()
public function actionInfoJson()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$id = $request->get('id',0);
$order_info = OrderT::findOne(['id'=>$id]);
$car_info = $order_info->car;
$nonitems=null;
if($order_info->non_id){
$nonitems=NonAutoInsurance::findOne(['id'=>$order_info->non_id]);
}
// dd($order_info->non_id);
//快递
// dd($car_info->id);
// $ems_items = EmsT::find()
// ->where(['car_id'=>$car_info->id,'order_id'=>$order_info->id])
// ->orderBy('id ASC')
// ->all();
// $ems_items1=(object)array();
// if(!$ems_items){
// $ems_items1 = ExpressT::find()
// ->where(['car_id'=>$car_info->id,'order_id'=>$order_info->id])
// ->orderBy('id ASC')
// ->all();
// }
//礼品
$gift_free_group_items = GiftGroupT::find()
->where('is_free=1')
->all();
$gift_group_items = GiftGroupT::find()
->where('is_free=0')
->all();
//获取礼品数据
$sel_gifts = array();
$tmp_items = OrderGiftT::find()
$order_gifts = OrderGiftT::find()
->where('order_id='.$order_info->id)
->all();
foreach($tmp_items as $item) {
$sel_gifts[$item->group_id] = $item;
}
$insurer_type_items = InsurerTypeT::find()
->all();
$insurer_type_items = InsurerTypeT::find()->all();
//登陆用户ID
$uid = $this->my->id;
$order_caiwu = OrderCaiwuT::findOne(['order_id'=>$order_info->id]);
$money_man='';
$money_no='';
$money_bank='';
if($order_caiwu){
$money_man=$order_caiwu->money_man;
$money_no= $order_caiwu->money_no;
$money_bank=$order_caiwu->money_bank;
}
return $this->render('info',[
'order_info'=>$order_info,
'car_info'=>$car_info,
// 'ems_items' => $ems_items,
// 'ems_items1' => $ems_items1,
'money_man' => $money_man,
'money_no' => $money_no,
'money_bank' => $money_bank,
'gift_free_group_items' => $gift_free_group_items,
'gift_group_items' => $gift_group_items,
'sel_gifts' => $sel_gifts,
return MyLib::ok3([
'order_info'=>MyLib::GetOrderInfoResponse($order_info),
'car_info'=>MyLib::GetCarInfoResponse($order_info->car),
'insurer_type_info' => MyLib::GetInfosResponse('insurer_type',$insurer_type_items,$order_info->id),
'gift_info' => MyLib::GetInfosResponse('gift',$order_gifts),
'order_insurer_info' => $order_caiwu,
'uid' => $uid,
'insurer_type_items' => $insurer_type_items,
'nonitems' => $nonitems
]);
}
public function actionSave()
{
Yii::$app->response->format = Response::FORMAT_JSON;

@ -89,7 +89,7 @@ use \common\libs\MyLib;
<div class="container">
<div class="form-group col-md-3" style="margin-bottom: 8px;">
<label class="control-label">业务分组</label>
<span class="order-info" data-name="businessGroup"></span>
<span class="order-info" data-name="business_group_name"></span>
</div>
<div class="form-group col-md-3" style="margin-bottom: 8px;">
<label class="control-label">被保险人</label>
@ -159,7 +159,7 @@ use \common\libs\MyLib;
<label class="control-label">备注</label>
<span class="order-info" data-name=""></span>
</div>
<div class="form-group col-md-3" style="margin-bottom: 8px;">
<div class="form-group col-md-6" style="margin-bottom: 8px;">
<label class="control-label">正本送单地址</label>
<span class="order-info" data-name="receiver_addr_txt"></span>
</div>
@ -221,15 +221,34 @@ use \common\libs\MyLib;
<label class="control-label">备注</label>
<span class="order-info" data-name="price_remark"></span>
</div>
</div><hr>
</div>
</div>
</div>
</div>
</div>
<div class="ibox float-e-margins">
<div class="ibox-title fixed">
<h5>保单文件信息</h5>
<div class="ibox-tools">
<a class="btn btn-primary btn-xs edit-btn" id="business_print_btn" href="javascript:void(0);" onclick="insurer_files_print('business')">
<i class="fa fa-search"></i> 查看商业保单并打印
</a>
<a class="btn btn-primary btn-xs edit-btn" id="compulsory_print_btn" href="javascript:void(0);" onclick="insurer_files_print('compulsory')">
<i class="fa fa-search"></i> 查看交强保单并打印
</a>
</div>
</div>
<div class="ibox-content">
<div class="row">
<div class="col-md-12">
<form method="get" class="form-horizontal">
<input type="hidden" name="id" class="form-control order-info">
<div class="form-group">
<label class="col-sm-4 control-label">商业保单文件</label>
<div class="col-sm-8">
<div class="input-group">
<input type="text" name="shangye_src" class="form-control order-info" value="">
<a href="javascript:void(0);" class="input-group-addon" id="upload">
<input type="text" data-name="shangye_src" name="shangye_src" class="form-control order-info" value="">
<a href="javascript:void(0);" class="input-group-addon upload">
上传文件
</a>
</div>
@ -240,8 +259,8 @@ use \common\libs\MyLib;
<label class="col-sm-4 control-label">交强保单文件</label>
<div class="col-sm-8">
<div class="input-group">
<input type="text" name="urlfile1" class="form-control order-info" value="">
<a href="javascript:void(0);" class="input-group-addon" id="upload">
<input type="text" data-name="jiaoqiang_src" name="jiaoqiang_src" class="form-control order-info" value="">
<a href="javascript:void(0);" class="input-group-addon upload">
上传文件
</a>
</div>
@ -249,16 +268,10 @@ use \common\libs\MyLib;
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="">
<a class="btn btn-primary edit-btn" data-id="0" href="javascript:void(0);" onclick="print_infos('insurer')">
<div class="text-center">
<a class="btn btn-primary edit-btn" data-id="0" href="javascript:void(0);" onclick="insurer_files_save()">
<i class="fa fa-save"></i> 保存
</a>
<a class="btn btn-primary edit-btn" data-id="0" href="javascript:void(0);" onclick="print_infos('insurer')">
<i class="fa fa-search"></i> 查看商业保单并打印
</a>
<a class="btn btn-primary edit-btn" data-id="0" href="javascript:void(0);" onclick="print_infos('insurer')">
<i class="fa fa-search"></i> 查看交强保单并打印
</a>
</div>
</div>
</form>
@ -274,7 +287,7 @@ use \common\libs\MyLib;
<div class="row">
<div class="col-md-6">
<h4 class="title">免费礼品</h4>
<table id="gift_free_table">
<table id="free_gift_table">
<thead>
<tr>
<th data-field="id">ID</th>
@ -286,7 +299,7 @@ use \common\libs\MyLib;
</div>
<div class="col-md-6">
<h4 class="title">自费礼品</h4>
<table id="gift_free_table">
<table id="private_gift_table">
<thead>
<tr>
<th data-field="id">ID</th>
@ -310,15 +323,15 @@ use \common\libs\MyLib;
<div class="col-md-12">
<div class="form-group col-md-3" style="margin-bottom: 8px;">
<label class="control-label">领款人</label>
<span class="money-info" data-name="money_man"></span>
<span class="order-insurer-info" data-name="money_man"></span>
</div>
<div class="form-group col-md-3" style="margin-bottom: 8px;">
<label class="control-label">开户行</label>
<span class="money-info" data-name="money_bank"></span>
<span class="order-insurer-info" data-name="money_bank"></span>
</div>
<div class="form-group col-md-3" style="margin-bottom: 8px;">
<label class="control-label">品牌</label>
<span class="money-info" data-name="money_no"></span>
<span class="order-insurer-info" data-name="money_no"></span>
</div>
</div>
</div>
@ -352,11 +365,11 @@ use \common\libs\MyLib;
<div class="ibox-title fixed">
<div class="ibox-tools">
<a class="btn btn-primary edit-btn" data-id="0" href="javascript:void(0);"
onclick="print_infos('insurer')">
onclick="reBack()">
<i class="fa fa-backward"></i> 退单
</a>
<a class="btn btn-primary edit-btn" data-id="0" href="javascript:void(0);"
onclick="print_infos('insurer')">
onclick="goBack()">
<i class="fa fa-close"></i> 关闭
</a>
</div>
@ -369,9 +382,28 @@ use \common\libs\MyLib;
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="/assets/js/plugins/webuploader/webuploader.min.js"></script>
<script type="text/javascript" language="javascript">
var params = {};
$(function () {
layui.use(['upload'], function(){
var upload = layui.upload;
var uploadInst = upload.render({
elem: '.upload' /*绑定元素*/,
url: '/common/upload' /*上传接口*/,
accept: 'file',
done: function(res){
//上传完毕回调
if(res.status == 'SUCCESS') {
$('#file').val(res.fileUrl);
}
},
error: function(){
//请求异常回调
}
});
});
$('.input-date').datepicker({
keyboardNavigation: false,
forceParse: false,
@ -385,7 +417,6 @@ use \common\libs\MyLib;
init();
} else {
alert('数据加载错误');
window.history.go(-1);
}
}, 'json');
@ -423,182 +454,103 @@ use \common\libs\MyLib;
});
function init(){
console.log(params);
carInfoInit(params['car_info']);
if(!params['order_info']['shangye_src']){
$('#business_print_btn').hide();
}
if(!params['order_info']['jiaoqiang_src']){
$('#compulsory_print_btn').hide();
}
orderInfoInit(params['order_info']);
selectInfoInit(params);
tableInfoInit(params);
buttonInit(params['can_cancel']);
}
//拨号
function strCall(phone) {
parent.drtCall(phone);
}
//挂断
function strHook() {
parent.drtHook();
}
// 保存车辆信息
function saveCarInfo() {
var params = $('#carFrm').serialize();
$.post('/car/save',params,function(obj){
alert(obj.msg);
window.location.reload();
},'json');
}
orderInsurerInfoInit(params['order_insurer_info']);
// 下一条信息
function nextInfo(){
var param = 'index=' + params['next_index'] + '&type='+ params['type'];
$.get('/track/ajax-next', param, function (obj) {
if (obj.success) {
if (obj.car_id > 0) {
window.location.href = '/car/info-track?id=' + obj.car_id + '&type='+ params['type'] +'&next_index='+ params['next_index'] + '&back_params=' + encodeURIComponent(params['back_params']);
} else {
alert('没有记录');
var free_gift = [],
private_gift = [];
$.each(params['gift_info'],function (i,d) {
if(d['is_free'] == 1){
free_gift.push(d);
}else {
private_gift.push(d);
}
});
var tables = {
'insurer_type': params['insurer_type_info'],
'free_gift': free_gift,
'private_gift': private_gift,
'car_history': {
url: '/car/ajax-history-index-json',
queryParamsFunc: function (param) {
param['car_id'] = params['car_info']['id'];
param['limit'] = param['limit'];
param['offset'] = param['offset'];
return param;
}
}
}, 'json');
}
// 返回
function goBack(){
var url = '';
switch (+type) {
case 1:
url = '/track/first?' + params['next_index'];break;
case 2:
url = '/track/today?' + params['next_index'];break;
case 3:
url = '/track/all?' + params['next_index'];break;
}
return window.location.href = url;
}
// 保险信息保存
function saveInsurerInfo(){
var params = $('#insurerFm').serialize();
$.post('/car/baocun', params, function (obj) {
alert(obj.msg);
}, 'json');
};
tableInfoInit(tables, params);
}
// 取消预约
function cancelAppointment(){
//这里是后来需求改了,暂时注释
//if(location == 6){
// var url = '/track/car-cancel-e';
//}else if(location == 3 || ptype == 3){
// var url = '/track/car-cancel';
//}
var location = params['car_info']['location'];
var ptype = $('#appointment_list').children("table").children("tbody").children("tr").eq(1).children(".ptyp").attr('data');
if (location == 3) {
//C库数据
//放d
var url = '/track/car-cancel';
} else if (location == 6 && ptype == 5) {
var url = '/track/car-cancel-e';
} else {
//无效
alert('不是目标客户,请点击无效数据按钮!');
return false;
function insurer_files_print(type) {
if(type == 'compulsory' && params['order_info']['jiaoqiang_src']){
window.open('/upload/files'+ params['order_info']['jiaoqiang_src'])
}
if (confirm('是否确认放弃?')) {
$.post(url, {id:params['car_info']['id']}, function (obj) {
alert(obj.msg);
if (obj.success) {
$('.back-btn').click();
}
}, 'json');
if(type == 'compulsory' && !params['order_info']['jiaoqiang_src']){
alert('找不到文件,加载失败');
}
}
// 预约保存
function appointmentSave(){
if (confirm('是否确认提交?')) {
var params = $("#appointmentFrm").serialize();
$.post('/appointment/save', params, function (obj) {
alert(obj.msg);
if (obj.success) {
$('#appointmentFrm')[0].reset();
$('#appointment_table').bootstrapTable('refresh');
}
}, 'json');
if(type == 'business' && params['order_info']['shangye_src']){
window.open('/upload/files'+ params['order_info']['shangye_src'])
}
}
// 无效保存
function appointmentInvalid(){
var car_id = params['car_info']['id'];
var invalid_id = $('#invalid_id').val();
if (invalid_id == 0) {
alert('必须选择无效理由!');
return;
if(type == 'business' && !params['order_info']['shangye_src']){
alert('找不到文件,加载失败');
}
if (confirm('是否无效这条数据?')) {
$.post('/car/invalid', {car_id: car_id, invalid_id: invalid_id}, function (obj) {
alert(obj.msg);
if (obj.success) {
$('#appointment-save-btn').attr('disabled', true);
$('.save-btn').attr('disabled', true);
$('.invalid-btn').attr('disabled', true);
}
function insurer_files_save() {
var param = $(this).closest('form').serialize();
$.post('/insurer/pdf-save',param,function(obj){
console.log(obj);
if(obj.success) {
alert('保单上传成功');
window.location.reload();
}
},'json');
}
function reBack(){
if(confirm('请核对好出单日期,确认退回到正本?')) {
$.post('/insurer/tuidan-save',{id:params['order_info']['id']},function(obj){
if(obj.success) {
alert('退单成功');
}
}, 'json');
},'json');
}
}
function tableInfoInit(data){
var tables = {
'appointment': '/appointment/index-json',
'insurer_order': '/car/info-track-table-json',
'new_gift': '/car/info-track-table-json',
'old_gift': '/car/info-track-table-json',
'car_history': '/car/info-track-table-json',
};
$.each(tables,function(name,url){
var $table = $('#'+ name +'_table');
$table.bootstrapTable('destroy');
$table.bootstrapTable({
url: url,
pagination: true,
sidePagination: 'server',
queryParams: function (param) {
if(name == 'new_gift'){
param['car_no'] = params['car_info']['car_no'];
}else {
param['car_id'] = params['car_info']['id'];
}
param['name'] = name;
param['limit'] = param['limit'];
param['offset'] = param['offset'];
return param;
},
responseHandler: function (res) {
console.log(res);
return res
}
});
});
function goBack(){
window.close();
}
// 品牌选项初始化
function selectInfoInit(data){
var keys = [
'brand',
'series',
'displacement',
'car_type',
'car_use',
'appointment_type',
'business_group',
'invalid',
];
$.each(keys,function(index,key){
var html = '<option value="0">---请选择---</option>';
$.each(data[key + '_info'],function(i,item){
var val = item['code']?item['code']:item['id'];
var selected = data['car_info'][key + '_id'] && data['car_info'][key + '_id'] == val? 'selected': '';
html += '<option value="'+ val +'" '+ selected +'>'+ item.name +'</option>'
});
$('#'+ key + '_info').html(html);
function tableInfoInit(tables){
$.each(tables,function(name,data){
var $table = $('#'+ name +'_table');
var options = {};
if(typeof data == 'String'){
options = {
url: data.url,
pagination: true,
sidePagination: 'server',
queryParams: data.queryParamsFunc
}
}else {
options = {
data: data
}
}
$table.bootstrapTable('destroy');
$table.bootstrapTable(options);
});
}
@ -621,6 +573,15 @@ use \common\libs\MyLib;
});
}
function orderInsurerInfoInit(data){
$('.order-insurer-info:not(input)').each(function(key,item) {
$(item).html(data[$(item).data('name')]);
});
$('.order-insurer-info:input').each(function(key,item) {
$(item).val(data[$(item).data('name')]);
});
}
function buttonInit(param) {
if(param){
$('#appointment_btn').prepend('<button type="button" class="btn btn-primary" onclick="cancelAppointment()">放弃</button>');

Loading…
Cancel
Save