// +---------------------------------------------------------------------- namespace battery\portal\controller; use battery\portal\model\BatteryBaseModel; use battery\portal\model\PingZfPlatform; use battery\portal\model\SdPlatform; use think\Config; use think\Request; use think\Validate; class BrandController extends BatteryBaseController { function index(){ $this->setTitleName('自助选车'); return $this->fetch(); } function searchBrand(){ $sdPlatform=new SdPlatform(); $info=$sdPlatform->searchBrand(); if($info['status']){ $this->success('请求成功','',$info['info']); }else{ $this->error('获取失败'); } } function searchSeries(){ $validate = new Validate([ 'name' => 'require', ]); $validate->message([ 'name.require' => '品牌名称', ]); $data = $this->request->param(); if (!$validate->check($data)) { $this->error($validate->getError()); } $sdPlatform=new SdPlatform(); $info=$sdPlatform->searchSeries(trim($data['name'])); if($info['status']){ $this->success('请求成功','',$info['info']); }else{ $this->error('获取失败'); } } function searchYear(){ $validate = new Validate([ 'name' => 'require', 'type' => 'require', ]); $validate->message([ 'name.require' => '品牌名称', 'type.require' => '车辆类型', ]); $data = $this->request->param(); if (!$validate->check($data)) { $this->error($validate->getError()); } $sdPlatform=new SdPlatform(); $info=$sdPlatform->searchYear(trim($data['name']),trim($data['type'])); if($info['status']){ $this->success('请求成功','',$info['info']); }else{ $this->error('获取失败'); } } function searchModel(){ $validate = new Validate([ 'name' => 'require', 'type' => 'require', 'year' => 'require', ]); $validate->message([ 'name.require' => '品牌名称', 'type.require' => '车辆类型', 'year.require' => '车辆类型', ]); $data = $this->request->param(); if (!$validate->check($data)) { $this->error($validate->getError()); } $sdPlatform=new SdPlatform(); $info=$sdPlatform->searchModel(trim($data['name']),trim($data['type']),trim($data['year'])); if($info['status']){ $this->success('请求成功','',$info['info']); }else{ $this->error('获取失败'); } } function goods(){ $validate = new Validate([ 'name' => 'require', 'type' => 'require', 'year' => 'require', 'model' => 'require', 'carid' => 'require', ]); $validate->message([ 'name.require' => '品牌名称', 'type.require' => '车辆类型', 'year.require' => '车辆类型', 'model.require' => '车辆类型', 'carid.require' => '车辆类型', ]); $data = $this->request->param(); if (!$validate->check($data)) { $this->error($validate->getError()); } $sdPlatform=new SdPlatform(); $info=$sdPlatform->weblcMatch(trim($data['carid'])); $sdata=array(); if($info['status']){ $sdata=$info['info']; } $this->setTitleName('电瓶上门安装'); $this->assign('carname', trim($data['name'])); $this->assign('cartype', trim($data['type'])); $this->assign('caryear', trim($data['year'])); $this->assign('carmodel', trim($data['model'])); $this->assign('datalist', $sdata); return $this->fetch(); } function getpay(){ $validate = new Validate([ 'name' => 'require', 'type' => 'require', 'year' => 'require', 'model' => 'require', 'gid' => 'require', ]); $validate->message([ 'name.require' => '品牌名称', 'type.require' => '车辆类型', 'year.require' => '车辆年份', 'model.require' => '车辆型号', 'gid.require' => '商品ID', ]); $data = $this->request->param(); if (!$validate->check($data)) { $this->error($validate->getError()); } $batteryBaseModel = new BatteryBaseModel(); $goodWhere['gid']=$data['gid']; $good=$batteryBaseModel->name('good')->where($goodWhere)->order('id DESC')->find(); if(!$good){ $this->error('获取商品失败'); } $morderid = 'T' . $this->getOrderId(); $time=time(); $md5=md5($morderid.'rWY27jftsCVkawzmUtNi2b53niWbTopU'); $orderData = array( 'order_id' => $morderid, 'gid' => intval($data['gid']), 'amount' => $good->price, 'create_time' => $time, 'up_time' => $time, 'brief' => '电池', 'car_name' => trim($data['name']), 'car_type' => trim($data['type']), 'car_year' => trim($data['year']), 'car_model' =>trim($data['model']), 'ip' => get_client_ip(), 'md5' => $md5 ); $tag=$batteryBaseModel->name('order')->insert($orderData); if($tag){ $this->success('请求成功','',$md5); }else{ $this->error('获取失败'); } } function details(){ $validate = new Validate([ 'token' => 'require', ]); $validate->message([ 'token.require' => '参数异常', ]); $data = $this->request->param(); if (!$validate->check($data)) { $this->error($validate->getError()); } $this->setTitleName('订单确认'); $batteryBaseModel=new BatteryBaseModel(); $where['md5']=$data['token']; $order=$batteryBaseModel->name('order')->where($where)->find(); if($order){ $order->amount=bcdiv($order->amount,100,2); $weekArr=array("日","一","二","三","四","五","六"); $days=array(); for($i=0;$i<35;$i++){ $days[$i]['time']=date("m-d",strtotime('+'.$i.'day')); $days[$i]['time_date']=date("Y-m-d",strtotime('+'.$i.'day')); if ($i==0) { $days[$i]['week']= '今'; $days[$i]['class']= 'jin'; }else{ $days[$i]['week']= $weekArr[date("w",strtotime('+'.$i.'day'))]; } } $setdata=array(); $str=''; foreach ($days as $key=>$v){ $str=$str."