public function createThreeSiteAccountMust($userId, $ajkBrokerId) { //查询三网mapping $objMapping = Model_Payment_AccountMapping::getAccountMappingByUserId($userId); if (!$objMapping || !$objMapping->accountidAjk || !$objMapping->accountidHz || !$objMapping->accountidJp) { //获取安居客账户 $objajkAccount = Model_Payment_AjkUserAccount::getAjkUserAccountByUserId($userId); if ($objajkAccount) { $ajkAccount = $objajkAccount->accountId; } else { $ajkAccount = $this->createAjkAccountId($userId); } //获取租房账户 $hzBrokerId = Model_Broker_HzMapping::get_hz_broker_id($ajkBrokerId); $objHzAccount = Model_Payment_HzUsersAccountMapping::getHzUserAccountByUserId($hzBrokerId); if ($objHzAccount) { $hzAccount = $objHzAccount->accountId; } else { $hzAccount = $this->createHzAccountId($hzBrokerId); } //获取金铺账户 $objJpMember = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($ajkBrokerId); $objJpAccount = Model_Payment_JpPayAccount::getAccountByBrokerId($objJpMember->id); if ($objJpAccount) { $jpAccount = $objJpAccount->account; } else { $jpAccount = $this->createJpAccountId($objJpMember->id); } //创建三网账号 $this->doCreateThreeSiteAccountMust($userId, $ajkAccount, $hzAccount, $jpAccount, $objMapping); } }
/** * @param AJKRequest $request * @param array $out * @throws Exception */ public static function initEnv($request, &$out) { $out['debug'] = isset($_GET['debug']) ? true : false; $out['cityId'] = $request->getBrokerCityId(); $out['ajkBrokerId'] = $request->getBrokerId(); $brokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerIdEx($out['ajkBrokerId']); if (empty($brokerInfo)) { throw new Exception('获取金铺经纪人信息失败:ajkBrokerId [' . $out['ajkBrokerId'] . ']'); } $out['brokerInfo'] = $brokerInfo; // 获取金铺brokerId $out['jpBrokerId'] = $brokerInfo['id']; // 是否精选 $out['isChoiceCity'] = Bll_City::isChoiceCity($out['cityId'], Const_Site::JINPU); $out['isBidCity'] = false; $out['isShowCaseCity'] = Bll_City::isShowCaseCity($out['cityId'], Const_Site::JINPU); $out['bidTip'] = '精选'; //经纪人全部有效房源 $out['houses'] = Bll_House_JpHouseInfo::getAllHouseInfoEx($out['ajkBrokerId']); $out['houseIds'] = array(); foreach ($out['houses'] as $infoP) { $base = $infoP['base']; $info = $infoP['info']; $type = $infoP['houseType']; $propertyId = in_array($type, array(1, 2)) ? $info['buildingId'] : $info['propertyId']; $out['houseIds'][$type][$base['id']] = array('houseId' => $base['id'], 'propertyId' => $propertyId); } $out['publishUrl'] = Bll_Broker_Combo_ManageJp::buildHousePublishUrl(); }
/** * init env * @param AJKRequest $request * @param $out * @throws Exception */ private static function initEnv($request, &$out) { $out['debug'] = isset($_GET['debug']) ? true : false; $out['cityId'] = $request->getBrokerCityId(); $out['ajkBrokerId'] = $request->getBrokerId(); $out['isComboBroker'] = Bll_Broker_HzBroker::isComboBroker($out['ajkBrokerId']); $route_matches = $request->get_router_matches(); $out['proId'] = trim($route_matches[2], "/ \t\n\r\v"); if (!$out['proId']) { throw new Exception('缺少房源Id参数'); } $jpMemberInfo = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($out['ajkBrokerId']); // 获取金铺brokerId $out['jpBrokerId'] = $jpMemberInfo->id; // 是否精选 $out['isChoiceCity'] = Bll_City::isChoiceCity($out['cityId'], Const_Site::JINPU); $out['isBidCity'] = Bll_City::isBidCity($out['cityId'], Const_Site::JINPU); if ($out['isChoiceCity'] || $out['isBidCity']) { $out['bidTip'] = $out['isChoiceCity'] ? '精选' : '竞价'; $out['bidUrl'] = $out['isChoiceCity'] ? '/ajkbroker/user/choice/set/jp/' . $out['proId'] : '/jinpu/bid/new/' . $out['proId']; } $multicity = APF::get_instance()->get_config("cities", "multicity"); $out['cityName'] = $multicity[$out['cityId']]; // 获取经纪人信息 if (!($out['brokerInfo'] = Model_Broker_JpBroker::data_access()->filter('id', $jpMemberInfo->id)->get_row())) { throw new Exception('获取金铺经纪人信息失败:hzBrokerId [' . $out['hzBrokerId'] . ']'); } }
public function handle_request_internal() { /** * @var AJKRequest $request */ $request = APF::get_instance()->get_request(); $cityId = $request->getBrokerCityId(); $keyWord = $request->get_parameter('q'); $siteType = trim($request->get_parameter('site')); if (empty($keyWord)) { $this->response('error', array()); return; } if ($siteType == 'hz') { //$this->response('ok', Util_SearchUtil::getHzSearchCommunity($cityId, $keyWord)); // 走二手房小区solr $result = Util_SearchUtil::getSearchCommunity($cityId, $keyWord); $this->response('ok', $result ? $result : array()); } elseif ($siteType == 'jp') { $pb = trim($request->get_parameter('pb')); $cityId = BLL_House_JpHouseManage::getMemberCityId($cityId); $jpMember = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId(self::$intBrokerID); $this->response('ok', Util_SearchUtil::getJpSearchProperty($cityId, $keyWord, $pb, intval($jpMember->id))); } else { $this->response('ok', Util_SearchUtil::getSearchCommunity($cityId, $keyWord)); } }
/** * 根据金铺的BrokerId 获取 二手房的BrokerId * * @param int $jpBrokerId * @return int * @throws Exception */ public static function getAjkBrokerIdByJpBrokerId($jpBrokerId) { $brokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByPk($jpBrokerId); if (is_null($brokerInfo)) { throw new Exception(sprintf('没有获取到经纪人信息[%d]', $jpBrokerId)); } return intval($brokerInfo->ajkMemberId); }
public function handle_request() { if ($this->_brokerId == 0) { echo sprintf('Usage: launcher.php Monitor_JpHouseSpreadState --broker=[:number:] [--release=...]'), PHP_EOL; return; } $loadFields = array('id', 'cityId', 'ajkMemberId'); $brokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerIdEx($this->_brokerId, $loadFields); if (empty($brokerInfo)) { $this->logMsg(sprintf('没有获取到经纪人[%d]的金铺经纪人信息', $this->_brokerId)); return; } $this->logMsg(sprintf('经纪人[%d]的金铺经纪人信息: %s', $this->_brokerId, json_encode($brokerInfo))); $searchParams = array('fl' => 'id,is_auction,is_combo', 'q' => '*:*', 'version' => '2.2', 'indent' => 'on', 'rows' => 1000, 'wt' => 'json'); $fieldQuery = array('fq=' . urlencode(sprintf('list_time:[0 TO %d]', time())), 'fq=' . urlencode(sprintf('member_id:%d', $brokerInfo['id'])), 'fq=' . urlencode(sprintf('city_id:%d', $brokerInfo['cityId']))); $query = http_build_query($searchParams); $houseInInSolr = array(); /** 查询在Solr中的房源 */ foreach ($this->_hosts as $houseType => $host) { $url = $host . '?' . $query . '&' . implode('&', $fieldQuery); $this->logMsg('URL: ' . $url); $temp = $this->httpRequest($url); foreach ($temp as $tmp) { $tmp['houseType'] = $houseType; $houseInInSolr[$tmp['id']] = $tmp; } } /** 获取推广中的房源 */ $houseComboRelationList = Bll_Combo_HouseRelation::getHouseRelations($this->_brokerId, Bll_Combo_HouseRelation::SITE_TYPE_JP, 1); if (empty($houseInInSolr) && empty($houseComboRelationList)) { $this->logMsg(sprintf('经纪人[%d]没有在solr和在线的房源', $this->_brokerId)); return; } $comboSpreadHouseIds = array(); foreach ($houseComboRelationList as $houseComboRelation) { $comboSpreadHouseIds[] = $houseComboRelation['houseId']; } /** 判断solr中的房源是否都在套餐推广中 该下没下 */ foreach ($houseInInSolr as $houseId => $houseSpreadState) { if (!in_array($houseId, $comboSpreadHouseIds)) { $this->logMsg(sprintf('房源[%d]在solr中,但是不在套餐推广中', $houseId)); file_put_contents($this->_houseInSolrNotSpread, sprintf('%d-%d' . PHP_EOL, $houseId, $houseSpreadState['houseType']), FILE_APPEND); } } /** 判断套餐推广中的房源是否在solr中 该上没上 */ foreach ($comboSpreadHouseIds as $houseId) { if (!isset($houseInInSolr[$houseId])) { $this->logMsg(sprintf('房源[%d]在套餐推广中,但是不在solr中', $houseId)); file_put_contents($this->_comboSpreadHouseNotInSolr, $houseId . PHP_EOL, FILE_APPEND); } } }
public function DownHouse($brokerId = 0, $promitionHouseNum = 0) { $brokerId = intval($brokerId); $promitionHouseNum = intval($promitionHouseNum); if ($brokerId == 0 || $promitionHouseNum == 0) { return false; } //将二手房经纪人ID转成商业地产ID $jpBrokerInfoObj = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($brokerId); if (!$jpBrokerInfoObj || $jpBrokerInfoObj->id == 0) { return Util_GlobalFunc::buildReturn(0, "该经纪人:{$brokerId}没有找到"); } //获取这个经纪人的有效计划 $OnlinePlan = Model_Plan_Jp::getOnlinePlanByMemberId($jpBrokerInfoObj->id); if (!$OnlinePlan) { return Util_GlobalFunc::buildReturn(0, "该经纪人:{$brokerId}没有有效计划"); } $onlineplan = array(); foreach ($OnlinePlan as $plan) { $onlineplan[] = $plan->id; $isBidVersion[$plan->id]['bidVersion'] = $plan->bidVersion; } //获取这些有效计划下的房子 $houseIdx = Model_House_JpHouseIdx::getHouseInfoByFixPlanId($onlineplan); if (!$houseIdx) { return Util_GlobalFunc::buildReturn(0, "该经纪人:{$brokerId}有效计划下的房子"); } $housecount = count($houseIdx); echo '正在处理商业地产' . $brokerId . ',总推广房源数' . $housecount . ',api中允许推广数量' . $promitionHouseNum; $allReturn = array(); //和套餐的推广房源做比较,如果当前在线推广的房子大于套餐推广房子,则下房源将较早推广的房子下架 if ($housecount > $promitionHouseNum) { $offNum = $housecount - $promitionHouseNum; for ($i = $offNum; $i >= 1; $i--) { if (empty($houseIdx[$i])) { continue; } if ($houseIdx[$i]->bidSpreadId) { $resultBid = Bll_House_JpHouseInfo::removeBidHouseFromSpread($houseIdx[$i], $jpBrokerInfoObj->id, 1, false); if (!$resultBid['success']) { $allReturn[] = $resultBid['data']; } } $resultFix = Bll_House_JpHouseInfo::removeFixHouseFromSpread($houseIdx[$i], $jpBrokerInfoObj->id); if (!$resultFix['success']) { $allReturn[] = $resultFix['data']; } } } return Util_GlobalFunc::buildReturn(1, $allReturn); }
public static function propdata_out_fix($params) { //系统操作,需要移出计划中房源 $houseInfoObj = Model_House_JpHouseIdx::getPropInfoByPk($params['pro_id']); $return = array(); if ($houseInfoObj->fixSpreadId) { $fixPlanInfoObj = Model_Plan_Jp::getPlanInfoByPk($houseInfoObj->fixSpreadId); if (!$fixPlanInfoObj) { return array('status' => 1, 'msg' => array("定价计划" . $houseInfoObj->fixSpreadId . "信息为空")); } $jpBrokerInfoObj = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($params['broker_id']); $params['broker_id'] = $jpBrokerInfoObj->id; if ($params['broker_id'] != $fixPlanInfoObj->memberId) { return array('status' => 1, 'msg' => array("定价计划" . $houseInfoObj->fixSpreadId . "信息经纪人ID不同")); } //取消定价,更新数据 if ($houseInfoObj->bidSpreadId) { //todo 取消定价之前需要先取消竞价 } //更新房源信息 if (BLL_Fixedspread_StaticPlanUpDownSwicher::isOnline()) { $houseInfoObj->save(array('id' => $params['pro_id'], 'fixSpreadId' => 0)); } $return[] = "房源" . $params['pro_id'] . "fixSpreadId:N=>0"; $return[] = "房源" . $params['pro_id'] . ",fixSpreadId:" . $houseInfoObj->fixSpreadId . "=>0"; $return[] = "定价计划" . $houseInfoObj->fixSpreadId . ",status=" . $fixPlanInfoObj->status; //房源移出定价计划日志 $data = self::build_prop_log($params, 11, "房源移出定价组", 0); Model_Log_HouseLogNew::create($data, date('Ymd'))->save(); //房源在线 if ($fixPlanInfoObj->status == 2 && $fixPlanInfoObj->noBudgetDate < date("Ymd")) { $return[] = "status=2,no_budget_date=" . $fixPlanInfoObj->noBudgetDate . ",房源在线"; if (BLL_Fixedspread_StaticPlanUpDownSwicher::isOnline()) { //获取房源分表信息 $houseClass = Model_House_JpHouseIdx::getHouseTypeModelClass($houseInfoObj->houseType); $houseObj = $houseClass::getPropInfoByPk($params['pro_id']); //更新删除房源时间 $houseObj->isList = 0; $houseObj->save(); $all_return[] = "houseType:" . $houseInfoObj->houseType . ",isList:1=>0"; } //写入下线日志,并且更新数据 $data = self::build_prop_log($params, 6, "房源下线", 0); Model_Log_HouseLogNew::create($data, date('Ymd'))->save(); $return[] = "房源" . $params['pro_id'] . "下线日志写入"; } } return array('status' => 1, 'msg' => $return); }
private function jpAction($brokerId, $params) { $jpBrokerId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($brokerId)->id; $houseId = $params['propId']; $dateStr = $params['date']; $date = str_replace('.', '', $dateStr); //获取金铺精选点击明细 $getChoiceClickDetails = Model_Choice_JpPropClickDetails::getChoiceClickDetailsInfo($jpBrokerId, $houseId, $date); $result = array(); foreach ($getChoiceClickDetails as $click) { $result[] = date('H:i:s', $click['clickTime']); } echo json_encode($result); return false; }
public function handle_request_internal() { $request = APF::get_instance()->get_request(); $params = $request->get_parameters(); $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; if ($params['site'] == 'jp') { //金铺逻辑 $jpMember = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($brokerId); $jpMemberId = intval($jpMember->id); $this->response(BLL_House_JpProperty::getJpLibrary($params, $jpMemberId)); } elseif ($params['site'] == 'hz') { //租房逻辑 } else { //二手房房逻辑 } }
/** * 经纪人操作添加记录 */ public function logHouseOperation($houseId, $memberId, $title, $comment = '') { if (!empty($comment) && strlen($comment) > 2000) { $comment = substr($comment, 0, 2000); } $houseInfo = Model_House_JpHouseIdx::getPropInfoByPk($houseId); $DBmember = Model_Broker_JpBroker::getJpBrokerInfoByPk($memberId); $PLog = new Model_Log_JpHouseOperation(); $PLog->house_id = $houseId; $PLog->house_type = $houseInfo->houseType; $PLog->member_id = $memberId; $PLog->operator_id = $memberId; $PLog->operator_name = $DBmember->realName; $PLog->title = $title; $PLog->comment = $comment; $PLog->save(); }
/** * 金铺-精选房源设置 * * @param $ajkBrokerId * @param $cityId * @param $propId * @param array $params * @return array */ public static function jp_setting_post($ajkBrokerId, $cityId, $propId, $params = array()) { $jpBrokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($ajkBrokerId); //check房源是否已经加入精选推广 $bidObj = Model_Plan_Jp::getBidPlanByHouseIdEx($ajkBrokerId, $propId, true); if (!empty($bidObj)) { if ($bidObj['status'] == Model_Plan_Jp::ENUM_STATUS_ONLINE || $bidObj['status'] == Model_Plan_Jp::ENUM_STATUS_CHOICE_HOLD) { return array('err_no' => self::BID_HOUSE_ALREADY_IN_BID, 'err_msg' => '房源已经加入精选推广'); } elseif ($bidObj['status'] == Model_Plan_Jp::ENUM_STATUS_HOLD) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源正在结算中,请稍后...'); } } $bidChoiceCount = Model_Plan_Jp::getBidChoiceInfoEx($cityId, $ajkBrokerId); //获取精选推广预算 $brokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($ajkBrokerId); $brokerCompanyId = $brokerInfo['BaseInfo']['COMPANYID']; $choiceSet = APF::get_instance()->get_config('choice_set'); if (isset($choiceSet[$brokerCompanyId]) && !empty($choiceSet[$brokerCompanyId])) { $min_budget = $choiceSet[$brokerCompanyId]['jp']['JP_CHOICE_MIN_BUDGET']; $max_budget = $choiceSet[$brokerCompanyId]['jp']['JP_CHOICE_MAX_BUDGET']; } else { $min_budget = $choiceSet['default']['jp']['JP_CHOICE_MIN_BUDGET']; $max_budget = $choiceSet['default']['jp']['JP_CHOICE_MAX_BUDGET']; } if ($params['budget'] < $min_budget || $params['budget'] > $max_budget) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '推广预算最低' . $min_budget . '安币,最高' . $max_budget . '安币'); } $status = isset($bidObj['status']) ? $bidObj['status'] : 0; if (count($bidChoiceCount) >= self::ALL_JP_PLAN_NUM && $status != 4) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '精选推广房源已经超过' . self::ALL_JP_PLAN_NUM . '套'); } if (0 == $jpBrokerInfo) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '您不是金铺经纪人'); } /** 获取房源基本信息 */ $propInfo = Bll_House_JpHouseInfo::getHouseInfoById($propId); if (empty($propInfo)) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在'); } if ($propInfo['base']['memberId'] != $jpBrokerInfo['id']) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不属于该经纪人'); } /** 判断是否是精选开放城市 */ if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::JINPU)) { /** 判断房源是否在套餐推广 */ $propCombos = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($propId, Bll_Combo_HouseRelation::SITE_TYPE_JP); if (empty($propCombos)) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源必须在套餐推广才能参与精选'); } } if (false == $propInfo['info']['isExquisite']) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '精品、新发15天房源才能参与精选推广', 'params' => array('site' => 'jp')); } $limitDay = intval(date('Ymd', strtotime('-15 days'))); $postDay = intval(date('Ymd', strtotime($propInfo['base']['createTime']))); if ($limitDay > $postDay) { return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '精品、新发15天房源才能参与精选推广', 'params' => array('site' => 'jp')); } /** 获取板块信息 **/ $blockArr = Bll_House_JpHouseInfo::getBlock($propInfo['base']['houseType'], $propInfo['info']); if (!$blockArr['blockId'] && !$blockArr['newBlockId']) { return array('err_no' => self::BID_HOUSE_ALREADY_IN_BID, 'err_msg' => '房源缺少板块信息'); } /** 获取价格信息 **/ $arrPrice = Bll_House_JpHouseInfo::getPrice($cityId, $propInfo['base']['houseType'], $propInfo['info']); if (empty($arrPrice['price_id'])) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '缺少价格段信息'); } /** 获取点击单价开始 */ try { $apiParams = array('brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'price' => $arrPrice['price'] ?: 0, 'blockId' => $blockArr['blockId'] ?: 0, 'newBlockId' => $blockArr['newBlockId'] ?: 0, 'houseType' => $propInfo['base']['houseType']); /** * @var Bll_Service_Client_HttpResponse $clickPrice */ for ($i = 0; $i < 3; $i++) { $clickPrice = Bll_Service_Choice::jpClickPrice($apiParams); if ($clickPrice->isSucceeded()) { break; } } if (!$clickPrice->isSucceeded() || $clickPrice['status'] == 'error') { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-1000)'); } if ($params['budget'] * 100 < $clickPrice['realTradeAmount']) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '推广预算不能小于点击单价'); } /** 点击单价不能小于当前系统内的单价 防止恶意操作 */ if ($params['price'] < $clickPrice['realTradeAmount'] / 100) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '点击单价错误'); } } catch (Exception $e) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-2000)'); } /** 防并发 */ if (false === self::rejectSameRequest(Bll_Plan_Bid_Choice::SITE_JP, $ajkBrokerId, $propId)) { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-906)'); } /** 往冻结队列里添加记录,获取request id*/ $bidFreezeOrder = new Bll_Plan_BidFreezeOrderNum(date('Y')); $ajk_user_id = Bll_Broker_MainBusiness::getDataByEsfId($ajkBrokerId)->memberId; $requestId = $bidFreezeOrder->getRequestId(Bll_Plan_BidFreezeOrderNum::JP, $ajk_user_id, date('Y'), 0, $propId); /** 冻结金额 **/ $freezeResult = self::bid_freeze($ajkBrokerId, $params['budget'] * 100, $requestId, sprintf('金铺精选房源冻结,房源ID是: %d', $propId), Const_PaymentApp::JP_CHOICE); /** 判断是否冻结成功 **/ $freezeResponse = $freezeResult->getResponse(); if (!$freezeResult->isSucceeded() || $freezeResponse['status'] == 'error') { return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => isset($freezeResult['info']) ? $freezeResult['info'] . "code:" . $freezeResult['code'] : '冻结金额失败'); } //检查是否有坑位 坑位+1 $bucketStatus = Model_Choice_JPBidBucket::incrementUsedNum($blockArr['blockId'], $blockArr['newBlockId'], $propInfo['base']['houseType'], $arrPrice['price_id']); if (!$bucketStatus) { return array('err_no' => self::BID_WAIT_FAIL, 'err_msg' => '精选推广已满,请稍后再试'); } /** 获取最小竞价单元的精选信息 **/ $bucketInfo = Model_Choice_JPBidBucket::getBucketInfo($blockArr['blockId'], $blockArr['newBlockId'], $propInfo['base']['houseType'], $arrPrice['price_id']); /** 根据最小竞价单位里面的房源数判断当前的房源应该是排队还是推广中 **/ /* if ($bucketInfo['usedNum'] > $bucketInfo['maxOnlineNum']) { $planStatus = Model_Plan_Jp::ENUM_STATUS_CHOICE_HOLD; } else { $planStatus = Model_Plan_Jp::ENUM_STATUS_ONLINE; } */ $planStatus = Model_Plan_Jp::ENUM_STATUS_CHOICE_HOLD; /** 如果计划已经存在删除该计划**/ if (isset($bidObj['status']) && $bidObj['status'] == 4) { Model_Plan_Jp::data_access()->set_field('isDelete', 1)->filter('id', $bidObj['id'])->update(); } /** 构造计划数据 创建计划**/ $planData = self::buildJpPlanData($cityId, $jpBrokerInfo['id'], $params['budget'], $freezeResult['data']['sn'], $propId, $blockArr['blockId'], $blockArr['newBlockId'], $arrPrice['price_id'], $propInfo['base']['houseType'], $planStatus); $planData['ajkBrokerId'] = $ajkBrokerId; $PlanObj = Model_Plan_Jp::create($planData); $PlanObj->save(); if (empty($PlanObj->id)) { /** 坑位-1 **/ Model_Choice_JPBidBucket::decrementUsedNum($blockArr['blockId'], $blockArr['newBlockId'], $propInfo['base']['houseType'], $arrPrice['price_id']); Model_Plan_Jp::data_access()->set_field('isDelete', 0)->filter('id', $bidObj['id'])->update(); return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '创建计划失败'); } /** 更新房源里面的竞价计划id **/ $propInfo['base']->bidSpreadId = $PlanObj->id; $propInfo['base']->save(); /** 更新房源分表信息 **/ //$propInfo['info']->isList = 1; $propInfo['info']->spreadOffer = $clickPrice['realTradeAmount']; $propInfo['info']->spreadOfferTime = time(); $propInfo['info']->save(); /** 构建精选动作处理数据 **/ $choiceData = self::buildJpChoiceData($ajkBrokerId, Model_Choice_ActionQueue::ENUM_BEGIN_BY_HAND, $PlanObj->id, '经纪人手动推广', $propId); /** 插入到精选动作处理队列表 **/ Model_Choice_ActionQueue::create($choiceData, date('m'))->save(); $bidFreezeOrder->updateRequestComplete($requestId, $freezeResult['data']['sn'], $PlanObj->id); if ($bucketInfo['usedNum'] > $bucketInfo['maxOnlineNum']) { $rank = $bucketInfo['usedNum'] - $bucketInfo['maxOnlineNum']; return array('err_no' => self::BID_WAIT_SUCCESS, 'err_msg' => '精选排队成功', 'rank' => $rank); } else { return array('err_no' => self::BID_SHOW_SUCCESS, 'err_msg' => '精选推广成功'); } }
public function getMemberBalance($memberId) { $memberInfo = Model_Broker_JpBroker::data_access()->filter('id', $memberId)->get_row(); if (intval($memberInfo['ajkMemberId']) > 0) { $ajkBrokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $memberInfo['ajkMemberId'])->get_row(); if (!empty($ajkBrokerInfo) && $ajkBrokerInfo['userId']) { $balanceInfo = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $ajkBrokerInfo['userId'])); if ($balanceInfo['status'] == 'error') { return -1; } return $balanceInfo['data']['balance']; } } return -1; }
public function checkInputValid($action) { switch ($action) { case 'deleteHouses': $jpBrokerId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($this->brokerId)->id; if (!$jpBrokerId) { $this->outPut(0, '金铺经纪人信息有误'); } if (empty($this->params['houseIds'])) { $this->outPut(0, '房源信息有误'); } $this->jpBrokerId = $jpBrokerId; break; case 'houseCombo': $jpBrokerId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($this->brokerId)->id; if (!$jpBrokerId) { $this->outPut(0, '金铺经纪人信息有误'); } //是否套餐经纪人 $broker_info = Dao_Broker_BrokerInfo::get_broker_base_info($this->brokerId); if ($broker_info['PAYTYPE'] != 9999) { $this->outPut(0, '经纪人信息有误'); } if (empty($this->params['houseIds'])) { $this->outPut(0, '房源信息有误'); } $this->jpBrokerId = $jpBrokerId; break; case 'cancelHouseCombo': $jpBrokerId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($this->brokerId)->id; if (!$jpBrokerId) { $this->outPut(0, '金铺经纪人信息有误'); } //是否套餐经纪人 $broker_info = Dao_Broker_BrokerInfo::get_broker_base_info($this->brokerId); if ($broker_info['PAYTYPE'] != 9999) { $this->outPut(0, '经纪人信息有误'); } if (empty($this->params['houseIds'])) { $this->outPut(0, '房源信息有误'); } $this->jpBrokerId = $jpBrokerId; break; case 'getPropTemplate': $jpBrokerId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($this->brokerId)->id; if (!$jpBrokerId) { $this->outPut(0, '金铺经纪人信息有误'); } $this->jpBrokerId = $jpBrokerId; break; case 'savePropTemplate': $jpBrokerId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($this->brokerId)->id; if (!$jpBrokerId) { $this->outPut(0, '金铺经纪人信息有误'); } if (!isset($this->params['type']) || !in_array($this->params['type'], array(1, 2, 3, 4))) { $this->outPut(0, '房源模板信息有误'); } if (!isset($this->params['title']) || empty($this->params['title']) || mb_strlen($this->params['title'], 'UTF-8') > 30) { $this->outPut(0, '房源模板标题不能超过30个字'); } if (!isset($this->params['content']) || empty($this->params['content'])) { $this->outPut(0, '房源模板内容不能为空'); } $templateContent = strip_tags($this->params['content']); if (empty($templateContent) || mb_strlen($templateContent, 'UTF-8') < 30) { $this->outPut(0, '房源模板内容不能小于30个字'); } $this->jpBrokerId = $jpBrokerId; break; case 'deletePropTemplate': $jpBrokerId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($this->brokerId)->id; if (!$jpBrokerId) { $this->outPut(0, '金铺经纪人信息有误'); } $this->jpBrokerId = $jpBrokerId; break; } }
protected static function init() { try { $idx = Model_House_JpHouseIdx::data_access()->find_by_pk(self::$houseId); self::$memberId = $idx->memberId; } catch (Exception $e) { self::$memberId = 0; $idx = null; } if (!$idx) { return false; } self::$houseType = $idx->houseType; self::$houseModelName = null; self::$houseImgModelName = NULL; self::get_houseModel(); $houseModel = self::$houseModelName; try { $house = $houseModel::data_access()->find_by_pk(self::$houseId); } catch (Exception $e) { } self::$officeExquisite = 0; self::$shopHighQuality = 0; self::$publishTime = 0; self::$spreadOffer = 0; self::$cityId = $idx->cityId; self::$houseUnitPrice = 0; self::$price_75 = null; self::$exquisiteScore = 0; if ($house) { self::$exquisiteScore = $house->exquisiteScore; if (self::$houseCategory == 'office') { self::$officeExquisite = $house->isExquisite; if (self::$houseType == Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_OFFICE_RENT) { self::$houseUnitPrice = $house->dailyRent; $midpricedata = self::get_midprice($house->buildingId); self::$price_75 = !is_null($midpricedata) ? $midpricedata->mid_price_office_rent : null; } else { self::$houseUnitPrice = $house->unitPrice; $midpricedata = self::get_midprice($house->buildingId); self::$price_75 = !is_null($midpricedata) ? $midpricedata->mid_price_office_sale : null; } } elseif (self::$houseCategory == 'shop') { self::$shopHighQuality = $house->isQuality; if (self::$houseType == Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_SHOP_RENT) { self::$houseUnitPrice = $house->dailyRent; $midpricedata = self::get_midprice($house->propertyId); self::$price_75 = !is_null($midpricedata) ? $midpricedata->mid_price_shop_rent : null; } else { self::$houseUnitPrice = $house->unitPrice; $midpricedata = self::get_midprice($house->propertyId); self::$price_75 = !is_null($midpricedata) ? $midpricedata->mid_price_shop_sale : null; } } if ($house->createTime) { self::$publishTime = $house->createTime; } if ($house->spreadOffer) { self::$spreadOffer = $house->spreadOffer; } } if ($idx->spreadId == 0) { self::$spreadType = 0; } else { try { $spread = Model_Plan_Jp::data_access()->find_by_pk($idx->spreadId); } catch (Exception $e) { } if ($spread) { self::$spreadType = $spread->type; } } $objMember = Model_Broker_JpBroker::data_access()->find_by_pk($idx->memberId, false); if ($objMember && $objMember->hasRecharged) { self::$memberType = 2; } return true; }
public static function checkList($list) { if (empty($list['planId'])) { return Bll_HzPropBll::build_return(0, array("planId 为空")); } if (empty($list['brokerId'])) { return Bll_HzPropBll::build_return(0, array("brokerId 为空")); } if (empty(Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($list['brokerId'])->id)) { return Bll_HzPropBll::build_return(0, array("获取金铺经纪人失败")); } return Bll_HzPropBll::build_return(1, array("success")); }
/** * 把房源从定价推广中移除 * @param $objHouse * @param int $p_intMemberId * @param $log_type:1,手动停止 2,房源过期 * @return mixed */ public static function removeFixHouseFromSpread($objHouse, $memberId = 0, $log_type = 1) { $arrResult = Bll_Plan_JpPlanManage::getInstance()->checkSpreadInfo($objHouse->fixSpreadId, $memberId); if (!$arrResult['success']) { return $arrResult; } $objSpread = $arrResult['data']; //更新计划内房源数 $objSpread->houseNum = $objSpread->houseNum - 1 > 0 ? $objSpread->houseNum - 1 : 0; $objSpread->save(); //添加统计和队列 if ($objSpread->status == Model_Plan_Jp::ENUM_STATUS_ONLINE) { $jpBrokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByPk($memberId); //写入定价上下架队列表 $ProPlanChangeApiBll = Bll_ProPlanChangeApiBll::get_instance(); $ProPlanChangeApiBll->insertProPlanChange(array('broker_id' => $jpBrokerInfo->ajkMemberId, 'pro_id' => $objHouse->id, 'plan_id' => $objSpread->id, 'type' => 'pro_del_from_plan', 'from' => 'jp_' . __FUNCTION__, 'remark' => json_encode(array('is_house_online' => $objSpread->status == 2, 'no_budget_date' => $objSpread->noBudgetDate)), 'site_type' => 3), $jpBrokerInfo->ajkMemberId); //下架房源 self::updateHouseIsList($objHouse->id, $objHouse->houseType, 0); //记录房源操作 $intTitle = Const_CrmHouseLog::V_OPERATION_TITLE_OUT_SHELVES; $intComment = Const_CrmHouseLog::V_OPERATION_COMMENT_HOUSE_SPREAD_OFFLINE; Bll_Log_JpHouse::getInstance()->logHouseOperation($objHouse->id, $objHouse->memberId, $intTitle, $intComment); //记录日志 Bll_Log_JpPlan::getInstance()->writeSpreadHouseLog(1, $objHouse->id, $objHouse->fixSpreadId, 2); //更新solr Bll_House_JpHouseInfo::updateHouseToSolr(1, $objHouse->id, 1); //TO 初始化房源统计日志 Bll_House_JpBwAnalysis::getInstance()->openSaveBluewhaleHouse($objHouse->id, date('Y-m-d'), $objHouse->fixSpreadId, $objSpread->type); //定价房源下线日志 if ($log_type == 1) { $house_log = Model_Log_JpHouseUpDown::ENUM_BID_MEMBER_HOUSE_STOP; } elseif ($log_type == 2) { $house_log = Model_Log_JpHouseUpDown::ENUM_JOB_HOUSE_EXPIRE; } Bll_Log_JpHouse::getInstance()->writeHouseLog($objHouse->id, $objHouse->fixSpreadId, 0, $objHouse->memberId, $house_log); } else { Bll_Log_JpPlan::getInstance()->writeSpreadHouseLog(0, $objHouse->id, $objHouse->fixSpreadId, 2); } //解除定价推广 $objHouse->fixSpreadId = 0; $objHouse->save(); return array('success' => true, 'data' => '操作成功'); }
public static function JpBidEffectRank($bidPlanIds, $ajkBrokerId) { if (empty($p_arrSpreadIDs)) { return array(); } $arrRtn = $arrSpreadIDs = array(); $objRankBll = BLL_Spread_SpreadRankBLL::get_instance(); $objHp = new BLL_Spread_HpManage(); $objClickBll = Bll_Pay_ClickLogBll::get_instance(); $jpMemberId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($ajkBrokerId); $memberId = $jpMemberId->id; //取计划信息 $objModelSp = Model_Plan_Jp::data_access(); $objSpreads = $objModelSp->find_by_pks($bidPlanIds); if (!empty($objSpreads)) { foreach ($objSpreads as $objSp) { //要返回的数据 $arrRtnEle = array('hid' => $objSp->house_id, 'spreadid' => $objSp->id, 'rank' => 0, 'click' => 0, 'cost' => 0, 'is_stop' => 0); $arrSpreadIDs[] = $objSp->id; //已经暂停的计划 if ($objSp->status == 4) { $arrRtnEle['is_stop'] = 1; } elseif ($objSp->status == 3) { $arrRtnEle['is_stop'] = -1; } //依据计划id获取 try { $objModelH = Model_House_JpHouseIdx::data_access(); $objHouse = $objModelH->filter('member_id', $memberId)->filter('bid_spread_id', $objSp->id)->find_only(); unset($objModelH); } catch (Exception $e) { $objHouse = null; } //若不在计划中,按房源id获取 if (empty($objHouse) && $objSp->house_id) { try { $objModelH = Model_House_JpHouseIdx::data_access(); $objHouse = $objModelH->find_by_pk($objSp->house_id); unset($objModelH); } catch (Exception $e) { $objHouse = null; } } else { $arrRtnEle['hid'] = $objHouse->id; } //根据房源信息获取竞价中房源的排名 if (!empty($objHouse) && $objHouse->bidSpreadId) { $objHouseInfo = Bll_House_JpHouseInfo::getHouseInfoById($objHouse->id); $arrRtnEle['rank'] = Bll_Plan_JpRank::getRankingByHouse($objHouse->id, $objHouseInfo['info']->spreadOffer, $objHouse->houseType, false, 'rank_show'); if (!$arrRtnEle['rank'] && $objHouse->bidSpreadId) { $arrRtnEle['rank'] = Bll_Plan_JpRank::getRankingByHouse($objHouse->id, $objHouseInfo['info']->spreadOffer, $objHouse->houseType, false, 'rank_pre'); } } //根据房源ID获取竞价计划的今日点击 $arrRtnEle['click'] = 0; if (!empty($objHouse)) { $arrClick_t = $objClickBll->get_today_click_info_by_house($objHouse->id, 2, date("Ymd")); //当日数据 $arrRtnEle['click'] = $arrClick_t; } $arrRtn[] = $arrRtnEle; } //根据计划ID获取竞价中计划的总花费 if (!empty($arrSpreadIDs)) { $arrPayLog = $objHp->getPayLogBySpreadIDs($arrSpreadIDs); foreach ($arrRtn as $key => $arrData) { if (isset($arrPayLog[$arrData['spreadid']])) { $arrData['cost'] = $arrPayLog[$arrData['spreadid']]['cost_sum']; } else { $arrData['cost'] = 0; } $arrRtn[$key] = $arrData; } } } return $arrRtn; }
public function dealTask($solrOnProId) { $houseInfo = Model_House_JpHouseIdx::data_access()->filter('id', $solrOnProId)->get_row(); $brokerInfo = Model_Broker_JpBroker::data_access()->filter('id', $houseInfo['memberId'])->get_row(); if ($houseInfo['isDelete'] == 1) { if ($this->dealFlag) { $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2); $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message'])); } $this->setLog(sprintf('房源 %s 已经删除, 需要通知solr下' . PHP_EOL, $solrOnProId)); return true; } //查询城市配置信息 $ComboConfig = DAO_My_ComboConfig::getComboConfigByCityId($houseInfo['cityId']); if ($ComboConfig && $ComboConfig['type'] == 0) { //套餐城市 if (!Bll_Combo_HouseRelation::getOnlineRelationByHouseId($solrOnProId, Bll_Combo_HouseRelation::SITE_TYPE_JP)) { if ($this->dealFlag) { $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2); $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message'])); } $this->setLog(sprintf('房源 %s 不在套餐推广中, 需要通知solr下' . PHP_EOL, $solrOnProId)); return true; } return true; } else { //ppc城市 if ($houseInfo['spreadId'] != 0) { $spreadInfo = Model_Plan_Jp::data_access()->filter('id', $houseInfo['spreadId'])->filter('type', Model_Plan_Jp::ENUM_TYPE_FIX)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->get_row(); if ($spreadInfo && $spreadInfo['status'] == 2) { return true; } } if ($this->dealFlag) { $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2); $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message'])); } $this->setLog(sprintf('房源 %s 不在定价推广中, 需要通知solr下' . PHP_EOL, $solrOnProId)); return true; } }
public static function broker_restitution($params) { $all_return[] = "队列(" . $params['id'] . ")开始处理"; $all_return[] = '金铺系统返还'; //todo 查询用户所有定价计划,开启计划,上线房源 $ajk_broker_id = $params['broker_id']; //获取金铺经纪人broker_id $jpBrokerInfoObj = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($params['broker_id']); $params['broker_id'] = $jpBrokerInfoObj->id; //获取由于余额用完停止的计划 $fixInfoObjs = Model_Plan_Jp::getNoBalancePlan($params['broker_id']); foreach ($fixInfoObjs as $fixInfoObj) { $plan_log = array(); $plan_log['id'] = $params['id']; $plan_log['plan_id'] = $fixInfoObj->id; $plan_log['broker_id'] = $ajk_broker_id; $plan_log['city_id'] = $fixInfoObj->cityId; $plan_log['type'] = $params['type']; $plan_log = Bll_JpFixPlanBll::build_plan_log($plan_log, 8, "系统返还", 0); //写计划日志 if (!Model_House_UpDown_PlanLog::create($plan_log, date('m'))->save()) { $all_return[] = "计划" . $plan_log['planId'] . "房源推广日志写入失败"; } else { $all_return[] = "计划" . $plan_log['planId'] . "房源推广日志写入成功"; } //计划开启 $fixInfoObj->status = 2; $fixInfoObj->stopReason = 0; if (!$fixInfoObj->save()) { return array('status' => 0, 'msg' => array("定价计划" . $plan_log['planId'] . ",更新失败")); } //获取房源列表 $houseInfoObjs = Model_House_JpHouseIdx::getHouseInfoByFixPlanId($plan_log['planId']); if ($houseInfoObjs) { foreach ($houseInfoObjs as $houseInfoObj) { $prop_log['id'] = $params['id']; $prop_log['pro_id'] = $houseInfoObj->id; $prop_log['plan_id'] = $plan_log['planId']; $prop_log['broker_id'] = $ajk_broker_id; $prop_log['city_id'] = $houseInfoObj->cityId; $prop_log['type'] = $params['type']; $prop_log = Bll_JpPropBll::build_prop_log($prop_log, 5, "系统返还", 0); //写房源日志 if (!Model_Log_HouseLogNew::create($prop_log, date('Ymd'))->save()) { $all_return[] = "房源" . $houseInfoObj->id . "系统返还后房源推广日志写入失败"; } else { $all_return[] = "房源" . $houseInfoObj->id . "系统返还后房源推广日志写入成功"; } //获取房源分表信息 $houseClass = Model_House_JpHouseIdx::getHouseTypeModelClass($houseInfoObj->houseType); $houseObj = $houseClass::getPropInfoByPk($houseInfoObj->id); //更新展示房源状态 $houseObj->isList = 1; if ($houseObj->save()) { $all_return[] = "houseType=" . $houseInfoObj->houseType . ",更新分表isList=1成功"; } else { $all_return[] = "houseType=" . $houseInfoObj->houseType . ",更新分表isList=1失败"; } } } } return Bll_JpPropBll::build_return(1, $all_return); }
/** * @param $request object * @param $brokerInfo array * @param $type string rent || sale * @return array */ public static function getShopBeforePost($request, $brokerInfo, $type) { $out = $logGiveArr = array(); $params = $request->get_parameters(); // manager_id不为空,说明是伪登录 $out['managerId'] = $request->get_cookie('manager_id'); // 经纪人信息 $out['brokerInfo'] = $brokerInfo; $cityId = $brokerInfo['CITYID']; //金铺城市ID转换 $jpCityId = $out['brokerInfo']['jpCityId'] = BLL_House_JpHouseManage::getMemberCityId($cityId); $out['ajkBrokerId'] = $out['brokerInfo']['BROKERID']; $jpMember = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($out['ajkBrokerId']); $out['brokerInfo']['jpMemberId'] = intval($jpMember->id); //获取城市配置信息是否是精选推广 $out['isChoiceCity'] = Bll_City::isChoiceCity($jpCityId, Const_Site::JINPU); $out['bidTip'] = $out['isChoiceCity'] ? '精选' : '竞价'; //是否套餐经纪人 $out['isCombo'] = $brokerInfo['PAYTYPE'] == 9999 ? 1 : 0; //套餐城市是否显示推广按钮,以及提示 $out['spreadFlagInfo'] = array('spreadFlag' => 1, 'info' => ''); if ($out['isCombo']) { $comboCheck = Bll_Combo_HouseRelation::housePublishComboCheck($out['ajkBrokerId'], $cityId, Bll_Combo_HouseRelation::SITE_TYPE_JP); if ($comboCheck['status'] != 1) { $out['spreadFlagInfo'] = array('spreadFlag' => 0, 'info' => $comboCheck['msg']); } } // 获取全部图片分类信息(用于编辑时候默认展示分类情况) $arrCategory = array(); $arrAllCates = Model_Image_Category::get_img_cates_by_type('shop'); $arrCategory['all'] = $arrAllCates; $arrCategory['classify'] = array_fill_keys(array_keys($arrAllCates), 0); $out['arrCategory'] = $arrCategory; // 描述引导 $out['descGuide'] = self::getShopDescGuideTitle($type); //编辑图片,用于展示退回照片模块 $out['editPic'] = $params['edit_pic']; //北上广深 四城市 $citySpecial = array('13', '14'); $out['priceType'] = in_array($jpCityId, $citySpecial) ? 1 : 0; $out['isPost'] = $request->is_post_method(); if ($type == 'rent') { //交租方式 $out['rentModeFirst'] = Model_House_JpShopRent::getRentModeFirst(); $out['rentModeSecond'] = Model_House_JpShopRent::getRentModeSecond(); } //---------是否编辑---------------// $shopInfo = array(); $shopId = 0; $propertyId = 0; // 初始化参数 $matches = $request->get_router_matches(); if (isset($matches[2]) && !empty($matches[2])) { $shopId = intval($matches[2]); $shopInfo = $type == 'rent' ? Model_House_JpShopRent::getPropInfoById($shopId) : Model_House_JpShopSale::getPropInfoById($shopId); $propertyId = $shopInfo['propertyId']; } $out['isEdit'] = empty($shopInfo) ? 0 : 1; //四选一弹层 $out['bolFlag'] = $out['isEdit'] || !isset($params['from']) ? 0 : 1; $out['shopInfo'] = $shopInfo; $out['shopId'] = $shopId; if (!$out['isCombo']) { $planInfo = BLL_House_JpHouseManage::getFixPlanInfo($shopId); if ($out['isEdit'] && $planInfo['success'] && $planInfo['data']['status'] == 3) { //定价计划状态为3,不可编辑 return array('status' => 'error', 'errCode' => Const_PublishCode::UNKNOWN_ERROR); } } //新发,需要验证房源发布套数限制 if (!$out['isEdit']) { if (BLL_House_JpHouseManage::houseNumLimit($out['brokerInfo']['jpMemberId'], $out['ajkBrokerId'], true)) { //保存漏斗日志 if ($out['isPost']) { $houseType = Bll_Loudou_Log::jinpuHouseType('shop', $type); $str = ''; switch ($params['goto_next_step']) { case 'planCombo': case 'planFix': $str = Bll_Loudou_Log::RESULT_TYPE_FIX_FAILED_OTHERS; break; case 'justSaveHouse': $str = Bll_Loudou_Log::RESULT_TYPE_SAVE_FAILED_HOUSE_MAX_LIMIT; break; } $logGiveArr[] = array('func' => array('Bll_Loudou_log', 'add'), 'params' => array($houseType, $str, Bll_Loudou_Log::SOURCE_TYPE_FORM)); } return array('status' => 'error', 'errCode' => Const_PublishCode::PUBLISH_OUT_OF_LIMIT); } } //经营信息模块的配置信息 list($out['enumShopType'], $out['enumShopMatching'], $out['enumShopIndustry'], $out['enumShopIndustryLimit'], $out['enumShopPassengerType']) = BLL_House_JpProperty::getShopEnum(); //页面精品房源url $out['exquisiteUrl'] = BLL_Plan_JpPlanUrl::buildHelpUrl('1026'); //页面经典范例url $out['exampleTitleUrl'] = BLL_Plan_JpPlanUrl::buildHelpUrl('1044'); //页面房源描述下方经典范例url $out['exampleDescUrl'] = BLL_Plan_JpPlanUrl::buildHelpUrl('1045'); //房源发布协议url $out['contractUrl'] = BLL_Plan_JpPlanUrl::buildHelpUrl('554'); //房源PPC价格段信息 $out['ppcInfo'] = Bll_Plan_JpPlanManage::getInstance()->getPPCPrice($jpCityId, $type == 'rent' ? 3 : 4); //城市区域列表,选择区域使用 $out['districts'] = Model_Jinpu_District::getCityDistricts($jpCityId); //经纪人定价推广组信息 $out['fixPlanInfo'] = $out['isCombo'] ? array() : Bll_Plan_JpPlanManage::getInstance()->getBrokerFixPlans($out['brokerInfo']['jpMemberId']); if ($out['isEdit']) { //编辑状态下的特殊信息 //编辑 验证房源是否属于经纪人 if ($out['brokerInfo']['jpMemberId'] != $out['shopInfo']['memberId']) { return array('status' => 'error', 'errCode' => Const_PublishCode::NOT_OWN_HOUSE); } //房源交租方式(付一押一) list($out['rentModelFirst'], $out['rentModelSecond']) = explode(',', $shopInfo['rentMode']); //单层 多层 独栋 $out['floorType'] = 1; if ($shopInfo['isFullFloor']) { $out['floorType'] = 3; } elseif ($shopInfo['upFloor']) { $out['floorType'] = 2; } //房源推广信息,被编辑的房源是否在推广中 $houseCanSpread = 1; if ($out['isCombo']) { $houseCombo = Model_Combo_HouseRelation::getOnlineHousebyHouseId($out['ajkBrokerId'], $shopId, $cityId, Model_Combo_HouseRelation::SITE_TYPE_JP); if (!empty($houseCombo)) { $houseCanSpread = 0; } } else { $shopIdx = Model_House_JpHouseIdx::data_access()->filter('id', $shopId)->get_row(); if (!empty($shopIdx['fixSpreadId'])) { $houseCanSpread = 0; } } $out['houseCanSpread'] = $houseCanSpread; //图片退回信息 $out['backRows'] = array(); if ($shopId && $out['isEdit']) { $out['backRows'] = Bll_Image_JpHouseImage::getBackRows($shopId, $type == 'rent' ? 3 : 4); } //房源描述 $desc = $type == 'rent' ? Model_Jinpu_ShopRentDesc::getByPk($shopId) : Model_Jinpu_ShopSaleDesc::getByPk($shopId); $out['shopDesc'] = $desc['desc']; //房源物业信息 $out['propertyData'] = $propertyData = (array) BLL_House_JpProperty::getProperty($shopInfo['propertyId']); if (!$propertyData) { return array('status' => 'error', 'errCode' => Const_PublishCode::NOT_OWN_HOUSE); } if ($propertyData['isRoad'] == 1 && ($shopInfo['districtId'] || !$shopInfo['blockId'])) { $out['forceBlockEdit'] = true; } elseif ($propertyData['isRoad'] == 0 && (!$propertyData['districtId'] || !$propertyData['blockId'])) { $out['forceBlockEdit'] = true; } if (!$out['forceBlockEdit']) { //逻辑好多啊 妹子的 $districtIdForSearch = !$propertyData['isRoad'] ? $propertyData['districtId'] : $shopInfo['districtId']; $blockIdForSearch = !$propertyData['isRoad'] ? $propertyData['blockId'] : $shopInfo['blockId']; $districtInfo = Model_Jinpu_District::data_access()->filter('id', $districtIdForSearch)->get_row(); $districtName = $districtInfo['is_actived'] == 1 ? $districtInfo['name'] : ''; $blockInfo = Model_Jinpu_Block::data_access()->filter('id', $blockIdForSearch)->get_row(); $blockName = $blockInfo['isActived'] == 1 ? $blockInfo['name'] : ''; $titleStr = $districtName . ' ' . $blockName . ' ' . (!$propertyData['isRoad'] ? $propertyData['address'] : '') . (!empty($shopInfo['closeRoad']) ? '靠近:' . $shopInfo['closeRoad'] : ''); $showStr = strlen($titleStr) > 90 ? Util_GlobalFunc::cutchar($titleStr, 28) : $titleStr; $out['titleStr'] = $titleStr; $out['showStr'] = $showStr; } $out['hasLibrary'] = BLL_House_JpProperty::hasLibrary($out['brokerInfo']['jpMemberId'], $shopInfo['propertyId'], 'property'); //房源图片查询和排序 $images = self::handleShopImages($shopId, $type); //个人图库图片是否被锁定 foreach ($images as $key => $imgVal) { $imgVal['isLock'] = 0; if ($imgVal && $imgVal['personalImgId']) { $personalImg = Model_Jinpu_PersonalGallery::getImgById($imgVal['personalImgId']); if ($personalImg && $personalImg->category) { $imgVal['isLock'] = 1; } } if ($imgVal['category'] && isset($out['arrCategory']['classify'][intval($imgVal['category'])])) { $out['arrCategory']['classify'][intval($imgVal['category'])] += 1; } $images[$key] = $imgVal; } $out['images'] = $images; } $lng = $lat = $mapDataFlag = 0; //地图标注商铺位置的逻辑 $DShopMap = Model_Jinpu_MapShop::getByPK($shopId); if (!empty($DShopMap)) { $lng = $DShopMap['lng']; $lat = $DShopMap['lat']; $mapDataFlag = 1; } else { if ($propertyId > 0) { $shopLocation = Model_Jinpu_MapProperty::getPropertyMapById($propertyId); if (!empty($shopLocation)) { $lng = $shopLocation['lng']; $lat = $shopLocation['lat']; } } else { list($lng, $lat) = BLL_House_JpHouseManage::getDefaultMap($out['brokerInfo']['CITYID']); } $mapDataFlag = 0; } $out['lng'] = $lng; $out['lat'] = $lat; $out['mapDataFlag'] = $mapDataFlag; return array('status' => 'ok', 'info' => $out, 'logArr' => $logGiveArr); }
private function noticeComboSolr($memberId, $houseId, $houseType) { $brokerInfo = Model_Broker_JpBroker::getBrokerInfoById($memberId, array('cityId', 'ajkMemberId')); if (empty($brokerInfo)) { $this->logMsg(sprintf('获取经纪人[%d]信息失败[houseId - %d - %d]', $memberId, $houseId, $houseType)); return; } $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($brokerInfo['cityId'], $brokerInfo['ajkMemberId'], $houseId, $houseType, self::NOTICE_SOLR_ACTION, self::NOTICE_SOLR_FROM, time(), date('YmdHis') . $houseId); $this->logMsg(sprintf('通知房源[%d - %d]solr下架,result: %s', $houseId, $houseType, json_encode($result))); }
public static function getJpBrokerInfoByAjkBrokerId($ajkBrokerId) { $houseIdxObj = Model_Broker_JpBroker::data_access()->filter_by_op('ajkMemberId', '=', $ajkBrokerId)->filter_by_op('source', '=', 1)->find_only(); return $houseIdxObj; }
private function getBrokerList() { return Model_Broker_JpBroker::scanBrokerBySource($this->_startId, 2, array('id', 'realName', 'cityId', 'ajkMemberId'), self::BATCH_LIMIT); }
/** * 判断该task的房子 不在线则通知上 * @param $task * @return bool * @throws Exception */ public function dealTask($task) { $houseInfo = $task; $proId = $houseInfo['id']; $cityId = $houseInfo['cityId']; $brokerInfo = Model_Broker_JpBroker::data_access()->filter('id', $houseInfo['memberId'])->get_row(); //查询城市配置信息 $ComboConfig = DAO_My_ComboConfig::getComboConfigByCityId($cityId); // 判断solr是否在线 不在线通知上 if ($ComboConfig && $ComboConfig['type'] == 0) { //套餐城市 if (Bll_Combo_HouseRelation::getOnlineRelationByHouseId($proId, Bll_Combo_HouseRelation::SITE_TYPE_JP)) { $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($cityId, $brokerInfo['ajkMemberId'], $proId, $houseInfo['houseType'], 1); $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $proId, $result['status'], $result['message'])); $this->setLog(sprintf('房源 %s 在套餐推广中, 需要通知solr上' . PHP_EOL, $proId)); return true; } return true; } else { //ppc城市 if ($houseInfo['fixSpreadId'] != 0) { $spreadInfo = Model_Plan_Jp::data_access()->filter('id', $houseInfo['fixSpreadId'])->filter('type', Model_Plan_Jp::ENUM_TYPE_FIX)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->get_row(); if ($spreadInfo && $spreadInfo['status'] == 2) { // 定价在线 需要通知上 $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($cityId, $brokerInfo['ajkMemberId'], $proId, $houseInfo['houseType'], 1); $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $proId, $result['status'], $result['message'])); $this->setLog(sprintf('房源 %s 在定价推广中, 需要通知solr上' . PHP_EOL, $proId)); return true; } } return true; } }
public function handle_request() { $refundClickList = Model_Stats_JpBlackVppv::scanByClickDt($this->_startId, $this->_date, self::BATCH_LIMIT); foreach ($refundClickList as $refundClick) { $this->setFlag(array('id' => $refundClick['id'])); $this->setLogContentPrefix($refundClick['id']); $this->setLog(sprintf('点击信息:%s', json_encode($refundClick))); $chargeLog = Model_Log_JpCharge::getRowById($refundClick['id']); if (empty($chargeLog)) { $this->setLog('没有获取到点击的扣费信息'); continue; } $this->setLog(sprintf('扣费信息: %s', json_encode($chargeLog))); if (Model_Log_JpCharge::CHARGE_TYPE_0 != $chargeLog[Model_Log_JpCharge::CHARGE_TYPE]) { $this->setLog('不是扣费记录'); continue; } if ($chargeLog['spread_type'] != Model_Log_JpCharge::SPREAD_TYPE_2) { $this->setLog('非精选扣费'); continue; } if ($chargeLog['is_refund'] != Model_Log_JpCharge::IS_REFUND_0) { $this->setLog('已经退费过了'); continue; } /** 执行退费逻辑 调用 Java API */ $jpMemberInfo = Model_Broker_JpBroker::getBrokerInfoById($refundClick['memberId'], array('ajkMemberId', 'id', 'isDelete', 'source')); if (empty($jpMemberInfo)) { $this->setLog(sprintf('没有获取到用户[%d]的信息', $refundClick['memberId'])); continue; } $this->setLog(sprintf('用户[%d]的信息: %s', $refundClick['memberId'], json_encode($jpMemberInfo))); $ajkUserId = Model_Broker_AjkBrokerExtend::getUserIdByBrokerId($jpMemberInfo['ajkMemberId']); if ($ajkUserId == 0) { $this->setLog(sprintf('没有获取到用户[jp:%d ajk:%d]的user id', $refundClick['memberId'], $jpMemberInfo['ajkMemberId'])); continue; } $this->setLog(sprintf('用户[jp:%d ajk:%d]的userId=%d', $refundClick['memberId'], $jpMemberInfo['ajkMemberId'], $ajkUserId)); $params = array('reqId' => $refundClick['id'], 'userId' => $ajkUserId, 'amount' => $chargeLog['real_cost'], 'note' => sprintf('房源[%d]精选点击退费', $refundClick['proId'])); $this->setLog(sprintf('请求的参数:%s', http_build_query($params))); $refundSuccess = false; for ($i = 0; $i < 3; $i++) { /** * @var Bll_Service_Client_HttpResponse $apiResponse */ $apiResponse = Bll_Service_Payment::refund(Const_PaymentApp::JP_SITE, $params); $this->setLog(sprintf('调用API退费返回值:%s', json_encode($apiResponse->getResponse()))); if ($apiResponse->isSucceeded() && isset($apiResponse['result']) && $apiResponse['result'] == true) { $refundSuccess = true; break; } } if ($refundSuccess == false) { $this->setLog('调用API退费失败'); continue; } /** 更新扣费日志状态 */ if (false == Model_Log_JpCharge::refund($chargeLog['id'])) { $this->setLog(sprintf('[%d] 修改表 Model_Log_JpCharge.is_refund 失败', $chargeLog['id'])); } else { $this->setLog(sprintf('[%d] 修改表 Model_Log_JpCharge.is_refund 成功', $chargeLog['id'])); } } if (count($refundClickList) < self::BATCH_LIMIT) { $this->removeFlag(); $this->setShStopFlag(); $this->setLog('处理完成...'); } }
public static function propCheck($houseId, $brokerId) { //获取房源信息 $objModel = Model_House_JpHouseIdx::data_access(); $objHouse = $objModel->find_by_pk($houseId, false); if (empty($objHouse)) { return array('flg' => false, 'data' => '房源为空'); } $jpMemberId = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($brokerId); if ($objHouse->memberId != $jpMemberId->id) { return array('flg' => false, 'data' => '没有权限操作房源'); } if ($objHouse->isDelete == 1) { return array('flg' => false, 'data' => '删除房源无法操作'); } $houseTypeClass = Model_House_JpHouseIdx::getHouseTypeModelClass($objHouse->houseType); $objHouseDetail = $houseTypeClass::getPropInfoByPk($houseId); if (empty($objHouseDetail)) { return array('flg' => false, 'data' => '房源不存在'); } if ($objHouseDetail->isExpired) { return array('flg' => false, 'data' => '过期房源不能操作'); } if ($objHouseDetail->isIllegal) { return array('flg' => false, 'data' => '违规房源不能操作'); } return array('flg' => true, 'data' => ''); }