Example #1
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']}上线日志写入";
             }
         }
     }
 }
Example #2
0
 /**
  * 公共房源日志写入
  * @param $type
  * @param $desc
  * @throws Exception_BllErrorException
  */
 private function writePropLog($type, $desc)
 {
     $data = Bll_HzPropBll::build_prop_log($this->params, $type, "房源{$this->params['pro_id']}{$desc}", $this->params['ajk_broker_id']);
     if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
         throw new Exception_BllErrorException("房源{$this->params['pro_id']}{$desc}日志写入失败");
     } else {
         $this->allReturn[] = "房源{$this->params['pro_id']}{$desc}日志写入";
     }
 }