Пример #1
0
 /**
  * 获取坑位的准确usedNum
  */
 public static function countBucketChoicePlan($blockId, $newBlockId, $houseType, $priceId)
 {
     $objModel = Model_Plan_Jp::data_access()->force_master();
     if ($newBlockId) {
         $countObj = $objModel->filter('newBlockId', $newBlockId)->filter('houseType', $houseType)->filter('priceId', $priceId);
     } else {
         $countObj = $objModel->filter('blockId', $blockId)->filter('houseType', $houseType)->filter('priceId', $priceId);
     }
     $count = $countObj->filter('type', Model_Plan_Jp::ENUM_TYPE_BID)->filter('bidVersion', Model_Plan_Jp::BIDVERSION_CHOICE)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->filter('status', array(2, 6))->count();
     return $count;
 }
Пример #2
0
 public static function stopJpBidData($list)
 {
     $checkList = self::checkList($list);
     if (!$checkList['status']) {
         return $checkList;
     }
     $planInfo = Model_Plan_Jp::data_access()->filter('id', $list['planId'])->find_only();
     if ($planInfo->isDelete == Model_Plan_Jp::ENUM_IS_DELETE_YES) {
         return Bll_HzPropBll::build_return(0, '无效的竞价计划' . json_encode($list));
     }
     if ($planInfo->status != Model_Plan_Jp::ENUM_STATUS_ONLINE) {
         return Bll_HzPropBll::build_return(0, '竞价计划不在推广中' . json_encode($list));
     }
     if ($planInfo->type != Model_Plan_Jp::ENUM_TYPE_BID) {
         return Bll_HzPropBll::build_return(0, '竞价计划类型有误' . json_encode($list));
     }
     if (!in_array($planInfo->bidVersion, array(Model_Plan_Jp::BIDVERSION_OLD, Model_Plan_Jp::BIDVERSION_CHOICE))) {
         return Bll_HzPropBll::build_return(0, '竞价计划version error' . json_encode($list));
     }
     $houseIdx = Model_House_JpHouseIdx::data_access()->filter('id', $planInfo['houseId'])->find_only();
     if (empty($houseIdx)) {
         return Bll_HzPropBll::build_return(0, '金铺房源信息没有' . json_encode($list));
     }
     if ($houseIdx->bidSpreadId != $planInfo->id) {
         return Bll_HzPropBll::build_return(0, '金铺房源信息有误bidSpreadId' . json_encode($list));
     }
     $houseIdx->bidSpreadId = 0;
     if (!$houseIdx->save()) {
         return Bll_HzPropBll::build_return(0, '金铺房源信息更新失败' . json_encode($list));
     }
     //发送结算
     $params = array();
     $params['spread_id'] = $planInfo->id;
     $params['log_status'] = 7;
     Bll_Plan_Bid_JpSettlement::getInstance()->settlement($params, 'bid');
     $planInfo->status = Model_Plan_Jp::ENUM_STATUS_OVER;
     $planInfo->isDelete = 1;
     $planInfo->updateTime = date('Y-m-d H:i:s');
     if (!$planInfo->save()) {
         return Bll_HzPropBll::build_return(0, '金铺计划信息更新失败' . json_encode($list));
     }
     //房源下架tosolr
     Bll_House_JpHouseInfo::updateHouseToSolr(1, $planInfo->houseId, 1);
     //通知更新q_spread_bid_update表 计算竞价系数
     Model_Plan_JpSpreadBidUpdate::setBidUpdateQ($planInfo->id);
     //记录房源日志
     $data = array('houseId' => $houseIdx->id, 'planId' => $planInfo->id, 'brokerId' => $list['brokerId'], 'cityId' => $planInfo->cityId, 'type' => 15, 'changeType' => 407, 'remark' => '房源' . $houseIdx->id . '移出定价计划/取消套餐推广。竞价' . $planInfo->id . '(id)取消竞价推广。', 'addDate' => date('Y-m-d H:i:s'), 'operatorId' => $list['operationId'], 'siteType' => 3);
     if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
         return Bll_HzPropBll::build_return(0, array("日志写入失败"));
     }
     return Bll_HzPropBll::build_return(1, array('竞价' . $planInfo->id . '(id)取消竞价推广。'));
 }
