Ejemplo n.º 1
0
 /**
  * 获得经纪人已竞价房源列表
  */
 public static function get_broker_bidprop($broker_id, $city_id)
 {
     $plans = Dao_Broker_HzPlan::get_broker_plan($broker_id, '1,3,7', Const_HzPlan::BID_TYPE);
     $plan_info = array();
     $planids = $proids = array();
     if ($plans) {
         foreach ($plans as $plan) {
             $plan_info[$plan['id']]['plan'] = $plan;
             //计划信息
             $planids[] = $plan['id'];
         }
     } else {
         return array();
     }
     $plannings = Dao_Broker_HzPlan::get_planning($planids, Const_HzPlan::BID_TYPE);
     if ($plannings) {
         foreach ($plannings as $planning) {
             $proids[$planning['proid']] = $planning['proid'];
             $plan_info[$planning['plan_id']]['proid'] = $planning['proid'];
             //房源ID
             $plan_info[$planning['plan_id']]['offer'] = $planning['unit_price'];
         }
     } else {
         return array();
     }
     $proinfo = Dao_Broker_HzProp::get_prop($proids);
     $clicks = Dao_Broker_HzProp::get_prop_clicks($proids, $city_id);
     foreach ($plan_info as $key => $value) {
         $prop = $proinfo[$value['proid']];
         if (empty($prop)) {
             unset($plan_info[$key]);
             continue;
         }
         $plan_info[$key]['prop'] = $prop;
         //房源信息
         $plan_info[$key]['clicks'] = intval($clicks[$value['proid']]['bid_cnum']);
         //当天点击量
         $plan_info[$key]['reconsume'] = $plan_info[$key]['plan']['status'] == 1 ? round($plan_info[$key]['plan']['amount'] - $plan_info[$key]['plan']['total_consume'], 2) : 0;
         //预算余额
         $plan_info[$key]['consume'] = $plan_info[$key]['plan']['status'] == 1 ? round($plan_info[$key]['plan']['amount'], 2) : 0;
         //预算
         if ($value['plan']['status'] == 1) {
             $prop["content_basic"]['proid'] = $prop['proid'];
             $prop["content_basic"]['unit_price'] = $value['offer'];
             $rank = self::get_bid_rank($prop["content_basic"], $city_id);
             if ($rank < 5) {
                 $plan_info[$key]['rank'] = $rank;
             } else {
                 $plan_info[$key]['rank'] = '排队中';
             }
         } else {
             $plan_info[$key]['rank'] = '已暂停';
         }
     }
     return empty($plan_info) ? array() : $plan_info;
 }
