maindb-procedure-1.sql 182 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303
  1. USE [MainDB]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[agentAddLimitLogin] Script Date: 2018/12/13 19:03:19 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE PROCEDURE [dbo].[agentAddLimitLogin]
  9. (
  10. @Key AS VARCHAR(100)
  11. )
  12. AS
  13. --INSERT INTO procLog SELECT 'agentAddLimitLogin', '', GETDATE()
  14. BEGIN
  15. --sean update at 2015-4-22, update the VerifyInfo text
  16. --INSERT bsCpStatus(cpMainId, StatusId, VerifyInfo, VerifyMan, VerifyDate)
  17. --SELECT ID, 9, '由于保险公司被投诉比例上升迅速,我们暂时对保险公司数量进行限制。只有交费企业会员才能正常使用,如需办理交费会员请致电网站客服400-626-5151联系相关事宜,谢谢合作!您的会员编号是' + LTRIM(STR(ID)), 1, GETDATE()
  18. INSERT bsCpStatus(cpMainId, StatusId, VerifyInfo, VerifyMan, VerifyDate)
  19. SELECT ID, 9, '您好!您在' + (SELECT TOP 1 WebSiteName FROM dcProvince WHERE Id = dcProvinceId) +
  20. '的帐号需要付费使用,详情可致电4006265151联系' + CASE WHEN ConsultantId BETWEEN 600 AND 699 THEN '5' ELSE '6' END + LTRIM(STR(ISNULL(ConsultantId, 0))) + '号顾问,祝您招聘顺利!', 1, GETDATE()
  21. FROM cpMain WITH(NOLOCK) WHERE HasLicence = 1
  22. AND Name LIKE '%' + @Key + '%'
  23. AND IsLimitLogin < 9
  24. AND MemberType < 3
  25. IF GETDATE() < '2017-8-26'
  26. UPDATE cpMain
  27. SET IsLimitLogin = 9
  28. WHERE HasLicence = 1
  29. AND Name LIKE '%' + @Key + '%'
  30. AND IsLimitLogin < 9
  31. AND MemberType < 3
  32. ELSE
  33. UPDATE cpMain
  34. SET IsLimitLogin = 9,
  35. RealName = 6
  36. WHERE HasLicence = 1
  37. AND Name LIKE '%' + @Key + '%'
  38. AND IsLimitLogin < 9
  39. AND MemberType < 3
  40. END
  41. GO
  42. /****** Object: StoredProcedure [dbo].[BackDataUpdate] Script Date: 2018/12/13 19:03:20 ******/
  43. SET ANSI_NULLS ON
  44. GO
  45. SET QUOTED_IDENTIFIER ON
  46. GO
  47. CREATE PROCEDURE [dbo].[BackDataUpdate]
  48. (
  49. @ManagerID INT,
  50. @Pass INT
  51. )
  52. AS
  53. SET NOCOUNT ON
  54. BEGIN TRAN
  55. DECLARE @ID AS INT
  56. BEGIN TRY
  57. SET @ID=0
  58. SELECT TOP 1 @ID=ID FROM backdata WITH(NOLOCK) WHERE
  59. ManagerID=@ManagerID AND CountDate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
  60. IF @ID=0
  61. INSERT INTO backdata(ManagerID,CountDate) VALUES(
  62. @ManagerID,YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
  63. )
  64. IF @Pass=1
  65. UPDATE backdata SET resume_pass=resume_pass + 1 WHERE
  66. ManagerID=@ManagerID AND CountDate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
  67. IF @Pass=10
  68. UPDATE backdata SET resume_nopass=resume_nopass + 1 WHERE
  69. ManagerID=@ManagerID AND CountDate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
  70. END TRY
  71. BEGIN CATCH
  72. GOTO ERR
  73. END CATCH
  74. COMMIT TRAN
  75. RETURN 1
  76. ERR:
  77. BEGIN
  78. ROLLBACK TRAN
  79. RETURN 0
  80. END
  81. GO
  82. /****** Object: StoredProcedure [dbo].[bpActivationCpDetailByCountSelect] Script Date: 2018/12/13 19:03:20 ******/
  83. SET ANSI_NULLS ON
  84. GO
  85. SET QUOTED_IDENTIFIER ON
  86. GO
  87. --创建人 Andy
  88. --时间 2015-01-23
  89. --按照条件查询企业激活个数
  90. --bpActivationCpDetailByCountSelect 1,1,'','2013-1-31 13:41:00','2013-1-31 13:41:00'
  91. CREATE PROCEDURE [dbo].[bpActivationCpDetailByCountSelect]
  92. (
  93. @AddManOld INT,
  94. @AddManNew INT,
  95. @RegDateOld VARCHAR(10),
  96. @RegDateNewBegin VARCHAR(10),
  97. @RegDateNewEnd VARCHAR(10)
  98. )
  99. AS
  100. BEGIN
  101. DECLARE @SQL VARCHAR(1000)
  102. SET @SQL = 'SELECT COUNT(*) allCount FROM LogDb..ActivationCpDetail WHERE 1=1'
  103. IF @AddManOld > 0
  104. SET @SQL = @SQL + ' And AddManOld = ' + LTRIM(STR(@AddManOld))
  105. IF @AddManNew > 0
  106. SET @SQL = @SQL + ' And AddManNew = ' + LTRIM(STR(@AddManNew))
  107. IF LEN(@RegDateOld) > 0
  108. BEGIN
  109. DECLARE @RegDateOldBegin DATETIME
  110. DECLARE @RegDateOldEnd DATETIME
  111. SET @RegDateOldBegin = CONVERT(DATETIME, @RegDateOld, 120)
  112. SET @RegDateOldEnd = @RegDateOldBegin + 1
  113. SET @SQL = @SQL + ' And RegDateOld BETWEEN ''' + @RegDateOld + ''' AND ''' + CONVERT(VARCHAR(10), @RegDateOldEnd + 1, 120) + ''''
  114. END
  115. IF LEN(@RegDateNewBegin) > 0
  116. SET @SQL = @SQL + ' And RegDateNew >= ''' + CONVERT(VARCHAR(10), @RegDateNewBegin, 120) + ''''
  117. IF LEN(@RegDateNewEnd) > 0
  118. SET @SQL = @SQL + ' And RegDateNew <= ''' + CONVERT(VARCHAR(10), @RegDateNewEnd, 120) + ''''
  119. --PRINT(@SQL)
  120. EXEC (@SQL)
  121. END
  122. GO
  123. /****** Object: StoredProcedure [dbo].[bpActivationCpDetailSelect] Script Date: 2018/12/13 19:03:20 ******/
  124. SET ANSI_NULLS ON
  125. GO
  126. SET QUOTED_IDENTIFIER ON
  127. GO
  128. --创建人 Andy
  129. --时间 2015-01-23
  130. --按照条件查询企业激活日志
  131. --bpActivationCpDetailSelect 1,1,'2013-1-31 13:41:00','','2013-1-31 13:41:00'
  132. CREATE PROCEDURE [dbo].[bpActivationCpDetailSelect]
  133. (
  134. @AddManOld INT,
  135. @AddManNew INT,
  136. @RegDateOld VARCHAR(10),
  137. @RegDateNewBegin VARCHAR(10),
  138. @RegDateNewEnd VARCHAR(10)
  139. )
  140. AS
  141. BEGIN
  142. DECLARE @SQL VARCHAR(1000)
  143. SET @SQL = '
  144. SELECT a.*,b.Name NameOld, c.Name NameNew
  145. FROM LogDb..ActivationCpDetail a
  146. JOIN ManagerUser b ON a.addmanold = b.id
  147. JOIN ManagerUser c ON a.addmannew = c.id
  148. Where 1 = 1'
  149. IF @AddManOld > 0
  150. SET @SQL = @SQL + ' And AddManOld = ' + LTRIM(STR(@AddManOld))
  151. IF @AddManNew > 0
  152. SET @SQL = @SQL + ' And AddManNew = ' + LTRIM(STR(@AddManNew))
  153. IF LEN(@RegDateOld) > 0
  154. BEGIN
  155. DECLARE @RegDateOldBegin DATETIME
  156. DECLARE @RegDateOldEnd DATETIME
  157. SET @RegDateOldBegin = CONVERT(DATETIME, @RegDateOld, 120)
  158. SET @RegDateOldEnd = @RegDateOldBegin + 1
  159. SET @SQL = @SQL + ' And RegDateOld BETWEEN ''' + @RegDateOld + ''' AND ''' + CONVERT(VARCHAR(10), @RegDateOldEnd + 1, 120) + ''''
  160. END
  161. IF LEN(@RegDateNewBegin) > 0
  162. SET @SQL = @SQL + ' And RegDateNew >= ''' + CONVERT(VARCHAR(10), @RegDateNewBegin, 120) + ''''
  163. IF LEN(@RegDateNewEnd) > 0
  164. SET @SQL = @SQL + ' And RegDateNew <= ''' + CONVERT(VARCHAR(10), @RegDateNewEnd, 120) + ''''
  165. SET @SQL = @SQL + ' Order By ID DESC'
  166. --PRINT(@SQL)
  167. EXEC (@SQL)
  168. END
  169. GO
  170. /****** Object: StoredProcedure [dbo].[bpActivationCvDetailByCountSelect] Script Date: 2018/12/13 19:03:20 ******/
  171. SET ANSI_NULLS ON
  172. GO
  173. SET QUOTED_IDENTIFIER ON
  174. GO
  175. --创建人 Andy
  176. --时间 2015-01-23
  177. --按照条件个人激活的个数
  178. --bpActivationCvDetailByCountSelect 0,0,'2013-1-31','2013-1-31 13:41:00','2013-3-31 13:41:00'
  179. CREATE PROCEDURE [dbo].[bpActivationCvDetailByCountSelect]
  180. (
  181. @AddManOld INT,
  182. @AddManNew INT,
  183. @RegDateOld VARCHAR(10),
  184. @RegDateNewBegin VARCHAR(10),
  185. @RegDateNewEnd VARCHAR(10)
  186. )
  187. AS
  188. BEGIN
  189. DECLARE @SQL VARCHAR(1000)
  190. SET @SQL = '
  191. SELECT COUNT(*) allCount FROM LogDb..ActivationCvDetail WHERE 1=1 '
  192. IF @AddManOld > 0
  193. SET @SQL = @SQL + ' And AddManOld = ' + LTRIM(STR(@AddManOld))
  194. IF @AddManNew > 0
  195. SET @SQL = @SQL + ' And AddManNew = ' + LTRIM(STR(@AddManNew))
  196. IF LEN(@RegDateOld) > 0
  197. BEGIN
  198. DECLARE @RegDateOldBegin DATETIME
  199. DECLARE @RegDateOldEnd DATETIME
  200. SET @RegDateOldBegin = CONVERT(DATETIME, @RegDateOld, 120)
  201. SET @RegDateOldEnd = @RegDateOldBegin + 1
  202. SET @SQL = @SQL + ' And RegDateOld BETWEEN ''' + @RegDateOld + ''' AND ''' + CONVERT(VARCHAR(10), @RegDateOldEnd + 1, 120) + ''''
  203. END
  204. IF LEN(@RegDateNewBegin) > 0
  205. SET @SQL = @SQL + ' And RegDateNew >= ''' + @RegDateNewBegin + ''''
  206. IF LEN(@RegDateNewEnd) > 0
  207. SET @SQL = @SQL + ' And RegDateNew <= ''' + @RegDateNewEnd + ''''
  208. --PRINT(@SQL)
  209. EXEC (@SQL)
  210. END
  211. GO
  212. /****** Object: StoredProcedure [dbo].[bpActivationCvDetailSelect] Script Date: 2018/12/13 19:03:21 ******/
  213. SET ANSI_NULLS ON
  214. GO
  215. SET QUOTED_IDENTIFIER ON
  216. GO
  217. --创建人 Andy
  218. --时间 2015-01-23
  219. --按照条件查询个人激活日志
  220. --bpActivationCvDetailSelect 0,0,'2013-1-31','2013-1-31 13:41:00','2013-3-31 13:41:00'
  221. CREATE PROCEDURE [dbo].[bpActivationCvDetailSelect]
  222. (
  223. @AddManOld INT,
  224. @AddManNew INT,
  225. @RegDateOld VARCHAR(10),
  226. @RegDateNewBegin VARCHAR(10),
  227. @RegDateNewEnd VARCHAR(10)
  228. )
  229. AS
  230. BEGIN
  231. DECLARE @SQL VARCHAR(1000)
  232. SET @SQL = '
  233. SELECT TOP 2000 a.*, b.Name NameOld, c.Name NameNew
  234. FROM LogDb..ActivationCvDetail a
  235. JOIN ManagerUser b ON a.addmanold = b.id
  236. JOIN ManagerUser c ON a.addmannew = c.id
  237. Where 1 = 1 '
  238. IF @AddManOld > 0
  239. SET @SQL = @SQL + ' And AddManOld = ' + LTRIM(STR(@AddManOld))
  240. IF @AddManNew > 0
  241. SET @SQL = @SQL + ' And AddManNew = ' + LTRIM(STR(@AddManNew))
  242. IF LEN(@RegDateOld) > 0
  243. BEGIN
  244. DECLARE @RegDateOldBegin DATETIME
  245. DECLARE @RegDateOldEnd DATETIME
  246. SET @RegDateOldBegin = CONVERT(DATETIME, @RegDateOld, 120)
  247. SET @RegDateOldEnd = @RegDateOldBegin + 1
  248. SET @SQL = @SQL + ' And RegDateOld BETWEEN ''' + @RegDateOld + ''' AND ''' + CONVERT(VARCHAR(10), @RegDateOldEnd + 1, 120) + ''''
  249. END
  250. IF LEN(@RegDateNewBegin) > 0
  251. SET @SQL = @SQL + ' And RegDateNew >= ''' + @RegDateNewBegin + ''''
  252. IF LEN(@RegDateNewEnd) > 0
  253. SET @SQL = @SQL + ' And RegDateNew <= ''' + @RegDateNewEnd + ''''
  254. SET @SQL = @SQL + ' Order By ID DESC'
  255. --PRINT(@SQL)
  256. EXEC (@SQL)
  257. END
  258. GO
  259. /****** Object: StoredProcedure [dbo].[bpActivationLogBySumSelect] Script Date: 2018/12/13 19:03:21 ******/
  260. SET ANSI_NULLS ON
  261. GO
  262. SET QUOTED_IDENTIFIER ON
  263. GO
  264. --bpActivationLogBySumSelect 1,'',''
  265. --创建人 Andy
  266. --时间 2015-01-23
  267. --信息员注册信息统计
  268. create PROCEDURE [dbo].[bpActivationLogBySumSelect]
  269. (
  270. @AddMan INT,
  271. @CountDateBegin VARCHAR(8), --格式:20120101
  272. @CountDateEnd VARCHAR(8) --格式:20120101
  273. )
  274. AS
  275. BEGIN
  276. SET @CountDateBegin = dbo.SafeSql(@CountDateBegin)
  277. SET @CountDateEnd = dbo.SafeSql(@CountDateEnd)
  278. DECLARE @SQL VARCHAR(1000)
  279. SET @SQL = '
  280. SELECT SUM(CvCount) CvCount, SUM(AllPerson) AllPerson, SUM(CpCount) CpCount, SUM(AllCompany) AllCompany
  281. FROM LogDb..ActivationLog a
  282. JOIN (
  283. SELECT CountDate, InfoManager_Id, SUM(Companyregnum_Our) AllCompany, SUM(Personregnum_Our) AllPerson
  284. FROM info_datereport
  285. GROUP BY CountDate, InfoManager_Id) b
  286. ON a.Countdate = b.Countdate AND a.AddMan = b.InfoManager_Id
  287. JOIN ManagerUser c
  288. ON a.AddMan = c.id
  289. WHERE 1 = 1 '
  290. IF @AddMan > 0
  291. SET @SQL = @SQL + ' And AddMan = ' + LTRIM(STR(@AddMan))
  292. IF LEN(@CountDateBegin) > 0
  293. SET @SQL = @SQL + ' And a.CountDate >= ''' + @CountDateBegin + ''''
  294. IF LEN(@CountDateEnd) > 0
  295. SET @SQL = @SQL + ' And a.CountDate <= ''' + @CountDateEnd + ''''
  296. --PRINT(@SQL)
  297. EXEC (@SQL)
  298. END
  299. GO
  300. /****** Object: StoredProcedure [dbo].[bpActivationLogSelect] Script Date: 2018/12/13 19:03:21 ******/
  301. SET ANSI_NULLS ON
  302. GO
  303. SET QUOTED_IDENTIFIER ON
  304. GO
  305. --bpActivationLogByAddManSelect 0,'20150111','20130131'
  306. --创建人 Andy
  307. --时间 2015-01-23
  308. --信息员注册信息查询
  309. create PROCEDURE [dbo].[bpActivationLogSelect]
  310. (
  311. @AddMan INT,
  312. @CountDateBegin VARCHAR(8), --格式:20120101
  313. @CountDateEnd VARCHAR(8) --格式:20120101
  314. )
  315. AS
  316. BEGIN
  317. SET @CountDateBegin = dbo.SafeSql(@CountDateBegin)
  318. SET @CountDateEnd = dbo.SafeSql(@CountDateEnd)
  319. DECLARE @SQL VARCHAR(1000)
  320. SET @SQL = '
  321. SELECT TOP 2000 a.*, b.*, c.name
  322. FROM LogDb..ActivationLog a
  323. JOIN (
  324. SELECT CountDate, InfoManager_Id, SUM(Companyregnum_Our) AllCompany, SUM(Personregnum_Our) AllPerson
  325. FROM info_datereport
  326. GROUP BY CountDate, InfoManager_Id) b
  327. ON a.Countdate = b.Countdate AND a.AddMan = b.InfoManager_Id
  328. JOIN ManagerUser c
  329. ON a.Addman=c.id WHERE 1 = 1 '
  330. IF @AddMan > 0
  331. SET @SQL = @SQL + ' And AddMan = ' + LTRIM(STR(@AddMan))
  332. IF LEN(@CountDateBegin) > 0
  333. SET @SQL = @SQL + ' And a.CountDate >= ''' + @CountDateBegin + ''''
  334. IF LEN(@CountDateEnd) > 0
  335. SET @SQL = @SQL + ' And a.CountDate <= ''' + @CountDateEnd + ''''
  336. SET @SQL = @SQL + ' ORDER BY a.CountDate DESC, Addman ASC'
  337. --PRINT(@SQL)
  338. EXEC (@SQL)
  339. END
  340. GO
  341. /****** Object: StoredProcedure [dbo].[bpAdverprojectByCompany_DeletedSelect] Script Date: 2018/12/13 19:03:21 ******/
  342. SET ANSI_NULLS ON
  343. GO
  344. SET QUOTED_IDENTIFIER ON
  345. GO
  346. --###########################
  347. --创建时间:2014.12.10
  348. --创建人:Nick
  349. --说明:删除单位发送通知
  350. --###########################
  351. CREATE PROCEDURE [dbo].[bpAdverprojectByCompany_DeletedSelect]
  352. (
  353. @cpMainID INT
  354. )
  355. AS
  356. INSERT INTO procLog SELECT 'bpAdverprojectByCompany_DeletedSelect', '', GETDATE()
  357. BEGIN
  358. SELECT TOP 10 b.ProvinceName, b.WebSiteName, b.ID, c.HandleMan
  359. FROM adverproject a, dcprovince b, Company_Deleted c
  360. WHERE a.province_id = b.id
  361. AND a.Companyid = c.id
  362. AND a.Endtime > GETDATE()
  363. AND CompanyId = @cpMainID
  364. END
  365. GO
  366. /****** Object: StoredProcedure [dbo].[bpAdverProjectSubmitUpdate] Script Date: 2018/12/13 19:03:21 ******/
  367. SET ANSI_NULLS ON
  368. GO
  369. SET QUOTED_IDENTIFIER ON
  370. GO
  371. -- =============================================
  372. -- Author: <Mice 123>
  373. -- Create date: <2014-11-20>
  374. -- Description: <保存广告计划管理记录>
  375. -- Edit:2014-11-21 Mice 增加参数@innews,@imagefilesmall
  376. -- 修改 @pids 为 varchar类型, 传入参数可为(31,32,33,36,83)
  377. --2018-04-16 Carl 修改 增添字段 isSelf
  378. -- =============================================
  379. CREATE PROCEDURE [dbo].[bpAdverProjectSubmitUpdate]
  380. (
  381. @id INT,
  382. @pids varchar(200),
  383. @type INT,
  384. @innews INT,
  385. @begintime VARCHAR(50),
  386. @endtime VARCHAR(50),
  387. @width INT,
  388. @height INT,
  389. @imagefile VARCHAR(50),
  390. @imagefilesmall VARCHAR(50),
  391. @orderby INT,
  392. @url VARCHAR(200),
  393. @companyid INT,
  394. @caorderid INT ,
  395. @description VARCHAR(200),
  396. @remarks VARCHAR(200),
  397. @addman INT,
  398. @isSelf BIT
  399. )
  400. AS
  401. INSERT INTO procLog SELECT 'bpAdverProjectSubmitUpdate', '', GETDATE()
  402. BEGIN TRAN
  403. BEGIN TRY
  404. DECLARE @result AS INT
  405. SET @result=0
  406. IF @companyid > 0
  407. BEGIN
  408. IF NOT EXISTS( SELECT 'X' FROM MAINDB..cpmain WITH(NOLOCK) WHERE ID=@companyid )
  409. BEGIN
  410. SET @result = -1 --找不到相关公司ID
  411. GOTO ERR
  412. END
  413. END
  414. IF @caorderid > 0
  415. BEGIN
  416. IF NOT EXISTS( SELECT 'X' FROM MAINDB..caOrder WITH(NOLOCK) WHERE ordertype=4 AND opendate IS NULL AND id= @caorderid )
  417. BEGIN
  418. SET @result=-2 --找不到相关订单号,或者订单类型不对,或者订单已经开通
  419. GOTO ERR
  420. END
  421. END
  422. IF Len(@url)=0
  423. SET @url = NULL
  424. IF @companyid = 0
  425. SET @companyid = NULL
  426. IF @caorderid = 0
  427. SET @caorderid = NULL
  428. IF Len(@description)=0
  429. SET @description = NULL
  430. IF @type <> 16
  431. SET @innews = NULL
  432. IF @type <> 14
  433. SET @imagefilesmall = NULL
  434. IF @width = 0
  435. SET @width = NULL
  436. IF @height = 0
  437. SET @height = NULL
  438. --保存
  439. IF @id = 0 --新增保存
  440. BEGIN
  441. INSERT INTO maindb..adverproject ([type],valid, innews, province_id,begintime,endtime,width,height,imagefile,orderby,url,companyid,caorderid,[description],remarks,addman,ImageFileSmall,IsSelf)
  442. SELECT @type, 1, @innews, a, @begintime,@endtime,@width,@height,@imagefile,@orderby,@url,@companyid,@caorderid,@description,@remarks,@addman,@imagefilesmall,@isSelf FROM dbo.fnsplit(@pids,',')
  443. IF @caorderid IS NOT NULL
  444. BEGIN
  445. --修改订单表的开始时间和结束时间
  446. UPDATE maindb..caOrder SET OpenDate=GetDate(),OpenMan=@addman, BeginDate=@begintime, EndDate=@endtime WHERE ID=@caorderid
  447. DECLARE @Paid AS INT
  448. SELECT @Paid = Paid FROM maindb..caOrder WITH(NOLOCK) WHERE id = @caorderid
  449. IF @Paid = 0 --如果金额为0则自动款到账
  450. UPDATE maindb..caOrder SET ReceiveDate=GetDate(),ReceiveMan = @addman WHERE id = @caorderid
  451. END
  452. END
  453. ELSE --修改保存
  454. BEGIN
  455. UPDATE maindb..adverproject SET begintime=@begintime, endtime=@endtime, imagefile=@imagefile, remarks=@remarks, province_id=@pids,width=@width, height=@height, orderby=@orderby, url=@url, companyid=@companyid, [description]=@description,ImageFileSmall=@imagefilesmall,IsSelf=@isSelf WHERE id=@id
  456. END
  457. END TRY
  458. BEGIN CATCH
  459. GOTO ERR
  460. END CATCH
  461. COMMIT TRAN
  462. RETURN 1
  463. ERR:
  464. BEGIN
  465. ROLLBACK TRAN
  466. RETURN @result
  467. END
  468. GO
  469. /****** Object: StoredProcedure [dbo].[bpAgentIPSelect] Script Date: 2018/12/13 19:03:21 ******/
  470. SET ANSI_NULLS ON
  471. GO
  472. SET QUOTED_IDENTIFIER ON
  473. GO
  474. --#####################################################
  475. --创建时间:2015.09.08
  476. --创建人:Nick
  477. --说明:AgentIP
  478. --#####################################################
  479. create PROCEDURE [dbo].[bpAgentIPSelect]
  480. AS
  481. BEGIN
  482. SELECT * FROM agentip WITH(NOLOCK) ORDER BY adddate DESC
  483. END
  484. GO
  485. /****** Object: StoredProcedure [dbo].[bpAnswerByIdIndexSelect] Script Date: 2018/12/13 19:03:22 ******/
  486. SET ANSI_NULLS ON
  487. GO
  488. SET QUOTED_IDENTIFIER ON
  489. GO
  490. --根据问题id 获取答题人数----------------
  491. --增加人Harry ---------------------------
  492. --增加时间:2015-1-28--------------------
  493. CREATE PROCEDURE [dbo].[bpAnswerByIdIndexSelect]
  494. (
  495. @id INT,
  496. @index INT
  497. )
  498. AS
  499. BEGIN
  500. SELECT COUNT(1) cnt
  501. FROM MainDb..Answer WITH(NOLOCK)
  502. WHERE questionid = @id
  503. AND EXISTS(
  504. SELECT 'x'
  505. FROM dbo.fnSplit(answer, ',')
  506. WHERE LTRIM(a) = @index
  507. )
  508. END
  509. GO
  510. /****** Object: StoredProcedure [dbo].[bpAnswerByIdManIdSelect] Script Date: 2018/12/13 19:03:22 ******/
  511. SET ANSI_NULLS ON
  512. GO
  513. SET QUOTED_IDENTIFIER ON
  514. GO
  515. --检查是否完成了问卷调查-----------------
  516. --增加人Harry ---------------------------
  517. --增加时间:2015-1-28--------------------
  518. CREATE PROCEDURE [dbo].[bpAnswerByIdManIdSelect]
  519. (
  520. @id INT,
  521. @manid INT
  522. )
  523. AS
  524. BEGIN
  525. SELECT TOP 1 *
  526. FROM MainDb..Answer WITH(NOLOCK)
  527. WHERE Questionid = @id
  528. AND ManId = @manid
  529. END
  530. GO
  531. /****** Object: StoredProcedure [dbo].[bpAnswerByIdSelect] Script Date: 2018/12/13 19:03:22 ******/
  532. SET ANSI_NULLS ON
  533. GO
  534. SET QUOTED_IDENTIFIER ON
  535. GO
  536. --根据问题id 获取答案----------------
  537. --增加人Harry ---------------------------
  538. --增加时间:2015-1-28--------------------
  539. CREATE PROCEDURE [dbo].[bpAnswerByIdSelect]
  540. (
  541. @id INT
  542. )
  543. AS
  544. BEGIN
  545. SELECT a.Assist, b.Id, b.Name
  546. FROM MainDb..Answer a WITH(NOLOCK), ManagerUser b WITH(NOLOCK)
  547. WHERE a.Manid = b.Id
  548. AND LEN(a.Assist)>0
  549. AND a.Questionid = @id
  550. END
  551. GO
  552. /****** Object: StoredProcedure [dbo].[bpAnswerByInvestIdSelect] Script Date: 2018/12/13 19:03:22 ******/
  553. SET ANSI_NULLS ON
  554. GO
  555. SET QUOTED_IDENTIFIER ON
  556. GO
  557. --获取调查的参加人数----------------
  558. --增加人Harry -----------------------
  559. --增加时间:2015-1-28---------------
  560. CREATE PROCEDURE [dbo].[bpAnswerByInvestIdSelect]
  561. (
  562. @id INT
  563. )
  564. AS
  565. BEGIN
  566. SELECT TOP 1 COUNT(1) cnt
  567. FROM MainDb..Answer a WITH(NOLOCK), MainDb..Question b WITH(NOLOCK)
  568. WHERE a.QuestionId = b.Id
  569. AND b.InvestId = @id
  570. GROUP BY a.QuestionId
  571. END
  572. GO
  573. /****** Object: StoredProcedure [dbo].[bpAnswerInsert] Script Date: 2018/12/13 19:03:22 ******/
  574. SET ANSI_NULLS ON
  575. GO
  576. SET QUOTED_IDENTIFIER ON
  577. GO
  578. --添加调查问卷回答的内容-----------------
  579. --增加人Harry ---------------------------
  580. --增加时间:2015-1-28--------------------
  581. CREATE PROCEDURE [dbo].[bpAnswerInsert]
  582. (
  583. @answer VARCHAR(20),
  584. @assist NVARCHAR(200),
  585. @questionid INT,
  586. @manid INT
  587. )
  588. AS
  589. BEGIN
  590. INSERT INTO MainDb..Answer (Answer, Assist, Questionid, Manid)
  591. VALUES (@answer, @assist, @questionid, @manid)
  592. END
  593. GO
  594. /****** Object: StoredProcedure [dbo].[bpBackDataByDaySelect] Script Date: 2018/12/13 19:03:23 ******/
  595. SET ANSI_NULLS ON
  596. GO
  597. SET QUOTED_IDENTIFIER ON
  598. GO
  599. CREATE PROCEDURE [dbo].[bpBackDataByDaySelect]
  600. (
  601. @Day VARCHAR(8)
  602. )
  603. AS
  604. BEGIN
  605. SELECT *,
  606. (SELECT COUNT(ID)
  607. FROM bscpstatus
  608. WHERE statusID=9
  609. AND CONVERT(VARCHAR(10), AddDate, 112) = @Day
  610. AND VerifyMan = x.ManagerID
  611. ) limitCount
  612. FROM
  613. (SELECT managerid, SUM(reSUMe_pass) reSUMe_pass, SUM(reSUMe_delete) reSUMe_delete,
  614. SUM(reSUMe_nopass) reSUMe_nopass, SUM(reSUMe_modify) reSUMe_modify, SUM(photo_pass) photo_pass,
  615. SUM(photo_modify) photo_modify, SUM(photo_delete) photo_delete, SUM(companylogo_pass) companylogo_pass,
  616. SUM(companylogo_delete) companylogo_delete, SUM(companyvisual_pass) companyvisual_pass,
  617. SUM(companyvisual_delete) companyvisual_delete, SUM(black) black, SUM(company_modify) company_modify,
  618. SUM(companydelete) companydelete,SUM(Contact_NoCvCount) Contact_NoCvCount,SUM(Contact_NoApplyCount) Contact_NoApplyCount,
  619. SUM(Contact_Count) Contact_Count,SUM(Contact_CvCount) Contact_CvCount,SUM(Contact_ApplyCount) Contact_ApplyCount
  620. FROM backdata WITH(NOLOCK)
  621. WHERE CONVERT(VARCHAR(10), CountDate, 112) = @Day
  622. GROUP BY ManagerID
  623. ) x
  624. ORDER BY ManagerID
  625. END
  626. GO
  627. /****** Object: StoredProcedure [dbo].[bpBackDataByManagerUserIDSelect] Script Date: 2018/12/13 19:03:23 ******/
  628. SET ANSI_NULLS ON
  629. GO
  630. SET QUOTED_IDENTIFIER ON
  631. GO
  632. --#####################################################
  633. --创建时间:2015.01.06
  634. --创建人:Nick
  635. --说明:根据根据manageruserid获取backdata
  636. --#####################################################
  637. CREATE PROCEDURE [dbo].[bpBackDataByManagerUserIDSelect]
  638. (
  639. @ManagerUserID INT,
  640. @BeginDate VARCHAR(40),
  641. @EndDate VARCHAR(40)
  642. )
  643. AS
  644. BEGIN
  645. SELECT *,(
  646. SELECT COUNT(ID)
  647. FROM bscpstatus
  648. WHERE statusID=9
  649. AND CONVERT(VARCHAR(10),adddate,112)=backdata.countdate
  650. AND VerifyMan = backdata.ManagerID
  651. ) limitCount
  652. FROM backdata WITH(NOLOCK)
  653. WHERE countdate>=@BeginDate
  654. AND countdate<=@EndDate
  655. AND managerid=@ManagerUserID
  656. ORDER BY countdate
  657. END
  658. GO
  659. /****** Object: StoredProcedure [dbo].[bpBackDataByMonthSelect] Script Date: 2018/12/13 19:03:23 ******/
  660. SET ANSI_NULLS ON
  661. GO
  662. SET QUOTED_IDENTIFIER ON
  663. GO
  664. CREATE PROCEDURE [dbo].[bpBackDataByMonthSelect]
  665. (
  666. @BeginDate VARCHAR(8),
  667. @EndDate VARCHAR(8)
  668. )
  669. AS
  670. BEGIN
  671. SELECT *,(
  672. SELECT COUNT(ID)
  673. FROM bscpstatus
  674. WHERE statusID=9
  675. AND CONVERT(VARCHAR(10),adddate,112)>=@BeginDate
  676. AND CONVERT(VARCHAR(10),adddate,112)<=@EndDate
  677. AND VerifyMan = x.ManagerID
  678. ) limitCount FROM (
  679. SELECT managerid,Sum(resume_pass) resume_pass,Sum(resume_delete) resume_delete,Sum(resume_nopass) resume_nopass,
  680. Sum(resume_modify) resume_modify,Sum(photo_pass) photo_pass,Sum(photo_modify) photo_modify,
  681. Sum(photo_delete) photo_delete,Sum(companylogo_pass) companylogo_pass,Sum(companylogo_delete) companylogo_delete,
  682. Sum(companyvisual_pass) companyvisual_pass,Sum(companyvisual_delete) companyvisual_delete,Sum(black) black,
  683. Sum(company_modify) company_modify,Sum(companydelete) companydelete,SUM(Contact_NoCvCount) Contact_NoCvCount,
  684. SUM(Contact_NoApplyCount) Contact_NoApplyCount,SUM(Contact_Count) Contact_Count,
  685. SUM(Contact_CvCount) Contact_CvCount,SUM(Contact_ApplyCount) Contact_ApplyCount
  686. FROM backdata WITH(NOLOCK)
  687. WHERE countdate>=@BeginDate
  688. AND countdate<=@EndDate
  689. GROUP BY ManagerID
  690. ) x ORDER BY ManagerID
  691. END
  692. GO
  693. /****** Object: StoredProcedure [dbo].[bpBackdataByWeekSelect] Script Date: 2018/12/13 19:03:23 ******/
  694. SET ANSI_NULLS ON
  695. GO
  696. SET QUOTED_IDENTIFIER ON
  697. GO
  698. CREATE PROCEDURE [dbo].[bpBackdataByWeekSelect]
  699. (
  700. @week INT
  701. )
  702. AS
  703. INSERT INTO procLog SELECT 'bpBackdataByWeekSelect', '', GETDATE()
  704. BEGIN
  705. SET DATEFIRST 1
  706. SELECT managerid, SUM(resume_pass) resume_pass,SUM(resume_delete) resume_delete,
  707. SUM(resume_nopass) resume_nopass,SUM(resume_modify) resume_modify,SUM(photo_pass) photo_pass,
  708. SUM(photo_modify) photo_modify,SUM(photo_delete) photo_delete,SUM(companylogo_pass) companylogo_pass,
  709. SUM(companylogo_delete) companylogo_delete,SUM(companyvisual_pass) companyvisual_pass,
  710. SUM(companyvisual_delete) companyvisual_delete,SUM(black) black,SUM(company_modify) company_modify,
  711. SUM(companydelete) companydelete,SUM(Contact_NoCvCount) Contact_NoCvCount,SUM(Contact_NoApplyCount) Contact_NoApplyCount,
  712. SUM(Contact_Count) Contact_Count,SUM(Contact_CvCount) Contact_CvCount,SUM(Contact_ApplyCount) Contact_ApplyCount
  713. FROM backdata with(nolock)
  714. WHERE countDate >= CONVERT(varchar(8),dateadd(day,1-datepart(weekday,getdate()-@week*7),getdate()-@week*7),112)
  715. AND countDate < CONVERT(varchar(8),dateadd(day,1-datepart(weekday,getdate()-(@week-1)*7),getdate()-(@week-1)*7),112)
  716. GROUP BY managerid
  717. ORDER BY managerid
  718. END
  719. GO
  720. /****** Object: StoredProcedure [dbo].[bpBackDataByYearSelect] Script Date: 2018/12/13 19:03:24 ******/
  721. SET ANSI_NULLS ON
  722. GO
  723. SET QUOTED_IDENTIFIER ON
  724. GO
  725. CREATE PROCEDURE [dbo].[bpBackDataByYearSelect]
  726. (
  727. @Year VARCHAR(8)
  728. )
  729. AS
  730. BEGIN
  731. SELECT *,(
  732. SELECT COUNT(ID)
  733. FROM bscpstatus
  734. WHERE statusID=9
  735. AND CONVERT(VARCHAR(4),adddate,112)=@Year
  736. AND VerifyMan = x.ManagerID
  737. ) limitCount
  738. FROM (
  739. SELECT managerid,Sum(resume_pass) resume_pass,Sum(resume_delete) resume_delete,Sum(resume_nopass) resume_nopass,
  740. Sum(resume_modify) resume_modify,Sum(photo_pass) photo_pass,Sum(photo_modify) photo_modify,
  741. Sum(photo_delete) photo_delete,Sum(companylogo_pass) companylogo_pass,Sum(companylogo_delete) companylogo_delete,
  742. Sum(companyvisual_pass) companyvisual_pass,Sum(companyvisual_delete) companyvisual_delete,Sum(black) black,
  743. Sum(company_modify) company_modify,Sum(companydelete) companydelete,SUM(Contact_NoCvCount) Contact_NoCvCount,
  744. SUM(Contact_NoApplyCount) Contact_NoApplyCount,SUM(Contact_Count) Contact_Count,SUM(Contact_CvCount) Contact_CvCount,
  745. SUM(Contact_ApplyCount) Contact_ApplyCount
  746. FROM backdata WITH(NOLOCK)
  747. WHERE LEFT(countdate,4) = @Year GROUP BY managerid
  748. ) x ORDER BY managerid
  749. END
  750. GO
  751. /****** Object: StoredProcedure [dbo].[bpBackDataUpdate] Script Date: 2018/12/13 19:03:24 ******/
  752. SET ANSI_NULLS ON
  753. GO
  754. SET QUOTED_IDENTIFIER ON
  755. GO
  756. -----------------
  757. --创建日期:2010-9-26
  758. --创建人:lambo
  759. --功能说明:根据列名和用户编号修改今天的操作记录,每次增加1,如果没有则先增加一条
  760. --用于后台记录用户的操作记录
  761. -----------------
  762. CREATE PROCEDURE [dbo].[bpBackDataUpdate]
  763. (
  764. @ManagerUserID INT,
  765. @col VARCHAR(50)
  766. )
  767. AS
  768. INSERT INTO procLog SELECT 'bpBackDataUpdate', '', GETDATE()
  769. BEGIN TRAN
  770. BEGIN TRY
  771. SET @col = REPLACE(@col, '''', '')
  772. DECLARE @SQL AS VARCHAR(1000)
  773. IF NOT EXISTS (SELECT id FROM backdata WITH (NOLOCK) WHERE managerid=@ManagerUserID AND CountDate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE()))
  774. INSERT INTO backdata (managerid,countdate) VALUES(@ManagerUserID,YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE()))
  775. SET @SQL = 'UPDATE backdata SET ' + @col + '=' + @col + '+ 1 WHERE managerid=' + LTRIM(STR(@ManagerUserID)) +
  776. ' AND CountDate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())'
  777. EXEC(@SQL)
  778. END TRY
  779. BEGIN CATCH
  780. GOTO err
  781. END CATCH
  782. COMMIT TRAN
  783. RETURN 1
  784. err:
  785. BEGIN
  786. ROLLBACK TRAN
  787. RETURN 0
  788. END
  789. GO
  790. /****** Object: StoredProcedure [dbo].[bpBaiduLogCheck] Script Date: 2018/12/13 19:03:24 ******/
  791. SET ANSI_NULLS ON
  792. GO
  793. SET QUOTED_IDENTIFIER ON
  794. GO
  795. CREATE PROCEDURE [dbo].[bpBaiduLogCheck]
  796. AS
  797. INSERT INTO procLog SELECT 'bpBaiduLogCheck', '', GETDATE()
  798. BEGIN
  799. SELECT TOP 0 * INTO #t FROM BaiduMapLog
  800. ALTER TABLE #t ADD Id1 INT
  801. ALTER TABLE #t ADD Id2 INT
  802. ALTER TABLE #t ADD Id3 INT
  803. ALTER TABLE #t ADD JobName1 NVARCHAR(100)
  804. ALTER TABLE #t ADD JobName2 NVARCHAR(100)
  805. ALTER TABLE #t ADD JobName3 NVARCHAR(100)
  806. INSERT INTO #t(JobID, Lng, Lat, Status)
  807. SELECT Id, Lng, Lat, 9
  808. FROM cpMainPublish WITH(NOLOCK)
  809. WHERE Valid = 1 AND Id IN(SELECT cpMainId FROM JobPublish WITH(NOLOCK) WHERE Valid = 1)
  810. AND Lng > 0
  811. UPDATE a
  812. SET a.Address = b.Address,
  813. a.cpMainName = b.Name,
  814. a.FullName = b.SecondId,
  815. a.Status = b.dcProvinceID
  816. FROM #t a, cpMain b
  817. WHERE a.JobId = b.Id
  818. UPDATE a
  819. SET a.JobUrl = b.ProvinceDomain
  820. FROM #t a, dcProvince b
  821. WHERE a.Status = b.Id
  822. UPDATE #t SET cpMainUrl = 'http://www.' + JobUrl + '/personal/cp' + FullName +'.html'
  823. UPDATE #t SET Status = 9, JobUrl = cpMainUrl, FullName = NULL
  824. SELECT cpMainId, Id, Name, dcSalaryId, ROW_NUMBER() OVER(PARTITION BY cpMainId ORDER BY CASE dcSalaryId WHEN 100 THEN 5 ELSE dcSalaryId END DESC, IssueDate DESC, ID DESC) RowNo
  825. INTO #1
  826. FROM JobPublish WITH(NOLOCK)
  827. WHERE Valid = 1
  828. DELETE #1 WHERE cpMainId NOT IN(SELECT JobId FROM #t)
  829. DELETE #1 WHERE RowNo > 3
  830. UPDATE a SET a.Id1 = b.Id, a.JobName1 = b.Name, a.dcSalaryId = b.dcSalaryId FROM #t a, #1 b WHERE a.JobId = b.cpMainId AND RowNo = 1
  831. UPDATE a SET a.Id2 = b.Id, a.JobName2 = b.Name FROM #t a, #1 b WHERE a.JobId = b.cpMainId AND RowNo = 2
  832. UPDATE a SET a.Id3 = b.Id, a.JobName3 = b.Name FROM #t a, #1 b WHERE a.JobId = b.cpMainId AND RowNo = 3
  833. DELETE FROM #t WHERE Id1 IS NULL
  834. UPDATE #t SET JobName = JobName1
  835. UPDATE #t SET JobName = JobName + ' | ' + JobName2 WHERE JobName2 IS NOT NULL AND LEN(JobName + ' | ' + JobName2) < 50
  836. UPDATE #t SET JobName = JobName + ' | ' + JobName3 WHERE JobName3 IS NOT NULL AND LEN(JobName + ' | ' + JobName3) < 51
  837. UPDATE a
  838. SET a.Salary = b.Description
  839. FROM #t a, dcSalary b
  840. WHERE a.dcSalaryId = b.Id
  841. ---------------------------------------
  842. INSERT INTO BaiduMapLog(JobId, JobName, Address, cpMainName, Lng, Lat, dcSalaryId, Salary, JobUrl, cpMainUrl, [Status])
  843. SELECT JobId, JobName, Address, cpMainName, Lng, Lat, dcSalaryId, Salary, JobUrl, cpMainUrl, 1
  844. FROM #t
  845. WHERE JobID NOT IN(SELECT JobId FROM BaiduMapLog WITH(NOLOCK))
  846. DELETE BaiduMapLog
  847. WHERE JobId IN(SELECT ID FROM cpMain WHERE Lat IS NULL OR Lng IS NULL)
  848. UPDATE BaiduMapLog
  849. SET Status = 3
  850. WHERE JobId NOT IN(
  851. SELECT b.Id
  852. FROM Job a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  853. WHERE a.cpMainId = b.Id
  854. AND a.Valid = 1
  855. AND b.Valid = 1)
  856. UPDATE b SET b.JobName = a.JobName ,b.Status=2 FROM #t a, BaiduMapLog b WHERE a.JobId = b.JobId AND b.Status = 0 AND a.JobName <> b.JobName
  857. UPDATE b SET b.Address = a.Address ,b.Status=2 FROM #t a, BaiduMapLog b WHERE a.FullName IS NULL AND a.JobId = b.JobId AND b.Status = 0 AND a.Address <> b.Address
  858. UPDATE b SET b.cpMainName =a.cpMainName, b.Status=2 FROM #t a, BaiduMapLog b WHERE a.FullName IS NULL AND a.JobId = b.JobId AND b.Status = 0 AND a.cpMainName <> b.cpMainName
  859. UPDATE b SET b.Lng=a.Lng, b.Status=2 FROM #t a, BaiduMapLog b WHERE a.FullName IS NULL AND a.JobId = b.JobId AND b.Status = 0 AND a.Lng <> b.Lng
  860. UPDATE b SET b.Lat = a.Lat, b.Status=2 FROM #t a, BaiduMapLog b WHERE a.FullName IS NULL AND a.JobId = b.JobId AND b.Status = 0 AND a.Lat <> b.Lat
  861. UPDATE b SET b.dcSalaryId = a.dcSalaryId, b.Status=2 FROM #t a, BaiduMapLog b WHERE a.FullName IS NULL AND a.JobId = b.JobId AND b.Status = 0 AND a.dcSalaryId <> b.dcSalaryId
  862. END
  863. GO
  864. /****** Object: StoredProcedure [dbo].[bpBaiduLogSelect] Script Date: 2018/12/13 19:03:24 ******/
  865. SET ANSI_NULLS ON
  866. GO
  867. SET QUOTED_IDENTIFIER ON
  868. GO
  869. CREATE PROCEDURE [dbo].[bpBaiduLogSelect]
  870. AS
  871. RETURN
  872. BEGIN
  873. /*
  874. UPDATE a SET
  875. a.Valid = b.Valid,
  876. a.OperDate = GETDATE()
  877. FROM LogDB..BaiduMapLog a,Job b
  878. WHERE a.JobID=b.ID AND a.Valid <> b.Valid
  879. UPDATE a SET
  880. a.RefreshDate = CONVERT(VARCHAR,c.LastLoginDate,112),
  881. a.OperDate = GETDATE()
  882. FROM LogDB..BaiduMapLog a,Job b,cpMain c
  883. WHERE a.JobID=b.ID AND b.cpMainID=c.ID AND a.RefreshDate<CONVERT(VARCHAR,c.LastLoginDate,112) AND a.Valid=1
  884. UPDATE a SET
  885. a.Lat = b.Lat,
  886. a.Lng = b.Lng,
  887. a.OperDate = GETDATE()
  888. FROM LogDB..BaiduMapLog a,Job b
  889. WHERE a.JobID=b.ID AND a.Lng<>b.Lng AND b.Lat<>a.Lat AND a.Valid=1
  890. UPDATE a SET
  891. a.Name=b.Name,
  892. a.CoordType=3,
  893. a.Industry=(SELECT TOP 1 dcIndustryID FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainid=b.cpMainID),
  894. a.Valid=b.Valid,
  895. a.Description=(SELECT Description FROM dcSalary WITH(NOLOCK) WHERE dcSalary.ID=b.dcSalaryID),
  896. a.dcJobTypeID=b.dcJobTypeID,
  897. a.SecondID=b.SecondID,
  898. a.RefreshDate=CONVERT(VARCHAR(8),b.RefreshDate,112),
  899. a.cpMainName=c.Name,
  900. a.cpMainSecondId=c.SecondID,
  901. a.JobName=b.Name,
  902. a.cpMainId=c.ID
  903. FROM Logdb..BaiduMapLog a,Job b,cpMain c
  904. WHERE a.JobID=b.ID AND b.cpMainID=c.ID AND OperDate>UploadDate
  905. UPDATE a SET
  906. a.FullName=(SELECT FullName + c.Address FROM dcRegion WITH(NOLOCK) WHERE dcRegion.ID=b.dcRegionID)
  907. FROM Logdb..BaiduMapLog a,Job b,cpMain c
  908. WHERE a.JobID=b.ID AND b.cpMainID=c.ID AND OperDate>UploadDate AND LEN(ISNULL(FullName,''))=0
  909. SELECT TOP 50000 * FROM Logdb..BaiduMapLog WITH(NOLOCK) WHERE OperDate>UploadDate ORDER BY OperDate DESC
  910. */
  911. print 1
  912. END
  913. GO
  914. /****** Object: StoredProcedure [dbo].[bpbsAskClickLogByCountMontySelect] Script Date: 2018/12/13 19:03:24 ******/
  915. SET ANSI_NULLS ON
  916. GO
  917. SET QUOTED_IDENTIFIER ON
  918. GO
  919. --bpbsAskClickLogByCountMontySelect '201401'
  920. --创建人 Andy
  921. --时间 2015-01-23
  922. --按月查询求职互助点击量
  923. CREATE PROCEDURE [dbo].[bpbsAskClickLogByCountMontySelect]
  924. (
  925. @CountMonth NVARCHAR(6)
  926. )
  927. AS
  928. BEGIN
  929. SELECT b.AddUserID, SUM(a.increase) Cnt
  930. FROM bsAskClickLog a, bsASKInfo b
  931. WHERE a.bsAskInfoID = b.ID
  932. AND a.CountMonth = @Countmonth
  933. GROUP BY b.AddUserID
  934. ORDER BY AddUserID
  935. END
  936. GO
  937. /****** Object: StoredProcedure [dbo].[bpBsAskInfoBySourceSelect] Script Date: 2018/12/13 19:03:25 ******/
  938. SET ANSI_NULLS ON
  939. GO
  940. SET QUOTED_IDENTIFIER ON
  941. GO
  942. CREATE PROCEDURE [dbo].[bpBsAskInfoBySourceSelect]
  943. AS
  944. SET NOCOUNT ON
  945. BEGIN
  946. SELECT CountDate, Province_Id, ISNULL(SUM(Page_Count), 0) cnt, southnorth
  947. INTO #t
  948. FROM (SELECT countdate, a.Id as Province_Id, D.Page_Count, southnorth
  949. FROM dcProvince a
  950. LEFT JOIN (
  951. SELECT b.CountDate, c.Page_Count, b.Province_Id
  952. From Innerer_CountNew b left join innerer_count_detail c
  953. ON c.Innerer_CountId = b.Id
  954. WHERE countdate >= CONVERT(VARCHAR(8), GETDATE() - 100, 112)
  955. AND c.Innerpage=5
  956. AND Province_Id < 999
  957. AND (LEN(Province_Id)=2 OR LEN(Province_Id)=4 OR Province_Id=0)
  958. ) d ON a.Id = d.Province_Id
  959. ) E
  960. GROUP BY CountDate, Province_Id, southnorth
  961. ORDER BY CountDate, CASE southnorth WHEN 4 THEN 1 ELSE southnorth END DESC,
  962. Province_Id
  963. SELECT DISTINCT CASE southnorth WHEN 4 THEN 1 ELSE southnorth END southnorth, Province_Id
  964. INTO #p
  965. FROM #t
  966. ORDER BY CASE southnorth WHEN 4 THEN 1 ELSE southnorth END DESC, Province_Id
  967. DECLARE @temp NVARCHAR(max)
  968. SELECT @temp=COALESCE(@temp,'')+ '['+ LTRIM(STR(province_id)) +'], '
  969. FROM
  970. #p
  971. set @temp=SUBSTRING(@temp,1,LEN(@temp)-1)
  972. --print @temp
  973. DECLARE @sql NVARCHAR(max)
  974. SET @sql='
  975. SELECT countdate, ' + @temp + '
  976. from (select countdate, province_id, cnt from #t) a
  977. pivot(avg(Cnt)
  978. for province_id IN('+ @temp+')
  979. )b ORDER BY CountDATE DESC'
  980. --PRINT @sql
  981. EXEC(@sql)
  982. END
  983. GO
  984. /****** Object: StoredProcedure [dbo].[bpbsConsultantFreeOrderInsert] Script Date: 2018/12/13 19:03:25 ******/
  985. SET ANSI_NULLS ON
  986. GO
  987. SET QUOTED_IDENTIFIER ON
  988. GO
  989. --添加顾问免费订单记录 Lucifer 2014-12-24
  990. CREATE PROCEDURE [dbo].[bpbsConsultantFreeOrderInsert]
  991. (
  992. @OrderID INT,
  993. @ConsultantID SMALLINT
  994. )
  995. AS
  996. INSERT INTO procLog SELECT 'bpbsConsultantFreeOrderInsert', '', GETDATE()
  997. BEGIN
  998. INSERT INTO MainDb..bsConsultantFreeOrder(ConsultantId,OpenDate,OrderID) SELECT @ConsultantID,GETDATE(),@OrderID
  999. END
  1000. GO
  1001. /****** Object: StoredProcedure [dbo].[bpbsConsultantFreeOrderSetSelect] Script Date: 2018/12/13 19:03:25 ******/
  1002. SET ANSI_NULLS ON
  1003. GO
  1004. SET QUOTED_IDENTIFIER ON
  1005. GO
  1006. --查询顾问当月是否还有订单赠送配额 Lucifer 2014-12-24
  1007. CREATE PROCEDURE [dbo].[bpbsConsultantFreeOrderSetSelect]
  1008. (
  1009. @ConsultantID SMALLINT
  1010. )
  1011. AS
  1012. BEGIN
  1013. SELECT 'X' FROM bsConsultantFreeOrderSet a WHERE (
  1014. SELECT COUNT(*) cnt FROM bsConsultantFreeOrder
  1015. WHERE OpenDate>CONVERT(DATETIME,CONVERT(VARCHAR(8),DATEADD(DAY, -25, GETDATE()),21)+'26') AND
  1016. ConsultantId = a.ConsultantId
  1017. ) < a.Number AND [Type]=13 AND ConsultantId = @ConsultantId
  1018. END
  1019. GO
  1020. /****** Object: StoredProcedure [dbo].[bpbsConsultantFreeOrderSetUpdate] Script Date: 2018/12/13 19:03:25 ******/
  1021. SET ANSI_NULLS ON
  1022. GO
  1023. SET QUOTED_IDENTIFIER ON
  1024. GO
  1025. -------------------------------------------------------
  1026. --创建日期:2014-12-1
  1027. --创建人:harry
  1028. --功能说明:newoamvc单位用户管理-->设置顾问开通权限限额分配
  1029. --用于设置后台顾问开通权限限额分配
  1030. -------------------------------------------------------
  1031. CREATE PROCEDURE [dbo].[bpbsConsultantFreeOrderSetUpdate]
  1032. (
  1033. @Number INT,
  1034. @DeptId INT
  1035. )
  1036. AS
  1037. SET NOCOUNT ON
  1038. BEGIN
  1039. UPDATE bsConsultantFreeOrderSet
  1040. SET Number = @Number
  1041. WHERE ConsultantId IN(
  1042. SELECT Id
  1043. FROM Manageruser WITH(NOLOCK)
  1044. WHERE DeptId = @DeptId)
  1045. INSERT INTO bsConsultantFreeOrderSet
  1046. SELECT ID, @Number, 13 FROM ManagerUser WHERE DeptId = @DeptId AND STATUS < 3 AND ID NOT IN(SELECT ConsultantId FROM bsConsultantFreeOrderSet)
  1047. RETURN 1
  1048. END
  1049. GO
  1050. /****** Object: StoredProcedure [dbo].[bpBsCpBackLoginByUnqueIDSelect] Script Date: 2018/12/13 19:03:26 ******/
  1051. SET ANSI_NULLS ON
  1052. GO
  1053. SET QUOTED_IDENTIFIER ON
  1054. GO
  1055. CREATE PROCEDURE [dbo].[bpBsCpBackLoginByUnqueIDSelect]
  1056. (
  1057. @UID VARCHAR(20)
  1058. )
  1059. AS
  1060. BEGIN
  1061. DECLARE @CaMainID AS INT
  1062. SELECT @CaMainID = caMainID
  1063. FROM bsCpBackLogin WITH(NOLOCK)
  1064. WHERE UnqueID = @UID
  1065. IF @CaMainID IS NULL
  1066. RETURN 0
  1067. ELSE
  1068. RETURN @CaMainID
  1069. END
  1070. GO
  1071. /****** Object: StoredProcedure [dbo].[bpBsCpBackLoginInsert] Script Date: 2018/12/13 19:03:26 ******/
  1072. SET ANSI_NULLS ON
  1073. GO
  1074. SET QUOTED_IDENTIFIER ON
  1075. GO
  1076. CREATE PROCEDURE [dbo].[bpBsCpBackLoginInsert]
  1077. (
  1078. @cpMainID INT,
  1079. @caMainID INT,
  1080. @ManagerUserID INT,
  1081. @UID VARCHAR(20) OUTPUT
  1082. )
  1083. AS
  1084. BEGIN
  1085. DECLARE @T AS VARCHAR(20)
  1086. SET @T = CONVERT(VARCHAR(20), CONVERT(DECIMAL(18,12),GETDATE()))
  1087. SET @T = RTRIM(CONVERT(VARCHAR(12), @cpMainID)) + '_' + RIGHT(@T,8)
  1088. INSERT INTO BsCpBackLogin (UnqueID,cpMainID,caMainID,ManagerUserID)
  1089. VALUES(@T,@cpMainID,@caMainID,@ManagerUserID)
  1090. SET @UID = @T
  1091. END
  1092. GO
  1093. /****** Object: StoredProcedure [dbo].[bpbsCpModifyByFilterWordSelect] Script Date: 2018/12/13 19:03:26 ******/
  1094. SET ANSI_NULLS ON
  1095. GO
  1096. SET QUOTED_IDENTIFIER ON
  1097. GO
  1098. --#####################################################
  1099. --创建时间:2015.1.8
  1100. --创建人:Nick
  1101. --说明:获取包含过滤词的职位
  1102. --#####################################################
  1103. CREATE PROCEDURE [dbo].[bpbsCpModifyByFilterWordSelect]
  1104. AS
  1105. BEGIN
  1106. SELECT a.Id cpMainID, a.IsLimitLogin, a.consultantid, a.haslicence, a.RegDate, a.Name cpName, b.FilterWord,
  1107. b.AddDate, Left(b.ColValue, 30) colValue
  1108. FROM cpMain a With(Nolock), bsCpModify b WITH(NOLOCK)
  1109. WHERE a.Id = b.cpMainId AND b.FilterWord>''
  1110. AND b.verifyinfo IS NULL AND b.AddDate > GETDATE() - 2 AND IsLimitLogin < 9
  1111. ORDER BY b.AddDate
  1112. End
  1113. GO
  1114. /****** Object: StoredProcedure [dbo].[bpbsCpModifyPassUpdate] Script Date: 2018/12/13 19:03:26 ******/
  1115. SET ANSI_NULLS ON
  1116. GO
  1117. SET QUOTED_IDENTIFIER ON
  1118. GO
  1119. CREATE PROCEDURE [dbo].[bpbsCpModifyPassUpdate]
  1120. (
  1121. @bsCpVerifyID INT,
  1122. @Pass INT
  1123. )
  1124. AS
  1125. BEGIN TRY
  1126. DECLARE @cpMainID AS INT
  1127. SELECT @cpMainID = cpMainID FROM bsCpVerify WITH(NOLOCK) WHERE ID=@bsCpVerifyID
  1128. UPDATE cpMain SET VerifyResult = @Pass WHERE ID = @cpMainID
  1129. /* Job全部通过,要么修改 要么删除
  1130. UPDATE Job SET VerifyResult = @Pass WHERE ID IN(
  1131. SELECT DISTINCT SubID FROM bsCpModify WITH(NOLOCK)
  1132. WHERE cpMainID = @cpMainID
  1133. AND Location Like 'c%'
  1134. )
  1135. */
  1136. END TRY
  1137. BEGIN CATCH
  1138. GOTO ERR
  1139. END CATCH
  1140. RETURN 1
  1141. ERR:
  1142. BEGIN
  1143. RETURN 0
  1144. END
  1145. GO
  1146. /****** Object: StoredProcedure [dbo].[bpbsCpModifyUpdate] Script Date: 2018/12/13 19:03:26 ******/
  1147. SET ANSI_NULLS ON
  1148. GO
  1149. SET QUOTED_IDENTIFIER ON
  1150. GO
  1151. CREATE PROCEDURE [dbo].[bpbsCpModifyUpdate]
  1152. (
  1153. @ID INT,
  1154. @bsCpVerifyID INT,
  1155. @VerifyInfo NVARCHAR(200)
  1156. )
  1157. AS
  1158. BEGIN TRY
  1159. DECLARE @MaxID AS INT
  1160. IF ISNULL(@VerifyInfo, '') =''
  1161. BEGIN
  1162. INSERT INTO bsCpVerifyLog(bsCpVerifyID,SubID,Location,AddDate,OldValue)
  1163. SELECT @bsCpVerifyID,SubID,Location,AddDate,ColValue FROM bsCpModify WITH(NOLOCK) WHERE ID = @ID
  1164. SET @MaxID = @@IDENTITY
  1165. DELETE FROM bsCpModify WHERE ID = @ID
  1166. END
  1167. ELSE
  1168. BEGIN
  1169. INSERT INTO bsCpVerifyLog(bsCpVerifyID,SubID,Location,AddDate,OldValue,VerifyResult,VerifyInfo)
  1170. SELECT @bsCpVerifyID,SubID,Location,AddDate,ColValue,1,@VerifyInfo FROM bsCpModify WITH(NOLOCK) WHERE ID = @ID
  1171. SET @MaxID = @@IDENTITY
  1172. UPDATE bsCpModify SET VerifyInfo=@VerifyInfo WHERE ID=@ID
  1173. END
  1174. END TRY
  1175. BEGIN CATCH
  1176. GOTO ERR
  1177. END CATCH
  1178. RETURN 1
  1179. ERR:
  1180. BEGIN
  1181. RETURN 0
  1182. END
  1183. GO
  1184. /****** Object: StoredProcedure [dbo].[bpbsCpStatusByCpMainIDSelect] Script Date: 2018/12/13 19:03:27 ******/
  1185. SET ANSI_NULLS ON
  1186. GO
  1187. SET QUOTED_IDENTIFIER ON
  1188. GO
  1189. CREATE PROCEDURE [dbo].[bpbsCpStatusByCpMainIDSelect]
  1190. (
  1191. @StatusID VARCHAR(20),
  1192. @cpMainID INT
  1193. )
  1194. AS
  1195. BEGIN
  1196. DECLARE @SQL AS VARCHAR(1000)
  1197. SET @StatusID = REPLACE(@StatusID, '''', '')
  1198. SET @SQL = 'SELECT * FROM BsCpStatus WITH(NOLOCK) WHERE cpMainID = ' + RTRIM(CONVERT(CHAR(10), @cpMainID))
  1199. IF LEN(@StatusID) > 0
  1200. SET @SQL = @SQL + ' AND StatusID IN (' + RTRIM(CONVERT(CHAR(10), @StatusID)) + ')'
  1201. SET @SQL = @SQL + ' ORDER BY ID DESC'
  1202. EXEC(@SQL)
  1203. END
  1204. GO
  1205. /****** Object: StoredProcedure [dbo].[bpBsCpStatusInsert] Script Date: 2018/12/13 19:03:27 ******/
  1206. SET ANSI_NULLS ON
  1207. GO
  1208. SET QUOTED_IDENTIFIER ON
  1209. GO
  1210. -----------------
  1211. --创建日期:2010-9-14
  1212. --创建人:lambo
  1213. --功能说明:增加企业状态操作记录
  1214. --用于后台企业用户管理模块
  1215. -----------------
  1216. CREATE PROCEDURE [dbo].[bpBsCpStatusInsert]
  1217. (
  1218. @cpMainID INT,
  1219. @StatusID INT,
  1220. @ApplyInfo VARCHAR(200),
  1221. @VerifyMan INT,
  1222. @VerifyInfo VARCHAR(500)
  1223. )
  1224. AS
  1225. BEGIN TRY
  1226. DECLARE @MaxID AS INT
  1227. INSERT INTO bsCpStatus (cpMainID,ApplyInfo,StatusID,VerifyMan,VerifyInfo,VerifyDate)
  1228. VALUES(@cpMainID,@ApplyInfo,@StatusID,@VerifyMan,@VerifyInfo,GETDATE())
  1229. SET @MaxID = @@IDENTITY
  1230. END TRY
  1231. BEGIN CATCH
  1232. GOTO ERR
  1233. END CATCH
  1234. RETURN @MaxID
  1235. ERR:
  1236. BEGIN
  1237. RETURN 0
  1238. END
  1239. GO
  1240. /****** Object: StoredProcedure [dbo].[bpBsCpVerifyBycpMainIDSelect] Script Date: 2018/12/13 19:03:27 ******/
  1241. SET ANSI_NULLS ON
  1242. GO
  1243. SET QUOTED_IDENTIFIER ON
  1244. GO
  1245. CREATE PROCEDURE [dbo].[bpBsCpVerifyBycpMainIDSelect]
  1246. (
  1247. @cpMainID INT
  1248. )
  1249. AS
  1250. BEGIN
  1251. SELECT * FROM BsCpVerify WITH(NOLOCK) WHERE cpMainID=@cpMainID
  1252. END
  1253. GO
  1254. /****** Object: StoredProcedure [dbo].[bpBsCpVerifyInsert] Script Date: 2018/12/13 19:03:27 ******/
  1255. SET ANSI_NULLS ON
  1256. GO
  1257. SET QUOTED_IDENTIFIER ON
  1258. GO
  1259. --修改Harry
  1260. --2018-5-15
  1261. --增加审核记录,用于计算审核延误1
  1262. CREATE PROCEDURE [dbo].[bpBsCpVerifyInsert]
  1263. (
  1264. @cpMainID INT,
  1265. @VerifyMan INT,
  1266. @VerifyResult TINYINT,
  1267. @VerifyInfo NVARCHAR(200)
  1268. )
  1269. AS
  1270. SET NOCOUNT ON
  1271. BEGIN
  1272. INSERT INTO bsCpVerify(cpMainID,VerifyMan,VerifyDate,VerifyResult,VerifyInfo)
  1273. VALUES(@cpMainID,@VerifyMan,GETDATE(),@VerifyResult,@VerifyInfo)
  1274. --harry begin
  1275. DECLARE @VerifyId INT, @submit DATETIME
  1276. SELECT TOP 1 @submit=adddate FROM bsCpModify WHERE cpMainID=@cpMainID ORDER BY adddate DESC
  1277. IF @submit is NULL
  1278. SET @submit=GETDATE()
  1279. SELECT @VerifyId=@@IDENTITY
  1280. INSERT INTO logdb..VerifyDelayLog(verifyType, relationId, submitDate, verifyDate, verifyMan)
  1281. SELECT 1,@VerifyId, @submit, GETDATE(), @VerifyMan
  1282. RETURN @VerifyId
  1283. END
  1284. GO
  1285. /****** Object: StoredProcedure [dbo].[bpbsCpVerifyLogBybsCpVerifyIDSelect] Script Date: 2018/12/13 19:03:27 ******/
  1286. SET ANSI_NULLS ON
  1287. GO
  1288. SET QUOTED_IDENTIFIER ON
  1289. GO
  1290. CREATE PROCEDURE [dbo].[bpbsCpVerifyLogBybsCpVerifyIDSelect]
  1291. (
  1292. @bsCpVerifyID INT
  1293. )
  1294. AS
  1295. BEGIN
  1296. SELECT * FROM bsCpVerifyLog WITH(NOLOCK) WHERE bsCpVerifyID = @bsCpVerifyID
  1297. END
  1298. GO
  1299. /****** Object: StoredProcedure [dbo].[bpBsCpVerifyLogSelect] Script Date: 2018/12/13 19:03:27 ******/
  1300. SET ANSI_NULLS ON
  1301. GO
  1302. SET QUOTED_IDENTIFIER ON
  1303. GO
  1304. CREATE PROCEDURE [dbo].[bpBsCpVerifyLogSelect]
  1305. (
  1306. @ID INT
  1307. )
  1308. AS
  1309. BEGIN
  1310. SELECT * FROM BsCpVerifyLog WITH(NOLOCK) WHERE ID=@ID
  1311. END
  1312. GO
  1313. /****** Object: StoredProcedure [dbo].[bpBsCpVerifySelect] Script Date: 2018/12/13 19:03:28 ******/
  1314. SET ANSI_NULLS ON
  1315. GO
  1316. SET QUOTED_IDENTIFIER ON
  1317. GO
  1318. CREATE PROCEDURE [dbo].[bpBsCpVerifySelect]
  1319. (
  1320. @cpMainID INT
  1321. )
  1322. AS
  1323. BEGIN
  1324. SELECT Top 1 * FROM BsCpVerify WITH(NOLOCK) WHERE cpMainID=@cpMainID ORDER BY VerifyDate DESC
  1325. END
  1326. GO
  1327. /****** Object: StoredProcedure [dbo].[bpbsCvModifyByCvMainIDDelete] Script Date: 2018/12/13 19:03:28 ******/
  1328. SET ANSI_NULLS ON
  1329. GO
  1330. SET QUOTED_IDENTIFIER ON
  1331. GO
  1332. --#####################################################
  1333. --创建时间:2014.12.26
  1334. --创建人:Nick
  1335. --说明:删除bsCvModify
  1336. --#####################################################
  1337. CREATE PROCEDURE [dbo].[bpbsCvModifyByCvMainIDDelete]
  1338. (
  1339. @CvMainID INT
  1340. )
  1341. AS
  1342. BEGIN
  1343. DELETE FROM bsCvModify WHERE Location='ac5' And cvMainID = @CvMainID
  1344. END
  1345. GO
  1346. /****** Object: StoredProcedure [dbo].[bpBsCvModifyByPaMainIDUpdate] Script Date: 2018/12/13 19:03:28 ******/
  1347. SET ANSI_NULLS ON
  1348. GO
  1349. SET QUOTED_IDENTIFIER ON
  1350. GO
  1351. CREATE PROCEDURE [dbo].[bpBsCvModifyByPaMainIDUpdate]
  1352. (
  1353. @paMainID INT,
  1354. @bsCvVerifyID INT,
  1355. @Pass INT --100通过,2不通过
  1356. )
  1357. AS
  1358. BEGIN TRAN
  1359. BEGIN TRY
  1360. DECLARE @bCh AS BIT
  1361. DECLARE @bEng AS BIT
  1362. SET @bCh = 0
  1363. SET @bEng = 0
  1364. IF EXISTS(SELECT 'X' FROM bsCvModify WITH(NOLOCK) WHERE paMainID = @paMainID AND SUBSTRING(Location, 2, 1) = 'c')
  1365. SET @bCh = 1
  1366. IF EXISTS(SELECT 'X' FROM bsCvModify WITH(NOLOCK) WHERE paMainID = @paMainID AND SUBSTRING(Location, 2, 1) = 'c')
  1367. SET @bEng = 1
  1368. IF @Pass = 100
  1369. BEGIN
  1370. INSERT INTO bsCvVerifyLog(bsCvVerifyID,SubID,Location,AddDate,OldValue)
  1371. SELECT @bsCvVerifyID,SubID,Location,AddDate,ColValue FROM bsCvModify WITH(NOLOCK) WHERE paMainID = @paMainID
  1372. UPDATE bsCvVerify SET VerifyResult = 100,VerifyInfo='本次审核所有简历审核通过' WHERE ID = @bsCvVerifyID
  1373. IF @bCH = 1
  1374. BEGIN
  1375. UPDATE cvMain SET VerifyResult=100
  1376. WHERE ID IN (SELECT cvMainID FROM bsCvModify WITH(NOLOCK) WHERE paMainID=@paMainID)
  1377. END
  1378. IF @bEng = 1
  1379. BEGIN
  1380. UPDATE cvMain SET VerifyResultEng=100
  1381. WHERE ID IN (SELECT cvMainID FROM bsCvModify WITH(NOLOCK) WHERE paMainID=@paMainID)
  1382. END
  1383. DELETE FROM bsCvModify WHERE paMainID = @paMainID
  1384. END
  1385. ELSE
  1386. BEGIN
  1387. INSERT INTO bsCvVerifyLog(bsCvVerifyID,SubID,Location,AddDate,OldValue,VerifyResult,VerifyInfo)
  1388. SELECT @bsCvVerifyID,SubID,Location,AddDate,ColValue,1,'本次审核所有简历审核不通过'
  1389. FROM bsCvModify WITH(NOLOCK) WHERE paMainID = @paMainID
  1390. UPDATE bsCvModify SET VerifyInfo='本次审核所有简历审核不通过' WHERE paMainID=@paMainID
  1391. UPDATE bsCvVerify SET VerifyResult = 2,VerifyInfo='本次审核所有简历审核不通过' WHERE ID = @bsCvVerifyID
  1392. IF @bCH = 1
  1393. BEGIN
  1394. UPDATE cvMain SET VerifyResult=@Pass
  1395. WHERE ID IN (SELECT cvMainID FROM bsCvModify WITH(NOLOCK) WHERE paMainID=@paMainID)
  1396. END
  1397. IF @bEng = 1
  1398. BEGIN
  1399. UPDATE cvMain SET VerifyResultEng=@Pass
  1400. WHERE ID IN (SELECT cvMainID FROM bsCvModify WITH(NOLOCK) WHERE paMainID=@paMainID)
  1401. END
  1402. END
  1403. END TRY
  1404. BEGIN CATCH
  1405. GOTO ERR
  1406. END CATCH
  1407. COMMIT TRAN
  1408. RETURN 1
  1409. ERR:
  1410. BEGIN
  1411. ROLLBACK TRAN
  1412. RETURN 0
  1413. END
  1414. GO
  1415. /****** Object: StoredProcedure [dbo].[bpBsCvModifyUpdate] Script Date: 2018/12/13 19:03:29 ******/
  1416. SET ANSI_NULLS ON
  1417. GO
  1418. SET QUOTED_IDENTIFIER ON
  1419. GO
  1420. CREATE PROCEDURE [dbo].[bpBsCvModifyUpdate]
  1421. (
  1422. @ID INT,
  1423. @bsCvVerifyID INT,
  1424. @cvMainID INT,
  1425. @VerifyInfo NVARCHAR(200)
  1426. )
  1427. AS
  1428. BEGIN TRY
  1429. DECLARE @MaxID AS INT
  1430. IF ISNULL(@VerifyInfo, '') =''
  1431. BEGIN
  1432. INSERT INTO bsCvVerifyLog(bsCvVerifyID,cvMainID,SubID,Location,AddDate,OldValue)
  1433. SELECT @bsCvVerifyID,@cvMainID,SubID,Location,AddDate,ColValue FROM bsCvModify WITH(NOLOCK) WHERE ID = @ID
  1434. SET @MaxID = @@IDENTITY
  1435. DELETE FROM bsCvModify WHERE ID = @ID
  1436. END
  1437. ELSE
  1438. BEGIN
  1439. INSERT INTO bsCvVerifyLog(bsCvVerifyID,cvMainID,SubID,Location,AddDate,OldValue,VerifyResult,VerifyInfo)
  1440. SELECT @bsCvVerifyID,@cvMainID,SubID,Location,AddDate,ColValue,1,@VerifyInfo FROM bsCvModify WITH(NOLOCK) WHERE ID = @ID
  1441. SET @MaxID = @@IDENTITY
  1442. UPDATE bsCvModify SET VerifyInfo=@VerifyInfo WHERE ID=@ID
  1443. END
  1444. END TRY
  1445. BEGIN CATCH
  1446. GOTO ERR
  1447. END CATCH
  1448. RETURN 1
  1449. ERR:
  1450. BEGIN
  1451. RETURN 0
  1452. END
  1453. GO
  1454. /****** Object: StoredProcedure [dbo].[bpbsCvReviewByCvMainIDDelete] Script Date: 2018/12/13 19:03:29 ******/
  1455. SET ANSI_NULLS ON
  1456. GO
  1457. SET QUOTED_IDENTIFIER ON
  1458. GO
  1459. --#####################################################
  1460. --创建时间:2014.12.25
  1461. --创建人:Nick
  1462. --说明:删除bsCvReview
  1463. --#####################################################
  1464. CREATE PROCEDURE [dbo].[bpbsCvReviewByCvMainIDDelete]
  1465. (
  1466. @CvMainID INT
  1467. )
  1468. AS
  1469. BEGIN
  1470. DELETE FROM bsCvReview WHERE cvMainID = @CvMainID
  1471. END
  1472. GO
  1473. /****** Object: StoredProcedure [dbo].[bpbsCvReviewByCvMainIDSelect] Script Date: 2018/12/13 19:03:29 ******/
  1474. SET ANSI_NULLS ON
  1475. GO
  1476. SET QUOTED_IDENTIFIER ON
  1477. GO
  1478. --#####################################################
  1479. --创建时间:2014.12.24
  1480. --创建人:Nick
  1481. --说明:根据cvmainid获取bsCvReview
  1482. --#####################################################
  1483. CREATE PROCEDURE [dbo].[bpbsCvReviewByCvMainIDSelect]
  1484. (
  1485. @cvMainID INT
  1486. )
  1487. AS
  1488. BEGIN
  1489. SELECT TOP 10 * FROM bsCvReview WHERE cvMainID = @cvMainID
  1490. END
  1491. GO
  1492. /****** Object: StoredProcedure [dbo].[bpbsCvReviewInsert] Script Date: 2018/12/13 19:03:29 ******/
  1493. SET ANSI_NULLS ON
  1494. GO
  1495. SET QUOTED_IDENTIFIER ON
  1496. GO
  1497. --#####################################################
  1498. --创建时间:2014.12.25
  1499. --创建人:Nick
  1500. --说明:插入bsCvReview
  1501. --#####################################################
  1502. CREATE PROCEDURE [dbo].[bpbsCvReviewInsert]
  1503. (
  1504. @CvMainID INT,
  1505. @ManagerUserID INT,
  1506. @Reason VARCHAR(500)
  1507. )
  1508. AS
  1509. BEGIN
  1510. INSERT bsCvReview(cvMainID,VerifyMan,VerifyInfo)
  1511. VALUES (@CvMainID,@ManagerUserID,@Reason)
  1512. END
  1513. GO
  1514. /****** Object: StoredProcedure [dbo].[bpBsCvVerifyInsert] Script Date: 2018/12/13 19:03:29 ******/
  1515. SET ANSI_NULLS ON
  1516. GO
  1517. SET QUOTED_IDENTIFIER ON
  1518. GO
  1519. --修改Harry
  1520. --2017-2-21
  1521. --增加审核记录,用于计算审核延误 编号2
  1522. ---20181102 Sunshine 添加判断
  1523. CREATE PROCEDURE [dbo].[bpBsCvVerifyInsert]
  1524. (
  1525. @cvMainID INT,
  1526. @VerifyMan INT,
  1527. @VerifyResult TINYINT,
  1528. @VerifyInfo NVARCHAR(200)
  1529. )
  1530. AS
  1531. SET NOCOUNT ON
  1532. BEGIN
  1533. DECLARE @bsCvVerifyID AS INT
  1534. INSERT INTO bsCvVerify(cvMainID, VerifyMan, VerifyDate, VerifyResult, VerifyInfo)
  1535. VALUES(@cvMainID, @VerifyMan, GETDATE(), @VerifyResult, @VerifyInfo)
  1536. SET @bsCvVerifyID = @@IDENTITY
  1537. --插入审核延误记录表
  1538. ---20181102 Sunshine 添加判断
  1539. IF NOT EXISTS(SELECT TOP 1 AddDate FROM bsCvModify WHERE cvMainID = @cvMainID)
  1540. INSERT INTO logdb..VerifyDelayLog(verifyType, relationId, submitDate, verifyDate, verifyMan)
  1541. SELECT 2,@bsCvVerifyID, GETDATE(), GETDATE(), @VerifyMan
  1542. ELSE
  1543. INSERT INTO logdb..VerifyDelayLog(verifyType, relationId, submitDate, verifyDate, verifyMan)
  1544. SELECT 2,@bsCvVerifyID,(SELECT TOP 1 AddDate FROM bsCvModify WHERE cvMainID=@cvMainID ORDER BY adddate DESC), GETDATE(), @VerifyMan
  1545. --Harry Begin
  1546. IF @VerifyResult = 10
  1547. BEGIN
  1548. DECLARE @wxFansId INT, @paMainId INT
  1549. SELECT @wxFansId = a.id, @paMainId=b.paMainId
  1550. FROM wxFans a WITH(NOLOCK), cvMain b WITH(NOLOCK)
  1551. WHERE a.paMainId = b.paMainId
  1552. AND b.Id = @cvMainID
  1553. AND a.[Status] = 2
  1554. IF @wxFansId > 0
  1555. BEGIN
  1556. --插入到wxMessageSend表中(7. --简历审核未通过)
  1557. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CvMainID, AddDate)
  1558. SELECT 7, @wxFansId, @paMainId, @bsCvVerifyID, @cvMainID, GETDATE()
  1559. END
  1560. --Harry End
  1561. END
  1562. RETURN @bsCvVerifyID
  1563. END
  1564. GO
  1565. /****** Object: StoredProcedure [dbo].[bpbsCvVerifyLogBybsCvVerifyIDSelect] Script Date: 2018/12/13 19:03:30 ******/
  1566. SET ANSI_NULLS ON
  1567. GO
  1568. SET QUOTED_IDENTIFIER ON
  1569. GO
  1570. CREATE PROCEDURE [dbo].[bpbsCvVerifyLogBybsCvVerifyIDSelect]
  1571. (
  1572. @bsCvVerifyID INT
  1573. )
  1574. AS
  1575. BEGIN
  1576. SELECT * FROM bsCvVerifyLog WITH(NOLOCK) WHERE bsCvVerifyID = @bsCvVerifyID
  1577. END
  1578. GO
  1579. /****** Object: StoredProcedure [dbo].[bpBsCvVerifySelect] Script Date: 2018/12/13 19:03:30 ******/
  1580. SET ANSI_NULLS ON
  1581. GO
  1582. SET QUOTED_IDENTIFIER ON
  1583. GO
  1584. CREATE PROCEDURE [dbo].[bpBsCvVerifySelect]
  1585. (
  1586. @ID INT
  1587. )
  1588. AS
  1589. BEGIN
  1590. SELECT * FROM BsCvVerify WITH(NOLOCK) WHERE ID=@ID
  1591. END
  1592. GO
  1593. /****** Object: StoredProcedure [dbo].[bpBsCvVerifyUpdate] Script Date: 2018/12/13 19:03:30 ******/
  1594. SET ANSI_NULLS ON
  1595. GO
  1596. SET QUOTED_IDENTIFIER ON
  1597. GO
  1598. CREATE PROCEDURE [dbo].[bpBsCvVerifyUpdate]
  1599. (
  1600. @ID INT,
  1601. @VerifyResult TINYINT
  1602. )
  1603. AS
  1604. BEGIN TRY
  1605. UPDATE bsCvVerify SET VerifyResult=@VerifyResult WHERE ID=@ID
  1606. RETURN 1
  1607. END TRY
  1608. BEGIN CATCH
  1609. RETURN 0
  1610. END CATCH
  1611. GO
  1612. /****** Object: StoredProcedure [dbo].[bpbsDeadCompanyByStatisticsSelect] Script Date: 2018/12/13 19:03:30 ******/
  1613. SET ANSI_NULLS ON
  1614. GO
  1615. SET QUOTED_IDENTIFIER ON
  1616. GO
  1617. -- =============================================
  1618. -- Author: <Mice 123>
  1619. -- Create date: <2014-12-09>
  1620. -- Description: <死客户汇总查询>
  1621. -- Editer : mice 2014-12-15 增加@strPara条件(权限控制)
  1622. -- Editer : mice 2014-12-29 修改激活数量ActiveNum的时间依据为激活时间
  1623. -- Editer : mice 2014-12-30 修改激活时间和联系时间差在两个月之内的,激活数有效
  1624. -- Editer : mice 2014-12-31 需改bug(left out join 为 full out join)
  1625. -- =============================================
  1626. CREATE PROCEDURE [dbo].[bpbsDeadCompanyByStatisticsSelect]
  1627. (
  1628. @group INT = 0,
  1629. @value INT = NULL,
  1630. @begintime1 VARCHAR(20) = '',
  1631. @endtime1 VARCHAR(20) = '',
  1632. @begintime2 VARCHAR(20) = '',
  1633. @endtime2 VARCHAR(20) = '',
  1634. @strPara VARCHAR(200) = NULL
  1635. )
  1636. AS
  1637. BEGIN
  1638. DECLARE @SQL AS VARCHAR(3000), @COLS AS VARCHAR(1000), @strWhere AS VARCHAR(300), @activeNumWhere AS VARCHAR(300)
  1639. SELECT @COLS = ' COUNT(c.id) AS totalCOUNT,
  1640. SUM(CASE ISNULL(c.ActiveDate,0) WHEN 0 THEN 1 ELSE 0 END) AS NotActiveNum,
  1641. SUM(CASE ISNULL(c.ContactResult,0) WHEN 0 THEN 1 ELSE 0 END) AS COUNT0,
  1642. SUM(CASE c.ContactResult WHEN 1 THEN 1 ELSE 0 END) AS COUNT1,
  1643. SUM(CASE c.ContactResult WHEN 2 THEN 1 ELSE 0 END) AS COUNT2,
  1644. SUM(CASE c.ContactResult WHEN 3 THEN 1 ELSE 0 END) AS COUNT3,
  1645. SUM(CASE c.ContactResult WHEN 4 THEN 1 ELSE 0 END) AS COUNT4,
  1646. SUM(CASE c.ContactResult WHEN 5 THEN 1 ELSE 0 END) AS COUNT5,
  1647. SUM(CASE c.ContactResult WHEN 6 THEN 1 ELSE 0 END) AS COUNT6 ',
  1648. @strWhere = '',
  1649. @activeNumWhere = ''
  1650. IF @begintime1 > ''
  1651. BEGIN
  1652. SET @strWhere = @strWhere + ' AND c.DeadDate > ''' + @begintime1 +''''
  1653. SET @activeNumWhere = @activeNumWhere + ' AND c.DeadDate > ''' + @begintime1 +''''
  1654. END
  1655. IF @endtime1 > ''
  1656. BEGIN
  1657. SET @strWhere = @strWhere + ' AND c.DeadDate < ''' + @endtime1 +''''
  1658. SET @activeNumWhere = @activeNumWhere + ' AND c.DeadDate < ''' + @endtime1 +''''
  1659. END
  1660. IF @begintime2 > ''
  1661. BEGIN
  1662. SET @strWhere = @strWhere + ' AND c.ContactDate > ''' + @begintime2 +''''
  1663. SET @activeNumWhere = @activeNumWhere + ' AND c.ActiveDate > ''' + @begintime2 +''''
  1664. END
  1665. IF @endtime2 > ''
  1666. BEGIN
  1667. SET @strWhere = @strWhere + ' AND C.ContactDate < ''' + @endtime2 +''''
  1668. SET @activeNumWhere = @activeNumWhere + ' AND c.ActiveDate < ''' + @endtime2 +''''
  1669. END
  1670. IF @strPara > ''
  1671. BEGIN
  1672. SET @strWhere = @strWhere + @strPara
  1673. SET @activeNumWhere = @activeNumWhere + @strPara
  1674. END
  1675. IF @value IS NOT NULL AND @VALUE > 0
  1676. BEGIN
  1677. IF @group = 1 -- 按照地区分组查询显示
  1678. BEGIN
  1679. SET @strWhere = @strWhere + ' AND a.dcProvinceID = ' + CONVERT(VARCHAR(10),@value)
  1680. SET @activeNumWhere = @activeNumWhere + ' AND a.dcProvinceID = ' + CONVERT(VARCHAR(10),@value)
  1681. END
  1682. ELSE IF @group = 2 -- 按照招聘顾问工号分组查询显示
  1683. BEGIN
  1684. SET @strWhere = @strWhere + ' AND a.ConsultantID = ' + CONVERT(VARCHAR(10),@value)
  1685. SET @activeNumWhere = @activeNumWhere + ' AND a.ConsultantID = ' + CONVERT(VARCHAR(10),@value)
  1686. END
  1687. ELSE -- 按照部门分组查询显示(默认显示方式)
  1688. BEGIN
  1689. SET @strWhere = @strWhere + ' AND b.deptID = ' + CONVERT(VARCHAR(10),@value)
  1690. SET @activeNumWhere = @activeNumWhere + ' AND b.deptID = ' + CONVERT(VARCHAR(10),@value)
  1691. END
  1692. END
  1693. IF @group = 1 -- 按照地区分组查询显示
  1694. BEGIN
  1695. SET @SQL = ' SELECT T1.*,T2.* FROM (
  1696. SELECT a.dcProvinceID as groupID,
  1697. ( SELECT x.ProvinceName FROM maindb..dcprovince x WITH(NOLOCK) WHERE x.id=a.dcProvinceID) AS groupName,
  1698. COUNT(1) AS ActiveNum
  1699. FROM maindb..cpmain a WITH(NOLOCK) , Maindb..bsDeadCompany c WITH(NOLOCK)
  1700. WHERE a.id = c.cpMainID AND c.ActiveDate IS NOT NULL
  1701. AND c.ContactDate IS NOT NULL AND DATEADD(MONTH,2,c.ContactDate ) > c.ActiveDate
  1702. ' + @activeNumWhere + '
  1703. GROUP BY a.dcProvinceID )
  1704. T1 FULL OUTER JOIN (
  1705. SELECT a.dcProvinceID as groupID2 ,
  1706. ( SELECT x.ProvinceName FROM maindb..dcprovince x WITH(NOLOCK) WHERE x.id=a.dcProvinceID) AS groupName2,
  1707. ' + @COLS +'
  1708. FROM maindb..cpmain a WITH(NOLOCK) , Maindb..bsDeadCompany c WITH(NOLOCK)
  1709. WHERE a.id = c.cpMainID
  1710. ' + @strWhere + '
  1711. GROUP BY a.dcProvinceID )
  1712. T2 ON T2.groupID2 = T1.groupID
  1713. ORDER BY T2.groupID2, T1.groupID '
  1714. END
  1715. ELSE IF @group = 2 -- 按照招聘顾问工号分组查询显示
  1716. BEGIN
  1717. SET @SQL = ' SELECT T1.*,T2.* FROM (
  1718. SELECT a.ConsultantID as groupID,
  1719. ( SELECT x.name FROM maindb..manageruser x WITH(NOLOCK) WHERE x.id=a.ConsultantID) AS groupName,
  1720. COUNT(1) AS ActiveNum
  1721. FROM maindb..cpmain a WITH(NOLOCK) , Maindb..bsDeadCompany c WITH(NOLOCK)
  1722. WHERE a.id = c.cpMainID AND c.ActiveDate IS NOT NULL
  1723. AND c.ContactDate IS NOT NULL AND DATEADD(MONTH,2,c.ContactDate ) > c.ActiveDate
  1724. ' + @activeNumWhere + '
  1725. GROUP BY a.ConsultantID )
  1726. T1 FULL OUTER JOIN (
  1727. SELECT a.ConsultantID as groupID2 ,
  1728. ( SELECT x.name FROM maindb..manageruser x WITH(NOLOCK) WHERE x.id=a.ConsultantID) AS groupName2,
  1729. ' + @COLS +'
  1730. FROM maindb..cpmain a WITH(NOLOCK) , Maindb..bsDeadCompany c WITH(NOLOCK)
  1731. WHERE a.id = c.cpMainID
  1732. ' + @strWhere + '
  1733. GROUP BY a.ConsultantID )
  1734. T2 ON T2.groupID2 = T1.groupID
  1735. ORDER BY T2.groupID2, T1.groupID '
  1736. END
  1737. ELSE -- 按照部门分组查询显示(默认显示方式)
  1738. BEGIN
  1739. SET @SQL = ' SELECT T1.*,T2.* FROM (
  1740. SELECT b.deptID as groupID,
  1741. ( SELECT x.DeptName FROM maindb..dept x WITH(NOLOCK) WHERE x.id=b.deptID ) AS groupName,
  1742. COUNT(1) AS ActiveNum
  1743. FROM maindb..cpmain a WITH(NOLOCK), oadb..manageruser b WITH(NOLOCK), Maindb..bsDeadCompany c WITH(NOLOCK)
  1744. WHERE a.ConsultantID = b.id AND a.id = c.cpMainID AND c.ActiveDate IS NOT NULL
  1745. AND c.ContactDate IS NOT NULL AND DATEADD(MONTH,2,c.ContactDate ) > c.ActiveDate
  1746. ' + @activeNumWhere + '
  1747. GROUP BY b.deptID )
  1748. T1 FULL OUTER JOIN (
  1749. SELECT b.deptID as groupID2 ,
  1750. ( SELECT x.DeptName FROM maindb..dept x WITH(NOLOCK) WHERE x.id=b.deptID ) AS groupName2,
  1751. ' + @COLS +'
  1752. FROM maindb..cpmain a WITH(NOLOCK), oadb..manageruser b WITH(NOLOCK), Maindb..bsDeadCompany c WITH(NOLOCK)
  1753. WHERE a.ConsultantID = b.id AND a.id = c.cpMainID
  1754. ' + @strWhere + '
  1755. GROUP BY b.deptID )
  1756. T2 ON T2.groupID2 = T1.groupID
  1757. ORDER BY T2.groupID2, T1.groupID '
  1758. END
  1759. --PRINT @Sql
  1760. EXEC(@SQL)
  1761. END
  1762. GO
  1763. /****** Object: StoredProcedure [dbo].[bpbsDeadCompanyInsert] Script Date: 2018/12/13 19:03:30 ******/
  1764. SET ANSI_NULLS ON
  1765. GO
  1766. SET QUOTED_IDENTIFIER ON
  1767. GO
  1768. -- =============================================
  1769. -- Author: <Mice 123>
  1770. -- Create date: <2014-12-05>
  1771. -- Description: <死客户记录生成>
  1772. -- Editer: 修改Mice 2015-2-5 修改时间格式为 2015-02-05
  1773. -- =============================================
  1774. CREATE PROCEDURE [dbo].[bpbsDeadCompanyInsert]
  1775. AS
  1776. BEGIN
  1777. SET NOCOUNT ON
  1778. DECLARE @begindate AS VARCHAR(100), @enddate AS VARCHAR(100), @datetime AS VARCHAR(100)
  1779. SELECT @enddate=CONVERT(VARCHAR(100), DATEADD(MONTH,-6,getDate()), 23) ,
  1780. @begindate=CONVERT(VARCHAR(100), DATEADD(MONTH,-7,getDate()), 23),
  1781. @datetime=CONVERT(VARCHAR(100), DATEADD(MONTH,-1,getDate()), 23)
  1782. IF NOT EXISTS(SELECT 'X' FROM Maindb..bsDeadCompany WITH(NOLOCK)) --初次生成遍历所有的
  1783. BEGIN
  1784. INSERT INTO bsDeadCompany(cpMainID,DeadDate,AddDate)
  1785. SELECT a.ID,a.LastLoginDate,getDate()
  1786. FROM Maindb..cpMain a WITH(NOLOCK)
  1787. WHERE MemberType=2 AND ConsultantDate < @datetime AND LastLoginDate < @enddate
  1788. AND (SELECT COUNT(1) FROM caOrder WITH(NOLOCK) WHERE Paid>0 AND EndDate > @datetime
  1789. AND (OrderType=1 OR OrderType=2 OR OrderType=8) AND cpMainID=a.id) = 0
  1790. ORDER BY LastLoginDate
  1791. END
  1792. ELSE --遍历新增月份的死客户
  1793. BEGIN
  1794. INSERT INTO bsDeadCompany(cpMainID,DeadDate,AddDate)
  1795. SELECT a.ID,a.LastLoginDate,getDate()
  1796. FROM Maindb..cpMain a WITH(NOLOCK)
  1797. WHERE MemberType=2
  1798. AND ConsultantDate < @datetime
  1799. AND LastLoginDate < @enddate
  1800. AND LastLoginDate > @begindate
  1801. AND (SELECT COUNT(1) FROM caOrder WITH(NOLOCK) WHERE Paid>0 AND EndDate > @datetime
  1802. AND (OrderType=1 OR OrderType=2 OR OrderType=8) AND cpMainID=a.id) = 0
  1803. AND a.Id NOT IN(SELECT cpMainId FROM bsDeadCompany WITH(NOLOCK) WHERE ActiveDate IS NULL)
  1804. ORDER BY LastLoginDate
  1805. END
  1806. SET NOCOUNT OFF
  1807. END
  1808. GO
  1809. /****** Object: StoredProcedure [dbo].[bpbsDeadCompanySelect] Script Date: 2018/12/13 19:03:31 ******/
  1810. SET ANSI_NULLS ON
  1811. GO
  1812. SET QUOTED_IDENTIFIER ON
  1813. GO
  1814. -- Author: <Mice 123>
  1815. -- Create date: <2014-12-09>
  1816. -- Description: <死客户列表查询>
  1817. -- 修改: 2014-12-12 mice 添加strWhere 查询条件
  1818. -- 修改: 2014-12-24 mice 增加查询条件(企业ID、企业名称)
  1819. -- 修改: 2014-12-30 mice 增加查询条件激活时间
  1820. -- 修改联系时间、激活时间为二选一查询
  1821. -- 修改: 2015-01-13 john 增加如果valid=0则ContactResult=0 OR IS NULL
  1822. -- 修改: 2015-01-20 NICK 加入按照联系活动搜索
  1823. -- 修改: 2015-03-20 Mice 加入查询条件 NOT (ActiveDate IS NOT NULL and ContactResult IS NULL )
  1824. -- 修改: 2018-5-9 Harry 加入当前会员状态
  1825. -- 修改: 2018-6-11 Harry 查询联系状态是按照联系时间排序
  1826. -- 修改: 2018-10-12 Alen 死客户列表增加是否限制登陆显示
  1827. -- =============================================
  1828. -- =============================================
  1829. CREATE PROCEDURE [dbo].[bpbsDeadCompanySelect]
  1830. (
  1831. @deptid INT = NULL, --部门ID
  1832. @pid INT = NULL, --省份ID
  1833. @valid VARCHAR(5) = NULL, --联系结果
  1834. @active INT = NULL, --激活状态
  1835. @manageruserid VARCHAR(50) = NULL, --顾问ID
  1836. @begintime1 VARCHAR(50) = NULL, --截点时间-起始时间
  1837. @endtime1 VARCHAR(50) = NULL, --截点时间-终止时间
  1838. @itemtime INT = 0, --1.激活时间; 0.联系时间
  1839. @begintime2 VARCHAR(50) = NULL, --激活/联系时间起始时间
  1840. @endtime2 VARCHAR(50) = NULL, --激活/联系时间终止时间
  1841. @strWhere VARCHAR(500) = NULL, --权限控制语句
  1842. @searchItem INT = 0, --0.企业ID; 1.企业名称
  1843. @searchText VARCHAR(50) = NULL, --企业ID/名称
  1844. @Page SMALLINT = 1 , --页数
  1845. @ContactID INT
  1846. )
  1847. AS
  1848. BEGIN
  1849. CREATE TABLE #T(
  1850. TitleID BIGINT,
  1851. ID int ,
  1852. cpMainID int,
  1853. ContactDate smalldatetime,
  1854. ContactMan int,
  1855. ContactResult int,
  1856. DeadDate smalldatetime,
  1857. ActiveDate smalldatetime,
  1858. ReMark nvarchar(500),
  1859. AddDate smalldatetime,
  1860. cpName nvarchar(500),
  1861. ConsultantID INT,
  1862. RegDate SMALLDATETIME,
  1863. IsLock BIT,
  1864. LastLoginDate SMALLDATETIME,
  1865. Consultantname nvarchar(50),
  1866. ContactManname nvarchar(50),
  1867. ContactDoneDate SMALLDATETIME,
  1868. ContactDoneID INT,
  1869. ContactDoneMan INT,
  1870. ContactDoneAdd SMALLDATETIME,
  1871. ContactNotDoneDate SMALLDATETIME,
  1872. ContactNotDoneID INT,
  1873. ContactNotDoneMan INT,
  1874. ContactNotDoneAdd SMALLDATETIME,
  1875. TotalNum INT,
  1876. HasPaid BIT,
  1877. MemberType INT,
  1878. IsLimitLogin INT
  1879. )
  1880. DECLARE @SQL AS VARCHAR(3000)
  1881. SET @SQL = ' INSERT INTO #T
  1882. ( TitleID, id ,cpMainID, ContactDate,ContactMan,ContactResult,DeadDate ,ActiveDate, ReMark, AddDate,
  1883. cpName,ConsultantID ,RegDate, IsLock,LastLoginDate,MemberType,IsLimitLogin)
  1884. SELECT TOP 3000 ROW_NUMBER() OVER ( ORDER BY a.DeadDate DESC ) AS TitleID ,a.id ,a.cpMainID, a.ContactDate,a.ContactMan,a.ContactResult,a.DeadDate ,a.ActiveDate, a.ReMark, a.AddDate,
  1885. b.name AS cpName, b.ConsultantID, b.RegDate, b.IsLock, b.LastLoginDate,b.MemberType,b.IsLimitLogin
  1886. FROM Maindb..bsDeadCompany a WITH(NOLOCK) , Maindb..cpMain b WITH(NOLOCK)
  1887. WHERE a.cpMainID=b.id AND NOT (ActiveDate IS NOT NULL and ContactResult IS NULL ) '
  1888. IF @strWhere <> ''
  1889. BEGIN
  1890. SET @SQL = @SQL + @strWhere
  1891. END
  1892. IF @pid > 0
  1893. SET @SQL = @SQL + ' AND b.dcProvinceID = ' + CONVERT(VARCHAR(10),@pid)
  1894. IF @valid <> ''
  1895. BEGIN
  1896. IF @valid = '0'
  1897. SET @SQL = @SQL + ' AND (a.ContactResult = 0 OR a.ContactResult IS NULL)'
  1898. ELSE
  1899. SET @SQL = @SQL + ' AND a.ContactResult = ' + @valid
  1900. END
  1901. IF @active = 1
  1902. SET @SQL = @SQL + ' AND a.ActiveDate IS NOT NULL '
  1903. ELSE IF @active = 2
  1904. SET @SQL = @SQL + ' AND a.ActiveDate IS NULL '
  1905. IF @manageruserid <> ''
  1906. BEGIN
  1907. SET @SQL = @SQL + ' AND b.ConsultantID = ' + @manageruserid
  1908. END
  1909. ELSE
  1910. BEGIN
  1911. IF @deptid > 0
  1912. SET @SQL = @SQL + ' AND b.ConsultantID IN ( SELECT x.id FROM maindb..manageruser x WITH(NOLOCK) WHERE x.deptid = ' + CONVERT(VARCHAR(10),@deptid) + ' ) '
  1913. END
  1914. IF @begintime1 <> ''
  1915. BEGIN
  1916. SET @SQL = @SQL + ' AND a.DeadDate > ''' + @begintime1 +''''
  1917. END
  1918. IF @endtime1 <> ''
  1919. BEGIN
  1920. SET @SQL = @SQL + ' AND a.DeadDate < ''' + @endtime1 +''''
  1921. END
  1922. IF @begintime2 <> ''
  1923. BEGIN
  1924. IF @itemtime = 1
  1925. SET @SQL = @SQL + ' AND a.ActiveDate > ''' + @begintime2 +''''
  1926. ELSE
  1927. SET @SQL = @SQL + ' AND a.ContactDate > ''' + @begintime2 +''''
  1928. END
  1929. --加入按照联系活动情况搜索 nick
  1930. IF @ContactID<>0
  1931. BEGIN
  1932. SET @SQL = @SQL + ' AND (SELECT TOP 1 CloseDate FROM MainDB..contact WITH(NOLOCK) WHERE CompanyId = a.cpMainID ORDER BY CloseDate DESC) < ''' + CONVERT(VARCHAR(50),DATEADD (DAY ,-@ContactID, GETDATE()))+''''
  1933. END
  1934. IF @endtime2 <> ''
  1935. BEGIN
  1936. IF @itemtime = 1
  1937. SET @SQL = @SQL + ' AND a.ActiveDate < ''' + @endtime2 +''''
  1938. ELSE
  1939. SET @SQL = @SQL + ' AND a.ContactDate < ''' + @endtime2 +''''
  1940. END
  1941. IF @searchText <> ''
  1942. BEGIN
  1943. IF @searchItem = 0
  1944. BEGIN
  1945. SET @SQL = @SQL + ' AND a.cpMainID = '+@searchText
  1946. END
  1947. ELSE
  1948. BEGIN
  1949. SET @SQL = @SQL + ' AND b.Name like ''%' + @searchText + '%'''
  1950. END
  1951. END
  1952. IF @valid>0
  1953. BEGIN
  1954. SET @SQL = @SQL + ' ORDER BY a.ContactDate DESC'
  1955. END
  1956. ELSE
  1957. BEGIN
  1958. SET @SQL = @SQL + ' ORDER BY a.DeadDate DESC'
  1959. END
  1960. EXEC(@SQL)
  1961. UPDATE #T SET Consultantname = (SELECT c.name FROM Maindb..manageruser c WHERE c.id = #T.ConsultantID ),
  1962. HasPaid = (SELECT TOP 1 ID FROM Maindb..caOrder WHERE Paid>0 AND OpenDate IS NOT NULL AND cpMainID=#T.cpMainID AND IsDeleted = 0),
  1963. ContactManname = (SELECT c.name FROM Maindb..manageruser c WHERE c.id = #T.ContactMan ),
  1964. ContactDoneDate = (SELECT top 1 e.BeginTime FROM maindb..contact e WITH(NOLOCK) WHERE e.companyid=#T.cpMainID AND e.status = 2 ORDER BY e.begintime DESC ) ,
  1965. ContactDoneID = (SELECT top 1 e.ID FROM maindb..contact e WITH(NOLOCK) WHERE e.companyid=#T.cpMainID AND e.status = 2 ORDER BY e.begintime DESC ) ,
  1966. ContactDoneMan = (SELECT top 1 e.ManagerUserID FROM maindb..contact e WITH(NOLOCK) WHERE e.companyid=#T.cpMainID AND e.status = 2 ORDER BY e.begintime DESC ) ,
  1967. ContactDoneAdd = (SELECT top 1 e.AddDate FROM maindb..contact e WITH(NOLOCK) WHERE e.companyid=#T.cpMainID AND e.status = 2 ORDER BY e.begintime DESC ) ,
  1968. ContactNotDoneDate = (SELECT top 1 e.BeginTime FROM maindb..contact e WITH(NOLOCK) WHERE e.companyid=#T.cpMainID AND e.status = 1 ORDER BY e.begintime DESC ) ,
  1969. ContactNotDoneID = (SELECT top 1 e.ID FROM maindb..contact e WITH(NOLOCK) WHERE e.companyid=#T.cpMainID AND e.status = 1 ORDER BY e.begintime DESC ) ,
  1970. ContactNotDoneMan = (SELECT top 1 e.ManagerUserID FROM maindb..contact e WITH(NOLOCK) WHERE e.companyid=#T.cpMainID AND e.status = 1 ORDER BY e.begintime DESC ) ,
  1971. ContactNotDoneAdd = (SELECT top 1 e.AddDate FROM maindb..contact e WITH(NOLOCK) WHERE e.companyid=#T.cpMainID AND e.status = 1 ORDER BY e.begintime DESC )
  1972. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1973. UPDATE #T SET TotalNum=( SELECT COUNT(*) FROM #T ) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page * 20
  1974. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1) * 20 AND TitleID <= @Page * 20
  1975. DROP TABLE #T
  1976. END
  1977. GO
  1978. /****** Object: StoredProcedure [dbo].[bpbsJobProblemByCpMainIDDelete] Script Date: 2018/12/13 19:03:31 ******/
  1979. SET ANSI_NULLS ON
  1980. GO
  1981. SET QUOTED_IDENTIFIER ON
  1982. GO
  1983. --#####################################################
  1984. --创建时间:2014.12.18
  1985. --创建人:Nick
  1986. --说明:限制登陆删除bsJobProblem
  1987. --#####################################################
  1988. CREATE PROCEDURE [dbo].[bpbsJobProblemByCpMainIDDelete]
  1989. (
  1990. @CpmainID INT
  1991. )
  1992. AS
  1993. BEGIN
  1994. DELETE FROM bsJobProblem WHERE cpMainID = @CpmainID
  1995. End
  1996. GO
  1997. /****** Object: StoredProcedure [dbo].[bpbsJobProblemByCpMainIDSelect] Script Date: 2018/12/13 19:03:31 ******/
  1998. SET ANSI_NULLS ON
  1999. GO
  2000. SET QUOTED_IDENTIFIER ON
  2001. GO
  2002. --#####################################################
  2003. --创建时间:2015.1.12
  2004. --创建人:Nick
  2005. --说明:根据cpmainid获取bsJobProblem
  2006. --#####################################################
  2007. CREATE PROCEDURE [dbo].[bpbsJobProblemByCpMainIDSelect]
  2008. (
  2009. @CpMainID INT
  2010. )
  2011. AS
  2012. BEGIN
  2013. SELECT TOP 1 Reason,AddMan FROM bsJobProblem
  2014. WHERE cpMainID=@CpMainID ORDER BY AddDate DESC
  2015. End
  2016. GO
  2017. /****** Object: StoredProcedure [dbo].[bpbsJobProblemDelete] Script Date: 2018/12/13 19:03:32 ******/
  2018. SET ANSI_NULLS ON
  2019. GO
  2020. SET QUOTED_IDENTIFIER ON
  2021. GO
  2022. --#####################################################
  2023. --创建时间:2015.1.8
  2024. --创建人:Nick
  2025. --说明:限制登陆删除bsJobProblem
  2026. --#####################################################
  2027. CREATE PROCEDURE [dbo].[bpbsJobProblemDelete]
  2028. AS
  2029. BEGIN
  2030. DELETE FROM bsJobProblem
  2031. WHERE cpMainID IN (
  2032. SELECT ID FROM cpMain WITH(NOLOCK)
  2033. WHERE ID=bsJobProblem.cpMainID
  2034. AND (
  2035. SELECT COUNT(1) FROM Job WHERE IsDelete=0 AND cpMainID=cpMain.ID
  2036. )=0
  2037. )
  2038. End
  2039. GO
  2040. /****** Object: StoredProcedure [dbo].[bpbsJobProblemSelect] Script Date: 2018/12/13 19:03:32 ******/
  2041. SET ANSI_NULLS ON
  2042. GO
  2043. SET QUOTED_IDENTIFIER ON
  2044. GO
  2045. --#####################################################
  2046. --创建时间:2015.1.8
  2047. --创建人:Nick
  2048. --说明:获取bsJobProblem
  2049. --#####################################################
  2050. CREATE PROCEDURE [dbo].[bpbsJobProblemSelect]
  2051. AS
  2052. BEGIN
  2053. SELECT a.cpMainID,c.IsLimitLogin,a.Addman,c.consultantid,c.haslicence,Reason,c.RegDate,c.Name cpName,
  2054. a.Adddate From bsJobProblem a With(Nolock),cpMain c With(Nolock)
  2055. WHERE a.cpMainID=c.ID
  2056. End
  2057. GO
  2058. /****** Object: StoredProcedure [dbo].[bpbsManagerUserActionInsert] Script Date: 2018/12/13 19:03:32 ******/
  2059. SET ANSI_NULLS ON
  2060. GO
  2061. SET QUOTED_IDENTIFIER ON
  2062. GO
  2063. -----------------
  2064. --创建日期:2010-11-15
  2065. --创建人:lambo
  2066. --功能说明:增加后台用户对单位的操作记录
  2067. --用于后台企业用户管理模块
  2068. -----------------
  2069. CREATE PROCEDURE [dbo].[bpbsManagerUserActionInsert]
  2070. (
  2071. @cpMainID INT,
  2072. @Action VARCHAR(100),
  2073. @Reason VARCHAR(200),
  2074. @ManagerUserID INT
  2075. )
  2076. AS
  2077. BEGIN TRY
  2078. DECLARE @MaxID AS INT
  2079. INSERT INTO bsManagerUserAction (cpMainID,Action,Reason,ManagerUserID,AddDate)
  2080. VALUES(@cpMainID,@Action,@Reason,@ManagerUserID,GETDATE())
  2081. SET @MaxID = @@IDENTITY
  2082. END TRY
  2083. BEGIN CATCH
  2084. GOTO ERR
  2085. END CATCH
  2086. RETURN @MaxID
  2087. ERR:
  2088. BEGIN
  2089. RETURN 0
  2090. END
  2091. GO
  2092. /****** Object: StoredProcedure [dbo].[bpbsManagerUserActionSelect] Script Date: 2018/12/13 19:03:32 ******/
  2093. SET ANSI_NULLS ON
  2094. GO
  2095. SET QUOTED_IDENTIFIER ON
  2096. GO
  2097. --获取招聘顾问分配记录-------------------
  2098. --添加人Harry -----------------------
  2099. --添加时间:2014-12-15---------------
  2100. CREATE PROCEDURE [dbo].[bpbsManagerUserActionSelect]
  2101. (
  2102. @WHERE VARCHAR(2000)
  2103. )
  2104. AS
  2105. BEGIN
  2106. DECLARE @SQL AS VARCHAR(2000)
  2107. SET @WHERE = dbo.SafeSql(@WHERE)
  2108. SET @SQL='
  2109. SELECT top 2000 *,
  2110. (SELECT Name
  2111. FROM cpMain WITH(NOLOCK)
  2112. WHERE cpMain.Id = bsManagerUserAction.cpMainID) CompanyName,
  2113. (SELECT regdate
  2114. FROM cpMain WITH(NOLOCK)
  2115. WHERE cpMain.Id = bsManagerUserAction.cpMainID) regdate
  2116. FROM bsManagerUserAction WITH(NOLOCK)
  2117. WHERE 1=1 '+ @WHERE
  2118. EXEC(@SQL)
  2119. END
  2120. GO
  2121. /****** Object: StoredProcedure [dbo].[bpbsMobileMessageDelete] Script Date: 2018/12/13 19:03:32 ******/
  2122. SET ANSI_NULLS ON
  2123. GO
  2124. SET QUOTED_IDENTIFIER ON
  2125. GO
  2126. --bpbsMobileMessageDelete 100
  2127. --#####################################################
  2128. --创建时间:2015-01-28
  2129. --创建人:Andy
  2130. --说明:删除一条短信推广内容
  2131. --#####################################################
  2132. CREATE PROCEDURE [dbo].[bpbsMobileMessageDelete]
  2133. (
  2134. @ID INT
  2135. )
  2136. AS
  2137. BEGIN
  2138. DELETE FROM bsMobileMessage WHERE ID = @ID
  2139. END
  2140. GO
  2141. /****** Object: StoredProcedure [dbo].[bpbsMobileMessageSave] Script Date: 2018/12/13 19:03:33 ******/
  2142. SET ANSI_NULLS ON
  2143. GO
  2144. SET QUOTED_IDENTIFIER ON
  2145. GO
  2146. --bpbsMobileMessageSave 1009,32, '2015-01-01', '2016-01-01', 'TEST1', 119
  2147. --#####################################################
  2148. --创建时间:2015-01-28
  2149. --创建人:Andy
  2150. --说明:保存一条短信推广内容
  2151. --#####################################################
  2152. CREATE PROCEDURE [dbo].[bpbsMobileMessageSave]
  2153. (
  2154. @ID INT, --如果=0,则是insert
  2155. @ProvinceID INT,
  2156. @BeginTime DATETIME,
  2157. @EndTime DATETIME,
  2158. @Message NVARCHAR(1000),
  2159. @ManagerUserID INT
  2160. )
  2161. AS
  2162. BEGIN
  2163. IF @ID = 0
  2164. INSERT INTO bsMobileMessage(dcProvinceId, [Message], BeginDate, EndDate, AddMan, AddDate)
  2165. VALUES(@ProvinceID, @Message, @BeginTime, @EndTime, @ManagerUserID, GETDATE())
  2166. ELSE
  2167. UPDATE bsMobileMessage
  2168. SET dcProvinceID = @ProvinceID, [Message] = @Message, BeginDate = @BeginTime, EndDate = @EndTime
  2169. WHERE ID = @ID
  2170. END
  2171. GO
  2172. /****** Object: StoredProcedure [dbo].[bpbsMobileMessageSelect] Script Date: 2018/12/13 19:03:33 ******/
  2173. SET ANSI_NULLS ON
  2174. GO
  2175. SET QUOTED_IDENTIFIER ON
  2176. GO
  2177. --bpbsMobileMessageSelect 1,0,'', '2011-01-01'
  2178. --创建人 Andy
  2179. --时间 2015-01-28
  2180. --查询短信推广内容列表
  2181. CREATE PROCEDURE [dbo].[bpbsMobileMessageSelect]
  2182. (
  2183. @ProvinceID INT,
  2184. @DateType INT,--0:开始时间,1:结束时间,2:添加时间
  2185. @BeginDate VARCHAR(10),
  2186. @EndDate VARCHAR(10)
  2187. )
  2188. AS
  2189. BEGIN
  2190. DECLARE @SQL VARCHAR(1000)
  2191. SET @SQL = 'SELECT * FROM bsMobileMessage WITH(NOLOCK) WHERE 1 = 1 '
  2192. IF @ProvinceID > 0
  2193. SET @SQL = @SQL + ' AND dcProvinceID = ' + LTRIM(STR(@ProvinceID))
  2194. IF @DateType = 0
  2195. BEGIN
  2196. IF LEN(@BeginDate) > 0
  2197. SET @SQL = @SQL + ' AND BeginDate >= ''' + @BeginDate + ''''
  2198. IF LEN(@EndDate) > 0
  2199. SET @SQL = @SQL + ' AND BeginDate <= ''' + @EndDate + ''''
  2200. END
  2201. IF @DateType = 1
  2202. BEGIN
  2203. IF LEN(@BeginDate) > 0
  2204. SET @SQL = @SQL + ' AND EndDate >= ''' + @BeginDate + ''''
  2205. IF LEN(@EndDate) > 0
  2206. SET @SQL = @SQL + ' AND EndDate <= ''' + @EndDate + ''''
  2207. END
  2208. ELSE IF @DateType = 2
  2209. BEGIN
  2210. IF LEN(@BeginDate) > 0
  2211. SET @SQL = @SQL + ' AND AddDate >= ''' + @BeginDate + ''''
  2212. IF LEN(@EndDate) > 0
  2213. SET @SQL = @SQL + ' AND AddDate <= ''' + @EndDate + ''''
  2214. END
  2215. SET @SQL = @SQL + ' ORDER BY EndDate DESC, ID DESC '
  2216. --PRINT(@SQL)
  2217. EXEC (@SQL)
  2218. END
  2219. GO
  2220. /****** Object: StoredProcedure [dbo].[bpbsMobileSpreadByCountSelect] Script Date: 2018/12/13 19:03:33 ******/
  2221. SET ANSI_NULLS ON
  2222. GO
  2223. SET QUOTED_IDENTIFIER ON
  2224. GO
  2225. --#####################################################
  2226. --创建时间:2015.2.3
  2227. --创建人:Andy
  2228. --说明:根据条件获取bsMobileSpread的行数
  2229. --#####################################################
  2230. --bpbsMobileSpreadByCountSelect 1, '20140101'
  2231. CREATE PROCEDURE [dbo].[bpbsMobileSpreadByCountSelect]
  2232. (
  2233. @AddMan INT, --被查询的ID
  2234. @ExportDate VARCHAR(8) --20130805
  2235. )
  2236. AS
  2237. BEGIN
  2238. SELECT Count(*) Cnt
  2239. FROM bsMobileSpread
  2240. WHERE AddMan = @AddMan AND ExportDate = @ExportDate
  2241. END
  2242. GO
  2243. /****** Object: StoredProcedure [dbo].[bpbsMobileSpreadByExportMobileNoSelect] Script Date: 2018/12/13 19:03:33 ******/
  2244. SET ANSI_NULLS ON
  2245. GO
  2246. SET QUOTED_IDENTIFIER ON
  2247. GO
  2248. --bpbsMobileSpreadByExportMobileNoSelect ' ', 119
  2249. --创建人 Andy
  2250. --时间 2015-01-23
  2251. --导出用户信息员短信推广内容手机号
  2252. CREATE PROCEDURE [dbo].[bpbsMobileSpreadByExportMobileNoSelect]
  2253. (
  2254. @Where VARCHAR(1000),
  2255. @AddMan INT
  2256. )
  2257. AS
  2258. BEGIN
  2259. SET @Where = dbo.SafeSql(@Where)
  2260. --查询共有多少条记录
  2261. DECLARE @Cnt INT
  2262. SELECT @Cnt = Count(*)
  2263. FROM bsMobileSpread
  2264. WHERE AddMan = @AddMan AND ExportDate = CONVERT(VARCHAR(10), GETDATE(), 112)
  2265. DECLARE @CntLeave INT
  2266. SET @CntLeave = 100 - @Cnt
  2267. IF @CntLeave < 0
  2268. SET @CntLeave = 100
  2269. ELSE IF @CntLeave > 100
  2270. SET @CntLeave = 100
  2271. --更新日期
  2272. DECLARE @SQL VARCHAR(1000)
  2273. SET @SQL = '
  2274. UPDATE bsMobileSpread
  2275. SET ExportDate = CONVERT(VARCHAR(8), GETDATE(), 112)'
  2276. SET @SQL = @SQL + ' WHERE ID IN(SELECT TOP '+ LTRIM(STR(@Cnt)) + ' ID FROM bsMobileSpread '
  2277. SET @SQL = @SQL + @Where + ' )'
  2278. --PRINT(@SQL)
  2279. EXEC (@SQL)
  2280. --查出结果
  2281. SELECT MobileNO
  2282. FROM bsMobileSpread
  2283. WHERE AddMan = @AddMan AND ExportDate = CONVERT(VARCHAR(10), GETDATE(), 112)
  2284. END
  2285. GO
  2286. /****** Object: StoredProcedure [dbo].[bpbsMobileSpreadByExportSelect] Script Date: 2018/12/13 19:03:33 ******/
  2287. SET ANSI_NULLS ON
  2288. GO
  2289. SET QUOTED_IDENTIFIER ON
  2290. GO
  2291. --bpbsMobileSpreadByExportSelect 1,1,1,'2010-01-01', '2011-01-01',1,'II'
  2292. --创建人 Andy
  2293. --时间 2015-01-23
  2294. --查询短信推广内容列表,用于导出
  2295. CREATE PROCEDURE [dbo].[bpbsMobileSpreadByExportSelect]
  2296. (
  2297. @Cnt INT,
  2298. @AddMan INT,
  2299. @ProvinceID INT,
  2300. @BeginDate VARCHAR(10),
  2301. @EndDate VARCHAR(10),
  2302. @UserType INT,
  2303. @CompanyName NVARCHAR(50)
  2304. )
  2305. AS
  2306. BEGIN
  2307. SET @CompanyName = dbo.SafeSql(@CompanyName)
  2308. SET @EndDate = dbo.SafeSql(@EndDate)
  2309. SET @BeginDate = dbo.SafeSql(@BeginDate)
  2310. DECLARE @SQL VARCHAR(1000)
  2311. SET @SQL = 'SELECT TOP ' + LTRIM(STR(@Cnt)) + ' * FROM bsMobileSpread WITH(NOLOCK) '
  2312. SET @SQL = @SQL + ' WHERE ExportDate IS NULL AND AddMan = ' + LTRIM(STR(@AddMan))
  2313. IF @ProvinceID > 0
  2314. SET @SQL = @SQL + ' AND ProvinceID = ' + LTRIM(STR(@ProvinceID))
  2315. IF LEN(@BeginDate) > 0
  2316. SET @SQL = @SQL + ' AND AddDate >= ' + CONVERT(VARCHAR(10), @BeginDate, 120)
  2317. IF LEN(@EndDate) > 0
  2318. SET @SQL = @SQL + ' AND AddDate <= ' + CONVERT(VARCHAR(10), @EndDate, 120)
  2319. SET @SQL = @SQL + ' AND HasReturn = 0 And AddDate < GETDATE() - 16 '
  2320. IF @UserType >= 0
  2321. SET @SQL = @SQL + ' AND UserType = ' + LTRIM(STR(@UserType))
  2322. IF LEN(@CompanyName) > 0
  2323. SET @SQL = @SQL + ' AND CompanyName LIKE ''%' + LTRIM(@CompanyName) + '%'''
  2324. SET @SQL = @SQL + ' ORDER BY ID DESC'
  2325. --PRINT(@SQL)
  2326. EXEC (@SQL)
  2327. END
  2328. GO
  2329. /****** Object: StoredProcedure [dbo].[bpbsMobileSpreadDelete] Script Date: 2018/12/13 19:03:33 ******/
  2330. SET ANSI_NULLS ON
  2331. GO
  2332. SET QUOTED_IDENTIFIER ON
  2333. GO
  2334. --bpbsMobileSpreadDelete 1
  2335. --创建人 Andy
  2336. --时间 2015-01-23
  2337. --删除短信推广内容
  2338. CREATE PROCEDURE [dbo].[bpbsMobileSpreadDelete]
  2339. (
  2340. @ID INT
  2341. )
  2342. AS
  2343. BEGIN
  2344. Delete FROM bsMobileSpread WHERE Id = @ID
  2345. END
  2346. GO
  2347. /****** Object: StoredProcedure [dbo].[bpbsMobileSpreadSelect] Script Date: 2018/12/13 19:03:34 ******/
  2348. SET ANSI_NULLS ON
  2349. GO
  2350. SET QUOTED_IDENTIFIER ON
  2351. GO
  2352. --bpbsMobileSpreadSelect 1,1,1,'2010-01-01', '2011-01-01',1,1,1, '中国','13889898989','ORDER BY ID DESC'
  2353. --创建人 Andy
  2354. --时间 2015-01-23
  2355. --查询短信推广内容列表
  2356. --修改:2015-01-28,Andy 修改之前用str函数处理@CompanyName参数的bug
  2357. CREATE PROCEDURE [dbo].[bpbsMobileSpreadSelect]
  2358. (
  2359. @AddMan INT,
  2360. @ProvinceID INT,
  2361. @DateType INT,--1:注册时间,2:返回时间,3:审核时间
  2362. @BeginDate DATETIME,
  2363. @EndDate DATETIME,
  2364. @HasReturn INT,
  2365. @HasAccount INT,
  2366. @UserType INT,
  2367. @CompanyName NVARCHAR(50),
  2368. @MobileNo VARCHAR(11),
  2369. @Order VARCHAR(50)
  2370. )
  2371. AS
  2372. SET NOCOUNT ON
  2373. DECLARE @Id INT
  2374. SET @Id = @@IDENTITY
  2375. BEGIN
  2376. SET @CompanyName = dbo.SafeSql(@CompanyName)
  2377. SET @MobileNo = dbo.SafeSql(@MobileNo)
  2378. SET @Order = dbo.SafeSql(@Order)
  2379. DECLARE @SQL VARCHAR(1000)
  2380. SET @SQL = 'SELECT TOP 2000 * FROM bsMobileSpread WITH(NOLOCK) WHERE 1 = 1 '
  2381. IF @AddMan > 0
  2382. SET @SQL = @SQL + ' AND AddMan = ' + LTRIM(STR(@AddMan))
  2383. IF @ProvinceID > 0
  2384. SET @SQL = @SQL + ' AND ProvinceID = ' + LTRIM(STR(@ProvinceID))
  2385. IF @DateType = 1
  2386. BEGIN
  2387. IF @BeginDate > '2010-1-1'
  2388. SET @SQL = @SQL + ' AND AddDate >= ' + CONVERT(VARCHAR(10), @BeginDate, 120)
  2389. IF @EndDate > '2010-1-1'
  2390. SET @SQL = @SQL + ' AND AddDate <= ' + CONVERT(VARCHAR(10), @EndDate, 120)
  2391. END
  2392. ELSE IF @DateType = 2
  2393. BEGIN
  2394. IF @BeginDate > '2010-1-1'
  2395. SET @SQL = @SQL + ' AND ReturnDate >= ' + CONVERT(VARCHAR(10), @BeginDate, 120)
  2396. IF @EndDate > '2010-1-1'
  2397. SET @SQL = @SQL + ' AND ReturnDate <= ' + CONVERT(VARCHAR(10), @EndDate, 120)
  2398. END
  2399. ELSE IF @DateType = 3
  2400. BEGIN
  2401. IF @BeginDate > '2010-1-1'
  2402. SET @SQL = @SQL + ' AND AccountDate >= ' + CONVERT(VARCHAR(10), @BeginDate, 120)
  2403. IF @EndDate > '2010-1-1'
  2404. SET @SQL = @SQL + ' AND AccountDate <= ' + CONVERT(VARCHAR(10), @EndDate, 120)
  2405. END
  2406. IF @HasReturn > 0
  2407. SET @SQL = @SQL + ' AND HasReturn = ' + LTRIM(STR(@HasReturn))
  2408. IF @HasAccount > 0
  2409. SET @SQL = @SQL + ' AND HasAccount = ' + LTRIM(STR(@HasAccount))
  2410. IF @UserType >= 0
  2411. SET @SQL = @SQL + ' AND UserType = ' + LTRIM(STR(@UserType))
  2412. IF LEN(@CompanyName) > 0
  2413. SET @SQL = @SQL + ' AND CompanyName LIKE ''%' + LTRIM(@CompanyName) + '%'''
  2414. IF LEN(@MobileNo) > 0
  2415. SET @SQL = @SQL + ' AND MobileNo = ' + @MobileNo
  2416. IF LEN(@Order) > 0
  2417. SET @SQL = @SQL + ' ' + @Order
  2418. --PRINT(@SQL)
  2419. EXEC (@SQL)
  2420. END
  2421. GO
  2422. /****** Object: StoredProcedure [dbo].[bpBsPaBackLoginInsert] Script Date: 2018/12/13 19:03:34 ******/
  2423. SET ANSI_NULLS ON
  2424. GO
  2425. SET QUOTED_IDENTIFIER ON
  2426. GO
  2427. --创建人 Lambo
  2428. --20101111
  2429. --个人后台登陆
  2430. CREATE PROCEDURE [dbo].[bpBsPaBackLoginInsert]
  2431. (
  2432. @paMainID INT,
  2433. @ManagerUserID INT,
  2434. @UID VARCHAR(20) OUTPUT
  2435. )
  2436. AS
  2437. BEGIN
  2438. DECLARE @T AS VARCHAR(20)
  2439. SET @T = CONVERT(VARCHAR(20), CONVERT(DECIMAL(18,12),GETDATE()))
  2440. SET @T = RTRIM(CONVERT(VARCHAR(12), @paMainID)) + '_' + RIGHT(@T,8)
  2441. INSERT INTO BsPaBackLogin (UnqueID,paMainID,ManagerUserID)
  2442. VALUES(@T,@paMainID,@ManagerUserID)
  2443. SET @UID = @T
  2444. END
  2445. GO
  2446. /****** Object: StoredProcedure [dbo].[bpBsPaStatusSelect] Script Date: 2018/12/13 19:03:34 ******/
  2447. SET ANSI_NULLS ON
  2448. GO
  2449. SET QUOTED_IDENTIFIER ON
  2450. GO
  2451. CREATE PROCEDURE [dbo].[bpBsPaStatusSelect]
  2452. (
  2453. @paMainID INT,
  2454. @cvMainID INT,
  2455. @StatusID INT
  2456. )
  2457. AS
  2458. BEGIN
  2459. DECLARE @SQL AS VARCHAR(1000)
  2460. SET @SQL = 'SELECT * FROM BsPaStatus WITH(NOLOCK) WHERE paMainID = ' + RTRIM(CONVERT(CHAR(10), @paMainID))
  2461. IF @cvMainID > 0
  2462. SET @SQL = @SQL + ' AND cvMainID = ' + RTRIM(CONVERT(CHAR(10), @cvMainID))
  2463. IF @StatusID > 0
  2464. SET @SQL = @SQL + ' AND StatusID = ' + RTRIM(CONVERT(CHAR(10), @StatusID))
  2465. SET @SQL = @SQL + ' ORDER BY cvMainID,StatusID'
  2466. EXEC(@SQL)
  2467. END
  2468. GO
  2469. /****** Object: StoredProcedure [dbo].[bpcaCvViewLogByCpMainIDCountNoOpenSelect] Script Date: 2018/12/13 19:03:34 ******/
  2470. SET ANSI_NULLS ON
  2471. GO
  2472. SET QUOTED_IDENTIFIER ON
  2473. GO
  2474. -----------------
  2475. --创建日期:20110421
  2476. --创建人:lambo
  2477. --功能说明:查询某单位一周内浏览的非开放简历数
  2478. --用于后台客户界面
  2479. -----------------
  2480. CREATE PROCEDURE [dbo].[bpcaCvViewLogByCpMainIDCountNoOpenSelect]
  2481. (
  2482. @cpMainID INT
  2483. )
  2484. AS
  2485. BEGIN
  2486. DECLARE @ViewCount INT
  2487. SELECT @ViewCount=COUNT(1) FROM caCvViewLog a WITH(index(IX_CaCvViewLog_caMainId) NOLOCK),caMain b WITH(NOLOCK),cvMain c WITH(NOLOCK)
  2488. WHERE a.caMainID = b.ID
  2489. AND a.CvMainID = c.ID
  2490. AND a.AddDate>GETDATE()-7
  2491. AND b.cpMainID=@cpMainID
  2492. AND c.IsOpen = 0
  2493. RETURN @ViewCount
  2494. END
  2495. GO
  2496. /****** Object: StoredProcedure [dbo].[bpcaCvViewLogByCpMainIDCountSelect] Script Date: 2018/12/13 19:03:35 ******/
  2497. SET ANSI_NULLS ON
  2498. GO
  2499. SET QUOTED_IDENTIFIER ON
  2500. GO
  2501. -----------------
  2502. --创建日期:2010-9-14
  2503. --创建人:lambo
  2504. --功能说明:查询某单位一周内浏览的简历数
  2505. --用于后台企业内容显示页面
  2506. -----------------
  2507. CREATE PROCEDURE [dbo].[bpcaCvViewLogByCpMainIDCountSelect]
  2508. (
  2509. @cpMainID INT
  2510. )
  2511. AS
  2512. BEGIN
  2513. DECLARE @ViewCount INT
  2514. SELECT @ViewCount=COUNT(1) FROM caCvViewLog a WITH(index(IX_CaCvViewLog_caMainId) NOLOCK),caMain b WITH(NOLOCK)
  2515. WHERE a.caMainID = b.ID
  2516. AND a.AddDate>GETDATE()-7
  2517. AND b.cpMainID=@cpMainID
  2518. RETURN @ViewCount
  2519. END
  2520. GO
  2521. /****** Object: StoredProcedure [dbo].[bpcaCvViewLogDelete] Script Date: 2018/12/13 19:03:35 ******/
  2522. SET ANSI_NULLS ON
  2523. GO
  2524. SET QUOTED_IDENTIFIER ON
  2525. GO
  2526. -----------------
  2527. --创建日期:2010-9-14
  2528. --创建人:lambo
  2529. --功能说明:删除一条简历浏览记录记录
  2530. --用于后台企业浏览简历记录页面
  2531. -----------------
  2532. CREATE PROCEDURE [dbo].[bpcaCvViewLogDelete]
  2533. (
  2534. @cvMainID INT,
  2535. @caMainID INT
  2536. )
  2537. AS
  2538. BEGIN
  2539. DELETE FROM caCvViewLog WHERE cvMainID=@cvMainID AND caMainID=@caMainID
  2540. END
  2541. GO
  2542. /****** Object: StoredProcedure [dbo].[bpCaCvViewLogSelect] Script Date: 2018/12/13 19:03:35 ******/
  2543. SET ANSI_NULLS ON
  2544. GO
  2545. SET QUOTED_IDENTIFIER ON
  2546. GO
  2547. -----------------
  2548. --创建日期:2010-9-14
  2549. --创建人:lambo
  2550. --功能说明:根据条件查询企业浏览简历记录
  2551. --用于企业浏览简历记录页面
  2552. --sean update 2013-1-18
  2553. --harry 2018-8-14 增加一天内查看简历数量
  2554. -----------------
  2555. CREATE PROCEDURE [dbo].[bpCaCvViewLogSelect]
  2556. (
  2557. @WHERE VARCHAR(1000)
  2558. )
  2559. AS
  2560. BEGIN
  2561. DECLARE @SQL VARCHAR(2000)
  2562. SET @Where = dbo.SafeSql(@Where)
  2563. SET @SQL =
  2564. 'SELECT TOP 500 b.ID, COUNT(1) cnt, max(b.Refreshdate) r, SPACE(16) Logincookies
  2565. FROM CaCvViewLog a WITH(NOLOCK INDEX(IX_caCvViewLog_AddDate)),
  2566. cpMain b WITH(NOLOCK),
  2567. caMain c WITH(NOLOCK)
  2568. WHERE a.caMainid = c.ID
  2569. AND c.cpMainid = b.ID
  2570. @where
  2571. GROUP BY b.ID
  2572. HAVING Count(1) > 20
  2573. ORDER BY cnt DESC, b.ID'
  2574. SET @Sql = REPLACE(@Sql, '@where', ISNULL(@Where, ''))
  2575. DECLARE @t AS TABLE(
  2576. ID int,
  2577. Cnt int,
  2578. R DATETIME,
  2579. LoginCookie Varchar(16)
  2580. )
  2581. INSERT @t
  2582. EXEC(@SQL)
  2583. UPDATE a
  2584. SET a.Logincookie = b.Logincookies
  2585. FROM @t a, (
  2586. SELECT f.cpMainId, MAX(e.Logincookies) Logincookies
  2587. FROM caLoginlog e with(nolock),
  2588. caMain f with(nolock)
  2589. WHERE e.caMainID = f.ID
  2590. AND f.cpMainId IN(SELECT id FROM @t)
  2591. AND e.LoginCookies <> '注册登录'
  2592. GROUP BY f.cpMainID) b
  2593. WHERE a.ID = b.cpMainId
  2594. SELECT * FROM @t
  2595. END
  2596. GO
  2597. /****** Object: StoredProcedure [dbo].[bpCaFeePageViewLogSelect] Script Date: 2018/12/13 19:03:35 ******/
  2598. SET ANSI_NULLS ON
  2599. GO
  2600. SET QUOTED_IDENTIFIER ON
  2601. GO
  2602. --获取单位点击收费页面记录-----------
  2603. --添加人Harry -----------------------
  2604. --添加时间:2014-12-15---------------
  2605. CREATE PROCEDURE [dbo].[bpCaFeePageViewLogSelect]
  2606. (
  2607. @WHERE VARCHAR(2000)
  2608. )
  2609. AS
  2610. BEGIN
  2611. DECLARE @SQL AS VARCHAR(2000)
  2612. SET @WHERE=dbo.SafeSql(@WHERE)
  2613. SET @SQL='
  2614. SELECT TOP 2000 a.*,b.Name caName,c.MemberType,c.Balance, c.Name cpName,c.ID cpMainID,c.ConsultantID ,c.RegDate,c.LastLoginDate
  2615. FROM caFeePageViewLog a WITH(NOLOCK)
  2616. INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  2617. INNER JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID
  2618. WHERE 1 = 1 ' + @WHERE
  2619. --print @sql
  2620. EXEC(@SQL)
  2621. END
  2622. GO
  2623. /****** Object: StoredProcedure [dbo].[bpCaGetPasswordLogBycpMainIDSelect] Script Date: 2018/12/13 19:03:35 ******/
  2624. SET ANSI_NULLS ON
  2625. GO
  2626. SET QUOTED_IDENTIFIER ON
  2627. GO
  2628. --lambo 20110218
  2629. --后台,查询企业取回密码日志
  2630. CREATE PROCEDURE [dbo].[bpCaGetPasswordLogBycpMainIDSelect]
  2631. (
  2632. @cpMainID INT
  2633. )
  2634. AS
  2635. BEGIN
  2636. SELECT a.* ,b.Name caName, c.Name cpName FROM caGetPasswordLog a WITH (NOLOCK)
  2637. INNER JOIN caMain b WITH (NOLOCK)
  2638. ON a.caMainID = b.ID
  2639. INNER JOIN cpMain c WITH (NOLOCK)
  2640. ON b.cpMainID = c.ID
  2641. WHERE c.ID = @cpMainID
  2642. END
  2643. GO
  2644. /****** Object: StoredProcedure [dbo].[bpCaLoginLogByAddDateCpMainIDSelect] Script Date: 2018/12/13 19:03:35 ******/
  2645. SET ANSI_NULLS ON
  2646. GO
  2647. SET QUOTED_IDENTIFIER ON
  2648. GO
  2649. -----------------
  2650. --创建日期:2010-9-14
  2651. --创建人:lambo
  2652. --功能说明:根据登陆时间和企业编号企业登陆记录
  2653. --用于后台企业登陆明显页面
  2654. -----------------
  2655. CREATE PROCEDURE [dbo].[bpCaLoginLogByAddDateCpMainIDSelect]
  2656. (
  2657. @AddDate VARCHAR(20),
  2658. @cpMainID INT
  2659. )
  2660. AS
  2661. BEGIN
  2662. SELECT b.cpMainID,a.cpMainName,a.AddDate,a.LoginIp,a.LoginCookies
  2663. FROM caloginlog a WITH(NOLOCK),caMain b WITH(NOLOCK)
  2664. WHERE a.caMainID = b.ID
  2665. AND CONVERT(VARCHAR(200),a.AddDate,112)<=@AddDate
  2666. AND b.cpMainID = @cpMainID
  2667. ORDER BY a.AddDate
  2668. END
  2669. GO
  2670. /****** Object: StoredProcedure [dbo].[bpCaLoginLogByAddDateLoginCookiesSelect] Script Date: 2018/12/13 19:03:35 ******/
  2671. SET ANSI_NULLS ON
  2672. GO
  2673. SET QUOTED_IDENTIFIER ON
  2674. GO
  2675. -----------------
  2676. --创建日期:2010-9-14
  2677. --创建人:lambo
  2678. --功能说明:根据登陆时间和机器码查询企业登陆记录
  2679. --用于后台非法机器码嫌疑页面
  2680. -----------------
  2681. CREATE PROCEDURE [dbo].[bpCaLoginLogByAddDateLoginCookiesSelect]
  2682. (
  2683. @AddDate VARCHAR(30),
  2684. @LoginCookies VARCHAR(30)
  2685. )
  2686. AS
  2687. BEGIN
  2688. SELECT c.ID,a.cpMainName Name,a.AddDate,a.LoginCookies,a.LoginIP,c.HasLicence,c.dcProvinceID,c.consultantID,c.RegDate,d.HasPassed,d.IP,d.CheckDate,d.ID LicenceID
  2689. FROM caLoginLog a WITH(NOLOCK)
  2690. INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  2691. INNER JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID
  2692. LEFT JOIN cpLicence d WITH(NOLOCK) ON d.cpMainID = c.ID
  2693. WHERE a.LoginCookies = @LoginCookies
  2694. AND CONVERT(VARCHAR(20),a.AddDate,112)=CONVERT(VARCHAR(20),@AddDate)
  2695. END
  2696. GO
  2697. /****** Object: StoredProcedure [dbo].[bpCaLoginLogByAddDateLoginIPSelect] Script Date: 2018/12/13 19:03:36 ******/
  2698. SET ANSI_NULLS ON
  2699. GO
  2700. SET QUOTED_IDENTIFIER ON
  2701. GO
  2702. CREATE PROCEDURE [dbo].[bpCaLoginLogByAddDateLoginIPSelect]
  2703. (
  2704. @AddDate VARCHAR(8),
  2705. @IP VARCHAR(31),
  2706. @OrderBy VARCHAR(50)
  2707. )
  2708. AS
  2709. BEGIN
  2710. DECLARE @SQL VARCHAR(2000)
  2711. SET @SQL = 'SELECT c.ID,a.cpMainName Name,a.AddDate,a.LoginCookies,a.LoginIP,c.HasLicence,c.dcProvinceID,c.RegDate,c.consultantID,d.HasPassed,d.IP,d.CheckDate,d.ID LicenceID '
  2712. SET @SQL = @SQL + 'FROM caLoginLog a WITH(NOLOCK) '
  2713. SET @SQL = @SQL + 'INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID '
  2714. SET @SQL = @SQL + 'INNER JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID '
  2715. SET @SQL = @SQL + 'LEFT JOIN cpLicence d WITH(NOLOCK) ON d.cpMainID = c.ID '
  2716. SET @SQL = @SQL + 'WHERE a.LoginIP = ''' + @IP + ''''
  2717. SET @SQL = @SQL + ' AND CONVERT(VARCHAR(8),a.AddDate,112)=''' + @AddDate + ''''
  2718. IF LEN(@OrderBy) > 0
  2719. BEGIN
  2720. SET @OrderBy = dbo.SafeSql(@OrderBy)
  2721. SET @SQL = @SQL + 'ORDER BY ' + @OrderBy
  2722. END
  2723. EXEC(@SQL)
  2724. END
  2725. GO
  2726. /****** Object: StoredProcedure [dbo].[bpCaLoginLogBycpMainIDOneSelect] Script Date: 2018/12/13 19:03:36 ******/
  2727. SET ANSI_NULLS ON
  2728. GO
  2729. SET QUOTED_IDENTIFIER ON
  2730. GO
  2731. --#####################################################
  2732. --创建时间:2014.12.9
  2733. --创建人:John
  2734. --说明:获取企业用户最新的登录机器码
  2735. --#####################################################
  2736. CREATE PROCEDURE [dbo].[bpCaLoginLogBycpMainIDOneSelect]
  2737. (
  2738. @cpMainID INT
  2739. )
  2740. AS
  2741. BEGIN
  2742. SELECT TOP 1 LoginIp, LoginCookies
  2743. FROM caLoginLog a, caMain b
  2744. WHERE a.caMainid = b.id
  2745. AND cpMainid = @cpMainID
  2746. ORDER BY a.AddDate DESC
  2747. END
  2748. GO
  2749. /****** Object: StoredProcedure [dbo].[bpCaLoginLogBycpMainIDSelect] Script Date: 2018/12/13 19:03:36 ******/
  2750. SET ANSI_NULLS ON
  2751. GO
  2752. SET QUOTED_IDENTIFIER ON
  2753. GO
  2754. --###########################
  2755. --创建时间:2014.12.10
  2756. --创建人:Nick
  2757. --说明:根据cpMainID获取caloginlog
  2758. --###########################
  2759. CREATE PROCEDURE [dbo].[bpCaLoginLogBycpMainIDSelect]
  2760. (
  2761. @cpMainID INT
  2762. )
  2763. AS
  2764. BEGIN
  2765. SELECT TOP 1 LoginIp, LoginCookies
  2766. FROM caLoginLog a, caMain b
  2767. WHERE a.caMainid = b.id
  2768. AND b.AccountType = 1
  2769. AND cpMainid = @cpMainID
  2770. ORDER BY a.AddDate DESC
  2771. END
  2772. GO
  2773. /****** Object: StoredProcedure [dbo].[bpCaLoginLogByLastLoginIPSelect] Script Date: 2018/12/13 19:03:36 ******/
  2774. SET ANSI_NULLS ON
  2775. GO
  2776. SET QUOTED_IDENTIFIER ON
  2777. GO
  2778. --Lambo 20101113
  2779. --查询单位的上次登陆IP
  2780. CREATE PROCEDURE [dbo].[bpCaLoginLogByLastLoginIPSelect]
  2781. (
  2782. @cpMainID INT
  2783. )
  2784. AS
  2785. BEGIN
  2786. SELECT TOP 2 a.LoginIP
  2787. FROM caLoginLog a WITH(NOLOCK) ,caMain b WITH(NOLOCK)
  2788. WHERE a.caMainID = b.ID
  2789. AND b.cpMainID = @cpMainID
  2790. ORDER BY a.ID DESC
  2791. END
  2792. GO
  2793. /****** Object: StoredProcedure [dbo].[bpCaLoginLogGroupByCookiesSelect] Script Date: 2018/12/13 19:03:36 ******/
  2794. SET ANSI_NULLS ON
  2795. GO
  2796. SET QUOTED_IDENTIFIER ON
  2797. GO
  2798. -----------------
  2799. --创建日期:2010-9-14
  2800. --创建人:lambo
  2801. --功能说明:倒序排列某天同一个机器码登录的企业数
  2802. --用于后台非法机器码登录嫌疑页面
  2803. -----------------
  2804. CREATE PROCEDURE [dbo].[bpCaLoginLogGroupByCookiesSelect]
  2805. (
  2806. @AddDate VARCHAR(20)
  2807. )
  2808. AS
  2809. BEGIN
  2810. SELECT COUNT(DISTINCT b.cpMainID) cnt,a.loginCookies
  2811. FROM caloginlog a WITH(NOLOCK),caMain b WITH(NOLOCK)
  2812. WHERE a.caMainID = b.ID
  2813. AND CONVERT(VARCHAR(20),a.AddDate,112)=@AddDate
  2814. GROUP BY a.loginCookies HAVING COUNT(DISTINCT b.cpMainID)>1
  2815. ORDER BY cnt DESC
  2816. END
  2817. GO
  2818. /****** Object: StoredProcedure [dbo].[bpCaLoginLogGroupByIPAddDateSelect] Script Date: 2018/12/13 19:03:36 ******/
  2819. SET ANSI_NULLS ON
  2820. GO
  2821. SET QUOTED_IDENTIFIER ON
  2822. GO
  2823. CREATE PROCEDURE [dbo].[bpCaLoginLogGroupByIPAddDateSelect]
  2824. (
  2825. @Day INT
  2826. )
  2827. AS
  2828. BEGIN
  2829. SELECT TOP 500 COUNT(DISTINCT b.cpMainID) cnt,a.loginIP
  2830. FROM caloginlog a WITH(NOLOCK),caMain b WITH(NOLOCK)
  2831. WHERE a.caMainID = b.ID
  2832. AND a.AddDate > = GETDATE() - @Day
  2833. GROUP BY a.loginIP HAVING COUNT(DISTINCT b.cpMainID)>1
  2834. ORDER BY cnt DESC
  2835. END
  2836. GO
  2837. /****** Object: StoredProcedure [dbo].[bpCaLoginLogGroupByIPSelect] Script Date: 2018/12/13 19:03:37 ******/
  2838. SET ANSI_NULLS ON
  2839. GO
  2840. SET QUOTED_IDENTIFIER ON
  2841. GO
  2842. -----------------
  2843. --创建日期:2010-9-14
  2844. --创建人:lambo
  2845. --功能说明:倒序排列某天同一个IP登录的企业数
  2846. --用于后台非法IP登录嫌疑页面
  2847. -----------------
  2848. CREATE PROCEDURE [dbo].[bpCaLoginLogGroupByIPSelect]
  2849. (
  2850. @AddDate VARCHAR(20)
  2851. )
  2852. AS
  2853. BEGIN
  2854. SELECT COUNT(DISTINCT b.cpMainID) cnt,a.loginIP
  2855. FROM caloginlog a WITH(NOLOCK),caMain b WITH(NOLOCK)
  2856. WHERE a.caMainID = b.ID
  2857. AND CONVERT(VARCHAR(20),a.AddDate,112)=@AddDate
  2858. GROUP BY a.loginIP HAVING COUNT(DISTINCT b.cpMainID)>1
  2859. ORDER BY cnt DESC
  2860. END
  2861. GO
  2862. /****** Object: StoredProcedure [dbo].[bpCaMainByBeVerifingSelect] Script Date: 2018/12/13 19:03:37 ******/
  2863. SET ANSI_NULLS ON
  2864. GO
  2865. SET QUOTED_IDENTIFIER ON
  2866. GO
  2867. CREATE PROCEDURE [dbo].[bpCaMainByBeVerifingSelect]
  2868. @IDS VARCHAR(1000)
  2869. AS
  2870. BEGIN TRY
  2871. DECLARE @caID Table(ID INT NULL)
  2872. DECLARE @I AS INT
  2873. SET @I= CHARINDEX(',',@IDS)
  2874. WHILE @I >= 1
  2875. BEGIN
  2876. IF LEFT(@IDS, @I - 1) > ''
  2877. INSERT @caID VALUES(LEFT(@IDS, @I - 1))
  2878. SET @IDS = SUBSTRING(@IDS, @I + 1, LEN(@IDS) - @I)
  2879. SET @I = CHARINDEX(',', @IDS)
  2880. END
  2881. IF @I < 1
  2882. INSERT @caID VALUES(@IDS)
  2883. SELECT
  2884. a.ID,
  2885. RegDate,
  2886. AccountType,
  2887. UserName,
  2888. Name,
  2889. Gender,
  2890. Title,
  2891. Dept,
  2892. TelePhone,
  2893. Mobile,
  2894. Fax,
  2895. EMail,
  2896. IsPause,
  2897. IsDelete,
  2898. LastModifyDate
  2899. FROM caMain a WITH(NOLOCK), @caID b
  2900. WHERE a.ID = b.ID
  2901. AND a.IsDelete = 0
  2902. END TRY
  2903. BEGIN CATCH
  2904. END CATCH
  2905. GO
  2906. /****** Object: StoredProcedure [dbo].[bpCaMainByIsPauseUpdate] Script Date: 2018/12/13 19:03:37 ******/
  2907. SET ANSI_NULLS ON
  2908. GO
  2909. SET QUOTED_IDENTIFIER ON
  2910. GO
  2911. --Lambo 20101114
  2912. --修改个单位非管理员用户的状态
  2913. --用于后台单位显示页面
  2914. CREATE PROCEDURE [dbo].[bpCaMainByIsPauseUpdate]
  2915. (
  2916. @ID INT,
  2917. @maxUserNumber INT,
  2918. @cpMainId INT
  2919. )
  2920. AS
  2921. BEGIN
  2922. BEGIN TRY
  2923. DECLARE @IsPause BIT
  2924. SELECT @IsPause = IsPause FROM caMain WHERE ID = @ID
  2925. IF @IsPause=1
  2926. BEGIN
  2927. DECLARE @UserNum AS INT
  2928. SELECT @UserNum=COUNT(*) FROM caMain
  2929. WHERE IsDelete=0 AND IsPause=0 AND AccountType<>1 AND cpMainID=@cpMainID
  2930. IF @maxUserNumber<=@UserNum
  2931. GOTO err
  2932. END
  2933. ELSE
  2934. BEGIN
  2935. UPDATE Job Set IssueEnd = GETDATE()-1 WHERE caMainID = @ID AND cpMainID=@cpMainID
  2936. END
  2937. UPDATE caMain SET IsPause = IsPause-1 WHERE ID=@ID
  2938. RETURN 1
  2939. END TRY
  2940. BEGIN CATCH
  2941. RETURN 0
  2942. END CATCH
  2943. END
  2944. err:
  2945. RETURN -1
  2946. GO
  2947. /****** Object: StoredProcedure [dbo].[bpCaMainByIsShowEmailContactUpdate] Script Date: 2018/12/13 19:03:37 ******/
  2948. SET ANSI_NULLS ON
  2949. GO
  2950. SET QUOTED_IDENTIFIER ON
  2951. GO
  2952. CREATE PROCEDURE [dbo].[bpCaMainByIsShowEmailContactUpdate]
  2953. (
  2954. @caMainId INT
  2955. )
  2956. AS
  2957. SET NOCOUNT ON
  2958. BEGIN
  2959. UPDATE caMain SET IsShowEmailContact = ISNULL(IsShowEmailContact, 0) - 1 WHERE Id = @caMainId
  2960. DECLARE @Show INT
  2961. SELECT @Show = IsShowEmailContact FROM caMain WITH(NOLOCK) WHERE Id = @caMainId
  2962. SELECT @caMainId caMainId, @Show ShowContact
  2963. END
  2964. GO
  2965. /****** Object: StoredProcedure [dbo].[bpCaMainByJobIDSelect] Script Date: 2018/12/13 19:03:37 ******/
  2966. SET ANSI_NULLS ON
  2967. GO
  2968. SET QUOTED_IDENTIFIER ON
  2969. GO
  2970. --#####################################################
  2971. --创建时间:2015.1.12
  2972. --创建人:Nick
  2973. --说明:删除职位获取相关信息
  2974. --#####################################################
  2975. CREATE PROCEDURE [dbo].[bpCaMainByJobIDSelect]
  2976. (
  2977. @JobID VARCHAR(100)
  2978. )
  2979. AS
  2980. BEGIN
  2981. SELECT a.ID cpmainID,a.Name,b.Email,a.dcSubSiteID,c.Name JobName
  2982. FROM cpMain a With(Nolock),caMain b With(Nolock),Job c With(Nolock)
  2983. WHERE c.cpMainID=a.ID
  2984. AND a.ID=b.cpMainID
  2985. AND b.AccountType=1
  2986. AND c.ID IN(SELECT * FROM dbo.fnSplit(@JobID,','))
  2987. End
  2988. GO
  2989. /****** Object: StoredProcedure [dbo].[bpCaMainDelete] Script Date: 2018/12/13 19:03:38 ******/
  2990. SET ANSI_NULLS ON
  2991. GO
  2992. SET QUOTED_IDENTIFIER ON
  2993. GO
  2994. --lambo 20101115
  2995. --后台删除单位非管理员用户
  2996. --用于后台单位显示页面
  2997. CREATE PROCEDURE [dbo].[bpCaMainDelete]
  2998. @ID INT
  2999. AS
  3000. BEGIN TRAN
  3001. BEGIN TRY
  3002. UPDATE Job SET IsDelete=1,valid=0 WHERE caMainID = @ID
  3003. DELETE FROM bsCpModify WHERE caMainID = @ID
  3004. UPDATE caMain SET IsDelete=1 WHERE ID=@ID
  3005. END TRY
  3006. BEGIN CATCH
  3007. GOTO ERR
  3008. END CATCH
  3009. COMMIT TRAN
  3010. RETURN 1
  3011. ERR:
  3012. BEGIN
  3013. ROLLBACK TRAN
  3014. RETURN 0
  3015. END
  3016. GO
  3017. /****** Object: StoredProcedure [dbo].[bpCampusBrochureSelect] Script Date: 2018/12/13 19:03:38 ******/
  3018. SET ANSI_NULLS ON
  3019. GO
  3020. SET QUOTED_IDENTIFIER ON
  3021. GO
  3022. -- =============================================
  3023. -- Author: <Mice 123>
  3024. -- Create date: <2014-12-22>
  3025. -- Description: <获取招聘简章列表>
  3026. -- 修改: AttachmentName参数的类型为NVARCHAR
  3027. -- =============================================
  3028. CREATE PROCEDURE [dbo].[bpCampusBrochureSelect]
  3029. (
  3030. @Where VARCHAR(500) = '',
  3031. @Page INT = 1
  3032. )
  3033. AS
  3034. BEGIN
  3035. CREATE TABLE #T(
  3036. TitleID BIGINT,
  3037. ID INT ,
  3038. CompanyID INT,
  3039. Title NVARCHAR(100),
  3040. Description NVARCHAR(MAX),
  3041. EndDate SMALLDATETIME,
  3042. [FileName] VARCHAR(100),
  3043. AttachmentName NVARCHAR(100),
  3044. ClickNumber INT,
  3045. AddMan SMALLINT,
  3046. AddDate SMALLDATETIME,
  3047. Source VARCHAR(500),
  3048. SourceName VARCHAR(100),
  3049. OrderBy INT,
  3050. addManName NVARCHAR(50),
  3051. SubSiteUrl VARCHAR(100),
  3052. SubSiteNames NVARCHAR(300),
  3053. TotalNum INT
  3054. )
  3055. DECLARE @SQL AS VARCHAR(5000)
  3056. SET @SQL = 'INSERT INTO #T
  3057. ( TitleID, ID,CompanyID,Title,Description,EndDate,[FileName],AttachmentName,ClickNumber,AddMan,AddDate,Source,SourceName,OrderBy )
  3058. SELECT ROW_NUMBER() OVER ( ORDER BY a.ID DESC ) AS TitleID , a.ID, a.CompanyID,a.Title,a.Description,a.EndDate,a.FileName,a.AttachmentName,
  3059. a.ClickNumber,a.AddMan, a.AddDate, a.Source, a.SourceName, a.OrderBy
  3060. FROM marketdb..CampusBrochure a WITH(NOLOCK)
  3061. WHERE 1 = 1 '
  3062. IF @Where <> ''
  3063. BEGIN
  3064. SET @Where = dbo.SafeSql(@Where)
  3065. SET @SQL = @SQL + @Where
  3066. END
  3067. SET @SQL = @SQL + ' ORDER BY a.ID DESC '
  3068. EXEC(@SQL)
  3069. UPDATE #T
  3070. SET addManName = (SELECT TOP 1 [Name] FROM maindb..manageruser y WITH(NOLOCK)
  3071. WHERE y.id = #T.AddMan), SubSiteUrl = (SELECT TOP 1 y.SubSiteUrl FROM marketdb..CampusBrochureSite x WITH(NOLOCK),maindb..dcSubSite y WITH(NOLOCK) WHERE x.dcSubsiteid = y.id AND CampusBrochure=#T.id),
  3072. SubSiteNames = STUFF((SELECT ','+CONVERT(VARCHAR,y.SubSIteCity) FROM marketdb..CampusBrochureSite x WITH(NOLOCK), maindb..dcSubSite y WITH(NOLOCK) WHERE x.dcSubsiteid = y.id AND CampusBrochure=#T.ID FOR XML PATH ('')),1,1,'')
  3073. WHERE TitleID > (@Page - 1) * 20
  3074. AND TitleID <= @Page*20
  3075. UPDATE #T
  3076. SET TotalNum = (SELECT COUNT(ID) FROM #T)
  3077. WHERE TitleID > (@Page-1)*20
  3078. AND TitleID <= @Page*20
  3079. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  3080. DROP TABLE #T
  3081. END
  3082. GO
  3083. /****** Object: StoredProcedure [dbo].[bpCaOperationLogSelect] Script Date: 2018/12/13 19:03:38 ******/
  3084. SET ANSI_NULLS ON
  3085. GO
  3086. SET QUOTED_IDENTIFIER ON
  3087. GO
  3088. CREATE PROCEDURE [dbo].[bpCaOperationLogSelect]
  3089. (
  3090. @cpMainID INT,
  3091. @Operation INT
  3092. )
  3093. AS
  3094. BEGIN
  3095. SELECT a.* FROM caOperationLog a WITH(NOLOCK),caMain b WITH(NOLOCK)
  3096. WHERE a.caMainID = b.ID
  3097. AND b.cpMainID=@cpMainID
  3098. AND a.Operation =@Operation
  3099. ORDER BY a.ID DESC
  3100. END
  3101. GO
  3102. /****** Object: StoredProcedure [dbo].[bpcaOrderBy7DayValidSelect] Script Date: 2018/12/13 19:03:39 ******/
  3103. SET ANSI_NULLS ON
  3104. GO
  3105. SET QUOTED_IDENTIFIER ON
  3106. GO
  3107. --根据cpmainid获取有效期>7天的订单
  3108. --Lucifer 2014-12-19
  3109. CREATE PROCEDURE [dbo].[bpcaOrderBy7DayValidSelect]
  3110. (
  3111. @cpMainID INT
  3112. )
  3113. AS
  3114. BEGIN
  3115. SELECT * FROM maindb..caOrder WITH(NOLOCK)
  3116. WHERE IsDeleted = 0 AND BeginDate<GETDATE() AND EndDate>GETDATE()+7 AND cpMainID=@cpMainID
  3117. AND OrderType = 8
  3118. END
  3119. GO
  3120. /****** Object: StoredProcedure [dbo].[bpcaOrderByActiveQuotaOpenDateUpdate] Script Date: 2018/12/13 19:03:39 ******/
  3121. SET ANSI_NULLS ON
  3122. GO
  3123. SET QUOTED_IDENTIFIER ON
  3124. GO
  3125. --开通简历下载数订单 Lucifer 2014-12-24
  3126. CREATE PROCEDURE [dbo].[bpcaOrderByActiveQuotaOpenDateUpdate]
  3127. (
  3128. @BeginDate SMALLDATETIME,
  3129. @EndDate SMALLDATETIME,
  3130. @OpenMan SMALLINT,
  3131. @OrderID INT,
  3132. @ActiveQuota INT
  3133. )
  3134. AS
  3135. BEGIN
  3136. UPDATE MainDB..caOrder SET
  3137. BeginDate=@BeginDate,
  3138. EndDate=@EndDate,
  3139. OpenDate=GetDate(),
  3140. OpenMan=@OpenMan,
  3141. ActiveQuota=@ActiveQuota,
  3142. RemainQuota=@ActiveQuota
  3143. WHERE ID=@OrderID
  3144. END
  3145. GO
  3146. /****** Object: StoredProcedure [dbo].[bpcaOrderByContractUpdate] Script Date: 2018/12/13 19:03:39 ******/
  3147. SET ANSI_NULLS ON
  3148. GO
  3149. SET QUOTED_IDENTIFIER ON
  3150. GO
  3151. --更新合同影像 Lucifer 2014-12-9
  3152. CREATE PROCEDURE [dbo].[bpcaOrderByContractUpdate]
  3153. (
  3154. @ContractFile VARCHAR(50),
  3155. @OrderID INT
  3156. )
  3157. AS
  3158. BEGIN
  3159. UPDATE MainDB..caOrder SET ContractFile=@ContractFile WHERE ID=@OrderID
  3160. END
  3161. GO
  3162. /****** Object: StoredProcedure [dbo].[bpCaorderByCpMainIDSelect] Script Date: 2018/12/13 19:03:39 ******/
  3163. SET ANSI_NULLS ON
  3164. GO
  3165. SET QUOTED_IDENTIFIER ON
  3166. GO
  3167. --创建人 Andy
  3168. --时间 2014-12-31
  3169. --按照条件查询一个企业的订单
  3170. CREATE PROCEDURE [dbo].[bpCaorderByCpMainIDSelect]
  3171. (
  3172. @CpMainID INT,
  3173. @OpenDate VARCHAR(20)
  3174. )
  3175. AS
  3176. BEGIN
  3177. SELECT ID,OpenDate,Paid,OrderType,EndDate
  3178. FROM CaOrder WITH(NOLOCK)
  3179. WHERE cpMainID=@CpMainID AND Paid>0 AND MainOrderID IS NULL AND OpenDate<@OpenDate
  3180. ORDER BY OpenDate DESC
  3181. END
  3182. GO
  3183. /****** Object: StoredProcedure [dbo].[bpCaOrderByCpMainIDValidVipSelect] Script Date: 2018/12/13 19:03:39 ******/
  3184. SET ANSI_NULLS ON
  3185. GO
  3186. SET QUOTED_IDENTIFIER ON
  3187. GO
  3188. --#####################################################
  3189. --创建时间:2014.12.9
  3190. --创建人:John
  3191. --说明:根据公司编号获取会员订单资费明细编号
  3192. --修改harry2016-12-21显示续费订单
  3193. --#####################################################
  3194. CREATE PROCEDURE [dbo].[bpCaOrderByCpMainIDValidVipSelect]
  3195. (
  3196. @cpMainID INT
  3197. )
  3198. AS
  3199. BEGIN
  3200. SELECT dcFeeDetailID
  3201. FROM caOrder WITH(NOLOCK)
  3202. WHERE cpMainid = @cpMainID
  3203. AND EndDate > GETDATE() - 1
  3204. AND OrderType = 8
  3205. AND OpenDate IS NOT NULL
  3206. AND IsDeleted = 0
  3207. END
  3208. GO
  3209. /****** Object: StoredProcedure [dbo].[bpCaOrderByDeletedSelect] Script Date: 2018/12/13 19:03:39 ******/
  3210. SET ANSI_NULLS ON
  3211. GO
  3212. SET QUOTED_IDENTIFIER ON
  3213. GO
  3214. --###############################
  3215. --Andy.Yin 2014-12-2
  3216. --###############################
  3217. CREATE PROCEDURE [dbo].[bpCaOrderByDeletedSelect]
  3218. (
  3219. @BankType INT,
  3220. @OrderType INT,
  3221. @SearchItem INT,
  3222. @SearchOption INT,
  3223. @SearchText NVARCHAR(200),
  3224. @Where VARCHAR(200)
  3225. )
  3226. AS
  3227. BEGIN
  3228. SET @SearchText = dbo.SafeSQL(@SearchText)
  3229. SET @Where = dbo.SafeSQL(@Where)
  3230. DECLARE @SQL AS VARCHAR(2000)
  3231. SET @SQL = 'SELECT Top 500 OrderType,PayMethod,ServiceType,id,Paid,Accounts,AddDate,OpenDate,RemittanceDate,manageruserid,companyname,cpMainID,DeletedMan,DeletedDate
  3232. FROM caOrder with(nolock) WHERE IsDeleted=1 '
  3233. --付款类型
  3234. IF @BankType<>0
  3235. SET @SQL = @SQL + ' AND PayMethod =' + CAST(@BankType AS NVARCHAR(10))
  3236. --订单类型
  3237. IF @OrderType<>0
  3238. SET @SQL = @SQL + ' AND OrderType =' + CAST(@OrderType AS NVARCHAR(10))
  3239. --搜索条件
  3240. IF @SearchItem=1
  3241. BEGIN
  3242. IF @SearchOption=0--等于
  3243. SET @SQL = @SQL + ' AND ID = ''' + @SearchText + ''''
  3244. ELSE
  3245. SET @SQL = @SQL + ' AND ID LIKE ''%' + @SearchText + '%'''
  3246. END
  3247. ELSE IF @SearchItem=2
  3248. BEGIN
  3249. IF @SearchOption=0--等于
  3250. SET @SQL = @SQL + ' AND CompanyName = ''' + @SearchText+ ''''
  3251. ELSE
  3252. SET @SQL = @SQL + ' AND CompanyName LIKE ''%' + @SearchText + '%'''
  3253. END
  3254. ELSE IF @SearchItem=3
  3255. BEGIN
  3256. IF @SearchOption=0--等于
  3257. SET @SQL = @SQL + ' AND cpMainID = ''' + @SearchText + ''''
  3258. ELSE
  3259. SET @SQL = @SQL + ' AND cpMainID LIKE ''%' + @SearchText + '%'''
  3260. END
  3261. ELSE IF @SearchItem=4
  3262. BEGIN
  3263. IF @SearchOption=0--等于
  3264. SET @SQL = @SQL + ' AND manageruserid = ''' + @SearchText + ''''
  3265. ELSE
  3266. SET @SQL = @SQL + ' AND manageruserid LIKE ''%' + @SearchText + '%'''
  3267. END
  3268. ELSE IF @SearchItem=5
  3269. BEGIN
  3270. IF @SearchText='1'
  3271. SET @SQL = @SQL + ' AND OpenDate Is Not Null'
  3272. ELSE IF @SearchText='0'
  3273. SET @SQL = @SQL + ' AND OpenDate Is Null'
  3274. END
  3275. ELSE IF @SearchItem=6
  3276. BEGIN
  3277. IF @SearchText='1'
  3278. SET @SQL = @SQL + ' AND ReceiveDate Is Not Null'
  3279. ELSE IF @SearchText='0'
  3280. SET @SQL = @SQL + ' AND ReceiveDate Is Null'
  3281. END
  3282. ELSE IF @SearchItem=7
  3283. BEGIN
  3284. IF @SearchText='1'
  3285. SET @SQL = @SQL + ' AND NeedInvoice=1'
  3286. ELSE IF @SearchText='0'
  3287. SET @SQL = @SQL + ' AND NeedInvoice=0'
  3288. END
  3289. IF LEN(@WHERE)>0
  3290. SET @SQL=@SQL + ' ' + @WHERE
  3291. SET @SQL=@SQL + ' Order By DeletedDate Desc'
  3292. PRINT @SQL
  3293. EXEC(@SQL)
  3294. END
  3295. GO
  3296. /****** Object: StoredProcedure [dbo].[bpcaOrderByInvoiceUpdate] Script Date: 2018/12/13 19:03:40 ******/
  3297. SET ANSI_NULLS ON
  3298. GO
  3299. SET QUOTED_IDENTIFIER ON
  3300. GO
  3301. --修改订单发票信息
  3302. --Lucifer 2014-12-19
  3303. CREATE PROCEDURE [dbo].[bpcaOrderByInvoiceUpdate]
  3304. (
  3305. @InvoiceAskDate SMALLDATETIME,
  3306. @NeedInvoice BIT,
  3307. @InvoiceConfirmDate SMALLDATETIME,
  3308. @InvoiceConfirmMan SMALLINT,
  3309. @InvoiceTitle NVARCHAR(50),
  3310. @MailAddress NVARCHAR(100),
  3311. @Recipient NVARCHAR(100),
  3312. @zip CHAR(6),
  3313. @PostTelephone VARCHAR(50),
  3314. @Tariff VARCHAR(30),
  3315. @RegisterAddress NVARCHAR(100),
  3316. @RegisterTel VARCHAR(50),
  3317. @BankName NVARCHAR(50),
  3318. @BankAccount NVARCHAR(50),
  3319. @OrderID INT
  3320. )
  3321. AS
  3322. SET NOCOUNT ON
  3323. BEGIN
  3324. IF @InvoiceConfirmDate IS NULL
  3325. UPDATE caOrder SET
  3326. InvoiceAskDate=@InvoiceAskDate,
  3327. NeedInvoice=@NeedInvoice,
  3328. InvoiceTitle=@InvoiceTitle,
  3329. MailAddress=@MailAddress,
  3330. Recipient=@Recipient,
  3331. zip=@zip,
  3332. IsBackSubmit=1,
  3333. PostTelephone=@PostTelephone,
  3334. Tariff=@Tariff,
  3335. RegisterAddress=@RegisterAddress,
  3336. RegisterTel=@RegisterTel,
  3337. BankName=@BankName,
  3338. BankAccount=@BankAccount
  3339. WHERE ID=@OrderID
  3340. ELSE
  3341. UPDATE caOrder SET
  3342. InvoiceAskDate=@InvoiceAskDate,
  3343. NeedInvoice=@NeedInvoice,
  3344. InvoiceConfirmDate=@InvoiceConfirmDate,
  3345. InvoiceConfirmMan=@InvoiceConfirmMan,
  3346. InvoiceTitle=@InvoiceTitle,
  3347. MailAddress=@MailAddress,
  3348. Recipient=@Recipient,
  3349. zip=@zip,
  3350. IsBackSubmit=1,
  3351. PostTelephone=@PostTelephone,
  3352. Tariff=@Tariff,
  3353. RegisterAddress=@RegisterAddress,
  3354. RegisterTel=@RegisterTel,
  3355. BankName=@BankName,
  3356. BankAccount=@BankAccount
  3357. WHERE ID=@OrderID
  3358. END
  3359. GO
  3360. /****** Object: StoredProcedure [dbo].[bpcaOrderByIsDeleteHasOpenUpdate] Script Date: 2018/12/13 19:03:40 ******/
  3361. SET ANSI_NULLS ON
  3362. GO
  3363. SET QUOTED_IDENTIFIER ON
  3364. GO
  3365. --已开通的订单删除 Lucifer 2014-12-9
  3366. CREATE PROCEDURE [dbo].[bpcaOrderByIsDeleteHasOpenUpdate]
  3367. (
  3368. @OrderID INT,
  3369. @DeletedMan SMALLINT,
  3370. @cpMainID INT,
  3371. @Reason VARCHAR(200)
  3372. )
  3373. AS
  3374. SET NOCOUNT ON
  3375. IF NOT EXISTS(SELECT 'x' FROM caOrder WHERE ReceiveDate IS NULL AND ID = @OrderID)
  3376. RETURN
  3377. BEGIN TRAN
  3378. DECLARE @UsePoint AS INT, @UseCoin AS INT, @GivePoint INT
  3379. --是否是积分订单
  3380. SELECT @UsePoint = PaidPoint, @GivePoint = GivePoint, @UseCoin = PaidCoin
  3381. FROM caOrder WITH(NOLOCK)
  3382. WHERE ID = @OrderID
  3383. IF @UsePoint > 0 --积分订单
  3384. BEGIN
  3385. --插入积分记录
  3386. INSERT INTO cpPoint (cpMainID, changeID, point, relativeID, lastModifyDate)
  3387. VALUES(@cpMainID, 16, @UsePoint, @OrderID, GETDATE())
  3388. END
  3389. IF @GivePoint > 0 --积分订单
  3390. BEGIN
  3391. --插入积分记录
  3392. INSERT INTO cpPoint (cpMainID, changeID, point, relativeID, lastModifyDate)
  3393. VALUES(@cpMainID, 24, @GivePoint * -1, @OrderID, GETDATE())
  3394. END
  3395. IF @UseCoin > 0
  3396. BEGIN
  3397. --插入金币记录
  3398. BEGIN
  3399. IF (SELECT COUNT(*) FROM cpCoin WITH(NOLOCK) WHERE caOrderId = @OrderID) = 1
  3400. BEGIN
  3401. DECLARE @Remaincoin INT
  3402. SELECT @Remaincoin = ISNULL(Remaincoin, 0) FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainID
  3403. INSERT INTO cpCoin(cpMainId, caOrderId, Coin, IsCancel, Balance, AddDate)
  3404. SELECT @cpMainId, @OrderID, @UseCoin, 1, @UseCoin + @Remaincoin, GETDATE()
  3405. END
  3406. END
  3407. END
  3408. SET @Reason = dbo.SafeSQL(@Reason)
  3409. UPDATE caOrder SET OpenDate = NULL, IsDeleted=1, DeletedDate=GETDATE(), DeletedMan=@DeletedMan WHERE ReceiveDate IS NULL AND ID = @OrderID
  3410. INSERT INTO caOrderRemarks(ManagerID,Remarks,OrderID) VALUES(@DeletedMan,@Reason,@OrderID)
  3411. EXEC spRedifinePrivilage @cpMainID
  3412. COMMIT TRAN
  3413. RETURN
  3414. ERR:
  3415. BEGIN
  3416. ROLLBACK TRAN
  3417. RETURN
  3418. END
  3419. GO
  3420. /****** Object: StoredProcedure [dbo].[bpcaOrderByIsDeleteUpdate] Script Date: 2018/12/13 19:03:40 ******/
  3421. SET ANSI_NULLS ON
  3422. GO
  3423. SET QUOTED_IDENTIFIER ON
  3424. GO
  3425. --未开通订单删除 Lucifer 2014-12-9
  3426. --修改:harry 增加积分,金币返还 2015-7-7
  3427. CREATE PROCEDURE [dbo].[bpcaOrderByIsDeleteUpdate]
  3428. (
  3429. @OrderID INT,
  3430. @DeletedMan SMALLINT
  3431. )
  3432. AS
  3433. SET NOCOUNT ON
  3434. BEGIN TRAN
  3435. IF NOT EXISTS(SELECT 'x' FROM caOrder WHERE OpenDate IS NULL AND ID=@OrderID)
  3436. RETURN
  3437. DECLARE @UsePoint AS INT, @UseCoin AS INT, @cpMainID AS INT, @GivePoint INT
  3438. --是否是积分订单
  3439. SELECT @UsePoint = PaidPoint, @GivePoint = GivePoint, @UseCoin = PaidCoin, @cpMainID = cpMainID
  3440. FROM caOrder WITH(NOLOCK)
  3441. WHERE ID = @OrderID
  3442. IF @UsePoint > 0 --积分订单
  3443. BEGIN
  3444. --插入积分记录
  3445. INSERT INTO cpPoint (cpMainID, changeID, point, relativeID, lastModifyDate)
  3446. VALUES(@cpMainID, 16, @UsePoint, @OrderID, GETDATE())
  3447. END
  3448. IF @GivePoint > 0 --积分订单
  3449. BEGIN
  3450. --插入积分记录
  3451. INSERT INTO cpPoint (cpMainID, changeID, point, relativeID, lastModifyDate)
  3452. VALUES(@cpMainID, 24, @GivePoint * -1, @OrderID, GETDATE())
  3453. END
  3454. IF @UseCoin > 0
  3455. BEGIN
  3456. --插入金币记录
  3457. BEGIN
  3458. IF (SELECT COUNT(*) FROM cpCoin WITH(NOLOCK) WHERE caOrderId = @OrderID) = 1
  3459. BEGIN
  3460. DECLARE @Remaincoin INT
  3461. SELECT @Remaincoin = ISNULL(Remaincoin, 0) FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainID
  3462. INSERT INTO cpCoin(cpMainId, caOrderId, Coin, IsCancel, Balance, AddDate)
  3463. SELECT @cpMainId, @OrderID, @UseCoin, 1, @UseCoin + @Remaincoin, GETDATE()
  3464. END
  3465. END
  3466. END
  3467. UPDATE caOrder SET IsDeleted=1, DeletedDate = GETDATE(), DeletedMan=@DeletedMan
  3468. WHERE OpenDate IS NULL AND ID=@OrderID
  3469. COMMIT TRAN
  3470. RETURN 1
  3471. ERR:
  3472. BEGIN
  3473. ROLLBACK TRAN
  3474. RETURN 0
  3475. END
  3476. GO
  3477. /****** Object: StoredProcedure [dbo].[bpcaOrderByJobNumberOpenDateUpdate] Script Date: 2018/12/13 19:03:41 ******/
  3478. SET ANSI_NULLS ON
  3479. GO
  3480. SET QUOTED_IDENTIFIER ON
  3481. GO
  3482. --开通职位数订单 Lucifer 2014-12-24
  3483. CREATE PROCEDURE [dbo].[bpcaOrderByJobNumberOpenDateUpdate]
  3484. (
  3485. @BeginDate SMALLDATETIME,
  3486. @EndDate SMALLDATETIME,
  3487. @OpenMan SMALLINT,
  3488. @OrderID INT,
  3489. @JobNumber INT
  3490. )
  3491. AS
  3492. BEGIN
  3493. UPDATE MainDB..caOrder SET
  3494. BeginDate=@BeginDate,
  3495. EndDate=@EndDate,
  3496. OpenDate=GetDate(),
  3497. OpenMan=@OpenMan,
  3498. JobNumber=@JobNumber
  3499. WHERE ID=@OrderID
  3500. END
  3501. GO
  3502. /****** Object: StoredProcedure [dbo].[bpcaOrderByJobRefrshQuotaOpenDateUpdate] Script Date: 2018/12/13 19:03:41 ******/
  3503. SET ANSI_NULLS ON
  3504. GO
  3505. SET QUOTED_IDENTIFIER ON
  3506. GO
  3507. --开通职位刷新数订单 Harry 2017-6-7
  3508. CREATE PROCEDURE [dbo].[bpcaOrderByJobRefrshQuotaOpenDateUpdate]
  3509. (
  3510. @BeginDate SMALLDATETIME,
  3511. @EndDate SMALLDATETIME,
  3512. @OpenMan SMALLINT,
  3513. @OrderID INT,
  3514. @SmsNumber INT
  3515. )
  3516. AS
  3517. SET NOCOUNT ON
  3518. BEGIN
  3519. UPDATE MainDB..caOrder SET
  3520. BeginDate = @BeginDate,
  3521. EndDate = @EndDate,
  3522. OpenDate = GetDate(),
  3523. OpenMan = @OpenMan,
  3524. jobRefreshQuota = @SmsNumber,
  3525. remainJobRefreshQuota = @SmsNumber
  3526. WHERE ID=@OrderID
  3527. END
  3528. SET NOCOUNT OFF
  3529. GO
  3530. /****** Object: StoredProcedure [dbo].[bpcaOrderByLatestSelect] Script Date: 2018/12/13 19:03:41 ******/
  3531. SET ANSI_NULLS ON
  3532. GO
  3533. SET QUOTED_IDENTIFIER ON
  3534. GO
  3535. --根据企业ID获取最近的正在执行的某类型订单,订单确认用 Lucifer 2014-12-24
  3536. CREATE PROCEDURE [dbo].[bpcaOrderByLatestSelect]
  3537. (
  3538. @cpMainID INT,
  3539. @OrderType SMALLINT
  3540. )
  3541. AS
  3542. BEGIN
  3543. SELECT Top 1 BeginDate,EndDate FROM caOrder WITH(NOLOCK)
  3544. WHERE cpMainId=@cpMainID AND OrderType=@OrderType AND EndDate>GETDATE() AND OpenDate IS NOT NULL AND IsDeleted=0
  3545. ORDER BY EndDate DESC
  3546. END
  3547. GO
  3548. /****** Object: StoredProcedure [dbo].[bpCaOrderByOpenDateSelect] Script Date: 2018/12/13 19:03:41 ******/
  3549. SET ANSI_NULLS ON
  3550. GO
  3551. SET QUOTED_IDENTIFIER ON
  3552. GO
  3553. --创建人 Andy
  3554. --时间 2014-12-03
  3555. --后台按照时间查询没有招聘顾问的订单
  3556. CREATE PROCEDURE [dbo].[bpCaOrderByOpenDateSelect]
  3557. (
  3558. @StartTime Datetime,
  3559. @EndTime Datetime
  3560. )
  3561. AS
  3562. BEGIN
  3563. --有招聘顾问的
  3564. SELECT Paid, DeptId, ManagerUserId
  3565. FROM caOrder a WITH(NOLOCK), Manageruser b WITH(NOLOCK)
  3566. WHERE a.manageruserid=b.id AND a.opendate >= @StartTime and a.opendate<=@EndTime
  3567. --AND a.Paid > 0 AND a.Isdeleted = 0
  3568. --没有招聘顾问的
  3569. SELECT Paid, b.id
  3570. FROM MainDB..caOrder a WITH(NOLOCK), MainDB..cpMain b WITH(NOLOCK)
  3571. WHERE a.cpMainID=b.id AND a.opendate >= @StartTime AND a.opendate<=@EndTime AND a.manageruserid IS NULL
  3572. --AND a.Paid > 0 AND a.Isdeleted = 0
  3573. END
  3574. GO
  3575. /****** Object: StoredProcedure [dbo].[bpcaOrderByOpenDateUpdate] Script Date: 2018/12/13 19:03:41 ******/
  3576. SET ANSI_NULLS ON
  3577. GO
  3578. SET QUOTED_IDENTIFIER ON
  3579. GO
  3580. --开通订单 Lucifer 2014-12-24
  3581. CREATE PROCEDURE [dbo].[bpcaOrderByOpenDateUpdate]
  3582. (
  3583. @BeginDate SMALLDATETIME,
  3584. @EndDate SMALLDATETIME,
  3585. @OpenMan SMALLINT,
  3586. @OrderID INT
  3587. )
  3588. AS
  3589. BEGIN
  3590. UPDATE MainDB..caOrder SET
  3591. BeginDate=@BeginDate,
  3592. EndDate=@EndDate,
  3593. OpenDate=GetDate(),
  3594. OpenMan=@OpenMan
  3595. WHERE ID=@OrderID
  3596. END
  3597. GO
  3598. /****** Object: StoredProcedure [dbo].[bpCaOrderByReceiveDateSelect] Script Date: 2018/12/13 19:03:41 ******/
  3599. SET ANSI_NULLS ON
  3600. GO
  3601. SET QUOTED_IDENTIFIER ON
  3602. GO
  3603. --创建人 Andy
  3604. --时间 2014-12-03
  3605. --后台按照接收时间查询订单
  3606. CREATE PROCEDURE [dbo].[bpCaOrderByReceiveDateSelect]
  3607. (
  3608. @StartTime VARCHAR(20),
  3609. @EndTime VARCHAR(20),
  3610. @Where VARCHAR(200)
  3611. )
  3612. AS
  3613. BEGIN
  3614. SET @Where = dbo.SafeSQL(@Where)
  3615. DECLARE @SQL AS VARCHAR(2000)
  3616. SET @SQL = 'SELECT a.Id ,b.Id CompanyId,b.Name CompanyName,ReceiveDate,b.RegDate,a.AddDate,a.OpenDate,a.Paid,a.OrderType
  3617. FROM CaOrder a WITH(NOLOCK),CpMain b WITH(NOLOCK)
  3618. WHERE a.Paid>0 AND a.cpMainID=b.id
  3619. AND ReceiveDate > ''' + @StartTime + '''
  3620. AND ReceiveDate < ''' + @EndTime + ''''
  3621. IF LEN(@Where) > 0
  3622. SET @SQL = @SQL + @Where
  3623. SET @SQL = @SQL + ' ORDER BY a.OpenDate'
  3624. --PRINT @SQL
  3625. EXEC(@SQL)
  3626. END
  3627. GO
  3628. /****** Object: StoredProcedure [dbo].[bpCaOrderByReceiveDateUpdate] Script Date: 2018/12/13 19:03:41 ******/
  3629. SET ANSI_NULLS ON
  3630. GO
  3631. SET QUOTED_IDENTIFIER ON
  3632. GO
  3633. --更新订单到账日期和到账人员 Lucifer 2014-12-24
  3634. CREATE PROCEDURE [dbo].[bpCaOrderByReceiveDateUpdate]
  3635. (
  3636. @OrderID INT,
  3637. @ReceiveMan SMALLINT
  3638. )
  3639. AS
  3640. BEGIN
  3641. UPDATE MainDB..caOrder SET ReceiveDate=GetDate(),ReceiveMan=@ReceiveMan WHERE ID=@OrderID
  3642. END
  3643. GO
  3644. /****** Object: StoredProcedure [dbo].[bpcaOrderByRemittanceFileUpdate] Script Date: 2018/12/13 19:03:42 ******/
  3645. SET ANSI_NULLS ON
  3646. GO
  3647. SET QUOTED_IDENTIFIER ON
  3648. GO
  3649. --#####################################################
  3650. --创建时间:2014.12.2
  3651. --创建人:Lucifer
  3652. --说明:上传汇款凭证更新
  3653. --harry 2018-5-19 增加 isdocopen
  3654. --#####################################################
  3655. CREATE PROCEDURE [dbo].[bpcaOrderByRemittanceFileUpdate]
  3656. (
  3657. @OrderID INT,
  3658. @RemittanceFile VARCHAR(100),
  3659. @IsDocOpen INT=0--1 合同图片 0 汇款单图片
  3660. )
  3661. AS
  3662. BEGIN
  3663. DECLARE @CurrentFile AS VARCHAR(100)
  3664. SELECT @CurrentFile = RemittanceFile FROM caOrder WHERE ID = @OrderID
  3665. IF ISNULL(@CurrentFile,'') = ''
  3666. UPDATE caOrder SET RemittanceDate = GETDATE(),RemittanceFile = @RemittanceFile WHERE ID = @OrderID
  3667. ELSE
  3668. UPDATE caOrder SET RemittanceDate = GETDATE(),RemittanceFile = RemittanceFile + '|' + @RemittanceFile WHERE ID = @OrderID
  3669. IF @IsDocOpen=1
  3670. UPDATE caOrder SET IsDocOpen =1 WHERE ID = @OrderID --合同图片
  3671. IF @IsDocOpen=0
  3672. UPDATE caOrder SET IsDocOpen =2 WHERE ID = @OrderID AND IsDocOpen =1 --汇款单图片
  3673. END
  3674. GO
  3675. /****** Object: StoredProcedure [dbo].[bpcaOrderBySmsNumberOpenDateUpdate] Script Date: 2018/12/13 19:03:42 ******/
  3676. SET ANSI_NULLS ON
  3677. GO
  3678. SET QUOTED_IDENTIFIER ON
  3679. GO
  3680. --开通短信数订单 Harry 2017-6-7
  3681. CREATE PROCEDURE [dbo].[bpcaOrderBySmsNumberOpenDateUpdate]
  3682. (
  3683. @BeginDate SMALLDATETIME,
  3684. @EndDate SMALLDATETIME,
  3685. @OpenMan SMALLINT,
  3686. @OrderID INT,
  3687. @SmsNumber INT
  3688. )
  3689. AS
  3690. SET NOCOUNT ON
  3691. BEGIN
  3692. UPDATE MainDB..caOrder SET
  3693. BeginDate = @BeginDate,
  3694. EndDate = @EndDate,
  3695. OpenDate = GetDate(),
  3696. OpenMan = @OpenMan,
  3697. SmsQuota = @SmsNumber,
  3698. RemainSmsQuota = @SmsNumber
  3699. WHERE ID=@OrderID
  3700. END
  3701. SET NOCOUNT OFF
  3702. GO
  3703. /****** Object: StoredProcedure [dbo].[bpcaOrderBySumSelect] Script Date: 2018/12/13 19:03:42 ******/
  3704. SET ANSI_NULLS ON
  3705. GO
  3706. SET QUOTED_IDENTIFIER ON
  3707. GO
  3708. CREATE PROCEDURE [dbo].[bpcaOrderBySumSelect]
  3709. (
  3710. @cpMainID INT
  3711. )
  3712. AS
  3713. SET NOCOUNT ON
  3714. BEGIN
  3715. DECLARE @ActiveQuota INT
  3716. DECLARE @UserNumber INT
  3717. DECLARE @JobNumber INT
  3718. DECLARE @RemainQuota INT
  3719. DECLARE @RemainSmsQuota INT
  3720. DECLARE @VIPDate DATETIME
  3721. SELECT @ActiveQuota = SUM(ActiveQuota),@UserNumber=SUM(UserNumber),@JobNumber=SUM(JobNumber),@VIPDate=MAX(EndDate),@RemainQuota=SUM(RemainQuota),@RemainSmsQuota=SUM(RemainSmsQuota)
  3722. FROM caOrder WITH(NOLOCK)
  3723. WHERE BeginDate < GETDATE()
  3724. AND EndDate > GETDATE()
  3725. AND OrderType IN (8,9,10,11,14)
  3726. AND cpMainID = @cpMainID
  3727. AND OpenDate IS NOT NULL
  3728. SELECT @ActiveQuota as ActiveQuota ,@UserNumber as UserNumber,@JobNumber as JobNumber,@VIPDate as VIPDate,@RemainQuota as RemainQuota,@RemainSmsQuota as RemainSmsQuota
  3729. END
  3730. GO
  3731. /****** Object: StoredProcedure [dbo].[bpcaOrderByUserNumberOpenDateUpdate] Script Date: 2018/12/13 19:03:42 ******/
  3732. SET ANSI_NULLS ON
  3733. GO
  3734. SET QUOTED_IDENTIFIER ON
  3735. GO
  3736. --开通用户数订单 Lucifer 2014-12-24
  3737. CREATE PROCEDURE [dbo].[bpcaOrderByUserNumberOpenDateUpdate]
  3738. (
  3739. @BeginDate SMALLDATETIME,
  3740. @EndDate SMALLDATETIME,
  3741. @OpenMan SMALLINT,
  3742. @OrderID INT,
  3743. @UserNumber INT
  3744. )
  3745. AS
  3746. BEGIN
  3747. UPDATE MainDB..caOrder SET
  3748. BeginDate=@BeginDate,
  3749. EndDate=@EndDate,
  3750. OpenDate=GetDate(),
  3751. OpenMan=@OpenMan,
  3752. UserNumber=@UserNumber
  3753. WHERE ID=@OrderID
  3754. END
  3755. GO
  3756. /****** Object: StoredProcedure [dbo].[bpcaOrderRemarksByOrderIDSelect] Script Date: 2018/12/13 19:03:42 ******/
  3757. SET ANSI_NULLS ON
  3758. GO
  3759. SET QUOTED_IDENTIFIER ON
  3760. GO
  3761. --根据cpmainid获取订单备注 Lucifer 2014-12-9
  3762. CREATE PROCEDURE [dbo].[bpcaOrderRemarksByOrderIDSelect]
  3763. (
  3764. @OrderID INT
  3765. )
  3766. AS
  3767. BEGIN
  3768. SELECT * FROM MainDB..caOrderRemarks WITH(NOLOCK) WHERE OrderID=@OrderID
  3769. END
  3770. GO
  3771. /****** Object: StoredProcedure [dbo].[bpcaOrderSelect] Script Date: 2018/12/13 19:03:42 ******/
  3772. SET ANSI_NULLS ON
  3773. GO
  3774. SET QUOTED_IDENTIFIER ON
  3775. GO
  3776. --#####################################################
  3777. --创建时间:2014.12.1
  3778. --创建人:Lucifer
  3779. --说明:根据条件获取订单列表
  3780. --修改:harry 2018-5-21 增加isdocopen
  3781. --修改:sunshine 2018-8-15 增加 dcRegionID
  3782. --#####################################################
  3783. CREATE PROCEDURE [dbo].[bpcaOrderSelect]
  3784. (
  3785. @Where VARCHAR(2000),
  3786. @Order VARCHAR(200)
  3787. )
  3788. AS
  3789. SET NOCOUNT ON
  3790. BEGIN
  3791. DECLARE @SQL AS VARCHAR(MAX)
  3792. SELECT @Where = dbo.SafeSql(@Where), @Order = dbo.SafeSql(@Order)
  3793. SET @SQL = '
  3794. Select Top 1000 Balance, ReceiveDate, FaxFile, OrderType, ProvinceID, PayMethod, ID, Paid, dcFeeDetailID,
  3795. Accounts, AddDate, OpenDate, RemittanceDate, ManageruserID, CompanyName, cpMainID, ServiceType, PlaceWeek, ContractFile,
  3796. NeedInvoice, InvoiceConfirmDate, OpenMan, InvoiceCompany, InvoiceMonth, PaidCoin, CancelReason, EndDate, BeginDate,
  3797. (Select ConsultantID From cpMain WITH(NOLOCK) Where ID = caOrder.cpMainID) ConsultantID, isdocopen,(Select dcRegionID From cpMain WITH(NOLOCK) Where ID = caOrder.cpMainID) dcRegionID
  3798. From caOrder With(Nolock)
  3799. Where 1=1' +
  3800. @Where +
  3801. @Order
  3802. --insert into a2 select @sql, getdate()
  3803. EXEC(@SQL)
  3804. END
  3805. GO
  3806. /****** Object: StoredProcedure [dbo].[bpcaOrderSUMSelect] Script Date: 2018/12/13 19:03:43 ******/
  3807. SET ANSI_NULLS ON
  3808. GO
  3809. SET QUOTED_IDENTIFIER ON
  3810. GO
  3811. --Lambo 20101117
  3812. --获取企业的购买的简历下载数,职位数,用户数
  3813. CREATE PROCEDURE [dbo].[bpcaOrderSUMSelect]
  3814. @cpMainID INT,
  3815. @ActiveQuota INT OUTPUT,
  3816. @UserNumber INT OUTPUT,
  3817. @JobNumber INT OUTPUT,
  3818. @RemainQuota INT OUTPUT,
  3819. @VIPDate DATETIME OUTPUT
  3820. AS
  3821. SELECT @ActiveQuota = SUM(ActiveQuota),@UserNumber=SUM(UserNumber),@JobNumber=SUM(JobNumber),@VIPDate=MAX(EndDate),@RemainQuota=SUM(RemainQuota)
  3822. FROM caOrder WITH(NOLOCK)
  3823. WHERE BeginDate<GETDATE()
  3824. AND EndDate>GETDATE()
  3825. AND OrderType IN (8,9,10,11)
  3826. AND cpMainID = @cpMainID
  3827. AND OpenDate IS NOT NULL
  3828. GO
  3829. /****** Object: StoredProcedure [dbo].[bpcaOrderTryInsert] Script Date: 2018/12/13 19:03:43 ******/
  3830. SET ANSI_NULLS ON
  3831. GO
  3832. SET QUOTED_IDENTIFIER ON
  3833. GO
  3834. --添加试用订单
  3835. --Lucifer 2014-12-19
  3836. --增加短信数harry2017-10-17
  3837. CREATE PROCEDURE [dbo].[bpcaOrderTryInsert]
  3838. (
  3839. @cpMainID INT,
  3840. @ProvinceID SMALLINT,
  3841. @PayMethod TINYINT,
  3842. @ConsultantID SMALLINT,
  3843. @CompanyName NVARCHAR(50),
  3844. @ManageruserID SMALLINT,
  3845. @LinkMan NVARCHAR(50),
  3846. @Telephone VARCHAR(50),
  3847. @LinkRemark NVARCHAR(1000)
  3848. )
  3849. AS
  3850. SET NOCOUNT ON
  3851. BEGIN
  3852. INSERT INTO maindb..caOrder(
  3853. cpMainID,
  3854. ProvinceID,
  3855. PayMethod,
  3856. OrderType,
  3857. Accounts,
  3858. Paid,
  3859. Manageruserid,
  3860. ActiveQuota,
  3861. RemainQuota,
  3862. JobNumber,
  3863. UserNumber,
  3864. SmsQuota,
  3865. RemainSmsQuota,
  3866. JobRefreshQuota,
  3867. RemainJobRefreshQuota,
  3868. CompanyName,
  3869. NeedInvoice,
  3870. dcFeeDetailID,
  3871. IsBackSubmit,
  3872. BeginDate,
  3873. EndDate,
  3874. OrderStatus,
  3875. OpenDate,
  3876. OpenMan,
  3877. LinkMan,
  3878. Telephone,
  3879. LinkRemark,
  3880. ReceiveDate
  3881. )
  3882. VALUES(
  3883. @cpMainID,
  3884. @ProvinceID,
  3885. @PayMethod,
  3886. 8,
  3887. 0,
  3888. 0,
  3889. @ConsultantID,
  3890. 10,
  3891. 10,
  3892. 5,
  3893. 1,
  3894. 7,
  3895. 7,
  3896. 14,
  3897. 14,
  3898. @CompanyName,
  3899. 0,
  3900. 0,
  3901. 1,
  3902. GETDATE(),
  3903. GETDATE()+7,
  3904. 13,
  3905. GETDATE(),
  3906. @ManageruserID,
  3907. @LinkMan,
  3908. @Telephone,
  3909. @LinkRemark,
  3910. GETDATE()
  3911. )
  3912. END
  3913. GO
  3914. /****** Object: StoredProcedure [dbo].[bpcaOrderUpdate] Script Date: 2018/12/13 19:03:43 ******/
  3915. SET ANSI_NULLS ON
  3916. GO
  3917. SET QUOTED_IDENTIFIER ON
  3918. GO
  3919. --更新订单信息
  3920. --Lucifer 2014-12-19
  3921. CREATE PROCEDURE [dbo].[bpcaOrderUpdate]
  3922. (
  3923. @WHERE VARCHAR(MAX),
  3924. @OrderID INT
  3925. )
  3926. AS
  3927. BEGIN
  3928. DECLARE @SQL VARCHAR(MAX)
  3929. SET @WHERE = dbo.SafeSQL(@WHERE)
  3930. SET @SQL = 'UPDATE caOrder SET ' + @WHERE + ' WHERE ID=' + CONVERT(VARCHAR(20),@OrderID)
  3931. EXEC(@SQL)
  3932. END
  3933. GO
  3934. /****** Object: StoredProcedure [dbo].[bpcaPlaintSelect] Script Date: 2018/12/13 19:03:43 ******/
  3935. SET ANSI_NULLS ON
  3936. GO
  3937. SET QUOTED_IDENTIFIER ON
  3938. GO
  3939. -----------------
  3940. --创建日期:2010-9-29
  3941. --创建人:lambo
  3942. --功能说明:根据条件查询记录
  3943. --用于后台客户服务模块,单位投诉个人页面
  3944. -----------------
  3945. CREATE PROCEDURE [dbo].[bpcaPlaintSelect]
  3946. (
  3947. @WHERE VARCHAR(1000)
  3948. )
  3949. AS
  3950. BEGIN
  3951. DECLARE @SQL VARCHAR(2000)
  3952. SET @SQL = 'SELECT TOP 5000 e.mobile,e.email paemail,a.*,b.name caName,d.paMainID paMainID,c.consultantID,c.Name,c.dcProvinceID,c.ID cpMainID,c.regDate'
  3953. SET @SQL = @SQL + ' FROM caPlaint a WITH(NOLOCK) '
  3954. SET @SQL = @SQL + ' LEFT JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID '
  3955. SET @SQL = @SQL + ' LEFT JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID '
  3956. SET @SQL = @SQL + ' INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID '
  3957. SET @SQL = @SQL + ' INNER JOIN paMain e WITH(NOLOCK) ON d.paMainID = e.ID '
  3958. SET @SQL = @SQL + ' WHERE 1=1 '
  3959. IF LEN(@WHERE) > 0
  3960. BEGIN
  3961. SET @WHERE = dbo.SafeSql(@Where)
  3962. SET @SQL = @SQL + @WHERE
  3963. END
  3964. SET @SQL = @SQL + ' ORDER BY a.AddDate DESC'
  3965. EXEC(@SQL)
  3966. END
  3967. GO
  3968. /****** Object: StoredProcedure [dbo].[bpCaPlaintUpdate] Script Date: 2018/12/13 19:03:43 ******/
  3969. SET ANSI_NULLS ON
  3970. GO
  3971. SET QUOTED_IDENTIFIER ON
  3972. GO
  3973. -----------------
  3974. --创建日期:2010-9-26
  3975. --创建人:lambo
  3976. --功能说明:根据编号修改一条单位投诉个人的记录
  3977. --用于后台单位投诉个人页面的处理文件
  3978. -----------------
  3979. CREATE PROCEDURE [dbo].[bpCaPlaintUpdate]
  3980. (
  3981. @ID INT,
  3982. @ReplyType INT,
  3983. @ReplyMan INT,
  3984. @ProcessMessage VARCHAR(500)
  3985. )
  3986. AS
  3987. BEGIN TRY
  3988. UPDATE CaPlaint SET ReplyType=@ReplyType,ReplyMan=@ReplyMan,ProcessMessage=@ProcessMessage,ProcessDate=GETDATE() WHERE ID=@ID
  3989. RETURN 1
  3990. END TRY
  3991. BEGIN CATCH
  3992. RETURN 0
  3993. END CATCH
  3994. GO
  3995. /****** Object: StoredProcedure [dbo].[bpCertificate_UnrealByIDDelete] Script Date: 2018/12/13 19:03:43 ******/
  3996. SET ANSI_NULLS ON
  3997. GO
  3998. SET QUOTED_IDENTIFIER ON
  3999. GO
  4000. --###########################
  4001. --创建时间:2014.12.15
  4002. --创建人:Nick
  4003. --说明:删除虚假营业执照
  4004. --###########################
  4005. CREATE PROCEDURE [dbo].[bpCertificate_UnrealByIDDelete]
  4006. (
  4007. @ID INT
  4008. )
  4009. AS
  4010. BEGIN
  4011. DELETE FROM certificate_unreal WHERE id = @ID
  4012. END
  4013. GO
  4014. /****** Object: StoredProcedure [dbo].[bpCertificate_UnrealByIDInsert] Script Date: 2018/12/13 19:03:43 ******/
  4015. SET ANSI_NULLS ON
  4016. GO
  4017. SET QUOTED_IDENTIFIER ON
  4018. GO
  4019. --###########################
  4020. --创建时间:2014.12.15
  4021. --创建人:Nick
  4022. --说明:插入虚假营业执照
  4023. --###########################
  4024. CREATE PROCEDURE [dbo].[bpCertificate_UnrealByIDInsert]
  4025. (
  4026. @CompanyName NVARCHAR(100),
  4027. @CertFileName VARCHAR(100),
  4028. @ManagerUserID INT,
  4029. @Des VARCHAR(MAX)
  4030. )
  4031. AS
  4032. BEGIN
  4033. INSERT INTO certificate_unreal (Companyname,certfilename,addman,description)
  4034. VALUES (@CompanyName,@CertFileName,@ManagerUserID,@Des)
  4035. END
  4036. GO
  4037. /****** Object: StoredProcedure [dbo].[bpCertificate_UnrealByIDSelect] Script Date: 2018/12/13 19:03:44 ******/
  4038. SET ANSI_NULLS ON
  4039. GO
  4040. SET QUOTED_IDENTIFIER ON
  4041. GO
  4042. --###########################
  4043. --创建时间:2014.12.15
  4044. --创建人:Nick
  4045. --说明:获取虚假营业执照
  4046. --###########################
  4047. CREATE PROCEDURE [dbo].[bpCertificate_UnrealByIDSelect]
  4048. (
  4049. @ID INT
  4050. )
  4051. AS
  4052. BEGIN
  4053. SELECT certfilename FROM certificate_unreal WITH(NOLOCK) WHERE id = @ID
  4054. END
  4055. GO
  4056. /****** Object: StoredProcedure [dbo].[bpCertificate_UnrealSelect] Script Date: 2018/12/13 19:03:44 ******/
  4057. SET ANSI_NULLS ON
  4058. GO
  4059. SET QUOTED_IDENTIFIER ON
  4060. GO
  4061. --###########################
  4062. --创建时间:2014.12.15
  4063. --创建人:Nick
  4064. --说明:获取虚假营业执照案例
  4065. --###########################
  4066. CREATE PROCEDURE [dbo].[bpCertificate_UnrealSelect]
  4067. AS
  4068. BEGIN
  4069. SELECT a.id,a.Companyname,a.certfilename,a.addman,a.AddDate,a.description, b.name
  4070. FROM certificate_unreal a WITH(NOLOCK) ,ManagerUser b
  4071. WHERE a.AddMan = b.ID
  4072. ORDER BY AddDate DESC
  4073. END
  4074. GO
  4075. /****** Object: StoredProcedure [dbo].[bpColdCustomerBycpMainIDSelect] Script Date: 2018/12/13 19:03:44 ******/
  4076. SET ANSI_NULLS ON
  4077. GO
  4078. SET QUOTED_IDENTIFIER ON
  4079. GO
  4080. --根据企业ID获取冷客户记录
  4081. --Lucifer 2014-12-19
  4082. CREATE PROCEDURE [dbo].[bpColdCustomerBycpMainIDSelect]
  4083. (
  4084. @cpMainID INT
  4085. )
  4086. AS
  4087. BEGIN
  4088. SELECT * FROM maindb..ColdCustomer WITH(NOLOCK) WHERE IsValid=1 AND cpMainID=@cpMainID
  4089. END
  4090. GO
  4091. /****** Object: StoredProcedure [dbo].[bpColdCustomerInsert] Script Date: 2018/12/13 19:03:44 ******/
  4092. SET ANSI_NULLS ON
  4093. GO
  4094. SET QUOTED_IDENTIFIER ON
  4095. GO
  4096. CREATE PROCEDURE [dbo].[bpColdCustomerInsert]
  4097. (
  4098. @CompanyName VARCHAR(100),
  4099. @ProvinceID TINYINT,
  4100. @Email VARCHAR(100),
  4101. @Phone VARCHAR(50),
  4102. @SourceLink VARCHAR(1000),
  4103. @RegType TINYINT,
  4104. @RegUserName VARCHAR(50),
  4105. @RegPassWord VARCHAR(50),
  4106. @IsNameRepeat BIT,
  4107. @IsEmailRepeat BIT,
  4108. @IsMobilerepeat BIT,
  4109. @IsAgree BIT,
  4110. @DisAgreeReason nvarchar(500),
  4111. @Status TINYINT,
  4112. @IsValid BIT,
  4113. @CheckReason nvarchar(500),
  4114. @CheckDate SMALLDATETIME,
  4115. @AddDate SMALLDATETIME,
  4116. @AddMan SMALLINT,
  4117. @AddWorkUserID SMALLINT,
  4118. @LinkMan VARCHAR(50),
  4119. @CpMainIDOld VARCHAR(100),
  4120. @PhotoFile VARCHAR(50),
  4121. @qq VARCHAR(15),
  4122. @cpIndustry VARCHAR(50),
  4123. @dcCompanyKindID INT,
  4124. @dcCompanySizeID INT,
  4125. @dcRegionID VARCHAR(6),
  4126. @Address VARCHAR(120),
  4127. @Brief VARCHAR(6000),
  4128. @OtherContact VARCHAR(100)
  4129. )
  4130. AS
  4131. SET NOCOUNT ON
  4132. BEGIN
  4133. INSERT INTo MainDB..ColdCustomer
  4134. (CompanyName, ProvinceID, Email, Phone, SourceLink, RegType,
  4135. RegUserName, RegPassWord, IsNameRepeat, IsEmailRepeat, IsMobilerepeat,
  4136. IsAgree, DisAgreeReason, Status, IsValid, CheckReason, CheckDate,
  4137. AddDate, AddMan, AddWorkUserID, LinkMan, CpMainIDOld, PhotoFile, QQ, cpIndustry, Address,
  4138. Brief, dcCompanySizeID, dcRegionID, dcCompanyKindID, OtherContact)
  4139. SELECT @CompanyName, @ProvinceID, @Email, @Phone, @SourceLink, @RegType,
  4140. @RegUserName, @RegPassWord, @IsNameRepeat, @IsEmailRepeat, @IsMobilerepeat,
  4141. @IsAgree, @DisAgreeReason, @Status, @IsValid, @CheckReason, @CheckDate,
  4142. @AddDate, @AddMan, @AddWorkUserID, @LinkMan, @CpMainIDOld, @PhotoFile, @QQ, @cpIndustry, @Address,
  4143. @Brief, @dcCompanySizeID, @dcRegionID, @dcCompanyKindID, @OtherContact
  4144. SELECT @@IDENTITY
  4145. END
  4146. GO
  4147. /****** Object: StoredProcedure [dbo].[bpColdCustomerReleaseConsultant] Script Date: 2018/12/13 19:03:44 ******/
  4148. SET ANSI_NULLS ON
  4149. GO
  4150. SET QUOTED_IDENTIFIER ON
  4151. GO
  4152. --alen 2018-4-4
  4153. --harry 2018-6-7 修改:分配顾问时间大于2个月的才释放
  4154. CREATE PROCEDURE [dbo].[bpColdCustomerReleaseConsultant]
  4155. AS
  4156. BEGIN
  4157. SET NOCOUNT ON
  4158. --2个月内未注册的,释放
  4159. UPDATE Maindb..ColdCustomer
  4160. SET AddMan = NULL
  4161. WHERE CpMainID IS NULL
  4162. AND AddDate < DATEADD(m, -2, GETDATE())
  4163. AND AddMan IS NOT NULL
  4164. --已注册,注册2个月内未上传营业执照的,释放
  4165. UPDATE a SET a.AddMan = NULL FROM Maindb..ColdCustomer a, cpMain b
  4166. WHERE a.cpMainID = b.ID AND b.HasLicence = 0 AND a.RegisterDate < DATEADD(m, -2, GETDATE())
  4167. AND b.consultantDate< DATEADD(m, -2, GETDATE())
  4168. AND a.AddMan IS NOT NULL
  4169. SET NOCOUNT OFF
  4170. --企业已删除的,改为未注册状态
  4171. UPDATE ColdCustomer SET
  4172. [Status] = 1,
  4173. cpMainID = NULL,
  4174. RegisterDate = NULL,
  4175. LastLoginDate = NULL,
  4176. LicenceDate = NULL,
  4177. PayDate = NULL,
  4178. PayFee = NULL
  4179. WHERE cpMainID > 0 AND cpMainId NOT IN(SELECT ID FROM cpMain)
  4180. END
  4181. GO
  4182. /****** Object: StoredProcedure [dbo].[bpColdCustomerTryByCompanyNameSelect] Script Date: 2018/12/13 19:03:44 ******/
  4183. SET ANSI_NULLS ON
  4184. GO
  4185. SET QUOTED_IDENTIFIER ON
  4186. GO
  4187. --根据公司名称获取冷客户VIP试用记录
  4188. --Lucifer 2014-12-19
  4189. CREATE PROCEDURE [dbo].[bpColdCustomerTryByCompanyNameSelect]
  4190. (
  4191. @CompanyName NVARCHAR(100)
  4192. )
  4193. AS
  4194. BEGIN
  4195. SELECT * FROM maindb..ColdCustomerTry WITH(NOLOCK) WHERE CompanyName=@CompanyName
  4196. END
  4197. GO
  4198. /****** Object: StoredProcedure [dbo].[bpCommentAndInterviewByStatisticsSelect] Script Date: 2018/12/13 19:03:45 ******/
  4199. SET ANSI_NULLS ON
  4200. GO
  4201. SET QUOTED_IDENTIFIER ON
  4202. GO
  4203. ---修改人Harry,修改点评、面经统计错误
  4204. CREATE PROCEDURE [dbo].[bpCommentAndInterviewByStatisticsSelect]
  4205. (
  4206. @ManagerUserID SMALLINT,
  4207. @YearMonth VARCHAR(6),
  4208. @DeptID SMALLINT
  4209. )
  4210. AS
  4211. BEGIN
  4212. CREATE TABLE #T
  4213. (
  4214. YearMonth VARCHAR(6),
  4215. WorkUserID SMALLINT,
  4216. paMainID INT,
  4217. GoodComment INT,
  4218. CommonComment INT,
  4219. InvalidComment INT,
  4220. GoodInterview INT,
  4221. CommonInterview INT,
  4222. InvalidInterview INT
  4223. )
  4224. IF LEN(ISNULL(@YearMonth,'')) = 0
  4225. BEGIN
  4226. IF DAY(GETDATE()) > 25
  4227. BEGIN
  4228. INSERT INTO #T(YearMonth,WorkUserID,paMainID) SELECT CONVERT(VARCHAR(6),DATEADD(MONTH,1,GETDATE()),112),WorkUserID,PaMainID FROM oadb..opWorkUserPaMain
  4229. INSERT INTO #T(YearMonth,WorkUserID,paMainID) SELECT CONVERT(VARCHAR(6),GETDATE(),112),WorkUserID,PaMainID FROM oadb..opWorkUserPaMain
  4230. INSERT INTO #T(YearMonth,WorkUserID,paMainID) SELECT CONVERT(VARCHAR(6),DATEADD(MONTH,-1,GETDATE()),112),WorkUserID,PaMainID FROM oadb..opWorkUserPaMain
  4231. END
  4232. ELSE
  4233. BEGIN
  4234. INSERT INTO #T(YearMonth,WorkUserID,paMainID) SELECT CONVERT(VARCHAR(6),GETDATE(),112),WorkUserID,PaMainID FROM oadb..opWorkUserPaMain
  4235. INSERT INTO #T(YearMonth,WorkUserID,paMainID) SELECT CONVERT(VARCHAR(6),DATEADD(MONTH,-1,GETDATE()),112),WorkUserID,PaMainID FROM oadb..opWorkUserPaMain
  4236. INSERT INTO #T(YearMonth,WorkUserID,paMainID) SELECT CONVERT(VARCHAR(6),DATEADD(MONTH,-2,GETDATE()),112),WorkUserID,PaMainID FROM oadb..opWorkUserPaMain
  4237. END
  4238. END
  4239. ELSE
  4240. BEGIN
  4241. INSERT INTO #T(YearMonth,WorkUserID,paMainID) SELECT @YearMonth,WorkUserID,PaMainID FROM oadb..opWorkUserPaMain
  4242. END
  4243. IF @ManagerUserID > 0
  4244. BEGIN
  4245. DELETE FROM #T WHERE WorkUserID NOT IN(SELECT ID FROM oadb..WorkUser WHERE ManageruserID=@ManagerUserID)
  4246. END
  4247. IF @DeptID > 0
  4248. BEGIN
  4249. DELETE FROM #T WHERE WorkUserID NOT IN(SELECT a.ID FROM oadb..WorkUser a,maindb..Manageruser b WHERE a.ManageruserID=b.ID AND b.DeptID=@DeptID)
  4250. END
  4251. --优质评论
  4252. UPDATE a SET a.GoodComment=b.cnt FROM #T a,(
  4253. SELECT paMainID,CONVERT(VARCHAR(6),AddDate,112) YearMonth,COUNT(1) cnt FROM(
  4254. SELECT ROW_NUMBER() OVER(PARTITION BY a.PaMainID, a.CpMainID ORDER BY a.ADDDATE DESC) i,a.paMainID,a.AddDate,a.CommentType
  4255. FROM Comments a, oadb..opWorkUserPaMain b, oadb..opCommentCompany c
  4256. WHERE a.paMainID=b.paMainID AND a.cpMainID=c.cpMainID AND c.WorkUserID=b.WorkUserID AND a.CommentType=2
  4257. ) a
  4258. WHERE i<4
  4259. GROUP BY paMainID,CONVERT(VARCHAR(6),AddDate,112)
  4260. ) b
  4261. WHERE a.YearMonth=b.YearMonth AND a.paMainID=b.paMainID
  4262. --一般评论
  4263. UPDATE a SET a.CommonComment=b.cnt FROM #T a,(
  4264. SELECT paMainID,CONVERT(VARCHAR(6),AddDate,112) YearMonth,COUNT(1) cnt FROM(
  4265. SELECT ROW_NUMBER() OVER(PARTITION BY a.PaMainID, a.CpMainID ORDER BY a.ADDDATE DESC) i,a.paMainID,a.AddDate,a.CommentType
  4266. FROM Comments a, oadb..opWorkUserPaMain b, oadb..opCommentCompany c
  4267. WHERE a.paMainID=b.paMainID AND a.cpMainID=c.cpMainID AND c.WorkUserID=b.WorkUserID AND a.CommentType=1
  4268. ) a
  4269. WHERE i<4
  4270. GROUP BY paMainID,CONVERT(VARCHAR(6),AddDate,112)
  4271. ) b
  4272. WHERE a.YearMonth=b.YearMonth AND a.paMainID=b.paMainID
  4273. --无效评论
  4274. UPDATE a SET a.InvalidComment=b.cnt FROM #T a,(
  4275. SELECT paMainID,CONVERT(VARCHAR(6),AddDate,112) YearMonth,COUNT(1) cnt FROM(
  4276. SELECT ROW_NUMBER() OVER(PARTITION BY a.PaMainID, a.CpMainID ORDER BY a.ADDDATE DESC) i,a.paMainID,a.AddDate,a.CommentType
  4277. FROM Comments a, oadb..opWorkUserPaMain b, oadb..opCommentCompany c
  4278. WHERE a.paMainID=b.paMainID AND a.cpMainID=c.cpMainID AND c.WorkUserID=b.WorkUserID AND a.CommentType=3
  4279. ) a
  4280. WHERE i<4
  4281. GROUP BY paMainID,CONVERT(VARCHAR(6),AddDate,112)
  4282. ) b
  4283. WHERE a.YearMonth=b.YearMonth AND a.paMainID=b.paMainID
  4284. --优质面经
  4285. UPDATE a SET a.GoodInterview=b.cnt FROM #T a,(
  4286. SELECT paMainID,CONVERT(VARCHAR(6),AddDate,112) YearMonth,COUNT(1) cnt FROM(
  4287. SELECT ROW_NUMBER() OVER(PARTITION BY a.PaMainID, a.CpMainID ORDER BY a.ADDDATE DESC) i,a.paMainID,a.AddDate,a.InterviewType
  4288. FROM Interview a, oadb..opWorkUserPaMain b, oadb..opCommentCompany c
  4289. WHERE a.paMainID=b.paMainID AND a.cpMainID=c.cpMainID AND c.WorkUserID=b.WorkUserID AND a.InterviewType=2
  4290. ) a
  4291. WHERE i<4
  4292. GROUP BY paMainID,CONVERT(VARCHAR(6),AddDate,112)
  4293. ) b
  4294. WHERE a.YearMonth=b.YearMonth AND a.paMainID=b.paMainID
  4295. --一般面经
  4296. UPDATE a SET a.CommonInterview=b.cnt FROM #T a,(
  4297. SELECT paMainID,CONVERT(VARCHAR(6),AddDate,112) YearMonth,COUNT(1) cnt FROM(
  4298. SELECT ROW_NUMBER() OVER(PARTITION BY a.PaMainID, a.CpMainID ORDER BY a.ADDDATE DESC) i,a.paMainID,a.AddDate,a.InterviewType
  4299. FROM Interview a, oadb..opWorkUserPaMain b, oadb..opCommentCompany c
  4300. WHERE a.paMainID=b.paMainID AND a.cpMainID=c.cpMainID AND c.WorkUserID=b.WorkUserID AND a.InterviewType=1
  4301. ) a
  4302. WHERE i<4
  4303. GROUP BY paMainID,CONVERT(VARCHAR(6),AddDate,112)
  4304. ) b
  4305. WHERE a.YearMonth=b.YearMonth AND a.paMainID=b.paMainID
  4306. --无效面经
  4307. UPDATE a SET a.InvalidInterview=b.cnt FROM #T a,(
  4308. SELECT paMainID,CONVERT(VARCHAR(6),AddDate,112) YearMonth,COUNT(1) cnt FROM(
  4309. SELECT ROW_NUMBER() OVER(PARTITION BY a.PaMainID, a.CpMainID ORDER BY a.ADDDATE DESC) i,a.paMainID,a.AddDate,a.InterviewType
  4310. FROM Interview a, oadb..opWorkUserPaMain b, oadb..opCommentCompany c
  4311. WHERE a.paMainID=b.paMainID AND a.cpMainID=c.cpMainID AND c.WorkUserID=b.WorkUserID AND a.InterviewType=3
  4312. ) a
  4313. WHERE i<4
  4314. GROUP BY paMainID,CONVERT(VARCHAR(6),AddDate,112)
  4315. ) b
  4316. WHERE a.YearMonth=b.YearMonth AND a.paMainID=b.paMainID
  4317. DELETE FROM #T WHERE GoodComment IS NULL
  4318. AND CommonComment IS NULL
  4319. AND InvalidComment IS NULL
  4320. AND GoodInterview IS NULL
  4321. AND CommonInterview IS NULL
  4322. AND InvalidInterview IS NULL
  4323. SELECT * FROM #T
  4324. DROP TABLE #T
  4325. END
  4326. GO
  4327. /****** Object: StoredProcedure [dbo].[bpCommentByStatisticsSelect] Script Date: 2018/12/13 19:03:45 ******/
  4328. SET ANSI_NULLS ON
  4329. GO
  4330. SET QUOTED_IDENTIFIER ON
  4331. GO
  4332. --审核人点评和面经审核工作量统计
  4333. --创建人:harry
  4334. --创建时间:2015/3/18
  4335. CREATE PROCEDURE [dbo].[bpCommentByStatisticsSelect]
  4336. (
  4337. @YearMonth VARCHAR(6),
  4338. @BeginDate DateTime,
  4339. @EndDate DateTime
  4340. )
  4341. AS
  4342. BEGIN
  4343. DECLARE @t AS TABLE
  4344. (
  4345. YearMonth VARCHAR(6),
  4346. ManagerUserId SMALLINT,
  4347. UserName VARCHAR(10),
  4348. GoodComment INT,
  4349. CommonComment INT,
  4350. InvalidComment INT,
  4351. GoodInterview INT,
  4352. CommonInterview INT,
  4353. InvalidInterview INT
  4354. )
  4355. INSERT INTO @t(ManagerUserId, UserName, YearMonth)
  4356. SELECT DISTINCT verifyman,name,@YearMonth FROM
  4357. (
  4358. (
  4359. SELECT DISTINCT a.verifyman, b.Name
  4360. FROM Comments a, managerUser b
  4361. WHERE verifyman IS NOT NULL
  4362. AND a.verifyman=b.Id
  4363. )
  4364. UNION
  4365. (
  4366. SELECT DISTINCT a.verifyman, b.Name
  4367. FROM interview a, managerUser b
  4368. WHERE verifyman IS NOT NULL
  4369. AND a.verifyman=b.Id
  4370. )
  4371. )E
  4372. --优质评论
  4373. UPDATE z SET GoodComment=(
  4374. SELECT COUNT(1)
  4375. FROM comments a
  4376. WHERE a.verifyman = z.ManagerUserId
  4377. AND a.commenttype=2
  4378. AND a.verifyDate>@BeginDate
  4379. AND a.verifyDate<@EndDate
  4380. GROUP BY a.commenttype, a.verifyman)
  4381. FROM @t z
  4382. --一般评论
  4383. UPDATE z SET CommonComment=(
  4384. SELECT COUNT(1)
  4385. FROM comments a
  4386. WHERE a.verifyman=z.ManagerUserId
  4387. AND a.commenttype=1
  4388. AND a.verifyDate>@BeginDate
  4389. AND a.verifyDate<@EndDate
  4390. GROUP BY a.commenttype,a.verifyman)
  4391. FROM @t z
  4392. --无效评论
  4393. UPDATE z SET InvalidComment=(
  4394. SELECT COUNT(1)
  4395. FROM comments a
  4396. WHERE a.verifyman=z.ManagerUserId
  4397. AND a.commenttype=3
  4398. AND a.verifyDate>@BeginDate
  4399. AND a.verifyDate<@EndDate
  4400. GROUP BY a.commenttype,a.verifyman)
  4401. FROM @t z
  4402. --优质面经
  4403. UPDATE z SET GoodInterview=(
  4404. SELECT COUNT(1)
  4405. FROM interview a
  4406. WHERE a.verifyman=z.ManagerUserId
  4407. AND a.interviewtype=2
  4408. AND a.verifyDate>@BeginDate
  4409. AND a.verifyDate<@EndDate
  4410. GROUP BY a.interviewtype,a.verifyman)
  4411. FROM @t z
  4412. --一般面经
  4413. UPDATE z SET CommonInterview=(
  4414. SELECT COUNT(1)
  4415. FROM interview a
  4416. WHERE a.verifyman=z.ManagerUserId
  4417. AND a.interviewtype=1
  4418. AND a.verifyDate>@BeginDate
  4419. AND a.verifyDate<@EndDate
  4420. GROUP BY a.interviewtype,a.verifyman)
  4421. FROM @t z
  4422. --无效面经
  4423. UPDATE z SET InvalidInterview=(
  4424. SELECT COUNT(1)
  4425. FROM interview a
  4426. WHERE a.verifyman=z.ManagerUserId AND a.interviewtype=3
  4427. AND a.verifyDate>@BeginDate
  4428. AND a.verifyDate<@EndDate
  4429. GROUP BY a.interviewtype,a.verifyman)
  4430. FROM @t z
  4431. SELECT * FROM @t
  4432. END
  4433. GO
  4434. /****** Object: StoredProcedure [dbo].[bpCommentsByCpMainID_CpLicenceUpdate] Script Date: 2018/12/13 19:03:45 ******/
  4435. SET ANSI_NULLS ON
  4436. GO
  4437. SET QUOTED_IDENTIFIER ON
  4438. GO
  4439. --###########################
  4440. --创建时间:2014.12.18
  4441. --创建人:Nick
  4442. --说明:营业执照审核时更新点评 面经信息
  4443. --###########################
  4444. CREATE PROCEDURE [dbo].[bpCommentsByCpMainID_CpLicenceUpdate]
  4445. (
  4446. @cpMainID INT,
  4447. @CompanyNameOld NVARCHAR(50),
  4448. @CompanyNameNew NVARCHAR(50),
  4449. @TypeID INT --1修改执照 2新增执照
  4450. )
  4451. AS
  4452. return
  4453. SET NOCOUNT ON
  4454. BEGIN
  4455. IF @TypeID = 1
  4456. BEGIN
  4457. IF @CompanyNameOld<>@CompanyNameNew
  4458. BEGIN
  4459. DELETE FROM Comments WHERE CpmainID = @cpMainID
  4460. DELETE FROM InterView WHERE CpmainID = @cpMainID
  4461. --添加营业执照 同步 点评信息
  4462. INSERT INTO Comments
  4463. SELECT @cpMainID,PaMainID,IP,SessionID,Relation,GradeStar,Remark1,Remark2,Remark3,Title,Position,WorkRegionID,
  4464. EntryDate,QuitDate,AddDate,CommentType,VerifyMan,VerifyDate,ReplyDate,ReplyContent,ReplyVerifyMan,ReplyVerifyDate,
  4465. PraiseCount,LoginPraiseCount,ReplyVerifyResult,0
  4466. FROM Comments
  4467. WHERE CpMainID IN (
  4468. SELECT TOP 1 CpMainID FROM Comments
  4469. WHERE CpMainID IN (SELECT ID FROM CpMain WHERE Name = @CompanyNameNew AND MemberType > 1)
  4470. AND CpMainID <> @cpMainID
  4471. )
  4472. --添加营业执照 同步 面经信息
  4473. INSERT INTO InterView
  4474. SELECT @cpMainID,PaMainID,IP,SessionID,JobName,InterviewDate,InterViewResult,SalaryMonth,InterViewExperience,
  4475. InterviewFeeling,Title,AddDate,VerifyMan,VerifyDate,InterviewType,ReplyDate,ReplyContent,ReplyVerifyMan,
  4476. ReplyVerifyDate,ReplyVerifyResult,PraiseCount,LoginPraiseCount,0
  4477. FROM InterView
  4478. WHERE CpMainID IN (
  4479. SELECT TOP 1 CpMainID FROM InterView
  4480. WHERE CpMainID IN (SELECT ID FROM CpMain WHERE Name = @CompanyNameNew AND MemberType > 1)
  4481. AND CpMainID <> @cpMainID
  4482. )
  4483. END
  4484. END
  4485. ELSE
  4486. BEGIN
  4487. --添加营业执照 同步 点评信息
  4488. INSERT INTO Comments
  4489. SELECT @cpMainID,PaMainID,IP,SessionID,Relation,GradeStar,Remark1,Remark2,Remark3,Title,Position,WorkRegionID,
  4490. EntryDate,QuitDate,AddDate,CommentType,VerifyMan,VerifyDate,ReplyDate,ReplyContent,ReplyVerifyMan,ReplyVerifyDate,
  4491. PraiseCount,LoginPraiseCount,ReplyVerifyResult,0
  4492. FROM Comments
  4493. WHERE CpMainID IN (
  4494. SELECT TOP 1 CpMainID FROM Comments
  4495. WHERE CpMainID IN (SELECT ID FROM CpMain WHERE Name = @CompanyNameNew AND MemberType > 1)
  4496. AND CpMainID <> @cpMainID
  4497. )
  4498. --添加营业执照 同步 面经信息
  4499. INSERT INTO InterView
  4500. SELECT @cpMainID,PaMainID,IP,SessionID,JobName,InterviewDate,InterViewResult,SalaryMonth,InterViewExperience,
  4501. InterviewFeeling,Title,AddDate,VerifyMan,VerifyDate,InterviewType,ReplyDate,ReplyContent,ReplyVerifyMan,
  4502. ReplyVerifyDate,ReplyVerifyResult,PraiseCount,LoginPraiseCount,0
  4503. FROM InterView
  4504. WHERE CpMainID IN (
  4505. SELECT TOP 1 CpMainID FROM InterView
  4506. WHERE CpMainID IN (SELECT ID FROM CpMain WHERE Name = @CompanyNameNew AND MemberType > 1)
  4507. AND CpMainID <> @cpMainID
  4508. )
  4509. END
  4510. END
  4511. GO
  4512. /****** Object: StoredProcedure [dbo].[bpCommentsSelect] Script Date: 2018/12/13 19:03:46 ******/
  4513. SET ANSI_NULLS ON
  4514. GO
  4515. SET QUOTED_IDENTIFIER ON
  4516. GO
  4517. CREATE PROCEDURE [dbo].[bpCommentsSelect]
  4518. (
  4519. @Where VARCHAR(MAX)
  4520. )
  4521. AS
  4522. BEGIN
  4523. DECLARE @Sql VARCHAR(MAX)
  4524. SET @Sql = 'SELECT TOP 2000 d.Name CompanyName,e.UserName,a.AddDate,a.CommentType,
  4525. d.SecondID,d.dcProvinceID,f.ManageruserID,f.Name ManageruserName,a.VerifyDate
  4526. FROM Maindb..Comments a,
  4527. oadb..opCommentCompany b,
  4528. oadb..opWorkUserPaMain c,
  4529. MainDB..cpMain d,
  4530. MainDB..paMain e,
  4531. oadb..WorkUser f
  4532. WHERE a.cpMainID=b.cpMainID
  4533. AND b.WorkUserID=c.WorkUserID
  4534. AND a.paMainID=c.paMainID
  4535. AND d.ID=a.cpMainID
  4536. AND e.ID=a.paMainID
  4537. AND f.ID=b.WorkUserID' + @where +
  4538. ' ORDER BY a.AddDate DESC'
  4539. EXEC(@SQL)
  4540. END
  4541. GO
  4542. /****** Object: StoredProcedure [dbo].[bpCompany_BlackByCompanyNameSelect] Script Date: 2018/12/13 19:03:46 ******/
  4543. SET ANSI_NULLS ON
  4544. GO
  4545. SET QUOTED_IDENTIFIER ON
  4546. GO
  4547. --###########################
  4548. --创建时间:2014.12.10
  4549. --创建人:Nick
  4550. --说明:根据单位名称判断是否在黑名单
  4551. --###########################
  4552. CREATE PROCEDURE [dbo].[bpCompany_BlackByCompanyNameSelect]
  4553. (
  4554. @CompanyName VARCHAR(100)
  4555. )
  4556. AS
  4557. BEGIN
  4558. SELECT * FROM Company_Black WITH(NOLOCK)
  4559. WHERE CHARINDEX(lTrim(rTrim(Companyname)), @CompanyName) > 0
  4560. END
  4561. GO
  4562. /****** Object: StoredProcedure [dbo].[bpCompany_BlackByReasonUpdate] Script Date: 2018/12/13 19:03:46 ******/
  4563. SET ANSI_NULLS ON
  4564. GO
  4565. SET QUOTED_IDENTIFIER ON
  4566. GO
  4567. -----------------
  4568. --创建日期:2010-9-14
  4569. --创建人:lambo
  4570. --功能说明:根据编号修改企业黑名单的增加原因
  4571. --用于企业黑名单页面
  4572. -----------------
  4573. CREATE PROCEDURE [dbo].[bpCompany_BlackByReasonUpdate]
  4574. (
  4575. @ID INT,
  4576. @Reason VARCHAR(500)
  4577. )
  4578. AS
  4579. BEGIN TRY
  4580. UPDATE Company_Black SET Reason=@Reason WHERE ID=@ID
  4581. RETURN 1
  4582. END TRY
  4583. BEGIN CATCH
  4584. RETURN 0
  4585. END CATCH
  4586. GO
  4587. /****** Object: StoredProcedure [dbo].[bpCompany_BlackDelete] Script Date: 2018/12/13 19:03:46 ******/
  4588. SET ANSI_NULLS ON
  4589. GO
  4590. SET QUOTED_IDENTIFIER ON
  4591. GO
  4592. -----------------
  4593. --创建日期:2010-9-14
  4594. --创建人:lambo
  4595. --功能说明:根据编号删除一条企业黑名单信息
  4596. --用于企业黑名单页面
  4597. -----------------
  4598. CREATE PROCEDURE [dbo].[bpCompany_BlackDelete]
  4599. (
  4600. @ID INT
  4601. )
  4602. AS
  4603. BEGIN TRY
  4604. DELETE FROM Company_Black WHERE ID=@ID
  4605. RETURN 1
  4606. END TRY
  4607. BEGIN CATCH
  4608. RETURN 0
  4609. END CATCH
  4610. GO
  4611. /****** Object: StoredProcedure [dbo].[bpCompany_BlackInsert] Script Date: 2018/12/13 19:03:46 ******/
  4612. SET ANSI_NULLS ON
  4613. GO
  4614. SET QUOTED_IDENTIFIER ON
  4615. GO
  4616. -----------------
  4617. --创建日期:2010-9-14
  4618. --创建人:lambo
  4619. --功能说明:插入一条企业黑名单信息
  4620. --用于增加企业黑名单页面
  4621. -----------------
  4622. CREATE PROCEDURE [dbo].[bpCompany_BlackInsert]
  4623. (
  4624. @CompanyName VARCHAR(50),
  4625. @ManagerID INT,
  4626. @Email VARCHAR(50),
  4627. @Reason VARCHAR(500),
  4628. @Mobile VARCHAR(11)
  4629. )
  4630. AS
  4631. BEGIN TRY
  4632. INSERT INTO Company_Black
  4633. (
  4634. CompanyName,
  4635. ManagerID,
  4636. Email,
  4637. Reason,
  4638. Mobile
  4639. )
  4640. VALUES
  4641. (
  4642. LTRIM(RTRIM(@CompanyName)),
  4643. @ManagerID,
  4644. LTRIM(RTRIM(@Email)),
  4645. @Reason,
  4646. LTRIM(RTRIM(@Mobile))
  4647. )
  4648. RETURN @@IDENTITY
  4649. END TRY
  4650. BEGIN CATCH
  4651. RETURN 0
  4652. END CATCH
  4653. GO
  4654. /****** Object: StoredProcedure [dbo].[bpCompany_BlackSelect] Script Date: 2018/12/13 19:03:47 ******/
  4655. SET ANSI_NULLS ON
  4656. GO
  4657. SET QUOTED_IDENTIFIER ON
  4658. GO
  4659. -----------------
  4660. --创建日期:2010-9-14
  4661. --创建人:lambo
  4662. --功能说明:根据条件查询企业黑名单记录
  4663. --用于企业黑名单页面
  4664. -----------------
  4665. CREATE PROCEDURE [dbo].[bpCompany_BlackSelect]
  4666. (
  4667. @WHERE VARCHAR(1000)
  4668. )
  4669. AS
  4670. BEGIN
  4671. DECLARE @SQL VARCHAR(2000)
  4672. SET @SQL = 'SELECT * FROM Company_Black WITH(NOLOCK) WHERE 1=1 '
  4673. IF LEN(@WHERE) > 0
  4674. BEGIN
  4675. SET @WHERE = dbo.SafeSql(@Where)
  4676. SET @SQL = @SQL + @WHERE
  4677. END
  4678. SET @SQL=@SQL + ' ORDER BY AddedDate DESC'
  4679. EXEC(@SQL)
  4680. END
  4681. GO
  4682. /****** Object: StoredProcedure [dbo].[bpCompany_DeleteedSelect] Script Date: 2018/12/13 19:03:47 ******/
  4683. SET ANSI_NULLS ON
  4684. GO
  4685. SET QUOTED_IDENTIFIER ON
  4686. GO
  4687. -----------------
  4688. --创建日期:2011-01-28
  4689. --创建人:lambo
  4690. --功能说明:根据查询条件查询已删除的企业的信息
  4691. --用于删除单位记录页面
  4692. -----------------
  4693. CREATE PROCEDURE [dbo].[bpCompany_DeleteedSelect]
  4694. (
  4695. @WHERE VARCHAR(1000)
  4696. )
  4697. AS
  4698. BEGIN
  4699. BEGIN TRY
  4700. DECLARE @SQL AS VARCHAR(2000)
  4701. SET @SQL='SELECT DISTINCT TOP 200 * FROM Company_Deleted a WITH(NOLOCK)'
  4702. IF LEN(@WHERE) > 0
  4703. BEGIN
  4704. SET @WHERE = dbo.SafeSql(@Where)
  4705. SET @SQL = @SQL + @WHERE
  4706. END
  4707. SET @SQL = @SQL + ' ORDER BY AddDate DESC'
  4708. EXEC(@SQL)
  4709. END TRY
  4710. BEGIN CATCH
  4711. END CATCH
  4712. END
  4713. GO
  4714. /****** Object: StoredProcedure [dbo].[bpCompany_xinxiDelete] Script Date: 2018/12/13 19:03:47 ******/
  4715. SET ANSI_NULLS ON
  4716. GO
  4717. SET QUOTED_IDENTIFIER ON
  4718. GO
  4719. -----------------
  4720. --创建日期:2010-9-14
  4721. --创建人:lambo
  4722. --功能说明:根据编号删除一条记录
  4723. --用于后台临时库查询页面
  4724. -----------------
  4725. CREATE PROCEDURE [dbo].[bpCompany_xinxiDelete]
  4726. (
  4727. @ID INT
  4728. )
  4729. AS
  4730. BEGIN TRY
  4731. DELETE FROM Company_xinxi WHERE ID=@ID
  4732. RETURN 1
  4733. END TRY
  4734. BEGIN CATCH
  4735. RETURN 0
  4736. END CATCH
  4737. GO
  4738. /****** Object: StoredProcedure [dbo].[bpCompany_xinxiSelect] Script Date: 2018/12/13 19:03:47 ******/
  4739. SET ANSI_NULLS ON
  4740. GO
  4741. SET QUOTED_IDENTIFIER ON
  4742. GO
  4743. -----------------
  4744. --创建日期:2010-9-14
  4745. --创建人:lambo
  4746. --功能说明:根据条件查询临时单位库的数据
  4747. --用于临时单位库查询页面
  4748. --修改:按照注册时间排序harry
  4749. -----------------
  4750. CREATE PROCEDURE [dbo].[bpCompany_xinxiSelect]
  4751. (
  4752. @count INT,
  4753. @WHERE VARCHAR(1000)
  4754. )
  4755. AS
  4756. BEGIN
  4757. DECLARE @SQL AS VARCHAR(2000)
  4758. SET @SQL='SELECT TOP '+LTRIM(str(@count))+' * FROM company_xinxi '
  4759. IF LEN(@WHERE) > 5
  4760. BEGIN
  4761. SET @WHERE = dbo.SafeSql(@Where)
  4762. SET @SQL = @SQL + ' WHERE ' + RIGHT(@WHERE, LEN(@Where) - 5)
  4763. END
  4764. SET @SQL = @SQL + ' ORDER BY regdate DESC, id DESC'
  4765. EXEC(@SQL)
  4766. END
  4767. GO
  4768. /****** Object: StoredProcedure [dbo].[bpCompany_xinxiUpdate] Script Date: 2018/12/13 19:03:47 ******/
  4769. SET ANSI_NULLS ON
  4770. GO
  4771. SET QUOTED_IDENTIFIER ON
  4772. GO
  4773. -----------------
  4774. --创建日期:2010-9-14
  4775. --创建人:lambo
  4776. --功能说明:根据编号修改单位临时库内的一条记录的邮箱和公司名称
  4777. --用于后台临时库查询页面
  4778. -----------------
  4779. CREATE PROCEDURE [dbo].[bpCompany_xinxiUpdate]
  4780. (
  4781. @ID INT,
  4782. @email VARCHAR(50),
  4783. @companyname VARCHAR(50)
  4784. )
  4785. AS
  4786. BEGIN TRY
  4787. UPDATE Company_xinxi SET email=@email,companyname=@companyname WHERE ID=@ID
  4788. RETURN 1
  4789. END TRY
  4790. BEGIN CATCH
  4791. RETURN 0
  4792. END CATCH
  4793. GO
  4794. /****** Object: StoredProcedure [dbo].[bpCompanyInformAllSelect] Script Date: 2018/12/13 19:03:48 ******/
  4795. SET ANSI_NULLS ON
  4796. GO
  4797. SET QUOTED_IDENTIFIER ON
  4798. GO
  4799. -----------------
  4800. --创建日期:2010-9-14
  4801. --创建人:lambo
  4802. --功能说明:查询所有的单位分类通知
  4803. --用于后台单位分类通知
  4804. -----------------
  4805. CREATE PROCEDURE [dbo].[bpCompanyInformAllSelect]
  4806. AS
  4807. BEGIN
  4808. SELECT a.*,b.SubSiteUrl,b.SubSiteCity FROM CompanyInform a WITH(NOLOCK),dcSubSite b WITH(NOLOCK)
  4809. WHERE b.ID=LEFT(a.Province,2)
  4810. ORDER BY AddDate DESC
  4811. END
  4812. GO
  4813. /****** Object: StoredProcedure [dbo].[bpCompanyInformByStatusUpdate] Script Date: 2018/12/13 19:03:48 ******/
  4814. SET ANSI_NULLS ON
  4815. GO
  4816. SET QUOTED_IDENTIFIER ON
  4817. GO
  4818. -----------------
  4819. --创建日期:2010-9-14
  4820. --创建人:lambo
  4821. --功能说明:修改单位用户分类通知的状态
  4822. --用于单位用户分类通知页面
  4823. -----------------
  4824. CREATE PROCEDURE [dbo].[bpCompanyInformByStatusUpdate]
  4825. @ID INT
  4826. AS
  4827. BEGIN TRY
  4828. UPDATE CompanyInform SET Status=Status-1 WHERE ID=@ID
  4829. RETURN 1
  4830. END TRY
  4831. BEGIN CATCH
  4832. RETURN 0
  4833. END CATCH
  4834. GO
  4835. /****** Object: StoredProcedure [dbo].[bpCompanyInformDelete] Script Date: 2018/12/13 19:03:48 ******/
  4836. SET ANSI_NULLS ON
  4837. GO
  4838. SET QUOTED_IDENTIFIER ON
  4839. GO
  4840. -----------------
  4841. --创建日期:2010-9-14
  4842. --创建人:lambo
  4843. --功能说明:删除一条单位分类通知
  4844. --用于后台单位分类通知
  4845. -----------------
  4846. CREATE PROCEDURE [dbo].[bpCompanyInformDelete]
  4847. @ID INT
  4848. AS
  4849. BEGIN TRY
  4850. DELETE FROM CompanyInform WHERE ID=@ID
  4851. END TRY
  4852. BEGIN CATCH
  4853. GOTO ERR
  4854. END CATCH
  4855. RETURN 1
  4856. ERR:
  4857. BEGIN
  4858. RETURN 0
  4859. END
  4860. GO
  4861. /****** Object: StoredProcedure [dbo].[bpCompanyInformSave] Script Date: 2018/12/13 19:03:48 ******/
  4862. SET ANSI_NULLS ON
  4863. GO
  4864. SET QUOTED_IDENTIFIER ON
  4865. GO
  4866. -----------------
  4867. --创建日期:2010-9-14
  4868. --创建人:lambo
  4869. --功能说明:增加或修改单位分类通知,如果@ID>0则是修改,否则是增加
  4870. --用于后台增加或修改单位分类通知
  4871. --修改:harry2016-8-17 修改content长度
  4872. -----------------
  4873. CREATE PROCEDURE [dbo].[bpCompanyInformSave]
  4874. (
  4875. @ID INT,
  4876. @Object VARCHAR(50),
  4877. @Title VARCHAR(50),
  4878. @Content VARCHAR(MAX),
  4879. @Type INT,
  4880. @Link VARCHAR(100),
  4881. @Province VARCHAR(100),
  4882. @EndDate VARCHAR(20)
  4883. )
  4884. AS
  4885. BEGIN TRAN
  4886. Declare @MaxId AS INT
  4887. BEGIN TRY
  4888. IF @ID>0
  4889. BEGIN
  4890. UPDATE CompanyInform SET
  4891. Object = @Object,
  4892. Title = @Title,
  4893. Content = @Content,
  4894. Type = @Type,
  4895. AddDate = GETDATE(),
  4896. Link = @Link,
  4897. Province = @Province,
  4898. EndDate = @EndDate
  4899. WHERE ID=@ID
  4900. SET @MaxID = @ID
  4901. End
  4902. ELSE
  4903. BEGIN
  4904. INSERT INTO CompanyInform
  4905. (
  4906. Object,Title,Content,Type,
  4907. Province,EndDate,Link
  4908. )
  4909. VALUES
  4910. (
  4911. @Object,@Title,@Content,@Type,
  4912. @Province,@EndDate,@Link
  4913. )
  4914. SET @MaxID = @@IDENTITY
  4915. END
  4916. END TRY
  4917. BEGIN CATCH
  4918. GOTO ERR
  4919. END CATCH
  4920. COMMIT TRAN
  4921. RETURN @MaxID
  4922. ERR:
  4923. BEGIN
  4924. ROLLBACK TRAN
  4925. RETURN 0
  4926. END
  4927. GO
  4928. /****** Object: StoredProcedure [dbo].[bpCompanyInformSelect] Script Date: 2018/12/13 19:03:48 ******/
  4929. SET ANSI_NULLS ON
  4930. GO
  4931. SET QUOTED_IDENTIFIER ON
  4932. GO
  4933. -----------------
  4934. --创建日期:2010-9-14
  4935. --创建人:lambo
  4936. --功能说明:根据编号查询一条单位分类通知
  4937. --用于后台单位分类通知
  4938. -----------------
  4939. CREATE PROCEDURE [dbo].[bpCompanyInformSelect]
  4940. (
  4941. @ID INT
  4942. )
  4943. AS
  4944. BEGIN
  4945. SELECT * FROM CompanyInform WHERE ID = @ID
  4946. END
  4947. GO
  4948. /****** Object: StoredProcedure [dbo].[bpCompanyNotifyDelete] Script Date: 2018/12/13 19:03:48 ******/
  4949. SET ANSI_NULLS ON
  4950. GO
  4951. SET QUOTED_IDENTIFIER ON
  4952. GO
  4953. -----------------
  4954. --创建日期:2010-9-14
  4955. --创建人:lambo
  4956. --功能说明:根据编号删除一条网站消息
  4957. --用于后台单位用户管理网站消息页面
  4958. -----------------
  4959. CREATE PROCEDURE [dbo].[bpCompanyNotifyDelete]
  4960. (
  4961. @ID INT
  4962. )
  4963. AS
  4964. BEGIN TRY
  4965. DELETE FROM CompanyNotify WHERE ID = @ID
  4966. END TRY
  4967. BEGIN CATCH
  4968. RETURN 0
  4969. END CATCH
  4970. RETURN 1
  4971. GO
  4972. /****** Object: StoredProcedure [dbo].[bpCompanyNotifyInsert] Script Date: 2018/12/13 19:03:49 ******/
  4973. SET ANSI_NULLS ON
  4974. GO
  4975. SET QUOTED_IDENTIFIER ON
  4976. GO
  4977. -----------------
  4978. --创建日期:2010-9-14
  4979. --创建人:lambo
  4980. --功能说明:增加一条网站消息
  4981. --用于后台单位用户管理网站消息页面
  4982. -----------------
  4983. CREATE PROCEDURE [dbo].[bpCompanyNotifyInsert]
  4984. (
  4985. @CompanyId INT,
  4986. @Type SMALLINT,
  4987. @Content NVARCHAR(600),
  4988. @EndDate VARCHAR(20),
  4989. @ManagerUserID INT,
  4990. @CompanyName VARCHAR(60)
  4991. )
  4992. AS
  4993. BEGIN TRY
  4994. If @Type = 1
  4995. Set @EndDate = NULL
  4996. INSERT INTO CompanyNotify (CompanyId,[type],[Content],EndDate,ManagerUserID,CompanyName)
  4997. VALUES(@CompanyId,@Type,@Content,@EndDate,@ManagerUserID,@CompanyName)
  4998. END TRY
  4999. BEGIN CATCH
  5000. RETURN 0
  5001. END CATCH
  5002. RETURN 1
  5003. GO
  5004. /****** Object: StoredProcedure [dbo].[bpCompanyNotifySelect] Script Date: 2018/12/13 19:03:49 ******/
  5005. SET ANSI_NULLS ON
  5006. GO
  5007. SET QUOTED_IDENTIFIER ON
  5008. GO
  5009. CREATE PROCEDURE [dbo].[bpCompanyNotifySelect]
  5010. (
  5011. @WHERE VARCHAR(1000)
  5012. )
  5013. AS
  5014. BEGIN
  5015. DECLARE @SQL AS VARCHAR(2000)
  5016. SET @SQL='SELECT TOP 300 a.AddDate NotifyAddDate,* FROM CompanyNotify a WITH(NOLOCK) LEFT JOIN Maindb..Manageruser b ON a.ManageruserID=b.ID WHERE 1=1 '
  5017. IF LEN(@WHERE) > 0
  5018. BEGIN
  5019. SET @WHERE = dbo.SafeSql(@Where)
  5020. SET @SQL = @SQL + @WHERE
  5021. END
  5022. SET @SQL = @SQL + ' ORDER BY a.AddDate DESC'
  5023. EXEC(@SQL)
  5024. END
  5025. GO
  5026. /****** Object: StoredProcedure [dbo].[bpConsultantByRepeatSelect] Script Date: 2018/12/13 19:03:49 ******/
  5027. SET ANSI_NULLS ON
  5028. GO
  5029. SET QUOTED_IDENTIFIER ON
  5030. GO
  5031. --[bpConsultantListSelect] 'And username like ''%aoli%''',12,1
  5032. CREATE PROCEDURE [dbo].[bpConsultantByRepeatSelect]
  5033. (
  5034. @Where VARCHAR(2000),
  5035. @Page SMALLINT
  5036. )
  5037. AS
  5038. BEGIN
  5039. BEGIN TRY
  5040. SET @WHERE = dbo.SafeSQLBack(@WHERE)
  5041. DECLARE @SQL AS VARCHAR(2000)
  5042. DECLARE @strOrder AS VARCHAR(1000)
  5043. SET @strOrder = ' ORDER BY RegDate DESC'
  5044. CREATE TABLE #T(
  5045. TitleID BIGINT,
  5046. ID INT,
  5047. Name NVARCHAR(50),
  5048. HasLicence BIT,
  5049. ziliaodate SMALLDATETIME,
  5050. Quality TINYINT,
  5051. ConsultantID SMALLINT,
  5052. RegDate SMALLDATETIME,
  5053. dcProvinceID TINYINT,
  5054. MemberType TINYINT,
  5055. VerifyResult TINYINT,
  5056. IsAgent BIT,
  5057. LastLoginDate SMALLDATETIME,
  5058. UnlimitedDate SMALLDATETIME,
  5059. Balance SMALLINT,
  5060. BalanceDate SMALLDATETIME,
  5061. IsLimitLogin TINYINT,
  5062. RefreshDate SMALLDATETIME,
  5063. ConsultantDate SMALLDATETIME,
  5064. IsLock BIT,
  5065. ResumeQuota SMALLINT,
  5066. IsDelete BIT,
  5067. JobNumber SMALLINT,
  5068. VerifyMan SMALLINT,
  5069. HasPaid BIT,
  5070. ContactDoneDate SMALLDATETIME,
  5071. ContactDoneMan SMALLINT,
  5072. ContactDoneAdd SMALLDATETIME,
  5073. ContactDoneID INT,
  5074. ContactNotDoneDate SMALLDATETIME,
  5075. ContactNotDoneMan SMALLINT,
  5076. ContactNotDoneAdd SMALLDATETIME,
  5077. ContactNotDoneID INT,
  5078. DownLoadToday SMALLINT,
  5079. JobViewNumber SMALLINT,
  5080. SendResumeNumber SMALLINT,
  5081. SendResumeNumberHigh SMALLINT
  5082. )
  5083. SET @SQL='
  5084. INSERT INTO #T
  5085. (TitleID,ID,Name,HasLicence,Quality,ConsultantID,RegDate,dcProvinceID,MemberType,VerifyResult,
  5086. IsAgent,LastLoginDate,UnlimitedDate,Balance,BalanceDate,IsLimitLogin,RefreshDate,ConsultantDate,IsLock,
  5087. ResumeQuota,IsDelete,JobNumber)
  5088. SELECT ROW_NUMBER() OVER ( ORDER BY b.id DESC, a.ID DESC) AS TitleID,a.ID,a.Name,HasLicence,Quality,
  5089. ConsultantID,a.RegDate,dcProvinceID,MemberType,VerifyResult,IsAgent,LastLoginDate,UnlimitedDate,Balance,
  5090. BalanceDate,IsLimitLogin,RefreshDate,ConsultantDate,IsLock,ResumeQuota,a.IsDelete,JobNumber
  5091. FROM cpMain a WITH(NOLOCK)
  5092. INNER JOIN (SELECT TOP 500 Name, Max(ID) ID FROM cpMain WITH(NOLOCK)
  5093. WHERE name <> ''某公司'' ' + @Where + '
  5094. GROUP BY Name HAVING COUNT(*) > 1
  5095. ORDER BY Max(ID) DESC) b ON a.Name = b.Name
  5096. ORDER BY b.ID DESC'
  5097. EXEC(@SQL)
  5098. UPDATE #T SET ziliaodate = (SELECT TOP 1 CheckDate FROM cpLicence Where cpMainID=#T.ID ORDER BY ID DESC),
  5099. VerifyMan = (Select TOP 1 VerifyMan From bsCpVerify Where bsCpVerify.cpMainID=#T.ID ORDER BY ID DESC),
  5100. HasPaid = (SELECT TOP 1 ID FROM caOrder WHERE Paid>0 AND OpenDate IS NOT NULL AND cpMainID=#T.ID),
  5101. ContactDoneDate = (SELECT top 1 BeginTime FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=2 ORDER BY begintime DESC),
  5102. ContactDoneMan = (SELECT top 1 ManagerUserID FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=2 ORDER BY begintime DESC),
  5103. ContactDoneAdd = (SELECT top 1 AddDate FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=2 ORDER BY begintime DESC),
  5104. ContactDoneID = (SELECT top 1 ID FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=2 ORDER BY begintime DESC),
  5105. ContactNotDoneDate = (SELECT top 1 BeginTime FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=1 ORDER BY begintime DESC),
  5106. ContactNotDoneMan = (SELECT top 1 ManagerUserID FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=1 ORDER BY begintime DESC),
  5107. ContactNotDoneAdd = (SELECT top 1 AddDate FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=1 ORDER BY begintime DESC),
  5108. ContactNotDoneID = (SELECT top 1 ID FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=1 ORDER BY begintime DESC),
  5109. DownLoadToday = (SELECT COUNT(ID) cnt FROM caActiveLog WHERE CONVERT(VARCHAR(10),AddDate,112)=CONVERT(VARCHAR(10),GETDATE(),112) AND cpMainID=#T.ID),
  5110. JobViewNumber = (select COUNT(1) cnt from paJobViewLog a with(nolock),Job b with(nolock) where b.cpMainID=#T.ID and a.JobID=b.ID and b.valid=1 and a.Adddate>getdate()-30)
  5111. WHERE TitleID > (@Page - 1) * 20 AND TitleID <= @Page * 20
  5112. UPDATE a SET SendResumeNumber = AllNumber,
  5113. SendResumeNumberHigh = NotOpenNumber FROM #T a
  5114. INNER JOIN qryJobApplyMonth b ON a.ID=b.cpMainID
  5115. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5116. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  5117. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5118. DROP TABLE #T
  5119. END TRY
  5120. BEGIN CATCH
  5121. DROP TABLE #T
  5122. END CATCH
  5123. END
  5124. GO
  5125. /****** Object: StoredProcedure [dbo].[bpConsultantListSelect] Script Date: 2018/12/13 19:03:49 ******/
  5126. SET ANSI_NULLS ON
  5127. GO
  5128. SET QUOTED_IDENTIFIER ON
  5129. GO
  5130. CREATE PROCEDURE [dbo].[bpConsultantListSelect]
  5131. (
  5132. @WHERE VARCHAR(1000),
  5133. @ORDER TINYINT,
  5134. @Page SMALLINT
  5135. )
  5136. AS
  5137. SET NOCOUNT ON
  5138. BEGIN
  5139. SET @WHERE = dbo.SafeSQLBack(@WHERE)
  5140. DECLARE @SQL AS VARCHAR(2000)
  5141. DECLARE @strOrder AS VARCHAR(1000)
  5142. SET @strOrder = ''
  5143. IF @ORDER = 1
  5144. SET @strOrder = @strOrder + ' ORDER BY ConsultantDate DESC'
  5145. ELSE IF @ORDER = 2
  5146. SET @strOrder = @strOrder + ' ORDER BY LastLoginDate DESC'
  5147. ELSE IF @ORDER = 3
  5148. SET @strOrder = @strOrder + ' ORDER BY (SELECT TOP 1 CerDate FROM MainDB..cpCertification WITH(NOLOCK) WHERE cpMainID = a.ID ORDER BY CerDate DESC) DESC'
  5149. ELSE IF @ORDER = 4
  5150. SET @strOrder = @strOrder + ' ORDER BY RegDate DESC'
  5151. ELSE IF @ORDER = 5
  5152. SET @strOrder = @strOrder + ' ORDER BY JobNumber DESC'
  5153. ELSE IF @ORDER = 6
  5154. SET @strOrder = @strOrder + ' ORDER BY (SELECT COUNT(1) FROM CaCvQuotaLog WITH(NOLOCK) WHERE cpMainID = a.ID) DESC'
  5155. ELSE IF @ORDER = 12
  5156. SET @strOrder = @strOrder + ' ORDER BY (SELECT COUNT(1) FROM CaActiveLog WITH(NOLOCK) WHERE cpMainID = a.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 23)) DESC, LastLoginDate DESC'
  5157. ELSE IF @ORDER = 7
  5158. SET @strOrder = @strOrder + ' ORDER BY (SELECT TOP 1 AddDate FROM bsCpStatus WITH(NOLOCK) WHERE cpMainID = a.ID AND statusID=9 ORDER BY AddDate DESC) DESC'
  5159. ELSE IF @ORDER = 8
  5160. SET @strOrder = @strOrder + ' ORDER BY (Select TOP 1 VerifyDate From bsCpVerify Where cpMainID=a.ID) DESC'
  5161. ELSE IF @ORDER = 9
  5162. SET @strOrder = @strOrder + ' ORDER BY (SELECT TOP 1 begintime FROM contact WITH(NOLOCK) WHERE status=2 AND companyid=a.ID ORDER BY begintime DESC) DESC'
  5163. ELSE IF @ORDER = 10
  5164. SET @strOrder = @strOrder + ' ORDER BY (SELECT TOP 1 begintime FROM contact WITH(NOLOCK) WHERE status=2 AND companyid=a.ID ORDER BY begintime DESC)'
  5165. ELSE IF @ORDER = 14
  5166. SET @strOrder = @strOrder + ' ORDER BY (SELECT TOP 1 EndDate FROM caOrder WITH(NOLOCK) WHERE OrderType=8 AND BeginDate<GetDate() AND EndDate>GETDATE() AND cpMainId = a.Id AND IsDeleted = 0)'
  5167. ELSE IF @ORDER = 15
  5168. SET @strOrder = @strOrder + ' ORDER BY BalanceDate'
  5169. ELSE IF @ORDER = 13
  5170. SET @strOrder = @strOrder + ' ORDER BY Balance'
  5171. ELSE IF @ORDER = 17
  5172. SET @strOrder = @strOrder + ' ORDER BY d.Id DESC'
  5173. Else IF @ORDER = 0
  5174. SET @strOrder = @strOrder + ' ORDER BY LastLoginDate DESC'
  5175. ELSE IF @ORDER = 19
  5176. SET @strOrder = @strOrder + ' ORDER BY (SELECT TOP 1 EndDate FROM caOrder WITH(NOLOCK) WHERE OrderType=8 AND BeginDate<GetDate() AND EndDate>GETDATE() AND cpMainId = a.Id AND IsDeleted = 0) DESC'
  5177. ELSE IF @ORDER = 20
  5178. SET @strOrder = @strOrder + ' ORDER BY BalanceDate DESC'
  5179. Else IF @ORDER = 16
  5180. SET @strOrder = @strOrder + ' ORDER BY MemberDate'
  5181. Else IF @ORDER = 21
  5182. SET @strOrder = @strOrder + ' ORDER BY MemberDate DESC'
  5183. Else IF @ORDER = 22
  5184. SET @strOrder = @strOrder + ' order by (select top 1 checkdate from cpimage WITH(NOLOCK) where cpmainid=a.id and imgtype=1 and HasPassed=1 ORDER BY checkdate DESC) desc'
  5185. Else IF @ORDER = 23
  5186. SET @strOrder = @strOrder + ' ORDER BY (SELECT TOP 1 OpenDate FROM caOrder WITH(NOLOCK) WHERE OrderType=8 AND BeginDate<GetDate() AND EndDate>GETDATE() AND cpMainId = a.Id AND IsDeleted = 0) DESC'
  5187. CREATE TABLE #T(
  5188. TitleID BIGINT,
  5189. ID INT,
  5190. Name VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  5191. HasLicence BIT,
  5192. ziliaodate SMALLDATETIME,
  5193. Quality TINYINT,
  5194. ConsultantID SMALLINT,
  5195. RegDate SMALLDATETIME,
  5196. dcProvinceID TINYINT,
  5197. MemberType TINYINT,
  5198. VerifyResult TINYINT,
  5199. IsAgent BIT,
  5200. LastLoginDate SMALLDATETIME,
  5201. UnlimitedDate SMALLDATETIME,
  5202. Balance SMALLINT,
  5203. BalanceDate SMALLDATETIME,
  5204. IsLimitLogin TINYINT,
  5205. RefreshDate SMALLDATETIME,
  5206. ConsultantDate SMALLDATETIME,
  5207. IsLock BIT,
  5208. ResumeQuota SMALLINT,
  5209. IsDelete BIT,
  5210. JobNumber SMALLINT,
  5211. VerifyMan SMALLINT,
  5212. HasPaid BIT,
  5213. ContactDoneDate SMALLDATETIME,
  5214. ContactDoneMan SMALLINT,
  5215. ContactDoneAdd SMALLDATETIME,
  5216. ContactDoneID INT,
  5217. ContactNotDoneDate SMALLDATETIME,
  5218. ContactNotDoneMan SMALLINT,
  5219. ContactNotDoneAdd SMALLDATETIME,
  5220. ContactNotDoneID INT,
  5221. DownLoadToday SMALLINT,
  5222. JobViewNumber SMALLINT,
  5223. SendResumeNumber SMALLINT,
  5224. SendResumeNumberHigh SMALLINT,
  5225. memberdate smalldatetime,
  5226. RealName TINYINT,
  5227. HasLogo BIT,
  5228. CerMemberType TINYINT,
  5229. CerType TINYINT,
  5230. CerDate SMALLDATETIME,
  5231. )
  5232. SET @SQL='
  5233. INSERT INTO #T
  5234. (TitleID,ID,Name,HasLicence,Quality,ConsultantID,RegDate,dcProvinceID,MemberType,VerifyResult,
  5235. IsAgent,LastLoginDate,UnlimitedDate,Balance,BalanceDate,IsLimitLogin,RefreshDate,ConsultantDate,IsLock,
  5236. ResumeQuota,IsDelete,JobNumber,memberdate,RealName,HasLogo)
  5237. SELECT TOP 4000 ROW_NUMBER() OVER (' + @strOrder + ') AS TitleID,a.ID,a.Name,HasLicence,Quality,
  5238. ConsultantID,a.RegDate,dcProvinceID,a.MemberType,VerifyResult,IsAgent,LastLoginDate,UnlimitedDate,Balance,
  5239. BalanceDate,IsLimitLogin,RefreshDate,ConsultantDate,IsLock,ResumeQuota,a.IsDelete,JobNumber,
  5240. memberdate,a.RealName,a.HasLogo
  5241. FROM cpMain a WITH(NOLOCK)'
  5242. IF @Order = 17
  5243. SET @SQL = @SQL + ' INNER JOIN (SELECT b.cpMainId, MAX(a.Id) Id
  5244. FROM caFeePageViewLog a, caMain b
  5245. WHERE a.caMainId = b.Id
  5246. GROUP BY b.cpMainId
  5247. ) d ON a.ID=d.cpMainID '
  5248. SET @SQL = @SQL + ' WHERE 1=1 '
  5249. IF LEN(@WHERE) > 0
  5250. SET @SQL = @SQL + @WHERE
  5251. --print @SQL
  5252. EXEC(@SQL)
  5253. UPDATE #T SET ziliaodate = (SELECT Top 1 CheckDate FROM cpLicence Where cpMainID=#T.ID ORDER BY ID DESC),
  5254. VerifyMan = (Select TOP 1 VerifyMan From bsCpVerify Where bsCpVerify.cpMainID=#T.ID ORDER BY ID DESC),
  5255. HasPaid = (SELECT TOP 1 ID FROM caOrder WHERE Paid>0 AND OpenDate IS NOT NULL AND cpMainID=#T.ID AND IsDeleted = 0),
  5256. ContactDoneDate = (SELECT top 1 BeginTime FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=2 ORDER BY begintime DESC),
  5257. ContactDoneMan = (SELECT top 1 ManagerUserID FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=2 ORDER BY begintime DESC),
  5258. ContactDoneAdd = (SELECT top 1 AddDate FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=2 ORDER BY begintime DESC),
  5259. ContactDoneID = (SELECT top 1 ID FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=2 ORDER BY begintime DESC),
  5260. ContactNotDoneDate = (SELECT top 1 BeginTime FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=1 ORDER BY begintime DESC),
  5261. ContactNotDoneMan = (SELECT top 1 ManagerUserID FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=1 ORDER BY begintime DESC),
  5262. ContactNotDoneAdd = (SELECT top 1 AddDate FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=1 ORDER BY begintime DESC),
  5263. ContactNotDoneID = (SELECT top 1 ID FROM contact WITH(NOLOCK) WHERE companyid=#T.ID AND status=1 ORDER BY begintime DESC),
  5264. DownLoadToday = (SELECT COUNT(ID) cnt FROM caActiveLog WHERE CONVERT(VARCHAR(10),AddDate,112)=CONVERT(VARCHAR(10),GETDATE(),112) AND cpMainID=#T.ID),
  5265. JobViewNumber = (select COUNT(1) cnt from paJobViewLog a with(nolock),Job b with(nolock) where b.cpMainID=#T.ID and a.JobID=b.ID and b.valid=1 and a.Adddate>getdate()-30),
  5266. CerMemberType = (SELECT TOP 1 MemberType FROM cpCertification WITH(NOLOCK) WHERE cpMainID = #T.ID AND CerStatus = 1 ORDER BY CerDate DESC),
  5267. CerType = (SELECT TOP 1 CerType FROM cpCertification WITH(NOLOCK) WHERE cpMainID = #T.ID AND CerStatus = 1 ORDER BY CerDate DESC),
  5268. CerDate = (SELECT TOP 1 CerDate FROM cpCertification WITH(NOLOCK) WHERE cpMainID = #T.ID AND CerStatus = 1 ORDER BY CerDate DESC)
  5269. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5270. UPDATE #T SET ContactDoneMan = (SELECT top 1 a.AddMan FROM ColdContact a,Coldcustomer b WITH(NOLOCK) WHERE b.id=a.CustomerID AND b.CpMainID=#T.ID AND isnull(a.beginTime,'')!='' ORDER BY a.BeginTime DESC),
  5271. ContactDoneDate= (SELECT top 1 a.AddDate FROM ColdContact a,Coldcustomer b WITH(NOLOCK) WHERE b.id=a.CustomerID AND b.CpMainID=#T.ID AND isnull(a.beginTime,'')!='' ORDER BY a.BeginTime DESC),
  5272. ContactDoneAdd = (SELECT top 1 a.AddDate FROM ColdContact a,Coldcustomer b WITH(NOLOCK) WHERE b.id=a.CustomerID AND b.CpMainID=#T.ID AND isnull(a.beginTime,'')!='' ORDER BY a.BeginTime DESC)
  5273. WHERE ISNULL(ContactDoneDate ,'')='' and TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5274. UPDATE #T SET ContactNotDoneMan = (SELECT top 1 a.AddMan FROM ColdContact a,Coldcustomer b WITH(NOLOCK) WHERE b.id=a.CustomerID AND b.CpMainID=#T.ID AND isnull(a.beginTime,'')='' ORDER BY a.AddDate DESC),
  5275. ContactNotDoneDate = (SELECT top 1 a.AddDate FROM ColdContact a,Coldcustomer b WITH(NOLOCK) WHERE b.id=a.CustomerID AND b.CpMainID=#T.ID AND isnull(a.beginTime,'')='' ORDER BY a.AddDate DESC) ,
  5276. ContactNotDoneAdd = (SELECT top 1 a.AddDate FROM ColdContact a,Coldcustomer b WITH(NOLOCK) WHERE b.id=a.CustomerID AND b.CpMainID=#T.ID AND isnull(a.beginTime,'')='' ORDER BY a.AddDate DESC)
  5277. WHERE ISNULL(ContactNotDoneDate ,'')='' and TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5278. UPDATE a SET SendResumeNumber = AllNumber,
  5279. SendResumeNumberHigh = NotOpenNumber FROM #T a
  5280. INNER JOIN qryJobApplyMonth b ON a.ID=b.cpMainID
  5281. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5282. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  5283. SELECT a.*, b.MemberType UnFinishedMemberType, b.CerType UnFinishedCerType, c.HasPassed, d.CheckResult PersonalCheckResult, e.CheckResult CompanyEmailCheckResult
  5284. FROM #T a WITH(NOLOCK)
  5285. LEFT JOIN cpCertification b WITH(NOLOCK) ON a.ID = b.cpMainID AND b.CerStatus IS NULL
  5286. LEFT JOIN cpLicence c WITH(NOLOCK) ON b.ID = c.cpCertificationID
  5287. LEFT JOIN cpPersonalAccount d WITH(NOLOCK) ON b.ID = d.cpCertificationID
  5288. LEFT JOIN cpCompanyEmail e WITH(NOLOCK) ON b.ID = e.cpCertificationID
  5289. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5290. DROP TABLE #T
  5291. END
  5292. GO
  5293. /****** Object: StoredProcedure [dbo].[bpcontactByCompanyIdSelect] Script Date: 2018/12/13 19:03:50 ******/
  5294. SET ANSI_NULLS ON
  5295. GO
  5296. SET QUOTED_IDENTIFIER ON
  5297. GO
  5298. --查询企业联系记录-------------------
  5299. --添加人Harry -----------------------
  5300. --添加时间:2014-12-16---------------
  5301. CREATE PROCEDURE [dbo].[bpcontactByCompanyIdSelect]
  5302. (
  5303. @CompanyId VARCHAR(20)
  5304. )
  5305. AS
  5306. BEGIN
  5307. SELECT TOP 1 Id, Title, Status, Quality, AddDate
  5308. FROM Contact WITH(NOLOCK INDEX(IX_Contact_CompanyId))
  5309. WHERE CompanyId = @CompanyId
  5310. ORDER BY ID DESC
  5311. END
  5312. GO
  5313. /****** Object: StoredProcedure [dbo].[bpContactByCountSelect] Script Date: 2018/12/13 19:03:50 ******/
  5314. SET ANSI_NULLS ON
  5315. GO
  5316. SET QUOTED_IDENTIFIER ON
  5317. GO
  5318. --创建人 Andy
  5319. --时间 2015-01-12
  5320. --按照条件查询后台联系活动的个数
  5321. CREATE PROCEDURE [dbo].[bpContactByCountSelect]
  5322. (
  5323. @ManagerUserID INT,
  5324. @Status INT,
  5325. @BeginTime DATETIME
  5326. )
  5327. AS
  5328. BEGIN
  5329. SELECT COUNT(1) cnt
  5330. FROM Contact WITH(NOLOCK)
  5331. WHERE ManagerUserID = @ManagerUserID
  5332. AND Status = @Status
  5333. AND BeginTime > @BeginTime
  5334. AND BeginTime < @BeginTime + 1
  5335. END
  5336. GO
  5337. /****** Object: StoredProcedure [dbo].[bpContactByCpMainIDSelect] Script Date: 2018/12/13 19:03:50 ******/
  5338. SET ANSI_NULLS ON
  5339. GO
  5340. SET QUOTED_IDENTIFIER ON
  5341. GO
  5342. --2018-1-25 peter
  5343. CREATE PROCEDURE [dbo].[bpContactByCpMainIDSelect]
  5344. (
  5345. @companyType INT,
  5346. @companyid INT
  5347. )
  5348. AS
  5349. SET NOCOUNT ON
  5350. BEGIN
  5351. IF NOT EXISTS(SELECT 'x' FROM coldcontact WHERE CustomerId IN(SELECT Id FROM ColdCustomer WHERE cpMainId = @companyid))
  5352. SELECT TOP 10 * FROM contact WITH(NOLOCK)
  5353. WHERE companyType = @companyType
  5354. AND companyID = @companyid
  5355. ORDER BY addDate DESC
  5356. ELSE
  5357. SELECT TOP 10 *
  5358. FROM (
  5359. SELECT *
  5360. FROM Contact WITH(NOLOCK)
  5361. WHERE companyID = @companyid
  5362. UNION
  5363. SELECT Id, Title, @CompanyId CompanyId, '冷客户:' + Description Description,
  5364. BeginTime, 2 Status, AddDate, AddMan Manageruserid, AddMan Creator,
  5365. NULL Quality, NULL CloseDate, 1 CompanyType, LinkMan, TelePhone, NULL Label
  5366. FROM coldcontact
  5367. WHERE CustomerId IN(SELECT Id FROM ColdCustomer WHERE cpMainId = @CompanyId)
  5368. ) a
  5369. ORDER BY addDate DESC
  5370. END
  5371. GO
  5372. /****** Object: StoredProcedure [dbo].[bpContactByStatisticSelect] Script Date: 2018/12/13 19:03:50 ******/
  5373. SET ANSI_NULLS ON
  5374. GO
  5375. SET QUOTED_IDENTIFIER ON
  5376. GO
  5377. --创建人 Andy
  5378. --时间 2015-01-08
  5379. --按照条件统计后台客户联系活动
  5380. CREATE PROCEDURE [dbo].[bpContactByStatisticSelect]
  5381. (
  5382. @StartTime DATETIME,
  5383. @EndTime DATETIME,
  5384. @CurManagerUserID INT,--当前登录用户ID
  5385. @Privi INT--当前用户的权限
  5386. )
  5387. AS
  5388. BEGIN
  5389. DECLARE @t AS TABLE(ManagerUserID int, Status INT, Cnt INT)
  5390. INSERT INTO @t
  5391. SELECT a.ManagerUserID, a.Status, COUNT(*) Cnt
  5392. FROM Contact a WITH(NOLOCK)
  5393. WHERE a.CompanyId > 0
  5394. AND a.BeginTime >= @StartTime
  5395. AND a.BeginTime <= @EndTime
  5396. AND a.ManagerUserID IN (SELECT ID FROM dbo.LowerUser(@CurManagerUserID, @Privi))
  5397. GROUP BY a.ManagerUserID, a.Status
  5398. SELECT DISTINCT ManagerUserID,
  5399. ISNULL((SELECT Cnt FROM @t WHERE ManagerUserID = a.ManagerUserID AND status = 2), 0) AS Finished,
  5400. ISNULL((SELECT Cnt FROM @t WHERE ManagerUserID =a .ManagerUserID AND status = 1), 0) AS NotFinished
  5401. FROM @t a
  5402. ORDER BY a.ManagerUserID
  5403. END
  5404. GO
  5405. /****** Object: StoredProcedure [dbo].[bpContactInsert] Script Date: 2018/12/13 19:03:50 ******/
  5406. SET ANSI_NULLS ON
  5407. GO
  5408. SET QUOTED_IDENTIFIER ON
  5409. GO
  5410. --创建人 Andy
  5411. --时间 2015-01-09
  5412. --插入一条后台沟通记录
  5413. --@CompanyID,0表示没有companyID
  5414. --修改:删除参数CloseDate,根据Status来判断CloseDate
  5415. CREATE PROCEDURE [dbo].[bpContactInsert]
  5416. (
  5417. @Title NVARCHAR(50),
  5418. @CompanyID INT,
  5419. @Description NVARCHAR(400),
  5420. @Begintime DATETIME,
  5421. @Status INT,
  5422. @ManagerUserId INT,
  5423. @Creator INT,
  5424. @Quality INT,
  5425. @CompanyType INT,
  5426. @LinkMan INT,
  5427. @Telephone nvarchar(50)
  5428. )
  5429. AS
  5430. BEGIN
  5431. INSERT INTO Contact(Title, Companyid, Description, BeginTime, Status, ManagerUserId, Creator, Quality, CloseDate, LinkMan, Telephone)
  5432. VALUES (@Title, (CASE WHEN @Companyid = 0 THEN NULL ELSE @Companyid END), @Description, @BeginTime, @Status, @ManagerUserId, @Creator, @Quality, (CASE WHEN @Status = 2 THEN GETDATE() ELSE NULL END), @LinkMan, @Telephone)
  5433. RETURN 1
  5434. END
  5435. GO
  5436. /****** Object: StoredProcedure [dbo].[bpContactSelect] Script Date: 2018/12/13 19:03:50 ******/
  5437. SET ANSI_NULLS ON
  5438. GO
  5439. SET QUOTED_IDENTIFIER ON
  5440. GO
  5441. --创建人 Andy
  5442. --时间 2015-01-08
  5443. --按照条件查询后台客户联系活动
  5444. create PROCEDURE [dbo].[bpContactSelect]
  5445. (
  5446. @StartTime DATETIME,
  5447. @EndTime DATETIME,
  5448. @ManagerUserID INT,
  5449. @CompanyID INT,
  5450. @Status INT,--完成状态,1:未完成, 2完成
  5451. @CurManagerUserID INT,--当前登录用户ID
  5452. @Privi INT--当前用户的权限
  5453. )
  5454. AS
  5455. BEGIN
  5456. DECLARE @SQL VARCHAR(1000)
  5457. SET @SQL = '
  5458. SELECT a.*, b.Name, c.Name CompanyName
  5459. FROM Contact a WITH(NOLOCK), ManagerUser b WITH(NOLOCK), cpMain c WITH(NOLOCK)
  5460. WHERE a.CompanyId = c.ID AND a.ManagerUserId = b.Id
  5461. AND a.BeginTime >= ''' + CONVERT(VARCHAR(20),@StartTime, 20) + '''
  5462. AND a.BeginTime <= ''' + CONVERT(VARCHAR(20),@EndTime, 20) + ''''
  5463. IF @ManagerUserID > 0
  5464. SET @SQL = @SQL + ' AND a.ManagerUserId = ' + LTRIM(STR(@ManagerUserID))
  5465. IF @CompanyID > 0
  5466. SET @SQL = @SQL + ' AND companyid = ' + LTRIM(STR(@CompanyID))
  5467. IF @Status = 1
  5468. SET @SQL = @SQL + ' AND a.Status = 1 '
  5469. ELSE IF @Status = 2
  5470. SET @SQL = @SQL + ' AND a.Status = 2 '
  5471. --权限
  5472. SET @SQL = @SQL + ' AND a.ManagerUserId IN (
  5473. SELECT ID FROM dbo.LowerUser(' + LTRIM(STR(@CurManagerUserID)) + ', ' + LTRIM(STR(@Privi)) + '))
  5474. ORDER BY BeginTime'
  5475. --PRINT(@SQL)
  5476. EXEC (@SQL)
  5477. END
  5478. GO
  5479. /****** Object: StoredProcedure [dbo].[bpCpActivationLogByCountDateSelect] Script Date: 2018/12/13 19:03:50 ******/
  5480. SET ANSI_NULLS ON
  5481. GO
  5482. SET QUOTED_IDENTIFIER ON
  5483. GO
  5484. --创建人 Andy
  5485. --时间 2015-01-23
  5486. --按照条件获取企业登录间隔
  5487. CREATE PROCEDURE [dbo].[bpCpActivationLogByCountDateSelect]
  5488. (
  5489. @BeginDate VARCHAR(8), --格式20140101
  5490. @EndDate VARCHAR(8) --格式20140101
  5491. )
  5492. AS
  5493. BEGIN
  5494. SET @BeginDate = dbo.SafeSql(@BeginDate)
  5495. SET @EndDate = dbo.SafeSql(@EndDate)
  5496. DECLARE @SQL VARCHAR(1000)
  5497. SET @SQL = 'SELECT TOP 2000 * FROM LogDb..CpActivationLog Where 1=1 '
  5498. IF LEN(@BeginDate) > 0
  5499. SET @SQL = @SQL + ' And CountDate >= ''' + @BeginDate + ''''
  5500. IF LEN(@EndDate) > 0
  5501. SET @SQL = @SQL + ' And CountDate <= ''' + @EndDate + ''''
  5502. --PRINT(@SQL)
  5503. EXEC (@SQL)
  5504. END
  5505. GO
  5506. /****** Object: StoredProcedure [dbo].[bpCpActivationLogByStatisticsSelect] Script Date: 2018/12/13 19:03:51 ******/
  5507. SET ANSI_NULLS ON
  5508. GO
  5509. SET QUOTED_IDENTIFIER ON
  5510. GO
  5511. --bpCpActivationLogByStatisticsSelect --'20120101','20150101'
  5512. --创建人 Andy
  5513. --时间 2015-01-23
  5514. --按照条件统计企业登录间隔
  5515. CREATE PROCEDURE [dbo].[bpCpActivationLogByStatisticsSelect]
  5516. (
  5517. @BeginDate VARCHAR(8), --格式20140101
  5518. @EndDate VARCHAR(8) --格式20140101
  5519. )
  5520. AS
  5521. BEGIN
  5522. SET @BeginDate = dbo.SafeSql(@BeginDate)
  5523. SET @EndDate = dbo.SafeSql(@EndDate)
  5524. DECLARE @SQL VARCHAR(1000)
  5525. SET @SQL = 'SELECT SUM(day1) day1, SUM(day2) day2, SUM(day3) day3, SUM(day7) day7, SUM(day15) day15, SUM(day30) day30, SUM(dayOther) dayOther
  5526. FROM LogDb..CpActivationLog
  5527. Where 1 = 1'
  5528. IF LEN(@BeginDate) > 0
  5529. SET @SQL = @SQL + ' And CountDate >= ''' + @BeginDate + ''''
  5530. IF LEN(@EndDate) > 0
  5531. SET @SQL = @SQL + ' And CountDate <= ''' + @EndDate + ''''
  5532. --PRINT(@SQL)
  5533. EXEC (@SQL)
  5534. END
  5535. GO
  5536. /****** Object: StoredProcedure [dbo].[bpcpAttachmentByCpMainIDSelect] Script Date: 2018/12/13 19:03:51 ******/
  5537. SET ANSI_NULLS ON
  5538. GO
  5539. SET QUOTED_IDENTIFIER ON
  5540. GO
  5541. --根据cpmainid获取单位资料 Lucifer 2014-12-9
  5542. CREATE PROCEDURE [dbo].[bpcpAttachmentByCpMainIDSelect]
  5543. (
  5544. @cpMainID INT
  5545. )
  5546. AS
  5547. BEGIN
  5548. SELECT TOP 10 * FROM cpAttachment WHERE cpMainID=@cpMainID
  5549. END
  5550. GO
  5551. /****** Object: StoredProcedure [dbo].[bpcpAttachmentInsert] Script Date: 2018/12/13 19:03:51 ******/
  5552. SET ANSI_NULLS ON
  5553. GO
  5554. SET QUOTED_IDENTIFIER ON
  5555. GO
  5556. --添加单位资料 Lucifer 2014-12-9
  5557. CREATE PROCEDURE [dbo].[bpcpAttachmentInsert]
  5558. (
  5559. @cpMainID INT,
  5560. @FileName VARCHAR(50),
  5561. @AddMan SMALLINT
  5562. )
  5563. AS
  5564. BEGIN
  5565. INSERT INTO cpAttachment(cpMainID,FileName,AddMan) VALUES(@cpMainID,@FileName,@AddMan)
  5566. END
  5567. GO
  5568. /****** Object: StoredProcedure [dbo].[bpCpCoinByCaOrderInsert] Script Date: 2018/12/13 19:03:51 ******/
  5569. SET ANSI_NULLS ON
  5570. GO
  5571. SET QUOTED_IDENTIFIER ON
  5572. GO
  5573. --订单积分添加 Lucifer 2014-12-24
  5574. CREATE PROCEDURE [dbo].[bpCpCoinByCaOrderInsert]
  5575. (
  5576. @OrderID INT,
  5577. @cpMainID INT,
  5578. @OrderType TINYINT
  5579. )
  5580. AS
  5581. SET NOCOUNT ON
  5582. BEGIN
  5583. DECLARE @CoinRation NUMERIC(18, 2), @Paid NUMERIC(18, 2), @GivePoint INT
  5584. IF @OrderType = 1
  5585. BEGIN
  5586. SELECT TOP 1 @CoinRation = a.CoinRation, @Paid = c.Paid, @GivePoint = b.GivePoint
  5587. FROM dcVip a, dcVipdetail b, caOrder c
  5588. WHERE c.dcFeeDetailID = b.ID AND b.dcVipID=a.ID AND c.ID = @OrderID
  5589. END
  5590. ELSE
  5591. BEGIN
  5592. SELECT TOP 1 @CoinRation = a.CoinRation, @Paid = c.Paid
  5593. FROM dcFee a,dcFeedetail b,caOrder c
  5594. WHERE c.dcFeeDetailID = b.id AND b.dcFeeID=a.ID AND c.ID = @OrderID
  5595. END
  5596. IF NOT EXISTS(SELECT 'X' FROM cpCoin WHERE caOrderID = @OrderID AND Coin > 0)
  5597. BEGIN
  5598. INSERT INTO cpCoin(cpMainID, caOrderID, Coin, AddDate)
  5599. VALUES(@cpMainID, @OrderID, @CoinRation * @Paid, GETDATE())
  5600. END
  5601. IF @GivePoint > 0
  5602. BEGIN
  5603. INSERT INTO cpPoint (cpMainID, changeID, Point, relativeID, lastModifyDate)
  5604. SELECT @cpMainID, 23, @GivePoint, @OrderID, GETDATE()
  5605. UPDATE caOrder SET GivePoint = @GivePoint WHERE Id = @OrderId
  5606. END
  5607. END
  5608. GO
  5609. /****** Object: StoredProcedure [dbo].[bpCpCompanyEmailUpdateByVerify] Script Date: 2018/12/13 19:03:51 ******/
  5610. SET ANSI_NULLS ON
  5611. GO
  5612. SET QUOTED_IDENTIFIER ON
  5613. GO
  5614. --企业邮箱审核
  5615. CREATE PROCEDURE [dbo].[bpCpCompanyEmailUpdateByVerify]
  5616. (
  5617. @cpCompanyEmailID INT,
  5618. @CheckResult INT,
  5619. @CheckMan INT,
  5620. @CheckMessage VARCHAR(100)
  5621. )
  5622. AS
  5623. BEGIN
  5624. DECLARE @cpCertificationID INT
  5625. SELECT TOP 1 @cpCertificationID = cpCertificationID
  5626. FROM cpCompanyEmail WITH(NOLOCK)
  5627. WHERE ID = @cpCompanyEmailID
  5628. IF @cpCertificationID IS NULL
  5629. RETURN
  5630. UPDATE cpCompanyEmail
  5631. SET CheckResult = @CheckResult,CheckMan = @CheckMan,CheckDate = GETDATE(),CheckMessage = @CheckMessage
  5632. WHERE ID = @cpCompanyEmailID
  5633. IF @CheckResult = 1
  5634. BEGIN
  5635. UPDATE MainDB..cpCertification
  5636. SET CerStatus = 1
  5637. WHERE ID = @cpCertificationID
  5638. END
  5639. ELSE
  5640. BEGIN
  5641. INSERT INTO SmsMessageLog (SendMan, caMainId, Mobile, Msg, MsgType, IsCat)
  5642. SELECT TOP 1 @CheckMan, b.ID, a.Mobile, '您的企业邮箱认证未通过,请登录' + d.WebSiteName + '(www.' + d.ProvinceDomain + ')进行查看', 50, 0
  5643. FROM cpCertification a WITH(NOLOCK)
  5644. INNER JOIN caMain b WITH(NOLOCK) ON a.cpMainID = b.cpMainID
  5645. INNER JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID
  5646. INNER JOIN dcProvince d WITH(NOLOCK) ON c.dcProvinceID = d.ID
  5647. WHERE a.ID = @cpCertificationID AND b.AccountType = 1
  5648. INSERT INTO rtxnotifylog
  5649. SELECT ISNULL(ConsultantID,0),'邮箱审核不通过提醒',Name+'('+LTRIM(STR(ID))+')企业邮箱审核未通过!http://sysback.51rc.com/newoa/company/cp/cpMainInfo?id=' + LTRIM(STR(ID)) + '&code=' + LTRIM(STR(DATEPART(HOUR, RegDate) * 100 + DATEPART(MINUTE, RegDate))),1,0,0,null,getdate()
  5650. FROM cpMain WITH(NOLOCK)
  5651. WHERE ID = (SELECT CpMainID FROM MainDB..cpCertification WITH(NOLOCK) WHERE id = @cpCertificationID)
  5652. END
  5653. END
  5654. GO
  5655. /****** Object: StoredProcedure [dbo].[bpCpImageByCpIDSelect] Script Date: 2018/12/13 19:03:51 ******/
  5656. SET ANSI_NULLS ON
  5657. GO
  5658. SET QUOTED_IDENTIFIER ON
  5659. GO
  5660. -- =============================================
  5661. -- Author: <Mice 123>
  5662. -- Create date: <2015-1-19>
  5663. -- Description: <企业图片查询>
  5664. -- =============================================
  5665. CREATE PROCEDURE [dbo].[bpCpImageByCpIDSelect]
  5666. (
  5667. @CpMainID VARCHAR(50),
  5668. @ImgType INT --3企业环境照片
  5669. )
  5670. AS
  5671. BEGIN
  5672. SELECT TOP 20 a.*, b.Name AS cpName
  5673. FROM cpImage a, cpMain b
  5674. WHERE a.cpMainID = b.id
  5675. AND a.cpMainID = @CpMainID
  5676. AND a.ImgType = CONVERT(VARCHAR(2),@ImgType)
  5677. END
  5678. GO
  5679. /****** Object: StoredProcedure [dbo].[bpcpImageByEnviUpdate] Script Date: 2018/12/13 19:03:52 ******/
  5680. SET ANSI_NULLS ON
  5681. GO
  5682. SET QUOTED_IDENTIFIER ON
  5683. GO
  5684. CREATE PROCEDURE [dbo].[bpcpImageByEnviUpdate]
  5685. (
  5686. @ID INT,
  5687. @cpMainID INT,
  5688. @HasPassed BIT,
  5689. @CheckMan INT,
  5690. @CheckMessage VARCHAR(500),
  5691. @imgType varchar(50)
  5692. )
  5693. AS
  5694. SET NOCOUNT ON
  5695. BEGIN
  5696. --插入审核延误记录表
  5697. INSERT INTO logdb..VerifyDelayLog(verifyType, relationId, submitDate, verifyDate, verifyMan)
  5698. SELECT 6,@ID,(SELECT AddDate FROM cpImage WHERE cpMainID=@cpMainID AND ID = @ID), GETDATE(), @CheckMan
  5699. IF @HasPassed = 1
  5700. BEGIN
  5701. UPDATE Maindb..cpImage
  5702. SET HasPassed = @HasPassed,
  5703. CheckMan = @CheckMan ,
  5704. Description = @CheckMessage,
  5705. CheckDate = GETDATE()
  5706. WHERE cpMainID=@cpMainID AND ID=@ID
  5707. END
  5708. ELSE
  5709. BEGIN
  5710. UPDATE Maindb..cpImage
  5711. SET HasPassed = @HasPassed,
  5712. CheckMan = @CheckMan ,
  5713. CheckMessage = @CheckMessage,
  5714. CheckDate = GETDATE()
  5715. WHERE cpMainID=@cpMainID AND ID=@ID
  5716. END
  5717. if @HasPassed = 1 ---审核通过
  5718. BEGIN
  5719. if @imgType='3'
  5720. INSERT INTO cpPoint(cpMainID, ChangeID, Point, LastModifyDate) VALUES(@cpMainID, 25, 10, GETDATE())
  5721. else if @imgType='4,5'
  5722. INSERT INTO cpPoint(cpMainID, ChangeID, Point, LastModifyDate) VALUES(@cpMainID, 26, 100, GETDATE())
  5723. END
  5724. END
  5725. GO
  5726. /****** Object: StoredProcedure [dbo].[bpCpImageByFileNameUpdate] Script Date: 2018/12/13 19:03:52 ******/
  5727. SET ANSI_NULLS ON
  5728. GO
  5729. SET QUOTED_IDENTIFIER ON
  5730. GO
  5731. -- =============================================
  5732. -- Author: <Mice 123>
  5733. -- Create date: <2015-1-19>
  5734. -- Description: <企业环境照片更新>
  5735. ---增加审核记录,用于计算审核延误6
  5736. -- =============================================
  5737. CREATE PROCEDURE [dbo].[bpCpImageByFileNameUpdate]
  5738. (
  5739. @ImgID VARCHAR(50),
  5740. @FileName VARCHAR(100),
  5741. @PhotoDesc NVARCHAR(100),
  5742. @ManageruserID INT
  5743. )
  5744. AS
  5745. SET NOCOUNT ON
  5746. BEGIN
  5747. UPDATE Maindb..cpImage
  5748. SET ImgFile = @FileName, AddDate = getDate() ,
  5749. HasPassed = 1, CheckMan = @ManageruserID,
  5750. CheckDate = GETDATE(), CheckMessage = NULL,
  5751. Description = @PhotoDesc
  5752. WHERE ID = @ImgID
  5753. --插入审核延误记录表
  5754. INSERT INTO logdb..VerifyDelayLog(verifyType, relationId, submitDate, verifyDate, verifyMan)
  5755. SELECT 6,@ImgID,(SELECT AddDate FROM cpImage WHERE ID = @ImgID), GETDATE(), @ManageruserID
  5756. END
  5757. GO
  5758. /****** Object: StoredProcedure [dbo].[bpCpImageByHasVisualSelect] Script Date: 2018/12/13 19:03:52 ******/
  5759. SET ANSI_NULLS ON
  5760. GO
  5761. SET QUOTED_IDENTIFIER ON
  5762. GO
  5763. --###########################
  5764. --创建时间:2014.11.27
  5765. --创建人:Nick
  5766. --说明:获取后台审核形象图
  5767. --###########################
  5768. CREATE PROCEDURE [dbo].[bpCpImageByHasVisualSelect]
  5769. (
  5770. @WHERE VARCHAR(2000),
  5771. @TypeID INT --1等待审核、2最近审核通过 3 最近审核未通过
  5772. )
  5773. AS
  5774. BEGIN
  5775. DECLARE @SQL VARCHAR(MAX)
  5776. IF @TypeID = 1
  5777. BEGIN
  5778. SET @SQL = '
  5779. SELECT a.ID ImageID,a.AddDate,b.ID,b.Name companyname,b.RegDate
  5780. FROM cpImage a With(Nolock),cpMain b With(Nolock)
  5781. WHERE a.cpMainID=b.ID
  5782. AND a.HasPassed Is Null
  5783. AND a.AddDate<DateAdd(mi, -40, GetDate())
  5784. AND a.ImgType=2
  5785. AND b.IsDelete=0
  5786. AND b.IsLimitLogin<>9
  5787. AND a.adddate < CONVERT(datetime, CONVERT(varchar(100), GETDATE(), 111)+'' 16:51'')
  5788. '+@WHERE + ' Order By a.AddDate'
  5789. END
  5790. ELSE IF @TypeID = 2
  5791. BEGIN
  5792. SET @SQL = '
  5793. SELECT a.ID imageid,a.CheckDate,b.id,b.Name companyname,a.ImgFile,b.RegDate,a.CheckMan
  5794. FROM cpImage a With(Nolock),cpMain b With(Nolock)
  5795. WHERE ImgType=2
  5796. AND a.cpMainID=b.ID
  5797. AND b.HasVisual=1
  5798. AND b.Isdelete<>1
  5799. AND HasPassed=1
  5800. '+@WHERE + ' ORDER BY a.CheckDate DESC'
  5801. END
  5802. ELSE IF @TypeID = 3
  5803. BEGIN
  5804. SET @SQL = '
  5805. SELECT TOP 100 a.ID ImageID,b.ID,b.Name,a.CheckDate,CheckMessage,ImgFile,CheckMan,b.RegDate
  5806. FROM cpImage a With(Nolock),cpMain b With(Nolock)
  5807. WHERE a.cpMainID=b.ID
  5808. AND b.HasVisual=0
  5809. AND a.ImgType=2
  5810. AND HasPassed=0
  5811. AND b.Isdelete<>1
  5812. '+@WHERE + ' Order By a.CheckDate Desc'
  5813. END
  5814. EXEC(@SQL)
  5815. END
  5816. GO
  5817. /****** Object: StoredProcedure [dbo].[bpCpImageByIDUpdate] Script Date: 2018/12/13 19:03:52 ******/
  5818. SET ANSI_NULLS ON
  5819. GO
  5820. SET QUOTED_IDENTIFIER ON
  5821. GO
  5822. --Peter 2014-08-25 修改
  5823. --审核通过Logo和形象图 添加积分记录
  5824. CREATE PROCEDURE [dbo].[bpCpImageByIDUpdate]
  5825. (
  5826. @ID INT,
  5827. @cpMainID INT,
  5828. @ImgType INT,
  5829. @HasPassed BIT,
  5830. @CheckMan INT,
  5831. @CheckMessage VARCHAR(500)
  5832. )
  5833. AS
  5834. BEGIN TRY
  5835. UPDATE cpImage
  5836. SET HasPassed = @HasPassed,
  5837. CheckMan = @CheckMan ,
  5838. CheckMessage = @CheckMessage,
  5839. CheckDate = GETDATE()
  5840. WHERE cpMainID=@cpMainID AND ImgType = @ImgType AND ID=@ID
  5841. IF @ImgType = 1
  5842. BEGIN
  5843. UPDATE cpMain SET HasLogo = @HasPassed WHERE ID = @cpMainID
  5844. IF @HasPassed = 1
  5845. IF NOT EXISTS (SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND HasLogo = 1) --之前没有审核通过的形象图
  5846. IF NOT EXISTS(SELECT 'x' FROM cpPoint WHERE cpMainID = @cpMainID AND ChangeId = 7 AND Point = 1000)
  5847. INSERT INTO cpPoint(cpMainID, ChangeID, Point, LastModifyDate) --插入积分记录
  5848. VALUES(@cpMainID, 7, CASE WHEN GETDATE() < '2017-4-26' THEN 1000 ELSE 10 END, GETDATE())
  5849. END
  5850. ELSE IF @ImgType = 2
  5851. BEGIN
  5852. IF @HasPassed = 1
  5853. IF NOT EXISTS (SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND HasVisual = 1) --之前没有审核通过的形象图
  5854. INSERT INTO cpPoint (cpMainID, ChangeID, Point, LastModifyDate) --插入积分记录
  5855. VALUES(@cpMainID, 9, 10, GETDATE())
  5856. UPDATE cpMain SET HasVisual = @HasPassed WHERE ID = @cpMainID
  5857. IF EXISTS(SELECT 'X' FROM cpImage WHERE cpMainID=@cpMainID AND HasPassed=1 AND ImgType=@ImgType)
  5858. UPDATE cpMain SET HasVisual = 1 WHERE ID = @cpMainID
  5859. END
  5860. --短信发送
  5861. IF @ImgType = 1
  5862. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  5863. SELECT @CheckMan, NULL, NULL, a.ID, a.Mobile,
  5864. CASE @HasPassed
  5865. WHEN 1 THEN 2
  5866. ELSE 3
  5867. END
  5868. ,0,
  5869. CASE @HasPassed
  5870. WHEN 1 THEN
  5871. IsNULL(a.Name,'') + '您好,您在' + c.subsitename + c.EmailSite + '上传的logo已通过审核,祝您招聘顺利'
  5872. ELSE
  5873. IsNULL(a.Name,'') + '您好,您在' + c.subsitename + c.EmailSite + '上传的logo未通过审核,请您及时登录网站修改,以免耽误使用'
  5874. END
  5875. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK), dcSubSite c WITH(NOLOCK)
  5876. WHERE a.cpMainID = b.ID
  5877. AND b.dcSubSiteID = c.ID
  5878. AND a.AccountType = 1
  5879. AND a.Mobile > ''
  5880. AND b.ID = @cpMainID
  5881. AND a.IsReceiveSms = 1
  5882. ELSE
  5883. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  5884. SELECT @CheckMan, NULL, NULL, a.ID, a.Mobile,
  5885. CASE @HasPassed
  5886. WHEN 1 THEN 4
  5887. ELSE 5
  5888. END
  5889. ,0,
  5890. CASE @HasPassed
  5891. WHEN 1 THEN
  5892. IsNULL(a.Name,'') + '您好,您在' + c.subsitename + c.EmailSite + '上传的形象图已通过审核,祝您招聘顺利'
  5893. ELSE
  5894. IsNULL(a.Name,'') + '您好,您在' + c.subsitename + c.EmailSite + '上传的形象图未通过审核,请您及时登录网站修改,以免耽误使用'
  5895. END
  5896. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK), dcSubSite c WITH(NOLOCK)
  5897. WHERE a.cpMainID = b.ID
  5898. AND b.dcSubSiteID = c.ID
  5899. AND a.AccountType = 1
  5900. AND a.Mobile > ''
  5901. AND b.ID = @cpMainID
  5902. AND a.IsReceiveSms = 1
  5903. END TRY
  5904. BEGIN CATCH
  5905. GOTO ERR
  5906. END CATCH
  5907. RETURN 1
  5908. ERR:
  5909. BEGIN
  5910. RETURN 0
  5911. END