/** * 添加代理新盘 * @param $brokerId * @param $newCommunityData * @return bool */ protected function doNewCommunity($brokerId, $newCommunityData) { $newCommunityList = Model_Mobile_CustomerNewPropRange::getBrokerIdRange($brokerId); $newCommunity = array(); if (!empty($newCommunityList)) { foreach ($newCommunityList as $key => $val) { $newCommunity[$val['loupanId']] = $val; } } $insertData = array(); if (!empty($newCommunityData) && is_array($newCommunityData)) { if (count($newCommunityData) > 10) { array_splice($newCommunityData, 10); } foreach ($newCommunityData as $key => $val) { if ($newCommunity[$val['loupanId']]) { //unset已经存在的,剩余数据删除 unset($newCommunity[$val['loupanId']]); } else { //插入数据 $insertData[] = $val; } } } if (!empty($newCommunity)) { $deleteDataId = array(); foreach ($newCommunity as $key => $val) { $deleteDataId[] = $val['id']; } } if (!empty($deleteDataId)) { Model_Mobile_CustomerNewPropRange::delRangeByBrokerId($brokerId, $deleteDataId); } $flag = true; foreach ($insertData as $val) { $data = array(); $data['loupanId'] = $val['loupanId']; $data['loupanName'] = $val['loupanName']; $data['cityId'] = $this->cityId; $data['brokerId'] = $brokerId; $data['createTime'] = time(); $rs = Bll_CustomerRush_Customer::getInstance()->insertCustomerNewCommunityRange($data); if (!$rs) { $flag = false; } } return $flag; }