/** * 处理comms业务功能 * @param $action */ public static function dealActionComms($action) { $allResult = array(); //添加去重数组,为更新租房commid=0的数据做准备 $blockInfoArr = array(); foreach ($action['comms'] as $comm) { $blockInof = Bll_HzProp::getBlockByTypeCode($comm['new_block_code'], array(0, 1), true); // 判断小区solr是否ok $ajkBlock = Dao_Broker_HzProp::getAjkBlockInfo($comm['new_block_code']); if (!$ajkBlock) { return self::buildReturn(0, '二手房没有该板块:' . $comm['new_block_code']); } if (!Bll_HzProp::isCommSolrUpdated($ajkBlock['TypeId'], $ajkBlock['ParentId'], $blockInof['cityid'], $comm['community_id'], $comm['community_name'])) { return self::buildReturn(0, '租房小区solr还没更新完,动作id:' . $action['id'] . ' 小区id:' . $comm['community_id']); } if ($blockInof) { $result = Bll_HzProp::updatePropBlock($blockInof['id'], $blockInof['parentid'], $blockInof['cityid'], $comm['community_id']); if (!$result['status']) { // 更新动作表 if (!Bll_Cms_BlockChange::updateCommAction($comm['s_id'], $action['id'], 3, '处理失败')) { return self::buildReturn(0, '更新动作表失败,动作id:' . $action['id']); } return $result; } $allResult = array_merge($allResult, $result['msg']); } // 更新动作表 if (!Bll_Cms_BlockChange::updateCommAction($comm['s_id'], $action['id'], 1, '处理成功')) { return self::buildReturn(0, '更新动作表失败,动作id:' . $action['id']); } $temp = array(); $temp['new_code'] = $comm['new_block_code']; $temp['old_code'] = $comm['block_code']; $temp['city_id'] = $comm['city_id']; $blockInfoArr[$temp['old_code'] . '_' . $temp['new_code']] = $temp; } if (!empty($blockInfoArr)) { Bll_Cms_BlockChange::insertCommList($blockInfoArr); } return self::buildReturn(1, $allResult); }
/** * 根据条件获取板块 * @param $typeCode * @param int $typeFlag * @param bool $isInsert * @return array */ public static function getBlockByTypeCode($typeCode, $typeFlag = 1, $isInsert = false) { if (!$typeFlag) { $typeFlag = array(0, 1); } if (!is_array($typeFlag)) { $typeFlag = explode(',', $typeFlag); } $result = Dao_Broker_HzProp::getBlocks(array('where' => 'type_code=? and typeflag in (' . implode(',', $typeFlag) . ') ', 'params' => array($typeCode))); if ($isInsert && !$result) { //查不到好租新增的板块,手动增加,并返回新的板块ID和区域ID //获取ajk新板块信息 $ajkBlock = Dao_Broker_HzProp::getAjkBlockInfo($typeCode); if ($ajkBlock) { //获取新板块的区域ID $parentArea = Bll_HzProp::getAreaByAjkId($ajkBlock['ParentId']); $ajkBlock['ParentId'] = (int) $parentArea['id']; $newBlockId = Bll_HzProp::insertBlock($ajkBlock); return array('id' => $newBlockId, 'parentid' => $ajkBlock['ParentId'], 'cityid' => $ajkBlock['CityId']); } } return isset($result[0]) ? $result[0] : array(); }