Ejemplo n.º 2
0
 /**
  * 增加money产生的公共动作
  * @param string $descript
  * @throws Exception_BllErrorException
  */
 private function addMoneyCommon($descript = '')
 {
     // 上线前判断余额 Jackin
     $userId = Bll_Broker_MainBusiness::getDataByEsfId($this->params['ajk_broker_id'])->memberId;
     try {
         $balanceInfo = Bll_Service_Payment::balance(Const_PaymentApp::HZ_DEFAULT, array('userId' => $userId));
     } catch (Exception $e) {
         throw new Exception_BllErrorException(sprintf('调用api失败: %s userId=%d broker_id=%d ajk_broker_id=%d', $e->getMessage(), $userId, $this->params['broker_id'], $this->params['ajk_broker_id']));
     }
     if ($balanceInfo['status'] == 'error') {
         throw new Exception_BllErrorException(sprintf('%s ajkBrokerId(%d) 获取余额失败', $descript, $this->params['ajk_broker_id']));
     } elseif ($balanceInfo['data']['balance'] <= 0) {
         throw new Exception_BllErrorException(sprintf('%s ajkBrokerId(%d) 余额(%d)不足', $descript, $this->params['ajk_broker_id'], $balanceInfo['data']['balance']));
     }
     $this->allReturn = array(sprintf('hz:%s ajkBrokerId(%d) 当前余额(%d) ', $descript, $this->params['ajk_broker_id'], $balanceInfo['data']['balance']));
     //获取刷爆$descript的计划
     $plans = Dao_Broker_HzPlan::get_broker_plan($this->params['broker_id'], 7);
     if (empty($plans)) {
         $this->allReturn[] = '没有获取到 status=7 的计划';
         return;
     }
     $plan_ids = array();
     foreach ($plans as $plan) {
         $plan_ids[] = $plan['id'];
     }
     // 获取所有房子并上线
     $plans_props = Bll_HzFixPlan::get_plan_props($plan_ids, $this->params['city_id']);
     if (empty($plans_props)) {
         $this->allReturn[] = sprintf('没有获取到计划(%s)的房源', implode(',', $plan_ids));
         return;
     }
     foreach ($plans_props as $plan_id => $props) {
         // 更新计划状态
         if (Bll_HzPropBll::switchUpOrDown()) {
             if (!Dao_Broker_HzPlan::update_plan_status($plan_id, Const_HzPlan::SPREAD)) {
                 $this->allReturn[] = "更新计划[{$plan_id}]数据失败";
             }
         } else {
             $this->allReturn[] = "开关关闭,计划[{$plan_id}]数据不再更新";
         }
         // 记录计划上线日志
         $data = Bll_HzFixPlanBll::build_plan_log($this->params, 8, "{$descript},计划上线", $this->params['broker_id']);
         if (!Model_House_UpDown_PlanLog::create($data, date('m'))->save()) {
             $this->allReturn[] = "{$descript},计划[{$plan_id}]上线写入失败";
         } else {
             $this->allReturn[] = "{$descript},计划[{$plan_id}]上线写入";
         }
         foreach ($props['props'] as $prop) {
             if (Bll_HzPropBll::switchUpOrDown()) {
                 if (Dao_Broker_HzProp::change_prop_status($prop['proid'], Const_HzStatus::ONLINE) && Model_Plan_HzPlanning::updatePlanningByPropId($prop['proid'], Const_HzPlan::SPREAD, Const_HzPlan::SPREAD_TYPE)) {
                     $this->allReturn[] = "房源{$prop['proid']}上线成功";
                 } else {
                     $this->allReturn[] = "房源{$prop['proid']}上线失败";
                 }
             } else {
                 $all_return[] = "开关关闭,房源[{$prop['proid']}]状态不改变";
             }
             $data = Bll_HzPropBll::build_prop_log($this->params, 5, "房源上线", $this->params['broker_id']);
             $data['planId'] = $plan_id;
             $data['houseId'] = $prop['proid'];
             if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
                 $this->allReturn[] = "房源{$prop['proid']}上线日志写入失败";
             } else {
                 $this->allReturn[] = "房源{$prop['proid']}上线日志写入";
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * 经纪人没有定价计划时,需要创建
  * 避免主从延迟,直接拼数组返回
  */
 public static function add_broker_plan($broker_id)
 {
     $broker_info = Dao_Broker_HzPlan::get_hzbroker_info($broker_id);
     $city_top = self::get_citytop($broker_info['cityid']);
     $plans = Dao_Broker_HzPlan::get_broker_plan($broker_id);
     //定价计划最多5个
     if (count($plans) >= 5) {
         return array();
     }
     //封顶城市最多一个计划
     if (!empty($city_top) && count($plans) >= 1) {
         return array();
     }
     $broker_money = Bll_PayAccount::get_broker_balance($broker_id);
     $default_plan = APF::get_instance()->get_config('plan_info', 'hzmessage');
     $plan_status = Const_HzPlan::SPREAD;
     if ($broker_money <= 0) {
         $plan_status = Const_HzPlan::UPPERLIMIT;
     } else {
         if ($broker_info['profile_verify'] != 2) {
             $plan_status = Const_HzPlan::MANUALLY_PAUSE;
         }
     }
     $plan_id = Dao_Broker_HzPlan::add_plan($default_plan['plan_name'], Const_HzPlan::SPREAD_TYPE, $broker_id, $default_plan['amount'], $plan_status);
     if ($plan_id) {
         return array(0 => array('id' => $plan_id, 'plan_title' => $default_plan['plan_name'], 'plan_type' => Const_HzPlan::SPREAD_TYPE, 'user_id' => $broker_id, 'amount' => $default_plan['amount'], 'consume' => 0, 'total_consume' => 0, 'valid_count' => 0, 'status' => $plan_status, 'stop_date' => 0, 'created' => time(), 'last_update' => date('Y-m-d H:i:s'), 'flag' => 1, 'order_update' => time()));
     }
     return array();
 }