Commit eb13b8dd authored by hujun's avatar hujun

异常捕获

parent 4fac74d6
......@@ -17,7 +17,7 @@ class VipService
/**
* 是否具有查看vip客户权限
*
* @param $id 经纪人ID
* @param $id //经纪人ID
* @param string $name
* @return int 是否可以查看vip客户 0:可查看 1:不可查看
*/
......
......@@ -24,17 +24,19 @@ use app\task\controller\ResultsSummaryNewTask;
class HouseService
{
protected $house;
protected $m_house;
protected $agent;
protected $agent_house;
protected $push;
protected $m_house_ext;
public function __construct()
{
$this->house = new GHouses();
$this->m_house = new GHouses();
$this->agent = new AAgents();
$this->agent_house = new GHousesToAgents();
$this->push = new PushMessageService();
$this->m_house_ext = new GHousesExt();
}
/**
......@@ -44,163 +46,165 @@ class HouseService
* @param int $agent_id
* @param int $is_app
* @return array
* @throws \think\exception\PDOException
*/
public function addHouse(array $data, int $agent_id, $is_app = 0): array
{
$result = [];
$result = [];
$validate = new HouseValidate();
if (empty($data['id'])) {
$check = $validate->scene('add')->check($data);
$check = $validate->scene('add')->check($data);
} else {
$check = $validate->scene('edit')->check($data);
$check = $validate->scene('edit')->check($data);
}
if (!$check) {
$result['status'] = 'fail';
$result['msg'] = $validate->getError();
$result['msg'] = $validate->getError();
return $result;
}
if (empty($agent_id)) {
$result['status'] = 'fail';
$result['msg'] = '上传人id为空';
$result['msg'] = '上传人id为空';
return $result;
}
if (!empty($data['id'])) {
$house_data = $this->house->getHouseInfo('id,internal_address,internal_title', ['id'=>$data['id']]);
if (empty($house_data[0]['id'])) {
$result['status'] = 'fail';
$result['msg'] = '没有该商铺信息';
return $result;
}
try {
if (!empty($data['id'])) {
$house_data = $this->m_house->getHouseInfo('id,internal_address,internal_title', ['id' => $data['id']]);
if (empty($house_data[0]['id'])) {
$result['status'] = 'fail';
$result['msg'] = '没有该商铺信息';
return $result;
}
$m_operating = new GOperatingRecords();
$remark = '修改为:剩余铺数'.$data['residue_num'];
if ($data['is_exclusive_type'] == 1) {
$remark .= ',独家有效期 '.$data['agent_start_time'].'—'.$data['agent_end_time'];
}
$m_operating = new GOperatingRecords();
$remark = '修改为:剩余铺数' . $data['residue_num'];
if ($data['is_exclusive_type'] == 1) {
$remark .= ',独家有效期 ' . $data['agent_start_time'] . '—' . $data['agent_end_time'];
}
if ($data['internal_title'] != $house_data[0]['internal_title']) {
$remark .= ',商铺名改为:'.$data['internal_title'];
}
if ($data['internal_title'] != $house_data[0]['internal_title']) {
$remark .= ',商铺名改为:' . $data['internal_title'];
}
if ($data['internal_address'] != $house_data[0]['internal_address']) {
$remark .= ',地址改为:'.$data['internal_address'];
}
$house_ext = new GHousesExt();
if ($data['internal_address'] != $house_data[0]['internal_address']) {
$remark .= ',地址改为:' . $data['internal_address'];
}
$house_data_ext = $house_ext->getInfo('landlord_phone', ['house_id'=>$data['id']]);
$house_data_ext = $this->m_house_ext->getInfo('landlord_phone', ['house_id' => $data['id']]);
if (!empty($house_data_ext['landlord_phone'])) {
$landlord_phone_arr = $landlord_phone_new_arr = $landlord_phone_old = [];
$landlord_phone = json_decode($house_data_ext['landlord_phone'], true);
if (!empty($house_data_ext['landlord_phone'])) {
$landlord_phone_arr = $landlord_phone_new_arr = $landlord_phone_old = [];
$landlord_phone = json_decode($house_data_ext['landlord_phone'], true);
if ($is_app == 1) {
$landlord_phone_new = json_decode($data['landlord_phone'], true);
} else {
$landlord_phone_new = $data['landlord_phone'];
}
if ($is_app == 1) {
$landlord_phone_new = json_decode($data['landlord_phone'], true);
} else {
$landlord_phone_new = $data['landlord_phone'];
}
foreach ($landlord_phone as $v) {
$landlord_phone_arr[] = $v['phone'];
}
foreach ($landlord_phone as $v) {
$landlord_phone_arr[] = $v['phone'];
}
foreach ($landlord_phone_new as $v2) {
$landlord_phone_new_arr[] = $v2['phone'];
}
foreach ($landlord_phone_new as $v2) {
$landlord_phone_new_arr[] = $v2['phone'];
}
foreach ($landlord_phone_arr as $v3) {
if (!empty($v3) && !in_array($v3, $landlord_phone_new_arr)) {
$landlord_phone_old[] = $v3;
foreach ($landlord_phone_arr as $v3) {
if (!empty($v3) && !in_array($v3, $landlord_phone_new_arr)) {
$landlord_phone_old[] = $v3;
}
}
}
if (!empty($landlord_phone_old)) {
$remark .= ',删除房东手机号:'. implode(',', $landlord_phone_old);
if (!empty($landlord_phone_old)) {
$remark .= ',删除房东手机号:' . implode(',', $landlord_phone_old);
}
}
}
$m_operating->record($agent_id, 6, $remark, $data['id']);
}
$m_operating->record($agent_id, 6, $remark, $data['id']);
}
$house_id = $this->house->addHouse($data, $agent_id);
$house_id = $this->m_house->addHouse($data, $agent_id);
if (empty($house_id)) {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑商铺失败';
return $result;
}
if (empty($house_id)) {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑商铺失败';
return $result;
}
$houses_ext = new GHousesExt();
$house_img = new GHousesImgs();
$house_img = new GHousesImgs();
//商铺扩展字段
$houses_ext->addHouseExt($data, $house_id, $is_app);
//商铺扩展字段
$this->m_house_ext->addHouseExt($data, $house_id, $is_app);
//商铺图片
if ($is_app == 1) {
$data['cover'] = json_decode($data['cover'], true);
$data['slide_show'] = json_decode($data['slide_show'], true);
$data['exclusive_img'] = json_decode($data['exclusive_img'], true);
}
//商铺图片
if ($is_app == 1) {
$data['cover'] = json_decode($data['cover'], true);
$data['slide_show'] = json_decode($data['slide_show'], true);
$data['exclusive_img'] = json_decode($data['exclusive_img'], true);
}
if ($data['id'] == '') {
$house_img->add($data, $house_id); //只记录新增图片
} else {
$image_result = $house_img->edit($data, $house_id); //编辑图片
if ($data['id'] == '') {
$house_img->add($data, $house_id); //只记录新增图片
} else {
$image_result = $house_img->edit($data, $house_id); //编辑图片
if ($image_result['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '编辑图片失败,' . $validate->getError();
return $result;
if ($image_result['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '编辑图片失败,' . $validate->getError();
return $result;
}
}
}
//案场权限人
if (isset($data['agent_data'])) {
$result_agent_data = $this->releaseRelationship($data['agent_data'], $house_id, 1, $agent_id, $data['internal_title']);
//案场权限人
if (isset($data['agent_data'])) {
$result_agent_data = $this->releaseRelationship($data['agent_data'], $house_id, 1, $agent_id, $data['internal_title']);
if ($result_agent_data['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑案场权限人失败,' . $result_agent_data['msg'];
return $result;
if ($result_agent_data['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑案场权限人失败,' . $result_agent_data['msg'];
return $result;
}
}
}
//盘方
if (isset($data['agent_dish'])) {
$result_agent_dish = $this->releaseRelationship($data['agent_dish'], $house_id, 2, $agent_id, $data['internal_title']);
if ($result_agent_dish['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑盘方失败,' . $result_agent_dish['msg'];
return $result;
//盘方
if (isset($data['agent_dish'])) {
$result_agent_dish = $this->releaseRelationship($data['agent_dish'], $house_id, 2, $agent_id, $data['internal_title']);
if ($result_agent_dish['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑盘方失败,' . $result_agent_dish['msg'];
return $result;
}
}
}
//独家方
if (isset($data['exclusive_ids'])) {
$result_exclusive_ids = $this->releaseRelationship($data['exclusive_ids'], $house_id, 3, $agent_id, $data['internal_title']);
if ($result_exclusive_ids['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑独家方失败,' . $result_exclusive_ids['msg'];
return $result;
//独家方
if (isset($data['exclusive_ids'])) {
$result_exclusive_ids = $this->releaseRelationship($data['exclusive_ids'], $house_id, 3, $agent_id, $data['internal_title']);
if ($result_exclusive_ids['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑独家方失败,' . $result_exclusive_ids['msg'];
return $result;
}
}
}
if (!empty($data['id'])) {
//剩余商铺为0下架
if (empty($data['residue_num']) || empty($data['total'])) {
$this->push->record(1, [ 0 => $house_id ], 0, $agent_id); //记录推送信息
if (!empty($data['id'])) {
//剩余商铺为0下架
if (empty($data['residue_num']) || empty($data['total'])) {
$this->push->record(1, [0 => $house_id], 0, $agent_id); //记录推送信息
}
}
}
$result['data']['house_id'] = $house_id;
$result['data']['internal_title'] = $data['internal_title'];
$result['status'] = 'successful';
$result['msg'] = '新增或编辑成功!';
$result['data']['house_id'] = $house_id;
$result['data']['internal_title'] = $data['internal_title'];
$result['status'] = 'successful';
$result['msg'] = '新增或编辑成功!';
} catch (\Exception $e) {
$result['status'] = 'fail';
$result['msg'] = '内部错误:' . $e->getMessage();
}
return $result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment