Esempio n. 1
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $planId = $this->_params['planId'];
     // 获取定价计划
     $fixPlan = Model_Plan_HzPlanBasic::getActivePlanById($planId);
     if (!$fixPlan) {
         throw new Exception('计划不存在', Const_APIStatus::E_PLAN_NOTFOUND);
     }
     // 暂停定价计划
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId);
     $result = Bll_HzFixPlan::option_fix_plan($hzBrokerId, $planId, "stop");
     if (!$result['status']) {
         switch ($result['msg']) {
             case Const_HzErrorInfo::PLANSTOPING:
                 throw new Exception('计划已经停止', Const_APIStatus::E_PLAN_ALREADY_STOPPED);
                 break;
             default:
                 return Util_MobileAPI::error(Const_APIStatus::E_PLAN_PARAM_ERR);
         }
     }
     // 记录定价上下架日志
     $result = Bll_ProPlanChangeApiBll::get_instance()->insertProPlanChange(array('broker_id' => $brokerId, 'plan_id' => $planId, 'type' => 'plan_stop', 'from' => 'Mobile API v1: ' . __CLASS__, 'remark' => json_encode(array('fix' => array('plan_status' => $fixPlan['status']))), 'site_type' => 2), $brokerId);
     if ($result['status'] != 'ok') {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => $result['msg']);
     }
     return array('status' => 'ok', 'data' => array());
 }
 public function handle_request_internal()
 {
     $request = APF::get_instance()->get_request();
     //参数
     $broker_id = $request->get_parameter('broker_id');
     //经纪人id,必传
     $pro_id = $request->get_parameter('pro_id');
     //房源id,房源动作必传
     $plan_id = $request->get_parameter('plan_id');
     //计划id,计划动作必传
     $type = $request->get_parameter('type');
     //分配到的动作字符串(见下表),必传
     $from = $request->get_parameter('from');
     //来源(网站+业务+发生点),必传
     $remark = $request->get_parameter('remark');
     //备注
     $time = $request->get_parameter('time');
     //时间戳
     $site_type = $request->get_parameter('site_type');
     //网站类型类型
     $operate_id = $request->get_parameter('operate_id');
     //操作人id
     $key = $request->get_parameter('key');
     //验证key,pro_id+ plan_id+ broker_id+ type+ from+ time+公共字符创,的md5。(公共字符串=ProPlanChangeApi)
     //判断请求的url是否在有效期内(有效期5秒)
     //时间相差60秒
     // pg环境相差比较大。所以...
     //if($time > time() || $time < time()-5){
     if (abs($time - time()) > 600) {
         echo json_encode(array('status' => 'err', 'msg' => '无效的请求'));
         exit;
     }
     //验证key值
     if (trim($key) != md5($pro_id . $plan_id . $broker_id . $type . $from . $time . $this->PublicKey)) {
         echo json_encode(array('status' => 'err', 'msg' => '非法请求'));
         exit;
     }
     $ProPlanChangeApiBll = Bll_ProPlanChangeApiBll::get_instance();
     $Result = $ProPlanChangeApiBll->insertProPlanChange(array('broker_id' => $broker_id, 'pro_id' => $pro_id, 'plan_id' => $plan_id, 'type' => $type, 'from' => $from, 'remark' => $remark, 'site_type' => $site_type), $operate_id);
     echo json_encode($Result);
     exit;
 }
Esempio n. 3
0
 /**
  * 删除房源,可批量
  */
 public static function delete_prop($hzBrokerId, $city_id, $proids)
 {
     // 获取二手房经纪人ID,用于基于房源定价上下架日志
     $ajkBrokerId = Model_Broker_MainBusiness::getMainBusinessByHzBrokerId($hzBrokerId)->ajkBrokerid;
     $proinfo = Dao_Broker_HzProp::get_prop($proids);
     foreach ($proinfo as $proid => $prop) {
         $basic_info = $prop['content_basic'];
         if ($basic_info['cityid'] != $city_id || $basic_info['userid'] != $hzBrokerId) {
             continue;
         }
         $fix_planning = Dao_Broker_HzPlan::get_prop_planning($proid);
         if (!empty($fix_planning)) {
             Bll_HzFixPlan::prop_out_fix($hzBrokerId, $proid, $fix_planning[0]['plan_id']);
         }
         Dao_Broker_HzProp::change_prop_status($proid, Const_HzStatus::REMOVE);
         // 记录房源定价上下架记录
         Bll_ProPlanChangeApiBll::get_instance()->insertProPlanChange(array('broker_id' => $ajkBrokerId, 'pro_id' => $proid, 'plan_id' => $fix_planning ? $fix_planning[0]['plan_id'] : '', 'type' => 'pro_del', 'from' => 'hz_' . __CLASS__ . '_' . __FUNCTION__, 'remark' => '删除房源', 'site_type' => 2), $ajkBrokerId);
     }
     return true;
 }