Пример #3
0
 public function handle_request()
 {
     $brokers = array();
     $dao = Model_Plan_Jp::data_access();
     if ($this->brokerid) {
         $dao->filter('memberId', $this->brokerid);
     }
     $dao->filter('cityId', $this->cityid);
     $dao->filter('type', 2);
     $dao->filter('status', 2);
     $dao->filter('isDelete', '0');
     $datas = $dao->find();
     foreach ($datas as $data) {
         $brokerid = $data['memberId'];
         if (isset($brokers[$brokerid])) {
             continue;
         }
         $result = Uri_Curl::get($this->url . 'jinpu/api/choice/brokerprop', array('brokerid' => $brokerid, 'status' => 5));
         printf('[%s]开始处理金铺: brokerId为 %s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $brokerid, $result);
         $brokers[$brokerid] = 1;
     }
 }
Пример #4
0
 /**
  * 金铺-精选房源设置
  *
  * @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' => '精选推广成功');
     }
 }
Пример #5
0
 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;
 }
Пример #6
0
 /**
  * 把房源从竞价推广中移除
  * @param $objHouse
  * @param int $p_intMemberId
  * @param $log_type:1,手动停止 2,房源过期
  * @param int $do_choice  是否处理精选计划,如果为false 说明插入竞价队列表,在竞价队列JOB中处理
  * @return mixed
  */
 public static function removeBidHouseFromSpread($objHouse, $memberId = 0, $log_type = 1, $do_choice = true)
 {
     if ($log_type == 1) {
         $arr_log_param = array('spread_status' => Model_Log_JpSpreadStatusUpdate::ENUM_STATUS_SPREAD_STOP, 'house_log' => Model_Log_JpHouseUpDown::ENUM_BID_MEMBER_HOUSE_STOP);
     } elseif ($log_type == 2) {
         $arr_log_param = array('spread_status' => Model_Log_JpSpreadStatusUpdate::ENUM_STATUS_SPREAD_HOUSE_EXPIRE, 'house_log' => Model_Log_JpHouseUpDown::ENUM_JOB_HOUSE_EXPIRE);
     }
     $p_intHouseId = $objHouse->id;
     //检查推广信息
     $arrResult = Bll_Plan_JpPlanManage::getInstance()->checkSpreadInfo($objHouse->bidSpreadId, $memberId, $objHouse->id);
     if (!$arrResult['success']) {
         return $arrResult;
     }
     $objSpread = $arrResult['data'];
     //从竞价中移除房源
     if ($objSpread->type == Model_Plan_Jp::ENUM_TYPE_HP) {
         if ($objSpread->bidVersion == Model_Plan_Jp::BIDVERSION_CHOICE) {
             if (false == $do_choice) {
                 return array('success' => true, 'data' => '操作成功');
             }
         }
         //记录停止日志
         Bll_Log_JpPlan::getInstance()->writeSpreadStatusLog($arr_log_param['spread_status'], $objHouse->bidSpreadId, '房源停止计划:触发结算前');
         //发送结算
         $params = array();
         $params['spread_id'] = $objHouse->bidSpreadId;
         $params['log_status'] = 7;
         Bll_Plan_Bid_JpSettlement::getInstance()->settlement($params, 'bid');
         //解除关系
         $objHouse->bidSpreadId = 0;
         $objHouse->save();
         //判断是否下架房源
         $intXiaJia = 1;
         if (!empty($objHouse->fixSpreadId)) {
             $objModel = Model_Plan_Jp::data_access();
             try {
                 $objFixSpread = $objModel->find_by_pk($objHouse->fixSpreadId, false);
             } catch (Exception $e) {
                 $objFixSpread = null;
             }
             if (!empty($objFixSpread) && $objFixSpread->status == 2) {
                 $intXiaJia = 0;
             }
         }
         //操作下架
         if ($intXiaJia) {
             //下架房源
             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);
         }
         //更新solr
         Bll_House_JpHouseInfo::updateHouseToSolr(1, $p_intHouseId, 1);
         //TO 初始化房源统计日志
         Bll_House_JpBwAnalysis::getInstance()->openSaveBluewhaleHouse($objHouse->id, date('Y-m-d'), $objHouse->bidSpreadId, $objSpread->type);
         //竞价房源下线日志
         Bll_Log_JpHouse::getInstance()->writeHouseLog($objHouse->id, $objHouse->bidSpreadId, 0, $objHouse->memberId, $arr_log_param['house_log']);
         $objSpread->isDelete = 1;
         $objSpread->save();
         return array('success' => true, 'data' => '操作成功');
     }
 }
Пример #7
0
 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;
     }
 }
Пример #8
0
 /**
  *
  * 查询经纪人定价、竞价、精选计划
  *
  * @param $jpBroekrId
  * @param int $type 1-定价,2-竞价、精选
  * @param array $status 2-推广
  * @return array
  */
 public static function getPlanByMemberId($jpBroekrId, $type = 1, $status = array(2))
 {
     try {
         $houseInfo = Model_Plan_Jp::data_access()->filter('memberId', $jpBroekrId)->filter('type', $type)->filter('status', $status)->filter('isDelete', 0)->get_all();
         return $houseInfo;
     } catch (Exception $e) {
         return array();
     }
 }
Пример #9
0
 /**
  * 判断该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;
     }
 }
Пример #10
0
 /**
  * @param $planId
  * @param $forceMaster
  * @return array
  */
 public static function getFixPlanInfoById($planId, $forceMaster = false)
 {
     $houseObj = Model_Plan_Jp::data_access()->filter('id', $planId);
     if ($forceMaster) {
         $houseObj->force_master();
     }
     $house = $houseObj->get_row();
     if (empty($house) || empty($house['fixSpreadId'])) {
         return array('success' => false, 'data' => '推广不存在');
     }
     $plan = Model_Plan_Jp::data_access()->filter('id', intval($house['fixSpreadId']))->filter('type', Model_Plan_Jp::ENUM_TYPE_FIX)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->get_row();
     if ($plan['memberId'] != $house['memberId']) {
         return array('success' => false, 'data' => '没有权限操作推广');
     }
     return array('success' => true, 'data' => $plan);
 }
Пример #11
0
 public static function prepareBidList(&$out)
 {
     $out['bidHouses'] = array();
     //获取经纪人竞价计划
     $BidPlans = Model_Plan_Jp::data_access()->filter('memberId', $out['jpBrokerId'])->filter('type', Model_Plan_Jp::ENUM_TYPE_BID)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->filter('bidVersion', Model_Plan_Jp::BIDVERSION_OLD)->get_all();
     $listInfo = $bidHouseIds = array();
     //排名 今日点击量 预算余额 采用页面加载后的ajax todo
     if ($BidPlans) {
         foreach ($BidPlans as $plan) {
             $houseInfo = $out['houses'][$plan['houseId']];
             if (empty($houseInfo['base']) || empty($plan)) {
                 continue;
             }
             $listInfo[$plan['houseId']]['houseInfo'] = $houseInfo;
             $listInfo[$plan['houseId']]['planInfo'] = $plan;
             $bidHouseIds[$plan['houseId']] = $plan['houseId'];
         }
     }
     foreach ($listInfo as $houseId => $mixInfo) {
         // 是否暂停
         if ($mixInfo['planInfo']['status'] == '4') {
             $is_stop_f = 1;
         } else {
             $is_stop_f = 0;
         }
         $is_stop[$houseId] = $is_stop_f;
     }
     array_multisort($is_stop, SORT_DESC, $bidHouseIds, SORT_DESC, $listInfo);
     $out['bidHouses'] = $listInfo;
     $out['bidHouseIds'] = $bidHouseIds;
 }
Пример #12
0
 public function addFixPlan($params, $from = 'search')
 {
     //创建默认的定价计划
     // 根据memcache判断结果,如果大于1,则返回查询结果
     $objMemcache = APF_Cache_Factory::get_instance()->get_memcache();
     $memKey = __CLASS__ . '_' . __FUNCTION__ . '_' . $params['memberId'];
     $currentValue = $objMemcache->increment($memKey, 1);
     $isTop = Model_City_JpLimit::data_access()->filter('city_id', $params['cityId'])->get_row();
     $plans = Model_Plan_Jp::data_access()->force_master()->filter('memberId', $params['memberId'])->filter('cityId', $params['cityId'])->filter('type', 1)->filter('isDelete', 0)->get_all();
     //封顶城市 1个定价组
     if (!empty($plans) && $isTop) {
         return $from == 'search' ? $plans : array('status' => -1, 'info' => '封顶城市最多一个定价组');
     }
     if ($isTop && $isTop['status'] == 1 && $currentValue && $currentValue > 1) {
         //封顶城市
         $objMemcache->delete($memKey);
         return $from == 'search' ? $plans : array('status' => -1, 'info' => '封顶城市最多一个定价组');
     }
     //不封顶城市 最多5个定价组
     if (!empty($plans) && count($plans) >= 5) {
         return $from == 'search' ? $plans : array('status' => -2, 'info' => '最多5个定价组');
     }
     if ($params['budget'] > 1000 || $params['budget'] < 10) {
         return $from == 'search' ? $plans : array('status' => -3, 'info' => '定价推广组预算最多1000元,最少10元');
     }
     //创建计划流程开始
     $plan = array();
     $plan['memberId'] = $params['memberId'];
     $plan['budget'] = $params['budget'] * 100;
     $plan['name'] = $params['name'];
     $plan['cityId'] = $params['cityId'];
     $plan['serialNumber'] = 0;
     $plan['startTime'] = 0;
     $plan['endTime'] = 0;
     $plan['noBudgetDate'] = 0;
     $plan['createTime'] = date('Y-m-d H:i:s');
     $plan['updateTime'] = date('Y-m-d H:i:s');
     $plan['isDelete'] = 0;
     $plan['houseNum'] = 0;
     $plan['type'] = 1;
     //经纪人身份认证状态
     $memberCheckState = $this->getMemberCheckStatus($plan['memberId']);
     //判定账户余额
     $balance = $this->getMemberBalance($plan['memberId']);
     if (!$memberCheckState) {
         $status = 4;
         $stopReason = 3;
     } elseif ($balance <= 0) {
         $status = 4;
         $stopReason = 2;
     } else {
         $status = 2;
         $stopReason = 0;
     }
     $plan['status'] = $status;
     $plan['stopReason'] = $stopReason;
     $newPlanObj = Model_Plan_Jp::create($plan);
     $newPlanObj->save();
     $planId = $newPlanObj->id;
     $plan['id'] = $planId;
     return $from == 'search' ? array($plan) : array('status' => 1, 'info' => '创建计划成功');
 }