public static function &getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; // 判断经纪人是否存在 $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$broker) { throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId); } //区域板块 $saleBlockList = Model_Mobile_CustomerSaleRange::getBrokerIdRange($brokerId, 1, 3); $saleBlock = array(); if (!empty($saleBlockList)) { foreach ($saleBlockList as $key => $val) { $saleBlock[$key] = array('areaId' => $val['areaId'], 'area' => $val['area'], 'blockId' => $val['blockId'], 'block' => $val['block'], 'mapx' => $val['mapx'], 'mapy' => $val['mapy']); } } //主营小区 $saleCommunityList = Model_Mobile_CustomerSaleRange::getBrokerIdRange($brokerId, 2, 10); $saleCommunity = array(); if (!empty($saleCommunityList)) { foreach ($saleCommunityList as $key => $val) { $saleCommunity[$key] = array('communityId' => $val['communityId'], 'communityName' => $val['communityName']); } } //代理新盘 $newCommunityList = Model_Mobile_CustomerNewPropRange::getBrokerIdRange($brokerId, 10); $newCommunity = array(); if (!empty($newCommunityList)) { foreach ($newCommunityList as $key => $val) { $newCommunity[$key] = array('loupanId' => $val['loupanId'], 'loupanName' => $val['loupanName']); } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('saleBlock' => array_values($saleBlock), 'saleCommunity' => array_values($saleCommunity), 'newCommunity' => array_values($newCommunity))); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; // 判断经纪人是否存在 $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$broker) { throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId); } //区域板块 $saleBlockList = Model_Mobile_CustomerSaleRange::getBrokerIdRange($brokerId, 1, 1); //主营小区 $saleCommunityList = Model_Mobile_CustomerSaleRange::getBrokerIdRange($brokerId, 2, 1); //代理新盘 $newCommunityList = Model_Mobile_CustomerNewPropRange::getBrokerIdRange($brokerId, 1); if ($saleBlockList || $saleCommunityList || $newCommunityList) { $randed = 1; } else { $randed = 0; } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('randed' => $randed)); }
/** * @param $data * @return mixed */ public function insertCustomerRange($data) { return Model_Mobile_CustomerSaleRange::getInstance()->insertData($data); }
/** * 添加主营小区 * @param $brokerId * @param $saleCommunityData * @return bool */ protected function doSaleCommunity($brokerId, $saleCommunityData) { $saleCommunityList = Model_Mobile_CustomerSaleRange::getBrokerIdRange($brokerId, 2); $saleCommunity = array(); if (!empty($saleCommunityList)) { foreach ($saleCommunityList as $key => $val) { $saleCommunity[$val['communityId']] = $val; } } $insertData = array(); if (!empty($saleCommunityData) && is_array($saleCommunityData)) { if (count($saleCommunityData) > 10) { array_splice($saleCommunityData, 10); } foreach ($saleCommunityData as $key => $val) { if ($saleCommunity[$val['communityId']]) { //unset已经存在的,剩余数据删除 unset($saleCommunity[$val['communityId']]); } else { //插入的数据 $insertData[] = $val; } } } if (!empty($saleCommunity)) { $deleteDataId = array(); foreach ($saleCommunity as $key => $val) { $deleteDataId[] = $val['id']; } } if (!empty($deleteDataId)) { Model_Mobile_CustomerSaleRange::delRangeByBrokerId($brokerId, 2, $deleteDataId); } $flag = true; foreach ($insertData as $val) { $data = array(); $data['communityId'] = $val['communityId']; $data['communityName'] = $val['communityName']; $data['type'] = 2; $data['cityId'] = $this->cityId; $data['brokerId'] = $brokerId; $data['createTime'] = time(); $rs = Bll_CustomerRush_Customer::getInstance()->insertCustomerRange($data); if (!$rs) { $flag = false; } } return $flag; }