Esempio n. 4
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $planId = $this->_params['planId'];
     // 获取定价计划
     $fixPlan = Model_Plan_HzPlanBasic::getActivePlanById($planId);
     if (!$fixPlan) {
         throw new Exception('计划不存在', Const_APIStatus::E_PLAN_NOTFOUND);
     }
     // 开启定价计划
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId);
     $result = Bll_HzFixPlan::option_fix_plan($hzBrokerId, $planId, "repeat");
     if (!$result['status']) {
         switch ($result['msg']) {
             case Const_HzErrorInfo::PLANFIXING:
                 throw new Exception('计划已经开启', Const_APIStatus::E_PLAN_ALREADY_STARTED);
                 break;
             case Const_HzErrorInfo::BROKERCHECK:
                 throw new Exception('您的身份认证未通过审核,请联系你的客户经理', Const_APIStatus::E_BROKER_ISNOT_VERFIYED);
                 break;
             case Const_HzErrorInfo::PLANMONEY:
                 throw new Exception('账户余额不足,请充值后操作', Const_APIStatus::E_BROKER_NO_MONEY);
                 break;
             case Const_HzErrorInfo::PLANAMOUNT:
                 throw new Exception('今日限额已经用完,请调整限额后操作', Const_APIStatus::E_PLAN_ERR_3013);
                 break;
             default:
                 return Util_MobileAPI::error(Const_APIStatus::E_PLAN_PARAM_ERR);
         }
     }
     // 记录定价上下架日志
     $result = Bll_ProPlanChangeApiBll::get_instance()->insertProPlanChange(array('broker_id' => $brokerId, 'plan_id' => $planId, 'type' => 'plan_start', 'from' => 'Mobile API v1: ' . __CLASS__, 'remark' => json_encode(array('fix' => array('plan_status' => $fixPlan['status']))), 'site_type' => 2), $brokerId);
     if ($result['status'] != 'ok') {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => $result['msg']);
     }
     return array('status' => 'ok', 'data' => array());
 }
