Пример #1
0
 /**
  * 动作 7
  * 房源移出定价计划,导致竞价停止(房源日志发起)
  * 结算
  * 更新计划为停止状态
  * 通知solr下(停止的房源)
  * 记录房源日志(停止的房源)
  * 根据停止的房源,取出坑位里面的推广、排队房源
  * 计算排名
  * 更新计划状态(坑位里面的异动房源更新状态)
  * 通知solr(坑位里面的异动房源通知solr)
  * 记房源日志(坑位里面的房源异动日志)
  * @param array $params
  * @return array|bool
  */
 public static function removeFixPlanForBid($params = array())
 {
     self::$qInfo = $params;
     // 检查参数
     $checkParams = self::checkParams($params);
     if (!$checkParams['status']) {
         return $checkParams;
     }
     // 获取信息,组装$params
     $joinParams = self::joinParams($params);
     if (!$joinParams['status']) {
         return $joinParams;
     }
     $all_return = array();
     //判断竞价计划是否删除
     if ($params['flag'] != 1) {
         return Bll_HzPropBll::build_return(0, '无效的竞价计划' . json_encode($params));
     }
     //非推广的计划
     if ($params['status'] != 1) {
         return Bll_HzPropBll::build_return(0, '非推广的竞价计划' . json_encode($params));
     }
     // 非精选判断
     if ($params['bidVersion'] == 2) {
         return Bll_HzPropBll::build_return(0, '房源为精选' . json_encode($params));
     }
     //获取竞价计划的冻结号
     $sn = Dao_Broker_HzPlan::get_bid_sn($params['planId']);
     $sn = $sn['sn'];
     if (empty($sn)) {
         return Bll_HzPropBll::build_return(0, Const_HzErrorInfo::PROPERROR . json_encode($params));
     }
     //获取竞价花费
     $amount = $params['totalConsume'];
     $note = urlencode('推广房源' . $params['proId']);
     $user_id = Bll_HzBroker::get_userid_by_hzbrokerid($params['']);
     /** 竞价结算 调用3次 */
     $charge_sn = false;
     $unfreezeOrderData = array('userId' => $user_id, 'proId' => $params['proId'], 'serialNumber' => $sn, 'planId' => $params['planId'], 'amount' => $amount);
     $unfreezeOrder = Bll_Ppc_BidUnfreeze::createHzOrder($unfreezeOrderData);
     for ($i = 0; $i < 3 && !$charge_sn; $i++) {
         $charge_sn = Bll_PayAccount::cancel_frozen($user_id, $amount, '', Const_PaymentApp::HZ_BID, $sn, $note, true);
     }
     if (!$charge_sn) {
         $unfreezeOrder->fail();
         $flag_array['msg'] = Const_HzErrorInfo::CHARGEFAIL;
         // 此处不需要block,由job保证此处解冻正确
         //return $flag_array;
     } else {
         $unfreezeOrder->complete();
     }
     //维护竞价关联关系
     if (!Dao_Broker_HzPlan::update_planning($params['planId'], Const_HzPlan::DELETE)) {
         $flag_array['msg'] = '维护竞价关联关系,数据更新失败.';
         return $flag_array;
     }
     //维护计划状态
     if (!Dao_Broker_HzPlan::update_plan_status($params['planId'], Const_HzPlan::DELETE)) {
         $flag_array['msg'] = '维护计划状态,数据更新失败.';
         return $flag_array;
     }
     // 更新计划的flag为删除状态
     if (!Dao_Broker_HzPlan::update_history_bids($params['planId'])) {
         $flag_array['msg'] = '更新计划的flag为删除状态,数据更新失败.';
         return $flag_array;
     }
     //记录房源日志
     $data = array('houseId' => $params['proId'], 'planId' => $params['planId'], 'brokerId' => $params['ajkBrokerId'], 'cityId' => $params['cityId'], 'type' => 15, 'changeType' => 407, 'remark' => '房源' . $params['proId'] . '移出定价计划。竞价' . $params['planId'] . '(id)取消竞价推广。', 'addDate' => date('Y-m-d H:i:s'), 'operatorId' => $params['operationId'], 'siteType' => 2);
     if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
         return Bll_HzPropBll::build_return(0, array("日志写入失败"));
     }
     //计算房源状态
     Bll_HzPropBll::bulidHzProStatu($params['proId']);
     return Bll_HzPropBll::build_return(1, array('竞价' . $params['planId'] . '(id)取消竞价推广。'));
 }
Пример #2
0
 /**
  * 租房精选房源取消推广
  * 1. 维护计划状态
  * 2. 通知solr上下
  */
 public static function choicePropOutBid($broker_id, $proid)
 {
     $flag_array = array('status' => 0, 'msg' => '');
     //获取精选 房源、计划关系表信息(promotion_prop_planning)
     $planning = Dao_Broker_HzPlan::get_prop_all_planning($proid, Const_HzPlan::BID_TYPE);
     if (empty($planning)) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPFIXNULL;
         return $flag_array;
     }
     //根据计划查询精选计划的信息
     $plan_info = Dao_Broker_HzPlan::get_plan($planning[0]['plan_id']);
     if (empty($plan_info)) {
         $flag_array['msg'] = Const_HzErrorInfo::NULLPLAN;
         return $flag_array;
     }
     //判断计划是否为该经纪人的
     if ($plan_info['user_id'] != $broker_id) {
         $flag_array['msg'] = Const_HzErrorInfo::PLANINFOERROR;
         return $flag_array;
     }
     //获取精选计划的冻结号
     $sn = Dao_Broker_HzPlan::get_bid_sn($plan_info['id']);
     $sn = $sn['sn'];
     if (empty($sn)) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPERROR;
         return $flag_array;
     }
     //获取精选花费
     // $amount = $plan_info['total_consume'];
     $amount = $plan_info['amount'] - $plan_info['total_consume'];
     $note = urlencode('推广房源' . $proid);
     $user_id = Bll_HzBroker::get_userid_by_hzbrokerid($broker_id);
     /** 精选结算 调用3次 */
     $charge_sn = false;
     $unfreezeOrderData = array('userId' => $user_id, 'proId' => $proid, 'serialNumber' => $sn, 'planId' => $plan_info['id'], 'amount' => $amount);
     $unfreezeOrder = Bll_Ppc_BidUnfreeze::createHzOrder($unfreezeOrderData);
     for ($i = 0; $i < 3 && !$charge_sn; $i++) {
         $charge_sn = Bll_PayAccount::cancel_frozen($user_id, $amount, $proid, Const_PaymentApp::HZ_CHOICE, $sn, $note, true);
     }
     if (!$charge_sn) {
         $unfreezeOrder->fail();
         $flag_array['msg'] = Const_HzErrorInfo::CHARGEFAIL;
         // 此处不需要block,由job保证此处解冻正确
         //return $flag_array;
     } else {
         $unfreezeOrder->complete();
     }
     //查询房源信息
     $proInfo = Model_House_HzProp::get_prop_info_by_prop_id($proid);
     //房源违规的、删除的不能更新房源状态
     $prop_status = $proInfo['contentBasic']['status'];
     // 兼容新套餐
     $ajkBrokerId = Model_Broker_HzMapping::get_ajk_broker_id($broker_id);
     if (Bll_Broker_HzBroker::isComboBroker($ajkBrokerId)) {
         /** 判断房源是否在套餐推广中 */
         if (!Bll_Combo_HouseRelation::getOnlineRelationByHouseId($proid, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) {
             $prop_status = Const_HzStatus::OUTLINE;
         }
     } else {
         //查询房源是否在计划里面
         $fix_planning = Dao_Broker_HzPlan::get_prop_planning($proid, Const_HzPlan::SPREAD_TYPE);
         if (!in_array($proInfo['contentBasic']['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
             if (empty($fix_planning)) {
                 //房源不在计划里面
                 $prop_status = Const_HzStatus::OUTLINE;
                 //房源不在计划里面
             } elseif ($fix_planning[0]['is_valid'] == Const_HzPlan::SPREAD) {
                 $prop_status = Const_HzStatus::ONLINE;
                 //定价正在推广
             } elseif ($fix_planning[0]['is_valid'] == Const_HzPlan::UPPERLIMIT) {
                 //定价非推广(没钱状态)
                 $prop_status = Const_HzStatus::NOCASH;
                 //房源没钱
             } else {
                 $prop_status = Const_HzStatus::MANUALLY;
                 //房源状态更新为9手动停止
             }
         }
     }
     //维护精选关联关系
     if (!Dao_Broker_HzPlan::update_planning($planning[0]['id'], Const_HzPlan::MENUOVER)) {
         $flag_array['msg'] = Const_HzErrorInfo::UPDATAPLANNINGFAIL;
         return $flag_array;
     }
     //维护计划状态
     if (!Dao_Broker_HzPlan::update_plan_status($plan_info['id'], Const_HzPlan::MENUOVER)) {
         $flag_array['msg'] = Const_HzErrorInfo::UPDATAPLANFAIL;
         return $flag_array;
     }
     //通知solr
     if ($prop_status == Const_HzStatus::ONLINE) {
         //定价正在推广
         Dao_Broker_HzProp::into_prop_lucene($proid, $planning[0]['city_id'], 1);
         //竞价下,定价还在线。则更新上
     } else {
         Dao_Broker_HzProp::into_prop_lucene($proid, $planning[0]['city_id'], 2);
         //下线房源
     }
     $flag_array['status'] = 1;
     return $flag_array;
 }
Пример #3
0
 /**
  * 精选结算
  * entry(1:恶意点击分析器;2:房源下架;3:余额不够;4:推广计划到期;5:其他;6:手动停止)
  */
 public function choiceSettlement($spreadId, $cityId, $entry = 6)
 {
     //通知java结算
     $url = APF::get_instance()->get_config('JavaAPIHost');
     $url .= 'service-internal/rest/hplan/trade?json';
     $curl = new Util_Http_Curl();
     $fields['plan_id'] = $spreadId;
     $fields['city_id'] = $cityId;
     $fields['entry'] = $entry;
     $logContent = sprintf('[%s] %s    %s', date('Y-m-d H:i:s'), $url, http_build_query($fields));
     $logFile = sprintf('/data1/logs/Bll_Plan_Bid_AjkChoice-%d.log', date('Ymd'));
     file_put_contents($logFile, $logContent, FILE_APPEND);
     $unfreezeOrder = Bll_Ppc_BidUnfreeze::createEsfOrder($spreadId);
     /** 精选结算失败 就调用3次 */
     for ($i = 0; $i < 3; $i++) {
         $res = $curl->setDefaults()->post($url, $fields);
         $resArr = json_decode($res, true);
         if (strcasecmp('ok', $resArr['status']) == 0) {
             file_put_contents($logFile, '    OK' . PHP_EOL, FILE_APPEND);
             $unfreezeOrder->complete();
             return true;
         }
     }
     $unfreezeOrder->fail();
     file_put_contents($logFile, ($res == false ? '    CURL error' : $res) . PHP_EOL, FILE_APPEND);
     $this->setMsg($res);
     return false;
 }