<?php
namespace frontend\controllers;
use common\libs\MyLib;
use common\models\AppointmentHistoryT;
use common\models\AppointmentT;
use common\models\Brand2T;
use common\models\BrandT;
use common\models\BusinessGroupT;
use common\models\CarBT;
use common\models\CarCT;
use common\models\CarDT;
use common\models\CarET;
use common\models\CarFT;
use common\models\CarF1T;
use common\models\CarF2T;
use common\models\CarF3T;
use common\models\CarF4T;
use common\models\CarF5T;
use common\models\CarF6T;
use common\models\CarGiftT;
use common\models\CarInvalidT;
use common\models\CarLogT;
use common\models\CarT;
use common\models\CarTypeT;
use common\models\CarUseT;
use common\models\CityT;
use common\models\DirectionT;
use common\models\Displacement2T;
use common\models\DisplacementT;
use common\models\DistrictT;
use common\models\DuanxinT;
use common\models\FactoryT;
use common\models\FinanceLogT;
use common\models\GiftGroupT;
use common\models\GiftT;
use common\models\GiftType2T;
use common\models\GiftType3T;
use common\models\InsurerCompany2T;
use common\models\MeetT;
use common\models\GiftTicketT;
use common\models\InsurerCompanyT;
use common\models\InsurerTypeT;
use common\models\InvalidT;
use common\models\LinkmanT;
use common\models\ModelT;
use common\models\OrderFinanceLogT;
use common\models\OrderGiftT;
use common\models\OrderT;
use common\models\OrderUserT;
use common\models\PayTypeT;
use common\models\PriceT;
use common\models\RangeT;
use common\models\Region;
use common\models\Series2T;
use common\models\SeriesT;
use common\models\StatusT;
use common\models\UserT;
use common\models\YearT;
use common\models\OrderCaiwuT;
use common\models\OrderAddress;
use common\models\InvalidNew;
use common\models\InvalidRenewal;
use Yii;
use yii\data\Pagination;
use yii\web\Response;
class CarController extends BaseController
{
public $enableCsrfValidation = false;
public $layout = 'blue-main';
public function actionIndex()
{
return $this->renderPartial('index');
}
public function actionMycars()
{
$user_id = $this->my->id;
return $this->renderPartial('mycars',[
'user_id' => $user_id
]);
}
public function actionOutputOrder()
{
// set_time_limit(0);
// $begin_time = time();
// $file_path = \Yii::getAlias('@console').'/controllers/';
// var_dump($row);
//加上级别筛选
$car_arr=array();
$order_info=OrderT::find()->where('insurance_status=3 or insurance_status=1')->andWhere('status_id>1')->all();
foreach($order_info as $vs){
$car_arr[$vs->car_no]=$vs->id;
}
// dd(count($car_arr));
$objectPHPExcel = new \PHPExcel();
$index = 1;
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'厂牌型号');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'车型');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'初登日期');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'商业到期日期');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'交强到期日期');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'被保险人');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'被保险人身份证');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'发动机号');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'车架号');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'年份');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('L'.$index,'车主');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('M'.$index,'电话');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('N'.$index,'车主身份证');
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('O'.$index,'保险公司');
// $query = OrderT::find();
foreach($car_arr as $item) {
$order_item=OrderT::findOne($item);
$index++;
$car = $order_item->car;
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$order_item->car_no);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car->factory_model);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$car->car_model);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$car->register_date);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car->insurer1_date);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$car->insurer2_date);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$car->id_man);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$car->id_number);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$car->engine_no);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$car->car_frame_no);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$car->car_year);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('L'.$index,$car->car_man);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('M'.$index,$car->phone);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('N'.$index,$car->car_man_number);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('O'.$index,$car->company);
}
header('Content-Type: application/vnd.ms-excel;charset=utf-8');
header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel5');
$objWriter->save('php://output');
}
//查找平移数据问题
public function actionPingyi()
{
//SELECT * FROM `car_log_t` WHERE `remark` = '从3005(饶丽云) 平移车辆给 3011(柳明芳·)' and `op_time` < '1541548800' and `op_man` ='0002(魏媛)' and `op_time` >'1533081600' ORDER BY `op_time` asc
// ['like', 'name', 'tester']
// ['remark'=>'从3005(饶丽云) 平移车辆给 3011(柳明芳·)'])
$datas=CarLogT::find()->where(['like', 'remark', '平移车辆'])
->andWhere(['< ', 'op_time', '1541548800'])
->andWhere(['>', 'op_time', '1533081600'])
->andWhere(['op_man' =>'0002(魏媛)']);
// ->limit(29);
//
$bnum=0;
$enum=0;
$enum1=0;
$enum9=0;
// echo '< pre > ';
foreach($datas->each(29) as $b_info) {
//// print_r($b_info->car_id);
// print_r($b_info->remark);
// echo '< br > ';
$car= CarT::findOne(['id'=>$b_info->car_id]);
//开始头字母
$bestr=substr($b_info->remark,3,1);
$bestr4=substr($b_info->remark,3,4);
// var_dump($bestr4);
// die;
//分配的工号
$endstr=substr($b_info->remark,35);
// echo '< br > ';
// var_dump($bestr);
// echo '< br > ';
// var_dump($endstr);
// echo '< br > ';
if($bestr==3){
continue;
// $car->op_user3=$endstr;
// $this->addLog($car->id,'补全平移数据问题',1);
$bnum++;
}elseif($bestr==1){
continue;
// $car->op_user1=$endstr;
// $this->addLog($car->id,'补全平移数据问题',1);
$enum++;
}elseif($bestr==2){
// if($bestr4==2057){
// $car->op_user1=$endstr;
// }else{
// continue;
// }
continue;
$enum1++;
}elseif($bestr==9){
// continue;
$car->op_user3=$endstr;
$this->addLog($car->id,'补全平移数据问题',1);
$enum9++;
}else{
continue;
}
//
$car->save();
//// print_r($car);
//
}
var_dump($bnum);
echo '< br > ';
var_dump($enum);
echo '< br > ';
var_dump($enum1);
echo '< br > ';
var_dump($enum9);
// echo $datas->createCommand()->rawSql;
// $datas->all();
// var_dump($datas) ;
// $$datas->all();
// var_dump($datas);
return $this->renderPartial('index');
}
//查找重复的数据
public function actionChongf()
{
//select car_no,count(*) as count from car_t group by car_no having count>1
$num=0;
$cnum=0;
$xnum=0;
$query=CarT::find()->select('car_no,count(*) count,id,location,hiddenes')->groupBy('car_no')->having(['>' ,'count',1])
->where('location=3');
// aa($query);
$data=$query->all();
foreach($data as $vs){
$carlogNum=CarLogT::find()->where(['car_id'=>$vs->id])
// ->andWhere(['remark'=> '从F库分配到C库'])
->andWhere(['or', 'remark="从A库分配到C库"', 'remark="从B库分配到C库"', 'remark="从E库分配到C库"', 'remark="从F库分配到C库"', 'remark="从无效库分配到C库"'])
->count();
if($carlogNum==1){
// dd($info);
$dear= CarT::findOne(['id'=>$vs->id]);
$dear->hiddenes=1;
// $sa=$info->id();
if($dear->save()){
$num++;
}
// echo $info->car_no;
}else{
// $xnum++;
continue;
//
}
}
// foreach($query->each(10) as $info) {
//// $carlogNum=CarLogT::find()->where(['car_id'=>$info->id])->count();
//// if($carlogNum>=1){
//// continue;
//// }else{
//// $num++;
//// }
//
//// if($info->location==3){
//// $cnum++;
//// }else{
//// continue;
//// }
//// ['or', 'id=1', 'id=2']
// $carlogNum=CarLogT::find()->where(['car_id'=>$info->id])
//// ->andWhere(['remark'=> '从F库分配到C库'])
// ->andWhere(['or', 'remark="从A库分配到C库"', 'remark="从B库分配到C库"', 'remark="从E库分配到C库"', 'remark="从F库分配到C库"', 'remark="从无效库分配到C库"'])
// ->count();
// if($carlogNum==1){
//// dd($info);
// $info->hiddenes=1;
//// $sa=$info->save();
// if($info->save()){
// $num++;
// }
//// echo $info->car_no;
//
// }else{
//// $xnum++;
// continue;
////
// }
//
//
//
//
//
// }
// $data= $query->count();
//
// aa($query);
// var_dump($data);
echo $num;
echo '< br > ';
// echo $xnum;
// echo $cnum;
}
public function actionJsonData()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$user_id = $request->get('user_id',0);
$car_man = $request->get('car_man','');
$car_no = $request->get('car_no','');
$engine_no = $request->get('engine_no','');
$car_frame_no = $request->get('car_frame_no','');
$register_begin = $request->get('register_begin','');
$register_end = $request->get('register_end','');
$resurer_begin = $request->get('resurer_begin','');
$resurer_end = $request->get('resurer_end','');
$sort = $request->get('sort','id');
$order = $request->get('order','asc');
$page = $request->get('page',1);
$limit = $request->get('rows',20);
$start = ($page-1)*$limit;
$query = CarT::find();
if($user_id > 0) {
$user_items = $this->my->getChildren();
$user_ids = array();
if($user_items != null) {
foreach($user_items as $user_item) {
$user_ids[] = $user_item->id;
}
}
$user_ids[] = $this->my->id;
$query = $query->andWhere(['in','user_id',$user_ids]);
}
if($car_man != '') {
$query = $query->andWhere('car_man="'.$car_man.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_no="'.$car_no.'"');
}
if($engine_no != '') {
$query = $query->andWhere('engine_no="'.$engine_no.'"');
}
if($car_frame_no != '') {
$query = $query->andWhere('car_frame_no="'.$car_frame_no.'"');
}
if($register_begin != '') {
$query = $query->andWhere('register_date>="'.$register_begin.'"');
}
if($register_end != '') {
$query = $query->andWhere('register_date< ="'.$register_end.'"');
}
$query = $query->orderBy($sort.' '.$order);
$total = $query->count();
$query = $query->offset($start)->limit($limit);
$items = $query->all();
$data = array();
foreach($items as $item) {
$row = array();
$row['id'] = $item->id;
$row['car_no'] = $item->car_no;
$row['car_man'] = $item->car_man;
$row['phone'] = $item->phone;
$row['engine_no'] = $item->engine_no;
$row['car_frame_no'] = $item->car_frame_no;
$row['seats'] = $item->seats;
$row['register_date'] = $item->register_date;
$row['user'] = $item->user?$item->user->getShowName():'';
$row['created_at'] = $item->created_at;
$data[] = $row;
}
$result['total'] = $total;
$result['rows'] = $data;
return $result;
}
public function actionEdit()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$back_params = $request->get('back_params');
$user_id = $request->get('user_id',0);
if($id > 0) {
$info = CarT::findOne(['id'=>$id]);
} else {
$info = new CarT();
}
$car_use_items = CarUseT::find()->all();
$car_type_items = CarTypeT::find()->all();
$brand_items = Brand2T::find()->all();
$factory_items = FactoryT::find()
->where('brand_id='.intval($info->brand_id))
->all();
$series_items = Series2T::find()
->where('factory_id='.intval($info->factory_id))
->all();
$displacement_items = Displacement2T::find()
->where('series_id='.intval($info->series_id))
->all();
$year_items = YearT::find()
->where('series_id='.intval($info->series_id.' and displacement_id='.intval($info->displacement_id)))
->all();
$model_items = ModelT::find()
->where('series_id='.intval($info->series_id))
->andWhere('displacement_id='.intval($info->displacement_id))
->andWhere('year_id='.intval($info->year_id))
->all();
return $this->render('edit',[
'user_id' => $user_id,
'info' => $info,
'car_use_items' => $car_use_items,
'car_type_items' => $car_type_items,
'brand_items' => $brand_items,
'factory_items' => $factory_items,
'series_items' => $series_items,
'displacement_items' => $displacement_items,
'year_items' => $year_items,
'model_items' => $model_items,
'back_params' => $back_params
]);
}
public function actionSave()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '保存失败';
if($request->isPost) {
$id = $request->post('id',0);
$car_no = $request->post('car_no');
$engine_no = $request->post('engine_no');
$car_frame_no = $request->post('car_frame_no');
$factory_model = $request->post('factory_model');
$seats = $request->post('seats');
$car_type_id = $request->post('car_type_id');
$car_use_id = $request->post('car_use_id');
$register_date = $request->post('register_date');
$car_year = $request->post('car_year');
$brand_id = $request->post('brand_id',0);
$factory_id = $request->post('factory_id',0);
$series_id = $request->post('series_id',0);
$displacement_id = $request->post('displacement_id',0);
$year_id = $request->post('year_id',0);
$model_id = $request->post('model_id',0);
$car_man = $request->post('car_man');
$phone = $request->post('phone');
$car_man_number = $request->post('car_man_number');
$insurer1_date = $request->post('insurer1_date');
$insurer2_date = $request->post('insurer2_date');
$company = $request->post('company');
$remark = $request->post('remark');
$op_user1 = $request->post('op_user1');
$op_user2 = $request->post('op_user2');
$op_user3 = $request->post('op_user3');
if($car_no == '') {
$result['msg'] = '请输入车牌号码!';
return $result;
}
$row = null;
if($id > 0) {
$row = CarT::findOne(['id'=>$id]);
} else {
$row = new CarT();
$row->user_id = 0;
$row->location = 1;
}
//去除首位空格和字符串中间的空格
$car_no= trim($car_no);
$car_no=str_replace(" ","",$car_no);
$row->car_no = $car_no;
$row->engine_no = $engine_no;
$row->car_frame_no = $car_frame_no;
$row->factory_model = $factory_model;
$row->car_model = $factory_model;
$row->seats = $seats;
$row->car_type_id = $car_type_id;
$row->car_use_id = $car_use_id;
$row->register_date = $register_date;
$row->car_year = $car_year;
$row->brand_id = $brand_id;
$row->factory_id = $factory_id;
$row->series_id = $series_id;
$row->displacement_id = $displacement_id;
$row->year_id = $year_id;
$row->model_id = $model_id;
$row->car_man = $car_man;
$row->phone = $phone;
$row->car_man_number = $car_man_number;
$row->remark = $remark;
if($insurer1_date != '')
$row->insurer1_date = $insurer1_date;
if($insurer2_date != '')
$row->insurer2_date = $insurer2_date;
if($company != '')
$row->company = $company;
$row->op_user1 = $op_user1;
$row->op_user2 = $op_user2;
$row->op_user3 = $op_user3;
$row->save();
$result['success'] = true;
$result['msg'] = '保存成功';
}
return $result;
}
public function actionDelete()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '删除失败';
if($request->isPost) {
$id = $request->post('id',0);
$tran = CarT::getDb()->beginTransaction();
try {
$ids = $request->post('ids',array());
if($id > 0) {
$car_info = CarT::findOne(['id'=>$id]);
if($car_info->location != 1) {
$result['msg'] = '该车辆必须先回到A库,才能删除';
return $result;
}
//删除预约信息
AppointmentT::deleteAll('car_id='.$id);
AppointmentHistoryT::deleteAll('car_id='.$id);
//删除保单信息
$items = OrderT::find()
->where('car_id='.$id)
->all();
foreach ($items as $item) {
PriceT::deleteAll(['order_id'=>$item->id]);
$item->delete();
}
//删除B、C、D库数据
if($car_info->location == 2)
CarBT::deleteAll('id='.$car_info->id);
if($car_info->location == 3)
CarCT::deleteAll('id='.$car_info->id);
if($car_info->location == 4)
CarDT::deleteAll('id='.$car_info->id);
$car_info->delete();
//清除操作记录
$this->removeLog($id);
}
$tran->commit();
$result['success'] = true;
$result['msg'] = '删除成功';
} catch(\Exception $e) {
$tran->rollBack();
$result['msg'] = $e->getMessage();
}
}
return $result;
}
public function actionDeleteAll()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '删除失败';
if($request->isPost) {
$tran = CarT::getDb()->beginTransaction();
try {
$ids = $request->post('ids',array());
foreach($ids as $id) {
if($id > 0) {
$row = CarT::findOne(['id'=>$id]);
AppointmentT::deleteAll('car_id='.$id);
AppointmentHistoryT::deleteAll('car_id='.$id);
$items = OrderT::find()
->where('car_id='.$id)
->all();
foreach ($items as $item) {
PriceT::deleteAll(['order_id'=>$item->id]);
$item->delete();
}
$row->delete();
}
}
$tran->commit();
$result['success'] = true;
$result['msg'] = '删除成功';
} catch(\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
public function actionAppointment()
{
$request = Yii::$app->request;
$car_id = $request->get('car_id');
return $this->renderPartial('appointment',[
'car_id' => $car_id
]);
}
public function actionAppointmentJsonData()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$car_id = $request->get('car_id');
$car_info = CarT::findOne(['id'=>$car_id]);
$page = $request->get('page',1);
$limit = $request->get('rows',20);
$start = ($page-1)*$limit;
$query = $car_info->getAppointments()
->orderBy('pdate DESC,ptime ASC,id DESC');
$total = $query->count();
$query = $query->offset($start)->limit($limit);
$items = $query->all();
$data = array();
foreach($items as $item) {
$row = array();
$row['id'] = $item->id;
$row['pdate'] = $item->pdate;
$row['ptime'] = $item->ptime;
$row['remark'] = $item->remark;
$row['user'] = $item->user?$item->user->getShowName():'';
$data[] = $row;
}
$result['total'] = $total;
$result['rows'] = $data;
return $result;
}
public function actionInsurer()
{
$request = Yii::$app->request;
$car_id = $request->get('car_id');
return $this->renderPartial('insurer',[
'car_id' => $car_id
]);
}
public function actionBaocun()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '保存失败';
if($request->isPost){
$car_id = $request->post('car_id');
$insurer1_date = $request->post('insurer1_date');
$insurer2_date = $request->post('insurer2_date');
$company = $request->post('company');
$order = CarT::findOne(['id'=>$car_id]);
$order->insurer1_date = $insurer1_date;
$order->insurer2_date = $insurer2_date;
$order->company = $company;
$order->save();
//操作日志
$this->addLog($car_id,'操作了商业止保,交强止保,保险公司',1);
$result['success'] = true;
$result['msg'] = '保存成功';
}
return $result;
}
// public function actionInfo()
// {
// $request = Yii::$app->request;
// $id = $request->get('id',0);
// $type = $request->get('type',0);
// $car_man = $request->get('car_man');
// $phone = $request->get('phone');
// $car_no = $request->get('car_no');
// $page = $request->get('page',1);
// $sort_key = $request->get('sort_key','appointment_t.pdate');
// $sort_value = $request->get('sort_value','ASC');
// $next_index = $request->get('next_index',0);
// $back_params = $request->get('back_params');
// $my_path = $this->my->group?$this->my->group->getPath():'';
//
// $car_info = CarT::findOne(['id'=>$id]);
// $order_info = $car_info->getOrders()->orderBy('id DESC')->one();
// if(!$order_info) {
// $user_id = 0;
// if($car_info->location == 2) {
// $b_info = CarBT::findOne(['id'=>$car_info->id]);
// $user_id = $b_info->user_id;
// }
// if($car_info->location == 3) {
// $c_info = CarCT::findOne(['id'=>$car_info->id]);
// $user_id = $c_info->user_id;
// }
// if($car_info->location == 4) {
// $d_info = CarDT::findOne(['id'=>$car_info->id]);
// $user_id = $d_info->user_id;
// }
// $order_info = new OrderT();
// $order_info->car_id = $car_info->id;
// $order_info->car_no = $car_info->car_no;
// $order_info->engine_no = $car_info->engine_no;
// $order_info->car_frame_no = $car_info->car_frame_no;
// $order_info->car_man = $car_info->car_man;
// $order_info->user_id = $user_id;
// $order_info->status_id = 1;
// $order_info->id_man = $car_info->car_man;
// $order_info->link_man = $car_info->car_man;
// $order_info->link_phone = $car_info->phone;
// $order_info->save();
// }
// $insurer_type_items = InsurerTypeT::find()->all();
// $insurer_company_items = InsurerCompanyT::find()->all();
// $insurer_company2_items = InsurerCompany2T::find()->all();
// $pay_type_items = PayTypeT::find()->all();
// $car_use_items = CarUseT::find()->all();
// $car_type_items = CarTypeT::find()->all();
// $brand_items = BrandT::find()->all();
// $series_items = SeriesT::find()
// ->where('brand_id='.intval($car_info->brand_id))
// ->all();
// $displacement_items = DisplacementT::find()
// ->where('series_id='.intval($car_info->series_id))
// ->all();
// $direction_items = DirectionT::find()
// ->all();
// $range_items = RangeT::find()
// ->all();
// $city_items = CityT::find()
// ->all();
// $district_items = DistrictT::find()
// ->orderBy('order_id ASC')
// ->all();
// $gift_items = GiftT::find()
// ->where('type_id=1')
// ->all();
// $success_items = InvalidT::getTree(1);
// $failure_items = InvalidT::getTreeXinbaoNew(2);
//
// //下一辆
// $next_id = 0;
// if($type == 1) {
// $query = AppointmentT::find()
// ->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
// ->where('appointment_t.is_first=1 and car_t.is_track=0')
// ->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
//
// $user_ids = $this->getChildrenUserIDs();
// $query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
//
// if($car_man != '') {
// $query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
// }
// if($phone != '') {
// $query = $query->andWhere('car_t.phone="'.$phone.'"');
// }
// if($car_no != '') {
// $query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
// }
// if($sort_key != '') {
// $query = $query->orderBy($sort_key.' '.$sort_value);
// }
// $next_item = $query->offset($next_index)->one();
// if($next_item) {
// $next_id = $next_item->car_id;
// }
// $next_index++;
// }
// if($type == 2) {
// $query = AppointmentT::find()
// ->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
// ->where('appointment_t.is_first=0 and car_t.is_track=0')
// ->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
//
// $user_ids = $this->getChildrenUserIDs();
// $query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
//
// if($car_man != '') {
// $query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
// }
// if($phone != '') {
// $query = $query->andWhere('car_t.phone="'.$phone.'"');
// }
// if($car_no != '') {
// $query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
// }
// if($sort_key != '') {
// $query = $query->orderBy($sort_key.' '.$sort_value);
// }
// $next_item = $query->offset($next_index)->one();
// if($next_item) {
// $next_id = $next_item->car_id;
// }
// $next_index++;
// }
// if($type == 3) {
// $query = AppointmentT::find()
// ->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
// ->where('appointment_t.is_first=0 and car_t.is_track=0');
//
// $user_ids = $this->getChildrenUserIDs();
// $query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
//
// if($car_man != '') {
// $query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
// }
// if($phone != '') {
// $query = $query->andWhere('car_t.phone="'.$phone.'"');
// }
// if($car_no != '') {
// $query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
// }
// if($sort_key != '') {
// $query = $query->orderBy($sort_key.' '.$sort_value);
// }
// $next_item = $query->offset($next_index)->one();
// if($next_item) {
// $next_id = $next_item->car_id;
// }
// $next_index++;
// }
// if($type == 4) {
// $query = OrderT::find()
// ->where('status_id=1 and return_status_id>0')
// ->orderBy('submit_date DESC, id DESC');
// $user_items = $this->my->getChildren();
// $user_ids[] = $this->my->id;
// if($user_items) {
// foreach($user_items as $user_item) {
// $user_ids[] = $user_item->id;
// }
// }
// $query = $query->andWhere(['in','user_id',$user_ids]);
// if($car_man != '') {
// $query = $query->andWhere('car_man="'.$car_man.'"');
// }
// if($phone != '') {
// $query = $query->andWhere('link_phone="'.$phone.'"');
// }
// if($car_no != '') {
// $query = $query->andWhere('car_no="'.$car_no.'"');
// }
// $next_item = $query->offset($next_index)->one();
// if($next_item) {
// $next_id = $next_item->car_id;
// }
// $next_index++;
// }
//
//// $gift_type_items = GiftType2T::find()->all();
// $gift_group_items = GiftGroupT::find()
// ->where('is_free=0')
// ->all();
// $gift_free_group_items = GiftGroupT::find()
// ->where('is_free=1')
// ->all();
// //获取礼品数据
// $sel_gifts = array();
// $tmp_items = OrderGiftT::find()
// ->where('order_id='.$order_info->id)
// ->all();
// foreach($tmp_items as $item) {
// $sel_gifts[$item->group_id] = $item;
// }
//
// $list = MeetT::getAllData(1);
//
// $business_group = BusinessGroupT::find()->all();
//
// return $this->render('info',[
// 'type' => $type,
// 'car_info' => $car_info,
// 'insurer_type_items' => $insurer_type_items,
// 'order_info' => $order_info,
// 'insurer_company_items' => $insurer_company_items,
// 'insurer_company2_items' => $insurer_company2_items,
// 'list' => $list,
// 'pay_type_items' => $pay_type_items,
// 'car_use_items' => $car_use_items,
// 'car_type_items' => $car_type_items,
// 'brand_items' => $brand_items,
// 'series_items' => $series_items,
// 'displacement_items' => $displacement_items,
// 'direction_items' => $direction_items,
// 'range_items' => $range_items,
// 'city_items' => $city_items,
// 'district_items' => $district_items,
// 'gift_items' => $gift_items,
// 'success_items' => $success_items,
// 'failure_items' => $failure_items,
// 'next_id' => $next_id,
// 'next_index' => $next_index,
// 'car_man' => $car_man,
// 'car_no' => $car_no,
// 'phone' => $phone,
// 'page' => $page,
// 'sort_key' => $sort_key,
// 'sort_value' => $sort_value,
// 'back_params' => $back_params,
//// 'gift_type_items' => $gift_type_items,
// 'gift_group_items' => $gift_group_items,
// 'gift_free_group_items' => $gift_free_group_items,
// 'sel_gifts' => $sel_gifts,
// 'business_group' => $business_group,
// 'business_group_id' => $this->my->business_group_id,
// ]);
// }
public function actionInfo()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$type = $request->get('type',0);
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$page = $request->get('page',1);
$sort_key = $request->get('sort_key','appointment_t.pdate');
$sort_value = $request->get('sort_value','ASC');
$next_index = $request->get('next_index',0);
$back_params = $request->get('back_params');
$my_path = $this->my->group?$this->my->group->getPath():'';
$car_info = CarT::findOne(['id'=>$id]);
$order_info = $car_info->getOrders()->orderBy('id DESC')->one();
if(!$order_info) {
$user_id = 0;
if($car_info->location == 2) {
$b_info = CarBT::findOne(['id'=>$car_info->id]);
$user_id = $b_info->user_id;
}
if($car_info->location == 3) {
$c_info = CarCT::findOne(['id'=>$car_info->id]);
$user_id = $c_info->user_id;
}
if($car_info->location == 4) {
$d_info = CarDT::findOne(['id'=>$car_info->id]);
$user_id = $d_info->user_id;
}
$order_info = new OrderT();
$order_info->car_id = $car_info->id;
$order_info->car_no = $car_info->car_no;
$order_info->engine_no = $car_info->engine_no;
$order_info->car_frame_no = $car_info->car_frame_no;
$order_info->car_man = $car_info->car_man;
$order_info->user_id = $user_id;
$order_info->status_id = 1;
$order_info->id_man = $car_info->car_man;
$order_info->link_man = $car_info->car_man;
$order_info->link_phone = $car_info->phone;
$order_info->save();
}
$insurer_type_items = InsurerTypeT::find()->all();
$insurer_company_items = InsurerCompanyT::find()->all();
$insurer_company2_items = InsurerCompany2T::find()->all();
$pay_type_items = PayTypeT::find()->all();
$car_use_items = CarUseT::find()->all();
$car_type_items = CarTypeT::find()->all();
$brand_items = BrandT::find()->all();
$series_items = SeriesT::find()
->where('brand_id='.intval($car_info->brand_id))
->all();
$displacement_items = DisplacementT::find()
->where('series_id='.intval($car_info->series_id))
->all();
$direction_items = DirectionT::find()
->all();
$range_items = RangeT::find()
->all();
$city_items = CityT::find()
->all();
$district_items = DistrictT::find()
->orderBy('order_id ASC')
->all();
$gift_items = GiftT::find()
->where('type_id=1')
->all();
$success_items = InvalidT::getTree(1);
$failure_items = InvalidT::getTreeXinbaoNew(2);
//下一辆
$next_id = 0;
if($type == 1) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=1 and car_t.is_track=0')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 2) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.is_track=0')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 3) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.is_track=0');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 4) {
$query = OrderT::find()
->where('status_id=1 and return_status_id>0')
->orderBy('submit_date DESC, id DESC');
$user_items = $this->my->getChildren();
$user_ids[] = $this->my->id;
if($user_items) {
foreach($user_items as $user_item) {
$user_ids[] = $user_item->id;
}
}
$query = $query->andWhere(['in','user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_man="'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('link_phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_no="'.$car_no.'"');
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
// $gift_type_items = GiftType2T::find()->all();
$gift_group_items = GiftGroupT::find()
->where('is_free=0')
->all();
$gift_free_group_items = GiftGroupT::find()
->where('is_free=1')
->all();
//获取礼品数据
$sel_gifts = array();
$tmp_items = OrderGiftT::find()
->where('order_id='.$order_info->id)
->all();
foreach($tmp_items as $item) {
$sel_gifts[$item->group_id] = $item;
}
$list = MeetT::getAllData(1);
$business_group = BusinessGroupT::find()->all();
$order_ad=OrderAddress::findOne(['id'=>$order_info->addr_id]);
//非车险方案表
// $scheme_items=Scheme::find()->all();
$province = Region::find()->asArray()->where(['parent_id'=>0])->andWhere(['level'=>1])->all();
// if($order_ad){
// $c = Region::find()->asArray()->where(['parent_id'=>$order_ad->province])->andWhere(['level'=>2])->all();
// $d = Region::find()->asArray()->where(['parent_id'=>$order_ad->city,'level'=>3])->all();
// $e = Region::find()->asArray()->where(['parent_id'=>$order_ad->district,'level'=>4])->all();
//
// }else{
// $c = Region::find()->asArray()->andWhere(['level'=>2])->all();
// $d = Region::find()->asArray()->where(['level'=>3])->all();
// $e = Region::find()->asArray()->where(['level'=>4])->all();
// }
$c=[];
$d=[];
$e=[];
// if($order_ad){
// $c = Region::find()->asArray()->where(['parent_id'=>$order_ad->province])->andWhere(['level'=>2])->all();
// $d = Region::find()->asArray()->where(['parent_id'=>$order_ad->city,'level'=>3])->all();
// $e = Region::find()->asArray()->where(['parent_id'=>$order_ad->district,'level'=>4])->all();
//
// }else{
// $c = Region::find()->asArray()->andWhere(['level'=>2])->all();
// $d = Region::find()->asArray()->where(['level'=>3])->all();
// $e = Region::find()->asArray()->where(['level'=>4])->all();
// }
return $this->render('info',[
'type' => $type,
'car_info' => $car_info,
'insurer_type_items' => $insurer_type_items,
'order_info' => $order_info,
'insurer_company_items' => $insurer_company_items,
'insurer_company2_items' => $insurer_company2_items,
'list' => $list,
'pay_type_items' => $pay_type_items,
'car_use_items' => $car_use_items,
'car_type_items' => $car_type_items,
'brand_items' => $brand_items,
'series_items' => $series_items,
'displacement_items' => $displacement_items,
'direction_items' => $direction_items,
'range_items' => $range_items,
'city_items' => $city_items,
'district_items' => $district_items,
'gift_items' => $gift_items,
'success_items' => $success_items,
'failure_items' => $failure_items,
'next_id' => $next_id,
'next_index' => $next_index,
'car_man' => $car_man,
'car_no' => $car_no,
'phone' => $phone,
'page' => $page,
'sort_key' => $sort_key,
'sort_value' => $sort_value,
'back_params' => $back_params,
// 'gift_type_items' => $gift_type_items,
'gift_group_items' => $gift_group_items,
'gift_free_group_items' => $gift_free_group_items,
'sel_gifts' => $sel_gifts,
'business_group' => $business_group,
'business_group_id' => $this->my->business_group_id,
'province' => $province,
'city' =>$c,
'district' =>$d,
'twon' =>isset($e)?$e:[],
'order_ad' =>isset($order_ad)?$order_ad:[],
]);
}
/*
* 获取地区
*/
public function actionGetRegion(){
$request = Yii::$app->request;
$parent_id =$request->get('parent_id');
$selected =$request->get('selected',0);
$data = Region::find()->where("parent_id=".$parent_id)->asArray()->all();
$html = '';
if($data){
foreach($data as $h){
if($h['id'] == $selected){
$html .= "< option value = '{$h[' id ' ] } ' selected > {$h['name']}< / option > ";
}
$html .= "< option value = '{$h[' id ' ] } ' > {$h['name']}< / option > ";
}
}
echo $html;
}
public function actionGetTown(){
$request = Yii::$app->request;
$parent_id =$request->get('parent_id');
$data = Region::find()->where("parent_id=".$parent_id)->asArray()->all();
// $data = M('region')->where("parent_id",$parent_id)->select();
$html = '';
if($data){
foreach($data as $h){
$html .= "< option value = '{$h[' id ' ] } ' > {$h['name']}< / option > ";
}
}
if(empty($html)){
echo '0';
}else{
echo $html;
}
}
public function actionInfoView()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$type = $request->get('type',0);
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$page = $request->get('page',1);
$sort_key = $request->get('sort_key','appointment_t.pdate');
$sort_value = $request->get('sort_value','ASC');
$next_index = $request->get('next_index',0);
$car_info = CarT::findOne(['id'=>$id]);
$failure_items = InvalidT::getTree(2);
//礼品
$gift_items = CarGiftT::find()
->where('car_id='.$car_info->id)
->orderBy('strategy_id DESC')
->all();
//下一辆
$next_id = 0;
if($type == 1) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=1 and car_t.is_track=1')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 2) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.is_track=1')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 3) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.is_track=1');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
return $this->render('info-view',[
'type' => $type,
'car_info' => $car_info,
'failure_items' => $failure_items,
'next_id' => $next_id,
'next_index' => $next_index,
'car_man' => $car_man,
'car_no' => $car_no,
'phone' => $phone,
'page' => $page,
'sort_key' => $sort_key,
'sort_value' => $sort_value,
'gift_items' => $gift_items
]);
}
public function actionInfoTrack()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$type = $request->get('type',0);
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$page = $request->get('page',1);
$sort_key = $request->get('sort_key','appointment_t.pdate');
$sort_value = $request->get('sort_value','ASC');
$next_index = $request->get('next_index',0);
$back_params = $request->get('back_params');
$car_info = CarT::findOne(['id'=>$id]);
$car_use_items = CarUseT::find()->all();
$car_type_items = CarTypeT::find()->all();
$brand_items = BrandT::find()->all();
$series_items = SeriesT::find()
->where('brand_id='.intval($car_info->brand_id))
->all();
$displacement_items = DisplacementT::find()
->where('series_id='.intval($car_info->series_id))
->all();
// $failure_items = InvalidT::getTree(2);
$failure_items = InvalidT::getTrees();
//新礼品
$query = GiftTicketT::find()
->orderBy('id DESC');
$items = $query->andWhere('car_no like "'.$car_info->car_no.'"')->all();
//旧礼品
$gift_items = CarGiftT::find()
->where('car_id='.$car_info->id)
->orderBy('strategy_id DESC')
->all();
//下一辆
$next_id = 0;
if($type == 1) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=1 and car_t.is_track=1')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 2) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.is_track=1')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 3) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.is_track=1');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
$list = MeetT::getAllData(2);
//登陆用户ID
$uid = $this->my->role_id;
$aid = $this->my->id;
//获取业务分组
$business_group = BusinessGroupT::find()->all();
$business_group_id = $this->my->business_group_id;
return $this->render('info-track',[
'type' => $type,
'car_info' => $car_info,
'failure_items' => $failure_items,
'next_id' => $next_id,
'list' => $list,
'items' => $items,
'gift_items' => $gift_items,
'uid' => $uid,
'next_index' => $next_index,
'car_man' => $car_man,
'car_no' => $car_no,
'phone' => $phone,
'page' => $page,
'sort_key' => $sort_key,
'sort_value' => $sort_value,
'car_use_items' => $car_use_items,
'car_type_items' => $car_type_items,
'brand_items' => $brand_items,
'series_items' => $series_items,
'displacement_items' => $displacement_items,
'back_params' => $back_params,
'business_group' => $business_group,
'business_group_id' => $business_group_id,
'adid' => $aid,
]);
}
public function actionInfoTrackFix()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$type = $request->get('type',0);
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$page = $request->get('page',1);
$sort_key = $request->get('sort_key','appointment_t.pdate');
$sort_value = $request->get('sort_value','ASC');
$next_index = $request->get('next_index',0);
$back_params = $request->get('back_params');
$car_info = CarT::findOne(['id'=>$id]);
$car_use_items = CarUseT::find()->all();
$car_type_items = CarTypeT::find()->all();
$brand_items = BrandT::find()->all();
$series_items = SeriesT::find()
->where('brand_id='.intval($car_info->brand_id))
->all();
$displacement_items = DisplacementT::find()
->where('series_id='.intval($car_info->series_id))
->all();
$failure_items = InvalidT::getTree(2);
//新礼品
$query = GiftTicketT::find()
->orderBy('id DESC');
$items = $query->andWhere('car_no like "'.$car_info->car_no.'"')->all();
//旧礼品
$gift_items = CarGiftT::find()
->where('car_id='.$car_info->id)
->orderBy('strategy_id DESC')
->all();
//下一辆
$next_id = 0;
if($type == 1) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=1 and car_t.is_track=1')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 2) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.is_track=1')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 3) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.is_track=1');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
$list = MeetT::getAllData(2);
//登陆用户ID
$uid = $this->my->role_id;
//获取业务分组
$business_group = BusinessGroupT::find()->all();
$business_group_id = $this->my->business_group_id;
return $this->render('info-track-fix',[
'type' => $type,
'car_info' => $car_info,
'failure_items' => $failure_items,
'next_id' => $next_id,
'list' => $list,
'items' => $items,
'gift_items' => $gift_items,
'uid' => $uid,
'next_index' => $next_index,
'car_man' => $car_man,
'car_no' => $car_no,
'phone' => $phone,
'page' => $page,
'sort_key' => $sort_key,
'sort_value' => $sort_value,
'car_use_items' => $car_use_items,
'car_type_items' => $car_type_items,
'brand_items' => $brand_items,
'series_items' => $series_items,
'displacement_items' => $displacement_items,
'back_params' => $back_params,
'business_group' => $business_group,
'business_group_id' => $business_group_id,
]);
}
// public function actionInfoRenewal()
// {
// $request = Yii::$app->request;
// $id = $request->get('id',0);
// $type = $request->get('type',0);
// $car_man = $request->get('car_man');
// $phone = $request->get('phone');
// $car_no = $request->get('car_no');
// $page = $request->get('page',1);
// $sort_key = $request->get('sort_key','appointment_t.pdate');
// $sort_value = $request->get('sort_value','ASC');
// $next_index = $request->get('next_index',0);
// $back_params = $request->get('back_params');
// $my_path = $this->my->group?$this->my->group->getPath():'';
//
// $car_info = CarT::findOne(['id'=>$id]);
// $order_info = $car_info->getOrders()->orderBy('id DESC')->one();
// if(!$order_info) {
// $user_id = 0;
// if($car_info->location == 2) {
// $b_info = CarBT::findOne(['id'=>$car_info->id]);
// $user_id = $b_info->user_id;
// }
// if($car_info->location == 3) {
// $c_info = CarCT::findOne(['id'=>$car_info->id]);
// $user_id = $c_info->user_id;
// }
// if($car_info->location == 4) {
// $d_info = CarDT::findOne(['id'=>$car_info->id]);
// $user_id = $d_info->user_id;
// }
// $order_info = new OrderT();
// $order_info->car_id = $car_info->id;
// $order_info->car_no = $car_info->car_no;
// $order_info->engine_no = $car_info->engine_no;
// $order_info->car_frame_no = $car_info->car_frame_no;
// $order_info->car_man = $car_info->car_man;
// $order_info->user_id = $user_id;
// $order_info->status_id = 1;
// $order_info->id_man = $car_info->car_man;
// $order_info->link_man = $car_info->car_man;
// $order_info->link_phone = $car_info->phone;
// $order_info->save();
// }
// $insurer_type_items = InsurerTypeT::find()->all();
// $insurer_company_items = InsurerCompanyT::find()->all();
// $insurer_company2_items = InsurerCompany2T::find()->all();
// $pay_type_items = PayTypeT::find()->all();
// $car_use_items = CarUseT::find()->all();
// $car_type_items = CarTypeT::find()->all();
// $brand_items = BrandT::find()->all();
// $series_items = SeriesT::find()
// ->where('brand_id='.intval($car_info->brand_id))
// ->all();
// $displacement_items = DisplacementT::find()
// ->where('series_id='.intval($car_info->series_id))
// ->all();
// $direction_items = DirectionT::find()
// ->all();
// $range_items = RangeT::find()
// ->all();
// $city_items = CityT::find()
// ->all();
// $district_items = DistrictT::find()
// ->orderBy('order_id ASC')
// ->all();
// $gift_items = GiftT::find()
// ->where('type_id=1')
// ->all();
// $success_items = InvalidT::getTree(1);
// $failure_items = InvalidT::getTreeXubao(2);
//
// //下一辆
// $next_id = 0;
// if($type == 1) {
// $query = AppointmentT::find()
// ->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
// ->where('appointment_t.is_first=1 and car_t.location=4')
// ->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
//
// $user_ids = $this->getChildrenUserIDs();
// $query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
//
// if($car_man != '') {
// $query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
// }
// if($phone != '') {
// $query = $query->andWhere('car_t.phone="'.$phone.'"');
// }
// if($car_no != '') {
// $query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
// }
// if($sort_key != '') {
// $query = $query->orderBy($sort_key.' '.$sort_value);
// }
// $next_item = $query->offset($next_index)->one();
// if($next_item) {
// $next_id = $next_item->car_id;
// }
// $next_index++;
// }
// if($type == 2) {
// $query = AppointmentT::find()
// ->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
// ->where('appointment_t.is_first=0 and car_t.location=4')
// ->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
//
// $user_ids = $this->getChildrenUserIDs();
// $query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
//
// if($car_man != '') {
// $query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
// }
// if($phone != '') {
// $query = $query->andWhere('car_t.phone="'.$phone.'"');
// }
// if($car_no != '') {
// $query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
// }
// if($sort_key != '') {
// $query = $query->orderBy($sort_key.' '.$sort_value);
// }
// $next_item = $query->offset($next_index)->one();
// if($next_item) {
// $next_id = $next_item->car_id;
// }
// $next_index++;
// }
// if($type == 3) {
// $query = AppointmentT::find()
// ->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
// ->where('appointment_t.is_first=0 and car_t.location=4');
//
// $user_ids = $this->getChildrenUserIDs();
// $query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
//
// if($car_man != '') {
// $query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
// }
// if($phone != '') {
// $query = $query->andWhere('car_t.phone="'.$phone.'"');
// }
// if($car_no != '') {
// $query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
// }
// if($sort_key != '') {
// $query = $query->orderBy($sort_key.' '.$sort_value);
// }
// $next_item = $query->offset($next_index)->one();
// if($next_item) {
// $next_id = $next_item->car_id;
// }
// $next_index++;
// }
// if($type == 4) {
// $query = OrderT::find()
// ->where('status_id=1 and return_status_id>0')
// ->orderBy('submit_date DESC, id DESC');
// $user_items = $this->my->getChildren();
// $user_ids[] = $this->my->id;
// if($user_items) {
// foreach($user_items as $user_item) {
// $user_ids[] = $user_item->id;
// }
// }
// $query = $query->andWhere(['in','user_id',$user_ids]);
// if($car_man != '') {
// $query = $query->andWhere('car_man="'.$car_man.'"');
// }
// if($phone != '') {
// $query = $query->andWhere('link_phone="'.$phone.'"');
// }
// if($car_no != '') {
// $query = $query->andWhere('car_no="'.$car_no.'"');
// }
// $next_item = $query->offset($next_index)->one();
// if($next_item) {
// $next_id = $next_item->car_id;
// }
// $next_index++;
// }
//
//// $gift_type_items = GiftType2T::find()->all();
// $gift_group_items = GiftGroupT::find()
// ->where('is_free=0')
// ->all();
// $gift_free_group_items = GiftGroupT::find()
// ->where('is_free=1')
// ->all();
// //获取礼品数据
// $sel_gifts = array();
// $tmp_items = OrderGiftT::find()
// ->where('order_id='.$order_info->id)
// ->all();
// foreach($tmp_items as $item) {
// $sel_gifts[$item->group_id] = $item;
// }
//
// $list = MeetT::getAllData(1);
//
// $business_group = BusinessGroupT::find()->all();
//
// return $this->render('info-renewal',[
// 'type' => $type,
// 'car_info' => $car_info,
// 'insurer_type_items' => $insurer_type_items,
// 'order_info' => $order_info,
// 'insurer_company_items' => $insurer_company_items,
// 'insurer_company2_items' => $insurer_company2_items,
// 'pay_type_items' => $pay_type_items,
// 'car_use_items' => $car_use_items,
// 'car_type_items' => $car_type_items,
// 'brand_items' => $brand_items,
// 'series_items' => $series_items,
// 'displacement_items' => $displacement_items,
// 'direction_items' => $direction_items,
// 'range_items' => $range_items,
// 'city_items' => $city_items,
// 'district_items' => $district_items,
// 'gift_items' => $gift_items,
// 'success_items' => $success_items,
// 'failure_items' => $failure_items,
// 'next_id' => $next_id,
// 'list' => $list,
// 'next_index' => $next_index,
// 'car_man' => $car_man,
// 'car_no' => $car_no,
// 'phone' => $phone,
// 'page' => $page,
// 'sort_key' => $sort_key,
// 'sort_value' => $sort_value,
// 'back_params' => $back_params,
//// 'gift_type_items' => $gift_type_items,
// 'gift_group_items' => $gift_group_items,
// 'gift_free_group_items' => $gift_free_group_items,
// 'sel_gifts' => $sel_gifts,
// 'my_path' => $my_path,
// 'business_group' => $business_group,
// 'business_group_id' => $this->my->business_group_id,
// ]);
// }
public function actionInfoRenewal()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$type = $request->get('type',0);
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$page = $request->get('page',1);
$sort_key = $request->get('sort_key','appointment_t.pdate');
$sort_value = $request->get('sort_value','ASC');
$next_index = $request->get('next_index',0);
$back_params = $request->get('back_params');
$my_path = $this->my->group?$this->my->group->getPath():'';
$car_info = CarT::findOne(['id'=>$id]);
$order_info = $car_info->getOrders()->orderBy('id DESC')->one();
if(!$order_info) {
$user_id = 0;
if($car_info->location == 2) {
$b_info = CarBT::findOne(['id'=>$car_info->id]);
$user_id = $b_info->user_id;
}
if($car_info->location == 3) {
$c_info = CarCT::findOne(['id'=>$car_info->id]);
$user_id = $c_info->user_id;
}
if($car_info->location == 4) {
$d_info = CarDT::findOne(['id'=>$car_info->id]);
$user_id = $d_info->user_id;
}
$order_info = new OrderT();
$order_info->car_id = $car_info->id;
$order_info->car_no = $car_info->car_no;
$order_info->engine_no = $car_info->engine_no;
$order_info->car_frame_no = $car_info->car_frame_no;
$order_info->car_man = $car_info->car_man;
$order_info->user_id = $user_id;
$order_info->status_id = 1;
$order_info->id_man = $car_info->car_man;
$order_info->link_man = $car_info->car_man;
$order_info->link_phone = $car_info->phone;
$order_info->save();
}
$insurer_type_items = InsurerTypeT::find()->all();
$insurer_company_items = InsurerCompanyT::find()->all();
$insurer_company2_items = InsurerCompany2T::find()->all();
$pay_type_items = PayTypeT::find()->all();
$car_use_items = CarUseT::find()->all();
$car_type_items = CarTypeT::find()->all();
$brand_items = BrandT::find()->all();
$series_items = SeriesT::find()
->where('brand_id='.intval($car_info->brand_id))
->all();
$displacement_items = DisplacementT::find()
->where('series_id='.intval($car_info->series_id))
->all();
$direction_items = DirectionT::find()
->all();
$range_items = RangeT::find()
->all();
$city_items = CityT::find()
->all();
$district_items = DistrictT::find()
->orderBy('order_id ASC')
->all();
$gift_items = GiftT::find()
->where('type_id=1')
->all();
$success_items = InvalidT::getTree(1);
$failure_items = InvalidT::getTreeXubao(2);
//下一辆
$next_id = 0;
if($type == 1) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=1 and car_t.location=4')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 2) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.location=4')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 3) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.location=4');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 4) {
$query = OrderT::find()
->where('status_id=1 and return_status_id>0')
->orderBy('submit_date DESC, id DESC');
$user_items = $this->my->getChildren();
$user_ids[] = $this->my->id;
if($user_items) {
foreach($user_items as $user_item) {
$user_ids[] = $user_item->id;
}
}
$query = $query->andWhere(['in','user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_man="'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('link_phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_no="'.$car_no.'"');
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
// $gift_type_items = GiftType2T::find()->all();
$gift_group_items = GiftGroupT::find()
->where('is_free=0')
->all();
$gift_free_group_items = GiftGroupT::find()
->where('is_free=1')
->all();
//获取礼品数据
$sel_gifts = array();
$tmp_items = OrderGiftT::find()
->where('order_id='.$order_info->id)
->all();
foreach($tmp_items as $item) {
$sel_gifts[$item->group_id] = $item;
}
$list = MeetT::getAllData(1);
$business_group = BusinessGroupT::find()->all();
$order_ad=OrderAddress::findOne(['id'=>$order_info->addr_id]);
$province = Region::find()->asArray()->where(['parent_id'=>0])->andWhere(['level'=>1])->all();
// if($order_ad){
// $c = Region::find()->asArray()->where(['parent_id'=>$order_ad->province])->andWhere(['level'=>2])->all();
// $d = Region::find()->asArray()->where(['parent_id'=>$order_ad->city,'level'=>3])->all();
// $e = Region::find()->asArray()->where(['parent_id'=>$order_ad->district,'level'=>4])->all();
//
// }else{
// $c = Region::find()->asArray()->andWhere(['level'=>2])->all();
// $d = Region::find()->asArray()->where(['level'=>3])->all();
// $e = Region::find()->asArray()->where(['level'=>4])->all();
// }
$c=[];
$d=[];
$e=[];
// if($order_ad){
// $c = Region::find()->asArray()->where(['parent_id'=>$order_ad->province])->andWhere(['level'=>2])->all();
// $d = Region::find()->asArray()->where(['parent_id'=>$order_ad->city,'level'=>3])->all();
// $e = Region::find()->asArray()->where(['parent_id'=>$order_ad->district,'level'=>4])->all();
//
// }else{
// $c = Region::find()->asArray()->andWhere(['level'=>2])->all();
// $d = Region::find()->asArray()->where(['level'=>3])->all();
// $e = Region::find()->asArray()->where(['level'=>4])->all();
// }
return $this->render('info-renewal',[
'type' => $type,
'car_info' => $car_info,
'insurer_type_items' => $insurer_type_items,
'order_info' => $order_info,
'insurer_company_items' => $insurer_company_items,
'insurer_company2_items' => $insurer_company2_items,
'pay_type_items' => $pay_type_items,
'car_use_items' => $car_use_items,
'car_type_items' => $car_type_items,
'brand_items' => $brand_items,
'series_items' => $series_items,
'displacement_items' => $displacement_items,
'direction_items' => $direction_items,
'range_items' => $range_items,
'city_items' => $city_items,
'district_items' => $district_items,
'gift_items' => $gift_items,
'success_items' => $success_items,
'failure_items' => $failure_items,
'next_id' => $next_id,
'list' => $list,
'next_index' => $next_index,
'car_man' => $car_man,
'car_no' => $car_no,
'phone' => $phone,
'page' => $page,
'sort_key' => $sort_key,
'sort_value' => $sort_value,
'back_params' => $back_params,
// 'gift_type_items' => $gift_type_items,
'gift_group_items' => $gift_group_items,
'gift_free_group_items' => $gift_free_group_items,
'sel_gifts' => $sel_gifts,
'my_path' => $my_path,
'business_group' => $business_group,
'business_group_id' => $this->my->business_group_id,
'province' => $province,
'city' =>$c,
'district' =>$d,
// 'address' =>$address,
'twon' =>isset($e)?$e:[],
'order_ad' =>isset($order_ad)?$order_ad:[],
]);
}
public function actionNonInfoRenewal()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$type = $request->get('type',0);
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$page = $request->get('page',1);
$sort_key = $request->get('sort_key','appointment_t.pdate');
$sort_value = $request->get('sort_value','ASC');
$next_index = $request->get('next_index',0);
$back_params = $request->get('back_params');
$my_path = $this->my->group?$this->my->group->getPath():'';
$car_info = CarT::findOne(['id'=>$id]);
$order_info = $car_info->getOrders()->orderBy('id DESC')->one();
if(!$order_info) {
$user_id = 0;
if($car_info->location == 2) {
$b_info = CarBT::findOne(['id'=>$car_info->id]);
$user_id = $b_info->user_id;
}
if($car_info->location == 3) {
$c_info = CarCT::findOne(['id'=>$car_info->id]);
$user_id = $c_info->user_id;
}
if($car_info->location == 4) {
$d_info = CarDT::findOne(['id'=>$car_info->id]);
$user_id = $d_info->user_id;
}
$order_info = new OrderT();
$order_info->car_id = $car_info->id;
$order_info->car_no = $car_info->car_no;
$order_info->engine_no = $car_info->engine_no;
$order_info->car_frame_no = $car_info->car_frame_no;
$order_info->car_man = $car_info->car_man;
$order_info->user_id = $user_id;
$order_info->status_id = 1;
$order_info->id_man = $car_info->car_man;
$order_info->link_man = $car_info->car_man;
$order_info->link_phone = $car_info->phone;
$order_info->save();
}
$insurer_type_items = InsurerTypeT::find()->all();
$insurer_company_items = InsurerCompanyT::find()->all();
$insurer_company2_items = InsurerCompany2T::find()->all();
$pay_type_items = PayTypeT::find()->all();
$car_use_items = CarUseT::find()->all();
$car_type_items = CarTypeT::find()->all();
$brand_items = BrandT::find()->all();
$series_items = SeriesT::find()
->where('brand_id='.intval($car_info->brand_id))
->all();
$displacement_items = DisplacementT::find()
->where('series_id='.intval($car_info->series_id))
->all();
$direction_items = DirectionT::find()
->all();
$range_items = RangeT::find()
->all();
$city_items = CityT::find()
->all();
$district_items = DistrictT::find()
->orderBy('order_id ASC')
->all();
$gift_items = GiftT::find()
->where('type_id=1')
->all();
$success_items = InvalidT::getTree(1);
$failure_items = InvalidT::getTreeXubao(2);
//下一辆
$next_id = 0;
if($type == 1) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=1 and car_t.location=4')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 2) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.location=4')
->andWhere('appointment_t.pdate< ="'.date('Y-m-d').'"');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 3) {
$query = AppointmentT::find()
->leftJoin('car_t','`car_t`.`id`=`appointment_t`.`car_id`')
->where('appointment_t.is_first=0 and car_t.location=4');
$user_ids = $this->getChildrenUserIDs();
$query = $query->andWhere(['in','appointment_t.user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($sort_key != '') {
$query = $query->orderBy($sort_key.' '.$sort_value);
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
if($type == 4) {
$query = OrderT::find()
->where('status_id=1 and return_status_id>0')
->orderBy('submit_date DESC, id DESC');
$user_items = $this->my->getChildren();
$user_ids[] = $this->my->id;
if($user_items) {
foreach($user_items as $user_item) {
$user_ids[] = $user_item->id;
}
}
$query = $query->andWhere(['in','user_id',$user_ids]);
if($car_man != '') {
$query = $query->andWhere('car_man="'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('link_phone="'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_no="'.$car_no.'"');
}
$next_item = $query->offset($next_index)->one();
if($next_item) {
$next_id = $next_item->car_id;
}
$next_index++;
}
// $gift_type_items = GiftType2T::find()->all();
$gift_group_items = GiftGroupT::find()
->where('is_free=0')
->all();
$gift_free_group_items = GiftGroupT::find()
->where('is_free=1')
->all();
//获取礼品数据
$sel_gifts = array();
$tmp_items = OrderGiftT::find()
->where('order_id='.$order_info->id)
->all();
foreach($tmp_items as $item) {
$sel_gifts[$item->group_id] = $item;
}
$list = MeetT::getAllData(1);
$business_group = BusinessGroupT::find()->all();
$order_ad=OrderAddress::findOne(['id'=>$order_info->addr_id]);
$province = Region::find()->asArray()->where(['parent_id'=>0])->andWhere(['level'=>1])->all();
if($order_ad){
$c = Region::find()->asArray()->where(['parent_id'=>$order_ad->province])->andWhere(['level'=>2])->all();
$d = Region::find()->asArray()->where(['parent_id'=>$order_ad->city,'level'=>3])->all();
$e = Region::find()->asArray()->where(['parent_id'=>$order_ad->district,'level'=>4])->all();
}else{
$c = Region::find()->asArray()->andWhere(['level'=>2])->all();
$d = Region::find()->asArray()->where(['level'=>3])->all();
$e = Region::find()->asArray()->where(['level'=>4])->all();
}
return $this->render('non-info-renewal',[
'type' => $type,
'car_info' => $car_info,
'insurer_type_items' => $insurer_type_items,
'order_info' => $order_info,
'insurer_company_items' => $insurer_company_items,
'insurer_company2_items' => $insurer_company2_items,
'pay_type_items' => $pay_type_items,
'car_use_items' => $car_use_items,
'car_type_items' => $car_type_items,
'brand_items' => $brand_items,
'series_items' => $series_items,
'displacement_items' => $displacement_items,
'direction_items' => $direction_items,
'range_items' => $range_items,
'city_items' => $city_items,
'district_items' => $district_items,
'gift_items' => $gift_items,
'success_items' => $success_items,
'failure_items' => $failure_items,
'next_id' => $next_id,
'list' => $list,
'next_index' => $next_index,
'car_man' => $car_man,
'car_no' => $car_no,
'phone' => $phone,
'page' => $page,
'sort_key' => $sort_key,
'sort_value' => $sort_value,
'back_params' => $back_params,
// 'gift_type_items' => $gift_type_items,
'gift_group_items' => $gift_group_items,
'gift_free_group_items' => $gift_free_group_items,
'sel_gifts' => $sel_gifts,
'my_path' => $my_path,
'business_group' => $business_group,
'business_group_id' => $this->my->business_group_id,
'province' => $province,
'city' =>$c,
'district' =>$d,
// 'address' =>$address,
'twon' =>isset($e)?$e:[],
'order_ad' =>isset($order_ad)?$order_ad:[],
]);
}
public function actionInfoEdit()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$info = CarT::findOne(['id'=>$id]);
$car_use_items = CarUseT::find()->all();
$car_type_items = CarTypeT::find()->all();
$brand_items = BrandT::find()->all();
$factory_items = FactoryT::find()
->where('brand_id='.intval($info->brand_id))
->all();
$series_items = SeriesT::find()
->where('factory_id='.intval($info->factory_id))
->all();
$displacement_items = DisplacementT::find()
->where('series_id='.intval($info->series_id))
->all();
$year_items = YearT::find()
->where('series_id='.intval($info->series_id.' and displacement_id='.intval($info->displacement_id)))
->all();
$model_items = ModelT::find()
->where('series_id='.intval($info->series_id))
->andWhere('displacement_id='.intval($info->displacement_id))
->andWhere('year_id='.intval($info->year_id))
->all();
return $this->render('info-edit',[
'info' => $info,
'car_use_items' => $car_use_items,
'car_type_items' => $car_type_items,
'brand_items' => $brand_items,
'factory_items' => $factory_items,
'series_items' => $series_items,
'displacement_items' => $displacement_items,
'year_items' => $year_items,
'model_items' => $model_items
]);
}
public function actionFactories()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$brand_id = $request->get('brand_id',0);
$factories = FactoryT::find()
->where('brand_id='.$brand_id)
->all();
$html = '< option value = "0" > ---请选择---< / option > ';
foreach($factories as $factory) {
$html .= '< option value = '.$factory->id.' > '.$factory->name.'< / option > ';
}
$result['success'] = true;
$result['html'] = $html;
return $result;
}
public function actionSeries()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$factory_id = $request->get('factory_id',0);
$series = Series2T::find()
->where('factory_id='.$factory_id)
->all();
$html = '< option value = "0" > ---请选择---< / option > ';
foreach($series as $series_info) {
$html .= '< option value = '.$series_info->id.' > '.$series_info->name.'< / option > ';
}
$result['success'] = true;
$result['html'] = $html;
return $result;
}
public function actionSeriesFix()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$brand_id = $request->get('brand_id',0);
$series = SeriesT::find()
->where('brand_id='.$brand_id)
->all();
$html = '< option value = "0" > ---请选择---< / option > ';
foreach($series as $series_info) {
$html .= '< option value = '.$series_info->id.' > '.$series_info->name.'< / option > ';
}
$result['success'] = true;
$result['html'] = $html;
return $result;
}
public function actionDisplacements()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$series_id = $request->get('series_id',0);
$query = Displacement2T::find()
->where('series_id='.$series_id);
$items = $query->all();
$html = '< option value = "0" > ---请选择---< / option > ';
foreach($items as $item) {
$html .= '< option value = '.$item->id.' > '.$item->name.'< / option > ';
}
$result['success'] = true;
$result['html'] = $html;
return $result;
}
public function actionDisplacementsFix()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$series_id = $request->get('series_id',0);
$query = DisplacementT::find()
->where('series_id='.$series_id);
$items = $query->all();
$html = '< option value = "0" > ---请选择---< / option > ';
foreach($items as $item) {
$html .= '< option value = '.$item->id.' > '.$item->name.'< / option > ';
}
$result['success'] = true;
$result['html'] = $html;
return $result;
}
public function actionYears()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$series_id = $request->get('series_id',0);
$displacement_id = $request->get('displacement_id',0);
$query = YearT::find()
->where('series_id='.$series_id.' and displacement_id='.$displacement_id);
$items = $query->all();
$html = '< option value = "0" > ---请选择---< / option > ';
foreach($items as $item) {
$html .= '< option value = '.$item->id.' > '.$item->name.'< / option > ';
}
$result['success'] = true;
$result['html'] = $html;
return $result;
}
public function actionModelsbak()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$series_id = $request->get('series_id',0);
$displacement_id = $request->get('displacement_id',0);
$year_id = $request->get('year_id',0);
$query = ModelT::find()
->where('series_id='.$series_id.' and displacement_id='.$displacement_id.' and year_id='.$year_id);
$items = $query->all();
$html = '< option value = "0" > ---请选择---< / option > ';
foreach($items as $item) {
$html .= '< option value = '.$item->id.' > '.$item->name.'< / option > ';
}
$result['success'] = true;
$result['html'] = $html;
return $result;
}
public function actionModels()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$factory_id = $request->get('factory_id',0);
$query = ModelT::find()
->where('factory_id='.$factory_id);
$items = $query->all();
$html = '< option value = "0" > ---请选择---< / option > ';
foreach($items as $item) {
$html .= '< option value = '.$item->id.' > '.$item->name.'< / option > ';
}
$result['success'] = true;
$result['html'] = $html;
return $result;
}
//保单信息保存
// public function actionOrderSave()
// {
// Yii::$app->response->format = Response::FORMAT_JSON;
// $request = Yii::$app->request;
// $result = array();
// $result['success'] = false;
// $result['msg'] = '保存失败';
// if ($request->isPost) {
// //状态
// $status_id = $request->post('status_id', 1);
// //车辆信息
// $car_id = $request->post('car_id', 0);
// $car_no = $request->post('car_no');
// $seats = (int)$request->post('seats');
// $register_date = $request->post('register_date');
// $car_man = $request->post('car_man');
// $car_man_number = $request->post('car_man_number');
//
// //保单信息
// $order_id = $request->post('order_id', 0);
// $id_man = $request->post('id_man');
// $id_number = $request->post('id_number');
// $link_man = $request->post('link_man');
// $link_phone = $request->post('link_phone');
// $send_date = $request->post('send_date');
// $company2_id = $request->post('company2_id');
// $pay_type_id = $request->post('pay_type_id');
// $shoufei_id = $request->post('shoufei_id');
// $email = $request->post('email');
// $insurer1_begin_date = $request->post('insurer1_begin_date');
// $insurer2_begin_date = $request->post('insurer2_begin_date');
// $order_remark = $request->post('order_remark');
// $direction1_id = $request->post('direction1_id');
// $range1_id = $request->post('range1_id');
// $city1_id = $request->post('city1_id');
// $district1_id = $request->post('district1_id');
// $send_address1 = $request->post('send_address1');
// $send_address2 = $request->post('send_address2');
// $success_id = $request->post('success_id');
// $gifts = $request->post('gifts');
// $car_man_weixin = $request->post('car_man_weixin');
// $business_group_id = $request->post('business_group_id', 0);
//
// //报价信息
// $total1_clear = $request->post('total1_clear');
// $total1 = $request->post('total1');
// $total1_real = $request->post('total1_real');
// $total1_dis = $request->post('total1_dis');
// $total1_percent = $request->post('total1_percent');
// $total2_clear = $request->post('total2_clear');
// $total2 = $request->post('total2');
// $total3 = $request->post('total3');
// $total_all = $request->post('total_all');
// $total_real = $request->post('total_real');
// $price_remark = $request->post('price_remark');
//
// //报价明细
// $types = $request->post('types', array());
// $nopays = $request->post('nopays', array());
//
// //礼品
// $gifts = $request->post('gifts', array());
//
// if ($car_no == '') {
// $result['msg'] = '请输入车牌号码!';
// return $result;
// }
// //财务信息条件
// $money_man = $request->post('money_man');
// $money_no = $request->post('money_no');
// $money_bank = $request->post('money_bank');
// $paydate= date('Y-m',time());
//// echo '< pre > ';
//// print_r($money_man);
//// var_dump($paydate);
//// die;
//
//
//
// //判断起保日期是否正确
// $begin_date = date('Y-m-d', strtotime('+90 day'));
//// var_dump($begin_date);
//// die;
// if ($insurer1_begin_date != '' & & $insurer1_begin_date > $begin_date) {
// $result['msg'] = '商业起保日期不正确!';
// return $result;
// }
// if ($insurer2_begin_date != '' & & $insurer2_begin_date > $begin_date) {
// $result['msg'] = '交强起保日期不正确!';
// return $result;
// }
// //提交才判断的条件
// if ($status_id > 1) {
// if ($success_id == 0) {
// $result['msg'] = '请选择成功理由';
// return $result;
// }
// if ($seats == 0) {
// $result['msg'] = '请输入座位数';
// return $result;
// }
// }
// //三者不能超过
// if($this->web->max_other_money > 0 & & floatval($types[2]) > $this->web->max_other_money) {
// if($this->web->max_out_rate > 0 & & (1 - $total1_percent)*100 > $this->web->max_out_rate) {
// $result['msg'] = '三者超过' . $this->web->max_other_money . '万,商业折扣率不能超过' . $this->web->max_out_rate.'%';
// return $result;
// }
// }
// //非京牌车优惠率不能超过
// if(substr($car_no,0,strlen('京')) != '京' & & $this->web->max_other_area_rate > 0 & & (1 - $total1_percent)*100 > $this->web->max_other_area_rate) {
// $result['msg'] = '非京牌车辆商业折扣率不能低于'.round((100 - $this->web->max_other_area_rate)/100,2);
// return $result;
// }
// //所有车辆优惠金额不能超过
// if($this->web->max_dis_money > 0 & & $total1_dis > $this->web->max_dis_money) {
// $result['msg'] = '所有车辆减免金额不能超过'.$this->web->max_dis_money.'元';
// return $result;
// }
//
// $tran = CarT::getDb()->beginTransaction();
// try {
// $order_info = OrderT::findOne(['id' => $order_id]);
// $car_info = $order_info->car;
// //车辆信息
// $car_info->car_no = $car_no;
// $car_info->seats = $seats;
// $car_info->register_date = $register_date;
// $car_info->car_man = $car_man;
// $car_info->car_man_number = $car_man_number;
// $car_info->weixin = $car_man_weixin;
// $car_info->save();
//
// //保单信息
// $order_info->car_no = $car_no;
// $order_info->engine_no = $car_info->engine_no;
// $order_info->car_frame_no = $car_info->car_frame_no;
// $order_info->car_man = $car_man;
// $order_info->company2_id = $company2_id;
// $order_info->success_id = $success_id;
// $order_info->status_id = $status_id;
// if ($status_id > 1) {
// $order_info->return_status_id = 0;
// $order_info->return_remark = '';
// $order_info->return_time = 0;
// }
// $order_info->submit_date = date('Y-m-d');
// $order_info->id_man = $id_man;
// $order_info->id_number = $id_number;
// $order_info->link_man = $link_man;
// $order_info->link_phone = $link_phone;
// $order_info->insurer1_begin_date = $insurer1_begin_date;
// $insurer1_end_date = '';
// if ($insurer1_begin_date != '') {
// $insurer1_end_date = date('Y-m-d', strtotime(date('Y-m-d', strtotime($insurer1_begin_date . "+1 year")) . '-1 day'));
// }
// $order_info->insurer1_end_date = $insurer1_end_date;
// $order_info->insurer2_begin_date = $insurer2_begin_date;
// $insurer2_end_date = '';
// if ($insurer2_end_date != '')
// $insurer2_end_date = date('Y-m-d', strtotime(date('Y-m-d', strtotime($insurer2_begin_date . "+1 year")) . '-1 day'));
// $order_info->insurer2_end_date = $insurer2_end_date;
// $order_info->send_date = $send_date;
// $order_info->direction1_id = $direction1_id;
// $order_info->range1_id = $range1_id;
// $order_info->city1_id = $city1_id;
// $order_info->district1_id = $district1_id;
// $order_info->send_address1 = $send_address1;
// $order_info->send_address2 = $send_address2;
// $order_info->pay_type_id = $pay_type_id;
// $order_info->shoufei_id = $shoufei_id;
// $order_info->email = $email;
// $order_info->remark = $order_remark;
//
// $order_info->total1_clear = $total1_clear;
// $order_info->total1 = $total1;
// $order_info->total1_real = $total1_real;
// $order_info->total1_dis = $total1_dis;
// $order_info->total1_percent = $total1_percent;
// $order_info->total2_clear = $total2_clear;
// $order_info->total2 = $total2;
// $order_info->total3 = $total3;
// $order_info->total_all = $total_all;
// $order_info->total_real = $total_real;
// $order_info->price_remark = $price_remark;
// $order_info->business_group_id = $business_group_id;
//
// $order_info->save();
//
// //处理操作人员状态 0:正在操作中,1:操作结束,2:退回操作,3:无效操作,4:放弃操作
// if ($status_id > 1) {
// $order_user_info = OrderUserT::findOne(['user_id' => $this->my->id, 'order_id' => $order_info->id, 'status' => 0]);
// if ($order_user_info) {
// $order_user_info->status = 1;
// $order_user_info->save();
// }
// }
// //礼品
// OrderGiftT::deleteAll('order_id=' . $order_info->id . ' and status=0');
// if (is_array($gifts)) {
// foreach ($gifts as $tmp_str) {
// $tmp = explode('_', $tmp_str);
// $group_id = isset($tmp[0]) ? $tmp[0] : 0;
// $gift_id = isset($tmp[1]) ? $tmp[1] : 0;
// if ($group_id == 0 & & $gift_id == 0) continue;
// $group_info = GiftGroupT::findOne(['id' => $group_id]);
// if (!isset($group_info)) {
// continue;
//// $result['msg'] = '礼品分组有错误,请与主管联系';
//// return $result;
// }
// $gift_info = GiftType3T::findOne(['id' => $gift_id]);
// if (!isset($gift_info)) {
// continue;
//// $result['msg'] = $group_info->name.' 礼品不存在,重新选择';
//// return $result;
// }
// $tmp_count = OrderGiftT::find()->where('order_id=' . $order_info->id . ' and group_id=' . $group_id . ' and status=1')->count();
// if ($tmp_count > 0) {
// continue;
// }
// //处理礼品数量
// if ($status_id > 1) {
// if ($gift_info->total > -1) {
// $gift_info->total = $gift_info->total - 1;
// $gift_info->save();
// }
// }
// $row = new OrderGiftT();
// $row->order_id = $order_info->id;
// $row->group_id = $group_id;
// $row->gift_id = $gift_id;
// $row->is_free = $group_info->is_free;
// $row->gift_type = $gift_info->type;
// $row->send_id = 0;
// $row->send_time = 0;
// $row->price = 0;
// $row->status = 0;
// if (!$row->save()) {
// var_dump($row->errors);
// }
// }
// }
//
// //险种明细
// foreach ($types as $id => $val) {
// $price_row = PriceT::find()
// ->where('order_id=' . $order_info->id . ' and type_id=' . $id)
// ->one();
// if (empty($price_row)) {
// $price_row = new PriceT();
// $price_row->order_id = $order_info->id;
// $price_row->type_id = $id;
// }
// $price_row->val = $val;
// if (!empty($nopays[$id]))
// $price_row->is_nopay = 1;
// else
// $price_row->is_nopay = 0;
// $price_row->save();
// }
//
// //处理预约
// if ($status_id > 1) {
// $tmp_row = AppointmentT::findOne(['car_id' => $car_info->id]);
// if (!empty($tmp_row)) {
// $tmp_row->delete();
// }
// $tmp_status_info = StatusT::findOne(['id' => $status_id]);
// $log_msg = '';
// if ($tmp_status_info) {
// $log_msg = '进入' . $tmp_status_info->name;
// }
// $this->addLog($car_info->id, $log_msg, 1);
// }
//
// //处理公司礼品
// //清除原公司礼品
// CarGiftT::deleteAll('user_id=' . $this->my->id . ' and car_id=' . $car_info->id . ' and order_id=' . $order_info->id . ' and type=1 and status=0');
// foreach ($gifts as $id_str) {
// $gift_ids = explode('-', $id_str);
// if (count($gift_ids) != 2) continue;
// $strategy_id = $gift_ids[0];
// $gift_id = $gift_ids[1];
// $car_gift_info = CarGiftT::find()
// ->where('strategy_id=' . $strategy_id . ' and order_id=' . $order_info->id . ' and gift_id=' . $gift_id)
// ->one();
// if (!$car_gift_info & & $gift_id > 0) {
// $car_gift_info = new CarGiftT();
// $car_gift_info->user_id = $this->my->id;
// $car_gift_info->car_id = $car_info->id;
// $car_gift_info->order_id = $order_info->id;
// $car_gift_info->strategy_id = $strategy_id;
// $car_gift_info->gift_id = $gift_id;
// $car_gift_info->submit_time = time();
// $car_gift_info->status = 0;
// $car_gift_info->type = 1;
// $car_gift_info->save();
// }
// }
// //处理自费礼品
// $gift_items = CarGiftT::find()
// ->where('car_id=' . $car_info->id . ' and order_id=0')
// ->all();
// foreach ($gift_items as $item) {
// $item->order_id = $order_info->id;
// $item->save();
// }
// // 处理财务-如果是在线支付-生成财务分支
//
// if ($status_id > 1) {
// if ($shoufei_id == 2) {
// $order_caiwu = OrderCaiwuT::findOne(['order_id'=>$order_info->id]);
//
// if(!$order_caiwu){
// $order_caiwu = new OrderCaiwuT();
// $order_caiwu->status_id = 2;
// }
//
// $order_caiwu->order_id = $order_info->id;
// $order_caiwu->money_man = $money_man;
// $order_caiwu->money_no = $money_no;
// $order_caiwu->pay_date = $paydate;
// $order_caiwu->money_bank = $money_bank;
// $order_caiwu->save();
// }
//
// }
// $result['success'] = true;
// $result['msg'] = '保存成功';
//
// $tran->commit();
// } catch (\Exception $e) {
// $tran->rollBack();
// throw $e;
// }
//
// }
// return $result;
// }
// public function actionOrderSave()
// {
// Yii::$app->response->format = Response::FORMAT_JSON;
// $request = Yii::$app->request;
// $result = array();
// $result['success'] = false;
// $result['msg'] = '保存失败';
// if ($request->isPost) {
// //状态
// $status_id = $request->post('status_id', 1);
// //车辆信息
// $car_id = $request->post('car_id', 0);
// $car_no = $request->post('car_no');
// $seats = (int)$request->post('seats');
// $register_date = $request->post('register_date');
// $car_man = $request->post('car_man');
// $car_man_number = $request->post('car_man_number');
// //地址信息
// $province = $request->post('province');
// $city = $request->post('city');
// $district = $request->post('district');
// $town = $request->post('twon');
// $address = $request->post('address');
//
// //保单信息
// $order_id = $request->post('order_id', 0);
// $id_man = $request->post('id_man');
// $id_number = $request->post('id_number');
// $link_man = $request->post('link_man');
// $link_phone = $request->post('link_phone');
// $send_date = $request->post('send_date');
// $company2_id = $request->post('company2_id');
// $pay_type_id = $request->post('pay_type_id');
// $shoufei_id = $request->post('shoufei_id');
// $email = $request->post('email');
// $insurer1_begin_date = $request->post('insurer1_begin_date');
// $insurer2_begin_date = $request->post('insurer2_begin_date');
// $order_remark = $request->post('order_remark');
// $direction1_id = $request->post('direction1_id');
// $range1_id = $request->post('range1_id');
// $city1_id = $request->post('city1_id');
// $district1_id = $request->post('district1_id');
// $send_address1 = $request->post('send_address1');
//// $send_address2 = $request->post('send_address2');
// $success_id = $request->post('success_id');
// $gifts = $request->post('gifts');
// $car_man_weixin = $request->post('car_man_weixin');
// $business_group_id = $request->post('business_group_id', 0);
//
// //非车险信息
//// $is_insurance = $request->post('is_insurance');
//// $ord_scheme_id = $request->post('scheme_id');
//// $non_num = $request->post('non_num');
//
//
// //报价信息
// $total1_clear = $request->post('total1_clear');
// $total1 = $request->post('total1');
// $total1_real = $request->post('total1_real');
// $total1_dis = $request->post('total1_dis');
// $total1_percent = $request->post('total1_percent');
// $total2_clear = $request->post('total2_clear');
// $total2 = $request->post('total2');
// $total3 = $request->post('total3');
// $total_all = $request->post('total_all');
// $total_real = $request->post('total_real');
// $price_remark = $request->post('price_remark');
//
// //报价明细
// $types = $request->post('types', array());
// $nopays = $request->post('nopays', array());
//
// //礼品
// $gifts = $request->post('gifts', array());
//
// if ($car_no == '') {
// $result['msg'] = '请输入车牌号码!';
// return $result;
// }
// //财务信息条件
// $money_man = $request->post('money_man');
// $money_no = $request->post('money_no');
// $money_bank = $request->post('money_bank');
// $paydate= date('Y-m',time());
//// echo '< pre > ';
//// print_r($money_man);
//// var_dump($paydate);
//// die;
//
//
//
// //判断起保日期是否正确
// $begin_date = date('Y-m-d', strtotime('+90 day'));
//// var_dump($begin_date);
//// die;
// if ($insurer1_begin_date != '' & & $insurer1_begin_date > $begin_date) {
// $result['msg'] = '商业起保日期不正确!';
// return $result;
// }
// if ($insurer2_begin_date != '' & & $insurer2_begin_date > $begin_date) {
// $result['msg'] = '交强起保日期不正确!';
// return $result;
// }
// //提交才判断的条件
// if ($status_id > 1) {
// if ($success_id == 0) {
// $result['msg'] = '请选择成功理由';
// return $result;
// }
// if ($seats == 0) {
// $result['msg'] = '请输入座位数';
// return $result;
// }
// }
// //三者不能超过
// if($this->web->max_other_money > 0 & & floatval($types[2]) > $this->web->max_other_money) {
// if($this->web->max_out_rate > 0 & & (1 - $total1_percent)*100 > $this->web->max_out_rate) {
// $result['msg'] = '三者超过' . $this->web->max_other_money . '万,商业折扣率不能超过' . $this->web->max_out_rate.'%';
// return $result;
// }
// }
// //非京牌车优惠率不能超过
// if(substr($car_no,0,strlen('京')) != '京' & & $this->web->max_other_area_rate > 0 & & (1 - $total1_percent)*100 > $this->web->max_other_area_rate) {
// $result['msg'] = '非京牌车辆商业折扣率不能低于'.round((100 - $this->web->max_other_area_rate)/100,2);
// return $result;
// }
// //所有车辆优惠金额不能超过
// if($this->web->max_dis_money > 0 & & $total1_dis > $this->web->max_dis_money) {
// $result['msg'] = '所有车辆减免金额不能超过'.$this->web->max_dis_money.'元';
// return $result;
// }
//
// $tran = CarT::getDb()->beginTransaction();
// try {
// $order_info = OrderT::findOne(['id' => $order_id]);
// $car_info = $order_info->car;
// //车辆信息
// $car_info->car_no = $car_no;
// $car_info->seats = $seats;
// $car_info->register_date = $register_date;
// $car_info->car_man = $car_man;
// $car_info->car_man_number = $car_man_number;
// $car_info->weixin = $car_man_weixin;
// $car_info->save();
//
// //保单信息
// $order_info->car_no = $car_no;
// $order_info->engine_no = $car_info->engine_no;
// $order_info->car_frame_no = $car_info->car_frame_no;
// $order_info->car_man = $car_man;
// $order_info->company2_id = $company2_id;
// $order_info->success_id = $success_id;
// $order_info->status_id = $status_id;
// if ($status_id > 1) {
// $order_info->return_status_id = 0;
// $order_info->return_remark = '';
// $order_info->return_time = 0;
// }
// $order_info->submit_date = date('Y-m-d');
// $order_info->id_man = $id_man;
// $order_info->id_number = $id_number;
// $order_info->link_man = $link_man;
// $order_info->link_phone = $link_phone;
// $order_info->insurer1_begin_date = $insurer1_begin_date;
// $insurer1_end_date = '';
// if ($insurer1_begin_date != '') {
// $insurer1_end_date = date('Y-m-d', strtotime(date('Y-m-d', strtotime($insurer1_begin_date . "+1 year")) . '-1 day'));
// }
// $order_info->insurer1_end_date = $insurer1_end_date;
// $order_info->insurer2_begin_date = $insurer2_begin_date;
// $insurer2_end_date = '';
// if ($insurer2_end_date != '')
// $insurer2_end_date = date('Y-m-d', strtotime(date('Y-m-d', strtotime($insurer2_begin_date . "+1 year")) . '-1 day'));
// $order_info->insurer2_end_date = $insurer2_end_date;
// $order_info->send_date = $send_date;
// $order_info->direction1_id = $direction1_id;
// $order_info->range1_id = $range1_id;
// $order_info->city1_id = $city1_id;
// $order_info->district1_id = $district1_id;
// $order_info->send_address1 = $send_address1;
//// $order_info->send_address2 = $send_address2;
// $order_info->pay_type_id = $pay_type_id;
// $order_info->shoufei_id = $shoufei_id;
// $order_info->email = $email;
// $order_info->remark = $order_remark;
//
// //正本地址存储
//
// if ($status_id > 1) {
// $order_ad= OrderAddress::findOne(['order_id'=>$order_id]);
// if(!$order_ad){
// $order_ad=new OrderAddress();
// $order_ad->order_id=$order_id;
// }
// $order_ad->province=$province;
// $order_ad->city=$city;
// $order_ad->district=$district;
// $order_ad->town=$town;
// $order_ad->address=$address;
// $order_ad->save();
// $order_info->addr_id=$order_ad->id;
// }
//
//
// $order_info->total1_clear = $total1_clear;
// $order_info->total1 = $total1;
// $order_info->total1_real = $total1_real;
// $order_info->total1_dis = $total1_dis;
// $order_info->total1_percent = $total1_percent;
// $order_info->total2_clear = $total2_clear;
// $order_info->total2 = $total2;
// $order_info->total3 = $total3;
// $order_info->total_all = $total_all;
// $order_info->total_real = $total_real;
// $order_info->price_remark = $price_remark;
// $order_info->business_group_id = $business_group_id;
//
// $order_info->save();
//
// //处理操作人员状态 0:正在操作中,1:操作结束,2:退回操作,3:无效操作,4:放弃操作
// if ($status_id > 1) {
// $order_user_info = OrderUserT::findOne(['user_id' => $this->my->id, 'order_id' => $order_info->id, 'status' => 0]);
// if ($order_user_info) {
// $order_user_info->status = 1;
// $order_user_info->save();
// }
// }
// //礼品
// OrderGiftT::deleteAll('order_id=' . $order_info->id . ' and status=0');
// if (is_array($gifts)) {
// foreach ($gifts as $tmp_str) {
// $tmp = explode('_', $tmp_str);
// $group_id = isset($tmp[0]) ? $tmp[0] : 0;
// $gift_id = isset($tmp[1]) ? $tmp[1] : 0;
// if ($group_id == 0 & & $gift_id == 0) continue;
// $group_info = GiftGroupT::findOne(['id' => $group_id]);
// if (!isset($group_info)) {
// continue;
//// $result['msg'] = '礼品分组有错误,请与主管联系';
//// return $result;
// }
// $gift_info = GiftType3T::findOne(['id' => $gift_id]);
// if (!isset($gift_info)) {
// continue;
//// $result['msg'] = $group_info->name.' 礼品不存在,重新选择';
//// return $result;
// }
// $tmp_count = OrderGiftT::find()->where('order_id=' . $order_info->id . ' and group_id=' . $group_id . ' and status=1')->count();
// if ($tmp_count > 0) {
// continue;
// }
// //处理礼品数量
// if ($status_id > 1) {
// if ($gift_info->total > -1) {
// $gift_info->total = $gift_info->total - 1;
// $gift_info->save();
// }
// }
// $row = new OrderGiftT();
// $row->order_id = $order_info->id;
// $row->group_id = $group_id;
// $row->gift_id = $gift_id;
// $row->is_free = $group_info->is_free;
// $row->gift_type = $gift_info->type;
// $row->send_id = 0;
// $row->send_time = 0;
// $row->price = 0;
// $row->status = 0;
// if (!$row->save()) {
// var_dump($row->errors);
// }
// }
// }
//
// //险种明细
// foreach ($types as $id => $val) {
// $price_row = PriceT::find()
// ->where('order_id=' . $order_info->id . ' and type_id=' . $id)
// ->one();
// if (empty($price_row)) {
// $price_row = new PriceT();
// $price_row->order_id = $order_info->id;
// $price_row->type_id = $id;
// }
// $price_row->val = $val;
// if (!empty($nopays[$id]))
// $price_row->is_nopay = 1;
// else
// $price_row->is_nopay = 0;
// $price_row->save();
// }
//
// //处理预约
// if ($status_id > 1) {
// $tmp_row = AppointmentT::findOne(['car_id' => $car_info->id]);
// if (!empty($tmp_row)) {
// $tmp_row->delete();
// }
// $tmp_status_info = StatusT::findOne(['id' => $status_id]);
// $log_msg = '';
// if ($tmp_status_info) {
// $log_msg = '进入' . $tmp_status_info->name;
// }
// $this->addLog($car_info->id, $log_msg, 1);
// }
//
// //处理公司礼品
// //清除原公司礼品
// CarGiftT::deleteAll('user_id=' . $this->my->id . ' and car_id=' . $car_info->id . ' and order_id=' . $order_info->id . ' and type=1 and status=0');
// foreach ($gifts as $id_str) {
// $gift_ids = explode('-', $id_str);
// if (count($gift_ids) != 2) continue;
// $strategy_id = $gift_ids[0];
// $gift_id = $gift_ids[1];
// $car_gift_info = CarGiftT::find()
// ->where('strategy_id=' . $strategy_id . ' and order_id=' . $order_info->id . ' and gift_id=' . $gift_id)
// ->one();
// if (!$car_gift_info & & $gift_id > 0) {
// $car_gift_info = new CarGiftT();
// $car_gift_info->user_id = $this->my->id;
// $car_gift_info->car_id = $car_info->id;
// $car_gift_info->order_id = $order_info->id;
// $car_gift_info->strategy_id = $strategy_id;
// $car_gift_info->gift_id = $gift_id;
// $car_gift_info->submit_time = time();
// $car_gift_info->status = 0;
// $car_gift_info->type = 1;
// $car_gift_info->save();
// }
// }
// //处理自费礼品
// $gift_items = CarGiftT::find()
// ->where('car_id=' . $car_info->id . ' and order_id=0')
// ->all();
// foreach ($gift_items as $item) {
// $item->order_id = $order_info->id;
// $item->save();
// }
// // 处理财务-如果是在线支付-生成财务分支
//
// if ($status_id > 1) {
// if ($shoufei_id == 2) {
// $order_caiwu = OrderCaiwuT::findOne(['order_id'=>$order_info->id]);
//
// if(!$order_caiwu){
// $order_caiwu = new OrderCaiwuT();
// $order_caiwu->status_id = 2;
// }
//
// $order_caiwu->order_id = $order_info->id;
// $order_caiwu->money_man = $money_man;
// $order_caiwu->money_no = $money_no;
// $order_caiwu->pay_date = $paydate;
// $order_caiwu->money_bank = $money_bank;
// $order_caiwu->save();
// }
//
// }
// $result['success'] = true;
// $result['msg'] = '保存成功';
//
// $tran->commit();
// } catch (\Exception $e) {
// $tran->rollBack();
// throw $e;
// }
//
// }
// return $result;
// }
public function actionOrderSave()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '保存失败';
if ($request->isPost) {
//状态
$status_id = $request->post('status_id', 1);
//车辆信息
$car_id = $request->post('car_id', 0);
$car_no = $request->post('car_no');
$seats = (int)$request->post('seats');
$register_date = $request->post('register_date');
$car_man = $request->post('car_man');
$car_man_number = $request->post('car_man_number');
//地址信息
// $province = $request->post('province');
//
// $district = $request->post('district');
// $town = $request->post('twon');
// $address = $request->post('address');
$city = $request->post('city');
$pcity = $request->post('pcity');
$pproper = $request->post('pproper');
$receiver_address = $request->post('receiver_address');
//保单信息
$order_id = $request->post('order_id', 0);
$id_man = $request->post('id_man');
$id_number = $request->post('id_number');
$link_man = $request->post('link_man');
$link_phone = $request->post('link_phone');
$send_date = $request->post('send_date');
$company2_id = $request->post('company2_id');
$pay_type_id = $request->post('pay_type_id');
$shoufei_id = $request->post('shoufei_id');
$email = $request->post('email');
$insurer1_begin_date = $request->post('insurer1_begin_date');
$insurer2_begin_date = $request->post('insurer2_begin_date');
$order_remark = $request->post('order_remark');
$direction1_id = $request->post('direction1_id');
$range1_id = $request->post('range1_id');
$city1_id = $request->post('city1_id');
$district1_id = $request->post('district1_id');
$send_address1 = $request->post('send_address1');
// $send_address2 = $request->post('send_address2');
$success_id = $request->post('success_id');
$gifts = $request->post('gifts');
$car_man_weixin = $request->post('car_man_weixin');
$business_group_id = $request->post('business_group_id', 0);
//非车险信息
// $is_insurance = $request->post('is_insurance');
// $ord_scheme_id = $request->post('scheme_id');
// $non_num = $request->post('non_num');
//报价信息
$total1_clear = $request->post('total1_clear');
$total1 = $request->post('total1');
$total1_real = $request->post('total1_real');
$total1_dis = $request->post('total1_dis');
$total1_percent = $request->post('total1_percent');
$total2_clear = $request->post('total2_clear');
$total2 = $request->post('total2');
$total3 = $request->post('total3');
$total_all = $request->post('total_all');
$total_real = $request->post('total_real');
$price_remark = $request->post('price_remark');
//报价明细
$types = $request->post('types', array());
$nopays = $request->post('nopays', array());
//礼品
$gifts = $request->post('gifts', array());
if ($car_no == '') {
$result['msg'] = '请输入车牌号码!';
return $result;
}
//财务信息条件
$money_man = $request->post('money_man');
$money_no = $request->post('money_no');
$money_bank = $request->post('money_bank');
$paydate= date('Y-m',time());
// echo '< pre > ';
// print_r($money_man);
// var_dump($paydate);
// die;
//判断起保日期是否正确
$begin_date = date('Y-m-d', strtotime('+90 day'));
// var_dump($begin_date);
// die;
if ($insurer1_begin_date != '' & & $insurer1_begin_date > $begin_date) {
$result['msg'] = '商业起保日期不正确!';
return $result;
}
if ($insurer2_begin_date != '' & & $insurer2_begin_date > $begin_date) {
$result['msg'] = '交强起保日期不正确!';
return $result;
}
//提交才判断的条件
if ($status_id > 1) {
if ($success_id == 0) {
$result['msg'] = '请选择成功理由';
return $result;
}
if ($seats == 0) {
$result['msg'] = '请输入座位数';
return $result;
}
}
//三者不能超过
if($this->web->max_other_money > 0 & & floatval($types[2]) > $this->web->max_other_money) {
if($this->web->max_out_rate > 0 & & (1 - $total1_percent)*100 > $this->web->max_out_rate) {
$result['msg'] = '三者超过' . $this->web->max_other_money . '万,商业折扣率不能超过' . $this->web->max_out_rate.'%';
return $result;
}
}
//非京牌车优惠率不能超过
if(substr($car_no,0,strlen('京')) != '京' & & $this->web->max_other_area_rate > 0 & & (1 - $total1_percent)*100 > $this->web->max_other_area_rate) {
$result['msg'] = '非京牌车辆商业折扣率不能低于'.round((100 - $this->web->max_other_area_rate)/100,2);
return $result;
}
//所有车辆优惠金额不能超过
if($this->web->max_dis_money > 0 & & $total1_dis > $this->web->max_dis_money) {
$result['msg'] = '所有车辆减免金额不能超过'.$this->web->max_dis_money.'元';
return $result;
}
$tran = CarT::getDb()->beginTransaction();
try {
$order_info = OrderT::findOne(['id' => $order_id]);
$car_info = $order_info->car;
//车辆信息
$car_info->car_no = $car_no;
$car_info->seats = $seats;
$car_info->register_date = $register_date;
$car_info->car_man = $car_man;
$car_info->car_man_number = $car_man_number;
$car_info->weixin = $car_man_weixin;
$car_info->save();
//保单信息
$order_info->car_no = $car_no;
$order_info->engine_no = $car_info->engine_no;
$order_info->car_frame_no = $car_info->car_frame_no;
$order_info->car_man = $car_man;
$order_info->company2_id = $company2_id;
$order_info->success_id = $success_id;
$order_info->status_id = $status_id;
if ($status_id > 1) {
$order_info->return_status_id = 0;
$order_info->return_remark = '';
$order_info->return_time = 0;
}
$order_info->submit_date = date('Y-m-d');
$order_info->id_man = $id_man;
$order_info->id_number = $id_number;
$order_info->link_man = $link_man;
$order_info->link_phone = $link_phone;
$order_info->insurer1_begin_date = $insurer1_begin_date;
$insurer1_end_date = '';
if ($insurer1_begin_date != '') {
$insurer1_end_date = date('Y-m-d', strtotime(date('Y-m-d', strtotime($insurer1_begin_date . "+1 year")) . '-1 day'));
}
$order_info->insurer1_end_date = $insurer1_end_date;
$order_info->insurer2_begin_date = $insurer2_begin_date;
$insurer2_end_date = '';
if ($insurer2_end_date != '')
$insurer2_end_date = date('Y-m-d', strtotime(date('Y-m-d', strtotime($insurer2_begin_date . "+1 year")) . '-1 day'));
$order_info->insurer2_end_date = $insurer2_end_date;
$order_info->send_date = $send_date;
$order_info->direction1_id = $direction1_id;
$order_info->range1_id = $range1_id;
$order_info->city1_id = $city1_id;
$order_info->district1_id = $district1_id;
$order_info->send_address1 = $send_address1;
// $order_info->send_address2 = $send_address2;
$order_info->pay_type_id = $pay_type_id;
$order_info->shoufei_id = $shoufei_id;
$order_info->email = $email;
$order_info->remark = $order_remark;
//正本地址存储
if ($status_id > 1) {
// $order_ad= OrderAddress::findOne(['order_id'=>$order_id]);
// if(!$order_ad){
// $order_ad=new OrderAddress();
// $order_ad->order_id=$order_id;
// }
// $order_ad->province=$province;
// $order_ad->city=$city;
// $order_ad->district=$district;
// $order_ad->town=$town;
// $order_ad->address=$address;
// $order_ad->save();
// $order_info->addr_id=$order_ad->id;
}
//非车险存储
// $order_info->is_insurance = $is_insurance;
// if($is_insurance==2 & & $ord_scheme_id & & $non_num){
// $order_info->ord_scheme_id=$ord_scheme_id;
// $scheme_items=Scheme::findOne(['id'=>$order_info->ord_scheme_id]);
// if($scheme_items){
// $order_info->non_baofei=$scheme_items->baofei;
//
// }
// $order_info->non_num=$non_num;
// }
$order_info->receiver_province = $city;
$order_info->receiver_city = $pcity;
$order_info->receiver_county = $pproper;
$order_info->receiver_address = $receiver_address;
$order_info->total1_clear = $total1_clear;
$order_info->total1 = $total1;
$order_info->total1_real = $total1_real;
$order_info->total1_dis = $total1_dis;
$order_info->total1_percent = $total1_percent;
$order_info->total2_clear = $total2_clear;
$order_info->total2 = $total2;
$order_info->total3 = $total3;
$order_info->total_all = $total_all;
$order_info->total_real = $total_real;
$order_info->price_remark = $price_remark;
$order_info->business_group_id = $business_group_id;
$order_info->save();
//处理操作人员状态 0:正在操作中,1:操作结束,2:退回操作,3:无效操作,4:放弃操作
if ($status_id > 1) {
$order_user_info = OrderUserT::findOne(['user_id' => $this->my->id, 'order_id' => $order_info->id, 'status' => 0]);
if ($order_user_info) {
$order_user_info->status = 1;
$order_user_info->save();
}
}
//礼品
OrderGiftT::deleteAll('order_id=' . $order_info->id . ' and status=0');
if (is_array($gifts)) {
foreach ($gifts as $tmp_str) {
$tmp = explode('_', $tmp_str);
$group_id = isset($tmp[0]) ? $tmp[0] : 0;
$gift_id = isset($tmp[1]) ? $tmp[1] : 0;
if ($group_id == 0 & & $gift_id == 0) continue;
$group_info = GiftGroupT::findOne(['id' => $group_id]);
if (!isset($group_info)) {
continue;
// $result['msg'] = '礼品分组有错误,请与主管联系';
// return $result;
}
$gift_info = GiftType3T::findOne(['id' => $gift_id]);
if (!isset($gift_info)) {
continue;
// $result['msg'] = $group_info->name.' 礼品不存在,重新选择';
// return $result;
}
$tmp_count = OrderGiftT::find()->where('order_id=' . $order_info->id . ' and group_id=' . $group_id . ' and status=1')->count();
if ($tmp_count > 0) {
continue;
}
//处理礼品数量
if ($status_id > 1) {
if ($gift_info->total > -1) {
$gift_info->total = $gift_info->total - 1;
$gift_info->save();
}
}
$row = new OrderGiftT();
$row->order_id = $order_info->id;
$row->group_id = $group_id;
$row->gift_id = $gift_id;
$row->is_free = $group_info->is_free;
$row->gift_type = $gift_info->type;
$row->send_id = 0;
$row->send_time = 0;
$row->price = 0;
$row->status = 0;
if (!$row->save()) {
var_dump($row->errors);
}
}
}
//险种明细
foreach ($types as $id => $val) {
$price_row = PriceT::find()
->where('order_id=' . $order_info->id . ' and type_id=' . $id)
->one();
if (empty($price_row)) {
$price_row = new PriceT();
$price_row->order_id = $order_info->id;
$price_row->type_id = $id;
}
$price_row->val = $val;
if (!empty($nopays[$id]))
$price_row->is_nopay = 1;
else
$price_row->is_nopay = 0;
$price_row->save();
}
//处理预约
if ($status_id > 1) {
$tmp_row = AppointmentT::findOne(['car_id' => $car_info->id]);
if (!empty($tmp_row)) {
$tmp_row->delete();
}
$tmp_status_info = StatusT::findOne(['id' => $status_id]);
$log_msg = '';
if ($tmp_status_info) {
$log_msg = '进入' . $tmp_status_info->name;
}
$this->addLog($car_info->id, $log_msg, 1);
}
//处理公司礼品
//清除原公司礼品
CarGiftT::deleteAll('user_id=' . $this->my->id . ' and car_id=' . $car_info->id . ' and order_id=' . $order_info->id . ' and type=1 and status=0');
foreach ($gifts as $id_str) {
$gift_ids = explode('-', $id_str);
if (count($gift_ids) != 2) continue;
$strategy_id = $gift_ids[0];
$gift_id = $gift_ids[1];
$car_gift_info = CarGiftT::find()
->where('strategy_id=' . $strategy_id . ' and order_id=' . $order_info->id . ' and gift_id=' . $gift_id)
->one();
if (!$car_gift_info & & $gift_id > 0) {
$car_gift_info = new CarGiftT();
$car_gift_info->user_id = $this->my->id;
$car_gift_info->car_id = $car_info->id;
$car_gift_info->order_id = $order_info->id;
$car_gift_info->strategy_id = $strategy_id;
$car_gift_info->gift_id = $gift_id;
$car_gift_info->submit_time = time();
$car_gift_info->status = 0;
$car_gift_info->type = 1;
$car_gift_info->save();
}
}
//处理自费礼品
$gift_items = CarGiftT::find()
->where('car_id=' . $car_info->id . ' and order_id=0')
->all();
foreach ($gift_items as $item) {
$item->order_id = $order_info->id;
$item->save();
}
// 处理财务-如果是在线支付-生成财务分支
if ($status_id > 1) {
if ($shoufei_id == 2) {
$order_caiwu = OrderCaiwuT::findOne(['order_id'=>$order_info->id]);
if(!$order_caiwu){
$order_caiwu = new OrderCaiwuT();
$order_caiwu->status_id = 2;
}
$order_caiwu->order_id = $order_info->id;
$order_caiwu->money_man = $money_man;
$order_caiwu->money_no = $money_no;
$order_caiwu->pay_date = $paydate;
$order_caiwu->money_bank = $money_bank;
$order_caiwu->save();
}
}
$result['success'] = true;
$result['msg'] = '保存成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
public function actionAjaxHistoryIndex()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$car_id = $request->get('car_id');
$page = $request->get('page',1);
$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();
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]);
$pagination->setPage($page-1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
$items = $query->all();
$page_info = MyLib::getAjaxPageInfo($pagination,'car_history_list');
$html = $this->renderPartial('ajax-history-index',[
'car_id' => $car_id,
'items' => $items,
'page' => $page,
'page_info' => $page_info
]);
$result['success'] = true;
$result['msg'] = '读取成功';
$result['html'] = $html;
return $result;
}
public function actionAjaxHistoryIndexXubao()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$car_id = $request->get('car_id');
$page = $request->get('page',1);
$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();
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]);
$pagination->setPage($page-1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
$items = $query->all();
$page_info = MyLib::getAjaxPageInfo($pagination,'car_history_list');
$html = $this->renderPartial('ajax-history-index',[
'car_id' => $car_id,
'items' => $items,
'page' => $page,
'page_info' => $page_info
]);
$result['success'] = true;
$result['msg'] = '读取成功';
$result['html'] = $html;
return $result;
}
public function actionAjaxHistoryFinance()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$car_id = $request->get('car_id');
$page = $request->get('page',1);
$result = array();
$result['success'] = false;
$result['msg'] = '读取失败';
$query = OrderFinanceLogT::find()
->where(['car_id'=>$car_id,'type'=>1])
->orderBy('id DESC');
$total = $query->count();
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]);
$pagination->setPage($page-1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
$items = $query->all();
$page_info = MyLib::getAjaxPageInfo($pagination,'car_history_list');
$html = $this->renderPartial('ajax-history-index',[
'car_id' => $car_id,
'items' => $items,
'page' => $page,
'page_info' => $page_info
]);
$result['success'] = true;
$result['html'] = $html;
return $result;
}
// public function actionInvalid()
// {
// Yii::$app->response->format = Response::FORMAT_JSON;
// $request = Yii::$app->request;
// $result = array();
// $result['success'] = false;
// $result['msg'] = '操作失败';
//
// if($request->isPost) {
// $car_id = $request->post('car_id');
// $invalid_id = $request->post('invalid_id',0);
//
// $tran = CarT::getDb()->beginTransaction();
// try {
// $car_info = CarT::findOne(['id'=>$car_id]);
// if($invalid_id == 26) {
//// $car_info->location = 6;
//// $car_info->save();
////
//// CarCT::deleteAll('id='.$car_info->id);
//// $c_info = new CarET();
//// $c_info->id = $car_info->id;
//// $c_info->user_id = 0;
//// $c_info->save();
////
//// CarBT::deleteAll(['id'=>$car_info->id]);
//// CarDT::deleteAll(['id'=>$car_info->id]);
////
//// //删除预约
//// AppointmentT::deleteAll('car_id='.$car_info->id);
////
//// //删除保单
//// $orders = OrderT::find()
//// ->where('car_id='.$car_info->id.' and status_id< 2 ' )
//// ->all();
//// foreach($orders as $order_info) {
//// OrderUserT::deleteAll('order_id='.$order_info->id);
//// $order_info->delete();
//// }
//// $orders = OrderT::find()
//// ->where('car_id='.$car_info->id.' and status_id>1')
//// ->all();
//// foreach($orders as $order_info) {
//// $order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
//// if($order_user_info) {
//// $order_user_info->status = 3;
//// $order_user_info->save();
//// }
//// }
////
//// $this->addLog($car_info->id,'已在其他人保公司续保车辆数据,进入E库',1);
//
// } else {
// $car_info->location = 5;
// $car_info->save();
//
// CarInvalidT::deleteAll('id='.$car_info->id);
// $invalid_info = new CarInvalidT();
// $invalid_info->id = $car_info->id;
// $invalid_info->invalid_id = $invalid_id;
// $invalid_info->user_id = $this->my->id;
// $invalid_info->save();
//
// CarBT::deleteAll(['id'=>$car_info->id]);
// CarCT::deleteAll(['id'=>$car_info->id]);
// CarDT::deleteAll(['id'=>$car_info->id]);
//
// //删除预约
// AppointmentT::deleteAll('car_id='.$car_info->id);
//
// //删除保单
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id< 2 ' )
// ->all();
// foreach($orders as $order_info) {
// OrderUserT::deleteAll('order_id='.$order_info->id);
// $order_info->delete();
// }
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id>1')
// ->all();
// foreach($orders as $order_info) {
// $order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
// if($order_user_info) {
// $order_user_info->status = 3;
// $order_user_info->save();
// }
// }
//
// $this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
//
// }
//
// $result['success'] = true;
// $result['msg'] = '操作成功';
//
// $tran->commit();
// } catch (\Exception $e) {
// $tran->rollBack();
// throw $e;
// }
// }
// return $result;
// }
// //无效数据到A库
// public function actionInvalidA()
// {
// Yii::$app->response->format = Response::FORMAT_JSON;
// $request = Yii::$app->request;
// $result = array();
// $result['success'] = false;
// $result['msg'] = '操作失败';
//
// if($request->isPost) {
//// var_dump($request->post());
//// die;
// $car_id = $request->post('car_id');
// $invalid_id = $request->post('invalid_id',0);
// $ac1 = $request->post('ac1');
// $ac2 = $request->post('ac2');
// $ac3 = $request->post('ac3');
//
// $tran = CarT::getDb()->beginTransaction();
// try {
// $car_info = CarT::findOne(['id'=>$car_id]);
// if($invalid_id == 25 || $invalid_id == 26 || $invalid_id == 27 ) {
// $car_info->location = 6;
//
// $car_info->insurer1_date = $ac1;
// $car_info->insurer2_date = $ac2;
// $car_info->company = $ac3;
// $car_info->save();
//
// CarCT::deleteAll('id='.$car_info->id);
// $c_info = new CarET();
// $c_info->id = $car_info->id;
// $c_info->user_id = 0;
// $c_info->save();
//
// CarBT::deleteAll(['id'=>$car_info->id]);
// CarDT::deleteAll(['id'=>$car_info->id]);
//
// //删除预约
// AppointmentT::deleteAll('car_id='.$car_info->id);
// AppointmentHistoryT::deleteAll('car_id='.$car_info->id);
//
// //删除保单
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id< 2 ' )
// ->all();
// foreach($orders as $order_info) {
// OrderUserT::deleteAll('order_id='.$order_info->id);
// $order_info->delete();
// }
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id>1')
// ->all();
// foreach($orders as $order_info) {
// $order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
// if($order_user_info) {
// $order_user_info->status = 3;
// $order_user_info->save();
// }
// }
//
// $this->addLog($car_info->id,'新保销售预约时,已在其他人保公司续保车辆数据或在人保公司续保,进入E库',1);
//
// } else {
// $car_info->location = 5;
// $car_info->save();
//
// CarInvalidT::deleteAll('id='.$car_info->id);
// $invalid_info = new CarInvalidT();
// $invalid_info->id = $car_info->id;
// $invalid_info->invalid_id = $invalid_id;
// $invalid_info->user_id = $this->my->id;
// $invalid_info->save();
//
// CarBT::deleteAll(['id'=>$car_info->id]);
// CarCT::deleteAll(['id'=>$car_info->id]);
// CarDT::deleteAll(['id'=>$car_info->id]);
//
// //删除预约
// AppointmentT::deleteAll('car_id='.$car_info->id);
//
// //删除保单
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id< 2 ' )
// ->all();
// foreach($orders as $order_info) {
// OrderUserT::deleteAll('order_id='.$order_info->id);
// $order_info->delete();
// }
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id>1')
// ->all();
// foreach($orders as $order_info) {
// $order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
// if($order_user_info) {
// $order_user_info->status = 3;
// $order_user_info->save();
// }
// }
//
// $this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
//
// }
//
// $result['success'] = true;
// $result['msg'] = '操作成功';
//
// $tran->commit();
// } catch (\Exception $e) {
// $tran->rollBack();
// throw $e;
// }
// }
// return $result;
// }
// //无效数据到F库
// public function actionInvalidF()
// {
// Yii::$app->response->format = Response::FORMAT_JSON;
// $request = Yii::$app->request;
// $result = array();
// $result['success'] = false;
// $result['msg'] = '操作失败';
//
// if($request->isPost) {
// $car_id = $request->post('car_id');
// $invalid_id = $request->post('invalid_id',0);
// $ac1 = $request->post('ac1');
// $ac2 = $request->post('ac2');
// $ac3 = $request->post('ac3');
//
// $tran = CarT::getDb()->beginTransaction();
// try {
// $car_info = CarT::findOne(['id'=>$car_id]);
// if($invalid_id == 25 || $invalid_id == 26 || $invalid_id == 27 ) {
// $car_info->location = 7;
// $car_info->insurer1_date = $ac1;
// $car_info->insurer2_date = $ac2;
// $car_info->company = $ac3;
// $car_info->save();
//
//
// CarCT::deleteAll('id='.$car_info->id);
// $c_info = new CarFT();
// $c_info->id = $car_info->id;
// $c_info->user_id = 0;
// $c_info->save();
//
// CarBT::deleteAll(['id'=>$car_info->id]);
// CarDT::deleteAll(['id'=>$car_info->id]);
//
// //删除预约
// AppointmentT::deleteAll('car_id='.$car_info->id);
// AppointmentHistoryT::deleteAll('car_id='.$car_info->id);
//
// //删除保单
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id< 2 ' )
// ->all();
// foreach($orders as $order_info) {
// OrderUserT::deleteAll('order_id='.$order_info->id);
// $order_info->delete();
// }
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id>1')
// ->all();
// foreach($orders as $order_info) {
// $order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
// if($order_user_info) {
// $order_user_info->status = 3;
// $order_user_info->save();
// }
// }
//
// $this->addLog($car_info->id,'续保销售预约时,已在其他人保公司续保车辆数据或在人保公司续保,进入F库',1);
//
// } else {
// $car_info->location = 5;
// $car_info->save();
//
// CarInvalidT::deleteAll('id='.$car_info->id);
// $invalid_info = new CarInvalidT();
// $invalid_info->id = $car_info->id;
// $invalid_info->invalid_id = $invalid_id;
// $invalid_info->user_id = $this->my->id;
// $invalid_info->save();
//
// CarBT::deleteAll(['id'=>$car_info->id]);
// CarCT::deleteAll(['id'=>$car_info->id]);
// CarDT::deleteAll(['id'=>$car_info->id]);
//
// //删除预约
// AppointmentT::deleteAll('car_id='.$car_info->id);
//
// //删除保单
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id< 2 ' )
// ->all();
// foreach($orders as $order_info) {
// OrderUserT::deleteAll('order_id='.$order_info->id);
// $order_info->delete();
// }
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id>1')
// ->all();
// foreach($orders as $order_info) {
// $order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
// if($order_user_info) {
// $order_user_info->status = 3;
// $order_user_info->save();
// }
// }
//
// $this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
//
// }
//
// $result['success'] = true;
// $result['msg'] = '操作成功';
//
// $tran->commit();
// } catch (\Exception $e) {
// $tran->rollBack();
// throw $e;
// }
// }
// return $result;
// }
public function actionInvalid()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$car_id = $request->post('car_id');
$invalid_id = $request->post('invalid_id',0);
$tran = CarT::getDb()->beginTransaction();
try {
$car_info = CarT::findOne(['id'=>$car_id]);
if($invalid_id == 26) {
// $car_info->location = 6;
// $car_info->save();
//
// CarCT::deleteAll('id='.$car_info->id);
// $c_info = new CarET();
// $c_info->id = $car_info->id;
// $c_info->user_id = 0;
// $c_info->save();
//
// CarBT::deleteAll(['id'=>$car_info->id]);
// CarDT::deleteAll(['id'=>$car_info->id]);
//
// //删除预约
// AppointmentT::deleteAll('car_id='.$car_info->id);
//
// //删除保单
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id< 2 ' )
// ->all();
// foreach($orders as $order_info) {
// OrderUserT::deleteAll('order_id='.$order_info->id);
// $order_info->delete();
// }
// $orders = OrderT::find()
// ->where('car_id='.$car_info->id.' and status_id>1')
// ->all();
// foreach($orders as $order_info) {
// $order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
// if($order_user_info) {
// $order_user_info->status = 3;
// $order_user_info->save();
// }
// }
//
// $this->addLog($car_info->id,'已在其他人保公司续保车辆数据,进入E库',1);
} else {
$car_info->location = 5;
$car_info->save();
CarF6T::deleteAll('id='.$car_info->id);
$invalid_info = new CarF6T();
$invalid_info->id = $car_info->id;
$invalid_info->invalid_id = $invalid_id;
$invalid_info->user_id = $this->my->id;
$invalid_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarCT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
$this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
}
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
//无效数据到A库
public function actionInvalidA()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
// var_dump($request->post());
// die;
$car_id = $request->post('car_id');
$invalid_id = $request->post('invalid_id',0);
$ac1 = $request->post('ac1');
$ac2 = $request->post('ac2');
$ac3 = $request->post('ac3');
$tran = CarT::getDb()->beginTransaction();
try {
$car_info = CarT::findOne(['id'=>$car_id]);
if($invalid_id == 25 || $invalid_id == 26 || $invalid_id == 27 ) {
$car_info->location = 6;
$car_info->insurer1_date = $ac1;
$car_info->insurer2_date = $ac2;
$car_info->company = $ac3;
$car_info->save();
CarCT::deleteAll('id='.$car_info->id);
$c_info = new CarET();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
$c_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
AppointmentHistoryT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
$this->addLog($car_info->id,'新保销售预约时,已在其他人保公司续保车辆数据或在人保公司续保,进入E库',1);
} else {
$car_info->location = 5;
$car_info->save();
CarInvalidT::deleteAll('id='.$car_info->id);
$invalid_info = new CarInvalidT();
$invalid_info->id = $car_info->id;
$invalid_info->invalid_id = $invalid_id;
$invalid_info->user_id = $this->my->id;
$invalid_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarCT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
$this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
}
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
//无效数据到管路员
public function actionInvalidMan()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$car_id = $request->post('car_id');
$invalid_id = $request->post('invalid_id',0);
$ac1 = $request->post('ac1');
$ac2 = $request->post('ac2');
// $ac3 = $request->post('ac3');
$tran = CarT::getDb()->beginTransaction();
try {
$car_info = CarT::findOne(['id'=>$car_id]);
//修改总库的数据
if($invalid_id == 25 || $invalid_id == 27 || $invalid_id == 26 || $invalid_id ==34 || $invalid_id ==35 || $invalid_id ==36) {
$car_info->insurer1_date=$ac1;
$car_info->insurer2_date=$ac2;
// $car_info->company = $ac3;
}
$car_info->save();
//无效给管理员 -存储一个中间表
$cdt= CarDT::find()->where('id='.$car_info->id)->one();
$apto=AppointmentT::find()->where('car_id='.$car_info->id)
->andWhere('user_id ='.$cdt->user_id)->orderBy('id desc')->one();
//删除重复提交的人员
$Invalids = InvalidRenewal::find()
->where('user_id= '.$cdt->user_id)
->all();
foreach($Invalids as $info) {
$info->delete();
}
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$renewal= new InvalidRenewal();
$renewal->car_id=$car_id;
$renewal->car_no=$car_info->car_no;
if($invalid_id == 25 || $invalid_id == 27 || $invalid_id == 26 || $invalid_id ==34 || $invalid_id ==35 || $invalid_id ==36) {
$renewal->insurer1_date=$ac1;
$renewal->insurer2_date=$ac2;
}else{
$renewal->insurer1_date=$car_info->insurer1_date;
$renewal->insurer2_date=$car_info->insurer2_date;
}
$renewal->phone=$car_info->phone;
$renewal->xdate= $apto?$apto->xdate:'';
$renewal->invalid_id= $invalid_id;
$renewal->num= 1;
$renewal->user_id= $cdt->user_id;
$renewal->save();
// dd( $renewal->save());
//d 库的user_id 改为0 收回状态
$car_dinfo = CarDT::findOne(['id'=>$car_id]);
$car_dinfo->user_id=0;
$car_dinfo->back=1;
$car_dinfo->iv_d=$invalid_id;
$car_dinfo->save();
$this->addLog($car_info->id,'续保销售预约时,无效给管理员进行管理',1);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
public function actionInvalidNewMan()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$car_id = $request->post('car_id');
$invalid_id = $request->post('invalid_id',0);
$ac1 = $request->post('ac1');
$ac2 = $request->post('ac2');
// $ac3 = $request->post('ac3');
$tran = CarT::getDb()->beginTransaction();
try {
$car_info = CarT::findOne(['id'=>$car_id]);
// dd($car_info);
//修改总库的数据
if($invalid_id == 57 || $invalid_id == 58 || $invalid_id == 59 || $invalid_id ==60 || $invalid_id ==61 ) {
$car_info->insurer1_date=$ac1;
$car_info->insurer2_date=$ac2;
// $car_info->company = $ac3;
}
$car_info->save();
//无效给管理员 -存储一个中间表
$cdt= CarBT::find()->where('id='.$car_info->id)->one();
$apto=AppointmentT::find()->where('car_id='.$car_info->id)
->andWhere('user_id ='.$cdt->user_id)->orderBy('id desc')->one();
//删除重复提交的人员
$Invalids = InvalidNew::find()
->where('user_id= '.$cdt->user_id)
->all();
foreach($Invalids as $info) {
$info->delete();
}
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$renewal= new InvalidNew();
$renewal->car_id=$car_id;
$renewal->car_no=$car_info->car_no;
if($invalid_id == 57 || $invalid_id == 58 || $invalid_id == 59 || $invalid_id ==60 || $invalid_id ==61 ) {
$renewal->insurer1_date=$ac1;
$renewal->insurer2_date=$ac2;
}else{
$renewal->insurer1_date=$car_info->insurer1_date;
$renewal->insurer2_date=$car_info->insurer2_date;
}
$renewal->phone=$car_info->phone;
$renewal->xdate= $apto?$apto->xdate:'';
$renewal->invalid_id= $invalid_id;
$renewal->num= 1;
$renewal->user_id= $cdt->user_id;
$renewal->save();
//d 库的user_id 改为0 收回状态
$car_dinfo = CarBT::findOne(['id'=>$car_id]);
$car_dinfo->user_id=0;
$car_dinfo->back=1;
$car_dinfo->iv_d=$invalid_id;
$car_dinfo->save();
$this->addLog($car_info->id,'新保销售预约时,无效给管理员进行管理',1);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
private function getDQuery($request)
{
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$insurer1_begin = $request->get('insurer1_begin');
$insurer1_end = $request->get('insurer1_end');
$status = $request->get('status',1);
$company = $request->get('company');
$invalid_id = $request->get('invalid_id');
$params = array();
$params['car_man'] = $car_man;
$params['phone'] = $phone;
$params['car_no'] = $car_no;
$params['insurer1_begin'] = $insurer1_begin;
$params['insurer1_end'] = $insurer1_end;
$params['status'] = $status;
$params['company'] = $company;
$params['invalid_id'] = $invalid_id;
$query = CarDT::find()
->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_d_t`.`id`')
->orderBy('car_d_t.updated_at desc');
$query = $query->andWhere('back=1');
if($car_man != '') {
$query = $query->andWhere('car_t.car_man="'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone like "'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($insurer1_begin != '') {
$query = $query->andWhere('car_t.insurer1_date>="'.$insurer1_begin.'"');
}
if($insurer1_end != '') {
$query = $query->andWhere('car_t.insurer1_date< ="'.$insurer1_end.'"');
}
if($company != '') {
$query = $query->andWhere('company like "'.$company.'%"');
}
if($status == 1) {
$query = $query->andWhere('car_d_t.user_id=0');
}
if($status == 2) {
$query = $query->andWhere('car_d_t.user_id>0');
}
if($invalid_id >0) {
$query = $query->andWhere('car_d_t.iv_d="'.$invalid_id.'"');
}
return ['query'=>$query,'params'=>$params];
}
//查询d库无效的数据
public function actionInvalidXubao()
{
$request = Yii::$app->request;
$page = $request->get('page',1);
$user_id = $request->get('user_id',1);
$data = $this->getDQuery($request);
$query = $data['query'];
$params = $data['params'];
$params['page'] = $page;
$total = $query->count();
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]);
$pagination->setPage($page-1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
// aa($query);
$items = $query->all();
$page_info = MyLib::getPageInfo($pagination);
$user_items = $this->my->getChildren();
$failure_items = InvalidT::getTreeXubao(2);
$params['items'] = $items;
$params['page_info'] = $page_info;
$params['user_id'] = $user_id;
$params['user_items'] = $user_items;
$params['failure_items'] = $failure_items;
return $this->render('xubao-list',$params);
}
//查询无效数据的详情
public function actionXubaoInfo()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$page = $request->get('page',1);
$back_params = $request->get('back_params');
$data= InvalidRenewal::find()->where(['car_id'=>$id])->all();
$failure_items = InvalidT::getTreeXubao(2);
$insurer_company2_items = InsurerCompany2T::find()->all();
return $this->render('xubao-info',[
'data'=>$data,
'page'=>$page,
'id'=>$id,
'failure_items'=>$failure_items,
'back_params' => $back_params,
'insurer_company2_items'=>$insurer_company2_items,
]);
}
private function getBQuery($request)
{
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$insurer1_begin = $request->get('insurer1_begin');
$insurer1_end = $request->get('insurer1_end');
$status = $request->get('status',1);
$company = $request->get('company');
$invalid_id = $request->get('invalid_id');
$params = array();
$params['car_man'] = $car_man;
$params['phone'] = $phone;
$params['car_no'] = $car_no;
$params['insurer1_begin'] = $insurer1_begin;
$params['insurer1_end'] = $insurer1_end;
$params['status'] = $status;
$params['company'] = $company;
$params['invalid_id'] = $invalid_id;
$query = CarBT::find()
->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_b_t`.`id`')
->orderBy('car_b_t.updated_at desc');
$query = $query->andWhere('back=1');
if($car_man != '') {
$query = $query->andWhere('car_t.car_man="'.$car_man.'"');
}
if($phone != '') {
$query = $query->andWhere('car_t.phone like "'.$phone.'"');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'"');
}
if($insurer1_begin != '') {
$query = $query->andWhere('car_t.insurer1_date>="'.$insurer1_begin.'"');
}
if($insurer1_end != '') {
$query = $query->andWhere('car_t.insurer1_date< ="'.$insurer1_end.'"');
}
if($company != '') {
$query = $query->andWhere('company like "'.$company.'%"');
}
if($status == 1) {
$query = $query->andWhere('car_b_t.user_id=0');
}
if($status == 2) {
$query = $query->andWhere('car_b_t.user_id>0');
}
if($invalid_id >0) {
$query = $query->andWhere('car_b_t.iv_d="'.$invalid_id.'"');
}
return ['query'=>$query,'params'=>$params];
}
//查询b库无效的数据
public function actionInvalidXinbaoList()
{
$request = Yii::$app->request;
$page = $request->get('page',1);
$user_id = $request->get('user_id',1);
$data = $this->getBQuery($request);
$query = $data['query'];
$params = $data['params'];
$params['page'] = $page;
$total = $query->count();
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]);
$pagination->setPage($page-1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
// aa($query);
$items = $query->all();
$page_info = MyLib::getPageInfo($pagination);
$user_items = $this->my->getChildren();
$failure_items = InvalidT::getTreeXinbaoNew(2);
$params['items'] = $items;
$params['page_info'] = $page_info;
$params['user_id'] = $user_id;
$params['user_items'] = $user_items;
$params['failure_items'] = $failure_items;
return $this->render('xinbao-list',$params);
}
//查询无效数据的详情
public function actionXinbaoInfo()
{
$request = Yii::$app->request;
$id = $request->get('id',0);
$page = $request->get('page',1);
$back_params = $request->get('back_params');
$data= InvalidNew::find()->where(['car_id'=>$id])->all();
// dd($data);
$failure_items = InvalidT::getTreeXinbaoNew(2);
$insurer_company2_items = InsurerCompany2T::find()->all();
return $this->render('xinbao-info',[
'data'=>$data,
'page'=>$page,
'id'=>$id,
'failure_items'=>$failure_items,
'back_params' => $back_params,
'insurer_company2_items'=>$insurer_company2_items,
]);
}
//无效数据到A库
public function actionInvalidF()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$car_id = $request->post('car_id');
$invalid_id = $request->post('invalid_id',0);
$ac1 = $request->post('ac1');
$ac2 = $request->post('ac2');
// $ac3 = $request->post('ac3');
$tran = CarT::getDb()->beginTransaction();
try {
$car_info = CarT::findOne(['id'=>$car_id]);
// dd($car_info);
if($invalid_id == 25 || $invalid_id == 27 || $invalid_id == 26 || $invalid_id ==34 || $invalid_id ==35 || $invalid_id ==36 || $invalid_id ==44) {
if($invalid_id == 25 || $invalid_id == 27){
CarFT::deleteAll('id='.$car_info->id);
$c_info = new CarFT();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
$c_info->save();
$car_info->location = 7;
$car_info->company = '其他小保险公司';
}elseif($invalid_id == 26 || $invalid_id ==34 || $invalid_id ==35 || $invalid_id ==36){
CarCT::deleteAll('id='.$car_info->id);
$c_info = new CarCT();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
switch($invalid_id) {
case 26:
$car_info->company = '人保';
$c_info->dif = 1;
break;
case 34:
$car_info->company = '太平洋';
$c_info->dif = 2;
break;
case 35:
$car_info->company = '国寿财';
$c_info->dif = 3;
break;
case 36:
$car_info->company = '平安';
$c_info->dif = 4;
break;
default:
$car_info->company = '';
}
$c_info->save();
$car_info->location = 3;
}elseif($invalid_id ==44){
$car_info->location = 1;
}
$car_info->insurer1_date = $ac1;
$car_info->insurer2_date = $ac2;
// $car_info->company = $ac3;
$car_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
AppointmentHistoryT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
if($invalid_id == 25 || $invalid_id == 27){
$this->addLog($car_info->id,'续保销售预约时,已在其他人保公司续保车辆数据或在人保公司续保,进入F库',1);
}elseif($invalid_id == 26 || $invalid_id ==34 || $invalid_id ==35 || $invalid_id ==36){
$this->addLog($car_info->id,'续保销售预约时,已在其他人保公司续保车辆数据,进入C库',1);
}elseif($invalid_id ==44){
$this->addLog($car_info->id,'续保销售预约时,部门曾经续保,进入A库',1);
}
} else {
$car_info->location = 5;
$car_info->save();
CarInvalidT::deleteAll('id='.$car_info->id);
$invalid_info = new CarInvalidT();
$invalid_info->id = $car_info->id;
$invalid_info->invalid_id = $invalid_id;
$invalid_info->user_id = $this->my->id;
$invalid_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarCT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
$this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
}
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
public function actionInvalidOldWuxiao()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$car_id = $request->post('car_id');
$invalid_id = $request->post('invalid_id',0);
$ac1 = $request->post('ac1');
$ac2 = $request->post('ac2');
// $ac3 = $request->post('ac3');
$tran = CarT::getDb()->beginTransaction();
try {
$car_info = CarT::findOne(['id'=>$car_id]);
// dd($car_info);
if($invalid_id == 25 || $invalid_id == 27 || $invalid_id == 26 || $invalid_id ==34 || $invalid_id ==35 || $invalid_id ==36 || $invalid_id ==44) {
if($invalid_id == 25 || $invalid_id == 27){
CarF5T::deleteAll('id='.$car_info->id);
$c_info = new CarF5T();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
$c_info->save();
$car_info->location = 12;
$car_info->company = '其他小保险公司';
}elseif($invalid_id == 26 || $invalid_id ==34 || $invalid_id ==35 || $invalid_id ==36){
CarF4T::deleteAll('id='.$car_info->id);
$c_info = new CarF4T();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
switch($invalid_id) {
case 26:
$car_info->company = '人保';
break;
case 34:
$car_info->company = '太平洋';
$c_info->dif = 2;
break;
case 35:
$car_info->company = '国寿财';
break;
case 36:
$car_info->company = '平安';
break;
default:
$car_info->company = '';
}
$c_info->save();
$car_info->location = 11;
}elseif($invalid_id ==44){
$car_info->location = 1;
}
$car_info->insurer1_date = $ac1;
$car_info->insurer2_date = $ac2;
// $car_info->company = $ac3;
$car_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
AppointmentHistoryT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
if($invalid_id == 25 || $invalid_id == 27){
$this->addLog($car_info->id,'续保销售预约时,进入F5续保其他小公司无效库',1);
}elseif($invalid_id == 26 || $invalid_id ==34 || $invalid_id ==35 || $invalid_id ==36){
$this->addLog($car_info->id,'续保销售预约时,进入F4续保四大公司无效库',1);
}elseif($invalid_id ==44){
$this->addLog($car_info->id,'续保销售预约时,部门曾经续保,进入A库',1);
}
} else {
$car_info->location = 13;
$car_info->save();
CarF6T::deleteAll('id='.$car_info->id);
$invalid_info = new CarF6T();
$invalid_info->id = $car_info->id;
$invalid_info->invalid_id = $invalid_id;
$invalid_info->user_id = $this->my->id;
$invalid_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarCT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
$this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
}
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
public function actionInvalidXinbao()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$car_id = $request->post('car_id');
$invalid_id = $request->post('invalid_id',0);
$ac1 = $request->post('ac1');
$ac2 = $request->post('ac2');
// $ac3 = $request->post('ac3');
$tran = CarT::getDb()->beginTransaction();
try {
$car_info = CarT::findOne(['id'=>$car_id]);
// dd($car_info);
if($invalid_id == 57 || $invalid_id == 58 || $invalid_id == 59 || $invalid_id ==60 || $invalid_id ==61) {
if($invalid_id == 61){
CarFT::deleteAll('id='.$car_info->id);
$c_info = new CarFT();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
$c_info->save();
$car_info->location = 7;
$car_info->company = '其他小保险公司';
}elseif($invalid_id == 57 || $invalid_id == 58 || $invalid_id == 59 || $invalid_id ==60){
CarCT::deleteAll('id='.$car_info->id);
$c_info = new CarCT();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
switch($invalid_id) {
case 57:
$car_info->company = '人保';
$c_info->dif = 1;
break;
case 58:
$car_info->company = '平安';
$c_info->dif = 4;
break;
case 59:
$car_info->company = '太平洋';
$c_info->dif = 2;
break;
case 60:
$car_info->company = '国寿财';
$c_info->dif = 3;
break;
default:
$car_info->company = '';
}
$c_info->save();
$car_info->location = 3;
}
$car_info->insurer1_date = $ac1;
$car_info->insurer2_date = $ac2;
// $car_info->company = $ac3;
$car_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
AppointmentHistoryT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
if($invalid_id == 61){
$this->addLog($car_info->id,'续保销售预约时,已在其他人保公司续保车辆数据或在人保公司续保,进入F库',1);
}elseif($invalid_id == 57 || $invalid_id == 58 || $invalid_id == 59 || $invalid_id ==60){
$this->addLog($car_info->id,'续保销售预约时,已在其他人保公司续保车辆数据,进入C库',1);
}
} else {
$car_info->location = 5;
$car_info->save();
CarInvalidT::deleteAll('id='.$car_info->id);
$invalid_info = new CarInvalidT();
$invalid_info->id = $car_info->id;
$invalid_info->invalid_id = $invalid_id;
$invalid_info->user_id = $this->my->id;
$invalid_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarCT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
$this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
}
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
public function actionInvalidNewWuxiao()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$car_id = $request->post('car_id');
$invalid_id = $request->post('invalid_id',0);
$ac1 = $request->post('ac1');
$ac2 = $request->post('ac2');
// $ac3 = $request->post('ac3');
$tran = CarT::getDb()->beginTransaction();
try {
$car_info = CarT::findOne(['id'=>$car_id]);
// dd($car_info);
if($invalid_id == 57 || $invalid_id == 58 || $invalid_id == 59 || $invalid_id ==60 || $invalid_id ==61) {
if($invalid_id == 61){
CarF2T::deleteAll('id='.$car_info->id);
$c_info = new CarF2T();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
$c_info->save();
$car_info->location = 9;
$car_info->company = '其他小保险公司';
}elseif($invalid_id == 57 || $invalid_id == 58 || $invalid_id == 59 || $invalid_id ==60){
CarF1T::deleteAll('id='.$car_info->id);
$c_info = new CarF1T();
$c_info->id = $car_info->id;
$c_info->user_id = 0;
switch($invalid_id) {
case 57:
$car_info->company = '人保';
break;
case 58:
$car_info->company = '平安';
break;
case 59:
$car_info->company = '太平洋';
break;
case 60:
$car_info->company = '国寿财';
break;
default:
$car_info->company = '';
}
$c_info->save();
$car_info->location = 8;
}
$car_info->insurer1_date = $ac1;
$car_info->insurer2_date = $ac2;
// $car_info->company = $ac3;
$car_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
AppointmentHistoryT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
if($invalid_id == 61){
$this->addLog($car_info->id,'新保销售预约时,已在新保其他小公司,进入F2库',1);
}elseif($invalid_id == 57 || $invalid_id == 58 || $invalid_id == 59 || $invalid_id ==60){
$this->addLog($car_info->id,'新保销售预约时,已在新保四大公司,进入F1库',1);
}
} else {
//dd($invalid_id);
$car_info->location = 10;
$car_info->save();
CarF3T::deleteAll('id='.$car_info->id);
$invalid_info = new CarF3T();
$invalid_info->id = $car_info->id;
$invalid_info->invalid_id = $invalid_id;
$invalid_info->user_id = $this->my->id;
$invalid_info->save();
CarBT::deleteAll(['id'=>$car_info->id]);
CarCT::deleteAll(['id'=>$car_info->id]);
CarDT::deleteAll(['id'=>$car_info->id]);
//删除预约
AppointmentT::deleteAll('car_id='.$car_info->id);
//删除保单
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id< 2 ' )
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
$order_info->delete();
}
$orders = OrderT::find()
->where('car_id='.$car_info->id.' and status_id>1')
->all();
foreach($orders as $order_info) {
$order_user_info = OrderUserT::findOne(['order_id'=>$order_info->id,'status'=>0]);
if($order_user_info) {
$order_user_info->status = 3;
$order_user_info->save();
}
}
$this->addLog($car_info->id,'无效车辆数据:'.$invalid_info->invalid->name,1);
}
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
throw $e;
}
}
return $result;
}
public function actionSearch()
{
$request = Yii::$app->request;
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$car_model = $request->get('car_model');
$register_date = $request->get('register_date');
$insurer_date = $request->get('insurer_date');
$id_man = $request->get('id_man');
$op = $request->get('op',1);
$page = $request->get('page',1);
if($page < 1 ) $ page = 1;
$query = CarT::find()
->leftJoin('order_t','`order_t`.`car_id`=`car_t`.`id`');
if($op==0) {
$query = $query->andWhere('car_t.id=-1');
}
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$linkman_items = LinkmanT::find()
->where('phone like "'.$phone.'"')
->all();
$car_ids = array();
foreach($linkman_items as $linkman_info) {
$car_ids[] = $linkman_info->car_id;
}
$car_ids_str = join(',',$car_ids);
if($car_ids_str == '')
$car_ids_str = '0';
$query = $query->andWhere('(car_t.phone like "'.$phone.'" or car_t.id in ('.$car_ids_str.'))');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'%"');
}
if($car_model != '') {
$query = $query->andWhere('car_t.car_model="'.$car_model.'"');
}
if($register_date != '') {
$query = $query->andWhere('car_t.register_date='.$register_date);
}
if($insurer_date != '') {
$query = $query->andWhere('car_t.insurer1_date="'.$insurer_date.'" or car_t.insurer2_date="'.$insurer_date.'"');
}
if($id_man != '') {
$query = $query->andWhere('order_t.id_man="'.$id_man.'"');
}
$total = $query->count();
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]);
$pagination->setPage($page-1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
$items = $query->all();
$page_info = MyLib::getPageInfo($pagination);
return $this->render('search',[
'items' => $items,
'car_man' => $car_man,
'phone' => $phone,
'car_no' => $car_no,
'car_model' => $car_model,
'register_date' => $register_date,
'insurer_date' => $insurer_date,
'id_man' => $id_man,
'page' => $page,
'page_info' => $page_info
]);
}
public function actionNonSearch()
{
$request = Yii::$app->request;
$car_man = $request->get('car_man');
$phone = $request->get('phone');
$car_no = $request->get('car_no');
$car_model = $request->get('car_model');
$register_date = $request->get('register_date');
$insurer_date = $request->get('insurer_date');
$id_man = $request->get('id_man');
$op = $request->get('op',1);
$page = $request->get('page',1);
if($page < 1 ) $ page = 1;
$query = CarT::find()
->leftJoin('order_t','`order_t`.`car_id`=`car_t`.`id`');
if($op==0) {
$query = $query->andWhere('car_t.id=-1');
}
if($car_man != '') {
$query = $query->andWhere('car_t.car_man like "'.$car_man.'"');
}
if($phone != '') {
$linkman_items = LinkmanT::find()
->where('phone like "'.$phone.'"')
->all();
$car_ids = array();
foreach($linkman_items as $linkman_info) {
$car_ids[] = $linkman_info->car_id;
}
$car_ids_str = join(',',$car_ids);
if($car_ids_str == '')
$car_ids_str = '0';
$query = $query->andWhere('(car_t.phone like "'.$phone.'" or car_t.id in ('.$car_ids_str.'))');
}
if($car_no != '') {
$query = $query->andWhere('car_t.car_no like "'.$car_no.'%"');
}
if($car_model != '') {
$query = $query->andWhere('car_t.car_model="'.$car_model.'"');
}
if($register_date != '') {
$query = $query->andWhere('car_t.register_date='.$register_date);
}
if($insurer_date != '') {
$query = $query->andWhere('car_t.insurer1_date="'.$insurer_date.'" or car_t.insurer2_date="'.$insurer_date.'"');
}
if($id_man != '') {
$query = $query->andWhere('order_t.id_man="'.$id_man.'"');
}
$total = $query->count();
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]);
$pagination->setPage($page-1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
$items = $query->all();
$page_info = MyLib::getPageInfo($pagination);
return $this->render('non-search',[
'items' => $items,
'car_man' => $car_man,
'phone' => $phone,
'car_no' => $car_no,
'car_model' => $car_model,
'register_date' => $register_date,
'insurer_date' => $insurer_date,
'id_man' => $id_man,
'page' => $page,
'page_info' => $page_info
]);
}
// public function actionSmsMake()
// {
// Yii::$app->response->format = Response::FORMAT_JSON;
// $request = Yii::$app->request;
// $result = array();
// $result['success'] = false;
// $result['msg'] = '生成失败';
//
// $order_id = $request->post('order_id');
// $order_info = OrderT::findOne(['id'=>$order_id]);
// $car_info = $order_info->car;
//
// $total1 = $request->post('total1');
// $total2 = $request->post('total2');
// $total3 = $request->post('total3');
// $total_all = $request->post('total_all');
// $total_real = $request->post('total_real');
// $types = $request->post('types');
// $nopays = $request->post('nopays');
//
// $insurer_type_items = InsurerTypeT::find()->all();
//
//// 之前的生成短信内容
//// $msg = '尊敬的'.$car_info->car_no.'客户您好,人保车险'.$this->my->name.'为您报价:';
//// $msg .= '交强险'.$total2.'元,';
//// $msg .= '商业险'.$total1.'元';
//// $msg .= '(包含';
//// $bj = '';
//// foreach($insurer_type_items as $item) {
//// if($item->id == 10 || $item->id == 11) continue;
//// if($types[$item->id] != '' & & $types[$item->id] != '否' & & $types[$item->id] != '无') {
//// $msg .= $item->name;
//// if($types[$item->id] != '是')
//// $msg .= $types[$item->id];
//// $msg .= '、';
//// if(isset($nopays[$item->id]) & & ($nopays[$item->id] == 1))
//// $bj .= $item->code;
//// }
//// }
//// if($bj != '') {
//// $msg .= '不计免赔覆盖'.$bj.'),';
//// }
//// if($total3 > 0) {
//// $msg .= '车船税'.$total3.'元,';
//// }
//// $msg .= '发票金额:'.$total_all.'元,';
//// $msg .= '实收:'.$total_real.'元,';
//// $msg .= '以上价格仅供参考,价格可能受您的历史理赔情况等的影响,最终价格以出单为准。详情请咨询010-53778188,回复TD拒收。';
//
// //新的生成短信
// $msg = '您好,中国人保车险'.$this->my->name.'(工号'.$this->my->username.'), 您的'.$car_info->car_no.':';
// $msg .= '交强险'.$total2.'元,';
// if($total3 > 0) {
// $msg .= '车船'.$total3.'元,';
// }
// $msg .= '商业险'.$total1.'元,';
// $msg .= '总计'.($total_all).'元,';
// $msg .= '实收:'.($total_real).'元,';
// $msg .= '(含';
// $bj = '';
// foreach($insurer_type_items as $item) {
// if($item->id == 10 || $item->id == 11) continue;
// if($types[$item->id] != '' & & $types[$item->id] != '否' & & $types[$item->id] != '无') {
// $msg .= $item->name;
// if($types[$item->id] != '是')
// $msg .= $types[$item->id];
// $msg .= '、';
// if(isset($nopays[$item->id]) & & ($nopays[$item->id] == 1))
// $bj .= $item->code;
// }
// }
// if($bj != '') {
// $msg .= '及相应不计免赔),';
//// $msg .= '不计免赔覆盖'.$bj.'),';
// }
// if($total1 < 1500 ) {
// $eleven = '7.(①进口3M封釉全车美容,②四轮定位动平衡,③二十二项全车检测,④保养100元工时抵用券,⑤内饰臭氧杀菌消毒);服务项目五选二';
// $eight = '8.上门免费办理ETC';
// $nine = null;
// }elseif($total1 >= 1500){
// $eleven = '7.(①进口3M封釉全车美容,②四轮定位动平衡,③二十二项全车检测,④保养100元工时抵用券,⑤内饰臭氧杀菌消毒);服务项目五选二';
// $eight = '8.上门免费办理ETC';
// $nine = null;
// }else if($total1 >= 2000){
// $eleven = '7.(①进口3M封釉全车美容,②四轮定位动平衡,③二十二项全车检测,④保养100元工时抵用券,⑤内饰臭氧杀菌消毒);服务项目五选二';
// $eight = '8.上门免费办理ETC';
// $nine = null;
// }else{
// $eleven = '7.上门免费办理ETC';
// $eight = null;
// $nine = null;
// }
// $msg .= '内含:
//1.客户经理一对一处理事故现场及理赔咨询
//2.全程代办:上门接送车辆定损维修理赔一站式服务
//3.一案多修(可维修四处车伤)
//4.单双方事故通定直赔,全程代办(可约代步车)
//5.全年24小时事故救援,非事故救援(搭电,送水,换备胎,拖车等)
//6.送单上门
//'.$eleven.'
//'.$eight.'
//'.$nine.'
//您有任何问题请拨打'.$this->my->phone.',微信同号。祝您生活愉快!
//回复TD拒收';
//
// $result['success'] = true;
// $result['msg'] = $msg;
// return $result;
// }
// public function actionSmsMake()
// {
// Yii::$app->response->format = Response::FORMAT_JSON;
// $request = Yii::$app->request;
// $result = array();
// $result['success'] = false;
// $result['msg'] = '生成失败';
//
// $order_id = $request->post('order_id');
// $order_info = OrderT::findOne(['id'=>$order_id]);
// $car_info = $order_info->car;
//
// $total1 = $request->post('total1');
// $total2 = $request->post('total2');
//
// $total1_clear = $request->post('total1_clear');
//
// $total3 = $request->post('total3');
// $total_all = $request->post('total_all');
// $total_real = $request->post('total_real');
// $types = $request->post('types');
// $nopays = $request->post('nopays');
// $total1_dis = $request->post('total1_dis');
//
// $insurer_type_items = InsurerTypeT::find()->all();
//
//// 之前的生成短信内容
//// $msg = '尊敬的'.$car_info->car_no.'客户您好,人保车险'.$this->my->name.'为您报价:';
//// $msg .= '交强险'.$total2.'元,';
//// $msg .= '商业险'.$total1.'元';
//// $msg .= '(包含';
//// $bj = '';
//// foreach($insurer_type_items as $item) {
//// if($item->id == 10 || $item->id == 11) continue;
//// if($types[$item->id] != '' & & $types[$item->id] != '否' & & $types[$item->id] != '无') {
//// $msg .= $item->name;
//// if($types[$item->id] != '是')
//// $msg .= $types[$item->id];
//// $msg .= '、';
//// if(isset($nopays[$item->id]) & & ($nopays[$item->id] == 1))
//// $bj .= $item->code;
//// }
//// }
//// if($bj != '') {
//// $msg .= '不计免赔覆盖'.$bj.'),';
//// }
//// if($total3 > 0) {
//// $msg .= '车船税'.$total3.'元,';
//// }
//// $msg .= '发票金额:'.$total_all.'元,';
//// $msg .= '实收:'.$total_real.'元,';
//// $msg .= '以上价格仅供参考,价格可能受您的历史理赔情况等的影响,最终价格以出单为准。详情请咨询010-53778188,回复TD拒收。';
//
// //新的生成短信
// $msg ='尊敬的'.$car_info->car_no.'客户您好:人保'.$this->my->name.'(工号'.$this->my->username.')为您报价:';
//// $msg = '您好,中国人保车险'.$this->my->name.'(工号'.$this->my->username.'), 您的'.$car_info->car_no.':';
// $msg .= '交强険'.$total2.'元,';
// if($total3 > 0) {
// $msg .= '车船'.$total3.'元,';
// }
// $msg .= '商业険'.$total1.'元,';
// $msg .= '总计'.($total_all).'元,';
// $msg .= '[';
// $bj = '';
// foreach($insurer_type_items as $item) {
// if($item->id == 10 || $item->id == 11) continue;
// if($types[$item->id] != '' & & $types[$item->id] != '否' & & $types[$item->id] != '无') {
// $msg .= $item->name;
// if($types[$item->id] != '是')
// $msg .= $types[$item->id];
// $msg .= '、';
// if(isset($nopays[$item->id]) & & ($nopays[$item->id] == 1))
// $bj .= $item->code;
// }
// }
// if($bj != '') {
// $msg .= '不计免赔];';
// }
//// if($total1_clear < 1000 ) {
//// $msg .= '
////您有任何问题请拨打'.$this->my->phone.'联系我,微信同号。祝您生活愉快!
////回复TD拒收';
////
//// }else{
//// if($total1_clear >= 1000 & & $total1_clear < 2000 ) {
//// $eleven = '7.另有超值项目五选二';
//// $eight = null;
//// $nine = null;
//// }else if($total1_clear >= 2000 & & $total1_clear< 3000 ) {
//// $eleven = '7.另有超值项目五选二';
////
//// $eight = null;
////
//// $nine = null;
//// }else if($total1_clear >= 3000){
////
////// $eleven = '7.(1.一个部位车伤修复 (含钣金喷漆),2.免费小保养一次 3.整车无机镀晶一次)三选一';
//// $eleven = '7.另有超值项目五选二';
////
//// $eight = null;
//// $nine = null;
//// }else{
////// $eleven = '7.上门免费办理ETC';
//// $eleven = null;
//// $eight = null;
//// $nine = null;
//// }
// $msg .= '出单赠送赠送≥'.$total1.'元商业全额保单专享礼包:
//1.'.$total1_dis.'元现金红包
//2.价值600-1000元升级礼券包(喷漆,保养,镀晶三选一)
//3.价值1200元超值美容包(外观美容封釉,内室臭氧杀菌,空调风道清洗三项)
//4.价值2000元VIP服务包(人伤极速赔、客户经理一对一、全程代办、双方事故直赔、一案多修、升级救援、代步车等15项理赔升级服务,附VIP客户车险服务权益书告知书一份)
//5.赠送470元全国通用体检套餐双人卡1份
//短信字数有限,详询010-51669518或'.$this->my->phone.'联系我,微信同号。祝您生活愉快!
//回复TD拒收';
//// }
//
//
// $result['success'] = true;
// $result['msg'] = $msg;
// return $result;
// }
// public function actionSmsMake()
// {
// Yii::$app->response->format = Response::FORMAT_JSON;
// $request = Yii::$app->request;
// $result = array();
// $result['success'] = false;
// $result['msg'] = '生成失败';
//
// $order_id = $request->post('order_id');
// $order_info = OrderT::findOne(['id'=>$order_id]);
// $car_info = $order_info->car;
//
// $total1 = $request->post('total1');
// $total2 = $request->post('total2');
//
// $total1_clear = $request->post('total1_clear');
//
// $total3 = $request->post('total3');
// $total_all = $request->post('total_all');
// $total_real = $request->post('total_real');
// $types = $request->post('types');
// $nopays = $request->post('nopays');
// $total1_dis = $request->post('total1_dis');
//
// $insurer_type_items = InsurerTypeT::find()->all();
//
// //保费15%
// $hongbao=$total1_clear * 0.15;
//
//
//// 之前的生成短信内容
//// $msg = '尊敬的'.$car_info->car_no.'客户您好,人保车险'.$this->my->name.'为您报价:';
//// $msg .= '交强险'.$total2.'元,';
//// $msg .= '商业险'.$total1.'元';
//// $msg .= '(包含';
//// $bj = '';
//// foreach($insurer_type_items as $item) {
//// if($item->id == 10 || $item->id == 11) continue;
//// if($types[$item->id] != '' & & $types[$item->id] != '否' & & $types[$item->id] != '无') {
//// $msg .= $item->name;
//// if($types[$item->id] != '是')
//// $msg .= $types[$item->id];
//// $msg .= '、';
//// if(isset($nopays[$item->id]) & & ($nopays[$item->id] == 1))
//// $bj .= $item->code;
//// }
//// }
//// if($bj != '') {
//// $msg .= '不计免赔覆盖'.$bj.'),';
//// }
//// if($total3 > 0) {
//// $msg .= '车船税'.$total3.'元,';
//// }
//// $msg .= '发票金额:'.$total_all.'元,';
//// $msg .= '实收:'.$total_real.'元,';
//// $msg .= '以上价格仅供参考,价格可能受您的历史理赔情况等的影响,最终价格以出单为准。详情请咨询010-53778188,回复TD拒收。';
//
//
// //新的生成短信
// $msg ='尊敬的'.$car_info->car_no.'客户您好:人保'.$this->my->name.'(工号'.$this->my->username.')为您报价:';
//// $msg = '您好,中国人保车险'.$this->my->name.'(工号'.$this->my->username.'), 您的'.$car_info->car_no.':';
// $msg .= '交强険'.$total2.'元,';
// if($total3 > 0) {
// $msg .= '车船'.$total3.'元,';
// }
// $msg .= '商业険'.$total1.'元,';
// $msg .= '总计'.($total_all).'元,';
// $msg .= '[';
// $bj = '';
// foreach($insurer_type_items as $item) {
// if($item->id == 10 || $item->id == 11) continue;
// if($types[$item->id] != '' & & $types[$item->id] != '否' & & $types[$item->id] != '无') {
// $msg .= $item->name;
// if($types[$item->id] != '是')
// $msg .= $types[$item->id];
// $msg .= '、';
// if(isset($nopays[$item->id]) & & ($nopays[$item->id] == 1))
// $bj .= $item->code;
// }
// }
// if($bj != '') {
// $msg .= '不计免赔];';
// }
//// if($total1_clear < 1000 ) {
//// $msg .= '
////您有任何问题请拨打'.$this->my->phone.'联系我,微信同号。祝您生活愉快!
////回复TD拒收';
////
//// }else{
//// if($total1_clear >= 1000 & & $total1_clear < 2000 ) {
//// $eleven = '7.另有超值项目五选二';
//// $eight = null;
//// $nine = null;
//// }else if($total1_clear >= 2000 & & $total1_clear< 3000 ) {
//// $eleven = '7.另有超值项目五选二';
////
//// $eight = null;
////
//// $nine = null;
//// }else if($total1_clear >= 3000){
////
////// $eleven = '7.(1.一个部位车伤修复 (含钣金喷漆),2.免费小保养一次 3.整车无机镀晶一次)三选一';
//// $eleven = '7.另有超值项目五选二';
////
//// $eight = null;
//// $nine = null;
//// }else{
////// $eleven = '7.上门免费办理ETC';
//// $eleven = null;
//// $eight = null;
//// $nine = null;
//// }
//// 1.现金红包XXX元(限时),2. 免费升级驾驶员人身意外保障26万。3.赠送VIP卡(包含进口封釉、内饰臭氧杀菌、空调风道清洗、四轮定位等十项服务)
//// 4.尊享VIP服务包(人伤极速赔、客户经理一对一、全程代办、双方事故直赔、一案多修、升级救援、代步车等15项理赔升级服务)5.升级划痕险不用投保享一案多修服务 6.享受北京市600家4S店直赔服务。
//// 7.享受全国免费事故,
//// 非事故救援(送水,搭电,换备胎,现场小修)8.享受玻璃上门更换 9.享受自然灾害百分百赔付(地震除外) 10.享受无法找到第三方无免赔服务 详询186******联系我,回复TD拒收
//
// $msg .='
//1.现金红包'.$total1_dis.'元(限时),
//2. 免费升级驾驶员人身意外保障26万。
//3.赠送VIP卡(包含进口封釉、内饰臭氧杀菌、空调风道清洗、四轮定位等十项服务)
//4.尊享VIP服务包(人伤极速赔、客户经理一对一、全程代办、双方事故直赔、一案多修、升级救援、代步车等15项理赔升级服务)
//5.升级划痕险不用投保享一案多修服务
//6.享受全国免费事故,非事故救援(送水,搭电,换备胎,现场小修),免费上门跟换玻璃
//7.享受无法找到第三方无免赔服务 详询'.$this->my->phone.'加我(微信同号),回复TD拒收';
//
//// }
//
//
// $result['success'] = true;
// $result['msg'] = $msg;
// return $result;
// }
public function actionSmsSend()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$MessageContent = $request->post('msg');
$UserNumber = $request->post('tel');
$company2_id = $request->post('company2_id');
if($company2_id == 0){
$result['msg'] = '保险公司不能为空';
return $result;
}
if($UserNumber == '' || $UserNumber == 0){
$result['msg'] = '手机手机号不能为空';
return $result;
}
if($MessageContent == ''){
$result['msg'] = '短信内容不能为空';
return $result;
}
$MessageContent = str_replace("\n","",$MessageContent);
$MessageContent = str_replace("\r","",$MessageContent);
$MessageContent = str_replace("\f","",$MessageContent);
$MessageContent = str_replace("\t","",$MessageContent);
$url = 'https://sms.yunpian.com/v2/sms/single_send.json';
$params['apikey'] = '453067dc4b9eb0dc0c448674d79e85aa';
$params['mobile'] = $UserNumber;
$params['text'] = $MessageContent;
$post_url = http_build_query($params);
$msg = MyLib::Post($post_url,$url);
// $msg = mb_convert_encoding($msg,'UTF8','GBK');
// parse_str($msg,$obj);
$obj = json_decode($msg);
$result = array();
// $result['success'] = true;
if($obj->code == 0){
$result['msg'] = $obj->msg;
}else{
$result['msg'] = $obj->msg.'('.$obj->detail.')';
}
return $result;
}
public function actionSmsMake()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '生成失败';
$order_id = $request->post('order_id');
$company2_id = $request->post('company2_id');
// $company2_name = InsurerCompany2T::findOne($company2_id)->name;
$company2_name ='';
if($company2_id == 1){
$company2_name = '人保车险';
}elseif ($company2_id ==8){
$company2_name = '平安车险';
}elseif ($company2_id == 4){
$company2_name = '太平洋车险';
}elseif ($company2_id ==7){
$company2_name = '人寿车险';
}
$company2 ='';
if($company2_id == 1){
$company2 = '人保';
}elseif ($company2_id == 8){
$company2 = '平安';
}elseif ($company2_id == 4){
$company2 = '太平洋';
}elseif ($company2_id == 7){
$company2 = '太平洋';
}
// var_dump($order_id);
// die;
$order_info = OrderT::findOne(['id'=>$order_id]);
$car_info = $order_info->car;
$total1 = $request->post('total1');
$total2 = $request->post('total2');
$total1_dis = $request->post('total1_dis');
$total1_clear = $request->post('total1_clear');
$total3 = $request->post('total3');
$total_all = $request->post('total_all');
$total_real = $request->post('total_real');
$types = $request->post('types');
$nopays = $request->post('nopays');
$insurer_type_items = InsurerTypeT::find()->all();
$msg = '【'.$company2_name.'】尊敬的'.$car_info->car_no.'客户您好:'.$company2.$this->my->name.'为您报价:';
$msg .= '交强、';
if($total3 > 0) {
$msg .= '车船税、';
}
// $msg .= '商业'.$total1.'元';
// $msg .= '总计'.($total_all).'元,';
// $msg .= '实收'.($total_real).'元;';
//$msg .= '[';
$msg1 = '';
$bj = '';
$has_chesun = 0;
foreach($insurer_type_items as $item) {
if($item->id == 10 || $item->id == 11) continue;
if($types[$item->id] != '' & & $types[$item->id] != '否' & & $types[$item->id] != '无') {
if($item->name == '车损'){
$has_chesun = 1;
}
if($item->name == '无法找到第三方特约险'){
$msg1 .= '无法找到第三方';
}else{
$msg1 .= $item->name;
}
if($types[$item->id] != '是')
if($item->name != '车损'){
$msg1 .= $types[$item->id];
}
$msg1 .= '、';
if(isset($nopays[$item->id]) & & ($nopays[$item->id] == 1))
$bj .= $item->code;
}
}
if($msg1 != ''){
if($bj != ''){
$msg1 .= '不计免赔';
$msg1 = $msg1.',';
}else{
$msg1 = rtrim($msg1,'、');
$msg1 = $msg1.',';
}
}
$msg .= $msg1;
// $msg .= '总计'.($total_all).'元;';
$msg .= '保费实收'.($total_real).'元;';
$msg_1 = '升级礼品三选一(喷漆,镀晶,保养);';
$msg_2 = '赠送VIP服务卡(车辆美容、人伤极速赔、客户经理一对一、全程代办等);';
$msg_3 = '尊享一案多修服务;';
if($has_chesun == 0){
$msg .= '1.'.$msg_2;
}elseif($total1_clear < 1500 ) {
$msg .= '1.'.$msg_2.'2.'.$msg_3;
}else{
$msg .= '1.'.$msg_1.'2.'.$msg_2.'3.'.$msg_3;
}
$msg .= '详询51669518或'.$this->my->phone.'微信同号,祝您生活愉快。';
// }
$result['success'] = true;
$result['msg'] = $msg;
return $result;
}
public function actionLinkmanSave()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '保存失败';
if($request->isPost) {
$car_id = $request->post('car_id',0);
$name = $request->post('name');
$phone = $request->post('phone');
$id_number = $request->post('id_number');
$type = $request->post('type');
if($name == '' || $phone == '') {
$result['msg'] = '请输入姓名和联系电话!';
return $result;
}
$row = null;
$linkman_info = new LinkmanT();
$linkman_info->car_id = $car_id;
$linkman_info->name = $name;
$linkman_info->phone = $phone;
$linkman_info->type = $type;
$linkman_info->id_number = $id_number;
if(!$linkman_info->save()) {
var_dump($linkman_info->errors);
}
$result['success'] = true;
$result['msg'] = '保存成功';
}
return $result;
}
public function actionAjaxLinkmanIndex()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$car_id = $request->get('car_id');
$result = array();
$result['success'] = false;
$result['msg'] = '读取失败';
$query = LinkmanT::find()
->where(['car_id'=>$car_id])
->orderBy('id ASC');
$items = $query->all();
$html = $this->renderPartial('ajax-linkman-index',[
'items' => $items
]);
$result['success'] = true;
$result['html'] = $html;
return $result;
}
}