Esempio n. 5
0
 /**
  * 将单个房源从定价组中移除
  */
 public static function prop_out_fix($broker_id, $proid, $plan_id)
 {
     $flag_array = array('status' => 0, 'msg' => '');
     $proinfo = Dao_Broker_HzProp::get_prop($proid);
     if (empty($proinfo[$proid])) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPNULL;
         return $flag_array;
     }
     $plan_info = Dao_Broker_HzPlan::get_plan($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;
     }
     if ($proinfo[$proid]['content_basic']['userid'] != $plan_info['user_id']) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPUSERNULL;
         return $flag_array;
     }
     $planning = Dao_Broker_HzPlan::get_check_planning($proid, $plan_id);
     if (empty($planning)) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPFIXNULL;
         return $flag_array;
     }
     //写入定价上下架队列表
     $ProPlanChangeApiBll = Bll_ProPlanChangeApiBll::get_instance();
     $ajkBrokerId = Model_Broker_HzMapping::get_ajk_broker_id($broker_id);
     $ProPlanChangeApiBll->insertProPlanChange(array('broker_id' => $ajkBrokerId, 'pro_id' => $proid, 'plan_id' => $plan_id, 'type' => 'pro_del_from_plan', 'from' => 'hz_' . __CLASS__ . '_' . __FUNCTION__, 'remark' => json_encode(array('fix' => array('plan_status' => 1))), 'site_type' => 2), $ajkBrokerId);
     $bid = Dao_Broker_HzPlan::get_prop_planning($proid, Const_HzPlan::BID_TYPE, '1');
     if (!empty($bid)) {
         //停止竞价
         $deleteBidResult = Bll_HzBidPlan::delete_bid($broker_id, $bid[0]['plan_id'], $proid);
     }
     $log_option = Const_HzLog::PAUSEPLAN;
     $new_is_valid = Const_HzPlan::MENUPAUSE;
     $basic_info = $proinfo[$proid]['content_basic'];
     //更新房源计划信息
     if (Dao_Broker_HzProp::change_prop_status($proid, Const_HzStatus::OUTLINE)) {
         //更新房源状态
         if (Dao_Broker_HzPlan::update_planning($planning[0]['id'], $new_is_valid)) {
             //更新关联关系
             Dao_Broker_HzPlan::add_prop_log($proid, $log_option, $basic_info['userid'], $plan_id, $basic_info['status'], Const_HzStatus::OUTLINE);
             //记房源日志
             if ($basic_info['status'] == Const_HzStatus::ONLINE) {
                 //插入solr队列,房源下线
                 Dao_Broker_HzProp::into_prop_lucene($proid, $basic_info['cityid'], 2);
                 //写日志
                 Dao_Broker_HzProp::ezft_assistant_log($planning[0]['proid'], $basic_info['userid'], Const_HzPlan::SPREAD_TYPE, $basic_info['spread_type']);
                 Dao_Broker_HzProp::add_updown_log($planning[0]['proid'], $plan_id, Const_HzStatus::GOOFFLINE, $log_option);
             }
             $flag_array['status'] = 1;
             return $flag_array;
         }
     }
     $flag_array['msg'] = Const_HzErrorInfo::DATAFAIL;
     return $flag_array;
 }
 /**
  * 创建log
  * @param $logInfo
  */
 private function createLog($logInfo)
 {
     if (!$logInfo) {
         return false;
     }
     $accountId = $logInfo['account_id'];
     //获取用户信息
     if (!($accountInfo = BLL_Payment_Account::getAccountMapping($accountId))) {
         echo 'balbanceLogId=' . $logInfo['id'] . ',获取accountInfo信息失败:$accountId=' . $accountId . PHP_EOL;
         return false;
     }
     $accountInfo = (array) $accountInfo;
     // 初始参数
     $userId = $accountInfo['userId'];
     $createTime = $logInfo['created_time'];
     $logDay = date("Ymd", strtotime($createTime));
     $amount = $logInfo['amount'];
     $inTable = false;
     // 是否写入子表
     $isStatic = false;
     // 是否定价
     $logType = $logInfo['log_type'];
     //只有定价扣费和退费才进子表
     //定价扣费
     if ($logInfo['log_type'] == 2) {
         if (in_array($logInfo['appid'], array(26, 47, 48, 30, 40))) {
             if (in_array($logInfo['appid'], array(30, 40)) && strstr($logInfo['note'], '定价') !== false) {
                 $inTable = true;
                 $isStatic = true;
             } elseif (in_array($logInfo['appid'], array(26, 47, 48))) {
                 $inTable = true;
                 $isStatic = true;
             } else {
                 $logType = 8;
                 //竞价
             }
         } else {
             $logType = 8;
             //竞价
         }
     }
     //退费
     if ($logInfo['log_type'] == 1 && ($logInfo['parentId'] == $logInfo['orderid'] && intval($logInfo['parentId'] > 0)) && $logInfo['account_id'] == $logInfo['payid']) {
         $inTable = true;
         $logType = 7;
     }
     $note = $logInfo['note'];
     // 在线充值
     if (substr($note, 0, strlen('from ')) == 'from ') {
         $note = '在线充值';
     } elseif ($logType == 1 && strpos($note, '返还') !== false) {
         //$note = '活动返还';
     } elseif ($logType == 7) {
         $note = '无效点击扣费返还';
     } elseif ($isStatic) {
         $note = '定价推广消费';
     }
     // 加钱
     if (in_array($logType, array(1, 4, 6, 7))) {
         if (!($broker = Dao_Broker_BrokerInfo::getBrokerInfoByUserId($userId))) {
             echo 'balbanceLogId=' . $logInfo['id'] . ',获取broker信息失败:userid=' . $userId . PHP_EOL;
             return false;
         }
         $cityId = $broker['CITYID'];
         $brokerId = $broker['BROKERID'];
         $isNotify = false;
         if ($logType == 4) {
             $result = $this->getBalance($accountInfo);
             if ($result['status'] == 'ok') {
                 if ($result['data']['balance'] > 0) {
                     $isNotify = true;
                 }
             }
         } else {
             $isNotify = true;
         }
         if ($isNotify) {
             // 通知租房 金浦
             //$this->notifyZufang($brokerId, $amount);//20140626 启用新队列
             //$this->notifyJinpu($brokerId, $amount);//20140626 启用新队列
             // 通知安居客上架
             //if (!Bll_House_AjkHpProSpread::insertProSpreadChange(0, 0, $brokerId, $cityId, 7, '支付中心日志同步:加钱', __CLASS__)) {
             //  echo 'balbanceLogId=' . $logInfo['id'] . '通知安居客上架失败' . PHP_EOL;
             // return false;
             //}
             $ProPlanChangeApiBll = Bll_ProPlanChangeApiBll::get_instance();
             $Result = $ProPlanChangeApiBll->insertProPlanChange(array('broker_id' => $brokerId, 'pro_id' => 0, 'plan_id' => 0, 'type' => 'BROKER_HAVE_MONEY', 'from' => __CLASS__, 'remark' => '支付中心日志同步:加钱;logType:' . $logType, 'site_type' => 4), 0);
             if ($Result['status'] != 'ok') {
                 echo 'balbanceLogId=' . $logInfo['id'] . '通知安居客上架失败,msg:' . $Result['msg'] . PHP_EOL;
             }
         }
     }
     // 账户钱变多, 通知生命周期队列
     if ($logType == 1) {
         //推广动作触发表
         if (!Bll_Broker_User::insertLifeQueen(array('BrokerId' => $brokerId, 'Type' => 2))) {
             echo 'balbanceLogId=' . $logInfo['id'] . '通知生命周期队列失败' . PHP_EOL;
         }
     }
     $isHaved = false;
     // 是否插入过
     if ($inTable) {
         if (Bll_Broker_BrokerAccountParticulars::getBalanceLogSubByAcenterId($logInfo['id'], $logDay)) {
             $isHaved = true;
         }
     } else {
         if (Bll_Broker_BrokerAccountParticulars::getBalanceLogByAcenterId($logInfo['id'], $logDay)) {
             $isHaved = true;
         }
     }
     // 重跑, 如果有记录则跳过
     if (!$isHaved) {
         $result = null;
         if ($inTable) {
             $result = (array) Bll_Broker_BrokerAccountParticulars::getBalanceLogWithCache($userId, $logType, $logDay);
         }
         if ($result) {
             //消费和退费
             $id = $result['id'];
             if ($createTime >= $result['createTimeEnd']) {
                 $createdTimeEnd = $createTime;
             } else {
                 $createdTimeEnd = date('Y-m-d H:i:s');
             }
             // 更新账户日志
             if (!Bll_Broker_BrokerAccountParticulars::updateBalanceLogById($id, $amount, $note, $createdTimeEnd)) {
                 echo 'balbanceLogId=' . $logInfo['id'] . ',账户日志更新失败' . PHP_EOL;
                 return false;
             }
         } else {
             // 新增账户日志
             if (!$userId) {
                 echo '+++++userid为空:';
                 var_dump($userId);
                 echo PHP_EOL . '支付中心账户日志id:' . $logInfo['id'] . ';获取$accountInfo为:';
                 var_dump($accountInfo);
                 echo PHP_EOL;
             }
             if (!($id = Bll_Broker_BrokerAccountParticulars::insertBalanceLog($userId, $amount, $logType, $note, $logDay, $createTime, $logInfo['id']))) {
                 echo 'balbanceLogId=' . $logInfo['id'] . ',账户日志新增失败' . PHP_EOL;
                 return false;
             }
         }
     } else {
         if (!$inTable) {
             echo 'balbanceLogId=' . $logInfo['id'] . ',已经存在表中' . PHP_EOL;
             return true;
         }
     }
     if ($inTable) {
         //消费和退费
         // 重跑 判断子表是否有, 有则直接返回
         if ($isHaved) {
             echo 'balbanceLogId=' . $logInfo['id'] . ',已经存在子表中' . PHP_EOL;
         }
         // 插入子表
         if (!($id = Bll_Broker_BrokerAccountParticulars::insertBalanceLogSub($id, $userId, $accountId, $amount, $logType, $logInfo['note'], $createTime, $logInfo['id']))) {
             echo 'balbanceLogId=' . $logInfo['id'] . ',账户子日志新增失败' . PHP_EOL;
         }
     }
 }
