486 lines
22 KiB
PHP
486 lines
22 KiB
PHP
<?php
|
||
|
||
|
||
namespace app\admin\service;
|
||
|
||
|
||
use app\admin\exception\LogicException;
|
||
use app\model\Inquiry;
|
||
use app\model\Property_cert_info;
|
||
use app\model\Survey;
|
||
use app\model\SurveyDetail;
|
||
use think\Db;
|
||
|
||
class SurveyService extends CommonService
|
||
{
|
||
/**
|
||
* 发起查勘
|
||
*
|
||
* @param $userId
|
||
* @param array $data
|
||
* @return mixed
|
||
* @throws LogicException
|
||
*/
|
||
public function askSurvey(array $data)
|
||
{
|
||
Db::startTrans();
|
||
|
||
|
||
$inquiry = Db::name('inquiry')->field('id,status')->where(['order_no' => $data['order_no']])->find();
|
||
if(!($inquiry['status'] >= 2))
|
||
return ['code'=>-1, 'msg'=>'订单状态有误,无法发起查勘'];
|
||
|
||
$start_time = date('Y-m-d H:i:s', strtotime('-6 months'));
|
||
$end_time = date('Y-m-d H:i:s');
|
||
|
||
//生成查勘数据
|
||
foreach ($data['detail'] as $res){
|
||
$adddata['order_no'] = $data['order_no'];
|
||
$adddata['property_cert_info_id'] = $res['property_cert_info_id'];
|
||
$adddata['contact_name'] = $res['contact_name'];
|
||
$adddata['contact_phone'] = $res['contact_phone'];
|
||
$adddata['area'] = $res['area'];
|
||
$adddata['area_id'] = $res['area_id'];
|
||
$adddata['remark'] = $res['remark'];
|
||
// $adddata['user_id'] = $data['user_id'];
|
||
// $adddata['user_name'] = $data['user_name'];
|
||
$adddata['user_id'] = $res['survey_user_id'];
|
||
$adddata['user_name'] = $res['survey_user_name'];
|
||
$adddata['assignee_id']= $data['user_id'];
|
||
$adddata['assign_time']=date('Y-m-d H:i:s',time());
|
||
|
||
$adddata['status'] = 2;
|
||
$adddata['create_time'] = date("Y-m-d H:i:s" ,time());
|
||
$adddata['update_time'] = date("Y-m-d H:i:s" ,time());
|
||
|
||
// 检查该物业是否在6个月之内出过报告
|
||
$property_full_name = Db::name('property_cert_info')
|
||
->where('id='.$res['property_cert_info_id'])
|
||
->value('property_full_name');
|
||
|
||
$ck_where = [];
|
||
$ck_where[] = ['property_full_name', '=', $property_full_name];
|
||
$ck_where[] = ['id', '<>', $res['property_cert_info_id']];
|
||
$ck_where[] = ['create_time', 'between time', [$start_time, $end_time]];
|
||
|
||
$inquiry_ids = Db::name('property_cert_info')
|
||
->where($ck_where)
|
||
->field('quot_id')
|
||
->select();
|
||
|
||
// foreach ($inquiry_ids as $quot_id) {
|
||
// $status = Db::name('inquiry')
|
||
// ->where('id='.$quot_id['quot_id'])
|
||
// ->value('status');
|
||
// if ($status==8) {
|
||
// Db::rollback();
|
||
// return ['code'=>-1, 'msg'=>'发起查勘失败,存在6个月内出过报告的物业,需要申请!'];
|
||
// }
|
||
// }
|
||
|
||
//添加查勘信息
|
||
$survey_id = Db::name('survey')->insertGetId($adddata);
|
||
if(!$survey_id){
|
||
Db::rollback();
|
||
return ['code'=>-1, 'msg'=>'查勘单生成失败'];
|
||
}
|
||
|
||
//添加查勘详情
|
||
if(!Db::name('survey_detail')->insert(['survey_id'=>$survey_id])){
|
||
Db::rollback();
|
||
return ['code'=>-1, 'msg'=>'查勘详情初始化失败'];
|
||
}
|
||
//写入消息
|
||
PublicMessage($inquiry['id'],5,6,$res['property_cert_info_id']); // 消息推送
|
||
}
|
||
|
||
//更新订单状态:查勘待派单
|
||
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => new \DateTime])) {
|
||
Db::rollback();
|
||
return ['code'=>-1, 'msg'=>'更新订单状态失败'];
|
||
}
|
||
|
||
Db::commit();
|
||
return ['code'=>1, 'msg'=>'操作成功'];
|
||
}
|
||
|
||
//
|
||
public function askSurveyUnck(array $data)
|
||
{
|
||
Db::startTrans();
|
||
$inquiry = Db::name('inquiry')->field('id,status')->where(['order_no' => $data['order_no']])->find();
|
||
if(!($inquiry['status'] >= 2))
|
||
return ['code'=>-1, 'msg'=>'订单状态有误,无法发起查勘'];
|
||
|
||
//生成查勘数据
|
||
foreach ($data['detail'] as $res){
|
||
$adddata['order_no'] = $data['order_no'];
|
||
$adddata['property_cert_info_id'] = $res['property_cert_info_id'];
|
||
$adddata['contact_name'] = $res['contact_name'];
|
||
$adddata['contact_phone'] = $res['contact_phone'];
|
||
$adddata['area'] = $res['area'];
|
||
$adddata['area_id'] = $res['area_id'];
|
||
$adddata['remark'] = $res['remark'];
|
||
$adddata['user_id'] = $res['survey_user_id'];
|
||
$adddata['user_name'] = $res['survey_user_name'];
|
||
$adddata['assignee_id']= $data['user_id'];
|
||
$adddata['assign_time']=date('Y-m-d H:i:s',time());
|
||
$adddata['status'] = 2;
|
||
$adddata['create_time'] = date("Y-m-d H:i:s" ,time());
|
||
$adddata['update_time'] = date("Y-m-d H:i:s" ,time());
|
||
|
||
//添加查勘信息
|
||
$survey_id = Db::name('survey')->insertGetId($adddata);
|
||
if(!$survey_id){
|
||
Db::rollback();
|
||
return ['code'=>-1, 'msg'=>'查勘单生成失败'];
|
||
}
|
||
|
||
//添加查勘详情
|
||
if(!Db::name('survey_detail')->insert(['survey_id'=>$survey_id])){
|
||
Db::rollback();
|
||
return ['code'=>-1, 'msg'=>'查勘详情初始化失败'];
|
||
}
|
||
//写入消息
|
||
PublicMessage($inquiry['id'],5,6,$res['property_cert_info_id']); // 消息推送
|
||
}
|
||
|
||
//更新订单状态:查勘待派单
|
||
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => new \DateTime])) {
|
||
Db::rollback();
|
||
return ['code'=>-1, 'msg'=>'更新订单状态失败'];
|
||
}
|
||
|
||
Db::commit();
|
||
return ['code'=>1, 'msg'=>'操作成功'];
|
||
}
|
||
|
||
/**
|
||
* 检查查勘信息
|
||
*/
|
||
public function checkSurvey(array $details){
|
||
$isSuccess = true;
|
||
$errors = [];
|
||
foreach ($details as $index => $detail){
|
||
//todo 城区检查
|
||
if(!isset($detail['property_cert_info_id']) || !$detail['property_cert_info_id']){
|
||
$isSuccess = false;
|
||
$errors[$index]['property_cert_info_id'] = '询价单详情id必填';
|
||
}
|
||
if(!isset($detail['contact_name']) || !$detail['contact_name']){
|
||
$isSuccess = false;
|
||
$errors[$index]['contact_name'] = '联系人必填';
|
||
}
|
||
if(!isset($detail['contact_phone']) || !$detail['contact_phone']){
|
||
$isSuccess = false;
|
||
$errors[$index]['contact_phone'] = '联系人电话必填';
|
||
}
|
||
if(!isset($detail['area']) || !$detail['area']){
|
||
$isSuccess = false;
|
||
$errors[$index]['area'] = '小片区必填';
|
||
}
|
||
}
|
||
return $this->verifyResult($isSuccess,$errors);
|
||
}
|
||
|
||
/**
|
||
* 指派
|
||
*
|
||
* @param $assignerId
|
||
* @param array $data
|
||
* @return mixed
|
||
* @throws LogicException
|
||
*/
|
||
public function assign($assignerId,array $data)
|
||
{
|
||
//todo 检查assignerId权限
|
||
$verifyResult = $this->checkSurveyIds($data['survey_ids']);
|
||
if ($verifyResult['is_success'] !== true)
|
||
throw new LogicException('参数验证失败',500,$verifyResult['errors']);
|
||
return DB::transaction(function ()use ($assignerId,$data){
|
||
//todo 检查查勘员信息
|
||
$user = $data['user_id'];
|
||
//survey
|
||
if (!Survey::where([['id','in',$data['survey_ids']]])->update([
|
||
'user_id' => $data['user_id'],
|
||
'user_name' => '',
|
||
'assignee_id' => $assignerId,
|
||
'assign_time' => date('Y-m-d H:i:s'),
|
||
'status' => Survey::STATUS_ASSIGNED,
|
||
]))
|
||
throw new \Exception('指派失败');
|
||
//survey_detail todo 这里user_id是否有利用价值待观察
|
||
if (!SurveyDetail::where([['survey_id','in',$data['survey_ids']]])->update([
|
||
'user_id' => $data['user_id']
|
||
]))
|
||
throw new \Exception('指派失败.');
|
||
return true;
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 检查所有物业是否都可以指派
|
||
*
|
||
* @param array $surveyIds
|
||
* @return array
|
||
*/
|
||
public function checkSurveyIds(array $surveyIds)
|
||
{
|
||
$allExists = true;
|
||
$errors = [];
|
||
foreach ($surveyIds as $surveyId) {
|
||
$survey = new Survey();
|
||
$survey = $survey->find($surveyId);
|
||
if (!$survey){
|
||
$allExists = false;
|
||
$errors[$surveyId] = '查勘id:'.$surveyId.'不存在';
|
||
}elseif (!in_array($survey->status,[Survey::STATUS_ASKED,Survey::STATUS_RETURNED])){
|
||
$allExists = false;
|
||
$errors[$surveyId] = '物业:'.$survey->property_cert_info->property_full_name.'的查勘状态为:'.
|
||
Survey::STATUS_MAP[$survey->status].',暂无法指派';
|
||
}
|
||
}
|
||
return $this->verifyResult($allExists,$errors);
|
||
}
|
||
|
||
/**
|
||
* 退回到待派单状态
|
||
*
|
||
* @param $userId
|
||
* @param array $data
|
||
* @return mixed
|
||
* @throws LogicException
|
||
*/
|
||
public function return_survey_to_asked($userId,array $data)
|
||
{
|
||
//todo 检查userId权限
|
||
$survey = new Survey();
|
||
$inquiryModel = new Inquiry();
|
||
$survey = $survey->find($data['survey_id']);
|
||
if (!$survey)
|
||
return ['code' => -1 , 'message' => '该查勘信息不存在'];
|
||
if ($survey->status != Survey::STATUS_ASSIGNED)
|
||
return ['code' => -1 , 'message' => '该查勘目前状态为:'.Survey::STATUS_MAP[$survey->status].',暂无法退回'];
|
||
if($userId != $survey['user_id'])
|
||
return ['code' => -1 , 'message' => '当前物业已转派查勘员,无法操作'];
|
||
$survey->user_id = null;
|
||
$survey->user_name = "";
|
||
$survey->last_return_user_id = $userId;
|
||
$survey->last_return_username = '';
|
||
|
||
$survey->status = Survey::STATUS_ASKED;
|
||
$inquiryModel->where('order_no' , $survey['order_no'])->update(['status' => 3]);
|
||
PublicMessage($inquiryModel->where('order_no' , $survey['order_no'])->value('id'),4,8,$survey['property_cert_info_id']); // 消息推送
|
||
$survey->save();
|
||
return ['code' => 1];
|
||
}
|
||
|
||
/**
|
||
* 退回查勘
|
||
*
|
||
* @param $userId
|
||
* @param array $data
|
||
* @return mixed
|
||
* @throws LogicException
|
||
*/
|
||
public function return_survey($userId,array $data)
|
||
{
|
||
//todo 检查userId权限
|
||
$survey = new Survey();
|
||
$inquiryModel = new Inquiry();
|
||
$survey = $survey->find($data['survey_id']);
|
||
if (!$survey)
|
||
return ['code' => -1 , 'message' => '该查勘信息不存在'];
|
||
if ($survey->status != Survey::STATUS_ASSIGNED)
|
||
return ['code' => -1 , 'message' => '该查勘目前状态为:'.Survey::STATUS_MAP[$survey->status].',暂无法退回'];
|
||
if($userId != $survey['user_id'])
|
||
return ['code' => -1 , 'message' => '当前物业已转派查勘员,无法操作'];
|
||
$survey->user_id = null;
|
||
$survey->user_name = "";
|
||
$survey->last_return_user_id = $userId;
|
||
$survey->last_return_username = '';
|
||
$survey->return_reason = $data['return_reason'];
|
||
$survey->status = Survey::STATUS_RETURNED;
|
||
$inquiryModel->where('order_no' , $survey['order_no'])->update(['status' => Inquiry::STATUS_CANCELED]);
|
||
//PublicMessage($inquiryModel->where('order_no' , $survey['order_no'])->value('id'),4,8,$survey['property_cert_info_id']); // 消息推送
|
||
$survey->save();
|
||
return ['code' => 1];
|
||
}
|
||
|
||
/**
|
||
* 保存查勘内容
|
||
*
|
||
* @param $userId
|
||
* @param array $data
|
||
* @param int $type 1查勘时新增 2报告时编辑 3.查勘完成时编辑
|
||
* @param string $user_name 查勘员名称(报告时编辑需传参)
|
||
* @param date $complete_time 查勘完成时间(报告时编辑需传参)
|
||
* @return bool
|
||
*/
|
||
public function survey_detail($userId,$data, $type = 1, $user_name = '', $complete_time = ''){
|
||
$surveyModel = new Survey();
|
||
$inquiryModel = new Inquiry();
|
||
$detail=new SurveyDetail();
|
||
$survey = $surveyModel->where('id',$data['survey_id'])->find();
|
||
// $detail = $detail->where('survey_id',$data['survey_id'])->find();
|
||
|
||
if (!$survey)
|
||
return ['code' => -1, 'message' => '该查勘信息不存在'];
|
||
if ($survey->status != Survey::STATUS_ASSIGNED && $type == 1)
|
||
return ['code' => -1, 'message' => '该查勘目前状态为:'.Survey::STATUS_MAP[$survey->status].',暂无法提交'];
|
||
|
||
if($userId != $survey['user_id'])
|
||
return ['code' => -1 , 'message' => '当前物业已转派查勘员,无法操作'];
|
||
|
||
$inquiry_status = $inquiryModel->where('order_no',$survey->order_no)->value('status');
|
||
if($inquiry_status > 5 && $type == 3)
|
||
return ['code' => -1, 'message' => '该订单已申请报告,暂无法编辑'];
|
||
|
||
$arr = [];
|
||
$arr['survey_id']=$data['survey_id'];
|
||
$arr['user_id']=$userId;
|
||
if ($type == 2) {
|
||
$surveyArray['user_id'] = $userId;
|
||
$surveyArray['user_name'] = $user_name;
|
||
$surveyArray['complete_time']=$complete_time;
|
||
|
||
$inquiryArray['survey_time']=$complete_time;
|
||
}
|
||
isset($data['adjacent_property']) && $arr['adjacent_property'] =$data['adjacent_property'];
|
||
isset($data['bus_lines']) && $arr['bus_lines'] =$data['bus_lines'];
|
||
isset($data['boundaries']) && $arr['boundaries'] =$data['boundaries'];
|
||
isset($data['pub_serv']) && $arr['pub_serv'] =$data['pub_serv'];
|
||
isset($data['scenery']) && $arr['scenery'] =$data['scenery'];
|
||
isset($data['property_intro']) && $arr['property_intro'] =$data['property_intro'];
|
||
isset($data['address']) && $arr['address'] =$data['address'];
|
||
isset($data['unit_type']) && $arr['unit_type'] =$data['unit_type'];
|
||
isset($data['towards']) && $arr['towards'] =$data['towards'];
|
||
isset($data['floor_no']) && $arr['floor_no'] =$data['floor_no'];
|
||
isset($data['total_floors']) && $arr['total_floors'] =$data['total_floors'];
|
||
isset($data['floor_height']) && $arr['floor_height'] =$data['floor_height'];
|
||
isset($data['elevator']) && $arr['elevator'] =$data['elevator'];
|
||
isset($data['parking_lot']) && $arr['parking_lot'] =$data['parking_lot'];
|
||
isset($data['parking_lot_usage']) && $arr['parking_lot_usage'] =$data['parking_lot_usage'];
|
||
isset($data['decoration']) && $arr['decoration'] =$data['decoration'];
|
||
isset($data['usage']) && $arr['usage'] =$data['usage'];
|
||
isset($data['property_mgm']) && $arr['property_mgm'] =$data['property_mgm'];
|
||
isset($data['newness_rate']) && $arr['newness_rate'] =$data['newness_rate'];
|
||
isset($data['structure']) && $arr['structure'] =$data['structure'];
|
||
// !empty($data['layout']) && $arrlayout =$data['layout'];
|
||
// !empty($data['greening']) && $arrgreen_environment =$data['greening'];
|
||
isset($data['exterior_view']) && $arr['exterior_view'] =$data['exterior_view'];
|
||
isset($data['exterior_view_img_ids']) && $arr['exterior_view_img_ids'] =$data['exterior_view_img_ids'];
|
||
isset($data['doorplate']) && $arr['doorplate'] =$data['doorplate'];
|
||
isset($data['doorplate_img_ids']) && $arr['doorplate_img_ids'] =$data['doorplate_img_ids'];
|
||
isset($data['living_room']) && $arr['living_room'] =$data['living_room'];
|
||
isset($data['living_room_img_ids']) && $arr['living_room_img_ids'] =$data['living_room_img_ids'];
|
||
isset($data['balcony']) && $arr['balcony'] =$data['balcony'];
|
||
isset($data['balcony_img_ids']) && $arr['balcony_img_ids'] =$data['balcony_img_ids'];
|
||
isset($data['kitchen']) && $arr['kitchen'] =$this->checkData($data['kitchen'],'kitchen');
|
||
isset($data['kitchen_img_ids']) && $arr['kitchen_img_ids'] =$data['kitchen_img_ids'];
|
||
isset($data['bedroom']) && $arr['bedroom'] =$data['bedroom'];
|
||
isset($data['bedroom_img_ids']) && $arr['bedroom_img_ids'] =$data['bedroom_img_ids'];
|
||
isset($data['bathroom']) && $arr['bathroom'] =$data['bathroom'];
|
||
isset($data['bathroom_img_ids']) && $arr['bathroom_img_ids'] =$data['bathroom_img_ids'];
|
||
isset($data['facility']) && $arr['facility'] =$data['facility'];
|
||
isset($data['facility_img_ids']) && $arr['facility_img_ids'] =$data['facility_img_ids'];
|
||
isset($data['other']) && $arr['other'] =$data['other'];
|
||
// !empty($data['others_img_ids']) && $arrother_imgs =$data['others_img_ids'];
|
||
isset($data['auto_loc_img_ids']) && $arr['auto_loc_img_ids'] =$data['auto_loc_img_ids'];
|
||
isset($data['loc_img_ids']) && $arr['loc_img_ids'] =$data['loc_img_ids'];
|
||
isset($data['prosperity_lv']) && $arr['prosperity_lv'] =$data['prosperity_lv'];
|
||
isset($data['business_district_lv']) && $arr['business_district_lv'] =$data['business_district_lv'];
|
||
isset($data['pub_fac']) && $arr['pub_fac'] =$data['pub_fac'];
|
||
isset($data['traffic']) && $arr['traffic'] =$data['traffic'];
|
||
isset($data['size']) && $arr['size'] =$data['size'];
|
||
isset($data['building_completion_time']) && $arr['building_completion_time'] =$data['building_completion_time'];
|
||
isset($data['podium_floor']) && $arr['podium_floor'] =$data['podium_floor'];
|
||
isset($data['business_content']) && $arr['business_content'] =$data['business_content'];
|
||
isset($data['property_form']) && $arr['property_form'] =$data['property_form'];
|
||
isset($data['commercial_positioning']) && $arr['commercial_positioning'] =$data['commercial_positioning'];
|
||
isset($data['shop_condition']) && $arr['shop_condition'] =$data['shop_condition'];
|
||
isset($data['parking_condition']) && $arr['parking_condition'] =$data['parking_condition'];
|
||
isset($data['usage_condition']) && $arr['usage_condition'] =$data['usage_condition'];
|
||
isset($data['exterior_wall']) && $arr['exterior_wall'] =$data['exterior_wall'];
|
||
isset($data['exterior_wall_img_ids']) && $arr['exterior_wall_img_ids'] =$data['exterior_wall_img_ids'];
|
||
isset($data['interior_wall']) && $arr['interior_wall'] =$data['interior_wall'];
|
||
isset($data['interior_wall_img_ids']) && $arr['interior_wall_img_ids'] =$data['interior_wall_img_ids'];
|
||
isset($data['door_window']) && $arr['door_window'] =$data['door_window'];
|
||
isset($data['door_window_img_ids']) && $arr['door_window_img_ids'] =$data['door_window_img_ids'];
|
||
isset($data['ground']) && $arr['ground'] =$data['ground'];
|
||
isset($data['ground_img_ids']) && $arr['ground_img_ids'] =$data['ground_img_ids'];
|
||
isset($data['ceiling']) && $arr['ceiling'] =$data['ceiling'];
|
||
isset($data['ceiling_img_ids']) && $arr['ceiling_img_ids'] =$data['ceiling_img_ids'];
|
||
isset($data['supplement_img_ids']) && $arr['supplement_img_ids'] =$data['supplement_img_ids'];
|
||
isset($data['elevator_apartment_count']) && $arr['elevator_apartment_count'] =$data['elevator_apartment_count'];
|
||
isset($data['loc_img_ids']) && $arr['loc_img_ids'] =$data['loc_img_ids'];
|
||
isset($data['house_type_img_ids']) && $arr['house_type_img_ids'] =$data['house_type_img_ids'];
|
||
isset($data['orientation_img_ids']) && $arr['orientation_img_ids'] =$data['orientation_img_ids'];
|
||
// !empty($data['survey_gallery']) && $arrsurvey_gallery =$data['survey_gallery'];
|
||
isset($data['street_view_img_ids']) && $arr['street_view_img_ids'] =$data['street_view_img_ids'];
|
||
isset($data['appraisal_img_ids']) && $arr['appraisal_img_ids'] =$data['appraisal_img_ids'];
|
||
// isset($data['special_remarks']) && $arr['special_remarks'] =$data['special_remarks'];
|
||
if (isset($data['special_remarks']) && !empty($data['special_remarks'])) {
|
||
$arr['special_remarks'] = $data['special_remarks'];
|
||
} else {
|
||
$arr['special_remarks'] = '';
|
||
}
|
||
isset($data['remarks']) && $arr['remarks'] =$data['remarks']; //备注//2020年5月24日14:54:42 cavan
|
||
if ($type == 1) {
|
||
$arr['submit_time']=date('Y-m-d H:i:s');//查勘完成时间
|
||
}
|
||
$arr['update_time']=date('Y-m-d H:i:s');
|
||
isset($arr['building_completion_time']) && $arr['building_completion_time'] == '' && $arr['building_completion_time'] = NULL;
|
||
empty($arr['exterior_view']) && $arr['exterior_view'] = null ;
|
||
empty($arr['doorplate']) && $arr['doorplate'] = null ;
|
||
$res= $detail->where('survey_id' , $data['survey_id']) ->update($arr);
|
||
if($res){
|
||
$surveyArray['id'] = $data['survey_id'];
|
||
$surveyArray['area'] = $data['area'];
|
||
$surveyArray['area_id'] = $data['area_id'];
|
||
$surveyArray['status'] = Survey::STATUS_COMPLETED;
|
||
if ($type == 1) {
|
||
$surveyArray['complete_time']=date('Y-m-d H:i:s');
|
||
}
|
||
$survey->update($surveyArray);
|
||
|
||
if(!empty($data['survey_type'])){
|
||
$surveyModel->where('id' , $data['survey_id'])->update(['survey_type' => $data['survey_type']]);
|
||
}
|
||
|
||
$inquiryArray['survey_user_id'] = $survey->user_id;
|
||
$inquiryArray['survey_user_name'] = $survey->user_name;
|
||
if ($type == 1) {
|
||
$inquiryArray['survey_time']=date('Y-m-d H:i:s');
|
||
}
|
||
Db::name('property_cert_info')->where('id',$survey->property_cert_info_id)->update($inquiryArray);
|
||
|
||
$survey_all = $survey->where('order_no' ,$survey->order_no)->where('status' , 'neq' , Survey::STATUS_COMPLETED)->find();
|
||
if(!$survey_all && $type == 1){
|
||
$res = $inquiryModel->where('order_no',$survey->order_no)->update(['status' => 5]);
|
||
}
|
||
|
||
if($type ==1){
|
||
PublicMessage($inquiryModel->where('order_no' , $survey->order_no)->value('id'),2,7,$survey->property_cert_info_id); // 消息推送
|
||
}
|
||
|
||
if($res!==false){
|
||
return ['code' =>1];
|
||
}else{
|
||
return ['code' =>1, 'message'=> '保存失败'];
|
||
}
|
||
}else{
|
||
return ['code' =>1, 'message'=> '保存失败'];
|
||
}
|
||
}
|
||
|
||
public function checkData($data,$key){
|
||
foreach ($data as $k => $v) {
|
||
if(!strstr($k,$key)){
|
||
unset($data[$k]);
|
||
}
|
||
}
|
||
// $data=json_encode($temp);
|
||
return $data;
|
||
}
|
||
} |