Example #1
0
 /**
  * 根据板块id获取精选房源,写房源日志
  *
  * @param int $brokerId
  * @param $oldAreaCode
  * @param $newAreaCode
  * @return array
  */
 public static function hzCommunityAreaChangeEx($brokerId, $oldAreaCode, $newAreaCode)
 {
     $newAreaInfo = Model_City_HzArea::getAreaByTypeCode($newAreaCode);
     $oldAreaInfo = Model_City_HzArea::getAreaByTypeCode($oldAreaCode);
     if (empty($newAreaInfo)) {
         return static::buildReturn(self::PROCESS_STATUS_ERROR, '好租区域板块变更,新的板块Id[' . $newAreaCode . ']映射不存在');
     }
     if (empty($oldAreaInfo)) {
         return static::buildReturn(self::PROCESS_STATUS_ERROR, '好租区域板块变更,旧的板块Id[' . $oldAreaCode . ']映射不存在');
     }
     $choicePlanList = Model_Plan_HzPlanBasic::getChoicePlanByBlockId($oldAreaInfo['cityId'], $oldAreaInfo['id']);
     if (empty($choicePlanList)) {
         return static::buildReturn(self::PROCESS_STATUS_SUCCESS, '好租区域板块变更,旧的板块Id[' . $newAreaCode . '],没有精选计划');
     }
     $choicePlanIdList = array();
     foreach ($choicePlanList as $choicePlanInfo) {
         $choicePlanIdList[] = $choicePlanInfo['id'];
     }
     $choicePlaningList = Model_Plan_HzPlanning::getPlanningByPlanIds($choicePlanIdList);
     if (empty($choicePlaningList)) {
         return static::buildReturn(self::PROCESS_STATUS_ERROR, sprintf('好租区域板块变更,没有获取到精选[%s]计划房源关系信息', implode(',', $choicePlanIdList)));
     }
     /** 写房源日志 */
     $remark = json_encode(array('remark' => '区域板块变更', 'newAreaCode' => $newAreaCode, 'oldAreaCode' => $oldAreaCode, 'newBlockId' => $newAreaInfo['id'], 'oldBlockId' => $oldAreaInfo['id']));
     $rtn = array();
     foreach ($choicePlaningList as $choicePlaningInfo) {
         $houseLog = array();
         $houseLog['houseId'] = $choicePlaningInfo['proid'];
         $houseLog['planId'] = 0;
         $houseLog['brokerId'] = $brokerId;
         $houseLog['cityId'] = $choicePlaningInfo['city_id'];
         $houseLog['type'] = Model_Log_HouseLogNew::TYPE_COMMUNITY_AREA_CHANGE_EX;
         $houseLog['changeType'] = Const_ProPlanChangeType::COMMUNITY_AREA_CHANGE_EX;
         $houseLog['remark'] = $remark;
         $houseLog['addDate'] = date('Y-m-d H:i:s');
         $houseLog['operatorId'] = 0;
         $houseLog['siteType'] = 2;
         if (!Model_Log_HouseLogNew::create($houseLog, date('Ymd'))->save()) {
             $rtn[] = sprintf('板块变更房源[%d]日志写入失败', $choicePlaningInfo['proid']);
             continue;
         }
         $rtn[] = sprintf('板块变更房源[%d]日志写入成功', $choicePlaningInfo['proid']);
     }
     return static::buildReturn(self::PROCESS_STATUS_SUCCESS, sprintf('好租区域板块变更,%s', implode(',', $rtn)));
 }