Esempio n. 7
0
 /**
  * 处理post
  * @param $esfProIds
  * @param $zfProIds
  * @param $getBrokerResActivity
  */
 private function doPost($esfProIds, $zfProIds, $getBrokerResActivity)
 {
     $insertEsfData = array();
     $insertZfData = array();
     //二手房
     if (!empty($esfProIds)) {
         $esfProIdsAll = $this->getProIdsByBrokerId(Bll_Combo_HouseRelation::SITE_TYPE_AJK);
         //过滤不属于该经济人的推广房源和已经参加活动的房源
         foreach ($esfProIds as $key => $val) {
             if (!in_array($val, $esfProIdsAll)) {
                 unset($esfProIds[$key]);
             }
             if (!empty($getBrokerResActivity[$val])) {
                 unset($esfProIds[$key]);
             }
         }
         if (!empty($esfProIds)) {
             $esfProInfos = Bll_House_EsfHouse::getHouseInfo($esfProIds, $this->cityId);
             foreach ($esfProInfos as $key => $val) {
                 $insertEsfData[] = array('proId' => $val['proId'], 'brokerId' => $this->brokerId, 'cityId' => $this->cityId, 'siteType' => Bll_Activity_Res_ProInfo::SITE_TYPE_AJK, 'proContent' => json_encode(Bll_Activity_Res_ProInfo::getEsfShowInfo($val)), 'addTime' => time());
             }
         }
     }
     //租房
     if (!empty($zfProIds)) {
         $zfProIdsAll = $this->getProIdsByBrokerId(Bll_Combo_HouseRelation::SITE_TYPE_HZ);
         foreach ($zfProIds as $key => $val) {
             if (!in_array($val, $zfProIdsAll)) {
                 unset($zfProIds[$key]);
             }
             if (!empty($getBrokerResActivity[$val])) {
                 unset($zfProIds[$key]);
             }
         }
         if (!empty($zfProIds)) {
             $zfProInfos = Bll_House_HzPro::getInstance()->getBrokerHzProInfo($zfProIds, $this->cityId);
             //房源主表信息
             $propMainInfo = Bll_House_HzPro::getInstance()->getHzProInfoByIds($zfProIds);
             $propMainNew = array();
             foreach ($propMainInfo as $val) {
                 $propMainNew[$val['propId']]['contentBasic'] = json_decode($val['contentBasic'], true);
                 $propMainNew[$val['propId']]['contentOther'] = json_decode($val['contentOther'], true);
             }
             foreach ($zfProInfos as $key => $val) {
                 $insertZfData[] = array('proId' => $val['proid'], 'brokerId' => $this->brokerId, 'cityId' => $this->cityId, 'siteType' => Bll_Activity_Res_ProInfo::SITE_TYPE_HZ, 'proContent' => json_encode(Bll_Activity_Res_ProInfo::getZfShowInfo($val, $propMainNew)), 'addTime' => time());
             }
         }
     }
     //合并
     $insertData = array_merge($insertEsfData, $insertZfData);
     foreach ($insertData as $proInfo) {
         Bll_Activity_Res_ProInfo::insertBrokerResActivityPropInfo($proInfo);
         $ProPlanChangeApiBll = Bll_ProPlanChangeApiBll::get_instance();
         $ProPlanChangeApiBll->insertProPlanChange(array('broker_id' => $this->brokerId, 'pro_id' => $proInfo['proId'], 'type' => 'ACTIVITY_RES_ADD', 'from' => __CLASS__, 'remark' => '房源季用户参加活动房源', 'site_type' => $proInfo['siteType']), 0);
     }
 }
Esempio n. 8
0
 /**
  * 把房源从定价推广中移除
  * @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' => '操作成功');
 }