findOrEmpty(); $address = $property['address']; if(empty($property)){ throw new Exception('物业代理不存在'); } $order = PropertyOrder::where(['property_user_id'=>$propertyUserId,'property_head_id'=>$params['property_head_id'],'order_status'=>0,'work_id'=>0])->order('id desc')->findOrEmpty(); Log::info('物业ID'.$order); if($order->isEmpty()){ PropertyOrder::create([ 'property_head_id' => $params['property_head_id'], 'property_user_id' => $propertyUserId, 'remark' => $params['remark']??'', 'address' => $address??'', 'order_status' => 0, 'work_id' => 0, ]); } Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 添加 - 下物业单 * @param array $params * @return bool */ public static function add(array $params) { // 判断户主是否存在 返回户主id $propertyUserId = PropertyUserLogic::getPropertyUserIdByMobile($params); Db::startTrans(); try { $propertyAddress = PropertyHead::where('id',$params['property_head_id'])->value('address'); $address = $params['address']?(($propertyAddress?$propertyAddress.$params['address']:'')):''; $res = PropertyOrder::create([ 'property_head_id' => $params['property_head_id'], 'property_user_id' => $propertyUserId, 'remark' => $params['remark']??'', 'address' => $address??'', 'order_status' => isset($params['order_status'])?$params['order_status']:0, 'work_id' => isset($params['work_id'])?$params['work_id']:0, ]); Db::commit(); $propertyHeadInfo = PropertyHeadLogic::detail(['id'=>$params['property_head_id']]); $propertyUserInfo = PropertyUserLogic::detail(['id'=>$propertyUserId]); event('Notice', [ 'scene_id' => 125, 'params' => [ 'user_id' => 0, 'thing2' => $propertyHeadInfo['village_name'], 'thing8' => $propertyUserInfo['householder_name'], 'phone_number11' => asteriskString($propertyUserInfo['householder_mobile']), ] ]); return $res->id; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } }